fix(sdk-coin-sol): fix decimalPlaces falsy check in solInstructionsFactory#8381
Open
ArunBala-Bitgo wants to merge 1 commit intomasterfrom
Open
fix(sdk-coin-sol): fix decimalPlaces falsy check in solInstructionsFactory#8381ArunBala-Bitgo wants to merge 1 commit intomasterfrom
ArunBala-Bitgo wants to merge 1 commit intomasterfrom
Conversation
3b82f12 to
6e2dadc
Compare
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>
6e2dadc to
17b8ab5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.decimalPlacesevaluates to false even whendecimalPlaces 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
!=nullin this location:TICKET: CECHO-606