diff --git a/helix-contract/deploy/create2.js b/helix-contract/deploy/create2.js index 677a4f9..442775d 100644 --- a/helix-contract/deploy/create2.js +++ b/helix-contract/deploy/create2.js @@ -3,6 +3,7 @@ var Create2 = { getDeployedBytecode: function(factory, constructorTypes, constructorArgs) { const abiCoder = ethers.utils.defaultAbiCoder; const encodedParams = abiCoder.encode(constructorTypes, constructorArgs); + console.log(`constructor bytes: ${encodedParams.slice(2)}`); const bytecode = `${factory.bytecode}${encodedParams.slice(2)}`; return bytecode; }, diff --git a/helix-contract/deploy/deploy_bytescode.js b/helix-contract/deploy/deploy_bytescode.js index 86598ef..a6819fe 100644 --- a/helix-contract/deploy/deploy_bytescode.js +++ b/helix-contract/deploy/deploy_bytescode.js @@ -71,6 +71,13 @@ async function getxTokenIssuingProxyBridgeBytecode(networkUrl, version, logicAdd return; } +async function getLnv3ProxyBridgeBytecode(networkUrl, version, logicAddress, proxyAdminAddress) { + const w = wallet(networkUrl); + const lnv3Factory = await ethers.getContractFactory("HelixLnBridgeV3", w); + await getLnProxyBridgeBytecode(w, version, lnv3Factory, logicAddress, proxyAdminAddress, [w.address]); + return; +} + // 2. deploy mapping token factory async function main() { //await getHelixProxyAdminBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0'); @@ -78,7 +85,8 @@ async function main() { //await getDefaultBridgeBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0'); //await getLnDefaultProxyBridgeBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0', '0x8af688056c6614acb5A78c62e1f9f49022C0452f', '0x601dE3B81c7cE04BecE3b29e5cEe4F3251d250dB'); //await getLnOppositeProxyBridgeBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0', '0x90873fa1bbd028F22277567530A22E05f7721D37', '0x601dE3B81c7cE04BecE3b29e5cEe4F3251d250dB'); - await getxTokenIssuingProxyBridgeBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0', "0x2279B98741D66ccbB1a9e8c80A571378a29afCf0", "0xa3D85134B8f8dB225D54AA4C5E4A25Bda3bD50eA"); + //await getxTokenIssuingProxyBridgeBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0', "0x2279B98741D66ccbB1a9e8c80A571378a29afCf0", "0xa3D85134B8f8dB225D54AA4C5E4A25Bda3bD50eA"); + await getLnv3ProxyBridgeBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0', "0xC4Cecb7d4c0eA6c7AA88CbdE56612Cdc2DE2E756", "0xE3979fFa68BBa1F53c6F502c8F5788B370d28730"); } main() diff --git a/helix-contract/deploy/deploy_lnv3_test.js b/helix-contract/deploy/deploy_lnv3_test.js index fb877d0..8bf9873 100644 --- a/helix-contract/deploy/deploy_lnv3_test.js +++ b/helix-contract/deploy/deploy_lnv3_test.js @@ -36,7 +36,7 @@ async function lockAndRemoteRelease( sourceToken, targetToken, amount, - nonce) { + timestamp) { const bridge = await ethers.getContractAt("LnBridgeSourceV3", bridgeAddress, wallet); const expectedFee = await bridge.totalFee( remoteChainId, @@ -46,21 +46,23 @@ async function lockAndRemoteRelease( amount); console.log("expect fee is", expectedFee); const value = sourceToken == '0x0000000000000000000000000000000000000000' ? amount.add(expectedFee) : 0; + const params = [ + remoteChainId, + provider, + sourceToken, + targetToken, + expectedFee, + amount, + wallet.address, + timestamp + ]; //const tx = await bridge.callStatic.lockAndRemoteRelease( const tx = await bridge.lockAndRemoteRelease( - [ - remoteChainId, - provider, - sourceToken, - targetToken, - expectedFee, - amount, - wallet.address, - nonce - ], + params, { value: value } ); console.log(tx); + return await bridge.getTransferId(params, amount); } async function relay( @@ -73,7 +75,7 @@ async function relay( sourceAmount, targetAmount, receiver, - nonce, + timestamp, expectedTransferId, ) { const toBridge = await ethers.getContractAt("HelixLnBridgeV3", toBridgeAddress, toWallet); @@ -87,7 +89,7 @@ async function relay( sourceAmount, targetAmount, receiver, - nonce, + timestamp, ], expectedTransferId, true @@ -106,7 +108,6 @@ async function slash( targetAmount, receiver, timestamp, - nonce, expectedTransferId, expectedIdWithTimestamp, ) { @@ -123,9 +124,8 @@ async function slash( sourceAmount, targetAmount, receiver, - nonce + timestamp ], - timestamp, expectedTransferId, expectedIdWithTimestamp, cost, @@ -164,10 +164,6 @@ function wallet(network) { // 2. deploy mapping token factory async function main() { - const goerliNetwork = networks['goerli']; - const zkSyncNetwork = networks['zksync-goerli']; - const goerliWallet = wallet(goerliNetwork); - const zksyncWallet = wallet(zkSyncNetwork); const provider = '0xB2a0654C6b2D0975846968D5a3e729F5006c2894'; const pathConfig = "./address/ln-dev.json"; @@ -175,47 +171,54 @@ async function main() { fs.readFileSync(pathConfig, "utf8") ); - //const sourceToken = configure.usdc['goerli']; - //const targetToken = configure.usdc['zksync-goerli']; + const sourceNetwork = configure.chains['sepolia']; + const targetNetwork = configure.chains['arbitrum-sepolia']; + const sourceWallet = wallet(sourceNetwork); + const targetWallet = wallet(targetNetwork); + //const sourceToken = '0x0000000000000000000000000000000000000000'; //const targetToken = '0x0000000000000000000000000000000000000000'; - const sourceToken = configure.usdt['goerli']; - const targetToken = configure.usdt['zksync-goerli']; + const sourceToken = configure.usdt['sepolia']; + const targetToken = configure.usdt['arbitrum-sepolia']; + + const timestamp = Date.parse(new Date().toString())/1000; + const amount = ethers.utils.parseEther("106"); - await lockAndRemoteRelease( - goerliWallet, + const transferId = await lockAndRemoteRelease( + sourceWallet, provider, configure.LnV3BridgeProxy.others, - zkSyncNetwork.chainId, + targetNetwork.chainId, sourceToken, targetToken, - 1050000, - //ethers.utils.parseEther("0.01"), - 7); - + amount, + timestamp + ); + console.log(timestamp, transferId); + /* await relay( - goerliNetwork.chainId, - zksyncWallet, - configure.LnV3BridgeProxy.zkSync, + sourceNetwork.chainId, + targetWallet, + configure.LnV3BridgeProxy.others, provider, - configure.usdc['goerli'], - configure.usdc['zksync-goerli'], - 100000000, - ethers.utils.parseEther("100"), + sourceToken, + targetToken, + amount, + amount, "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4", - 2, - "0xec2bd3228192aff141404ad1dddb3476c9b999e18b55fd4d8c685552780f0595" //expectedTransferId, + 1704960830, + "0x110db54735ca7a73984ec654686c7ea9d6fa572fcee138ca109dda58c75d2142" //expectedTransferId, ); */ /* await requestWithdrawLiquidity( - zksyncWallet, + targetWallet, provider, - goerliNetwork.chainId, - configure.LnV3BridgeProxy.zkSync, - ["0x7cf958c470daafd85b6cce5e57cb4253e6e8f6380125052c37ac896ea58d1a59", "0xec2bd3228192aff141404ad1dddb3476c9b999e18b55fd4d8c685552780f0595"], + sourceNetwork.chainId, + configure.LnV3BridgeProxy.others, + ["0x110db54735ca7a73984ec654686c7ea9d6fa572fcee138ca109dda58c75d2142", "0x82CA1BBCFCB03E55C7F7938EFC6DF9636C72E0F628CF94488E31ED328BDF6FE4"], "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4", ); */