UNPKG

@apillon/cli

Version:
108 lines 4.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.listCollectionTransactions = exports.transferCollectionOwnership = exports.burnCollectionNft = exports.nestMintCollectionNft = exports.mintCollectionNft = exports.createCollection = exports.getCollection = exports.listCollections = void 0; const sdk_1 = require("@apillon/sdk"); const files_1 = require("../../lib/files"); const options_1 = require("../../lib/options"); const utils_1 = require("../../lib/utils"); async function listCollections(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const data = await new sdk_1.Nft(optsWithGlobals).listCollections(Object.assign(Object.assign({}, (0, options_1.paginate)(optsWithGlobals)), { collectionStatus: (0, sdk_1.toInteger)(optsWithGlobals.status) })); console.log(data.items.map((d) => d.serialize())); }); } exports.listCollections = listCollections; async function getCollection(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const data = await new sdk_1.Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) .get(); console.log(data.serialize()); }); } exports.getCollection = getCollection; async function createCollection(filePath, optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { let createCollectionData; try { createCollectionData = (0, files_1.readAndParseJson)(filePath); } catch (e) { if (e.code === 'ENOENT') { return console.error(`Error: File not found (${filePath}).`); } else if (e.name === 'SyntaxError' && e.message.includes('Unexpected end of JSON input')) { return console.error(`Error: Failed to parse JSON file (${filePath}).`); } else { return console.error(e); } } if (!createCollectionData) { return; } const nft = new sdk_1.Nft(optsWithGlobals); const data = optsWithGlobals.substrate ? await nft.createSubstrate(createCollectionData) : await nft.create(createCollectionData); console.log(data.serialize()); console.log('NFT collection created successfully!'); }); } exports.createCollection = createCollection; async function mintCollectionNft(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const data = await new sdk_1.Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) .mint({ receivingAddress: optsWithGlobals.address, quantity: (0, sdk_1.toInteger)(optsWithGlobals.quantity), }); if (data.success) { console.log('NFT minted successfully'); } }); } exports.mintCollectionNft = mintCollectionNft; async function nestMintCollectionNft(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const data = await new sdk_1.Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) .nestMint(optsWithGlobals.parentCollection, (0, sdk_1.toInteger)(optsWithGlobals.parentNft), (0, sdk_1.toInteger)(optsWithGlobals.quantity)); if (data.success) { console.log('NFT nest minted successfully'); } }); } exports.nestMintCollectionNft = nestMintCollectionNft; async function burnCollectionNft(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const data = await new sdk_1.Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) .burn(optsWithGlobals.tokenId); if (data.success) { console.log('NFT burned successfully'); } }); } exports.burnCollectionNft = burnCollectionNft; async function transferCollectionOwnership(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { await new sdk_1.Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) .transferOwnership(optsWithGlobals.address); console.log('NFT ownership transferred successfully'); }); } exports.transferCollectionOwnership = transferCollectionOwnership; async function listCollectionTransactions(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const data = await new sdk_1.Nft(optsWithGlobals) .collection(optsWithGlobals.uuid) .listTransactions(Object.assign(Object.assign({}, (0, options_1.paginate)(optsWithGlobals)), { transactionStatus: (0, sdk_1.toInteger)(optsWithGlobals.status), transactionType: (0, sdk_1.toInteger)(optsWithGlobals.type) })); console.log(data); }); } exports.listCollectionTransactions = listCollectionTransactions; //# sourceMappingURL=nft.service.js.map