Skip to content

Commit

Permalink
support query events
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoAtwill committed Nov 29, 2024
1 parent d03dce8 commit 8a730f8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions contracts/tasks/cross-network-messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,25 @@ task('cross-network-send')
const contract = contracts.contracts.CrossMessengeCaller
await contract.invokeSendMessage(subnetId, args.recipient, amount, { value: Number(amount) })
})

// step 3. check result
// sample command: pnpm exec hardhat cross-network-scan --network calibrationnet 314159
task('cross-network-scan')
.setDescription('Scan cross network send in the target subnet')
.setAction(async (args: TaskArguments, hre: HardhatRuntimeEnvironment) => {
await hre.run('compile')

const subnetId = { root: args.root, route: args.route.split(',') }
console.log('sending to subnet', subnetId)

const amount = hre.ethers.utils.parseEther(args.value)
console.log('sending to address', args.recipient, 'with amount', amount)

const contracts = await Deployments.resolve(hre, 'CrossMessengeCaller')
const contract = contracts.contracts.CrossMessengeCaller
const received = contract.filters.CallReceived()
const events = await contract.queryFilter(received)
for (const event of events) {
console.log(event);
}
})

0 comments on commit 8a730f8

Please sign in to comment.