@magiceden/magiceden-sdk
Version:
A TypeScript SDK for interacting with Magic Eden's API across multiple chains.
193 lines (192 loc) • 7.18 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateLaunchpadParams = exports.SolanaUpdateLaunchpadParamsSchema = exports.EvmUpdateLaunchpadParamsSchema = exports.BaseUpdateLaunchpadParamsSchema = 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 evm_1 = require("../../evm");
const shared_1 = require("./shared");
const solana_1 = require("../../solana");
/**
* Parameters for updating a launchpad
*/
exports.BaseUpdateLaunchpadParamsSchema = zod_1.z.object({
/**
* The collection address/ID to update.
*/
collectionId: zod_1.z.string().describe('Collection address/ID'),
/**
* The owner wallet address.
*/
owner: evm_1.EVMAddressToLowerCaseSchema.describe('Owner wallet address'),
/**
* The blockchain where the collection is deployed.
*/
chain: zod_1.z.nativeEnum(chains_1.Blockchain).describe('Blockchain'),
/**
* The protocol used for the token.
*/
protocol: protocol_1.TokenProtocolType.describe('Token protocol type'),
/**
* The collection name.
*/
name: zod_1.z.string().min(1).max(nft_1.MAX_NAME_LENGTH).optional().describe('Collection name'),
/**
* 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}`)
.optional()
.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) => {
return creators.reduce((acc, creator) => acc + creator.share, 0) === 100;
}, {
message: "Creator's shares must sum to 100",
})
.optional()
.describe('Royalty recipients and their shares'),
/**
* The payout recipient address of mint proceeds.
*/
payoutRecipient: zod_1.z
.string()
.min(1)
.optional()
.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'),
/**
* The mint stages.
*/
mintStages: shared_1.MintStages.optional().describe('Mint stages configuration'),
/**
* 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'),
/**
* Token ID for ERC1155.
*/
tokenId: zod_1.z.number().int().min(0).optional().describe('Token ID for ERC1155'),
});
exports.EvmUpdateLaunchpadParamsSchema = exports.BaseUpdateLaunchpadParamsSchema.extend({
/**
* The collection address/ID to update.
*/
collectionId: evm_1.EVMAddressToLowerCaseSchema.describe('Collection address/ID'),
/**
* The blockchain where the collection is deployed.
*/
chain: chains_1.ZodEvmBlockchain,
/**
* The protocol used for the token.
*/
protocol: zod_1.z.enum([protocol_1.EvmProtocolType.ERC721, protocol_1.EvmProtocolType.ERC1155]),
});
exports.SolanaUpdateLaunchpadParamsSchema = exports.BaseUpdateLaunchpadParamsSchema.extend({
/**
* The collection address/ID to update.
*/
collectionId: primitives_1.zSolanaAddress.describe('Collection address/ID'),
/**
* The blockchain where the collection is deployed.
*/
chain: zod_1.z.literal(chains_1.Blockchain.SOLANA),
/**
* The protocol used for the token.
*/
protocol: zod_1.z.literal(protocol_1.SolProtocolType.METAPLEX_CORE),
/**
* The payout recipient address of mint proceeds.
*/
payoutRecipient: primitives_1.zSolanaAddress.describe('Payout recipient address of mint proceeds'),
/**
* The payer address for transaction fees.
*/
payer: primitives_1.zSolanaAddress.describe('Payer address'),
/**
* The social media links.
*/
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 current collection symbol.
*/
symbol: primitives_1.SolanaSymbol.describe('Collection symbol'),
/**
* The new collection symbol to update to.
*/
newSymbol: primitives_1.SolanaSymbol.optional().describe('New collection symbol'),
/**
* The candy machine ID associated with the collection.
*/
candyMachineId: primitives_1.zSolanaAddress.describe('Candy machine ID'),
/**
* The owner address of the collection.
*/
owner: primitives_1.zSolanaAddress.describe('Owner address'),
/**
* External link for the collection.
*/
externalLink: zod_1.z.string().optional().describe('External link'),
/**
* The royalty recipients and their shares.
*/
royaltyRecipients: zod_1.z
.array(solana_1.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'),
});
exports.UpdateLaunchpadParams = zod_1.z.union([
exports.EvmUpdateLaunchpadParamsSchema,
exports.SolanaUpdateLaunchpadParamsSchema,
]);