Skip to content

refactor(tokens): use kit codecs for instruction data in Token-2022 and create-token examples - #676

Open
amilz wants to merge 1 commit into
mainfrom
fix/kit-codecs-token-2022-u8-args
Open

refactor(tokens): use kit codecs for instruction data in Token-2022 and create-token examples#676
amilz wants to merge 1 commit into
mainfrom
fix/kit-codecs-token-2022-u8-args

Conversation

@amilz

@amilz amilz commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

What changed

Instruction data in these example test suites was built with the borsh package. This swaps that for @solana/kit codecs (getStructEncoder + getU8Encoder, plus addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()) for the string fields in the create-token examples), so the examples rely on a single serialization library instead of two.

  • borsh removed from dependencies in all nine packages (no borsh usage remains in any of them)
  • Lockfiles regenerated with the repo-pinned pnpm@10.33.0
  • Wire format is unchanged: kit's u32-length-prefixed UTF-8 string matches borsh's string

Follows the pattern established in #675.

Packages

  • tokens/token-2022/default-account-state/native
  • tokens/token-2022/mint-close-authority/native
  • tokens/token-2022/mint-close-authority/pinocchio
  • tokens/token-2022/non-transferable/native
  • tokens/token-2022/non-transferable/pinocchio
  • tokens/token-2022/transfer-fee/native
  • tokens/token-2022/multiple-extensions/native
  • tokens/create-token/native
  • tokens/create-token/pinocchio

Test evidence

For each package: pnpm install, tsc --noEmit, and pnpm build-and-test (cargo build-sbf + mocha/LiteSVM). All nine pass.

PASS tokens/token-2022/default-account-state/native
PASS tokens/token-2022/mint-close-authority/native
PASS tokens/token-2022/mint-close-authority/pinocchio
PASS tokens/token-2022/non-transferable/native
PASS tokens/token-2022/non-transferable/pinocchio
PASS tokens/token-2022/transfer-fee/native
PASS tokens/token-2022/multiple-extensions/native
PASS tokens/create-token/native
PASS tokens/create-token/pinocchio

prettier --check is clean on every changed file.

Part of DEV-838

…nd create-token examples

Replace the borsh instruction-data serializer with @solana/kit codecs in nine
token example test suites and drop the borsh dependency from each package.

Part of DEV-838
@amilz
amilz requested a review from dev-jodee as a code owner August 6, 2026 17:32
@linear

linear Bot commented Aug 6, 2026

Copy link
Copy Markdown

DEV-838

@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces Borsh-based instruction-data serialization with equivalent @solana/kit codecs across nine create-token and Token-2022 examples.

  • Removes the borsh dependency and corresponding lockfile entries.
  • Encodes single-byte decimal arguments with Kit struct/u8 encoders.
  • Encodes create-token strings as u32-length-prefixed UTF-8 fields.
  • The serialization layouts align with the program-side Borsh and Pinocchio parsers, but the PR commit is unsigned.

Confidence Score: 4/5

The code changes appear behaviorally sound, but the unsigned commit must be replaced with a signed, verified commit before merging.

The new codecs preserve the existing instruction wire formats, while the sole PR commit reports no signature and therefore violates the repository's mandatory commit-verification policy.

Important Files Changed

Filename Overview
tokens/create-token/native/tests/test.ts Replaces Borsh serialization with a Kit encoder whose ordered, little-endian length-prefixed fields match the native program's instruction schema.
tokens/create-token/pinocchio/tests/test.ts Uses the same compatible Kit wire format for the Pinocchio parser and preserves the instruction payload.
tokens/token-2022/mint-close-authority/native/tests/test.ts Replaces the one-byte Borsh decimal payload with an equivalent single-u8 Kit struct encoding.
tokens/token-2022/mint-close-authority/pinocchio/tests/test.ts Preserves the one-byte decimals payload expected by the Pinocchio instruction parser.
tokens/token-2022/default-account-state/native/tests/test.ts Migrates the single-u8 instruction payload to an equivalent Kit encoder.
tokens/token-2022/multiple-extensions/native/tests/test.ts Migrates the single-u8 instruction payload to an equivalent Kit encoder.
tokens/token-2022/non-transferable/native/tests/test.ts Migrates the single-u8 instruction payload to an equivalent Kit encoder.
tokens/token-2022/non-transferable/pinocchio/tests/test.ts Preserves the one-byte decimals payload expected by the Pinocchio parser.
tokens/token-2022/transfer-fee/native/tests/test.ts Migrates the single-u8 instruction payload to an equivalent Kit encoder.

Reviews (1): Last reviewed commit: "refactor(tokens): use kit codecs for ins..." | Re-trigger Greptile

"@solana-program/token": "^0.15.0",
"@solana/kit": "^7.0.0",
"borsh": "^2.0.0"
"@solana/kit": "^7.0.0"

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.

P1 Unsigned commit violates policy

Commit feb93df76b435904addf167ef7a6aa90b93c3798 has no signature, so this PR does not satisfy the repository's requirement for signed, verified commits and must be re-signed before approval.

Context Used: Request changes if the commits are not signed (ver... (source)

@amilz amilz self-assigned this Aug 6, 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.

2 participants