From 3c15a3c76c8e98e41c05046004bd8c0e71392f1c Mon Sep 17 00:00:00 2001 From: fishingpi <65535060+fishingpi@users.noreply.github.com> Date: Fri, 9 Jan 2026 23:06:41 -0500 Subject: [PATCH] Fix Solana transaction logic, SOL formatting, and add safety checks for logs --- src/lib/base.ts | 4 ++-- src/lib/solana.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/base.ts b/src/lib/base.ts index 8c72fe1..58ba247 100644 --- a/src/lib/base.ts +++ b/src/lib/base.ts @@ -653,11 +653,11 @@ export class BaseMessageDecoder { }; return decodedData.args.messageHash as Hex; } else if (this.isExecutionLog(log)) { - if (log.topics.length > 2) { + if (log.topics && log.topics.length > 2) { return log.topics[2] as Hex; } } else if (this.isMessageInitLog(log)) { - if (log.topics.length > 1) { + if (log.topics && log.topics.length > 1) { return log.topics[1] as Hex; } } diff --git a/src/lib/solana.ts b/src/lib/solana.ts index b89439b..7faf2bc 100644 --- a/src/lib/solana.ts +++ b/src/lib/solana.ts @@ -153,8 +153,10 @@ export class SolanaMessageDecoder { } const [tx1, tx2] = res; + // getSignaturesForAddress returns newest first. + // If there are two transactions, tx1 is execution and tx2 is validation. const validationTx = tx2 ?? tx1; - const executeTx = tx2 ? tx1 : tx2; + const executeTx = tx2 ? tx1 : undefined; console.log({ executeTx }); @@ -313,7 +315,7 @@ export class SolanaMessageDecoder { if (msg.localToken === SOL_ADDRESS) { asset = "SOL"; - amount = String(Number(msg.amount) / 1_000_000_000); + amount = formatUnitsString(String(msg.amount), 9); } else { // Figure out what localToken is const { amount: a, asset: ast } = await this.getSplData(