import {z} from 'zod' export type CreateSignatureV2025DTO = {type: 'message', params: {message: string, signer?: string | undefined, chain?: ('arbitrum-sepolia' | 'arc-testnet' | 'avalanche-fuji' | 'curtis' | 'base-goerli' | 'base-sepolia' | 'bsc-testnet' | 'chiliz-spicy-testnet' | 'coti-testnet' | 'ethereum-goerli' | 'ethereum-sepolia' | 'hedera-testnet' | 'hypersonic-testnet' | 'lightlink-pegasus' | 'mantle-sepolia' | 'optimism-goerli' | 'optimism-sepolia' | 'polygon-amoy' | 'polygon-mumbai' | 'crossmint-private-testnet-ethereum' | 'crossmint-private-testnet-polygon' | 'rari-testnet' | 'scroll-sepolia' | 'sei-atlantic-2-testnet' | 'shape-sepolia' | 'skale-nebula-testnet' | 'soneium-minato-testnet' | 'space-testnet' | 'story-testnet' | 'verify-testnet' | 'viction-testnet' | 'xai-sepolia-testnet' | 'zkatana' | 'zkyoto' | 'zora-goerli' | 'zora-sepolia' | 'mode-sepolia' | 'u2u-nebulas' | 'zenchain-testnet' | 'abstract-testnet' | 'world-chain-sepolia' | 'plume-testnet' | 'flow-testnet' | 'tempo-testnet' | 'robinhood-chain-testnet' | 'ethereum' | 'polygon' | 'bsc' | 'optimism' | 'arbitrum' | 'base' | 'zora' | 'arbitrumnova' | 'astar-zkevm' | 'apechain' | 'hedera' | 'coti' | 'lightlink' | 'mantle' | 'skale-nebula' | 'sei-pacific-1' | 'chiliz' | 'avalanche' | 'xai' | 'shape' | 'rari' | 'scroll' | 'viction' | 'mode' | 'space' | 'soneium' | 'story' | 'u2u-solaris' | 'abstract' | 'world-chain' | 'plume' | 'flow' | 'tempo' | 'robinhood-chain') | undefined}} | {type: 'typed-data', params: {typedData: {domain: {name: string, version: string, chainId: number, verifyingContract: string, salt?: string | undefined}, types: {[key: string]: Array<{name: string, type: string}>}, primaryType: string, message: {[key: string]: unknown}}, chain: 'arbitrum-sepolia' | 'arc-testnet' | 'avalanche-fuji' | 'curtis' | 'base-goerli' | 'base-sepolia' | 'bsc-testnet' | 'chiliz-spicy-testnet' | 'coti-testnet' | 'ethereum-goerli' | 'ethereum-sepolia' | 'hedera-testnet' | 'hypersonic-testnet' | 'lightlink-pegasus' | 'mantle-sepolia' | 'optimism-goerli' | 'optimism-sepolia' | 'polygon-amoy' | 'polygon-mumbai' | 'crossmint-private-testnet-ethereum' | 'crossmint-private-testnet-polygon' | 'rari-testnet' | 'scroll-sepolia' | 'sei-atlantic-2-testnet' | 'shape-sepolia' | 'skale-nebula-testnet' | 'soneium-minato-testnet' | 'space-testnet' | 'story-testnet' | 'verify-testnet' | 'viction-testnet' | 'xai-sepolia-testnet' | 'zkatana' | 'zkyoto' | 'zora-goerli' | 'zora-sepolia' | 'mode-sepolia' | 'u2u-nebulas' | 'zenchain-testnet' | 'abstract-testnet' | 'world-chain-sepolia' | 'plume-testnet' | 'flow-testnet' | 'tempo-testnet' | 'robinhood-chain-testnet' | 'ethereum' | 'polygon' | 'bsc' | 'optimism' | 'arbitrum' | 'base' | 'zora' | 'arbitrumnova' | 'astar-zkevm' | 'apechain' | 'hedera' | 'coti' | 'lightlink' | 'mantle' | 'skale-nebula' | 'sei-pacific-1' | 'chiliz' | 'avalanche' | 'xai' | 'shape' | 'rari' | 'scroll' | 'viction' | 'mode' | 'space' | 'soneium' | 'story' | 'u2u-solaris' | 'abstract' | 'world-chain' | 'plume' | 'flow' | 'tempo' | 'robinhood-chain', signer?: string | undefined, isSmartWalletSignature?: boolean | undefined}} | {type: 'auth-entries', params: {authorizationEntries: string, signer?: string | undefined}}; export type CreateApi20250609WalletsWalletLocatorSignaturesArgs = {'X-API-KEY': string, walletLocator: string, 'x-idempotency-key'?: string | undefined, body: CreateSignatureV2025DTO}; export type CreateApi20250609WalletsWalletLocatorSignaturesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const walletsSignatureV2025ResponseDTO = z.object({id: z.string(), type: z.enum(["message", "typed-data", "auth-entries"]), chainType: z.enum(["evm", "solana", "aptos", "sui", "stellar"]), walletType: z.enum(["smart", "mpc"]), status: z.enum(["awaiting-approval", "pending", "failed", "success"]), params: z.union([z.object({message: z.string(), signer: z.union([z.object({type: z.literal("external-wallet"), address: z.string(), locator: z.string()}), z.object({type: z.literal("passkey"), id: z.string(), locator: z.string()}), z.object({type: z.literal("api-key"), address: z.string(), locator: z.string()}), z.object({type: z.literal("device"), publicKey: z.object({x: z.string(), y: z.string()}), locator: z.string(), name: z.string().optional()}), z.object({type: z.literal("email"), email: z.string(), locator: z.string()}), z.object({type: z.literal("phone"), phone: z.string(), locator: z.string()}), z.object({type: z.literal("server"), address: z.string(), locator: z.string()})]).optional(), chain: z.enum(["arbitrum-sepolia", "arc-testnet", "avalanche-fuji", "curtis", "base-goerli", "base-sepolia", "bsc-testnet", "chiliz-spicy-testnet", "coti-testnet", "ethereum-goerli", "ethereum-sepolia", "hedera-testnet", "hypersonic-testnet", "lightlink-pegasus", "mantle-sepolia", "optimism-goerli", "optimism-sepolia", "polygon-amoy", "polygon-mumbai", "crossmint-private-testnet-ethereum", "crossmint-private-testnet-polygon", "rari-testnet", "scroll-sepolia", "sei-atlantic-2-testnet", "shape-sepolia", "skale-nebula-testnet", "soneium-minato-testnet", "space-testnet", "story-testnet", "verify-testnet", "viction-testnet", "xai-sepolia-testnet", "zkatana", "zkyoto", "zora-goerli", "zora-sepolia", "mode-sepolia", "u2u-nebulas", "zenchain-testnet", "abstract-testnet", "world-chain-sepolia", "plume-testnet", "flow-testnet", "tempo-testnet", "robinhood-chain-testnet", "ethereum", "polygon", "bsc", "optimism", "arbitrum", "base", "zora", "arbitrumnova", "astar-zkevm", "apechain", "hedera", "coti", "lightlink", "mantle", "skale-nebula", "sei-pacific-1", "chiliz", "avalanche", "xai", "shape", "rari", "scroll", "viction", "mode", "space", "soneium", "story", "u2u-solaris", "abstract", "world-chain", "plume", "flow", "tempo", "robinhood-chain"]).optional()}), z.object({typedData: z.object({domain: z.object({name: z.string(), version: z.string(), chainId: z.number(), verifyingContract: z.string(), salt: z.string().optional()}), types: z.record(z.string(), z.array(z.object({name: z.string(), type: z.string()}))), primaryType: z.string(), message: z.record(z.string(), z.unknown())}), chain: z.enum(["arbitrum-sepolia", "arc-testnet", "avalanche-fuji", "curtis", "base-goerli", "base-sepolia", "bsc-testnet", "chiliz-spicy-testnet", "coti-testnet", "ethereum-goerli", "ethereum-sepolia", "hedera-testnet", "hypersonic-testnet", "lightlink-pegasus", "mantle-sepolia", "optimism-goerli", "optimism-sepolia", "polygon-amoy", "polygon-mumbai", "crossmint-private-testnet-ethereum", "crossmint-private-testnet-polygon", "rari-testnet", "scroll-sepolia", "sei-atlantic-2-testnet", "shape-sepolia", "skale-nebula-testnet", "soneium-minato-testnet", "space-testnet", "story-testnet", "verify-testnet", "viction-testnet", "xai-sepolia-testnet", "zkatana", "zkyoto", "zora-goerli", "zora-sepolia", "mode-sepolia", "u2u-nebulas", "zenchain-testnet", "abstract-testnet", "world-chain-sepolia", "plume-testnet", "flow-testnet", "tempo-testnet", "robinhood-chain-testnet", "ethereum", "polygon", "bsc", "optimism", "arbitrum", "base", "zora", "arbitrumnova", "astar-zkevm", "apechain", "hedera", "coti", "lightlink", "mantle", "skale-nebula", "sei-pacific-1", "chiliz", "avalanche", "xai", "shape", "rari", "scroll", "viction", "mode", "space", "soneium", "story", "u2u-solaris", "abstract", "world-chain", "plume", "flow", "tempo", "robinhood-chain"]), signer: z.union([z.object({type: z.literal("external-wallet"), address: z.string(), locator: z.string()}), z.object({type: z.literal("passkey"), id: z.string(), locator: z.string()}), z.object({type: z.literal("api-key"), address: z.string(), locator: z.string()}), z.object({type: z.literal("device"), publicKey: z.object({x: z.string(), y: z.string()}), locator: z.string(), name: z.string().optional()}), z.object({type: z.literal("email"), email: z.string(), locator: z.string()}), z.object({type: z.literal("phone"), phone: z.string(), locator: z.string()}), z.object({type: z.literal("server"), address: z.string(), locator: z.string()})]).optional(), isSmartWalletSignature: z.boolean().optional()}), z.object({authorizationEntries: z.string(), signer: z.union([z.object({type: z.literal("external-wallet"), address: z.string(), locator: z.string()}), z.object({type: z.literal("passkey"), id: z.string(), locator: z.string()}), z.object({type: z.literal("api-key"), address: z.string(), locator: z.string()}), z.object({type: z.literal("device"), publicKey: z.object({x: z.string(), y: z.string()}), locator: z.string(), name: z.string().optional()}), z.object({type: z.literal("email"), email: z.string(), locator: z.string()}), z.object({type: z.literal("phone"), phone: z.string(), locator: z.string()}), z.object({type: z.literal("server"), address: z.string(), locator: z.string()})]).optional()})]), approvals: z.object({pending: z.array(z.union([z.object({signer: z.object({type: z.literal("quorum"), locator: z.string()}), quorumApprovals: z.object({threshold: z.number(), remaining: z.number(), pending: z.array(z.object({signer: z.union([z.object({type: z.literal("external-wallet"), address: z.string(), locator: z.string()}), z.object({type: z.literal("passkey"), id: z.string(), locator: z.string()}), z.object({type: z.literal("api-key"), address: z.string(), locator: z.string()}), z.object({type: z.literal("device"), publicKey: z.object({x: z.string(), y: z.string()}), locator: z.string(), name: z.string().optional()}), z.object({type: z.literal("email"), email: z.string(), locator: z.string()}), z.object({type: z.literal("phone"), phone: z.string(), locator: z.string()}), z.object({type: z.literal("server"), address: z.string(), locator: z.string()})]), message: z.string()})), submitted: z.array(z.object({signer: z.union([z.object({type: z.literal("external-wallet"), address: z.string(), locator: z.string()}), z.object({type: z.literal("passkey"), id: z.string(), locator: z.string()}), z.object({type: z.literal("api-key"), address: z.string(), locator: z.string()}), z.object({type: z.literal("device"), publicKey: z.object({x: z.string(), y: z.string()}), locator: z.string(), name: z.string().optional()}), z.object({type: z.literal("email"), email: z.string(), locator: z.string()}), z.object({type: z.literal("phone"), phone: z.string(), locator: z.string()}), z.object({type: z.literal("server"), address: z.string(), locator: z.string()})]), message: z.string(), signature: z.string(), submittedAt: z.union([z.number(), z.string()])}))})}), z.object({signer: z.union([z.object({type: z.literal("external-wallet"), address: z.string(), locator: z.string()}), z.object({type: z.literal("passkey"), id: z.string(), locator: z.string()}), z.object({type: z.literal("api-key"), address: z.string(), locator: z.string()}), z.object({type: z.literal("device"), publicKey: z.object({x: z.string(), y: z.string()}), locator: z.string(), name: z.string().optional()}), z.object({type: z.literal("email"), email: z.string(), locator: z.string()}), z.object({type: z.literal("phone"), phone: z.string(), locator: z.string()}), z.object({type: z.literal("server"), address: z.string(), locator: z.string()})]), message: z.string()})])).optional(), submitted: z.array(z.union([z.object({signer: z.object({type: z.literal("quorum"), locator: z.string()}), quorumApprovals: z.object({threshold: z.number(), remaining: z.number(), pending: z.array(z.object({signer: z.union([z.object({type: z.literal("external-wallet"), address: z.string(), locator: z.string()}), z.object({type: z.literal("passkey"), id: z.string(), locator: z.string()}), z.object({type: z.literal("api-key"), address: z.string(), locator: z.string()}), z.object({type: z.literal("device"), publicKey: z.object({x: z.string(), y: z.string()}), locator: z.string(), name: z.string().optional()}), z.object({type: z.literal("email"), email: z.string(), locator: z.string()}), z.object({type: z.literal("phone"), phone: z.string(), locator: z.string()}), z.object({type: z.literal("server"), address: z.string(), locator: z.string()})]), message: z.string()})), submitted: z.array(z.object({signer: z.union([z.object({type: z.literal("external-wallet"), address: z.string(), locator: z.string()}), z.object({type: z.literal("passkey"), id: z.string(), locator: z.string()}), z.object({type: z.literal("api-key"), address: z.string(), locator: z.string()}), z.object({type: z.literal("device"), publicKey: z.object({x: z.string(), y: z.string()}), locator: z.string(), name: z.string().optional()}), z.object({type: z.literal("email"), email: z.string(), locator: z.string()}), z.object({type: z.literal("phone"), phone: z.string(), locator: z.string()}), z.object({type: z.literal("server"), address: z.string(), locator: z.string()})]), message: z.string(), signature: z.string(), submittedAt: z.union([z.number(), z.string()])}))})}), z.object({signature: z.string(), submittedAt: z.union([z.number(), z.string()]), signer: z.union([z.object({type: z.literal("external-wallet"), address: z.string(), locator: z.string()}), z.object({type: z.literal("passkey"), id: z.string(), locator: z.string()}), z.object({type: z.literal("api-key"), address: z.string(), locator: z.string()}), z.object({type: z.literal("device"), publicKey: z.object({x: z.string(), y: z.string()}), locator: z.string(), name: z.string().optional()}), z.object({type: z.literal("email"), email: z.string(), locator: z.string()}), z.object({type: z.literal("phone"), phone: z.string(), locator: z.string()}), z.object({type: z.literal("server"), address: z.string(), locator: z.string()})]), message: z.string(), metadata: z.object({deviceInfo: z.string().optional(), ipAddress: z.string().optional(), userAgent: z.string().optional()}).optional()})])).optional(), required: z.number().optional()}), createdAt: z.union([z.number(), z.string()]), completedAt: z.union([z.number(), z.string()]).optional(), error: z.unknown(), outputSignature: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Create Signature * * POST /2025-06-09/wallets/{walletLocator}/signatures */ export const createApi20250609WalletsWalletLocatorSignatures = async (args: CreateApi20250609WalletsWalletLocatorSignaturesArgs, options?: CreateApi20250609WalletsWalletLocatorSignaturesOptions) => { const {baseUrl = "https://staging.crossmint.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['X-API-KEY'] != null) headers.set("X-API-KEY", String(args['X-API-KEY'])) if (args['x-idempotency-key'] != null) headers.set("x-idempotency-key", String(args['x-idempotency-key'])) const url = `${baseUrl.replace(/\/+$/, '')}/2025-06-09/wallets/${encodeURIComponent(String(args.walletLocator))}/signatures${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(walletsSignatureV2025ResponseDTO, await res.json()) };