@solana/spl-token
Advanced tools
Comparing version 0.3.7 to 0.3.8
@@ -32,3 +32,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const associatedToken = yield (0, mint_js_1.getAssociatedTokenAddress)(mint, owner, false, programId, associatedTokenProgramId); | ||
const associatedToken = (0, mint_js_1.getAssociatedTokenAddressSync)(mint, owner, false, programId, associatedTokenProgramId); | ||
const transaction = new web3_js_1.Transaction().add((0, associatedTokenAccount_js_1.createAssociatedTokenAccountInstruction)(payer.publicKey, associatedToken, owner, mint, programId, associatedTokenProgramId)); | ||
@@ -35,0 +35,0 @@ yield (0, web3_js_1.sendAndConfirmTransaction)(connection, transaction, [payer], confirmOptions); |
@@ -33,3 +33,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const associatedToken = yield (0, mint_js_1.getAssociatedTokenAddress)(mint, owner, false, programId, associatedTokenProgramId); | ||
const associatedToken = (0, mint_js_1.getAssociatedTokenAddressSync)(mint, owner, false, programId, associatedTokenProgramId); | ||
const transaction = new web3_js_1.Transaction().add((0, associatedTokenAccount_js_1.createAssociatedTokenAccountIdempotentInstruction)(payer.publicKey, associatedToken, owner, mint, programId, associatedTokenProgramId)); | ||
@@ -36,0 +36,0 @@ yield (0, web3_js_1.sendAndConfirmTransaction)(connection, transaction, [payer], confirmOptions); |
@@ -41,3 +41,3 @@ "use strict"; | ||
if (!keypair) { | ||
const associatedToken = yield (0, mint_js_1.getAssociatedTokenAddress)(nativeMint, owner, false, programId, constants_js_1.ASSOCIATED_TOKEN_PROGRAM_ID); | ||
const associatedToken = (0, mint_js_1.getAssociatedTokenAddressSync)(nativeMint, owner, false, programId, constants_js_1.ASSOCIATED_TOKEN_PROGRAM_ID); | ||
const transaction = new web3_js_1.Transaction().add((0, associatedTokenAccount_js_1.createAssociatedTokenAccountInstruction)(payer.publicKey, associatedToken, owner, nativeMint, programId, constants_js_1.ASSOCIATED_TOKEN_PROGRAM_ID), web3_js_1.SystemProgram.transfer({ | ||
@@ -44,0 +44,0 @@ fromPubkey: payer.publicKey, |
@@ -36,3 +36,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const associatedToken = yield (0, mint_js_1.getAssociatedTokenAddress)(mint, owner, allowOwnerOffCurve, programId, associatedTokenProgramId); | ||
const associatedToken = (0, mint_js_1.getAssociatedTokenAddressSync)(mint, owner, allowOwnerOffCurve, programId, associatedTokenProgramId); | ||
// This is the optimal logic, considering TX fee, client-side computation, RPC roundtrips and guaranteed idempotent. | ||
@@ -39,0 +39,0 @@ // Sadly we can't do this atomically. |
@@ -32,2 +32,3 @@ "use strict"; | ||
ExtensionType[ExtensionType["PermanentDelegate"] = 12] = "PermanentDelegate"; | ||
ExtensionType[ExtensionType["NonTransferableAccount"] = 13] = "NonTransferableAccount"; | ||
})(ExtensionType = exports.ExtensionType || (exports.ExtensionType = {})); | ||
@@ -66,2 +67,4 @@ exports.TYPE_SIZE = 2; | ||
return permanentDelegate_js_1.PERMANENT_DELEGATE_SIZE; | ||
case ExtensionType.NonTransferableAccount: | ||
return nonTransferable_js_1.NON_TRANSFERABLE_ACCOUNT_SIZE; | ||
default: | ||
@@ -88,2 +91,3 @@ throw Error(`Unknown extension type: ${e}`); | ||
case ExtensionType.CpiGuard: | ||
case ExtensionType.NonTransferableAccount: | ||
return false; | ||
@@ -102,2 +106,3 @@ default: | ||
case ExtensionType.CpiGuard: | ||
case ExtensionType.NonTransferableAccount: | ||
return true; | ||
@@ -124,2 +129,4 @@ case ExtensionType.Uninitialized: | ||
return ExtensionType.ConfidentialTransferAccount; | ||
case ExtensionType.NonTransferable: | ||
return ExtensionType.NonTransferableAccount; | ||
case ExtensionType.TransferFeeAmount: | ||
@@ -132,6 +139,6 @@ case ExtensionType.ConfidentialTransferAccount: | ||
case ExtensionType.MintCloseAuthority: | ||
case ExtensionType.NonTransferable: | ||
case ExtensionType.Uninitialized: | ||
case ExtensionType.InterestBearingConfig: | ||
case ExtensionType.PermanentDelegate: | ||
case ExtensionType.NonTransferableAccount: | ||
return ExtensionType.Uninitialized; | ||
@@ -138,0 +145,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getNonTransferable = exports.NON_TRANSFERABLE_SIZE = exports.NonTransferableLayout = void 0; | ||
exports.getNonTransferableAccount = exports.getNonTransferable = exports.NON_TRANSFERABLE_ACCOUNT_SIZE = exports.NON_TRANSFERABLE_SIZE = exports.NonTransferableLayout = void 0; | ||
const buffer_layout_1 = require("@solana/buffer-layout"); | ||
@@ -9,2 +9,3 @@ const extensionType_js_1 = require("./extensionType.js"); | ||
exports.NON_TRANSFERABLE_SIZE = exports.NonTransferableLayout.span; | ||
exports.NON_TRANSFERABLE_ACCOUNT_SIZE = exports.NonTransferableLayout.span; | ||
function getNonTransferable(mint) { | ||
@@ -20,2 +21,12 @@ const extensionData = (0, extensionType_js_1.getExtensionData)(extensionType_js_1.ExtensionType.NonTransferable, mint.tlvData); | ||
exports.getNonTransferable = getNonTransferable; | ||
function getNonTransferableAccount(account) { | ||
const extensionData = (0, extensionType_js_1.getExtensionData)(extensionType_js_1.ExtensionType.NonTransferableAccount, account.tlvData); | ||
if (extensionData !== null) { | ||
return exports.NonTransferableLayout.decode(extensionData); | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
exports.getNonTransferableAccount = getNonTransferableAccount; | ||
//# sourceMappingURL=nonTransferable.js.map |
import { sendAndConfirmTransaction, Transaction } from '@solana/web3.js'; | ||
import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '../constants.js'; | ||
import { createAssociatedTokenAccountInstruction } from '../instructions/associatedTokenAccount.js'; | ||
import { getAssociatedTokenAddress } from '../state/mint.js'; | ||
import { getAssociatedTokenAddressSync } from '../state/mint.js'; | ||
/** | ||
@@ -19,3 +19,3 @@ * Create and initialize a new associated token account | ||
export async function createAssociatedTokenAccount(connection, payer, mint, owner, confirmOptions, programId = TOKEN_PROGRAM_ID, associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID) { | ||
const associatedToken = await getAssociatedTokenAddress(mint, owner, false, programId, associatedTokenProgramId); | ||
const associatedToken = getAssociatedTokenAddressSync(mint, owner, false, programId, associatedTokenProgramId); | ||
const transaction = new Transaction().add(createAssociatedTokenAccountInstruction(payer.publicKey, associatedToken, owner, mint, programId, associatedTokenProgramId)); | ||
@@ -22,0 +22,0 @@ await sendAndConfirmTransaction(connection, transaction, [payer], confirmOptions); |
import { sendAndConfirmTransaction, Transaction } from '@solana/web3.js'; | ||
import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '../constants.js'; | ||
import { createAssociatedTokenAccountIdempotentInstruction } from '../instructions/associatedTokenAccount.js'; | ||
import { getAssociatedTokenAddress } from '../state/mint.js'; | ||
import { getAssociatedTokenAddressSync } from '../state/mint.js'; | ||
/** | ||
@@ -20,3 +20,3 @@ * Create and initialize a new associated token account | ||
export async function createAssociatedTokenAccountIdempotent(connection, payer, mint, owner, confirmOptions, programId = TOKEN_PROGRAM_ID, associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID) { | ||
const associatedToken = await getAssociatedTokenAddress(mint, owner, false, programId, associatedTokenProgramId); | ||
const associatedToken = getAssociatedTokenAddressSync(mint, owner, false, programId, associatedTokenProgramId); | ||
const transaction = new Transaction().add(createAssociatedTokenAccountIdempotentInstruction(payer.publicKey, associatedToken, owner, mint, programId, associatedTokenProgramId)); | ||
@@ -23,0 +23,0 @@ await sendAndConfirmTransaction(connection, transaction, [payer], confirmOptions); |
@@ -7,3 +7,3 @@ import { sendAndConfirmTransaction, SystemProgram, Transaction } from '@solana/web3.js'; | ||
import { ACCOUNT_SIZE, getMinimumBalanceForRentExemptAccount } from '../state/account.js'; | ||
import { getAssociatedTokenAddress } from '../state/mint.js'; | ||
import { getAssociatedTokenAddressSync } from '../state/mint.js'; | ||
import { createAccount } from './createAccount.js'; | ||
@@ -29,3 +29,3 @@ /** | ||
if (!keypair) { | ||
const associatedToken = await getAssociatedTokenAddress(nativeMint, owner, false, programId, ASSOCIATED_TOKEN_PROGRAM_ID); | ||
const associatedToken = getAssociatedTokenAddressSync(nativeMint, owner, false, programId, ASSOCIATED_TOKEN_PROGRAM_ID); | ||
const transaction = new Transaction().add(createAssociatedTokenAccountInstruction(payer.publicKey, associatedToken, owner, nativeMint, programId, ASSOCIATED_TOKEN_PROGRAM_ID), SystemProgram.transfer({ | ||
@@ -32,0 +32,0 @@ fromPubkey: payer.publicKey, |
@@ -6,3 +6,3 @@ import { sendAndConfirmTransaction, Transaction } from '@solana/web3.js'; | ||
import { getAccount } from '../state/account.js'; | ||
import { getAssociatedTokenAddress } from '../state/mint.js'; | ||
import { getAssociatedTokenAddressSync } from '../state/mint.js'; | ||
/** | ||
@@ -24,3 +24,3 @@ * Retrieve the associated token account, or create it if it doesn't exist | ||
export async function getOrCreateAssociatedTokenAccount(connection, payer, mint, owner, allowOwnerOffCurve = false, commitment, confirmOptions, programId = TOKEN_PROGRAM_ID, associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID) { | ||
const associatedToken = await getAssociatedTokenAddress(mint, owner, allowOwnerOffCurve, programId, associatedTokenProgramId); | ||
const associatedToken = getAssociatedTokenAddressSync(mint, owner, allowOwnerOffCurve, programId, associatedTokenProgramId); | ||
// This is the optimal logic, considering TX fee, client-side computation, RPC roundtrips and guaranteed idempotent. | ||
@@ -27,0 +27,0 @@ // Sadly we can't do this atomically. |
@@ -11,3 +11,3 @@ import { ACCOUNT_SIZE } from '../state/account.js'; | ||
import { MINT_CLOSE_AUTHORITY_SIZE } from './mintCloseAuthority.js'; | ||
import { NON_TRANSFERABLE_SIZE } from './nonTransferable.js'; | ||
import { NON_TRANSFERABLE_SIZE, NON_TRANSFERABLE_ACCOUNT_SIZE } from './nonTransferable.js'; | ||
import { PERMANENT_DELEGATE_SIZE } from './permanentDelegate.js'; | ||
@@ -30,2 +30,3 @@ import { TRANSFER_FEE_AMOUNT_SIZE, TRANSFER_FEE_CONFIG_SIZE } from './transferFee/index.js'; | ||
ExtensionType[ExtensionType["PermanentDelegate"] = 12] = "PermanentDelegate"; | ||
ExtensionType[ExtensionType["NonTransferableAccount"] = 13] = "NonTransferableAccount"; | ||
})(ExtensionType || (ExtensionType = {})); | ||
@@ -64,2 +65,4 @@ export const TYPE_SIZE = 2; | ||
return PERMANENT_DELEGATE_SIZE; | ||
case ExtensionType.NonTransferableAccount: | ||
return NON_TRANSFERABLE_ACCOUNT_SIZE; | ||
default: | ||
@@ -85,2 +88,3 @@ throw Error(`Unknown extension type: ${e}`); | ||
case ExtensionType.CpiGuard: | ||
case ExtensionType.NonTransferableAccount: | ||
return false; | ||
@@ -98,2 +102,3 @@ default: | ||
case ExtensionType.CpiGuard: | ||
case ExtensionType.NonTransferableAccount: | ||
return true; | ||
@@ -119,2 +124,4 @@ case ExtensionType.Uninitialized: | ||
return ExtensionType.ConfidentialTransferAccount; | ||
case ExtensionType.NonTransferable: | ||
return ExtensionType.NonTransferableAccount; | ||
case ExtensionType.TransferFeeAmount: | ||
@@ -127,6 +134,6 @@ case ExtensionType.ConfidentialTransferAccount: | ||
case ExtensionType.MintCloseAuthority: | ||
case ExtensionType.NonTransferable: | ||
case ExtensionType.Uninitialized: | ||
case ExtensionType.InterestBearingConfig: | ||
case ExtensionType.PermanentDelegate: | ||
case ExtensionType.NonTransferableAccount: | ||
return ExtensionType.Uninitialized; | ||
@@ -133,0 +140,0 @@ } |
@@ -6,2 +6,3 @@ import { struct } from '@solana/buffer-layout'; | ||
export const NON_TRANSFERABLE_SIZE = NonTransferableLayout.span; | ||
export const NON_TRANSFERABLE_ACCOUNT_SIZE = NonTransferableLayout.span; | ||
export function getNonTransferable(mint) { | ||
@@ -16,2 +17,11 @@ const extensionData = getExtensionData(ExtensionType.NonTransferable, mint.tlvData); | ||
} | ||
export function getNonTransferableAccount(account) { | ||
const extensionData = getExtensionData(ExtensionType.NonTransferableAccount, account.tlvData); | ||
if (extensionData !== null) { | ||
return NonTransferableLayout.decode(extensionData); | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
//# sourceMappingURL=nonTransferable.js.map |
@@ -16,3 +16,4 @@ /// <reference types="node" /> | ||
CpiGuard = 11, | ||
PermanentDelegate = 12 | ||
PermanentDelegate = 12, | ||
NonTransferableAccount = 13 | ||
} | ||
@@ -19,0 +20,0 @@ export declare const TYPE_SIZE = 2; |
@@ -0,9 +1,15 @@ | ||
import type { Account } from '../state/account.js'; | ||
import type { Mint } from '../state/mint.js'; | ||
/** Non-transferable state as stored by the program */ | ||
/** Non-transferable mint state as stored by the program */ | ||
export interface NonTransferable { | ||
} | ||
/** Non-transferable token account state as stored by the program */ | ||
export interface NonTransferableAccount { | ||
} | ||
/** Buffer layout for de/serializing an account */ | ||
export declare const NonTransferableLayout: import("@solana/buffer-layout").Structure<NonTransferable>; | ||
export declare const NON_TRANSFERABLE_SIZE: number; | ||
export declare const NON_TRANSFERABLE_ACCOUNT_SIZE: number; | ||
export declare function getNonTransferable(mint: Mint): NonTransferable | null; | ||
export declare function getNonTransferableAccount(account: Account): NonTransferableAccount | null; | ||
//# sourceMappingURL=nonTransferable.d.ts.map |
@@ -25,3 +25,3 @@ import type { TransactionInstruction } from '@solana/web3.js'; | ||
/** TODO: docs */ | ||
export declare type DecodedInstruction = DecodedInitializeMintInstruction | DecodedInitializeAccountInstruction | DecodedInitializeMultisigInstruction | DecodedTransferInstruction | DecodedApproveInstruction | DecodedRevokeInstruction | DecodedSetAuthorityInstruction | DecodedMintToInstruction | DecodedBurnInstruction | DecodedCloseAccountInstruction | DecodedFreezeAccountInstruction | DecodedThawAccountInstruction | DecodedTransferCheckedInstruction | DecodedApproveCheckedInstruction | DecodedMintToCheckedInstruction | DecodedBurnCheckedInstruction | DecodedInitializeAccount2Instruction | DecodedSyncNativeInstruction | DecodedInitializeAccount3Instruction | DecodedInitializeMint2Instruction | DecodedAmountToUiAmountInstruction | DecodedUiAmountToAmountInstruction | never; | ||
export type DecodedInstruction = DecodedInitializeMintInstruction | DecodedInitializeAccountInstruction | DecodedInitializeMultisigInstruction | DecodedTransferInstruction | DecodedApproveInstruction | DecodedRevokeInstruction | DecodedSetAuthorityInstruction | DecodedMintToInstruction | DecodedBurnInstruction | DecodedCloseAccountInstruction | DecodedFreezeAccountInstruction | DecodedThawAccountInstruction | DecodedTransferCheckedInstruction | DecodedApproveCheckedInstruction | DecodedMintToCheckedInstruction | DecodedBurnCheckedInstruction | DecodedInitializeAccount2Instruction | DecodedSyncNativeInstruction | DecodedInitializeAccount3Instruction | DecodedInitializeMint2Instruction | DecodedAmountToUiAmountInstruction | DecodedUiAmountToAmountInstruction | never; | ||
/** TODO: docs */ | ||
@@ -28,0 +28,0 @@ export declare function decodeInstruction(instruction: TransactionInstruction, programId?: import("@solana/web3.js").PublicKey): DecodedInstruction; |
@@ -27,3 +27,3 @@ /// <reference types="node" /> | ||
/** Multisig as stored by the program */ | ||
export declare type RawMultisig = Omit<Multisig, 'address'>; | ||
export type RawMultisig = Omit<Multisig, 'address'>; | ||
/** Buffer layout for de/serializing a multisig */ | ||
@@ -30,0 +30,0 @@ export declare const MultisigLayout: import("@solana/buffer-layout").Structure<RawMultisig>; |
{ | ||
"name": "@solana/spl-token", | ||
"description": "SPL Token Program JS API", | ||
"version": "0.3.7", | ||
"author": "Solana Maintainers <maintainers@solana.foundation>", | ||
"version": "0.3.8", | ||
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>", | ||
"repository": "https://github.com/solana-labs/solana-program-library", | ||
@@ -26,5 +26,5 @@ "license": "Apache-2.0", | ||
"exports": { | ||
"types": "./lib/types/index.d.ts", | ||
"require": "./lib/cjs/index.js", | ||
"import": "./lib/esm/index.js", | ||
"types": "./lib/types/index.d.ts" | ||
"import": "./lib/esm/index.js" | ||
}, | ||
@@ -67,3 +67,3 @@ "scripts": { | ||
"@types/mocha": "^10.0.0", | ||
"@types/node": "^18.7.9", | ||
"@types/node": "^20.1.1", | ||
"@types/node-fetch": "^2.6.2", | ||
@@ -79,3 +79,3 @@ "@types/prettier": "^2.7.0", | ||
"eslint-plugin-require-extensions": "^0.1.1", | ||
"gh-pages": "^3.2.3", | ||
"gh-pages": "^5.0.0", | ||
"mocha": "^10.1.0", | ||
@@ -85,8 +85,8 @@ "prettier": "^2.7.1", | ||
"shx": "^0.3.4", | ||
"start-server-and-test": "^1.14.0", | ||
"start-server-and-test": "^2.0.0", | ||
"tslib": "^2.3.1", | ||
"ts-node": "^10.9.1", | ||
"typedoc": "^0.23.10", | ||
"typescript": "^4.7.4" | ||
"typedoc": "^0.24.7", | ||
"typescript": "^5.0.4" | ||
} | ||
} |
@@ -23,3 +23,3 @@ # `@solana/spl-token` | ||
Please see [upgrading from 0.1.x](#upgrading-from-0.1.x). | ||
Please see [upgrading from 0.1.x](#upgrading-from-01x). | ||
@@ -26,0 +26,0 @@ ## Install |
@@ -5,3 +5,3 @@ import type { ConfirmOptions, Connection, PublicKey, Signer } from '@solana/web3.js'; | ||
import { createAssociatedTokenAccountInstruction } from '../instructions/associatedTokenAccount.js'; | ||
import { getAssociatedTokenAddress } from '../state/mint.js'; | ||
import { getAssociatedTokenAddressSync } from '../state/mint.js'; | ||
@@ -30,3 +30,3 @@ /** | ||
): Promise<PublicKey> { | ||
const associatedToken = await getAssociatedTokenAddress(mint, owner, false, programId, associatedTokenProgramId); | ||
const associatedToken = getAssociatedTokenAddressSync(mint, owner, false, programId, associatedTokenProgramId); | ||
@@ -33,0 +33,0 @@ const transaction = new Transaction().add( |
@@ -5,3 +5,3 @@ import type { ConfirmOptions, Connection, PublicKey, Signer } from '@solana/web3.js'; | ||
import { createAssociatedTokenAccountIdempotentInstruction } from '../instructions/associatedTokenAccount.js'; | ||
import { getAssociatedTokenAddress } from '../state/mint.js'; | ||
import { getAssociatedTokenAddressSync } from '../state/mint.js'; | ||
@@ -31,3 +31,3 @@ /** | ||
): Promise<PublicKey> { | ||
const associatedToken = await getAssociatedTokenAddress(mint, owner, false, programId, associatedTokenProgramId); | ||
const associatedToken = getAssociatedTokenAddressSync(mint, owner, false, programId, associatedTokenProgramId); | ||
@@ -34,0 +34,0 @@ const transaction = new Transaction().add( |
@@ -8,3 +8,3 @@ import type { ConfirmOptions, Connection, Keypair, PublicKey, Signer } from '@solana/web3.js'; | ||
import { ACCOUNT_SIZE, getMinimumBalanceForRentExemptAccount } from '../state/account.js'; | ||
import { getAssociatedTokenAddress } from '../state/mint.js'; | ||
import { getAssociatedTokenAddressSync } from '../state/mint.js'; | ||
import { createAccount } from './createAccount.js'; | ||
@@ -40,3 +40,3 @@ | ||
if (!keypair) { | ||
const associatedToken = await getAssociatedTokenAddress( | ||
const associatedToken = getAssociatedTokenAddressSync( | ||
nativeMint, | ||
@@ -43,0 +43,0 @@ owner, |
@@ -13,3 +13,3 @@ import type { Commitment, ConfirmOptions, Connection, PublicKey, Signer } from '@solana/web3.js'; | ||
import { getAccount } from '../state/account.js'; | ||
import { getAssociatedTokenAddress } from '../state/mint.js'; | ||
import { getAssociatedTokenAddressSync } from '../state/mint.js'; | ||
@@ -42,3 +42,3 @@ /** | ||
): Promise<Account> { | ||
const associatedToken = await getAssociatedTokenAddress( | ||
const associatedToken = getAssociatedTokenAddressSync( | ||
mint, | ||
@@ -45,0 +45,0 @@ owner, |
@@ -12,3 +12,3 @@ import { ACCOUNT_SIZE } from '../state/account.js'; | ||
import { MINT_CLOSE_AUTHORITY_SIZE } from './mintCloseAuthority.js'; | ||
import { NON_TRANSFERABLE_SIZE } from './nonTransferable.js'; | ||
import { NON_TRANSFERABLE_SIZE, NON_TRANSFERABLE_ACCOUNT_SIZE } from './nonTransferable.js'; | ||
import { PERMANENT_DELEGATE_SIZE } from './permanentDelegate.js'; | ||
@@ -31,2 +31,3 @@ import { TRANSFER_FEE_AMOUNT_SIZE, TRANSFER_FEE_CONFIG_SIZE } from './transferFee/index.js'; | ||
PermanentDelegate, | ||
NonTransferableAccount, | ||
} | ||
@@ -67,2 +68,4 @@ | ||
return PERMANENT_DELEGATE_SIZE; | ||
case ExtensionType.NonTransferableAccount: | ||
return NON_TRANSFERABLE_ACCOUNT_SIZE; | ||
default: | ||
@@ -89,2 +92,3 @@ throw Error(`Unknown extension type: ${e}`); | ||
case ExtensionType.CpiGuard: | ||
case ExtensionType.NonTransferableAccount: | ||
return false; | ||
@@ -103,2 +107,3 @@ default: | ||
case ExtensionType.CpiGuard: | ||
case ExtensionType.NonTransferableAccount: | ||
return true; | ||
@@ -125,2 +130,4 @@ case ExtensionType.Uninitialized: | ||
return ExtensionType.ConfidentialTransferAccount; | ||
case ExtensionType.NonTransferable: | ||
return ExtensionType.NonTransferableAccount; | ||
case ExtensionType.TransferFeeAmount: | ||
@@ -133,6 +140,6 @@ case ExtensionType.ConfidentialTransferAccount: | ||
case ExtensionType.MintCloseAuthority: | ||
case ExtensionType.NonTransferable: | ||
case ExtensionType.Uninitialized: | ||
case ExtensionType.InterestBearingConfig: | ||
case ExtensionType.PermanentDelegate: | ||
case ExtensionType.NonTransferableAccount: | ||
return ExtensionType.Uninitialized; | ||
@@ -139,0 +146,0 @@ } |
import { struct } from '@solana/buffer-layout'; | ||
import type { Account } from '../state/account.js'; | ||
import type { Mint } from '../state/mint.js'; | ||
import { ExtensionType, getExtensionData } from './extensionType.js'; | ||
/** Non-transferable state as stored by the program */ | ||
/** Non-transferable mint state as stored by the program */ | ||
export interface NonTransferable {} // eslint-disable-line | ||
/** Non-transferable token account state as stored by the program */ | ||
export interface NonTransferableAccount {} // eslint-disable-line | ||
/** Buffer layout for de/serializing an account */ | ||
@@ -12,2 +16,3 @@ export const NonTransferableLayout = struct<NonTransferable>([]); | ||
export const NON_TRANSFERABLE_SIZE = NonTransferableLayout.span; | ||
export const NON_TRANSFERABLE_ACCOUNT_SIZE = NonTransferableLayout.span; | ||
@@ -22,1 +27,10 @@ export function getNonTransferable(mint: Mint): NonTransferable | null { | ||
} | ||
export function getNonTransferableAccount(account: Account): NonTransferableAccount | null { | ||
const extensionData = getExtensionData(ExtensionType.NonTransferableAccount, account.tlvData); | ||
if (extensionData !== null) { | ||
return NonTransferableLayout.decode(extensionData); | ||
} else { | ||
return null; | ||
} | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1320632
21745