sendCreditsAll.js 1.2 KB

123456789101112131415161718192021222324252627
  1. const { CHAIN_ID } = require("@layerzerolabs/lz-sdk")
  2. const { POOLS } = require("@layerzerolabs/sg-sdk")
  3. task("sendCreditsAll", "sendCredits to each outgoing configured chainPath").setAction(async (taskArgs) => {
  4. const signers = await ethers.getSigners()
  5. const owner = signers[0]
  6. const router = await ethers.getContract("Router")
  7. let srcChainId = CHAIN_ID[hre.network.name]
  8. let srcPoolData = POOLS[hre.network.name]
  9. // console.log(srcPoolData)
  10. for (let srcPoolId in srcPoolData) {
  11. let { info, chainPaths } = srcPoolData[srcPoolId]
  12. console.log(`Source chain ${srcChainId} PoolId: ${srcPoolId}`)
  13. console.table(chainPaths)
  14. for (let chainPath of chainPaths) {
  15. let { weight, dstChainId, dstPoolId } = chainPath
  16. let tx = await (
  17. await router.sendCredits(dstChainId, srcPoolId, dstPoolId, owner.address, { value: ethers.utils.parseEther("2") })
  18. ).wait()
  19. console.log(
  20. `💸 [${hre.network.name}].sendCredits(dstChainId: ${dstChainId}, srcPoolId:${srcPoolId}, dstPoolId: ${dstPoolId}) | tx: ${tx.transactionHash}`
  21. )
  22. }
  23. }
  24. })