From c33315cb2d22b9d0c96e61f12528447fdced7c02 Mon Sep 17 00:00:00 2001 From: aelmanaa Date: Sat, 31 Oct 2026 08:02:17 +0000 Subject: [PATCH 1/2] fix(js-legacy): work without a global Buffer --- clients/js-legacy/.oxlintrc.json | 6 ++- clients/js-legacy/package.json | 1 - clients/js-legacy/pnpm-lock.yaml | 44 --------------- .../js-legacy/src/actions/amountToUiAmount.ts | 1 + .../js-legacy/src/actions/uiAmountToAmount.ts | 3 +- .../src/extensions/cpiGuard/instructions.ts | 1 + .../src/extensions/cpiGuard/state.ts | 3 +- .../defaultAccountState/instructions.ts | 1 + .../extensions/defaultAccountState/state.ts | 1 + .../js-legacy/src/extensions/extensionType.ts | 1 + .../groupMemberPointer/instructions.ts | 3 +- .../extensions/groupMemberPointer/state.ts | 3 +- .../extensions/groupPointer/instructions.ts | 3 +- .../src/extensions/groupPointer/state.ts | 3 +- .../src/extensions/immutableOwner.ts | 1 + .../interestBearingMint/instructions.ts | 3 +- .../extensions/interestBearingMint/state.ts | 2 +- .../extensions/memoTransfer/instructions.ts | 1 + .../src/extensions/memoTransfer/state.ts | 3 +- .../metadataPointer/instructions.ts | 3 +- .../src/extensions/metadataPointer/state.ts | 3 +- .../src/extensions/mintCloseAuthority.ts | 3 +- .../src/extensions/nonTransferable.ts | 1 + .../src/extensions/pausable/instructions.ts | 3 +- .../src/extensions/pausable/state.ts | 3 +- .../src/extensions/permanentDelegate.ts | 3 +- .../permissionedBurn/instructions.ts | 3 +- .../src/extensions/permissionedBurn/state.ts | 3 +- .../extensions/scaledUiAmount/instructions.ts | 3 +- .../src/extensions/scaledUiAmount/state.ts | 2 +- .../src/extensions/tokenGroup/state.ts | 2 +- .../extensions/transferFee/instructions.ts | 3 +- .../src/extensions/transferFee/state.ts | 3 +- .../extensions/transferHook/instructions.ts | 3 +- .../src/extensions/transferHook/pubkeyData.ts | 1 + .../src/extensions/transferHook/seeds.ts | 1 + .../src/extensions/transferHook/state.ts | 3 +- .../src/instructions/amountToUiAmount.ts | 3 +- clients/js-legacy/src/instructions/approve.ts | 3 +- .../src/instructions/approveChecked.ts | 3 +- .../instructions/associatedTokenAccount.ts | 1 + clients/js-legacy/src/instructions/burn.ts | 3 +- .../js-legacy/src/instructions/burnChecked.ts | 3 +- .../src/instructions/closeAccount.ts | 1 + .../src/instructions/createNativeMint.ts | 1 + .../src/instructions/freezeAccount.ts | 1 + .../src/instructions/initializeAccount.ts | 1 + .../src/instructions/initializeAccount2.ts | 3 +- .../src/instructions/initializeAccount3.ts | 3 +- .../instructions/initializeImmutableOwner.ts | 1 + .../src/instructions/initializeMint.ts | 3 +- .../src/instructions/initializeMint2.ts | 3 +- .../initializeMintCloseAuthority.ts | 1 + .../src/instructions/initializeMultisig.ts | 1 + .../initializeNonTransferableMint.ts | 1 + .../initializePermanentDelegate.ts | 3 +- clients/js-legacy/src/instructions/mintTo.ts | 3 +- .../src/instructions/mintToChecked.ts | 3 +- .../js-legacy/src/instructions/reallocate.ts | 1 + clients/js-legacy/src/instructions/revoke.ts | 1 + .../src/instructions/setAuthority.ts | 3 +- .../js-legacy/src/instructions/syncNative.ts | 1 + .../js-legacy/src/instructions/thawAccount.ts | 1 + .../js-legacy/src/instructions/transfer.ts | 3 +- .../src/instructions/transferChecked.ts | 3 +- .../src/instructions/uiAmountToAmount.ts | 1 + .../src/instructions/unwrapLamports.ts | 1 + clients/js-legacy/src/layouts.ts | 54 +++++++++++++++++++ clients/js-legacy/src/serialization.ts | 3 +- clients/js-legacy/src/state/account.ts | 3 +- clients/js-legacy/src/state/mint.ts | 3 +- clients/js-legacy/src/state/multisig.ts | 3 +- clients/js-legacy/test/unit/layouts.test.ts | 47 ++++++++++++++++ clients/js-legacy/tsconfig.base.json | 1 + 74 files changed, 214 insertions(+), 90 deletions(-) create mode 100644 clients/js-legacy/src/layouts.ts create mode 100644 clients/js-legacy/test/unit/layouts.test.ts diff --git a/clients/js-legacy/.oxlintrc.json b/clients/js-legacy/.oxlintrc.json index 0750047c8..88368001f 100644 --- a/clients/js-legacy/.oxlintrc.json +++ b/clients/js-legacy/.oxlintrc.json @@ -11,14 +11,16 @@ "no-unused-vars": "off", "typescript/no-empty-object-type": "off", "typescript/consistent-type-imports": "error", - "import/extensions": ["error", "ignorePackages"] + "import/extensions": ["error", "ignorePackages"], + "no-restricted-globals": ["error", { "name": "Buffer", "message": "Import it from 'buffer': browsers have no global Buffer." }] }, "ignorePatterns": ["dist", "docs", "lib", "test-ledger"], "overrides": [ { "files": ["examples/**/*", "test/**/*"], "rules": { - "import/extensions": "off" + "import/extensions": "off", + "no-restricted-globals": "off" } } ] diff --git a/clients/js-legacy/package.json b/clients/js-legacy/package.json index 59ec6661e..e59f80fbb 100644 --- a/clients/js-legacy/package.json +++ b/clients/js-legacy/package.json @@ -60,7 +60,6 @@ }, "dependencies": { "@solana/buffer-layout": "^4.0.0", - "@solana/buffer-layout-utils": "^0.3.0", "@solana/spl-token-group": "^0.0.7", "@solana/spl-token-metadata": "^0.1.6", "buffer": "^6.0.3" diff --git a/clients/js-legacy/pnpm-lock.yaml b/clients/js-legacy/pnpm-lock.yaml index 56294f517..b29691d3b 100644 --- a/clients/js-legacy/pnpm-lock.yaml +++ b/clients/js-legacy/pnpm-lock.yaml @@ -11,9 +11,6 @@ importers: '@solana/buffer-layout': specifier: ^4.0.0 version: 4.0.1 - '@solana/buffer-layout-utils': - specifier: ^0.3.0 - version: 0.3.0(bufferutil@4.1.0)(typescript@6.0.3)(utf-8-validate@6.0.6) '@solana/spl-token-group': specifier: ^0.0.7 version: 0.0.7(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@6.0.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@6.0.3) @@ -368,10 +365,6 @@ packages: '@shikijs/vscode-textmate@10.0.2': resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==} - '@solana/buffer-layout-utils@0.3.0': - resolution: {integrity: sha512-MuQOCC1j0np1xH9yAv0ZWWfwvr7Bt7Sz4LId11Wi4wDdAmJ+lobE+vHg/mZmGcihF0BIkqVBNxGmlv8QE5DrtA==} - engines: {node: '>= 10'} - '@solana/buffer-layout@4.0.1': resolution: {integrity: sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==} engines: {node: '>=5.10'} @@ -599,16 +592,6 @@ packages: base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - bigint-buffer@1.1.5: - resolution: {integrity: sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==} - engines: {node: '>= 10.0.0'} - - bignumber.js@9.3.1: - resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==} - - bindings@1.5.0: - resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} - bn.js@5.2.5: resolution: {integrity: sha512-Vq886eXykuP5E6HcKSSStP3bJgrE6In5WKxVUvJ8XGpWWYs2xZHWqUwzCtGgEtBcxyd57KBFDPFoUfNzdaHCNg==} @@ -791,9 +774,6 @@ packages: fastq@1.18.0: resolution: {integrity: sha512-QKHXPW0hD8g4UET03SdOdunzSouc9N4AuHdsX8XNcTsuz+yYFILVNIX4l9yHABMhiEI9Db0JTTIpu0wB+Y1QQw==} - file-uri-to-path@1.0.0: - resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} - filename-reserved-regex@2.0.0: resolution: {integrity: sha512-lc1bnsSr4L4Bdif8Xb/qrtokGbq5zlsms/CYH8PP+WtCkGNF65DPiQY8vG3SakEdRn8Dlnm+gW/qWKKjS5sZzQ==} engines: {node: '>=4'} @@ -1521,18 +1501,6 @@ snapshots: '@shikijs/vscode-textmate@10.0.2': {} - '@solana/buffer-layout-utils@0.3.0(bufferutil@4.1.0)(typescript@6.0.3)(utf-8-validate@6.0.6)': - dependencies: - '@solana/buffer-layout': 4.0.1 - '@solana/web3.js': 1.99.0(bufferutil@4.1.0)(typescript@6.0.3)(utf-8-validate@6.0.6) - bigint-buffer: 1.1.5 - bignumber.js: 9.3.1 - transitivePeerDependencies: - - bufferutil - - encoding - - typescript - - utf-8-validate - '@solana/buffer-layout@4.0.1': dependencies: buffer: 6.0.3 @@ -1770,16 +1738,6 @@ snapshots: base64-js@1.5.1: {} - bigint-buffer@1.1.5: - dependencies: - bindings: 1.5.0 - - bignumber.js@9.3.1: {} - - bindings@1.5.0: - dependencies: - file-uri-to-path: 1.0.0 - bn.js@5.2.5: {} borsh@0.7.0: @@ -1947,8 +1905,6 @@ snapshots: dependencies: reusify: 1.0.4 - file-uri-to-path@1.0.0: {} - filename-reserved-regex@2.0.0: {} filenamify@4.3.0: diff --git a/clients/js-legacy/src/actions/amountToUiAmount.ts b/clients/js-legacy/src/actions/amountToUiAmount.ts index 8927853e2..fb1f9f872 100644 --- a/clients/js-legacy/src/actions/amountToUiAmount.ts +++ b/clients/js-legacy/src/actions/amountToUiAmount.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import type { Connection, Signer, TransactionError } from '@solana/web3.js'; import { PublicKey, Transaction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/actions/uiAmountToAmount.ts b/clients/js-legacy/src/actions/uiAmountToAmount.ts index e6bdaf61f..38d4bf0ea 100644 --- a/clients/js-legacy/src/actions/uiAmountToAmount.ts +++ b/clients/js-legacy/src/actions/uiAmountToAmount.ts @@ -1,4 +1,5 @@ -import { u64 } from '@solana/buffer-layout-utils'; +import { Buffer } from 'buffer'; +import { u64 } from '../layouts.js'; import type { Connection, PublicKey, Signer, TransactionError } from '@solana/web3.js'; import { Transaction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/extensions/cpiGuard/instructions.ts b/clients/js-legacy/src/extensions/cpiGuard/instructions.ts index 04e5d65f9..351706b36 100644 --- a/clients/js-legacy/src/extensions/cpiGuard/instructions.ts +++ b/clients/js-legacy/src/extensions/cpiGuard/instructions.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/extensions/cpiGuard/state.ts b/clients/js-legacy/src/extensions/cpiGuard/state.ts index b9e5682ed..7ef40cbf6 100644 --- a/clients/js-legacy/src/extensions/cpiGuard/state.ts +++ b/clients/js-legacy/src/extensions/cpiGuard/state.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { bool } from '@solana/buffer-layout-utils'; +import { bool } from '../../layouts.js'; import type { Account } from '../../state/account.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/defaultAccountState/instructions.ts b/clients/js-legacy/src/extensions/defaultAccountState/instructions.ts index 02b16d06a..e7e4d0943 100644 --- a/clients/js-legacy/src/extensions/defaultAccountState/instructions.ts +++ b/clients/js-legacy/src/extensions/defaultAccountState/instructions.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/extensions/defaultAccountState/state.ts b/clients/js-legacy/src/extensions/defaultAccountState/state.ts index bd6cb0950..ec9710f8c 100644 --- a/clients/js-legacy/src/extensions/defaultAccountState/state.ts +++ b/clients/js-legacy/src/extensions/defaultAccountState/state.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountState } from '../../state/account.js'; import type { Mint } from '../../state/mint.js'; diff --git a/clients/js-legacy/src/extensions/extensionType.ts b/clients/js-legacy/src/extensions/extensionType.ts index e4842a5e9..3feeaa3c5 100644 --- a/clients/js-legacy/src/extensions/extensionType.ts +++ b/clients/js-legacy/src/extensions/extensionType.ts @@ -1,3 +1,4 @@ +import type { Buffer } from 'buffer'; import type { AccountInfo, PublicKey } from '@solana/web3.js'; import { ACCOUNT_SIZE } from '../state/account.js'; diff --git a/clients/js-legacy/src/extensions/groupMemberPointer/instructions.ts b/clients/js-legacy/src/extensions/groupMemberPointer/instructions.ts index 21e13a62f..4cdbd8526 100644 --- a/clients/js-legacy/src/extensions/groupMemberPointer/instructions.ts +++ b/clients/js-legacy/src/extensions/groupMemberPointer/instructions.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import type { Signer } from '@solana/web3.js'; import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID, programSupportsExtensions } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/groupMemberPointer/state.ts b/clients/js-legacy/src/extensions/groupMemberPointer/state.ts index ceda20730..b8abe2c48 100644 --- a/clients/js-legacy/src/extensions/groupMemberPointer/state.ts +++ b/clients/js-legacy/src/extensions/groupMemberPointer/state.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/groupPointer/instructions.ts b/clients/js-legacy/src/extensions/groupPointer/instructions.ts index 7ebbf9ae4..f8d40ab20 100644 --- a/clients/js-legacy/src/extensions/groupPointer/instructions.ts +++ b/clients/js-legacy/src/extensions/groupPointer/instructions.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import type { Signer } from '@solana/web3.js'; import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID, programSupportsExtensions } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/groupPointer/state.ts b/clients/js-legacy/src/extensions/groupPointer/state.ts index 1f522612c..5ac46beb5 100644 --- a/clients/js-legacy/src/extensions/groupPointer/state.ts +++ b/clients/js-legacy/src/extensions/groupPointer/state.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/immutableOwner.ts b/clients/js-legacy/src/extensions/immutableOwner.ts index 72a1ce252..c00175df9 100644 --- a/clients/js-legacy/src/extensions/immutableOwner.ts +++ b/clients/js-legacy/src/extensions/immutableOwner.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; import type { Account } from '../state/account.js'; import { ExtensionType, getExtensionData } from './extensionType.js'; diff --git a/clients/js-legacy/src/extensions/interestBearingMint/instructions.ts b/clients/js-legacy/src/extensions/interestBearingMint/instructions.ts index e5de48eb7..f17e17cae 100644 --- a/clients/js-legacy/src/extensions/interestBearingMint/instructions.ts +++ b/clients/js-legacy/src/extensions/interestBearingMint/instructions.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { s16, struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import type { PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/interestBearingMint/state.ts b/clients/js-legacy/src/extensions/interestBearingMint/state.ts index b10cb3ab8..794c04b00 100644 --- a/clients/js-legacy/src/extensions/interestBearingMint/state.ts +++ b/clients/js-legacy/src/extensions/interestBearingMint/state.ts @@ -1,5 +1,5 @@ import { ns64, s16, struct } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import type { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/memoTransfer/instructions.ts b/clients/js-legacy/src/extensions/memoTransfer/instructions.ts index 65ff26528..22e50633e 100644 --- a/clients/js-legacy/src/extensions/memoTransfer/instructions.ts +++ b/clients/js-legacy/src/extensions/memoTransfer/instructions.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/extensions/memoTransfer/state.ts b/clients/js-legacy/src/extensions/memoTransfer/state.ts index 0f8a72609..4fb50ee10 100644 --- a/clients/js-legacy/src/extensions/memoTransfer/state.ts +++ b/clients/js-legacy/src/extensions/memoTransfer/state.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { bool } from '@solana/buffer-layout-utils'; +import { bool } from '../../layouts.js'; import type { Account } from '../../state/account.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/metadataPointer/instructions.ts b/clients/js-legacy/src/extensions/metadataPointer/instructions.ts index fe26b32b8..e3c1d2ecc 100644 --- a/clients/js-legacy/src/extensions/metadataPointer/instructions.ts +++ b/clients/js-legacy/src/extensions/metadataPointer/instructions.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import type { Signer } from '@solana/web3.js'; import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID, programSupportsExtensions } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/metadataPointer/state.ts b/clients/js-legacy/src/extensions/metadataPointer/state.ts index 75335fb14..7ebc8408d 100644 --- a/clients/js-legacy/src/extensions/metadataPointer/state.ts +++ b/clients/js-legacy/src/extensions/metadataPointer/state.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/mintCloseAuthority.ts b/clients/js-legacy/src/extensions/mintCloseAuthority.ts index 5f09f451a..c013e815a 100644 --- a/clients/js-legacy/src/extensions/mintCloseAuthority.ts +++ b/clients/js-legacy/src/extensions/mintCloseAuthority.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../layouts.js'; import type { PublicKey } from '@solana/web3.js'; import type { Mint } from '../state/mint.js'; import { ExtensionType, getExtensionData } from './extensionType.js'; diff --git a/clients/js-legacy/src/extensions/nonTransferable.ts b/clients/js-legacy/src/extensions/nonTransferable.ts index af9e85168..9f210cb76 100644 --- a/clients/js-legacy/src/extensions/nonTransferable.ts +++ b/clients/js-legacy/src/extensions/nonTransferable.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; import type { Account } from '../state/account.js'; import type { Mint } from '../state/mint.js'; diff --git a/clients/js-legacy/src/extensions/pausable/instructions.ts b/clients/js-legacy/src/extensions/pausable/instructions.ts index 68583478d..28ff9f5d8 100644 --- a/clients/js-legacy/src/extensions/pausable/instructions.ts +++ b/clients/js-legacy/src/extensions/pausable/instructions.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import type { Signer } from '@solana/web3.js'; import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID, programSupportsExtensions } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/pausable/state.ts b/clients/js-legacy/src/extensions/pausable/state.ts index c7ecd1ec8..bbe2bf80d 100644 --- a/clients/js-legacy/src/extensions/pausable/state.ts +++ b/clients/js-legacy/src/extensions/pausable/state.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey, bool } from '@solana/buffer-layout-utils'; +import { publicKey, bool } from '../../layouts.js'; import { PublicKey } from '@solana/web3.js'; import type { Account } from '../../state/account.js'; import type { Mint } from '../../state/mint.js'; diff --git a/clients/js-legacy/src/extensions/permanentDelegate.ts b/clients/js-legacy/src/extensions/permanentDelegate.ts index 5b1fb1ef5..1a6f5fea8 100644 --- a/clients/js-legacy/src/extensions/permanentDelegate.ts +++ b/clients/js-legacy/src/extensions/permanentDelegate.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../layouts.js'; import type { PublicKey } from '@solana/web3.js'; import type { Mint } from '../state/mint.js'; import { ExtensionType, getExtensionData } from './extensionType.js'; diff --git a/clients/js-legacy/src/extensions/permissionedBurn/instructions.ts b/clients/js-legacy/src/extensions/permissionedBurn/instructions.ts index 8ab169736..d33dfe8a0 100644 --- a/clients/js-legacy/src/extensions/permissionedBurn/instructions.ts +++ b/clients/js-legacy/src/extensions/permissionedBurn/instructions.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey, u64 } from '@solana/buffer-layout-utils'; +import { publicKey, u64 } from '../../layouts.js'; import type { PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { programSupportsExtensions, TOKEN_2022_PROGRAM_ID } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/permissionedBurn/state.ts b/clients/js-legacy/src/extensions/permissionedBurn/state.ts index 0dc65e98d..a8f948626 100644 --- a/clients/js-legacy/src/extensions/permissionedBurn/state.ts +++ b/clients/js-legacy/src/extensions/permissionedBurn/state.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/scaledUiAmount/instructions.ts b/clients/js-legacy/src/extensions/scaledUiAmount/instructions.ts index e02c915e8..06e85d5d9 100644 --- a/clients/js-legacy/src/extensions/scaledUiAmount/instructions.ts +++ b/clients/js-legacy/src/extensions/scaledUiAmount/instructions.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8, f64 } from '@solana/buffer-layout'; -import { publicKey, u64 } from '@solana/buffer-layout-utils'; +import { publicKey, u64 } from '../../layouts.js'; import { TokenInstruction } from '../../instructions/types.js'; import type { Signer } from '@solana/web3.js'; import { TransactionInstruction, PublicKey } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/extensions/scaledUiAmount/state.ts b/clients/js-legacy/src/extensions/scaledUiAmount/state.ts index 9b21242eb..b9d7b73c6 100644 --- a/clients/js-legacy/src/extensions/scaledUiAmount/state.ts +++ b/clients/js-legacy/src/extensions/scaledUiAmount/state.ts @@ -1,5 +1,5 @@ import { f64, struct } from '@solana/buffer-layout'; -import { publicKey, u64 } from '@solana/buffer-layout-utils'; +import { publicKey, u64 } from '../../layouts.js'; import { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/tokenGroup/state.ts b/clients/js-legacy/src/extensions/tokenGroup/state.ts index a0822357c..faf2b52e7 100644 --- a/clients/js-legacy/src/extensions/tokenGroup/state.ts +++ b/clients/js-legacy/src/extensions/tokenGroup/state.ts @@ -1,5 +1,5 @@ import { struct, u32 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import { PublicKey } from '@solana/web3.js'; import { unpackTokenGroup, diff --git a/clients/js-legacy/src/extensions/transferFee/instructions.ts b/clients/js-legacy/src/extensions/transferFee/instructions.ts index 46a1f55a9..ecfc44623 100644 --- a/clients/js-legacy/src/extensions/transferFee/instructions.ts +++ b/clients/js-legacy/src/extensions/transferFee/instructions.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u16, u8 } from '@solana/buffer-layout'; -import { u64 } from '@solana/buffer-layout-utils'; +import { u64 } from '../../layouts.js'; import type { AccountMeta, Signer, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { programSupportsExtensions, TOKEN_2022_PROGRAM_ID } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/transferFee/state.ts b/clients/js-legacy/src/extensions/transferFee/state.ts index bef4e9a7d..1ec2083cc 100644 --- a/clients/js-legacy/src/extensions/transferFee/state.ts +++ b/clients/js-legacy/src/extensions/transferFee/state.ts @@ -1,6 +1,7 @@ +import { Buffer } from 'buffer'; import type { Layout } from '@solana/buffer-layout'; import { struct, u16 } from '@solana/buffer-layout'; -import { publicKey, u64 } from '@solana/buffer-layout-utils'; +import { publicKey, u64 } from '../../layouts.js'; import type { PublicKey } from '@solana/web3.js'; import type { Account } from '../../state/account.js'; import type { Mint } from '../../state/mint.js'; diff --git a/clients/js-legacy/src/extensions/transferHook/instructions.ts b/clients/js-legacy/src/extensions/transferHook/instructions.ts index ab113386e..83992b12e 100644 --- a/clients/js-legacy/src/extensions/transferHook/instructions.ts +++ b/clients/js-legacy/src/extensions/transferHook/instructions.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, Commitment, Connection, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; @@ -5,7 +6,7 @@ import { programSupportsExtensions, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } fr import { TokenUnsupportedInstructionError } from '../../errors.js'; import { addSigners } from '../../instructions/internal.js'; import { TokenInstruction } from '../../instructions/types.js'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../../layouts.js'; import { createTransferCheckedInstruction } from '../../instructions/transferChecked.js'; import { createTransferCheckedWithFeeInstruction } from '../transferFee/instructions.js'; import { getMint } from '../../state/mint.js'; diff --git a/clients/js-legacy/src/extensions/transferHook/pubkeyData.ts b/clients/js-legacy/src/extensions/transferHook/pubkeyData.ts index f6e307a0d..2e5e11c51 100644 --- a/clients/js-legacy/src/extensions/transferHook/pubkeyData.ts +++ b/clients/js-legacy/src/extensions/transferHook/pubkeyData.ts @@ -1,3 +1,4 @@ +import type { Buffer } from 'buffer'; import { PUBLIC_KEY_LENGTH, PublicKey } from '@solana/web3.js'; import type { AccountMeta, Connection } from '@solana/web3.js'; import { diff --git a/clients/js-legacy/src/extensions/transferHook/seeds.ts b/clients/js-legacy/src/extensions/transferHook/seeds.ts index 230af7208..2900aad8b 100644 --- a/clients/js-legacy/src/extensions/transferHook/seeds.ts +++ b/clients/js-legacy/src/extensions/transferHook/seeds.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import type { AccountMeta, Connection } from '@solana/web3.js'; import { TokenTransferHookAccountDataNotFound, TokenTransferHookInvalidSeed } from '../../errors.js'; diff --git a/clients/js-legacy/src/extensions/transferHook/state.ts b/clients/js-legacy/src/extensions/transferHook/state.ts index b971ceac6..53e05d9b5 100644 --- a/clients/js-legacy/src/extensions/transferHook/state.ts +++ b/clients/js-legacy/src/extensions/transferHook/state.ts @@ -1,9 +1,10 @@ +import { Buffer } from 'buffer'; import { blob, greedy, seq, struct, u32, u8 } from '@solana/buffer-layout'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; import type { AccountInfo, AccountMeta, Connection } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; -import { bool, publicKey, u64 } from '@solana/buffer-layout-utils'; +import { bool, publicKey, u64 } from '../../layouts.js'; import type { Account } from '../../state/account.js'; import { TokenTransferHookAccountNotFound } from '../../errors.js'; import { unpackSeeds } from './seeds.js'; diff --git a/clients/js-legacy/src/instructions/amountToUiAmount.ts b/clients/js-legacy/src/instructions/amountToUiAmount.ts index 57230e99d..d5c46e1e8 100644 --- a/clients/js-legacy/src/instructions/amountToUiAmount.ts +++ b/clients/js-legacy/src/instructions/amountToUiAmount.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '@solana/buffer-layout-utils'; +import { u64 } from '../layouts.js'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/approve.ts b/clients/js-legacy/src/instructions/approve.ts index 9ef38c8e3..d3f914afe 100644 --- a/clients/js-legacy/src/instructions/approve.ts +++ b/clients/js-legacy/src/instructions/approve.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '@solana/buffer-layout-utils'; +import { u64 } from '../layouts.js'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/approveChecked.ts b/clients/js-legacy/src/instructions/approveChecked.ts index ccb52eb4e..95c9a38dd 100644 --- a/clients/js-legacy/src/instructions/approveChecked.ts +++ b/clients/js-legacy/src/instructions/approveChecked.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '@solana/buffer-layout-utils'; +import { u64 } from '../layouts.js'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/associatedTokenAccount.ts b/clients/js-legacy/src/instructions/associatedTokenAccount.ts index d8d47c7ba..4ee0cb75d 100644 --- a/clients/js-legacy/src/instructions/associatedTokenAccount.ts +++ b/clients/js-legacy/src/instructions/associatedTokenAccount.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import type { PublicKey } from '@solana/web3.js'; import { SystemProgram, TransactionInstruction } from '@solana/web3.js'; import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/burn.ts b/clients/js-legacy/src/instructions/burn.ts index f6f9708b8..60570cd10 100644 --- a/clients/js-legacy/src/instructions/burn.ts +++ b/clients/js-legacy/src/instructions/burn.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '@solana/buffer-layout-utils'; +import { u64 } from '../layouts.js'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/burnChecked.ts b/clients/js-legacy/src/instructions/burnChecked.ts index 9f8926c48..4c0af561d 100644 --- a/clients/js-legacy/src/instructions/burnChecked.ts +++ b/clients/js-legacy/src/instructions/burnChecked.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '@solana/buffer-layout-utils'; +import { u64 } from '../layouts.js'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/closeAccount.ts b/clients/js-legacy/src/instructions/closeAccount.ts index 9ed3a1062..ff4bf3909 100644 --- a/clients/js-legacy/src/instructions/closeAccount.ts +++ b/clients/js-legacy/src/instructions/closeAccount.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/createNativeMint.ts b/clients/js-legacy/src/instructions/createNativeMint.ts index 4ae9dff8b..243ef7a5e 100644 --- a/clients/js-legacy/src/instructions/createNativeMint.ts +++ b/clients/js-legacy/src/instructions/createNativeMint.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { PublicKey } from '@solana/web3.js'; import { SystemProgram, TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/freezeAccount.ts b/clients/js-legacy/src/instructions/freezeAccount.ts index 8dbebcaa7..787438e1c 100644 --- a/clients/js-legacy/src/instructions/freezeAccount.ts +++ b/clients/js-legacy/src/instructions/freezeAccount.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/initializeAccount.ts b/clients/js-legacy/src/instructions/initializeAccount.ts index 7708b5063..333a94484 100644 --- a/clients/js-legacy/src/instructions/initializeAccount.ts +++ b/clients/js-legacy/src/instructions/initializeAccount.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { SYSVAR_RENT_PUBKEY, TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/initializeAccount2.ts b/clients/js-legacy/src/instructions/initializeAccount2.ts index f6c3c1292..78aa4d792 100644 --- a/clients/js-legacy/src/instructions/initializeAccount2.ts +++ b/clients/js-legacy/src/instructions/initializeAccount2.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../layouts.js'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { SYSVAR_RENT_PUBKEY, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/initializeAccount3.ts b/clients/js-legacy/src/instructions/initializeAccount3.ts index af167ea9c..48ec50164 100644 --- a/clients/js-legacy/src/instructions/initializeAccount3.ts +++ b/clients/js-legacy/src/instructions/initializeAccount3.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../layouts.js'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/initializeImmutableOwner.ts b/clients/js-legacy/src/instructions/initializeImmutableOwner.ts index c1023d781..989e19c10 100644 --- a/clients/js-legacy/src/instructions/initializeImmutableOwner.ts +++ b/clients/js-legacy/src/instructions/initializeImmutableOwner.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/initializeMint.ts b/clients/js-legacy/src/instructions/initializeMint.ts index 01014cf4b..3e274fe88 100644 --- a/clients/js-legacy/src/instructions/initializeMint.ts +++ b/clients/js-legacy/src/instructions/initializeMint.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../layouts.js'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { SYSVAR_RENT_PUBKEY, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/initializeMint2.ts b/clients/js-legacy/src/instructions/initializeMint2.ts index 3601d3557..a8aa5da54 100644 --- a/clients/js-legacy/src/instructions/initializeMint2.ts +++ b/clients/js-legacy/src/instructions/initializeMint2.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../layouts.js'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/initializeMintCloseAuthority.ts b/clients/js-legacy/src/instructions/initializeMintCloseAuthority.ts index 76591955c..1140b5359 100644 --- a/clients/js-legacy/src/instructions/initializeMintCloseAuthority.ts +++ b/clients/js-legacy/src/instructions/initializeMintCloseAuthority.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/initializeMultisig.ts b/clients/js-legacy/src/instructions/initializeMultisig.ts index 4f21046b4..88ae86e8c 100644 --- a/clients/js-legacy/src/instructions/initializeMultisig.ts +++ b/clients/js-legacy/src/instructions/initializeMultisig.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, Signer } from '@solana/web3.js'; import { PublicKey, SYSVAR_RENT_PUBKEY, TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/initializeNonTransferableMint.ts b/clients/js-legacy/src/instructions/initializeNonTransferableMint.ts index c837178eb..18e46d9ab 100644 --- a/clients/js-legacy/src/instructions/initializeNonTransferableMint.ts +++ b/clients/js-legacy/src/instructions/initializeNonTransferableMint.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/initializePermanentDelegate.ts b/clients/js-legacy/src/instructions/initializePermanentDelegate.ts index a4f28b4a9..77d818262 100644 --- a/clients/js-legacy/src/instructions/initializePermanentDelegate.ts +++ b/clients/js-legacy/src/instructions/initializePermanentDelegate.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../layouts.js'; import type { AccountMeta } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/mintTo.ts b/clients/js-legacy/src/instructions/mintTo.ts index a1d93b89b..43c1b524c 100644 --- a/clients/js-legacy/src/instructions/mintTo.ts +++ b/clients/js-legacy/src/instructions/mintTo.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '@solana/buffer-layout-utils'; +import { u64 } from '../layouts.js'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/mintToChecked.ts b/clients/js-legacy/src/instructions/mintToChecked.ts index 85eb9a4fe..349563a78 100644 --- a/clients/js-legacy/src/instructions/mintToChecked.ts +++ b/clients/js-legacy/src/instructions/mintToChecked.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '@solana/buffer-layout-utils'; +import { u64 } from '../layouts.js'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/reallocate.ts b/clients/js-legacy/src/instructions/reallocate.ts index 6b90f35de..5b24fa943 100644 --- a/clients/js-legacy/src/instructions/reallocate.ts +++ b/clients/js-legacy/src/instructions/reallocate.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { seq, struct, u16, u8 } from '@solana/buffer-layout'; import type { PublicKey, Signer } from '@solana/web3.js'; import { SystemProgram, TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/revoke.ts b/clients/js-legacy/src/instructions/revoke.ts index 5b7232342..cc4418ecc 100644 --- a/clients/js-legacy/src/instructions/revoke.ts +++ b/clients/js-legacy/src/instructions/revoke.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/setAuthority.ts b/clients/js-legacy/src/instructions/setAuthority.ts index ca18817f7..ba7add8a2 100644 --- a/clients/js-legacy/src/instructions/setAuthority.ts +++ b/clients/js-legacy/src/instructions/setAuthority.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '@solana/buffer-layout-utils'; +import { publicKey } from '../layouts.js'; import type { AccountMeta, Signer, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/syncNative.ts b/clients/js-legacy/src/instructions/syncNative.ts index 8340a5460..4b55ca76b 100644 --- a/clients/js-legacy/src/instructions/syncNative.ts +++ b/clients/js-legacy/src/instructions/syncNative.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/thawAccount.ts b/clients/js-legacy/src/instructions/thawAccount.ts index 3423fb104..6ceb20da0 100644 --- a/clients/js-legacy/src/instructions/thawAccount.ts +++ b/clients/js-legacy/src/instructions/thawAccount.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/transfer.ts b/clients/js-legacy/src/instructions/transfer.ts index 6cd415e3d..460573a8c 100644 --- a/clients/js-legacy/src/instructions/transfer.ts +++ b/clients/js-legacy/src/instructions/transfer.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '@solana/buffer-layout-utils'; +import { u64 } from '../layouts.js'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/transferChecked.ts b/clients/js-legacy/src/instructions/transferChecked.ts index b3f53dc94..fd4a73d1c 100644 --- a/clients/js-legacy/src/instructions/transferChecked.ts +++ b/clients/js-legacy/src/instructions/transferChecked.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '@solana/buffer-layout-utils'; +import { u64 } from '../layouts.js'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/uiAmountToAmount.ts b/clients/js-legacy/src/instructions/uiAmountToAmount.ts index 490ba1752..ae2b9d4ae 100644 --- a/clients/js-legacy/src/instructions/uiAmountToAmount.ts +++ b/clients/js-legacy/src/instructions/uiAmountToAmount.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { blob, struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/unwrapLamports.ts b/clients/js-legacy/src/instructions/unwrapLamports.ts index 5ba667750..931032f3d 100644 --- a/clients/js-legacy/src/instructions/unwrapLamports.ts +++ b/clients/js-legacy/src/instructions/unwrapLamports.ts @@ -1,3 +1,4 @@ +import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/layouts.ts b/clients/js-legacy/src/layouts.ts new file mode 100644 index 000000000..7605685e8 --- /dev/null +++ b/clients/js-legacy/src/layouts.ts @@ -0,0 +1,54 @@ +import type { Layout } from '@solana/buffer-layout'; +import { blob, u8 } from '@solana/buffer-layout'; +import { PublicKey } from '@solana/web3.js'; + +// Same layouts as `@solana/buffer-layout-utils`, without its native `bigint-buffer` dependency. + +const U64_MAX = BigInt('0xffffffffffffffff'); + +export const bool = (property?: string): Layout => { + const layout = u8(property); + const decode = layout.decode.bind(layout); + const encode = layout.encode.bind(layout); + + const boolLayout = layout as Layout as Layout; + boolLayout.decode = (buffer: Uint8Array, offset = 0) => !!decode(buffer, offset); + boolLayout.encode = (value: boolean, buffer: Uint8Array, offset = 0) => encode(Number(value), buffer, offset); + return boolLayout; +}; + +export const publicKey = (property?: string): Layout => { + const layout = blob(32, property); + const decode = layout.decode.bind(layout); + const encode = layout.encode.bind(layout); + + const publicKeyLayout = layout as Layout as Layout; + publicKeyLayout.decode = (buffer: Uint8Array, offset = 0) => new PublicKey(decode(buffer, offset)); + publicKeyLayout.encode = (value: PublicKey, buffer: Uint8Array, offset = 0) => + encode(value.toBytes(), buffer, offset); + return publicKeyLayout; +}; + +export const u64 = (property?: string): Layout => { + const layout = blob(8, property); + const decode = layout.decode.bind(layout); + const encode = layout.encode.bind(layout); + + const u64Layout = layout as Layout as Layout; + u64Layout.decode = (buffer: Uint8Array, offset = 0) => { + const src = decode(buffer, offset); + return new DataView(src.buffer, src.byteOffset, src.byteLength).getBigUint64(0, true); + }; + u64Layout.encode = (value: bigint, buffer: Uint8Array, offset = 0) => { + if (typeof value !== 'bigint') { + throw new Error('Expected a `BigInt`'); + } + if (value < BigInt(0) || value > U64_MAX) { + throw new RangeError(`u64 out of range: ${value}`); + } + const src = new Uint8Array(8); + new DataView(src.buffer).setBigUint64(0, value, true); + return encode(src, buffer, offset); + }; + return u64Layout; +}; diff --git a/clients/js-legacy/src/serialization.ts b/clients/js-legacy/src/serialization.ts index 669eaffd9..f752b0df9 100644 --- a/clients/js-legacy/src/serialization.ts +++ b/clients/js-legacy/src/serialization.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { Layout } from '@solana/buffer-layout'; -import { publicKey, u64 } from '@solana/buffer-layout-utils'; +import { publicKey, u64 } from './layouts.js'; import type { PublicKey } from '@solana/web3.js'; export class COptionPublicKeyLayout extends Layout { diff --git a/clients/js-legacy/src/state/account.ts b/clients/js-legacy/src/state/account.ts index b068f4727..ca55bdc20 100644 --- a/clients/js-legacy/src/state/account.ts +++ b/clients/js-legacy/src/state/account.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u32, u8 } from '@solana/buffer-layout'; -import { publicKey, u64 } from '@solana/buffer-layout-utils'; +import { publicKey, u64 } from '../layouts.js'; import type { AccountInfo, Commitment, Connection, PublicKey } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; import { diff --git a/clients/js-legacy/src/state/mint.ts b/clients/js-legacy/src/state/mint.ts index cb09ec317..0d30842b8 100644 --- a/clients/js-legacy/src/state/mint.ts +++ b/clients/js-legacy/src/state/mint.ts @@ -1,5 +1,6 @@ +import { Buffer } from 'buffer'; import { struct, u32, u8 } from '@solana/buffer-layout'; -import { bool, publicKey, u64 } from '@solana/buffer-layout-utils'; +import { bool, publicKey, u64 } from '../layouts.js'; import type { AccountInfo, Commitment, Connection } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/state/multisig.ts b/clients/js-legacy/src/state/multisig.ts index 047348375..abc948e0d 100644 --- a/clients/js-legacy/src/state/multisig.ts +++ b/clients/js-legacy/src/state/multisig.ts @@ -1,5 +1,6 @@ +import type { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { bool, publicKey } from '@solana/buffer-layout-utils'; +import { bool, publicKey } from '../layouts.js'; import type { AccountInfo, Commitment, Connection, PublicKey } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; import { TokenAccountNotFoundError, TokenInvalidAccountOwnerError, TokenInvalidAccountSizeError } from '../errors.js'; diff --git a/clients/js-legacy/test/unit/layouts.test.ts b/clients/js-legacy/test/unit/layouts.test.ts new file mode 100644 index 000000000..63323c881 --- /dev/null +++ b/clients/js-legacy/test/unit/layouts.test.ts @@ -0,0 +1,47 @@ +import { PublicKey } from '@solana/web3.js'; +import { expect } from 'chai'; +import { bool, publicKey, u64 } from '../../src/layouts'; + +describe('layouts', () => { + describe('u64', () => { + const cases: [bigint, number[]][] = [ + [0n, [0, 0, 0, 0, 0, 0, 0, 0]], + [1n, [1, 0, 0, 0, 0, 0, 0, 0]], + [0x0123456789abcdefn, [0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01]], + [0xffffffffffffffffn, [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]], + ]; + for (const [value, bytes] of cases) { + it(`encodes and decodes ${value} little-endian`, () => { + const buffer = new Uint8Array(10); + expect(u64().encode(value, buffer, 1)).to.equal(8); + expect(Array.from(buffer.subarray(1, 9))).to.deep.equal(bytes); + expect(u64().decode(buffer, 1)).to.equal(value); + }); + } + + it('rejects values outside the u64 range', () => { + expect(() => u64().encode(-1n, new Uint8Array(8))).to.throw(RangeError); + expect(() => u64().encode(0x10000000000000000n, new Uint8Array(8))).to.throw(RangeError); + }); + + it('rejects non-bigint values', () => { + expect(() => u64().encode(1 as unknown as bigint, new Uint8Array(8))).to.throw('Expected a `BigInt`'); + }); + }); + + it('encodes and decodes bool', () => { + const buffer = new Uint8Array(2); + bool().encode(true, buffer, 1); + expect(Array.from(buffer)).to.deep.equal([0, 1]); + expect(bool().decode(buffer, 1)).to.equal(true); + expect(bool().decode(buffer, 0)).to.equal(false); + }); + + it('encodes and decodes publicKey', () => { + const key = PublicKey.unique(); + const buffer = new Uint8Array(33); + expect(publicKey().encode(key, buffer, 1)).to.equal(32); + expect(Array.from(buffer.subarray(1))).to.deep.equal(Array.from(key.toBytes())); + expect(publicKey().decode(buffer, 1).equals(key)).to.equal(true); + }); +}); diff --git a/clients/js-legacy/tsconfig.base.json b/clients/js-legacy/tsconfig.base.json index 4e94c1db5..1ff7187ec 100644 --- a/clients/js-legacy/tsconfig.base.json +++ b/clients/js-legacy/tsconfig.base.json @@ -10,6 +10,7 @@ "resolveJsonModule": true, "strict": true, "stripInternal": true, + "types": ["node"], "ignoreDeprecations": "6.0" } } From 32629fe0ab7d3a7011abc61043f29df1531cd67e Mon Sep 17 00:00:00 2001 From: aelmanaa Date: Sat, 21 Nov 2026 10:24:07 +0000 Subject: [PATCH 2/2] fix(js-legacy): keep only the explicit Buffer imports Co-Authored-By: Claude Opus 5.5 --- clients/js-legacy/.oxlintrc.json | 6 +-- clients/js-legacy/package.json | 1 + clients/js-legacy/pnpm-lock.yaml | 44 +++++++++++++++ .../js-legacy/src/actions/uiAmountToAmount.ts | 2 +- .../src/extensions/cpiGuard/state.ts | 2 +- .../groupMemberPointer/instructions.ts | 2 +- .../extensions/groupMemberPointer/state.ts | 2 +- .../extensions/groupPointer/instructions.ts | 2 +- .../src/extensions/groupPointer/state.ts | 2 +- .../interestBearingMint/instructions.ts | 2 +- .../extensions/interestBearingMint/state.ts | 2 +- .../src/extensions/memoTransfer/state.ts | 2 +- .../metadataPointer/instructions.ts | 2 +- .../src/extensions/metadataPointer/state.ts | 2 +- .../src/extensions/mintCloseAuthority.ts | 2 +- .../src/extensions/pausable/instructions.ts | 2 +- .../src/extensions/pausable/state.ts | 2 +- .../src/extensions/permanentDelegate.ts | 2 +- .../permissionedBurn/instructions.ts | 2 +- .../src/extensions/permissionedBurn/state.ts | 2 +- .../extensions/scaledUiAmount/instructions.ts | 2 +- .../src/extensions/scaledUiAmount/state.ts | 2 +- .../src/extensions/tokenGroup/state.ts | 2 +- .../extensions/transferFee/instructions.ts | 2 +- .../src/extensions/transferFee/state.ts | 2 +- .../extensions/transferHook/instructions.ts | 2 +- .../src/extensions/transferHook/state.ts | 2 +- .../src/instructions/amountToUiAmount.ts | 2 +- clients/js-legacy/src/instructions/approve.ts | 2 +- .../src/instructions/approveChecked.ts | 2 +- clients/js-legacy/src/instructions/burn.ts | 2 +- .../js-legacy/src/instructions/burnChecked.ts | 2 +- .../src/instructions/initializeAccount2.ts | 2 +- .../src/instructions/initializeAccount3.ts | 2 +- .../src/instructions/initializeMint.ts | 2 +- .../src/instructions/initializeMint2.ts | 2 +- .../initializePermanentDelegate.ts | 2 +- clients/js-legacy/src/instructions/mintTo.ts | 2 +- .../src/instructions/mintToChecked.ts | 2 +- .../src/instructions/setAuthority.ts | 2 +- .../js-legacy/src/instructions/transfer.ts | 2 +- .../src/instructions/transferChecked.ts | 2 +- clients/js-legacy/src/layouts.ts | 54 ------------------- clients/js-legacy/src/serialization.ts | 2 +- clients/js-legacy/src/state/account.ts | 2 +- clients/js-legacy/src/state/mint.ts | 2 +- clients/js-legacy/src/state/multisig.ts | 2 +- clients/js-legacy/test/unit/layouts.test.ts | 47 ---------------- clients/js-legacy/tsconfig.base.json | 1 - 49 files changed, 90 insertions(+), 149 deletions(-) delete mode 100644 clients/js-legacy/src/layouts.ts delete mode 100644 clients/js-legacy/test/unit/layouts.test.ts diff --git a/clients/js-legacy/.oxlintrc.json b/clients/js-legacy/.oxlintrc.json index 88368001f..0750047c8 100644 --- a/clients/js-legacy/.oxlintrc.json +++ b/clients/js-legacy/.oxlintrc.json @@ -11,16 +11,14 @@ "no-unused-vars": "off", "typescript/no-empty-object-type": "off", "typescript/consistent-type-imports": "error", - "import/extensions": ["error", "ignorePackages"], - "no-restricted-globals": ["error", { "name": "Buffer", "message": "Import it from 'buffer': browsers have no global Buffer." }] + "import/extensions": ["error", "ignorePackages"] }, "ignorePatterns": ["dist", "docs", "lib", "test-ledger"], "overrides": [ { "files": ["examples/**/*", "test/**/*"], "rules": { - "import/extensions": "off", - "no-restricted-globals": "off" + "import/extensions": "off" } } ] diff --git a/clients/js-legacy/package.json b/clients/js-legacy/package.json index e59f80fbb..59ec6661e 100644 --- a/clients/js-legacy/package.json +++ b/clients/js-legacy/package.json @@ -60,6 +60,7 @@ }, "dependencies": { "@solana/buffer-layout": "^4.0.0", + "@solana/buffer-layout-utils": "^0.3.0", "@solana/spl-token-group": "^0.0.7", "@solana/spl-token-metadata": "^0.1.6", "buffer": "^6.0.3" diff --git a/clients/js-legacy/pnpm-lock.yaml b/clients/js-legacy/pnpm-lock.yaml index b29691d3b..56294f517 100644 --- a/clients/js-legacy/pnpm-lock.yaml +++ b/clients/js-legacy/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@solana/buffer-layout': specifier: ^4.0.0 version: 4.0.1 + '@solana/buffer-layout-utils': + specifier: ^0.3.0 + version: 0.3.0(bufferutil@4.1.0)(typescript@6.0.3)(utf-8-validate@6.0.6) '@solana/spl-token-group': specifier: ^0.0.7 version: 0.0.7(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@6.0.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@6.0.3) @@ -365,6 +368,10 @@ packages: '@shikijs/vscode-textmate@10.0.2': resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==} + '@solana/buffer-layout-utils@0.3.0': + resolution: {integrity: sha512-MuQOCC1j0np1xH9yAv0ZWWfwvr7Bt7Sz4LId11Wi4wDdAmJ+lobE+vHg/mZmGcihF0BIkqVBNxGmlv8QE5DrtA==} + engines: {node: '>= 10'} + '@solana/buffer-layout@4.0.1': resolution: {integrity: sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==} engines: {node: '>=5.10'} @@ -592,6 +599,16 @@ packages: base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + bigint-buffer@1.1.5: + resolution: {integrity: sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==} + engines: {node: '>= 10.0.0'} + + bignumber.js@9.3.1: + resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==} + + bindings@1.5.0: + resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} + bn.js@5.2.5: resolution: {integrity: sha512-Vq886eXykuP5E6HcKSSStP3bJgrE6In5WKxVUvJ8XGpWWYs2xZHWqUwzCtGgEtBcxyd57KBFDPFoUfNzdaHCNg==} @@ -774,6 +791,9 @@ packages: fastq@1.18.0: resolution: {integrity: sha512-QKHXPW0hD8g4UET03SdOdunzSouc9N4AuHdsX8XNcTsuz+yYFILVNIX4l9yHABMhiEI9Db0JTTIpu0wB+Y1QQw==} + file-uri-to-path@1.0.0: + resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} + filename-reserved-regex@2.0.0: resolution: {integrity: sha512-lc1bnsSr4L4Bdif8Xb/qrtokGbq5zlsms/CYH8PP+WtCkGNF65DPiQY8vG3SakEdRn8Dlnm+gW/qWKKjS5sZzQ==} engines: {node: '>=4'} @@ -1501,6 +1521,18 @@ snapshots: '@shikijs/vscode-textmate@10.0.2': {} + '@solana/buffer-layout-utils@0.3.0(bufferutil@4.1.0)(typescript@6.0.3)(utf-8-validate@6.0.6)': + dependencies: + '@solana/buffer-layout': 4.0.1 + '@solana/web3.js': 1.99.0(bufferutil@4.1.0)(typescript@6.0.3)(utf-8-validate@6.0.6) + bigint-buffer: 1.1.5 + bignumber.js: 9.3.1 + transitivePeerDependencies: + - bufferutil + - encoding + - typescript + - utf-8-validate + '@solana/buffer-layout@4.0.1': dependencies: buffer: 6.0.3 @@ -1738,6 +1770,16 @@ snapshots: base64-js@1.5.1: {} + bigint-buffer@1.1.5: + dependencies: + bindings: 1.5.0 + + bignumber.js@9.3.1: {} + + bindings@1.5.0: + dependencies: + file-uri-to-path: 1.0.0 + bn.js@5.2.5: {} borsh@0.7.0: @@ -1905,6 +1947,8 @@ snapshots: dependencies: reusify: 1.0.4 + file-uri-to-path@1.0.0: {} + filename-reserved-regex@2.0.0: {} filenamify@4.3.0: diff --git a/clients/js-legacy/src/actions/uiAmountToAmount.ts b/clients/js-legacy/src/actions/uiAmountToAmount.ts index 38d4bf0ea..92dfe3db2 100644 --- a/clients/js-legacy/src/actions/uiAmountToAmount.ts +++ b/clients/js-legacy/src/actions/uiAmountToAmount.ts @@ -1,5 +1,5 @@ import { Buffer } from 'buffer'; -import { u64 } from '../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { Connection, PublicKey, Signer, TransactionError } from '@solana/web3.js'; import { Transaction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/extensions/cpiGuard/state.ts b/clients/js-legacy/src/extensions/cpiGuard/state.ts index 7ef40cbf6..6ac2951fe 100644 --- a/clients/js-legacy/src/extensions/cpiGuard/state.ts +++ b/clients/js-legacy/src/extensions/cpiGuard/state.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { bool } from '../../layouts.js'; +import { bool } from '@solana/buffer-layout-utils'; import type { Account } from '../../state/account.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/groupMemberPointer/instructions.ts b/clients/js-legacy/src/extensions/groupMemberPointer/instructions.ts index 4cdbd8526..90e0067aa 100644 --- a/clients/js-legacy/src/extensions/groupMemberPointer/instructions.ts +++ b/clients/js-legacy/src/extensions/groupMemberPointer/instructions.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { Signer } from '@solana/web3.js'; import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID, programSupportsExtensions } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/groupMemberPointer/state.ts b/clients/js-legacy/src/extensions/groupMemberPointer/state.ts index b8abe2c48..d61a29941 100644 --- a/clients/js-legacy/src/extensions/groupMemberPointer/state.ts +++ b/clients/js-legacy/src/extensions/groupMemberPointer/state.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/groupPointer/instructions.ts b/clients/js-legacy/src/extensions/groupPointer/instructions.ts index f8d40ab20..ef0efc45b 100644 --- a/clients/js-legacy/src/extensions/groupPointer/instructions.ts +++ b/clients/js-legacy/src/extensions/groupPointer/instructions.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { Signer } from '@solana/web3.js'; import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID, programSupportsExtensions } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/groupPointer/state.ts b/clients/js-legacy/src/extensions/groupPointer/state.ts index 5ac46beb5..f98636200 100644 --- a/clients/js-legacy/src/extensions/groupPointer/state.ts +++ b/clients/js-legacy/src/extensions/groupPointer/state.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/interestBearingMint/instructions.ts b/clients/js-legacy/src/extensions/interestBearingMint/instructions.ts index f17e17cae..243c9931b 100644 --- a/clients/js-legacy/src/extensions/interestBearingMint/instructions.ts +++ b/clients/js-legacy/src/extensions/interestBearingMint/instructions.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { s16, struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/interestBearingMint/state.ts b/clients/js-legacy/src/extensions/interestBearingMint/state.ts index 794c04b00..b10cb3ab8 100644 --- a/clients/js-legacy/src/extensions/interestBearingMint/state.ts +++ b/clients/js-legacy/src/extensions/interestBearingMint/state.ts @@ -1,5 +1,5 @@ import { ns64, s16, struct } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/memoTransfer/state.ts b/clients/js-legacy/src/extensions/memoTransfer/state.ts index 4fb50ee10..09bfb1a22 100644 --- a/clients/js-legacy/src/extensions/memoTransfer/state.ts +++ b/clients/js-legacy/src/extensions/memoTransfer/state.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { bool } from '../../layouts.js'; +import { bool } from '@solana/buffer-layout-utils'; import type { Account } from '../../state/account.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/metadataPointer/instructions.ts b/clients/js-legacy/src/extensions/metadataPointer/instructions.ts index e3c1d2ecc..771a8136d 100644 --- a/clients/js-legacy/src/extensions/metadataPointer/instructions.ts +++ b/clients/js-legacy/src/extensions/metadataPointer/instructions.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { Signer } from '@solana/web3.js'; import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID, programSupportsExtensions } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/metadataPointer/state.ts b/clients/js-legacy/src/extensions/metadataPointer/state.ts index 7ebc8408d..e030d8647 100644 --- a/clients/js-legacy/src/extensions/metadataPointer/state.ts +++ b/clients/js-legacy/src/extensions/metadataPointer/state.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/mintCloseAuthority.ts b/clients/js-legacy/src/extensions/mintCloseAuthority.ts index c013e815a..de9744a01 100644 --- a/clients/js-legacy/src/extensions/mintCloseAuthority.ts +++ b/clients/js-legacy/src/extensions/mintCloseAuthority.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { PublicKey } from '@solana/web3.js'; import type { Mint } from '../state/mint.js'; import { ExtensionType, getExtensionData } from './extensionType.js'; diff --git a/clients/js-legacy/src/extensions/pausable/instructions.ts b/clients/js-legacy/src/extensions/pausable/instructions.ts index 28ff9f5d8..7fb9f054c 100644 --- a/clients/js-legacy/src/extensions/pausable/instructions.ts +++ b/clients/js-legacy/src/extensions/pausable/instructions.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { Signer } from '@solana/web3.js'; import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_2022_PROGRAM_ID, programSupportsExtensions } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/pausable/state.ts b/clients/js-legacy/src/extensions/pausable/state.ts index bbe2bf80d..bc5e0434d 100644 --- a/clients/js-legacy/src/extensions/pausable/state.ts +++ b/clients/js-legacy/src/extensions/pausable/state.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey, bool } from '../../layouts.js'; +import { publicKey, bool } from '@solana/buffer-layout-utils'; import { PublicKey } from '@solana/web3.js'; import type { Account } from '../../state/account.js'; import type { Mint } from '../../state/mint.js'; diff --git a/clients/js-legacy/src/extensions/permanentDelegate.ts b/clients/js-legacy/src/extensions/permanentDelegate.ts index 1a6f5fea8..9998a1209 100644 --- a/clients/js-legacy/src/extensions/permanentDelegate.ts +++ b/clients/js-legacy/src/extensions/permanentDelegate.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { PublicKey } from '@solana/web3.js'; import type { Mint } from '../state/mint.js'; import { ExtensionType, getExtensionData } from './extensionType.js'; diff --git a/clients/js-legacy/src/extensions/permissionedBurn/instructions.ts b/clients/js-legacy/src/extensions/permissionedBurn/instructions.ts index d33dfe8a0..3f71ea2df 100644 --- a/clients/js-legacy/src/extensions/permissionedBurn/instructions.ts +++ b/clients/js-legacy/src/extensions/permissionedBurn/instructions.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey, u64 } from '../../layouts.js'; +import { publicKey, u64 } from '@solana/buffer-layout-utils'; import type { PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { programSupportsExtensions, TOKEN_2022_PROGRAM_ID } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/permissionedBurn/state.ts b/clients/js-legacy/src/extensions/permissionedBurn/state.ts index a8f948626..ea7c6bccd 100644 --- a/clients/js-legacy/src/extensions/permissionedBurn/state.ts +++ b/clients/js-legacy/src/extensions/permissionedBurn/state.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/scaledUiAmount/instructions.ts b/clients/js-legacy/src/extensions/scaledUiAmount/instructions.ts index 06e85d5d9..d4c7f24bf 100644 --- a/clients/js-legacy/src/extensions/scaledUiAmount/instructions.ts +++ b/clients/js-legacy/src/extensions/scaledUiAmount/instructions.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8, f64 } from '@solana/buffer-layout'; -import { publicKey, u64 } from '../../layouts.js'; +import { publicKey, u64 } from '@solana/buffer-layout-utils'; import { TokenInstruction } from '../../instructions/types.js'; import type { Signer } from '@solana/web3.js'; import { TransactionInstruction, PublicKey } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/extensions/scaledUiAmount/state.ts b/clients/js-legacy/src/extensions/scaledUiAmount/state.ts index b9d7b73c6..9b21242eb 100644 --- a/clients/js-legacy/src/extensions/scaledUiAmount/state.ts +++ b/clients/js-legacy/src/extensions/scaledUiAmount/state.ts @@ -1,5 +1,5 @@ import { f64, struct } from '@solana/buffer-layout'; -import { publicKey, u64 } from '../../layouts.js'; +import { publicKey, u64 } from '@solana/buffer-layout-utils'; import { PublicKey } from '@solana/web3.js'; import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; diff --git a/clients/js-legacy/src/extensions/tokenGroup/state.ts b/clients/js-legacy/src/extensions/tokenGroup/state.ts index faf2b52e7..a0822357c 100644 --- a/clients/js-legacy/src/extensions/tokenGroup/state.ts +++ b/clients/js-legacy/src/extensions/tokenGroup/state.ts @@ -1,5 +1,5 @@ import { struct, u32 } from '@solana/buffer-layout'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import { PublicKey } from '@solana/web3.js'; import { unpackTokenGroup, diff --git a/clients/js-legacy/src/extensions/transferFee/instructions.ts b/clients/js-legacy/src/extensions/transferFee/instructions.ts index ecfc44623..603cb69e5 100644 --- a/clients/js-legacy/src/extensions/transferFee/instructions.ts +++ b/clients/js-legacy/src/extensions/transferFee/instructions.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u16, u8 } from '@solana/buffer-layout'; -import { u64 } from '../../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { AccountMeta, Signer, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { programSupportsExtensions, TOKEN_2022_PROGRAM_ID } from '../../constants.js'; diff --git a/clients/js-legacy/src/extensions/transferFee/state.ts b/clients/js-legacy/src/extensions/transferFee/state.ts index 1ec2083cc..92479ff04 100644 --- a/clients/js-legacy/src/extensions/transferFee/state.ts +++ b/clients/js-legacy/src/extensions/transferFee/state.ts @@ -1,7 +1,7 @@ import { Buffer } from 'buffer'; import type { Layout } from '@solana/buffer-layout'; import { struct, u16 } from '@solana/buffer-layout'; -import { publicKey, u64 } from '../../layouts.js'; +import { publicKey, u64 } from '@solana/buffer-layout-utils'; import type { PublicKey } from '@solana/web3.js'; import type { Account } from '../../state/account.js'; import type { Mint } from '../../state/mint.js'; diff --git a/clients/js-legacy/src/extensions/transferHook/instructions.ts b/clients/js-legacy/src/extensions/transferHook/instructions.ts index 83992b12e..b5995ba4f 100644 --- a/clients/js-legacy/src/extensions/transferHook/instructions.ts +++ b/clients/js-legacy/src/extensions/transferHook/instructions.ts @@ -6,7 +6,7 @@ import { programSupportsExtensions, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } fr import { TokenUnsupportedInstructionError } from '../../errors.js'; import { addSigners } from '../../instructions/internal.js'; import { TokenInstruction } from '../../instructions/types.js'; -import { publicKey } from '../../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import { createTransferCheckedInstruction } from '../../instructions/transferChecked.js'; import { createTransferCheckedWithFeeInstruction } from '../transferFee/instructions.js'; import { getMint } from '../../state/mint.js'; diff --git a/clients/js-legacy/src/extensions/transferHook/state.ts b/clients/js-legacy/src/extensions/transferHook/state.ts index 53e05d9b5..77ce22bcc 100644 --- a/clients/js-legacy/src/extensions/transferHook/state.ts +++ b/clients/js-legacy/src/extensions/transferHook/state.ts @@ -4,7 +4,7 @@ import type { Mint } from '../../state/mint.js'; import { ExtensionType, getExtensionData } from '../extensionType.js'; import type { AccountInfo, AccountMeta, Connection } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; -import { bool, publicKey, u64 } from '../../layouts.js'; +import { bool, publicKey, u64 } from '@solana/buffer-layout-utils'; import type { Account } from '../../state/account.js'; import { TokenTransferHookAccountNotFound } from '../../errors.js'; import { unpackSeeds } from './seeds.js'; diff --git a/clients/js-legacy/src/instructions/amountToUiAmount.ts b/clients/js-legacy/src/instructions/amountToUiAmount.ts index d5c46e1e8..0ecb2fba3 100644 --- a/clients/js-legacy/src/instructions/amountToUiAmount.ts +++ b/clients/js-legacy/src/instructions/amountToUiAmount.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/approve.ts b/clients/js-legacy/src/instructions/approve.ts index d3f914afe..c6bad8b04 100644 --- a/clients/js-legacy/src/instructions/approve.ts +++ b/clients/js-legacy/src/instructions/approve.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/approveChecked.ts b/clients/js-legacy/src/instructions/approveChecked.ts index 95c9a38dd..de5a1fa7c 100644 --- a/clients/js-legacy/src/instructions/approveChecked.ts +++ b/clients/js-legacy/src/instructions/approveChecked.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/burn.ts b/clients/js-legacy/src/instructions/burn.ts index 60570cd10..1b37b4cc1 100644 --- a/clients/js-legacy/src/instructions/burn.ts +++ b/clients/js-legacy/src/instructions/burn.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/burnChecked.ts b/clients/js-legacy/src/instructions/burnChecked.ts index 4c0af561d..d44979010 100644 --- a/clients/js-legacy/src/instructions/burnChecked.ts +++ b/clients/js-legacy/src/instructions/burnChecked.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/initializeAccount2.ts b/clients/js-legacy/src/instructions/initializeAccount2.ts index 78aa4d792..ec7d540e8 100644 --- a/clients/js-legacy/src/instructions/initializeAccount2.ts +++ b/clients/js-legacy/src/instructions/initializeAccount2.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { SYSVAR_RENT_PUBKEY, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/initializeAccount3.ts b/clients/js-legacy/src/instructions/initializeAccount3.ts index 48ec50164..50f74aafc 100644 --- a/clients/js-legacy/src/instructions/initializeAccount3.ts +++ b/clients/js-legacy/src/instructions/initializeAccount3.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/initializeMint.ts b/clients/js-legacy/src/instructions/initializeMint.ts index 3e274fe88..2513647d3 100644 --- a/clients/js-legacy/src/instructions/initializeMint.ts +++ b/clients/js-legacy/src/instructions/initializeMint.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { SYSVAR_RENT_PUBKEY, TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/initializeMint2.ts b/clients/js-legacy/src/instructions/initializeMint2.ts index a8aa5da54..9bc64a706 100644 --- a/clients/js-legacy/src/instructions/initializeMint2.ts +++ b/clients/js-legacy/src/instructions/initializeMint2.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/initializePermanentDelegate.ts b/clients/js-legacy/src/instructions/initializePermanentDelegate.ts index 77d818262..d28b250c9 100644 --- a/clients/js-legacy/src/instructions/initializePermanentDelegate.ts +++ b/clients/js-legacy/src/instructions/initializePermanentDelegate.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { AccountMeta } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; diff --git a/clients/js-legacy/src/instructions/mintTo.ts b/clients/js-legacy/src/instructions/mintTo.ts index 43c1b524c..636267649 100644 --- a/clients/js-legacy/src/instructions/mintTo.ts +++ b/clients/js-legacy/src/instructions/mintTo.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/mintToChecked.ts b/clients/js-legacy/src/instructions/mintToChecked.ts index 349563a78..fdf0117e6 100644 --- a/clients/js-legacy/src/instructions/mintToChecked.ts +++ b/clients/js-legacy/src/instructions/mintToChecked.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/setAuthority.ts b/clients/js-legacy/src/instructions/setAuthority.ts index ba7add8a2..589a55fbe 100644 --- a/clients/js-legacy/src/instructions/setAuthority.ts +++ b/clients/js-legacy/src/instructions/setAuthority.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { publicKey } from '../layouts.js'; +import { publicKey } from '@solana/buffer-layout-utils'; import type { AccountMeta, Signer, PublicKey } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/transfer.ts b/clients/js-legacy/src/instructions/transfer.ts index 460573a8c..f6ff71785 100644 --- a/clients/js-legacy/src/instructions/transfer.ts +++ b/clients/js-legacy/src/instructions/transfer.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/instructions/transferChecked.ts b/clients/js-legacy/src/instructions/transferChecked.ts index fd4a73d1c..391bdbe78 100644 --- a/clients/js-legacy/src/instructions/transferChecked.ts +++ b/clients/js-legacy/src/instructions/transferChecked.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { u64 } from '../layouts.js'; +import { u64 } from '@solana/buffer-layout-utils'; import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js'; import { TransactionInstruction } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/layouts.ts b/clients/js-legacy/src/layouts.ts deleted file mode 100644 index 7605685e8..000000000 --- a/clients/js-legacy/src/layouts.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { Layout } from '@solana/buffer-layout'; -import { blob, u8 } from '@solana/buffer-layout'; -import { PublicKey } from '@solana/web3.js'; - -// Same layouts as `@solana/buffer-layout-utils`, without its native `bigint-buffer` dependency. - -const U64_MAX = BigInt('0xffffffffffffffff'); - -export const bool = (property?: string): Layout => { - const layout = u8(property); - const decode = layout.decode.bind(layout); - const encode = layout.encode.bind(layout); - - const boolLayout = layout as Layout as Layout; - boolLayout.decode = (buffer: Uint8Array, offset = 0) => !!decode(buffer, offset); - boolLayout.encode = (value: boolean, buffer: Uint8Array, offset = 0) => encode(Number(value), buffer, offset); - return boolLayout; -}; - -export const publicKey = (property?: string): Layout => { - const layout = blob(32, property); - const decode = layout.decode.bind(layout); - const encode = layout.encode.bind(layout); - - const publicKeyLayout = layout as Layout as Layout; - publicKeyLayout.decode = (buffer: Uint8Array, offset = 0) => new PublicKey(decode(buffer, offset)); - publicKeyLayout.encode = (value: PublicKey, buffer: Uint8Array, offset = 0) => - encode(value.toBytes(), buffer, offset); - return publicKeyLayout; -}; - -export const u64 = (property?: string): Layout => { - const layout = blob(8, property); - const decode = layout.decode.bind(layout); - const encode = layout.encode.bind(layout); - - const u64Layout = layout as Layout as Layout; - u64Layout.decode = (buffer: Uint8Array, offset = 0) => { - const src = decode(buffer, offset); - return new DataView(src.buffer, src.byteOffset, src.byteLength).getBigUint64(0, true); - }; - u64Layout.encode = (value: bigint, buffer: Uint8Array, offset = 0) => { - if (typeof value !== 'bigint') { - throw new Error('Expected a `BigInt`'); - } - if (value < BigInt(0) || value > U64_MAX) { - throw new RangeError(`u64 out of range: ${value}`); - } - const src = new Uint8Array(8); - new DataView(src.buffer).setBigUint64(0, value, true); - return encode(src, buffer, offset); - }; - return u64Layout; -}; diff --git a/clients/js-legacy/src/serialization.ts b/clients/js-legacy/src/serialization.ts index f752b0df9..9b5645491 100644 --- a/clients/js-legacy/src/serialization.ts +++ b/clients/js-legacy/src/serialization.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { Layout } from '@solana/buffer-layout'; -import { publicKey, u64 } from './layouts.js'; +import { publicKey, u64 } from '@solana/buffer-layout-utils'; import type { PublicKey } from '@solana/web3.js'; export class COptionPublicKeyLayout extends Layout { diff --git a/clients/js-legacy/src/state/account.ts b/clients/js-legacy/src/state/account.ts index ca55bdc20..8a65c3645 100644 --- a/clients/js-legacy/src/state/account.ts +++ b/clients/js-legacy/src/state/account.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u32, u8 } from '@solana/buffer-layout'; -import { publicKey, u64 } from '../layouts.js'; +import { publicKey, u64 } from '@solana/buffer-layout-utils'; import type { AccountInfo, Commitment, Connection, PublicKey } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; import { diff --git a/clients/js-legacy/src/state/mint.ts b/clients/js-legacy/src/state/mint.ts index 0d30842b8..82ecfd2b2 100644 --- a/clients/js-legacy/src/state/mint.ts +++ b/clients/js-legacy/src/state/mint.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; import { struct, u32, u8 } from '@solana/buffer-layout'; -import { bool, publicKey, u64 } from '../layouts.js'; +import { bool, publicKey, u64 } from '@solana/buffer-layout-utils'; import type { AccountInfo, Commitment, Connection } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '../constants.js'; diff --git a/clients/js-legacy/src/state/multisig.ts b/clients/js-legacy/src/state/multisig.ts index abc948e0d..16cc22ec9 100644 --- a/clients/js-legacy/src/state/multisig.ts +++ b/clients/js-legacy/src/state/multisig.ts @@ -1,6 +1,6 @@ import type { Buffer } from 'buffer'; import { struct, u8 } from '@solana/buffer-layout'; -import { bool, publicKey } from '../layouts.js'; +import { bool, publicKey } from '@solana/buffer-layout-utils'; import type { AccountInfo, Commitment, Connection, PublicKey } from '@solana/web3.js'; import { TOKEN_PROGRAM_ID } from '../constants.js'; import { TokenAccountNotFoundError, TokenInvalidAccountOwnerError, TokenInvalidAccountSizeError } from '../errors.js'; diff --git a/clients/js-legacy/test/unit/layouts.test.ts b/clients/js-legacy/test/unit/layouts.test.ts deleted file mode 100644 index 63323c881..000000000 --- a/clients/js-legacy/test/unit/layouts.test.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { PublicKey } from '@solana/web3.js'; -import { expect } from 'chai'; -import { bool, publicKey, u64 } from '../../src/layouts'; - -describe('layouts', () => { - describe('u64', () => { - const cases: [bigint, number[]][] = [ - [0n, [0, 0, 0, 0, 0, 0, 0, 0]], - [1n, [1, 0, 0, 0, 0, 0, 0, 0]], - [0x0123456789abcdefn, [0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01]], - [0xffffffffffffffffn, [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]], - ]; - for (const [value, bytes] of cases) { - it(`encodes and decodes ${value} little-endian`, () => { - const buffer = new Uint8Array(10); - expect(u64().encode(value, buffer, 1)).to.equal(8); - expect(Array.from(buffer.subarray(1, 9))).to.deep.equal(bytes); - expect(u64().decode(buffer, 1)).to.equal(value); - }); - } - - it('rejects values outside the u64 range', () => { - expect(() => u64().encode(-1n, new Uint8Array(8))).to.throw(RangeError); - expect(() => u64().encode(0x10000000000000000n, new Uint8Array(8))).to.throw(RangeError); - }); - - it('rejects non-bigint values', () => { - expect(() => u64().encode(1 as unknown as bigint, new Uint8Array(8))).to.throw('Expected a `BigInt`'); - }); - }); - - it('encodes and decodes bool', () => { - const buffer = new Uint8Array(2); - bool().encode(true, buffer, 1); - expect(Array.from(buffer)).to.deep.equal([0, 1]); - expect(bool().decode(buffer, 1)).to.equal(true); - expect(bool().decode(buffer, 0)).to.equal(false); - }); - - it('encodes and decodes publicKey', () => { - const key = PublicKey.unique(); - const buffer = new Uint8Array(33); - expect(publicKey().encode(key, buffer, 1)).to.equal(32); - expect(Array.from(buffer.subarray(1))).to.deep.equal(Array.from(key.toBytes())); - expect(publicKey().decode(buffer, 1).equals(key)).to.equal(true); - }); -}); diff --git a/clients/js-legacy/tsconfig.base.json b/clients/js-legacy/tsconfig.base.json index 1ff7187ec..4e94c1db5 100644 --- a/clients/js-legacy/tsconfig.base.json +++ b/clients/js-legacy/tsconfig.base.json @@ -10,7 +10,6 @@ "resolveJsonModule": true, "strict": true, "stripInternal": true, - "types": ["node"], "ignoreDeprecations": "6.0" } }