UNPKG

@magiceden/magiceden-sdk

Version:

A TypeScript SDK for interacting with Magic Eden's API across multiple chains.

172 lines (171 loc) 6.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CreateLaunchpadParams = exports.SolanaCreateLaunchpadParamsSchema = exports.EvmCreateLaunchpadParamsSchema = exports.BaseCreateLaunchpadParamsSchema = void 0; const zod_1 = require("zod"); const chains_1 = require("../../chains"); const protocol_1 = require("../../protocol"); const primitives_1 = require("../../solana/primitives"); const nft_1 = require("../../../constants/nft"); const nft_2 = require("../../solana/nft"); const shared_1 = require("./shared"); /** * Parameters for creating a launchpad */ exports.BaseCreateLaunchpadParamsSchema = zod_1.z.object({ /** * The blockchain to deploy on. */ chain: zod_1.z.nativeEnum(chains_1.Blockchain).describe('Blockchain to deploy on'), /** * The protocol to use for the token. */ protocol: protocol_1.TokenProtocolType.describe('Token protocol type'), /** * The creator wallet address. */ creator: zod_1.z.string().min(1).describe('Creator wallet address'), /** * The collection name. */ name: zod_1.z.string().min(1).max(nft_1.MAX_NAME_LENGTH).describe('Collection name'), /** * The collection symbol. */ symbol: zod_1.z.string().min(1).max(nft_1.MAX_SYMBOL_LENGTH).describe('Collection symbol'), /** * URL pointing to the collection image. * For all collections, this image represents the entire collection. * For open editions, this is also used as the default image for individual NFTs if tokenImageUrl is not provided. */ imageUrl: zod_1.z.string().optional().describe('URL pointing to image for the collection'), /** * The collection description. */ description: zod_1.z.string().optional().describe('Collection description'), /** * The royalty basis points. */ royaltyBps: zod_1.z .number() .int() .min(nft_1.MIN_ROYALTY_BPS, `Royalty basis points must be at least ${nft_1.MIN_ROYALTY_BPS}`) .max(nft_1.MAX_ROYALTY_BPS, `Royalty basis points must be at most ${nft_1.MAX_ROYALTY_BPS}`) .describe('Royalty basis points'), /** * The royalty recipients and their shares. */ royaltyRecipients: zod_1.z .array(zod_1.z.object({ address: zod_1.z.string().min(1).describe('Royalty recipient address'), share: zod_1.z.number().int().min(1).max(100).describe('Share percentage'), })) .min(1) .refine((creators) => creators.reduce((acc, creator) => acc + creator.share, 0) === 100, { message: "Creator's shares must sum to 100", }) .describe('Royalty recipients and their shares'), /** * The payout recipient address of mint proceeds. */ payoutRecipient: zod_1.z.string().min(1).describe('Payout recipient address of mint proceeds'), /** * For non-open editions: Required URL pointing to a directory containing metadata JSON files for each NFT (0.json, 1.json, etc.). * Each JSON file should include its own image URL for that specific NFT. * * For open editions: Optional URL for additional metadata. */ nftMetadataUrl: zod_1.z.string().min(1).optional().describe('JSON file that contains all the metadata'), /** * For open editions only: URL pointing to the image used for all NFTs in the open edition. * If not provided for open editions, imageUrl will be used instead. * Not used for non-open editions, as individual NFT images are defined in the metadata files at nftMetadataUrl. * * This will be ignored for non-open editions. */ tokenImageUrl: zod_1.z.string().min(1).optional().describe('URL for image for the token'), /** * The mint stages. */ mintStages: shared_1.MintStages.describe('Mint stages configuration'), }); exports.EvmCreateLaunchpadParamsSchema = exports.BaseCreateLaunchpadParamsSchema.extend({ /** * The blockchain to deploy on. */ chain: chains_1.ZodEvmBlockchain, /** * The protocol to use for the token. */ protocol: zod_1.z.enum([protocol_1.EvmProtocolType.ERC721, protocol_1.EvmProtocolType.ERC1155]), }); exports.SolanaCreateLaunchpadParamsSchema = exports.BaseCreateLaunchpadParamsSchema.extend({ /** * The blockchain to deploy on. */ chain: zod_1.z.literal(chains_1.Blockchain.SOLANA).describe('Blockchain to deploy on'), /** * The protocol to use for the token. */ protocol: zod_1.z.literal(protocol_1.SolProtocolType.METAPLEX_CORE).describe('Token protocol type'), /** * The payout recipient address of mint proceeds. */ payoutRecipient: primitives_1.zSolanaAddress.describe('Payout recipient address of mint proceeds'), /** * The creator wallet address. */ creator: primitives_1.zSolanaAddress.describe('Creator wallet address'), // TODO: Uncomment the accounts once we properly implement a way for signerPubkeys to sign the VersionedTransaction // See the comments in src/adapters/transactions/solana.ts for more details // accounts: z // .object({ // collectionAccount: zSolanaAddress, // configAccount: zSolanaAddress, // orderInfoAccount: zSolanaAddress, // }) // .optional() // .describe('Accounts for the launchpad'), /** * The social media links. * * Currently only works on Solana. EVM is not yet supported. */ social: zod_1.z .object({ discordUrl: zod_1.z.string().optional(), externalUrl: zod_1.z.string().optional(), telegramUrl: zod_1.z.string().optional(), twitterUsername: zod_1.z.string().optional(), }) .optional() .describe('Social media links'), /** * The collection name. */ name: zod_1.z.string().max(nft_1.SOL_MAX_NAME_LENGTH).describe('Collection name'), /** * The collection symbol. */ symbol: primitives_1.SolanaSymbol.describe('Collection symbol'), /** * The royalty recipients and their shares. */ royaltyRecipients: zod_1.z .array(nft_2.zSolNonFungibleCreator) .min(1) .max(4) .refine((creators) => { return creators.reduce((acc, creator) => acc + creator.share, 0) === 100; }, { message: "Creator's shares must sum to 100", }) .describe('Royalty recipients and their shares'), /** * Whether the collection is an open edition. */ isOpenEdition: zod_1.z.boolean().describe('Whether the collection is an open edition'), }); exports.CreateLaunchpadParams = zod_1.z.union([ exports.EvmCreateLaunchpadParamsSchema, exports.SolanaCreateLaunchpadParamsSchema, ]);