Skip to content

Commit 4eba3b8

Browse files
evgenikoclaude
andcommitted
refactor: filter logs by contract address instead of try/catch
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 76d1356 commit 4eba3b8

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

e2e/sendToSolanaOnChainQuote.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)