Repository navigation
js-legacy: import Buffer explicitly instead of relying on the global - #153
Merged
joncinque merged 2 commits intoNov 21, 2026
Merged
Conversation
aelmanaa
force-pushed
the
fix/js-legacy-explicit-buffer
branch
from
November 4, 2026 18:53
bdf46f8 to
a05744b
Compare
Contributor
Author
|
@joncinque gentle ping, same as solana-program/token-2022#1612. CI is waiting for workflow approval. |
joncinque
reviewed
Nov 20, 2026
joncinque
left a comment
Contributor
There was a problem hiding this comment.
Thanks for your contribution! Just a few little points, then we can land this
Comment on lines
+63
to
+66
| it('Exposes the account discriminator as a Buffer', () => { | ||
| expect(Buffer.isBuffer(TOKEN_METADATA_DISCRIMINATOR)).to.equal(true); | ||
| expect([...TOKEN_METADATA_DISCRIMINATOR]).to.deep.equal([112, 132, 90, 90, 11, 88, 157, 87]); | ||
| }); |
Contributor
There was a problem hiding this comment.
This test is a bit useless, can you remove it?
Comment on lines
+15
to
+18
| "no-restricted-globals": [ | ||
| "error", | ||
| { "name": "Buffer", "message": "Import it from 'buffer': browsers have no global Buffer." } | ||
| ] |
Contributor
There was a problem hiding this comment.
Let's revert this part and keep things simpler
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
@joncinque thanks for the review. Both points are addressed in 194c90a: the discriminator test is removed and the oxlint rule is reverted. The PR is now only the two explicit |
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.
Fixes #152.
import { Buffer } from 'buffer'insrc/state.tsandsrc/instruction.ts, the only runtime uses of the globalbufferadded todependencies(@solana/web3.jsalready depends on it, so it dedupes for most users)Checks:
pnpm lint,pnpm format,pnpm build, and mochastate+instruction(10 passing).Browser check (first version, same
srcchange): an esbuild--platform=browserbundle callingcreateInitializeInstruction,pack/unpackand readingTOKEN_METADATA_DISCRIMINATOR, run in a context with noBufferglobal:main:ReferenceError: Buffer is not definedOn Node nothing changes:
bufferresolves to the built-in module.