Socket
Socket
Sign inDemoInstall

@solana/spl-token

Package Overview
Dependencies
Maintainers
14
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/spl-token - npm Package Compare versions

Comparing version 0.3.9 to 0.3.10

lib/cjs/extensions/tokenMetadata/actions.js

28

lib/cjs/extensions/extensionType.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccountLenForMint = exports.getExtensionTypes = exports.getExtensionData = exports.getAccountLen = exports.getMintLen = exports.getAccountTypeOfMintType = exports.isAccountExtension = exports.isMintExtension = exports.getTypeLen = exports.LENGTH_SIZE = exports.TYPE_SIZE = exports.ExtensionType = void 0;
exports.getNewAccountLenForExtensionLen = exports.getAccountLenForMint = exports.getExtensionTypes = exports.getExtensionData = exports.getAccountLen = exports.getMintLen = exports.getAccountTypeOfMintType = exports.isAccountExtension = exports.isMintExtension = exports.getTypeLen = exports.LENGTH_SIZE = exports.TYPE_SIZE = exports.ExtensionType = void 0;
const account_js_1 = require("../state/account.js");

@@ -19,2 +19,3 @@ const mint_js_1 = require("../state/mint.js");

const index_js_5 = require("./transferHook/index.js");
const constants_js_1 = require("../constants.js");
// Sequence from https://github.com/solana-labs/solana-program-library/blob/master/token/program-2022/src/extension/mod.rs#L903

@@ -42,5 +43,9 @@ var ExtensionType;

ExtensionType[ExtensionType["MetadataPointer"] = 18] = "MetadataPointer";
ExtensionType[ExtensionType["TokenMetadata"] = 19] = "TokenMetadata";
})(ExtensionType || (exports.ExtensionType = ExtensionType = {}));
exports.TYPE_SIZE = 2;
exports.LENGTH_SIZE = 2;
function addTypeAndLengthToLen(len) {
return len + exports.TYPE_SIZE + exports.LENGTH_SIZE;
}
// NOTE: All of these should eventually use their type's Span instead of these

@@ -84,2 +89,4 @@ // constants. This is provided for at least creation to work.

return index_js_5.TRANSFER_HOOK_ACCOUNT_SIZE;
case ExtensionType.TokenMetadata:
throw Error(`Cannot get type length for variable extension type: ${e}`);
default:

@@ -101,2 +108,3 @@ throw Error(`Unknown extension type: ${e}`);

case ExtensionType.MetadataPointer:
case ExtensionType.TokenMetadata:
return true;

@@ -137,2 +145,3 @@ case ExtensionType.Uninitialized:

case ExtensionType.MetadataPointer:
case ExtensionType.TokenMetadata:
return false;

@@ -162,2 +171,3 @@ default:

case ExtensionType.MetadataPointer:
case ExtensionType.TokenMetadata:
case ExtensionType.Uninitialized:

@@ -181,3 +191,3 @@ case ExtensionType.InterestBearingConfig:

.filter((element, i) => i === extensionTypes.indexOf(element))
.map((element) => getTypeLen(element) + exports.TYPE_SIZE + exports.LENGTH_SIZE)
.map((element) => addTypeAndLengthToLen(getTypeLen(element)))
.reduce((a, b) => a + b);

@@ -202,6 +212,6 @@ if (accountLength === multisig_js_1.MULTISIG_SIZE) {

let extensionTypeIndex = 0;
while (extensionTypeIndex + exports.TYPE_SIZE + exports.LENGTH_SIZE <= tlvData.length) {
while (addTypeAndLengthToLen(extensionTypeIndex) <= tlvData.length) {
const entryType = tlvData.readUInt16LE(extensionTypeIndex);
const entryLength = tlvData.readUInt16LE(extensionTypeIndex + exports.TYPE_SIZE);
const typeIndex = extensionTypeIndex + exports.TYPE_SIZE + exports.LENGTH_SIZE;
const typeIndex = addTypeAndLengthToLen(extensionTypeIndex);
if (entryType == extension) {

@@ -222,3 +232,3 @@ return tlvData.slice(typeIndex, typeIndex + entryLength);

const entryLength = tlvData.readUInt16LE(extensionTypeIndex + exports.TYPE_SIZE);
extensionTypeIndex += exports.TYPE_SIZE + exports.LENGTH_SIZE + entryLength;
extensionTypeIndex += addTypeAndLengthToLen(entryLength);
}

@@ -234,2 +244,10 @@ return extensionTypes;

exports.getAccountLenForMint = getAccountLenForMint;
function getNewAccountLenForExtensionLen(info, address, extensionType, extensionLen, programId = constants_js_1.TOKEN_2022_PROGRAM_ID) {
const mint = (0, mint_js_1.unpackMint)(address, info, programId);
const extensionData = getExtensionData(extensionType, mint.tlvData);
const currentExtensionLen = extensionData ? addTypeAndLengthToLen(extensionData.length) : 0;
const newExtensionLen = addTypeAndLengthToLen(extensionLen);
return info.data.length + newExtensionLen - currentExtensionLen;
}
exports.getNewAccountLenForExtensionLen = getNewAccountLenForExtensionLen;
//# sourceMappingURL=extensionType.js.map

@@ -25,2 +25,3 @@ "use strict";

__exportStar(require("./metadataPointer/index.js"), exports);
__exportStar(require("./tokenMetadata/index.js"), exports);
__exportStar(require("./mintCloseAuthority.js"), exports);

@@ -27,0 +28,0 @@ __exportStar(require("./nonTransferable.js"), exports);

@@ -17,2 +17,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createEmitInstruction = exports.createUpdateAuthorityInstruction = exports.createRemoveKeyInstruction = exports.createUpdateFieldInstruction = exports.createInitializeInstruction = void 0;
var spl_token_metadata_1 = require("@solana/spl-token-metadata");
Object.defineProperty(exports, "createInitializeInstruction", { enumerable: true, get: function () { return spl_token_metadata_1.createInitializeInstruction; } });
Object.defineProperty(exports, "createUpdateFieldInstruction", { enumerable: true, get: function () { return spl_token_metadata_1.createUpdateFieldInstruction; } });
Object.defineProperty(exports, "createRemoveKeyInstruction", { enumerable: true, get: function () { return spl_token_metadata_1.createRemoveKeyInstruction; } });
Object.defineProperty(exports, "createUpdateAuthorityInstruction", { enumerable: true, get: function () { return spl_token_metadata_1.createUpdateAuthorityInstruction; } });
Object.defineProperty(exports, "createEmitInstruction", { enumerable: true, get: function () { return spl_token_metadata_1.createEmitInstruction; } });
__exportStar(require("./associatedTokenAccount.js"), exports);

@@ -19,0 +26,0 @@ __exportStar(require("./decode.js"), exports);

import { ACCOUNT_SIZE } from '../state/account.js';
import { MINT_SIZE } from '../state/mint.js';
import { MINT_SIZE, unpackMint } from '../state/mint.js';
import { MULTISIG_SIZE } from '../state/multisig.js';

@@ -16,2 +16,3 @@ import { ACCOUNT_TYPE_SIZE } from './accountType.js';

import { TRANSFER_HOOK_ACCOUNT_SIZE, TRANSFER_HOOK_SIZE } from './transferHook/index.js';
import { TOKEN_2022_PROGRAM_ID } from '../constants.js';
// Sequence from https://github.com/solana-labs/solana-program-library/blob/master/token/program-2022/src/extension/mod.rs#L903

@@ -39,5 +40,9 @@ export var ExtensionType;

ExtensionType[ExtensionType["MetadataPointer"] = 18] = "MetadataPointer";
ExtensionType[ExtensionType["TokenMetadata"] = 19] = "TokenMetadata";
})(ExtensionType || (ExtensionType = {}));
export const TYPE_SIZE = 2;
export const LENGTH_SIZE = 2;
function addTypeAndLengthToLen(len) {
return len + TYPE_SIZE + LENGTH_SIZE;
}
// NOTE: All of these should eventually use their type's Span instead of these

@@ -81,2 +86,4 @@ // constants. This is provided for at least creation to work.

return TRANSFER_HOOK_ACCOUNT_SIZE;
case ExtensionType.TokenMetadata:
throw Error(`Cannot get type length for variable extension type: ${e}`);
default:

@@ -97,2 +104,3 @@ throw Error(`Unknown extension type: ${e}`);

case ExtensionType.MetadataPointer:
case ExtensionType.TokenMetadata:
return true;

@@ -132,2 +140,3 @@ case ExtensionType.Uninitialized:

case ExtensionType.MetadataPointer:
case ExtensionType.TokenMetadata:
return false;

@@ -156,2 +165,3 @@ default:

case ExtensionType.MetadataPointer:
case ExtensionType.TokenMetadata:
case ExtensionType.Uninitialized:

@@ -174,3 +184,3 @@ case ExtensionType.InterestBearingConfig:

.filter((element, i) => i === extensionTypes.indexOf(element))
.map((element) => getTypeLen(element) + TYPE_SIZE + LENGTH_SIZE)
.map((element) => addTypeAndLengthToLen(getTypeLen(element)))
.reduce((a, b) => a + b);

@@ -193,6 +203,6 @@ if (accountLength === MULTISIG_SIZE) {

let extensionTypeIndex = 0;
while (extensionTypeIndex + TYPE_SIZE + LENGTH_SIZE <= tlvData.length) {
while (addTypeAndLengthToLen(extensionTypeIndex) <= tlvData.length) {
const entryType = tlvData.readUInt16LE(extensionTypeIndex);
const entryLength = tlvData.readUInt16LE(extensionTypeIndex + TYPE_SIZE);
const typeIndex = extensionTypeIndex + TYPE_SIZE + LENGTH_SIZE;
const typeIndex = addTypeAndLengthToLen(extensionTypeIndex);
if (entryType == extension) {

@@ -212,3 +222,3 @@ return tlvData.slice(typeIndex, typeIndex + entryLength);

const entryLength = tlvData.readUInt16LE(extensionTypeIndex + TYPE_SIZE);
extensionTypeIndex += TYPE_SIZE + LENGTH_SIZE + entryLength;
extensionTypeIndex += addTypeAndLengthToLen(entryLength);
}

@@ -222,2 +232,9 @@ return extensionTypes;

}
export function getNewAccountLenForExtensionLen(info, address, extensionType, extensionLen, programId = TOKEN_2022_PROGRAM_ID) {
const mint = unpackMint(address, info, programId);
const extensionData = getExtensionData(extensionType, mint.tlvData);
const currentExtensionLen = extensionData ? addTypeAndLengthToLen(extensionData.length) : 0;
const newExtensionLen = addTypeAndLengthToLen(extensionLen);
return info.data.length + newExtensionLen - currentExtensionLen;
}
//# sourceMappingURL=extensionType.js.map

@@ -9,2 +9,3 @@ export * from './accountType.js';

export * from './metadataPointer/index.js';
export * from './tokenMetadata/index.js';
export * from './mintCloseAuthority.js';

@@ -11,0 +12,0 @@ export * from './nonTransferable.js';

@@ -0,1 +1,2 @@

export { createInitializeInstruction, createUpdateFieldInstruction, createRemoveKeyInstruction, createUpdateAuthorityInstruction, createEmitInstruction, } from '@solana/spl-token-metadata';
export * from './associatedTokenAccount.js';

@@ -2,0 +3,0 @@ export * from './decode.js';

5

lib/types/extensions/extensionType.d.ts
/// <reference types="node" />
import type { AccountInfo, PublicKey } from '@solana/web3.js';
import type { Mint } from '../state/mint.js';

@@ -20,3 +21,4 @@ export declare enum ExtensionType {

TransferHookAccount = 15,
MetadataPointer = 18
MetadataPointer = 18,// Remove number once above extensions implemented
TokenMetadata = 19
}

@@ -34,2 +36,3 @@ export declare const TYPE_SIZE = 2;

export declare function getAccountLenForMint(mint: Mint): number;
export declare function getNewAccountLenForExtensionLen(info: AccountInfo<Buffer>, address: PublicKey, extensionType: ExtensionType, extensionLen: number, programId?: PublicKey): number;
//# sourceMappingURL=extensionType.d.ts.map

@@ -9,2 +9,3 @@ export * from './accountType.js';

export * from './metadataPointer/index.js';
export * from './tokenMetadata/index.js';
export * from './mintCloseAuthority.js';

@@ -11,0 +12,0 @@ export * from './nonTransferable.js';

@@ -0,1 +1,2 @@

export { createInitializeInstruction, createUpdateFieldInstruction, createRemoveKeyInstruction, createUpdateAuthorityInstruction, createEmitInstruction, } from '@solana/spl-token-metadata';
export * from './associatedTokenAccount.js';

@@ -2,0 +3,0 @@ export * from './decode.js';

{
"name": "@solana/spl-token",
"description": "SPL Token Program JS API",
"version": "0.3.9",
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
"repository": "https://github.com/solana-labs/solana-program-library",
"license": "Apache-2.0",
"type": "module",
"sideEffects": false,
"engines": {
"node": ">=16"
},
"files": [
"lib",
"src",
"LICENSE",
"README.md"
],
"publishConfig": {
"access": "public"
},
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"name": "@solana/spl-token",
"description": "SPL Token Program JS API",
"version": "0.3.10",
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
"repository": "https://github.com/solana-labs/solana-program-library",
"license": "Apache-2.0",
"type": "module",
"sideEffects": false,
"engines": {
"node": ">=16"
},
"files": [
"lib",
"src",
"LICENSE",
"README.md"
],
"publishConfig": {
"access": "public"
},
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/types/index.d.ts",
"exports": {
"types": "./lib/types/index.d.ts",
"exports": {
"types": "./lib/types/index.d.ts",
"require": "./lib/cjs/index.js",
"import": "./lib/esm/index.js"
},
"scripts": {
"nuke": "shx rm -rf node_modules package-lock.json || true",
"reinstall": "npm run nuke && npm install",
"clean": "shx rm -rf lib **/*.tsbuildinfo || true",
"build": "tsc --build --verbose tsconfig.all.json",
"postbuild": "shx echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json",
"watch": "tsc --build --verbose --watch tsconfig.all.json",
"release": "npm run clean && npm run build",
"fmt": "prettier --write '{*,**/*}.{ts,tsx,js,jsx,json}'",
"lint": "prettier --check '{*,**/*}.{ts,tsx,js,jsx,json}' && eslint --max-warnings 0 .",
"lint:fix": "npm run fmt && eslint --fix .",
"example": "node --experimental-specifier-resolution=node --loader ts-node/esm examples/createMintAndTransferTokens.ts",
"test": "npm run test:unit && npm run test:e2e-built && npm run test:e2e-native && npm run test:e2e-2022",
"test:unit": "mocha test/unit",
"test:e2e-built": "start-server-and-test 'solana-test-validator --bpf-program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA ../../target/deploy/spl_token.so --reset --quiet' http://127.0.0.1:8899/health 'mocha test/e2e'",
"test:e2e-2022": "TEST_PROGRAM_ID=TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb start-server-and-test 'solana-test-validator --bpf-program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL ../../target/deploy/spl_associated_token_account.so --bpf-program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb ../../target/deploy/spl_token_2022.so --bpf-program TokenHookExampLe8smaVNrxTBezWTRbEwxwb1Zykrb ../../target/deploy/spl_transfer_hook_example.so --reset --quiet' http://127.0.0.1:8899/health 'mocha test/e2e*'",
"test:e2e-native": "start-server-and-test 'solana-test-validator --reset --quiet' http://127.0.0.1:8899/health 'mocha test/e2e'",
"test:build-programs": "cargo build-sbf --manifest-path ../program/Cargo.toml && cargo build-sbf --manifest-path ../program-2022/Cargo.toml && cargo build-sbf --manifest-path ../../associated-token-account/program/Cargo.toml",
"deploy": "npm run deploy:docs",
"docs": "shx rm -rf docs && typedoc && shx cp .nojekyll docs/",
"deploy:docs": "npm run docs && gh-pages --dest token/js --dist docs --dotfiles"
},
"peerDependencies": {
"@solana/web3.js": "^1.47.4"
},
"dependencies": {
"@solana/buffer-layout": "^4.0.0",
"@solana/buffer-layout-utils": "^0.2.0",
"buffer": "^6.0.3"
},
"devDependencies": {
"@solana/spl-memo": "workspace:*",
"@solana/web3.js": "^1.47.4",
"@types/chai-as-promised": "^7.1.4",
"@types/chai": "^4.3.3",
"@types/mocha": "^10.0.0",
"@types/node": "^20.1.1",
"@types/node-fetch": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.0.0",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"eslint": "^8.20.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-require-extensions": "^0.1.1",
"gh-pages": "^6.0.0",
"mocha": "^10.1.0",
"prettier": "^3.1.0",
"process": "^0.11.10",
"shx": "^0.3.4",
"start-server-and-test": "^2.0.0",
"tslib": "^2.3.1",
"ts-node": "^10.9.1",
"typedoc": "^0.25.0",
"typescript": "^5.0.4"
}
}
"require": "./lib/cjs/index.js",
"import": "./lib/esm/index.js"
},
"peerDependencies": {
"@solana/web3.js": "^1.87.6"
},
"dependencies": {
"@solana/buffer-layout": "^4.0.0",
"@solana/buffer-layout-utils": "^0.2.0",
"@solana/spl-token-metadata": "^0.1.2",
"buffer": "^6.0.3"
},
"devDependencies": {
"@solana/codecs-strings": "2.0.0-experimental.9741939",
"@solana/spl-memo": "0.2.3",
"@solana/web3.js": "^1.87.6",
"@types/chai-as-promised": "^7.1.4",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@types/node": "^20.10.6",
"@types/node-fetch": "^2.6.10",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-require-extensions": "^0.1.1",
"gh-pages": "^6.1.1",
"mocha": "^10.1.0",
"prettier": "^3.1.1",
"process": "^0.11.10",
"shx": "^0.3.4",
"start-server-and-test": "^2.0.3",
"tslib": "^2.3.1",
"ts-node": "^10.9.2",
"typedoc": "^0.25.6",
"typescript": "^5.3.3"
},
"scripts": {
"nuke": "shx rm -rf node_modules package-lock.json || true",
"reinstall": "npm run nuke && npm install",
"clean": "shx rm -rf lib **/*.tsbuildinfo || true",
"build": "tsc --build --verbose tsconfig.all.json",
"postbuild": "shx echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json",
"build:program": "cargo build-sbf --manifest-path=../program/Cargo.toml && cargo build-sbf --manifest-path=../program-2022/Cargo.toml && cargo build-sbf --manifest-path=../../associated-token-account/program/Cargo.toml && cargo build-sbf --manifest-path=../transfer-hook/example/Cargo.toml",
"watch": "tsc --build --verbose --watch tsconfig.all.json",
"release": "npm run clean && npm run build",
"fmt": "prettier --write '{*,**/*}.{ts,tsx,js,jsx,json}'",
"lint": "prettier --check '{*,**/*}.{ts,tsx,js,jsx,json}' && eslint --max-warnings 0 .",
"lint:fix": "npm run fmt && eslint --fix .",
"example": "node --experimental-specifier-resolution=node --loader ts-node/esm examples/createMintAndTransferTokens.ts",
"test": "npm run test:unit && npm run test:e2e-built && npm run test:e2e-native && npm run test:e2e-2022",
"test:unit": "mocha test/unit",
"test:e2e-built": "start-server-and-test 'solana-test-validator --bpf-program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA ../../target/deploy/spl_token.so --reset --quiet' http://127.0.0.1:8899/health 'mocha test/e2e'",
"test:e2e-2022": "TEST_PROGRAM_ID=TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb start-server-and-test 'solana-test-validator --bpf-program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL ../../target/deploy/spl_associated_token_account.so --bpf-program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb ../../target/deploy/spl_token_2022.so --bpf-program TokenHookExampLe8smaVNrxTBezWTRbEwxwb1Zykrb ../../target/deploy/spl_transfer_hook_example.so --reset --quiet' http://127.0.0.1:8899/health 'mocha test/e2e*'",
"test:e2e-native": "start-server-and-test 'solana-test-validator --reset --quiet' http://127.0.0.1:8899/health 'mocha test/e2e'",
"test:build-programs": "cargo build-sbf --manifest-path ../program/Cargo.toml && cargo build-sbf --manifest-path ../program-2022/Cargo.toml && cargo build-sbf --manifest-path ../../associated-token-account/program/Cargo.toml",
"deploy": "npm run deploy:docs",
"docs": "shx rm -rf docs && typedoc && shx cp .nojekyll docs/",
"deploy:docs": "npm run docs && gh-pages --dest token/js --dist docs --dotfiles"
}
}

@@ -0,4 +1,6 @@

import type { AccountInfo, PublicKey } from '@solana/web3.js';
import { ACCOUNT_SIZE } from '../state/account.js';
import type { Mint } from '../state/mint.js';
import { MINT_SIZE } from '../state/mint.js';
import { MINT_SIZE, unpackMint } from '../state/mint.js';
import { MULTISIG_SIZE } from '../state/multisig.js';

@@ -17,2 +19,3 @@ import { ACCOUNT_TYPE_SIZE } from './accountType.js';

import { TRANSFER_HOOK_ACCOUNT_SIZE, TRANSFER_HOOK_SIZE } from './transferHook/index.js';
import { TOKEN_2022_PROGRAM_ID } from '../constants.js';

@@ -40,2 +43,3 @@ // Sequence from https://github.com/solana-labs/solana-program-library/blob/master/token/program-2022/src/extension/mod.rs#L903

MetadataPointer = 18, // Remove number once above extensions implemented
TokenMetadata = 19, // Remove number once above extensions implemented
}

@@ -46,2 +50,6 @@

function addTypeAndLengthToLen(len: number): number {
return len + TYPE_SIZE + LENGTH_SIZE;
}
// NOTE: All of these should eventually use their type's Span instead of these

@@ -85,2 +93,4 @@ // constants. This is provided for at least creation to work.

return TRANSFER_HOOK_ACCOUNT_SIZE;
case ExtensionType.TokenMetadata:
throw Error(`Cannot get type length for variable extension type: ${e}`);
default:

@@ -102,2 +112,3 @@ throw Error(`Unknown extension type: ${e}`);

case ExtensionType.MetadataPointer:
case ExtensionType.TokenMetadata:
return true;

@@ -138,2 +149,3 @@ case ExtensionType.Uninitialized:

case ExtensionType.MetadataPointer:
case ExtensionType.TokenMetadata:
return false;

@@ -163,2 +175,3 @@ default:

case ExtensionType.MetadataPointer:
case ExtensionType.TokenMetadata:
case ExtensionType.Uninitialized:

@@ -182,3 +195,3 @@ case ExtensionType.InterestBearingConfig:

.filter((element, i) => i === extensionTypes.indexOf(element))
.map((element) => getTypeLen(element) + TYPE_SIZE + LENGTH_SIZE)
.map((element) => addTypeAndLengthToLen(getTypeLen(element)))
.reduce((a, b) => a + b);

@@ -203,6 +216,6 @@ if (accountLength === MULTISIG_SIZE) {

let extensionTypeIndex = 0;
while (extensionTypeIndex + TYPE_SIZE + LENGTH_SIZE <= tlvData.length) {
while (addTypeAndLengthToLen(extensionTypeIndex) <= tlvData.length) {
const entryType = tlvData.readUInt16LE(extensionTypeIndex);
const entryLength = tlvData.readUInt16LE(extensionTypeIndex + TYPE_SIZE);
const typeIndex = extensionTypeIndex + TYPE_SIZE + LENGTH_SIZE;
const typeIndex = addTypeAndLengthToLen(extensionTypeIndex);
if (entryType == extension) {

@@ -223,3 +236,3 @@ return tlvData.slice(typeIndex, typeIndex + entryLength);

const entryLength = tlvData.readUInt16LE(extensionTypeIndex + TYPE_SIZE);
extensionTypeIndex += TYPE_SIZE + LENGTH_SIZE + entryLength;
extensionTypeIndex += addTypeAndLengthToLen(entryLength);
}

@@ -234,1 +247,17 @@ return extensionTypes;

}
export function getNewAccountLenForExtensionLen(
info: AccountInfo<Buffer>,
address: PublicKey,
extensionType: ExtensionType,
extensionLen: number,
programId = TOKEN_2022_PROGRAM_ID
): number {
const mint = unpackMint(address, info, programId);
const extensionData = getExtensionData(extensionType, mint.tlvData);
const currentExtensionLen = extensionData ? addTypeAndLengthToLen(extensionData.length) : 0;
const newExtensionLen = addTypeAndLengthToLen(extensionLen);
return info.data.length + newExtensionLen - currentExtensionLen;
}

@@ -9,2 +9,3 @@ export * from './accountType.js';

export * from './metadataPointer/index.js';
export * from './tokenMetadata/index.js';
export * from './mintCloseAuthority.js';

@@ -11,0 +12,0 @@ export * from './nonTransferable.js';

@@ -0,1 +1,9 @@

export {
createInitializeInstruction,
createUpdateFieldInstruction,
createRemoveKeyInstruction,
createUpdateAuthorityInstruction,
createEmitInstruction,
} from '@solana/spl-token-metadata';
export * from './associatedTokenAccount.js';

@@ -2,0 +10,0 @@ export * from './decode.js';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc