// const { POOLS } = require("@layerzerolabs/sg-sdk") const {getEndpointId} = require("../utils/network") const {getEndpointIdByName} = require("../utils/layerzero") const {getPoolsByNetwork} = require("../utils/layerzero") task("activateChainPaths", "activate chain paths") .addParam("targetNetwork", "activate chain paths for this destination targetNetwork") .setAction(async (taskArgs) => { let router = await ethers.getContract("Router") console.log(`router.address: ${router.address}`) let pools = getPoolsByNetwork(hre.network.name); // const poolData = POOLS[hre.network.name] const mirrorgateEthVault = await ethers.getContract("MirrorgateEthVault"); pools.push({ info: { poolId: 0, address: mirrorgateEthVault.address, sharedDecimals: await mirrorgateEthVault.decimals(), }, chainPaths: [ { dstChainId: getEndpointIdByName(taskArgs.targetNetwork), dstPoolId: 0, weight: 1000, } ] }) let tx for (let pool of pools) { console.log(`mapping ${hre.network.name}[${getEndpointId()}] srcPoolId: ${pool.info.poolId}:`) let chainPaths = pool.chainPaths for (let dstObj of chainPaths) { let {dstChainId, dstPoolId, weight} = dstObj if (dstChainId != getEndpointIdByName(taskArgs.targetNetwork)) { continue } try { tx = await (await router.activateChainPath(pool.info.poolId, dstChainId, dstPoolId)).wait() console.log( ` ✅ activateChainPath: poolId:${pool.info.poolId} dstChainId:${dstChainId} dstPoolId:${dstPoolId} | tx: ${tx.transactionHash}` ) } catch (e) { if (e.error.message.includes("Stargate: chainPath is already active")) { console.log( ` ✅ activateChainPath: poolId:${pool.info.poolId} dstChainId:${dstChainId} dstPoolId:${dstPoolId} | *already exists*` ) } else { console.log(e) console.log("^ ERROR") } } } } })