Skip to content

fix(js-legacy): handle uninitialized extension padding - #1610

Merged
samkim-crypto merged 1 commit into
solana-program:mainfrom
mobydih:fix/legacy-token-extension-padding
Nov 22, 2026
Merged

samkim-crypto merged 1 commit into
solana-program:mainfrom
mobydih:fix/legacy-token-extension-padding

Conversation

@mobydih

@mobydih mobydih commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Valid Token-2022 mints whose unpadded size equals Multisig::LEN end with a two-byte Uninitialized marker. The legacy JavaScript parser currently tries to read a length after that marker and throws RangeError. This also breaks getAccountLenForMint and createAccount when a keypair is supplied.

Stop before reading the length of an Uninitialized entry, and ignore a final byte that cannot contain a type, matching the Rust TLV reader. Add regression coverage for multisig-size padding, overallocated data, zero-length initialized extensions, truncated length fields, and token account sizing. This changes the legacy @solana/spl-token client.

Closes #1587.

Validation in clients/js-legacy:

  • pnpm test:unit: 119 passing. The new padding regressions failed before the parser change.
  • pnpm build, pnpm exec tsc --project tsconfig.json --noEmit, pnpm format, and pnpm lint: passed.
  • Reproduced the original failure using both mainnet mints in the issue. With the built fix, their saved account data returns [MetadataPointer, TokenMetadata], and createAccount constructs the expected instructions using an in-memory connection stub.

The validator-backed end-to-end suites have not been run locally.

@samkim-crypto samkim-crypto left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for addressing this! It looks good to me. It does seem like the CI is failing, so can you rebase so that we kick off the CI again?

@mobydih
mobydih force-pushed the fix/legacy-token-extension-padding branch from a597ee1 to 606c0e2 Compare November 21, 2026 20:08
@mobydih

mobydih commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

yep rebased. thanks

@samkim-crypto samkim-crypto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@samkim-crypto
samkim-crypto merged commit 6704f8b into solana-program:main Nov 22, 2026
46 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.

js-legacy: getExtensionTypes throws on mints with Multisig::LEN padding

2 participants