import type { Chain } from "../types" import { getCrossChainDropMintPath, getDeployDropPath, getDeployDropReceiptPath, getDropMintPath, getDropPath, getDropsPath, } from "./apiPaths" import type { Fetcher } from "./fetcher" import type { CrossChainDropMintRequest, CrossChainDropMintResponse, DropDeployReceiptResponse, DropDeployRequest, DropDeployResponse, DropMintRequest, DropMintResponse, GetDropResponse, GetDropsArgs, GetDropsResponse, } from "./types" /** * Drop-related API operations */ export class DropsAPI { constructor(private fetcher: Fetcher) {} /** * Gets a list of drops (mints). */ async getDrops(args?: GetDropsArgs): Promise { const response = await this.fetcher.get(getDropsPath(), { ...args, chains: args?.chains?.join(","), }) return response } /** * Gets detailed drop information for a collection. */ async getDrop(slug: string): Promise { const response = await this.fetcher.get(getDropPath(slug)) return response } /** * Builds a mint transaction for a drop. */ async buildMintTransaction( slug: string, request: DropMintRequest, ): Promise { const response = await this.fetcher.post( getDropMintPath(slug), request, ) return response } /** * Builds ordered transactions for paying on one chain and minting on * another. Submit each transaction in order, then poll the returned * `receiptRequest` with `getTransactionReceipt` until it is terminal. */ async buildCrossChainMintTransactions( slug: string, request: CrossChainDropMintRequest, ): Promise { return this.fetcher.post( getCrossChainDropMintPath(slug), request, ) } /** * Builds a deploy-contract transaction for a new drop. Returns * ready-to-sign transaction data — caller submits onchain and then polls * `getDeployReceipt` until the contract address is available. */ async deployDropContract( request: DropDeployRequest, ): Promise { return this.fetcher.post(getDeployDropPath(), request) } /** * Get the receipt of a previously submitted drop-deploy transaction. */ async getDeployReceipt( chain: Chain, txHash: string, ): Promise { return this.fetcher.get( getDeployDropReceiptPath(chain, txHash), ) } }