@@ -117,20 +117,20 @@ async function main() {
117117 const receipt = await tx . wait ( ) ;
118118 console . log ( `Confirmed in block ${ receipt . blockNumber } ` ) ;
119119
120- // Parse GreetingSent event
121- let vaaSequence : bigint | undefined ;
120+ // Parse GreetingSent event (filter by contract address, then decode)
122121 const iface = new ethers . Interface ( ABI ) ;
123- for ( const log of receipt . logs ) {
124- try {
125- const parsed = iface . parseLog ( { topics : log . topics as string [ ] , data : log . data } ) ;
126- if ( parsed ?. name === 'GreetingSent' ) {
127- vaaSequence = BigInt ( parsed . args [ 2 ] ) ;
128- console . log ( `\nGreetingSent event:` ) ;
129- console . log ( ` Message: ${ parsed . args [ 0 ] } ` ) ;
130- console . log ( ` Target Chain: ${ parsed . args [ 1 ] } ` ) ;
131- console . log ( ` Sequence: ${ vaaSequence } ` ) ;
132- }
133- } catch { }
122+ const sentEvent = receipt . logs
123+ . filter ( log => log . address . toLowerCase ( ) === HELLO_WORMHOLE_OC . toLowerCase ( ) )
124+ . map ( log => iface . parseLog ( { topics : log . topics as string [ ] , data : log . data } ) )
125+ . find ( event => event ?. name === 'GreetingSent' ) ;
126+
127+ let vaaSequence : bigint | undefined ;
128+ if ( sentEvent ) {
129+ vaaSequence = BigInt ( sentEvent . args [ 2 ] ) ;
130+ console . log ( `\nGreetingSent event:` ) ;
131+ console . log ( ` Message: ${ sentEvent . args [ 0 ] } ` ) ;
132+ console . log ( ` Target Chain: ${ sentEvent . args [ 1 ] } ` ) ;
133+ console . log ( ` Sequence: ${ vaaSequence } ` ) ;
134134 }
135135
136136 // Poll executor status
0 commit comments