UNPKG

frakt-client

Version:

Client library for interacting with FRAKT solana program

1,013 lines (1,012 loc) 34.8 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getEditionMarkPda = exports.deprecatedGetReservationList = exports.getMetadata = exports.getEdition = exports.convertMasterEditionV1ToV2 = exports.deprecatedMintPrintingTokens = exports.signMetadata = exports.deprecatedCreateReservationList = exports.updatePrimarySaleHappenedViaToken = exports.mintNewEditionFromMasterEditionViaToken = exports.deprecatedMintNewEditionFromMasterEditionViaPrintingToken = exports.createMasterEdition = exports.createMetadata = exports.updateMetadata = exports.decodeMasterEdition = exports.decodeEdition = exports.decodeEditionMarker = exports.decodeMetadata = exports.processMetaData = exports.METADATA_SCHEMA = exports.Metadata = exports.Data = exports.Creator = exports.Edition = exports.EditionMarker = exports.MasterEditionV2 = exports.MasterEditionV1 = exports.MetadataCategory = exports.MetadataKey = exports.findProgramAddress = exports.EDITION_MARKER_BIT_SIZE = exports.MAX_EDITION_LEN = exports.MAX_METADATA_LEN = exports.MAX_CREATOR_LEN = exports.MAX_CREATOR_LIMIT = exports.MAX_URI_LENGTH = exports.MAX_SYMBOL_LENGTH = exports.MAX_NAME_LENGTH = exports.extendBorsh = exports.RESERVATION = exports.EDITION = exports.METADATA_PREFIX = void 0; const web3_js_1 = require("@solana/web3.js"); const ids_1 = require("./utils/ids"); const borsh_1 = require("borsh"); exports.METADATA_PREFIX = 'metadata'; exports.EDITION = 'edition'; exports.RESERVATION = 'reservation'; exports.extendBorsh = () => { borsh_1.BinaryReader.prototype.readPubkey = function () { const reader = this; const array = reader.readFixedArray(32); return new web3_js_1.PublicKey(array); }; borsh_1.BinaryWriter.prototype.writePubkey = function (value) { const writer = this; writer.writeFixedArray(value.toBuffer()); }; }; exports.extendBorsh(); exports.MAX_NAME_LENGTH = 32; exports.MAX_SYMBOL_LENGTH = 10; exports.MAX_URI_LENGTH = 200; exports.MAX_CREATOR_LIMIT = 5; exports.MAX_CREATOR_LEN = 32 + 1 + 1; exports.MAX_METADATA_LEN = 1 + 32 + 32 + exports.MAX_NAME_LENGTH + exports.MAX_SYMBOL_LENGTH + exports.MAX_URI_LENGTH + exports.MAX_CREATOR_LIMIT * exports.MAX_CREATOR_LEN + 2 + 1 + 1 + 198; exports.MAX_EDITION_LEN = 1 + 32 + 8 + 200; exports.EDITION_MARKER_BIT_SIZE = 248; exports.findProgramAddress = (seeds, programId) => __awaiter(void 0, void 0, void 0, function* () { const key = 'pda-' + seeds.reduce((agg, item) => agg + item.toString('hex'), '') + programId.toString(); // let cached = localStorage.getItem(key); // if (cached) { // const value = JSON.parse(cached); // return [new PublicKey(value.key), parseInt(value.nonce)] as [ // PublicKey, // number, // ]; // } const result = yield web3_js_1.PublicKey.findProgramAddress(seeds, programId); // localStorage.setItem( // key, // JSON.stringify({ // key: result[0].toBase58(), // nonce: result[1], // }), // ); return result; }); var MetadataKey; (function (MetadataKey) { MetadataKey[MetadataKey["Uninitialized"] = 0] = "Uninitialized"; MetadataKey[MetadataKey["MetadataV1"] = 4] = "MetadataV1"; MetadataKey[MetadataKey["EditionV1"] = 1] = "EditionV1"; MetadataKey[MetadataKey["MasterEditionV1"] = 2] = "MasterEditionV1"; MetadataKey[MetadataKey["MasterEditionV2"] = 6] = "MasterEditionV2"; MetadataKey[MetadataKey["EditionMarker"] = 7] = "EditionMarker"; })(MetadataKey = exports.MetadataKey || (exports.MetadataKey = {})); var MetadataCategory; (function (MetadataCategory) { MetadataCategory["Audio"] = "audio"; MetadataCategory["Video"] = "video"; MetadataCategory["Image"] = "image"; MetadataCategory["VR"] = "vr"; })(MetadataCategory = exports.MetadataCategory || (exports.MetadataCategory = {})); class MasterEditionV1 { constructor(args) { this.key = MetadataKey.MasterEditionV1; this.supply = args.supply; this.maxSupply = args.maxSupply; this.printingMint = args.printingMint; this.oneTimePrintingAuthorizationMint = args.oneTimePrintingAuthorizationMint; } } exports.MasterEditionV1 = MasterEditionV1; class MasterEditionV2 { constructor(args) { this.key = MetadataKey.MasterEditionV2; this.supply = args.supply; this.maxSupply = args.maxSupply; } } exports.MasterEditionV2 = MasterEditionV2; class EditionMarker { constructor(args) { this.key = MetadataKey.EditionMarker; this.ledger = args.ledger; } editionTaken(edition) { const editionOffset = edition % exports.EDITION_MARKER_BIT_SIZE; const indexOffset = Math.floor(editionOffset / 8); if (indexOffset > 30) { throw Error('bad index for edition'); } const positionInBitsetFromRight = 7 - (editionOffset % 8); const mask = Math.pow(2, positionInBitsetFromRight); const appliedMask = this.ledger[indexOffset] & mask; return appliedMask != 0; } } exports.EditionMarker = EditionMarker; class Edition { constructor(args) { this.key = MetadataKey.EditionV1; this.parent = args.parent; this.edition = args.edition; } } exports.Edition = Edition; class Creator { constructor(args) { this.address = args.address; this.verified = args.verified; this.share = args.share; } } exports.Creator = Creator; class Data { constructor(args) { this.name = args.name; this.symbol = args.symbol; this.uri = args.uri; this.sellerFeeBasisPoints = args.sellerFeeBasisPoints; this.creators = args.creators; } } exports.Data = Data; class Metadata { constructor(args) { this.key = MetadataKey.MetadataV1; this.updateAuthority = args.updateAuthority; this.mint = args.mint; this.data = args.data; this.primarySaleHappened = args.primarySaleHappened; this.isMutable = args.isMutable; } init() { return __awaiter(this, void 0, void 0, function* () { const edition = yield getEdition(this.mint); this.edition = edition; this.masterEdition = edition; }); } } exports.Metadata = Metadata; class CreateMetadataArgs { constructor(args) { this.instruction = 0; this.data = args.data; this.isMutable = args.isMutable; } } class UpdateMetadataArgs { constructor(args) { this.instruction = 1; this.data = args.data ? args.data : null; this.updateAuthority = args.updateAuthority ? new web3_js_1.PublicKey(args.updateAuthority) : null; this.primarySaleHappened = args.primarySaleHappened; } } class CreateMasterEditionArgs { constructor(args) { this.instruction = 10; this.maxSupply = args.maxSupply; } } class MintPrintingTokensArgs { constructor(args) { this.instruction = 9; this.supply = args.supply; } } exports.METADATA_SCHEMA = new Map([ [ CreateMetadataArgs, { kind: 'struct', fields: [ ['instruction', 'u8'], ['data', Data], ['isMutable', 'u8'], ], }, ], [ UpdateMetadataArgs, { kind: 'struct', fields: [ ['instruction', 'u8'], ['data', { kind: 'option', type: Data }], ['updateAuthority', { kind: 'option', type: 'pubkey' }], ['primarySaleHappened', { kind: 'option', type: 'u8' }], ], }, ], [ CreateMasterEditionArgs, { kind: 'struct', fields: [ ['instruction', 'u8'], ['maxSupply', { kind: 'option', type: 'u64' }], ], }, ], [ MintPrintingTokensArgs, { kind: 'struct', fields: [ ['instruction', 'u8'], ['supply', 'u64'], ], }, ], [ MasterEditionV1, { kind: 'struct', fields: [ ['key', 'u8'], ['supply', 'u64'], ['maxSupply', { kind: 'option', type: 'u64' }], ['printingMint', 'pubkey'], ['oneTimePrintingAuthorizationMint', 'pubkey'], ], }, ], [ MasterEditionV2, { kind: 'struct', fields: [ ['key', 'u8'], ['supply', 'u64'], ['maxSupply', { kind: 'option', type: 'u64' }], ], }, ], [ Edition, { kind: 'struct', fields: [ ['key', 'u8'], ['parent', 'pubkey'], ['edition', 'u64'], ], }, ], [ Data, { kind: 'struct', fields: [ ['name', 'string'], ['symbol', 'string'], ['uri', 'string'], ['sellerFeeBasisPoints', 'u16'], ['creators', { kind: 'option', type: [Creator] }], ], }, ], [ Creator, { kind: 'struct', fields: [ ['address', 'pubkey'], ['verified', 'u8'], ['share', 'u8'], ], }, ], [ Metadata, { kind: 'struct', fields: [ ['key', 'u8'], ['updateAuthority', 'pubkey'], ['mint', 'pubkey'], ['data', Data], ['primarySaleHappened', 'u8'], ['isMutable', 'u8'], ], }, ], [ EditionMarker, { kind: 'struct', fields: [ ['key', 'u8'], ['ledger', [31]], ], }, ], ]); function isValidHttpUrl(text) { let url; try { url = new URL(text); } catch (_) { return false; } return url.protocol === 'http:' || url.protocol === 'https:'; } exports.processMetaData = (meta, metaStorage) => { if (meta.account.owner.toBase58() !== ids_1.programIds().metadata.toBase58()) return; try { if (meta.account.data[0] === MetadataKey.MetadataV1) { const metadata = exports.decodeMetadata(meta.account.data); if (isValidHttpUrl(metadata.data.uri) && metadata.data.uri.indexOf('arweave') >= 0) { const account = { pubkey: meta.pubkey, account: meta.account, info: metadata, }; // setter('metadataByMint', metadata.mint.toBase58(), account); metaStorage['metadataByMint'].push({ mintAddress: metadata.mint.toBase58(), account }); return account; } } else if (meta.account.data[0] === MetadataKey.EditionV1) { const edition = exports.decodeEdition(meta.account.data); const account = { pubkey: meta.pubkey, account: meta.account, info: edition, }; // setter('editions', meta.pubkey.toBase58(), account); metaStorage['editions'].push({ mintAddress: meta.pubkey.toBase58(), account }); } else if (meta.account.data[0] === MetadataKey.MasterEditionV1 || meta.account.data[0] === MetadataKey.MasterEditionV2) { const masterEdition = exports.decodeMasterEdition(meta.account.data); if (masterEdition.key == MetadataKey.MasterEditionV1) { const account = { pubkey: meta.pubkey, account: meta.account, info: masterEdition, }; metaStorage['masterEditions'].push({ mintAddress: meta.pubkey.toBase58(), account }); metaStorage['masterEditionsByPrintingMint'].push({ mintAddress: masterEdition.printingMint.toBase58(), account }); metaStorage['masterEditionsByOneTimeAuthMint'].push({ mintAddress: masterEdition.oneTimePrintingAuthorizationMint.toBase58(), account }); // setter('masterEditions', meta.pubkey.toBase58(), account); // setter( // 'masterEditionsByPrintingMint', // (masterEdition as MasterEditionV1).printingMint.toBase58(), // account, // ); // setter( // 'masterEditionsByOneTimeAuthMint', // ( // masterEdition as MasterEditionV1 // ).oneTimePrintingAuthorizationMint.toBase58(), // account, // ); } else { const account = { pubkey: meta.pubkey, account: meta.account, info: masterEdition, }; // setter('masterEditions', meta.pubkey.toBase58(), account); metaStorage['masterEditions'].push({ mintAddress: meta.pubkey.toBase58(), account }); } } } catch (_a) { // ignore errors // add type as first byte for easier deserialization } }; exports.decodeMetadata = (buffer) => { const metadata = borsh_1.deserializeUnchecked(exports.METADATA_SCHEMA, Metadata, buffer); return metadata; }; exports.decodeEditionMarker = (buffer) => { const editionMarker = borsh_1.deserializeUnchecked(exports.METADATA_SCHEMA, EditionMarker, buffer); return editionMarker; }; exports.decodeEdition = (buffer) => { return borsh_1.deserializeUnchecked(exports.METADATA_SCHEMA, Edition, buffer); }; exports.decodeMasterEdition = (buffer) => { if (buffer[0] == MetadataKey.MasterEditionV1) { return borsh_1.deserializeUnchecked(exports.METADATA_SCHEMA, MasterEditionV1, buffer); } else { return borsh_1.deserializeUnchecked(exports.METADATA_SCHEMA, MasterEditionV2, buffer); } }; function updateMetadata(data, newUpdateAuthority, primarySaleHappened, mintKey, updateAuthority, instructions, metadataAccount) { return __awaiter(this, void 0, void 0, function* () { const metadataProgramId = ids_1.programIds().metadata; metadataAccount = metadataAccount || (yield exports.findProgramAddress([ Buffer.from('metadata'), metadataProgramId.toBuffer(), mintKey.toBuffer(), ], metadataProgramId))[0]; const value = new UpdateMetadataArgs({ data, updateAuthority: !newUpdateAuthority ? undefined : newUpdateAuthority, primarySaleHappened: primarySaleHappened === null || primarySaleHappened === undefined ? null : primarySaleHappened, }); const txnData = Buffer.from(borsh_1.serialize(exports.METADATA_SCHEMA, value)); const keys = [ { pubkey: metadataAccount, isSigner: false, isWritable: true, }, { pubkey: updateAuthority, isSigner: true, isWritable: false, }, ]; instructions.push(new web3_js_1.TransactionInstruction({ keys, programId: metadataProgramId, data: txnData, })); return metadataAccount; }); } exports.updateMetadata = updateMetadata; function createMetadata(data, updateAuthority, mintKey, mintAuthorityKey, instructions, payer) { return __awaiter(this, void 0, void 0, function* () { const metadataProgramId = ids_1.programIds().metadata; const metadataAccount = (yield exports.findProgramAddress([ Buffer.from('metadata'), metadataProgramId.toBuffer(), mintKey.toBuffer(), ], metadataProgramId))[0]; console.log('Data', data); const value = new CreateMetadataArgs({ data, isMutable: true }); const txnData = Buffer.from(borsh_1.serialize(exports.METADATA_SCHEMA, value)); const keys = [ { pubkey: metadataAccount, isSigner: false, isWritable: true, }, { pubkey: mintKey, isSigner: false, isWritable: false, }, { pubkey: mintAuthorityKey, isSigner: true, isWritable: false, }, { pubkey: payer, isSigner: true, isWritable: false, }, { pubkey: updateAuthority, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false, }, ]; instructions.push(new web3_js_1.TransactionInstruction({ keys, programId: metadataProgramId, data: txnData, })); return metadataAccount; }); } exports.createMetadata = createMetadata; function createMasterEdition(maxSupply, mintKey, updateAuthorityKey, mintAuthorityKey, payer, instructions) { return __awaiter(this, void 0, void 0, function* () { const metadataProgramId = ids_1.programIds().metadata; const metadataAccount = (yield exports.findProgramAddress([ Buffer.from(exports.METADATA_PREFIX), metadataProgramId.toBuffer(), mintKey.toBuffer(), ], metadataProgramId))[0]; const editionAccount = (yield exports.findProgramAddress([ Buffer.from(exports.METADATA_PREFIX), metadataProgramId.toBuffer(), mintKey.toBuffer(), Buffer.from(exports.EDITION), ], metadataProgramId))[0]; const value = new CreateMasterEditionArgs({ maxSupply: maxSupply || null }); const data = Buffer.from(borsh_1.serialize(exports.METADATA_SCHEMA, value)); const keys = [ { pubkey: editionAccount, isSigner: false, isWritable: true, }, { pubkey: mintKey, isSigner: false, isWritable: true, }, { pubkey: updateAuthorityKey, isSigner: true, isWritable: false, }, { pubkey: mintAuthorityKey, isSigner: true, isWritable: false, }, { pubkey: payer, isSigner: true, isWritable: false, }, { pubkey: metadataAccount, isSigner: false, isWritable: false, }, { pubkey: ids_1.programIds().token, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false, }, ]; instructions.push(new web3_js_1.TransactionInstruction({ keys, programId: metadataProgramId, data, })); }); } exports.createMasterEdition = createMasterEdition; function deprecatedMintNewEditionFromMasterEditionViaPrintingToken(newMint, tokenMint, newMintAuthority, printingMint, authorizationTokenHoldingAccount, burnAuthority, updateAuthorityOfMaster, reservationList, instructions, payer) { return __awaiter(this, void 0, void 0, function* () { const metadataProgramId = ids_1.programIds().metadata; const newMetadataKey = yield getMetadata(newMint); const masterMetadataKey = yield getMetadata(tokenMint); const newEdition = yield getEdition(newMint); const masterEdition = yield getEdition(tokenMint); const data = Buffer.from([3]); const keys = [ { pubkey: newMetadataKey, isSigner: false, isWritable: true, }, { pubkey: newEdition, isSigner: false, isWritable: true, }, { pubkey: masterEdition, isSigner: false, isWritable: true, }, { pubkey: newMint, isSigner: false, isWritable: true, }, { pubkey: newMintAuthority, isSigner: true, isWritable: false, }, { pubkey: printingMint, isSigner: false, isWritable: true, }, { pubkey: authorizationTokenHoldingAccount, isSigner: false, isWritable: true, }, { pubkey: burnAuthority, isSigner: true, isWritable: false, }, { pubkey: payer, isSigner: true, isWritable: false, }, { pubkey: updateAuthorityOfMaster, isSigner: false, isWritable: false, }, { pubkey: masterMetadataKey, isSigner: false, isWritable: false, }, { pubkey: ids_1.programIds().token, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false, }, ]; if (reservationList) { keys.push({ pubkey: reservationList, isSigner: false, isWritable: true, }); } instructions.push(new web3_js_1.TransactionInstruction({ keys, programId: metadataProgramId, data, })); }); } exports.deprecatedMintNewEditionFromMasterEditionViaPrintingToken = deprecatedMintNewEditionFromMasterEditionViaPrintingToken; function mintNewEditionFromMasterEditionViaToken(newMint, tokenMint, newMintAuthority, newUpdateAuthority, tokenOwner, tokenAccount, instructions, payer, edition) { return __awaiter(this, void 0, void 0, function* () { const metadataProgramId = ids_1.programIds().metadata; const newMetadataKey = yield getMetadata(newMint); const masterMetadataKey = yield getMetadata(tokenMint); const newEdition = yield getEdition(newMint); const masterEdition = yield getEdition(tokenMint); const editionMarkPda = yield getEditionMarkPda(tokenMint, edition); const data = Buffer.from([11]); const keys = [ { pubkey: newMetadataKey, isSigner: false, isWritable: true, }, { pubkey: newEdition, isSigner: false, isWritable: true, }, { pubkey: masterEdition, isSigner: false, isWritable: true, }, { pubkey: newMint, isSigner: false, isWritable: true, }, { pubkey: editionMarkPda, isSigner: false, isWritable: true, }, { pubkey: newMintAuthority, isSigner: true, isWritable: false, }, { pubkey: payer, isSigner: true, isWritable: false, }, { pubkey: tokenOwner, isSigner: true, isWritable: false, }, { pubkey: tokenAccount, isSigner: false, isWritable: false, }, { pubkey: newUpdateAuthority, isSigner: false, isWritable: false, }, { pubkey: masterMetadataKey, isSigner: false, isWritable: false, }, { pubkey: ids_1.programIds().token, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false, }, ]; instructions.push(new web3_js_1.TransactionInstruction({ keys, programId: metadataProgramId, data, })); }); } exports.mintNewEditionFromMasterEditionViaToken = mintNewEditionFromMasterEditionViaToken; function updatePrimarySaleHappenedViaToken(metadata, owner, tokenAccount, instructions) { return __awaiter(this, void 0, void 0, function* () { const metadataProgramId = ids_1.programIds().metadata; const data = Buffer.from([4]); const keys = [ { pubkey: metadata, isSigner: false, isWritable: true, }, { pubkey: owner, isSigner: true, isWritable: false, }, { pubkey: tokenAccount, isSigner: false, isWritable: false, }, ]; instructions.push(new web3_js_1.TransactionInstruction({ keys, programId: metadataProgramId, data, })); }); } exports.updatePrimarySaleHappenedViaToken = updatePrimarySaleHappenedViaToken; function deprecatedCreateReservationList(metadata, masterEdition, resource, updateAuthority, payer, instructions) { return __awaiter(this, void 0, void 0, function* () { const metadataProgramId = ids_1.programIds().metadata; const reservationList = yield deprecatedGetReservationList(masterEdition, resource); const data = Buffer.from([6]); const keys = [ { pubkey: reservationList, isSigner: false, isWritable: true, }, { pubkey: payer, isSigner: true, isWritable: false, }, { pubkey: updateAuthority, isSigner: true, isWritable: false, }, { pubkey: masterEdition, isSigner: false, isWritable: false, }, { pubkey: resource, isSigner: false, isWritable: false, }, { pubkey: metadata, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false, }, ]; instructions.push(new web3_js_1.TransactionInstruction({ keys, programId: metadataProgramId, data, })); }); } exports.deprecatedCreateReservationList = deprecatedCreateReservationList; function signMetadata(metadata, creator, instructions) { return __awaiter(this, void 0, void 0, function* () { const metadataProgramId = ids_1.programIds().metadata; const data = Buffer.from([7]); const keys = [ { pubkey: metadata, isSigner: false, isWritable: true, }, { pubkey: creator, isSigner: true, isWritable: false, }, ]; instructions.push(new web3_js_1.TransactionInstruction({ keys, programId: metadataProgramId, data, })); }); } exports.signMetadata = signMetadata; function deprecatedMintPrintingTokens(destination, printingMint, updateAuthority, metadata, masterEdition, supply, instructions) { return __awaiter(this, void 0, void 0, function* () { const PROGRAM_IDS = ids_1.programIds(); const metadataProgramId = PROGRAM_IDS.metadata; const value = new MintPrintingTokensArgs({ supply }); const data = Buffer.from(borsh_1.serialize(exports.METADATA_SCHEMA, value)); const keys = [ { pubkey: destination, isSigner: false, isWritable: true, }, { pubkey: printingMint, isSigner: false, isWritable: true, }, { pubkey: updateAuthority, isSigner: true, isWritable: false, }, { pubkey: metadata, isSigner: false, isWritable: false, }, { pubkey: masterEdition, isSigner: false, isWritable: false, }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false, }, { pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false, }, ]; instructions.push(new web3_js_1.TransactionInstruction({ keys, programId: metadataProgramId, data, })); }); } exports.deprecatedMintPrintingTokens = deprecatedMintPrintingTokens; function convertMasterEditionV1ToV2(masterEdition, oneTimeAuthMint, printingMint, instructions) { return __awaiter(this, void 0, void 0, function* () { const metadataProgramId = ids_1.programIds().metadata; const data = Buffer.from([12]); const keys = [ { pubkey: masterEdition, isSigner: false, isWritable: true, }, { pubkey: oneTimeAuthMint, isSigner: false, isWritable: true, }, { pubkey: printingMint, isSigner: false, isWritable: true, }, ]; instructions.push(new web3_js_1.TransactionInstruction({ keys, programId: metadataProgramId, data, })); }); } exports.convertMasterEditionV1ToV2 = convertMasterEditionV1ToV2; function getEdition(tokenMint) { return __awaiter(this, void 0, void 0, function* () { const PROGRAM_IDS = ids_1.programIds(); return (yield exports.findProgramAddress([ Buffer.from(exports.METADATA_PREFIX), PROGRAM_IDS.metadata.toBuffer(), tokenMint.toBuffer(), Buffer.from(exports.EDITION), ], PROGRAM_IDS.metadata))[0]; }); } exports.getEdition = getEdition; function getMetadata(tokenMint) { return __awaiter(this, void 0, void 0, function* () { const PROGRAM_IDS = ids_1.programIds(); return (yield exports.findProgramAddress([ Buffer.from(exports.METADATA_PREFIX), PROGRAM_IDS.metadata.toBuffer(), tokenMint.toBuffer(), ], PROGRAM_IDS.metadata))[0]; }); } exports.getMetadata = getMetadata; function deprecatedGetReservationList(masterEdition, resource) { return __awaiter(this, void 0, void 0, function* () { const PROGRAM_IDS = ids_1.programIds(); return (yield exports.findProgramAddress([ Buffer.from(exports.METADATA_PREFIX), PROGRAM_IDS.metadata.toBuffer(), masterEdition.toBuffer(), Buffer.from(exports.RESERVATION), resource.toBuffer(), ], PROGRAM_IDS.metadata))[0]; }); } exports.deprecatedGetReservationList = deprecatedGetReservationList; function getEditionMarkPda(mint, edition) { return __awaiter(this, void 0, void 0, function* () { const PROGRAM_IDS = ids_1.programIds(); const editionNumber = Math.floor(edition.toNumber() / 248); return (yield exports.findProgramAddress([ Buffer.from(exports.METADATA_PREFIX), PROGRAM_IDS.metadata.toBuffer(), mint.toBuffer(), Buffer.from(exports.EDITION), Buffer.from(editionNumber.toString()), ], PROGRAM_IDS.metadata))[0]; }); } exports.getEditionMarkPda = getEditionMarkPda;