UNPKG

@metaplex-foundation/mpl-candy-guard

Version:

MPL Candy Guard JavaScript API. This MPL package is for the current generation of the Candy Guard

121 lines 5.11 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.freezeEscrowBeet = exports.FreezeEscrow = exports.freezeEscrowDiscriminator = void 0; const web3 = __importStar(require("@solana/web3.js")); const beet = __importStar(require("@metaplex-foundation/beet")); const beetSolana = __importStar(require("@metaplex-foundation/beet-solana")); exports.freezeEscrowDiscriminator = [227, 186, 40, 152, 7, 174, 131, 184]; class FreezeEscrow { constructor(candyGuard, candyMachine, frozenCount, firstMintTime, freezePeriod, destination, authority) { this.candyGuard = candyGuard; this.candyMachine = candyMachine; this.frozenCount = frozenCount; this.firstMintTime = firstMintTime; this.freezePeriod = freezePeriod; this.destination = destination; this.authority = authority; } static fromArgs(args) { return new FreezeEscrow(args.candyGuard, args.candyMachine, args.frozenCount, args.firstMintTime, args.freezePeriod, args.destination, args.authority); } static fromAccountInfo(accountInfo, offset = 0) { return FreezeEscrow.deserialize(accountInfo.data, offset); } static async fromAccountAddress(connection, address, commitmentOrConfig) { const accountInfo = await connection.getAccountInfo(address, commitmentOrConfig); if (accountInfo == null) { throw new Error(`Unable to find FreezeEscrow account at ${address}`); } return FreezeEscrow.fromAccountInfo(accountInfo, 0)[0]; } static gpaBuilder(programId = new web3.PublicKey('Guard1JwRhJkVH6XZhzoYxeBVQe872VH6QggF4BWmS9g')) { return beetSolana.GpaBuilder.fromStruct(programId, exports.freezeEscrowBeet); } static deserialize(buf, offset = 0) { return exports.freezeEscrowBeet.deserialize(buf, offset); } serialize() { return exports.freezeEscrowBeet.serialize({ accountDiscriminator: exports.freezeEscrowDiscriminator, ...this, }); } static byteSize(args) { const instance = FreezeEscrow.fromArgs(args); return exports.freezeEscrowBeet.toFixedFromValue({ accountDiscriminator: exports.freezeEscrowDiscriminator, ...instance, }).byteSize; } static async getMinimumBalanceForRentExemption(args, connection, commitment) { return connection.getMinimumBalanceForRentExemption(FreezeEscrow.byteSize(args), commitment); } pretty() { return { candyGuard: this.candyGuard.toBase58(), candyMachine: this.candyMachine.toBase58(), frozenCount: (() => { const x = this.frozenCount; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), firstMintTime: this.firstMintTime, freezePeriod: (() => { const x = this.freezePeriod; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), destination: this.destination.toBase58(), authority: this.authority.toBase58(), }; } } exports.FreezeEscrow = FreezeEscrow; exports.freezeEscrowBeet = new beet.FixableBeetStruct([ ['accountDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], ['candyGuard', beetSolana.publicKey], ['candyMachine', beetSolana.publicKey], ['frozenCount', beet.u64], ['firstMintTime', beet.coption(beet.i64)], ['freezePeriod', beet.i64], ['destination', beetSolana.publicKey], ['authority', beetSolana.publicKey], ], FreezeEscrow.fromArgs, 'FreezeEscrow'); //# sourceMappingURL=FreezeEscrow.js.map