UNPKG

@magiceden/magiceden-sdk

Version:

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

93 lines (92 loc) 3.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BuyParams = exports.SolanaBuyParamsSchema = exports.EvmMultipleBuyParamsSchema = exports.EvmBuyParamsSchema = exports.BaseBuyParamsSchema = void 0; const zod_1 = require("zod"); const chains_1 = require("../../chains"); /** * Parameters for buying an NFT */ exports.BaseBuyParamsSchema = zod_1.z.object({ /** * The NFT token * * - For EVM, the token is in the format of contractAddress:tokenId * - For Solana, the token is the mint address */ token: zod_1.z .string() .describe('The NFT token in the format of contractAddress:tokenId for EVM and <mint address> for Solana'), }); exports.EvmBuyParamsSchema = exports.BaseBuyParamsSchema.extend({ /** * The collection to buy */ collection: zod_1.z.string().optional().describe('Collection to buy.'), /** * The number of NFTs to buy */ quantity: zod_1.z.number().optional().describe('The number of NFTs to buy.'), /** * The order id to fill */ orderId: zod_1.z.string().optional().describe('Optional order id to fill.'), }); exports.EvmMultipleBuyParamsSchema = zod_1.z.object({ /** * The EVM chain to buy on */ chain: chains_1.ZodEvmBlockchain.describe('The chain to buy on'), /** * The currency to use for the purchase */ currency: zod_1.z.string().optional().describe('The currency to use for the purchase'), /** * The chain id of the currency */ currencyChainId: zod_1.z.number().optional().describe('The chain id of the currency'), /** * The buy parameters */ items: zod_1.z.array(exports.EvmBuyParamsSchema).describe('The buy parameters'), }); exports.SolanaBuyParamsSchema = exports.BaseBuyParamsSchema.extend({ /** * The seller's wallet address */ seller: zod_1.z.string().describe("The seller's wallet address"), /** * The purchase price */ price: zod_1.z.string().describe('The purchase price'), /** * The auction house address * * @default AUCTION_HOUSE_ADDRESS (found in constants/solana/marketplace.ts) */ auctionHouseAddress: zod_1.z.string().optional().describe('Auction house address'), /** * The buyer referral address */ buyerReferral: zod_1.z.string().optional().describe('Buyer referral address'), /** * The seller referral address */ sellerReferral: zod_1.z.string().optional().describe('Seller referral address'), /** * The buyer expiry timestamp */ buyerExpiry: zod_1.z.number().optional().describe('Buyer expiry timestamp'), /** * The seller expiry timestamp */ sellerExpiry: zod_1.z.number().optional().describe('Seller expiry timestamp'), /** * The buyer creator royalty percentage */ buyerCreatorRoyaltyPercent: zod_1.z.number().optional().describe('Buyer creator royalty percentage'), /** * The SPL token price details */ splPrice: zod_1.z.custom().optional().describe('SPL token price details'), }); exports.BuyParams = zod_1.z.union([exports.EvmMultipleBuyParamsSchema, exports.SolanaBuyParamsSchema]);