/** * X402 crypto-payment primitives shared by Nexior and PlatformFrontend. * * SCOPE IS DELIBERATELY NARROW. This module contains ONLY the pure, * deterministic, byte-identical helpers + constants that both apps had * duplicated — no `@solana/web3.js`, no wallet adapters, no Vue, no network. * The money path itself (transaction building, wallet signing, * `signAndSendTransaction`, WalletConnect, EVM typed-data signing, lazy * module loading) stays in each app because it genuinely diverges and is too * coupled to wallet-adapter instances to share safely. * * Everything here is covered by exact-output unit tests so an app adopting it * is provably getting the same bytes/strings it produced before. */ /** Public Solana RPC endpoints (used as fallbacks when no custom RPC is given). */ export declare const SOLANA_MAINNET_RPC = "https://api.mainnet-beta.solana.com"; export declare const SOLANA_DEVNET_RPC = "https://api.devnet.solana.com"; /** SPL Token program addresses (raw base58 strings; callers construct PublicKey). */ export declare const TOKEN_PROGRAM_ID_ADDRESS = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; export declare const ASSOCIATED_TOKEN_PROGRAM_ID_ADDRESS = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"; /** * Convert a Uint8Array to a base64 string (browser-native, no Node Buffer). */ export declare function uint8ArrayToBase64(bytes: Uint8Array): string; /** * Resolve the Solana RPC URL for a network: an explicit custom URL wins, * otherwise devnet for any network whose name contains "devnet", else mainnet. */ export declare function resolveRpcUrl(network: string, customRpcUrl?: string): string; /** * Build the 10-byte SPL Token `TransferChecked` instruction data: * `[discriminator=12][amount: u64 LE][decimals: u8]`. */ export declare function createTransferCheckedData(amount: bigint, decimals: number): Uint8Array; /** * Format a raw token amount (integer base units) as a human string, capping * the displayed fraction digits at 6. */ export declare function formatTokenAmount(raw: bigint, decimals: number): string; /** Format integer base units exactly and remove insignificant trailing zeroes. */ export declare function formatAtomicTokenAmount(raw: bigint, decimals: number): string; /** Resolve a transaction URL only for explicitly supported CAIP-2 networks. */ export declare function getX402TransactionExplorerUrl(network: string, transaction: string): string | undefined; export declare const X402_PAYMENT_ERROR_CODES: readonly ["payer_token_account_missing", "insufficient_token_balance", "authorization_expired", "wallet_rejected", "network_mismatch", "invalid_signature", "payment_requirements_unavailable", "facilitator_unavailable", "settlement_pending", "settlement_failed", "payment_failed"]; export type X402PaymentErrorCode = (typeof X402_PAYMENT_ERROR_CODES)[number]; export type X402ErrorContext = 'order' | 'request'; export interface CanonicalX402PaymentError { code: X402PaymentErrorCode; params: Record; stage?: 'sign' | 'verify' | 'settle'; retryable: boolean; charged?: boolean; } export interface X402ErrorPresentation extends CanonicalX402PaymentError { title: string; description: string; safety?: string; nextStep: string; technicalCode: string; severity: 'error' | 'warning'; } type Translate = (key: string, params?: Record) => unknown; export declare function extractX402PaymentError(source: unknown): CanonicalX402PaymentError; export declare function resolveX402PaymentError(source: unknown, translate: Translate, context?: X402ErrorContext): X402ErrorPresentation; export declare function isX402Challenge(error: unknown): boolean; export {}; //# sourceMappingURL=index.d.ts.map