Skip to content

Commit 6e2dadc

Browse files
fix(sdk-coin-sol): handle zero decimalPlaces in token transfer builders
Solana SPL tokens with 0 decimal places (e.g. NFTs) fail during pending approval because decimalPlaces is checked with a truthy comparison. In JavaScript, 0 is falsy, so the condition `data.params.decimalPlaces` evaluates to false even when decimalPlaces is explicitly set to 0. This causes the code to skip the sendParams/data.params branch, fall through to the token registry lookup (which fails for unsupported tokens), and throw "Could not determine token information" or "Invalid token name". Use `!= null` instead of truthy checks to correctly handle 0 as a valid value while rejecting both null and undefined. This is one of the standard cases where loose equality is preferred over strict. Changed in three locations: - tokenTransferBuilder.ts buildImplementation() - transferBuilderV2.ts buildImplementation() - solInstructionFactory.ts tokenTransferInstruction() TICKET: CECHO-606 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4a311fc commit 6e2dadc

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

modules/sdk-coin-sol/src/lib/solInstructionFactory.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ function tokenTransferInstruction(data: TokenTransfer): TransactionInstruction[]
196196
let tokenAddress: string;
197197
let programId: string | undefined;
198198
let decimalPlaces: number;
199-
if (data.params.tokenAddress && data.params.decimalPlaces) {
199+
// eslint-disable-next-line eqeqeq
200+
if (data.params.tokenAddress && data.params.decimalPlaces != null) {
200201
tokenAddress = data.params.tokenAddress;
201202
decimalPlaces = data.params.decimalPlaces;
202203
programId = data.params.programId;

0 commit comments

Comments
 (0)