Skip to content

Commit 47e5f15

Browse files
authored
chore: show some more data on bridge tasks (#757)
* chore: show some more data on bridge tasks Signed-off-by: Tomás Migone <[email protected]>
1 parent 7eafa56 commit 47e5f15

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tasks/bridge/deposits.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ task(TASK_BRIDGE_DEPOSITS, 'List deposits initiated on L1GraphTokenGateway')
2525

2626
const startBlock = taskArgs.startBlock ? parseInt(taskArgs.startBlock) : 0
2727
const endBlock = taskArgs.endBlock ? parseInt(taskArgs.endBlock) : 'latest'
28-
console.log(`Searching blocks from ${startBlock} to ${endBlock}`)
28+
console.log(`Searching blocks from block ${startBlock} to block ${endBlock}`)
2929

3030
const events = (
3131
await gateway.queryFilter(gateway.filters.DepositInitiated(), startBlock, endBlock)
@@ -37,6 +37,14 @@ task(TASK_BRIDGE_DEPOSITS, 'List deposits initiated on L1GraphTokenGateway')
3737
amount: ethers.utils.formatEther(e.args.amount),
3838
}))
3939

40+
const total = events.reduce(
41+
(acc, e) => acc.add(ethers.utils.parseEther(e.amount)),
42+
ethers.BigNumber.from(0),
43+
)
44+
console.log(
45+
`Found ${events.length} deposits with a total of ${ethers.utils.formatEther(total)} GRT`,
46+
)
47+
4048
printEvents(events)
4149
})
4250

tasks/bridge/withdrawals.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ task(TASK_BRIDGE_WITHDRAWALS, 'List withdrawals initiated on L2GraphTokenGateway
2525

2626
const startBlock = taskArgs.startBlock ? parseInt(taskArgs.startBlock) : 0
2727
const endBlock = taskArgs.endBlock ? parseInt(taskArgs.endBlock) : 'latest'
28-
console.log(`Searching blocks from ${startBlock} to ${endBlock}`)
28+
console.log(`Searching blocks from block ${startBlock} to block ${endBlock}`)
2929

3030
const events = (
3131
await gateway.queryFilter(gateway.filters.WithdrawalInitiated(), startBlock, endBlock)
@@ -37,6 +37,14 @@ task(TASK_BRIDGE_WITHDRAWALS, 'List withdrawals initiated on L2GraphTokenGateway
3737
amount: ethers.utils.formatEther(e.args.amount),
3838
}))
3939

40+
const total = events.reduce(
41+
(acc, e) => acc.add(ethers.utils.parseEther(e.amount)),
42+
ethers.BigNumber.from(0),
43+
)
44+
console.log(
45+
`Found ${events.length} withdrawals for a total of ${ethers.utils.formatEther(total)} GRT`,
46+
)
47+
4048
printEvents(events)
4149
})
4250

0 commit comments

Comments
 (0)