File tree Expand file tree Collapse file tree 1 file changed +28
-7
lines changed
Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -52,17 +52,38 @@ export const getConfirmationsInfo = async <
5252 contract . read . getConfirmExpiry ( ) ,
5353 publicClient . getBlockNumber ( ) ,
5454 ] ) ;
55+
5556 const confirmExpireInBlocks = confirmExpiry / AVG_BLOCK_TIME_SEC ;
5657 const fromBlock = currentBlock - confirmExpireInBlocks ;
5758
59+ const safeBlockSize = 10_000n ; // safe for rpc calls
60+ const ranges : Array < Record < 'fromBlock' | 'toBlock' , bigint > > = [ ] ;
61+
62+ for ( let start = fromBlock ; start <= currentBlock ; start += safeBlockSize ) {
63+ ranges . push ( {
64+ fromBlock : start ,
65+ toBlock :
66+ start + safeBlockSize - 1n <= currentBlock
67+ ? start + safeBlockSize - 1n
68+ : currentBlock ,
69+ } ) ;
70+ }
71+
5872 // get all logs without filtering by role, because Operator Grid uses addresses instead of roles
59- const logs = await publicClient . getContractEvents ( {
60- address : contract . address ,
61- abi : contract . abi ,
62- eventName : 'RoleMemberConfirmed' ,
63- fromBlock,
64- strict : true ,
65- } ) ;
73+ const logs = (
74+ await Promise . all (
75+ ranges . map ( ( { fromBlock, toBlock } ) =>
76+ publicClient . getContractEvents ( {
77+ address : contract . address ,
78+ abi : contract . abi ,
79+ eventName : 'RoleMemberConfirmed' ,
80+ strict : true ,
81+ fromBlock,
82+ toBlock,
83+ } ) ,
84+ ) ,
85+ )
86+ ) . flat ( ) ;
6687
6788 let confirmations = logs
6889 // filter out confirmations that are already expired
You can’t perform that action at this time.
0 commit comments