@fugitivesclub/nft-cli
Version:
This CLI allow you to mint your NFT's
64 lines (63 loc) • 3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.mint = void 0;
const nft_1 = require("@fugitivesclub/nft");
require("reflect-metadata");
const mint = async (configuration, nftContents, supply = 0) => {
var _a, _b, _c, _d, _e, _f, _g, _h;
// Create client
const client = new nft_1.ClientNFT({
hederaAccount: configuration.hederaAccount,
nftStorageApiKey: configuration.nftStorageApiKey,
debugLevel: nft_1.DebugLevel.DEBUG,
});
if (Array.isArray(nftContents)) {
if (!configuration.metadata) {
throw new Error('`metadata` should be defined in your json configuration file.');
}
// Token metadata
const name = configuration.metadata.name;
const symbol = configuration.metadata.symbol;
const customRoyaltyFee = (_a = configuration.metadata.customRoyaltyFee) !== null && _a !== void 0 ? _a : null;
// Map NFT metadata
const nfts = nftContents.map((nftContent) => {
var _a, _b, _c, _d;
return ({
name: nftContent.metadata.name,
description: nftContent.metadata.description,
category: configuration.metadata.category,
creator: (_a = nftContent.metadata.creator) !== null && _a !== void 0 ? _a : configuration.metadata.creator,
attributes: (_b = nftContent.metadata.attributes) !== null && _b !== void 0 ? _b : null,
customProperties: (_d = (_c = nftContent.metadata.customProperties) !== null && _c !== void 0 ? _c : configuration.metadata.customProperties) !== null && _d !== void 0 ? _d : null,
media: nftContent.media,
});
});
return client.createAndMint({
name,
symbol,
customRoyaltyFee,
nfts,
});
}
const nftContent = nftContents;
const name = nftContent.metadata.name;
const description = nftContent.metadata.description;
const category = (_b = nftContent.metadata.category) !== null && _b !== void 0 ? _b : nft_1.CategoryNFT.ART;
const attributes = (_c = nftContent.metadata.attributes) !== null && _c !== void 0 ? _c : null;
const creator = (_d = nftContent.metadata.creator) !== null && _d !== void 0 ? _d : (_e = configuration.metadata) === null || _e === void 0 ? void 0 : _e.creator;
const customRoyaltyFee = (_f = nftContent.metadata.customRoyaltyFee) !== null && _f !== void 0 ? _f : null;
const customProperties = (_h = (_g = nftContent.metadata.customProperties) !== null && _g !== void 0 ? _g : (configuration.metadata && configuration.metadata.customProperties)) !== null && _h !== void 0 ? _h : null;
const media = nftContent.media;
return client.createAndMint({
name,
description,
category,
creator,
supply,
media,
attributes,
customProperties,
customRoyaltyFee,
});
};
exports.mint = mint;