PHP WebShell
Текущая директория: /usr/lib/node_modules/bitgo/node_modules/@solana/spl-token/lib/cjs/extensions/defaultAccountState
Просмотр файла: instructions.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createUpdateDefaultAccountStateInstruction = exports.createInitializeDefaultAccountStateInstruction = exports.defaultAccountStateInstructionData = exports.DefaultAccountStateInstruction = void 0;
const buffer_layout_1 = require("@solana/buffer-layout");
const web3_js_1 = require("@solana/web3.js");
const types_1 = require("../../instructions/types");
const constants_1 = require("../../constants");
const errors_1 = require("../../errors");
var DefaultAccountStateInstruction;
(function (DefaultAccountStateInstruction) {
DefaultAccountStateInstruction[DefaultAccountStateInstruction["Initialize"] = 0] = "Initialize";
DefaultAccountStateInstruction[DefaultAccountStateInstruction["Update"] = 1] = "Update";
})(DefaultAccountStateInstruction = exports.DefaultAccountStateInstruction || (exports.DefaultAccountStateInstruction = {}));
/** TODO: docs */
exports.defaultAccountStateInstructionData = (0, buffer_layout_1.struct)([
(0, buffer_layout_1.u8)('instruction'),
(0, buffer_layout_1.u8)('defaultAccountStateInstruction'),
(0, buffer_layout_1.u8)('accountState'),
]);
/**
* Construct an InitializeDefaultAccountState instruction
*
* @param mint Mint to initialize
* @param accountState Default account state to set on all new accounts
* @param programId SPL Token program account
*
* @return Instruction to add to a transaction
*/
function createInitializeDefaultAccountStateInstruction(mint, accountState, programId = constants_1.TOKEN_2022_PROGRAM_ID) {
if (!(0, constants_1.programSupportsExtensions)(programId)) {
throw new errors_1.TokenUnsupportedInstructionError();
}
const keys = [{ pubkey: mint, isSigner: false, isWritable: true }];
const data = Buffer.alloc(exports.defaultAccountStateInstructionData.span);
exports.defaultAccountStateInstructionData.encode({
instruction: types_1.TokenInstruction.DefaultAccountStateExtension,
defaultAccountStateInstruction: DefaultAccountStateInstruction.Initialize,
accountState,
}, data);
return new web3_js_1.TransactionInstruction({ keys, programId, data });
}
exports.createInitializeDefaultAccountStateInstruction = createInitializeDefaultAccountStateInstruction;
/**
* Construct an UpdateDefaultAccountState instruction
*
* @param mint Mint to update
* @param accountState Default account state to set on all accounts
* @param freezeAuthority The mint's freeze authority
* @param signers The signer account(s) for a multisig
* @param programId SPL Token program account
*
* @return Instruction to add to a transaction
*/
function createUpdateDefaultAccountStateInstruction(mint, accountState, freezeAuthority, multiSigners = [], programId = constants_1.TOKEN_2022_PROGRAM_ID) {
if (!(0, constants_1.programSupportsExtensions)(programId)) {
throw new errors_1.TokenUnsupportedInstructionError();
}
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 data = Buffer.alloc(exports.defaultAccountStateInstructionData.span);
exports.defaultAccountStateInstructionData.encode({
instruction: types_1.TokenInstruction.DefaultAccountStateExtension,
defaultAccountStateInstruction: DefaultAccountStateInstruction.Update,
accountState,
}, data);
return new web3_js_1.TransactionInstruction({ keys, programId, data });
}
exports.createUpdateDefaultAccountStateInstruction = createUpdateDefaultAccountStateInstruction;
//# sourceMappingURL=instructions.js.mapВыполнить команду
Для локальной разработки. Не используйте в интернете!