import { N as Network } from '../network-N01ZIAhA.mjs'; import * as _solana_kit from '@solana/kit'; import { Transaction, TransactionSigner, RpcDevnet, SolanaRpcApiDevnet, RpcMainnet, SolanaRpcApiMainnet, KeyPairSigner } from '@solana/kit'; import { Hex, Address } from 'viem'; import { R as RoutesConfig, a as RoutePattern, P as Price, E as ERC20TokenAmount, S as SPLTokenAmount } from '../middleware-C-tTZ9La.mjs'; import { P as PaymentRequirements, a as PaymentPayload, E as ExactSvmPayload } from '../x402Specs-DDvn2leQ.mjs'; import { c as createDevnetRpcClient, a as createMainnetRpcClient, g as getRpcClient, b as getRpcSubscriptions } from '../rpc-B2R9VX68.mjs'; import { a as SvmConnectedClient, S as SvmSigner, c as createSignerFromBase58, b as createSvmConnectedClient, i as isSignerWallet } from '../wallet-BHq0zJhq.mjs'; import 'zod'; import '../wallet-h2_C4cJt.mjs'; import 'viem/chains'; /** * Converts an object to a JSON-safe format by converting bigint values to strings * and recursively processing nested objects and arrays * * @param data - The object to convert to JSON-safe format * @returns A new object with all bigint values converted to strings */ declare function toJsonSafe(data: T): object; declare const Base64EncodedRegex: RegExp; /** * Encodes a string to base64 format * * @param data - The string to be encoded to base64 * @returns The base64 encoded string */ declare function safeBase64Encode(data: string): string; /** * Decodes a base64 string back to its original format * * @param data - The base64 encoded string to be decoded * @returns The decoded string in UTF-8 format */ declare function safeBase64Decode(data: string): string; /** * Converts a network name to its corresponding chain ID * * @param network - The network name to convert to a chain ID * @returns The chain ID for the specified network * @throws Error if the network is not supported */ declare function getNetworkId(network: Network): number; /** * Computes the route patterns for the given routes config * * @param routes - The routes config to compute the patterns for * @returns The route patterns */ declare function computeRoutePatterns(routes: RoutesConfig): RoutePattern[]; /** * Finds the matching route pattern for the given path and method * * @param routePatterns - The route patterns to search through * @param path - The path to match against * @param method - The HTTP method to match against * @returns The matching route pattern or undefined if no match is found */ declare function findMatchingRoute(routePatterns: RoutePattern[], path: string, method: string): RoutePattern | undefined; /** * Gets the default asset (USDC) for the given network * * @param network - The network to get the default asset for * @returns The default asset */ declare function getDefaultAsset(network: Network): { address: `0x${string}` | _solana_kit.Address; decimals: number; eip712: { name: string; version: string; }; }; /** * Parses the amount from the given price * * @param price - The price to parse * @param network - The network to get the default asset for * @returns The parsed amount or an error message * * Supports multiple price formats: * - Dollar amount with $ prefix: "$1.2" → 1,200,000 atomic units (1.2 USDC) * - Wei/atomic units (string without $): "1000000" → 1,000,000 atomic units (1 USDC) * - Numeric dollar amount: 0.10 → 100,000 atomic units (0.10 USDC) * * Note: String prices without a $ prefix are interpreted as wei/atomic units. * To specify dollar amounts, either use the $ prefix (e.g., "$1.2") or pass a number (e.g., 1.2). */ declare function processPriceToAtomicAmount(price: Price, network: Network): { maxAmountRequired: string; asset: ERC20TokenAmount["asset"] | SPLTokenAmount["asset"]; } | { error: string; }; /** * Finds the matching payment requirements for the given payment * * @param paymentRequirements - The payment requirements to search through * @param payment - The payment to match against * @returns The matching payment requirements or undefined if no match is found * * For cross-chain payments, the payment.network is the source network (where the payer * signs the permit), while paymentRequirements.network is the destination network. * We need to match against srcNetwork for cross-chain scenarios. */ declare function findMatchingPaymentRequirements(paymentRequirements: PaymentRequirements[], payment: PaymentPayload): { scheme: "exact"; description: string; asset: string; maxAmountRequired: string; network: "base-sepolia" | "avalanche-fuji" | "abstract" | "abstract-testnet" | "arbitrum" | "avalanche" | "b3" | "base" | "bsc" | "ethereum" | "iotex" | "optimism" | "peaq" | "polygon" | "polygon-amoy" | "sei" | "sei-testnet" | "solana-devnet" | "solana"; resource: string; mimeType: string; payTo: string; maxTimeoutSeconds: number; outputSchema?: Record | undefined; srcAmountRequired?: string | undefined; extra?: Record | undefined; srcTokenAddress?: string | undefined; srcNetwork?: "base-sepolia" | "avalanche-fuji" | "abstract" | "abstract-testnet" | "arbitrum" | "avalanche" | "b3" | "base" | "bsc" | "ethereum" | "iotex" | "optimism" | "peaq" | "polygon" | "polygon-amoy" | "sei" | "sei-testnet" | "solana-devnet" | "solana" | undefined; } | undefined; /** * Decodes the X-PAYMENT-RESPONSE header * * @param header - The X-PAYMENT-RESPONSE header to decode * @returns The decoded payment response */ declare function decodeXPaymentResponse(header: string): { success: boolean; transaction: Hex; network: Network; payer: Address; }; /** * Check token compatibility with EIP-2612 and EIP-3009 * * Results are cached for 1 hour to avoid repeated API calls * * @param network - The x402 network identifier * @param tokenAddress - The token contract address * @returns Token compatibility information */ declare function checkTokenCompatibility(network: Network, tokenAddress: string): Promise<{ supportsEip2612: boolean; supportsEip3009: boolean; error?: string; }>; /** * Validate if a token supports the required signature type * * @param network - The x402 network identifier * @param tokenAddress - The token contract address * @param requiredType - Required signature type (if undefined, checks if token supports ANY gasless method) * @returns Validation result */ declare function validateTokenCompatibility(network: Network, tokenAddress: string, requiredType?: "authorization" | "permit"): Promise<{ isCompatible: boolean; reason?: string; }>; /** * Clear the compatibility cache * Useful for testing or force-refresh scenarios */ declare function clearCompatibilityCache(): void; /** * Get cache statistics * Useful for monitoring and debugging * * @returns Object containing cache size and entry details */ declare function getCacheStats(): { size: number; entries: Array<{ key: string; age: number; }>; }; /** * Given an object with a base64 encoded transaction, decode the * base64 encoded transaction into a solana transaction object. * * @param svmPayload - The SVM payload to decode * @returns The decoded transaction */ declare function decodeTransactionFromPayload(svmPayload: ExactSvmPayload): Transaction; /** * Extract the token sender (owner of the source token account) * from the TransferChecked instruction. * * @param transaction - The transaction to extract the token payer from * @returns The token payer address as a base58 string */ declare function getTokenPayerFromTransaction(transaction: Transaction): string; /** * Sign and simulate a transaction. * * @param signer - The signer that will sign the transaction * @param transaction - The transaction to sign and simulate * @param rpc - The RPC client to use to simulate the transaction * @returns The transaction simulation result */ declare function signAndSimulateTransaction(signer: TransactionSigner, transaction: Transaction, rpc: RpcDevnet | RpcMainnet): Promise; value: Readonly<{ readonly accounts: null; }> & Readonly<{ err: _solana_kit.TransactionError | null; logs: string[] | null; returnData: Readonly<{ data: _solana_kit.Base64EncodedDataResponse; programId: _solana_kit.Address; }> | null; unitsConsumed?: bigint; }>; }>>; /** * Signs a transaction using the provided {@link TransactionSigner}. * * Prefers modifying signers (wallets that can rewrite the transaction) and falls * back to partial signers that only append signatures. * * @param signer - Wallet or signer capable of producing transaction signatures * @param transaction - Compiled transaction to sign * @returns The transaction including any signatures added by the signer */ declare function signTransactionWithSigner(signer: TransactionSigner, transaction: Transaction): Promise; declare const index_KeyPairSigner: typeof KeyPairSigner; declare const index_SvmConnectedClient: typeof SvmConnectedClient; declare const index_SvmSigner: typeof SvmSigner; declare const index_createDevnetRpcClient: typeof createDevnetRpcClient; declare const index_createMainnetRpcClient: typeof createMainnetRpcClient; declare const index_createSignerFromBase58: typeof createSignerFromBase58; declare const index_createSvmConnectedClient: typeof createSvmConnectedClient; declare const index_decodeTransactionFromPayload: typeof decodeTransactionFromPayload; declare const index_getRpcClient: typeof getRpcClient; declare const index_getRpcSubscriptions: typeof getRpcSubscriptions; declare const index_getTokenPayerFromTransaction: typeof getTokenPayerFromTransaction; declare const index_isSignerWallet: typeof isSignerWallet; declare const index_signAndSimulateTransaction: typeof signAndSimulateTransaction; declare const index_signTransactionWithSigner: typeof signTransactionWithSigner; declare namespace index { export { index_KeyPairSigner as KeyPairSigner, index_SvmConnectedClient as SvmConnectedClient, index_SvmSigner as SvmSigner, index_createDevnetRpcClient as createDevnetRpcClient, index_createMainnetRpcClient as createMainnetRpcClient, index_createSignerFromBase58 as createSignerFromBase58, index_createSvmConnectedClient as createSvmConnectedClient, index_decodeTransactionFromPayload as decodeTransactionFromPayload, index_getRpcClient as getRpcClient, index_getRpcSubscriptions as getRpcSubscriptions, index_getTokenPayerFromTransaction as getTokenPayerFromTransaction, index_isSignerWallet as isSignerWallet, index_signAndSimulateTransaction as signAndSimulateTransaction, index_signTransactionWithSigner as signTransactionWithSigner }; } export { Base64EncodedRegex, checkTokenCompatibility, clearCompatibilityCache, computeRoutePatterns, decodeXPaymentResponse, findMatchingPaymentRequirements, findMatchingRoute, getCacheStats, getDefaultAsset, getNetworkId, processPriceToAtomicAmount, safeBase64Decode, safeBase64Encode, index as svm, toJsonSafe, validateTokenCompatibility };