Skip to content

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

Merged
ArunBala-Bitgo merged 1 commit intomasterfrom
CECHO-606
Apr 1, 2026
Merged

fix(sdk-coin-sol): fix decimalPlaces falsy check in solInstructionsFactory#8381
ArunBala-Bitgo merged 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 6 times, most recently from 6e2dadc to 17b8ab5 Compare March 31, 2026 09:34
@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
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>
Copy link
Copy Markdown
Contributor

@mullapudipruthvik mullapudipruthvik left a comment

Choose a reason for hiding this comment

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

Code review

No issues found. Checked for: CLAUDE.md compliance, bugs, error handling, security, bot-specific failure modes, database operations, code comment accuracy.

This PR looks safe to approve — small, trivial change with no logic modifications.

@ArunBala-Bitgo ArunBala-Bitgo merged commit 72c6673 into master Apr 1, 2026
21 checks passed
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.

2 participants