setBridge.js 1.2 KB

12345678910111213141516171819202122232425
  1. const CONFIG = require("../constants/config.json")
  2. task("setBridge", "connect the local stargate to a remote stargate by configuring the remote bridge")
  3. .addParam("local", "the local bridge address")
  4. .addParam("dstChainId", "the LayerZero chainId of the remote bridge")
  5. .addParam("bridge", "the remote bridge address")
  6. .setAction(async (taskArgs) => {
  7. let accounts = await ethers.getSigners()
  8. let owner = accounts[0] // me
  9. // console.log(`owner: ${owner.address}`);
  10. let Bridge = await ethers.getContractFactory("Bridge")
  11. let bridge = await Bridge.attach(taskArgs.local)
  12. let numFunctionTypes = 4
  13. for (let functionType = 1; functionType <= numFunctionTypes; ++functionType) {
  14. // function setGasAmount(uint16 _chainId, uint8 _functionType, uint _gasAmount)
  15. let gasAmount = CONFIG.gasAmounts[functionType]
  16. await (await bridge.setGasAmount(taskArgs.dstChainId, functionType, gasAmount)).wait()
  17. console.log(`bridge.setGasAmount(chainId:${taskArgs.dstChainId}, functionType:${functionType}, gasAmount:${gasAmount}`)
  18. }
  19. let tx = await bridge.setBridge(taskArgs.dstChainId, taskArgs.bridge)
  20. console.log(`tx.hash: ${tx.hash}`)
  21. })