66
77const { ethers } = require ( 'ethers' ) ;
88
9- // Event signatures - keccak256 of event signature
9+ // Compute event signature from function signature string
10+ const computeEventSignature = ( signature ) => ethers . utils . id ( signature ) ;
11+
12+ // Event signatures - computed keccak256 hashes
1013const EVENT_SIGNATURES = {
1114 // TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData)
12- TRANSACTION_DEPOSITED : '0xb3813568d9991fc951961fcb4c784893574240a28925604d09fc577c55bb7c32' ,
13-
14- // DisputeGameCreated(address indexed disputeProxy, uint32 indexed gameType, bytes32 indexed rootClaim)
15- DISPUTE_GAME_CREATED : '0x5b565efe82411da98814f356d0e7bcb8f0c5b2c3f9e9b6b4d7f2e4e3b7b8c9a1' ,
16-
17- // OutputProposed(bytes32 indexed outputRoot, uint256 indexed l2OutputIndex, uint256 indexed l2BlockNumber, uint256 l1Timestamp)
18- OUTPUT_PROPOSED : '0xa7aaf2512769da4e444e3de247be2564225c2e7a8f74cfe528e46e17d24868e2'
19- } ;
20-
21- // Compute actual signatures to verify
22- const computeEventSignature = ( signature ) => {
23- return ethers . utils . id ( signature ) ;
24- } ;
25-
26- // Verify and update signatures (for debugging)
27- const COMPUTED_SIGNATURES = {
2815 TRANSACTION_DEPOSITED : computeEventSignature ( 'TransactionDeposited(address,address,uint256,bytes)' ) ,
16+ // DisputeGameCreated(address indexed disputeProxy, uint32 indexed gameType, bytes32 indexed rootClaim)
2917 DISPUTE_GAME_CREATED : computeEventSignature ( 'DisputeGameCreated(address,uint32,bytes32)' ) ,
18+ // OutputProposed(bytes32 indexed outputRoot, uint256 indexed l2OutputIndex, uint256 indexed l2BlockNumber, uint256 l1Timestamp)
3019 OUTPUT_PROPOSED : computeEventSignature ( 'OutputProposed(bytes32,uint256,uint256,uint256)' )
3120} ;
3221
@@ -142,7 +131,7 @@ const isTransactionDepositedEvent = (log, optimismPortalAddress) => {
142131 if ( ! log . address || ! optimismPortalAddress ) return false ;
143132
144133 return log . address . toLowerCase ( ) === optimismPortalAddress . toLowerCase ( ) &&
145- log . topics [ 0 ] . toLowerCase ( ) === COMPUTED_SIGNATURES . TRANSACTION_DEPOSITED . toLowerCase ( ) ;
134+ log . topics [ 0 ] . toLowerCase ( ) === EVENT_SIGNATURES . TRANSACTION_DEPOSITED . toLowerCase ( ) ;
146135} ;
147136
148137/**
@@ -156,7 +145,7 @@ const isDisputeGameCreatedEvent = (log, disputeGameFactoryAddress) => {
156145 if ( ! log . address || ! disputeGameFactoryAddress ) return false ;
157146
158147 return log . address . toLowerCase ( ) === disputeGameFactoryAddress . toLowerCase ( ) &&
159- log . topics [ 0 ] . toLowerCase ( ) === COMPUTED_SIGNATURES . DISPUTE_GAME_CREATED . toLowerCase ( ) ;
148+ log . topics [ 0 ] . toLowerCase ( ) === EVENT_SIGNATURES . DISPUTE_GAME_CREATED . toLowerCase ( ) ;
160149} ;
161150
162151/**
@@ -170,11 +159,11 @@ const isOutputProposedEvent = (log, l2OutputOracleAddress) => {
170159 if ( ! log . address || ! l2OutputOracleAddress ) return false ;
171160
172161 return log . address . toLowerCase ( ) === l2OutputOracleAddress . toLowerCase ( ) &&
173- log . topics [ 0 ] . toLowerCase ( ) === COMPUTED_SIGNATURES . OUTPUT_PROPOSED . toLowerCase ( ) ;
162+ log . topics [ 0 ] . toLowerCase ( ) === EVENT_SIGNATURES . OUTPUT_PROPOSED . toLowerCase ( ) ;
174163} ;
175164
176165module . exports = {
177- EVENT_SIGNATURES : COMPUTED_SIGNATURES ,
166+ EVENT_SIGNATURES ,
178167 parseTransactionDeposited,
179168 parseDisputeGameCreated,
180169 parseOutputProposed,
0 commit comments