Socket
Socket
Sign inDemoInstall

@solana/spl-token

Package Overview
Dependencies
Maintainers
13
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.6 to 0.3.7

lib/cjs/extensions/cpiGuard/actions.js

7

lib/cjs/extensions/defaultAccountState/instructions.js

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

const errors_js_1 = require("../../errors.js");
const internal_js_1 = require("../../instructions/internal.js");
const types_js_1 = require("../../instructions/types.js");

@@ -59,7 +60,3 @@ var DefaultAccountStateInstruction;

}
const keys = [{ pubkey: mint, isSigner: false, isWritable: true }];
keys.push({ pubkey: freezeAuthority, isSigner: !multiSigners.length, isWritable: false });
for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = (0, internal_js_1.addSigners)([{ pubkey: mint, isSigner: false, isWritable: true }], freezeAuthority, multiSigners);
const data = Buffer.alloc(exports.defaultAccountStateInstructionData.span);

@@ -66,0 +63,0 @@ exports.defaultAccountStateInstructionData.encode({

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccountLenForMint = exports.getExtensionTypes = exports.getExtensionData = exports.getAccountLen = exports.getMintLen = exports.getAccountTypeOfMintType = exports.getTypeLen = exports.LENGTH_SIZE = exports.TYPE_SIZE = exports.ExtensionType = void 0;
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");

@@ -8,9 +8,11 @@ const mint_js_1 = require("../state/mint.js");

const accountType_js_1 = require("./accountType.js");
const index_js_1 = require("./defaultAccountState/index.js");
const index_js_1 = require("./cpiGuard/index.js");
const index_js_2 = require("./defaultAccountState/index.js");
const immutableOwner_js_1 = require("./immutableOwner.js");
const state_js_1 = require("./interestBearingMint/state.js");
const index_js_2 = require("./memoTransfer/index.js");
const index_js_3 = require("./memoTransfer/index.js");
const mintCloseAuthority_js_1 = require("./mintCloseAuthority.js");
const nonTransferable_js_1 = require("./nonTransferable.js");
const index_js_3 = require("./transferFee/index.js");
const permanentDelegate_js_1 = require("./permanentDelegate.js");
const index_js_4 = require("./transferFee/index.js");
var ExtensionType;

@@ -28,3 +30,5 @@ (function (ExtensionType) {

ExtensionType[ExtensionType["NonTransferable"] = 9] = "NonTransferable";
ExtensionType[ExtensionType["InterestBearingMint"] = 10] = "InterestBearingMint";
ExtensionType[ExtensionType["InterestBearingConfig"] = 10] = "InterestBearingConfig";
ExtensionType[ExtensionType["CpiGuard"] = 11] = "CpiGuard";
ExtensionType[ExtensionType["PermanentDelegate"] = 12] = "PermanentDelegate";
})(ExtensionType = exports.ExtensionType || (exports.ExtensionType = {}));

@@ -40,5 +44,5 @@ exports.TYPE_SIZE = 2;

case ExtensionType.TransferFeeConfig:
return index_js_3.TRANSFER_FEE_CONFIG_SIZE;
return index_js_4.TRANSFER_FEE_CONFIG_SIZE;
case ExtensionType.TransferFeeAmount:
return index_js_3.TRANSFER_FEE_AMOUNT_SIZE;
return index_js_4.TRANSFER_FEE_AMOUNT_SIZE;
case ExtensionType.MintCloseAuthority:

@@ -50,12 +54,16 @@ return mintCloseAuthority_js_1.MINT_CLOSE_AUTHORITY_SIZE;

return 286;
case ExtensionType.CpiGuard:
return index_js_1.CPI_GUARD_SIZE;
case ExtensionType.DefaultAccountState:
return index_js_1.DEFAULT_ACCOUNT_STATE_SIZE;
return index_js_2.DEFAULT_ACCOUNT_STATE_SIZE;
case ExtensionType.ImmutableOwner:
return immutableOwner_js_1.IMMUTABLE_OWNER_SIZE;
case ExtensionType.MemoTransfer:
return index_js_2.MEMO_TRANSFER_SIZE;
return index_js_3.MEMO_TRANSFER_SIZE;
case ExtensionType.NonTransferable:
return nonTransferable_js_1.NON_TRANSFERABLE_SIZE;
case ExtensionType.InterestBearingMint:
case ExtensionType.InterestBearingConfig:
return state_js_1.INTEREST_BEARING_MINT_CONFIG_STATE_SIZE;
case ExtensionType.PermanentDelegate:
return permanentDelegate_js_1.PERMANENT_DELEGATE_SIZE;
default:

@@ -66,2 +74,46 @@ throw Error(`Unknown extension type: ${e}`);

exports.getTypeLen = getTypeLen;
function isMintExtension(e) {
switch (e) {
case ExtensionType.TransferFeeConfig:
case ExtensionType.MintCloseAuthority:
case ExtensionType.ConfidentialTransferMint:
case ExtensionType.DefaultAccountState:
case ExtensionType.NonTransferable:
case ExtensionType.InterestBearingConfig:
case ExtensionType.PermanentDelegate:
return true;
case ExtensionType.Uninitialized:
case ExtensionType.TransferFeeAmount:
case ExtensionType.ConfidentialTransferAccount:
case ExtensionType.ImmutableOwner:
case ExtensionType.MemoTransfer:
case ExtensionType.CpiGuard:
return false;
default:
throw Error(`Unknown extension type: ${e}`);
}
}
exports.isMintExtension = isMintExtension;
function isAccountExtension(e) {
switch (e) {
case ExtensionType.TransferFeeAmount:
case ExtensionType.ConfidentialTransferAccount:
case ExtensionType.ImmutableOwner:
case ExtensionType.MemoTransfer:
case ExtensionType.CpiGuard:
return true;
case ExtensionType.Uninitialized:
case ExtensionType.TransferFeeConfig:
case ExtensionType.MintCloseAuthority:
case ExtensionType.ConfidentialTransferMint:
case ExtensionType.DefaultAccountState:
case ExtensionType.NonTransferable:
case ExtensionType.InterestBearingConfig:
case ExtensionType.PermanentDelegate:
return false;
default:
throw Error(`Unknown extension type: ${e}`);
}
}
exports.isAccountExtension = isAccountExtension;
function getAccountTypeOfMintType(e) {

@@ -75,2 +127,3 @@ switch (e) {

case ExtensionType.ConfidentialTransferAccount:
case ExtensionType.CpiGuard:
case ExtensionType.DefaultAccountState:

@@ -82,3 +135,4 @@ case ExtensionType.ImmutableOwner:

case ExtensionType.Uninitialized:
case ExtensionType.InterestBearingMint:
case ExtensionType.InterestBearingConfig:
case ExtensionType.PermanentDelegate:
return ExtensionType.Uninitialized;

@@ -117,3 +171,3 @@ }

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

@@ -120,0 +174,0 @@ const entryLength = tlvData.readUInt16LE(extensionTypeIndex + exports.TYPE_SIZE);

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

__exportStar(require("./accountType.js"), exports);
__exportStar(require("./cpiGuard/index.js"), exports);
__exportStar(require("./defaultAccountState/index.js"), exports);

@@ -27,2 +28,3 @@ __exportStar(require("./extensionType.js"), exports);

__exportStar(require("./transferFee/index.js"), exports);
__exportStar(require("./permanentDelegate.js"), exports);
//# sourceMappingURL=index.js.map

@@ -37,3 +37,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
const mintLen = (0, extensionType_js_1.getMintLen)([extensionType_js_1.ExtensionType.InterestBearingMint]);
const mintLen = (0, extensionType_js_1.getMintLen)([extensionType_js_1.ExtensionType.InterestBearingConfig]);
const lamports = yield connection.getMinimumBalanceForRentExemption(mintLen);

@@ -40,0 +40,0 @@ const transaction = new web3_js_1.Transaction().add(web3_js_1.SystemProgram.createAccount({

@@ -16,3 +16,3 @@ "use strict";

function getInterestBearingMintConfigState(mint) {
const extensionData = (0, extensionType_js_1.getExtensionData)(extensionType_js_1.ExtensionType.InterestBearingMint, mint.tlvData);
const extensionData = (0, extensionType_js_1.getExtensionData)(extensionType_js_1.ExtensionType.InterestBearingConfig, mint.tlvData);
if (extensionData !== null) {

@@ -19,0 +19,0 @@ return exports.InterestBearingMintConfigStateLayout.decode(extensionData);

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

const errors_js_1 = require("../../errors.js");
const internal_js_1 = require("../../instructions/internal.js");
const types_js_1 = require("../../instructions/types.js");

@@ -31,3 +32,3 @@ var MemoTransferInstruction;

function createEnableRequiredMemoTransfersInstruction(account, authority, multiSigners = [], programId = constants_js_1.TOKEN_2022_PROGRAM_ID) {
return createMemoTransferInstruction(/* enable */ true, account, authority, multiSigners, programId);
return createMemoTransferInstruction(MemoTransferInstruction.Enable, account, authority, multiSigners, programId);
}

@@ -46,18 +47,14 @@ exports.createEnableRequiredMemoTransfersInstruction = createEnableRequiredMemoTransfersInstruction;

function createDisableRequiredMemoTransfersInstruction(account, authority, multiSigners = [], programId = constants_js_1.TOKEN_2022_PROGRAM_ID) {
return createMemoTransferInstruction(/* enable */ false, account, authority, multiSigners, programId);
return createMemoTransferInstruction(MemoTransferInstruction.Disable, account, authority, multiSigners, programId);
}
exports.createDisableRequiredMemoTransfersInstruction = createDisableRequiredMemoTransfersInstruction;
function createMemoTransferInstruction(enable, account, authority, multiSigners, programId) {
function createMemoTransferInstruction(memoTransferInstruction, account, authority, multiSigners, programId) {
if (!(0, constants_js_1.programSupportsExtensions)(programId)) {
throw new errors_js_1.TokenUnsupportedInstructionError();
}
const keys = [{ pubkey: account, isSigner: false, isWritable: true }];
keys.push({ pubkey: authority, isSigner: !multiSigners.length, isWritable: false });
for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = (0, internal_js_1.addSigners)([{ pubkey: account, isSigner: false, isWritable: true }], authority, multiSigners);
const data = Buffer.alloc(exports.memoTransferInstructionData.span);
exports.memoTransferInstructionData.encode({
instruction: types_js_1.TokenInstruction.MemoTransferExtension,
memoTransferInstruction: enable ? MemoTransferInstruction.Enable : MemoTransferInstruction.Disable,
memoTransferInstruction,
}, data);

@@ -64,0 +61,0 @@ return new web3_js_1.TransactionInstruction({ keys, programId, data });

@@ -7,3 +7,3 @@ "use strict";

const extensionType_js_1 = require("../extensionType.js");
/** Buffer layout for de/serializing a transfer fee config extension */
/** Buffer layout for de/serializing a memo transfer extension */
exports.MemoTransferLayout = (0, buffer_layout_1.struct)([(0, buffer_layout_utils_1.bool)('requireIncomingTransferMemos')]);

@@ -10,0 +10,0 @@ exports.MEMO_TRANSFER_SIZE = exports.MemoTransferLayout.span;

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

const errors_js_1 = require("../../errors.js");
const internal_js_1 = require("../../instructions/internal.js");
const types_js_1 = require("../../instructions/types.js");

@@ -149,10 +150,7 @@ var TransferFeeInstruction;

}, data);
const keys = [];
keys.push({ pubkey: source, isSigner: false, isWritable: true });
keys.push({ pubkey: mint, isSigner: false, isWritable: false });
keys.push({ pubkey: destination, isSigner: false, isWritable: true });
keys.push({ pubkey: authority, isSigner: !multiSigners.length, isWritable: false });
for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = (0, internal_js_1.addSigners)([
{ pubkey: source, isSigner: false, isWritable: true },
{ pubkey: mint, isSigner: false, isWritable: false },
{ pubkey: destination, isSigner: false, isWritable: true },
], authority, multiSigners);
return new web3_js_1.TransactionInstruction({ keys, programId, data });

@@ -245,7 +243,6 @@ }

}, data);
const keys = [];
keys.push({ pubkey: mint, isSigner: false, isWritable: true }, { pubkey: destination, isSigner: false, isWritable: true }, { pubkey: authority, isSigner: !signers.length, isWritable: false });
for (const signer of signers) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = (0, internal_js_1.addSigners)([
{ pubkey: mint, isSigner: false, isWritable: true },
{ pubkey: destination, isSigner: false, isWritable: true },
], authority, signers);
return new web3_js_1.TransactionInstruction({ keys, programId, data });

@@ -336,7 +333,6 @@ }

}, data);
const keys = [];
keys.push({ pubkey: mint, isSigner: false, isWritable: true }, { pubkey: destination, isSigner: false, isWritable: true }, { pubkey: authority, isSigner: !signers.length, isWritable: false });
for (const signer of signers) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = (0, internal_js_1.addSigners)([
{ pubkey: mint, isSigner: false, isWritable: true },
{ pubkey: destination, isSigner: false, isWritable: true },
], authority, signers);
for (const source of sources) {

@@ -343,0 +339,0 @@ keys.push({ pubkey: source, isSigner: false, isWritable: true });

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

__exportStar(require("./initializeNonTransferableMint.js"), exports); // 32
__exportStar(require("./initializePermanentDelegate.js"), exports); // 35
//# sourceMappingURL=index.js.map

@@ -30,3 +30,7 @@ "use strict";

for (const signer of signers) {
keys.push({ pubkey: signer, isSigner: false, isWritable: false });
keys.push({
pubkey: signer instanceof web3_js_1.PublicKey ? signer : signer.publicKey,
isSigner: false,
isWritable: false,
});
}

@@ -33,0 +37,0 @@ const data = Buffer.alloc(exports.initializeMultisigInstructionData.span);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addSigners = void 0;
const web3_js_1 = require("@solana/web3.js");
/** @internal */

@@ -9,3 +10,7 @@ function addSigners(keys, ownerOrAuthority, multiSigners) {

for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
keys.push({
pubkey: signer instanceof web3_js_1.PublicKey ? signer : signer.publicKey,
isSigner: true,
isWritable: false,
});
}

@@ -12,0 +17,0 @@ }

@@ -41,3 +41,5 @@ "use strict";

TokenInstruction[TokenInstruction["InterestBearingMintExtension"] = 33] = "InterestBearingMintExtension";
TokenInstruction[TokenInstruction["CpiGuardExtension"] = 34] = "CpiGuardExtension";
TokenInstruction[TokenInstruction["InitializePermanentDelegate"] = 35] = "InitializePermanentDelegate";
})(TokenInstruction = exports.TokenInstruction || (exports.TokenInstruction = {}));
//# sourceMappingURL=types.js.map

@@ -5,2 +5,3 @@ import { struct, u8 } from '@solana/buffer-layout';

import { TokenUnsupportedInstructionError } from '../../errors.js';
import { addSigners } from '../../instructions/internal.js';
import { TokenInstruction } from '../../instructions/types.js';

@@ -55,7 +56,3 @@ export var DefaultAccountStateInstruction;

}
const keys = [{ pubkey: mint, isSigner: false, isWritable: true }];
keys.push({ pubkey: freezeAuthority, isSigner: !multiSigners.length, isWritable: false });
for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = addSigners([{ pubkey: mint, isSigner: false, isWritable: true }], freezeAuthority, multiSigners);
const data = Buffer.alloc(defaultAccountStateInstructionData.span);

@@ -62,0 +59,0 @@ defaultAccountStateInstructionData.encode({

@@ -5,2 +5,3 @@ import { ACCOUNT_SIZE } from '../state/account.js';

import { ACCOUNT_TYPE_SIZE } from './accountType.js';
import { CPI_GUARD_SIZE } from './cpiGuard/index.js';
import { DEFAULT_ACCOUNT_STATE_SIZE } from './defaultAccountState/index.js';

@@ -12,2 +13,3 @@ import { IMMUTABLE_OWNER_SIZE } from './immutableOwner.js';

import { NON_TRANSFERABLE_SIZE } from './nonTransferable.js';
import { PERMANENT_DELEGATE_SIZE } from './permanentDelegate.js';
import { TRANSFER_FEE_AMOUNT_SIZE, TRANSFER_FEE_CONFIG_SIZE } from './transferFee/index.js';

@@ -26,3 +28,5 @@ export var ExtensionType;

ExtensionType[ExtensionType["NonTransferable"] = 9] = "NonTransferable";
ExtensionType[ExtensionType["InterestBearingMint"] = 10] = "InterestBearingMint";
ExtensionType[ExtensionType["InterestBearingConfig"] = 10] = "InterestBearingConfig";
ExtensionType[ExtensionType["CpiGuard"] = 11] = "CpiGuard";
ExtensionType[ExtensionType["PermanentDelegate"] = 12] = "PermanentDelegate";
})(ExtensionType || (ExtensionType = {}));

@@ -47,2 +51,4 @@ export const TYPE_SIZE = 2;

return 286;
case ExtensionType.CpiGuard:
return CPI_GUARD_SIZE;
case ExtensionType.DefaultAccountState:

@@ -56,4 +62,6 @@ return DEFAULT_ACCOUNT_STATE_SIZE;

return NON_TRANSFERABLE_SIZE;
case ExtensionType.InterestBearingMint:
case ExtensionType.InterestBearingConfig:
return INTEREST_BEARING_MINT_CONFIG_STATE_SIZE;
case ExtensionType.PermanentDelegate:
return PERMANENT_DELEGATE_SIZE;
default:

@@ -63,2 +71,44 @@ throw Error(`Unknown extension type: ${e}`);

}
export function isMintExtension(e) {
switch (e) {
case ExtensionType.TransferFeeConfig:
case ExtensionType.MintCloseAuthority:
case ExtensionType.ConfidentialTransferMint:
case ExtensionType.DefaultAccountState:
case ExtensionType.NonTransferable:
case ExtensionType.InterestBearingConfig:
case ExtensionType.PermanentDelegate:
return true;
case ExtensionType.Uninitialized:
case ExtensionType.TransferFeeAmount:
case ExtensionType.ConfidentialTransferAccount:
case ExtensionType.ImmutableOwner:
case ExtensionType.MemoTransfer:
case ExtensionType.CpiGuard:
return false;
default:
throw Error(`Unknown extension type: ${e}`);
}
}
export function isAccountExtension(e) {
switch (e) {
case ExtensionType.TransferFeeAmount:
case ExtensionType.ConfidentialTransferAccount:
case ExtensionType.ImmutableOwner:
case ExtensionType.MemoTransfer:
case ExtensionType.CpiGuard:
return true;
case ExtensionType.Uninitialized:
case ExtensionType.TransferFeeConfig:
case ExtensionType.MintCloseAuthority:
case ExtensionType.ConfidentialTransferMint:
case ExtensionType.DefaultAccountState:
case ExtensionType.NonTransferable:
case ExtensionType.InterestBearingConfig:
case ExtensionType.PermanentDelegate:
return false;
default:
throw Error(`Unknown extension type: ${e}`);
}
}
export function getAccountTypeOfMintType(e) {

@@ -72,2 +122,3 @@ switch (e) {

case ExtensionType.ConfidentialTransferAccount:
case ExtensionType.CpiGuard:
case ExtensionType.DefaultAccountState:

@@ -79,3 +130,4 @@ case ExtensionType.ImmutableOwner:

case ExtensionType.Uninitialized:
case ExtensionType.InterestBearingMint:
case ExtensionType.InterestBearingConfig:
case ExtensionType.PermanentDelegate:
return ExtensionType.Uninitialized;

@@ -111,3 +163,3 @@ }

let extensionTypeIndex = 0;
while (extensionTypeIndex < tlvData.length) {
while (extensionTypeIndex + TYPE_SIZE + LENGTH_SIZE <= tlvData.length) {
const entryType = tlvData.readUInt16LE(extensionTypeIndex);

@@ -114,0 +166,0 @@ const entryLength = tlvData.readUInt16LE(extensionTypeIndex + TYPE_SIZE);

export * from './accountType.js';
export * from './cpiGuard/index.js';
export * from './defaultAccountState/index.js';

@@ -10,2 +11,3 @@ export * from './extensionType.js';

export * from './transferFee/index.js';
export * from './permanentDelegate.js';
//# sourceMappingURL=index.js.map

@@ -24,3 +24,3 @@ import { Keypair, sendAndConfirmTransaction, SystemProgram, Transaction } from '@solana/web3.js';

export async function createInterestBearingMint(connection, payer, mintAuthority, freezeAuthority, rateAuthority, rate, decimals, keypair = Keypair.generate(), confirmOptions, programId = TOKEN_2022_PROGRAM_ID) {
const mintLen = getMintLen([ExtensionType.InterestBearingMint]);
const mintLen = getMintLen([ExtensionType.InterestBearingConfig]);
const lamports = await connection.getMinimumBalanceForRentExemption(mintLen);

@@ -27,0 +27,0 @@ const transaction = new Transaction().add(SystemProgram.createAccount({

@@ -13,3 +13,3 @@ import { ns64, s16, struct } from '@solana/buffer-layout';

export function getInterestBearingMintConfigState(mint) {
const extensionData = getExtensionData(ExtensionType.InterestBearingMint, mint.tlvData);
const extensionData = getExtensionData(ExtensionType.InterestBearingConfig, mint.tlvData);
if (extensionData !== null) {

@@ -16,0 +16,0 @@ return InterestBearingMintConfigStateLayout.decode(extensionData);

@@ -5,2 +5,3 @@ import { struct, u8 } from '@solana/buffer-layout';

import { TokenUnsupportedInstructionError } from '../../errors.js';
import { addSigners } from '../../instructions/internal.js';
import { TokenInstruction } from '../../instructions/types.js';

@@ -28,3 +29,3 @@ export var MemoTransferInstruction;

export function createEnableRequiredMemoTransfersInstruction(account, authority, multiSigners = [], programId = TOKEN_2022_PROGRAM_ID) {
return createMemoTransferInstruction(/* enable */ true, account, authority, multiSigners, programId);
return createMemoTransferInstruction(MemoTransferInstruction.Enable, account, authority, multiSigners, programId);
}

@@ -42,17 +43,13 @@ /**

export function createDisableRequiredMemoTransfersInstruction(account, authority, multiSigners = [], programId = TOKEN_2022_PROGRAM_ID) {
return createMemoTransferInstruction(/* enable */ false, account, authority, multiSigners, programId);
return createMemoTransferInstruction(MemoTransferInstruction.Disable, account, authority, multiSigners, programId);
}
function createMemoTransferInstruction(enable, account, authority, multiSigners, programId) {
function createMemoTransferInstruction(memoTransferInstruction, account, authority, multiSigners, programId) {
if (!programSupportsExtensions(programId)) {
throw new TokenUnsupportedInstructionError();
}
const keys = [{ pubkey: account, isSigner: false, isWritable: true }];
keys.push({ pubkey: authority, isSigner: !multiSigners.length, isWritable: false });
for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = addSigners([{ pubkey: account, isSigner: false, isWritable: true }], authority, multiSigners);
const data = Buffer.alloc(memoTransferInstructionData.span);
memoTransferInstructionData.encode({
instruction: TokenInstruction.MemoTransferExtension,
memoTransferInstruction: enable ? MemoTransferInstruction.Enable : MemoTransferInstruction.Disable,
memoTransferInstruction,
}, data);

@@ -59,0 +56,0 @@ return new TransactionInstruction({ keys, programId, data });

import { struct } from '@solana/buffer-layout';
import { bool } from '@solana/buffer-layout-utils';
import { ExtensionType, getExtensionData } from '../extensionType.js';
/** Buffer layout for de/serializing a transfer fee config extension */
/** Buffer layout for de/serializing a memo transfer extension */
export const MemoTransferLayout = struct([bool('requireIncomingTransferMemos')]);

@@ -6,0 +6,0 @@ export const MEMO_TRANSFER_SIZE = MemoTransferLayout.span;

@@ -6,2 +6,3 @@ import { struct, u16, u8 } from '@solana/buffer-layout';

import { TokenInvalidInstructionDataError, TokenInvalidInstructionKeysError, TokenInvalidInstructionProgramError, TokenInvalidInstructionTypeError, TokenUnsupportedInstructionError, } from '../../errors.js';
import { addSigners } from '../../instructions/internal.js';
import { TokenInstruction } from '../../instructions/types.js';

@@ -143,10 +144,7 @@ export var TransferFeeInstruction;

}, data);
const keys = [];
keys.push({ pubkey: source, isSigner: false, isWritable: true });
keys.push({ pubkey: mint, isSigner: false, isWritable: false });
keys.push({ pubkey: destination, isSigner: false, isWritable: true });
keys.push({ pubkey: authority, isSigner: !multiSigners.length, isWritable: false });
for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = addSigners([
{ pubkey: source, isSigner: false, isWritable: true },
{ pubkey: mint, isSigner: false, isWritable: false },
{ pubkey: destination, isSigner: false, isWritable: true },
], authority, multiSigners);
return new TransactionInstruction({ keys, programId, data });

@@ -236,7 +234,6 @@ }

}, data);
const keys = [];
keys.push({ pubkey: mint, isSigner: false, isWritable: true }, { pubkey: destination, isSigner: false, isWritable: true }, { pubkey: authority, isSigner: !signers.length, isWritable: false });
for (const signer of signers) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = addSigners([
{ pubkey: mint, isSigner: false, isWritable: true },
{ pubkey: destination, isSigner: false, isWritable: true },
], authority, signers);
return new TransactionInstruction({ keys, programId, data });

@@ -324,7 +321,6 @@ }

}, data);
const keys = [];
keys.push({ pubkey: mint, isSigner: false, isWritable: true }, { pubkey: destination, isSigner: false, isWritable: true }, { pubkey: authority, isSigner: !signers.length, isWritable: false });
for (const signer of signers) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = addSigners([
{ pubkey: mint, isSigner: false, isWritable: true },
{ pubkey: destination, isSigner: false, isWritable: true },
], authority, signers);
for (const source of sources) {

@@ -331,0 +327,0 @@ keys.push({ pubkey: source, isSigner: false, isWritable: true });

@@ -32,2 +32,3 @@ export * from './associatedTokenAccount.js';

export * from './initializeNonTransferableMint.js'; // 32
export * from './initializePermanentDelegate.js'; // 35
//# sourceMappingURL=index.js.map
import { struct, u8 } from '@solana/buffer-layout';
import { SYSVAR_RENT_PUBKEY, TransactionInstruction } from '@solana/web3.js';
import { PublicKey, SYSVAR_RENT_PUBKEY, TransactionInstruction } from '@solana/web3.js';
import { TOKEN_PROGRAM_ID } from '../constants.js';

@@ -27,3 +27,7 @@ import { TokenInvalidInstructionDataError, TokenInvalidInstructionKeysError, TokenInvalidInstructionProgramError, TokenInvalidInstructionTypeError, } from '../errors.js';

for (const signer of signers) {
keys.push({ pubkey: signer, isSigner: false, isWritable: false });
keys.push({
pubkey: signer instanceof PublicKey ? signer : signer.publicKey,
isSigner: false,
isWritable: false,
});
}

@@ -30,0 +34,0 @@ const data = Buffer.alloc(initializeMultisigInstructionData.span);

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

import { PublicKey } from '@solana/web3.js';
/** @internal */

@@ -6,3 +7,7 @@ export function addSigners(keys, ownerOrAuthority, multiSigners) {

for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
keys.push({
pubkey: signer instanceof PublicKey ? signer : signer.publicKey,
isSigner: true,
isWritable: false,
});
}

@@ -9,0 +14,0 @@ }

@@ -38,3 +38,5 @@ /** Instructions defined by the program */

TokenInstruction[TokenInstruction["InterestBearingMintExtension"] = 33] = "InterestBearingMintExtension";
TokenInstruction[TokenInstruction["CpiGuardExtension"] = 34] = "CpiGuardExtension";
TokenInstruction[TokenInstruction["InitializePermanentDelegate"] = 35] = "InitializePermanentDelegate";
})(TokenInstruction || (TokenInstruction = {}));
//# sourceMappingURL=types.js.map

@@ -38,3 +38,3 @@ import type { PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createUpdateDefaultAccountStateInstruction(mint: PublicKey, accountState: AccountState, freezeAuthority: PublicKey, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createUpdateDefaultAccountStateInstruction(mint: PublicKey, accountState: AccountState, freezeAuthority: PublicKey, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
//# sourceMappingURL=instructions.d.ts.map

@@ -14,3 +14,5 @@ /// <reference types="node" />

NonTransferable = 9,
InterestBearingMint = 10
InterestBearingConfig = 10,
CpiGuard = 11,
PermanentDelegate = 12
}

@@ -20,2 +22,4 @@ export declare const TYPE_SIZE = 2;

export declare function getTypeLen(e: ExtensionType): number;
export declare function isMintExtension(e: ExtensionType): boolean;
export declare function isAccountExtension(e: ExtensionType): boolean;
export declare function getAccountTypeOfMintType(e: ExtensionType): ExtensionType;

@@ -22,0 +26,0 @@ export declare function getMintLen(extensionTypes: ExtensionType[]): number;

export * from './accountType.js';
export * from './cpiGuard/index.js';
export * from './defaultAccountState/index.js';

@@ -10,2 +11,3 @@ export * from './extensionType.js';

export * from './transferFee/index.js';
export * from './permanentDelegate.js';
//# sourceMappingURL=index.d.ts.map

@@ -43,3 +43,3 @@ import type { PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createUpdateRateInterestBearingMintInstruction(mint: PublicKey, rateAuthority: PublicKey, rate: number, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createUpdateRateInterestBearingMintInstruction(mint: PublicKey, rateAuthority: PublicKey, rate: number, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
//# sourceMappingURL=instructions.d.ts.map

@@ -25,3 +25,3 @@ import type { PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createEnableRequiredMemoTransfersInstruction(account: PublicKey, authority: PublicKey, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createEnableRequiredMemoTransfersInstruction(account: PublicKey, authority: PublicKey, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/**

@@ -37,3 +37,3 @@ * Construct a DisableMemoTransfer instruction

*/
export declare function createDisableRequiredMemoTransfersInstruction(account: PublicKey, authority: PublicKey, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createDisableRequiredMemoTransfersInstruction(account: PublicKey, authority: PublicKey, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
//# sourceMappingURL=instructions.d.ts.map

@@ -7,3 +7,3 @@ import type { Account } from '../../state/account.js';

}
/** Buffer layout for de/serializing a transfer fee config extension */
/** Buffer layout for de/serializing a memo transfer extension */
export declare const MemoTransferLayout: import("@solana/buffer-layout").Structure<MemoTransfer>;

@@ -10,0 +10,0 @@ export declare const MEMO_TRANSFER_SIZE: number;

@@ -108,3 +108,3 @@ import type { AccountMeta, Signer } from '@solana/web3.js';

*/
export declare function createTransferCheckedWithFeeInstruction(source: PublicKey, mint: PublicKey, destination: PublicKey, authority: PublicKey, amount: bigint, decimals: number, fee: bigint, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createTransferCheckedWithFeeInstruction(source: PublicKey, mint: PublicKey, destination: PublicKey, authority: PublicKey, amount: bigint, decimals: number, fee: bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid TransferCheckedWithFee instruction */

@@ -179,3 +179,3 @@ export interface DecodedTransferCheckedWithFeeInstruction {

*/
export declare function createWithdrawWithheldTokensFromMintInstruction(mint: PublicKey, destination: PublicKey, authority: PublicKey, signers?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createWithdrawWithheldTokensFromMintInstruction(mint: PublicKey, destination: PublicKey, authority: PublicKey, signers?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid WithdrawWithheldTokensFromMint instruction */

@@ -244,3 +244,3 @@ export interface DecodedWithdrawWithheldTokensFromMintInstruction {

*/
export declare function createWithdrawWithheldTokensFromAccountsInstruction(mint: PublicKey, destination: PublicKey, authority: PublicKey, signers: Signer[], sources: PublicKey[], programId?: PublicKey): TransactionInstruction;
export declare function createWithdrawWithheldTokensFromAccountsInstruction(mint: PublicKey, destination: PublicKey, authority: PublicKey, signers: (Signer | PublicKey)[], sources: PublicKey[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid WithdrawWithheldTokensFromAccounts instruction */

@@ -247,0 +247,0 @@ export interface DecodedWithdrawWithheldTokensFromAccountsInstruction {

@@ -23,3 +23,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createApproveInstruction(account: PublicKey, delegate: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createApproveInstruction(account: PublicKey, delegate: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid Approve instruction */

@@ -26,0 +26,0 @@ export interface DecodedApproveInstruction {

@@ -26,3 +26,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createApproveCheckedInstruction(account: PublicKey, mint: PublicKey, delegate: PublicKey, owner: PublicKey, amount: number | bigint, decimals: number, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createApproveCheckedInstruction(account: PublicKey, mint: PublicKey, delegate: PublicKey, owner: PublicKey, amount: number | bigint, decimals: number, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid ApproveChecked instruction */

@@ -29,0 +29,0 @@ export interface DecodedApproveCheckedInstruction {

@@ -23,3 +23,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createBurnInstruction(account: PublicKey, mint: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createBurnInstruction(account: PublicKey, mint: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid Burn instruction */

@@ -26,0 +26,0 @@ export interface DecodedBurnInstruction {

@@ -25,3 +25,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createBurnCheckedInstruction(account: PublicKey, mint: PublicKey, owner: PublicKey, amount: number | bigint, decimals: number, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createBurnCheckedInstruction(account: PublicKey, mint: PublicKey, owner: PublicKey, amount: number | bigint, decimals: number, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid BurnChecked instruction */

@@ -28,0 +28,0 @@ export interface DecodedBurnCheckedInstruction {

@@ -21,3 +21,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createCloseAccountInstruction(account: PublicKey, destination: PublicKey, authority: PublicKey, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createCloseAccountInstruction(account: PublicKey, destination: PublicKey, authority: PublicKey, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid CloseAccount instruction */

@@ -24,0 +24,0 @@ export interface DecodedCloseAccountInstruction {

@@ -21,3 +21,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createFreezeAccountInstruction(account: PublicKey, mint: PublicKey, authority: PublicKey, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createFreezeAccountInstruction(account: PublicKey, mint: PublicKey, authority: PublicKey, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid FreezeAccount instruction */

@@ -24,0 +24,0 @@ export interface DecodedFreezeAccountInstruction {

@@ -32,2 +32,3 @@ export * from './associatedTokenAccount.js';

export * from './initializeNonTransferableMint.js';
export * from './initializePermanentDelegate.js';
//# sourceMappingURL=index.d.ts.map

@@ -1,3 +0,3 @@

import type { AccountMeta, PublicKey } from '@solana/web3.js';
import { TransactionInstruction } from '@solana/web3.js';
import type { AccountMeta, Signer } from '@solana/web3.js';
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
import { TokenInstruction } from './types.js';

@@ -21,3 +21,3 @@ /** TODO: docs */

*/
export declare function createInitializeMultisigInstruction(account: PublicKey, signers: PublicKey[], m: number, programId?: PublicKey): TransactionInstruction;
export declare function createInitializeMultisigInstruction(account: PublicKey, signers: (Signer | PublicKey)[], m: number, programId?: PublicKey): TransactionInstruction;
/** A decoded, valid InitializeMultisig instruction */

@@ -24,0 +24,0 @@ export interface DecodedInitializeMultisigInstruction {

@@ -23,3 +23,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createMintToInstruction(mint: PublicKey, destination: PublicKey, authority: PublicKey, amount: number | bigint, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createMintToInstruction(mint: PublicKey, destination: PublicKey, authority: PublicKey, amount: number | bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid MintTo instruction */

@@ -26,0 +26,0 @@ export interface DecodedMintToInstruction {

@@ -25,3 +25,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createMintToCheckedInstruction(mint: PublicKey, destination: PublicKey, authority: PublicKey, amount: number | bigint, decimals: number, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createMintToCheckedInstruction(mint: PublicKey, destination: PublicKey, authority: PublicKey, amount: number | bigint, decimals: number, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid MintToChecked instruction */

@@ -28,0 +28,0 @@ export interface DecodedMintToCheckedInstruction {

@@ -22,3 +22,3 @@ import type { PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createReallocateInstruction(account: PublicKey, payer: PublicKey, extensionTypes: ExtensionType[], owner: PublicKey, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createReallocateInstruction(account: PublicKey, payer: PublicKey, extensionTypes: ExtensionType[], owner: PublicKey, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
//# sourceMappingURL=reallocate.d.ts.map

@@ -20,3 +20,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createRevokeInstruction(account: PublicKey, owner: PublicKey, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createRevokeInstruction(account: PublicKey, owner: PublicKey, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid Revoke instruction */

@@ -23,0 +23,0 @@ export interface DecodedRevokeInstruction {

@@ -32,3 +32,3 @@ import type { AccountMeta, Signer } from '@solana/web3.js';

*/
export declare function createSetAuthorityInstruction(account: PublicKey, currentAuthority: PublicKey, authorityType: AuthorityType, newAuthority: PublicKey | null, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createSetAuthorityInstruction(account: PublicKey, currentAuthority: PublicKey, authorityType: AuthorityType, newAuthority: PublicKey | null, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid SetAuthority instruction */

@@ -35,0 +35,0 @@ export interface DecodedSetAuthorityInstruction {

@@ -21,3 +21,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createThawAccountInstruction(account: PublicKey, mint: PublicKey, authority: PublicKey, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createThawAccountInstruction(account: PublicKey, mint: PublicKey, authority: PublicKey, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid ThawAccount instruction */

@@ -24,0 +24,0 @@ export interface DecodedThawAccountInstruction {

@@ -23,3 +23,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid Transfer instruction */

@@ -26,0 +26,0 @@ export interface DecodedTransferInstruction {

@@ -26,3 +26,3 @@ import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';

*/
export declare function createTransferCheckedInstruction(source: PublicKey, mint: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, decimals: number, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
export declare function createTransferCheckedInstruction(source: PublicKey, mint: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, decimals: number, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
/** A decoded, valid TransferChecked instruction */

@@ -29,0 +29,0 @@ export interface DecodedTransferCheckedInstruction {

@@ -36,4 +36,6 @@ /** Instructions defined by the program */

InitializeNonTransferableMint = 32,
InterestBearingMintExtension = 33
InterestBearingMintExtension = 33,
CpiGuardExtension = 34,
InitializePermanentDelegate = 35
}
//# sourceMappingURL=types.d.ts.map
{
"name": "@solana/spl-token",
"description": "SPL Token Program JS API",
"version": "0.3.6",
"version": "0.3.7",
"author": "Solana Maintainers <maintainers@solana.foundation>",

@@ -65,3 +65,3 @@ "repository": "https://github.com/solana-labs/solana-program-library",

"@types/chai": "^4.3.3",
"@types/mocha": "^9.1.0",
"@types/mocha": "^10.0.0",
"@types/node": "^18.7.9",

@@ -79,3 +79,3 @@ "@types/node-fetch": "^2.6.2",

"gh-pages": "^3.2.3",
"mocha": "^9.1.4",
"mocha": "^10.1.0",
"prettier": "^2.7.1",

@@ -82,0 +82,0 @@ "process": "^0.11.10",

@@ -6,2 +6,3 @@ import { struct, u8 } from '@solana/buffer-layout';

import { TokenUnsupportedInstructionError } from '../../errors.js';
import { addSigners } from '../../instructions/internal.js';
import { TokenInstruction } from '../../instructions/types.js';

@@ -75,3 +76,3 @@ import type { AccountState } from '../../state/account.js';

freezeAuthority: PublicKey,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_2022_PROGRAM_ID

@@ -82,8 +83,4 @@ ): TransactionInstruction {

}
const keys = [{ pubkey: mint, isSigner: false, isWritable: true }];
keys.push({ pubkey: freezeAuthority, isSigner: !multiSigners.length, isWritable: false });
for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = addSigners([{ pubkey: mint, isSigner: false, isWritable: true }], freezeAuthority, multiSigners);
const data = Buffer.alloc(defaultAccountStateInstructionData.span);

@@ -90,0 +87,0 @@ defaultAccountStateInstructionData.encode(

@@ -6,2 +6,3 @@ import { ACCOUNT_SIZE } from '../state/account.js';

import { ACCOUNT_TYPE_SIZE } from './accountType.js';
import { CPI_GUARD_SIZE } from './cpiGuard/index.js';
import { DEFAULT_ACCOUNT_STATE_SIZE } from './defaultAccountState/index.js';

@@ -13,2 +14,3 @@ import { IMMUTABLE_OWNER_SIZE } from './immutableOwner.js';

import { NON_TRANSFERABLE_SIZE } from './nonTransferable.js';
import { PERMANENT_DELEGATE_SIZE } from './permanentDelegate.js';
import { TRANSFER_FEE_AMOUNT_SIZE, TRANSFER_FEE_CONFIG_SIZE } from './transferFee/index.js';

@@ -27,3 +29,5 @@

NonTransferable,
InterestBearingMint,
InterestBearingConfig,
CpiGuard,
PermanentDelegate,
}

@@ -50,2 +54,4 @@

return 286;
case ExtensionType.CpiGuard:
return CPI_GUARD_SIZE;
case ExtensionType.DefaultAccountState:

@@ -59,4 +65,6 @@ return DEFAULT_ACCOUNT_STATE_SIZE;

return NON_TRANSFERABLE_SIZE;
case ExtensionType.InterestBearingMint:
case ExtensionType.InterestBearingConfig:
return INTEREST_BEARING_MINT_CONFIG_STATE_SIZE;
case ExtensionType.PermanentDelegate:
return PERMANENT_DELEGATE_SIZE;
default:

@@ -67,2 +75,46 @@ throw Error(`Unknown extension type: ${e}`);

export function isMintExtension(e: ExtensionType): boolean {
switch (e) {
case ExtensionType.TransferFeeConfig:
case ExtensionType.MintCloseAuthority:
case ExtensionType.ConfidentialTransferMint:
case ExtensionType.DefaultAccountState:
case ExtensionType.NonTransferable:
case ExtensionType.InterestBearingConfig:
case ExtensionType.PermanentDelegate:
return true;
case ExtensionType.Uninitialized:
case ExtensionType.TransferFeeAmount:
case ExtensionType.ConfidentialTransferAccount:
case ExtensionType.ImmutableOwner:
case ExtensionType.MemoTransfer:
case ExtensionType.CpiGuard:
return false;
default:
throw Error(`Unknown extension type: ${e}`);
}
}
export function isAccountExtension(e: ExtensionType): boolean {
switch (e) {
case ExtensionType.TransferFeeAmount:
case ExtensionType.ConfidentialTransferAccount:
case ExtensionType.ImmutableOwner:
case ExtensionType.MemoTransfer:
case ExtensionType.CpiGuard:
return true;
case ExtensionType.Uninitialized:
case ExtensionType.TransferFeeConfig:
case ExtensionType.MintCloseAuthority:
case ExtensionType.ConfidentialTransferMint:
case ExtensionType.DefaultAccountState:
case ExtensionType.NonTransferable:
case ExtensionType.InterestBearingConfig:
case ExtensionType.PermanentDelegate:
return false;
default:
throw Error(`Unknown extension type: ${e}`);
}
}
export function getAccountTypeOfMintType(e: ExtensionType): ExtensionType {

@@ -76,2 +128,3 @@ switch (e) {

case ExtensionType.ConfidentialTransferAccount:
case ExtensionType.CpiGuard:
case ExtensionType.DefaultAccountState:

@@ -83,3 +136,4 @@ case ExtensionType.ImmutableOwner:

case ExtensionType.Uninitialized:
case ExtensionType.InterestBearingMint:
case ExtensionType.InterestBearingConfig:
case ExtensionType.PermanentDelegate:
return ExtensionType.Uninitialized;

@@ -118,3 +172,3 @@ }

let extensionTypeIndex = 0;
while (extensionTypeIndex < tlvData.length) {
while (extensionTypeIndex + TYPE_SIZE + LENGTH_SIZE <= tlvData.length) {
const entryType = tlvData.readUInt16LE(extensionTypeIndex);

@@ -121,0 +175,0 @@ const entryLength = tlvData.readUInt16LE(extensionTypeIndex + TYPE_SIZE);

export * from './accountType.js';
export * from './cpiGuard/index.js';
export * from './defaultAccountState/index.js';

@@ -10,1 +11,2 @@ export * from './extensionType.js';

export * from './transferFee/index.js';
export * from './permanentDelegate.js';

@@ -40,3 +40,3 @@ import type { ConfirmOptions, Connection, PublicKey, Signer } from '@solana/web3.js';

): Promise<PublicKey> {
const mintLen = getMintLen([ExtensionType.InterestBearingMint]);
const mintLen = getMintLen([ExtensionType.InterestBearingConfig]);
const lamports = await connection.getMinimumBalanceForRentExemption(mintLen);

@@ -43,0 +43,0 @@ const transaction = new Transaction().add(

@@ -86,3 +86,3 @@ import { s16, struct, u8 } from '@solana/buffer-layout';

rate: number,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_2022_PROGRAM_ID

@@ -89,0 +89,0 @@ ) {

@@ -26,3 +26,3 @@ import { ns64, s16, struct } from '@solana/buffer-layout';

export function getInterestBearingMintConfigState(mint: Mint): InterestBearingMintConfigState | null {
const extensionData = getExtensionData(ExtensionType.InterestBearingMint, mint.tlvData);
const extensionData = getExtensionData(ExtensionType.InterestBearingConfig, mint.tlvData);
if (extensionData !== null) {

@@ -29,0 +29,0 @@ return InterestBearingMintConfigStateLayout.decode(extensionData);

@@ -6,2 +6,3 @@ import { struct, u8 } from '@solana/buffer-layout';

import { TokenUnsupportedInstructionError } from '../../errors.js';
import { addSigners } from '../../instructions/internal.js';
import { TokenInstruction } from '../../instructions/types.js';

@@ -39,6 +40,6 @@

authority: PublicKey,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_2022_PROGRAM_ID
): TransactionInstruction {
return createMemoTransferInstruction(/* enable */ true, account, authority, multiSigners, programId);
return createMemoTransferInstruction(MemoTransferInstruction.Enable, account, authority, multiSigners, programId);
}

@@ -59,13 +60,13 @@

authority: PublicKey,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_2022_PROGRAM_ID
): TransactionInstruction {
return createMemoTransferInstruction(/* enable */ false, account, authority, multiSigners, programId);
return createMemoTransferInstruction(MemoTransferInstruction.Disable, account, authority, multiSigners, programId);
}
function createMemoTransferInstruction(
enable: boolean,
memoTransferInstruction: MemoTransferInstruction,
account: PublicKey,
authority: PublicKey,
multiSigners: Signer[],
multiSigners: (Signer | PublicKey)[],
programId: PublicKey

@@ -76,8 +77,4 @@ ): TransactionInstruction {

}
const keys = [{ pubkey: account, isSigner: false, isWritable: true }];
keys.push({ pubkey: authority, isSigner: !multiSigners.length, isWritable: false });
for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = addSigners([{ pubkey: account, isSigner: false, isWritable: true }], authority, multiSigners);
const data = Buffer.alloc(memoTransferInstructionData.span);

@@ -87,3 +84,3 @@ memoTransferInstructionData.encode(

instruction: TokenInstruction.MemoTransferExtension,
memoTransferInstruction: enable ? MemoTransferInstruction.Enable : MemoTransferInstruction.Disable,
memoTransferInstruction,
},

@@ -90,0 +87,0 @@ data

@@ -12,3 +12,3 @@ import { struct } from '@solana/buffer-layout';

/** Buffer layout for de/serializing a transfer fee config extension */
/** Buffer layout for de/serializing a memo transfer extension */
export const MemoTransferLayout = struct<MemoTransfer>([bool('requireIncomingTransferMemos')]);

@@ -15,0 +15,0 @@

@@ -13,2 +13,3 @@ import { struct, u16, u8 } from '@solana/buffer-layout';

} from '../../errors.js';
import { addSigners } from '../../instructions/internal.js';
import { TokenInstruction } from '../../instructions/types.js';

@@ -241,3 +242,3 @@

fee: bigint,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_2022_PROGRAM_ID

@@ -259,10 +260,11 @@ ): TransactionInstruction {

);
const keys: AccountMeta[] = [];
keys.push({ pubkey: source, isSigner: false, isWritable: true });
keys.push({ pubkey: mint, isSigner: false, isWritable: false });
keys.push({ pubkey: destination, isSigner: false, isWritable: true });
keys.push({ pubkey: authority, isSigner: !multiSigners.length, isWritable: false });
for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
const keys = addSigners(
[
{ pubkey: source, isSigner: false, isWritable: true },
{ pubkey: mint, isSigner: false, isWritable: false },
{ pubkey: destination, isSigner: false, isWritable: true },
],
authority,
multiSigners
);
return new TransactionInstruction({ keys, programId, data });

@@ -409,3 +411,3 @@ }

authority: PublicKey,
signers: Signer[] = [],
signers: (Signer | PublicKey)[] = [],
programId = TOKEN_2022_PROGRAM_ID

@@ -424,11 +426,10 @@ ): TransactionInstruction {

);
const keys: AccountMeta[] = [];
keys.push(
{ pubkey: mint, isSigner: false, isWritable: true },
{ pubkey: destination, isSigner: false, isWritable: true },
{ pubkey: authority, isSigner: !signers.length, isWritable: false }
const keys = addSigners(
[
{ pubkey: mint, isSigner: false, isWritable: true },
{ pubkey: destination, isSigner: false, isWritable: true },
],
authority,
signers
);
for (const signer of signers) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
return new TransactionInstruction({ keys, programId, data });

@@ -565,3 +566,3 @@ }

authority: PublicKey,
signers: Signer[],
signers: (Signer | PublicKey)[],
sources: PublicKey[],

@@ -582,11 +583,10 @@ programId = TOKEN_2022_PROGRAM_ID

);
const keys: AccountMeta[] = [];
keys.push(
{ pubkey: mint, isSigner: false, isWritable: true },
{ pubkey: destination, isSigner: false, isWritable: true },
{ pubkey: authority, isSigner: !signers.length, isWritable: false }
const keys = addSigners(
[
{ pubkey: mint, isSigner: false, isWritable: true },
{ pubkey: destination, isSigner: false, isWritable: true },
],
authority,
signers
);
for (const signer of signers) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
}
for (const source of sources) {

@@ -593,0 +593,0 @@ keys.push({ pubkey: source, isSigner: false, isWritable: true });

@@ -41,3 +41,3 @@ import { struct, u8 } from '@solana/buffer-layout';

amount: number | bigint,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -44,0 +44,0 @@ ): TransactionInstruction {

@@ -50,3 +50,3 @@ import { struct, u8 } from '@solana/buffer-layout';

decimals: number,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -53,0 +53,0 @@ ): TransactionInstruction {

@@ -41,3 +41,3 @@ import { struct, u8 } from '@solana/buffer-layout';

amount: number | bigint,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -44,0 +44,0 @@ ): TransactionInstruction {

@@ -48,3 +48,3 @@ import { struct, u8 } from '@solana/buffer-layout';

decimals: number,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -51,0 +51,0 @@ ): TransactionInstruction {

@@ -37,3 +37,3 @@ import { struct, u8 } from '@solana/buffer-layout';

authority: PublicKey,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -40,0 +40,0 @@ ): TransactionInstruction {

@@ -37,3 +37,3 @@ import { struct, u8 } from '@solana/buffer-layout';

authority: PublicKey,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -40,0 +40,0 @@ ): TransactionInstruction {

@@ -33,1 +33,2 @@ export * from './associatedTokenAccount.js';

export * from './initializeNonTransferableMint.js'; // 32
export * from './initializePermanentDelegate.js'; // 35
import { struct, u8 } from '@solana/buffer-layout';
import type { AccountMeta, PublicKey } from '@solana/web3.js';
import { SYSVAR_RENT_PUBKEY, TransactionInstruction } from '@solana/web3.js';
import type { AccountMeta, Signer } from '@solana/web3.js';
import { PublicKey, SYSVAR_RENT_PUBKEY, TransactionInstruction } from '@solana/web3.js';
import { TOKEN_PROGRAM_ID } from '../constants.js';

@@ -11,2 +11,3 @@ import {

} from '../errors.js';
import { addSigners } from './internal.js';
import { TokenInstruction } from './types.js';

@@ -38,3 +39,3 @@

account: PublicKey,
signers: PublicKey[],
signers: (Signer | PublicKey)[],
m: number,

@@ -48,3 +49,7 @@ programId = TOKEN_PROGRAM_ID

for (const signer of signers) {
keys.push({ pubkey: signer, isSigner: false, isWritable: false });
keys.push({
pubkey: signer instanceof PublicKey ? signer : signer.publicKey,
isSigner: false,
isWritable: false,
});
}

@@ -51,0 +56,0 @@

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

import type { AccountMeta, PublicKey, Signer } from '@solana/web3.js';
import type { AccountMeta, Signer } from '@solana/web3.js';
import { PublicKey } from '@solana/web3.js';
/** @internal */
export function addSigners(keys: AccountMeta[], ownerOrAuthority: PublicKey, multiSigners: Signer[]): AccountMeta[] {
export function addSigners(
keys: AccountMeta[],
ownerOrAuthority: PublicKey,
multiSigners: (Signer | PublicKey)[]
): AccountMeta[] {
if (multiSigners.length) {
keys.push({ pubkey: ownerOrAuthority, isSigner: false, isWritable: false });
for (const signer of multiSigners) {
keys.push({ pubkey: signer.publicKey, isSigner: true, isWritable: false });
keys.push({
pubkey: signer instanceof PublicKey ? signer : signer.publicKey,
isSigner: true,
isWritable: false,
});
}

@@ -10,0 +19,0 @@ } else {

@@ -41,3 +41,3 @@ import { struct, u8 } from '@solana/buffer-layout';

amount: number | bigint,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -44,0 +44,0 @@ ): TransactionInstruction {

@@ -48,3 +48,3 @@ import { struct, u8 } from '@solana/buffer-layout';

decimals: number,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -51,0 +51,0 @@ ): TransactionInstruction {

@@ -33,3 +33,3 @@ import { seq, struct, u16, u8 } from '@solana/buffer-layout';

owner: PublicKey,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_2022_PROGRAM_ID

@@ -36,0 +36,0 @@ ): TransactionInstruction {

@@ -35,3 +35,3 @@ import { struct, u8 } from '@solana/buffer-layout';

owner: PublicKey,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -38,0 +38,0 @@ ): TransactionInstruction {

@@ -56,3 +56,3 @@ import { struct, u8 } from '@solana/buffer-layout';

newAuthority: PublicKey | null,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -59,0 +59,0 @@ ): TransactionInstruction {

@@ -37,3 +37,3 @@ import { struct, u8 } from '@solana/buffer-layout';

authority: PublicKey,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -40,0 +40,0 @@ ): TransactionInstruction {

@@ -41,3 +41,3 @@ import { struct, u8 } from '@solana/buffer-layout';

amount: number | bigint,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -44,0 +44,0 @@ ): TransactionInstruction {

@@ -50,3 +50,3 @@ import { struct, u8 } from '@solana/buffer-layout';

decimals: number,
multiSigners: Signer[] = [],
multiSigners: (Signer | PublicKey)[] = [],
programId = TOKEN_PROGRAM_ID

@@ -53,0 +53,0 @@ ): TransactionInstruction {

@@ -37,2 +37,4 @@ /** Instructions defined by the program */

InterestBearingMintExtension = 33,
CpiGuardExtension = 34,
InitializePermanentDelegate = 35,
}

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

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