Skip to content

fix(sdk-coin-sol): fix decimalPlaces falsy check in solInstructionsFactory#8381

Open
ArunBala-Bitgo wants to merge 1 commit intomasterfrom
CECHO-606
Open

fix(sdk-coin-sol): fix decimalPlaces falsy check in solInstructionsFactory#8381
ArunBala-Bitgo wants to merge 1 commit intomasterfrom
CECHO-606

Conversation

@ArunBala-Bitgo
Copy link
Copy Markdown
Contributor

@ArunBala-Bitgo ArunBala-Bitgo commented Mar 31, 2026

Solana unsupported SPL NFTs with 0 decimal places 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 "Invalid token name".

Replace truthy checks with !=null in this location:

  • solInstructionFactory.ts tokenTransferInstruction()

TICKET: CECHO-606

@ArunBala-Bitgo ArunBala-Bitgo requested a review from a team as a code owner March 31, 2026 09:12
@ArunBala-Bitgo ArunBala-Bitgo force-pushed the CECHO-606 branch 5 times, most recently from 3b82f12 to 6e2dadc Compare March 31, 2026 09:33
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>
@ArunBala-Bitgo ArunBala-Bitgo changed the title fix(sdk-coin-sol): fix same decimalPlaces falsy check in solInstructions fix(sdk-coin-sol): fix decimalPlaces falsy check in solInstructionsFactory Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant