Skip to content

Commit

Permalink
fix OmniCounter example
Browse files Browse the repository at this point in the history
A commit was added to add a payload to the default OmniCounter.sol.  As such,
we need to `estimateFees(...)` with the new payload.  Poll the payload from the
contract and use it in the task.

Signed-off-by: Ryan Goulding <[email protected]>
  • Loading branch information
ryandgoulding committed Nov 3, 2023
1 parent 706e141 commit 30d6896
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tasks/incrementCounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ module.exports = async function (taskArgs, hre) {
const omniCounter = await ethers.getContract("OmniCounter")

// quote fee with default adapterParams
let adapterParams = ethers.utils.solidityPack(["uint16", "uint256"], [1, 200000]) // default adapterParams example
const adapterParams = ethers.utils.solidityPack(["uint16", "uint256"], [1, 200000]) // default adapterParams example

const payload = await omniCounter.PAYLOAD()
const endpoint = await ethers.getContractAt("ILayerZeroEndpoint", ENDPOINTS[hre.network.name])
let fees = await endpoint.estimateFees(remoteChainId, omniCounter.address, "0x", false, adapterParams)
const fees = await endpoint.estimateFees(remoteChainId, omniCounter.address, payload, false, adapterParams)
console.log(`fees[0] (wei): ${fees[0]} / (eth): ${ethers.utils.formatEther(fees[0])}`)

let tx = await (await omniCounter.incrementCounter(remoteChainId, { value: fees[0] })).wait()
Expand Down

0 comments on commit 30d6896

Please sign in to comment.