Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ const decodeTx = async (
tokenTo = decodedInfo.tokenTo!;
}
await marketData
.getMarketInfoByContracts([tx.to!], network.coingeckoPlatform!)
.getMarketInfoByContracts(
[tx.to!.toLowerCase()],
network.coingeckoPlatform!,
)
.then(marketInfo => {
if (marketInfo[tx.to!]) {
currentPriceUSD = marketInfo[tx.to!]!.current_price ?? 0;
CGToken = marketInfo[tx.to!]!.id;
if (marketInfo[tx.to!.toLowerCase()]) {
currentPriceUSD =
marketInfo[tx.to!.toLowerCase()]!.current_price ?? 0;
CGToken = marketInfo[tx.to!.toLowerCase()]!.id;
}
});
} else {
Expand All @@ -82,7 +86,7 @@ const decodeTx = async (
return {
isContractCreation,
dataHex: bufferToHex(dataDecoder.data),
toAddress: tx.to!,
toAddress: tx.to!.toLowerCase(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

Crash on contract-creation transactions.

tx.to can be undefined/null (see Line 17: isContractCreation = tx.to ? false : true, and the optional toAddress?: string in DecodedTx). The ! non-null assertion is compile-time only and has no runtime effect, so calling .toLowerCase() unconditionally will throw a TypeError for every contract-creation transaction, where previously tx.to was simply passed through as-is without any method call.

🐛 Proposed fix
-    toAddress: tx.to!.toLowerCase(),
+    toAddress: tx.to?.toLowerCase(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
toAddress: tx.to!.toLowerCase(),
toAddress: tx.to?.toLowerCase(),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/extension/src/providers/ethereum/libs/transaction/decoder.ts` at
line 89, The DecodedTx mapping in decoder.ts is still calling toLowerCase on
tx.to via a non-null assertion, which will crash for contract-creation
transactions where tx.to is absent. Update the decoding logic around the tx.to
assignment so it safely handles undefined/null values, preserving the existing
behavior for contract creation by leaving toAddress unset or passing through the
missing value without invoking string methods.

decodedHex: dataDecoder.decode().values,
decoded: dataDecoder.decode().decoded,
tokenDecimals,
Expand Down
Loading