UNPKG

@web3auth/no-modal

Version:
44 lines (43 loc) 2.34 kB
import { Wallet } from "@wallet-standard/base"; import { Address, type WalletClient } from "viem"; import { IProvider } from "../base/connector"; export * from "./interfaces"; export declare const EVM_CAIP2_WILDCARD = "eip155:*"; export declare const SOLANA_CAIP2_WILDCARD = "solana:*"; export declare function getEvmAddress(provider: IProvider): Promise<Address | null>; export declare function createProviderBackedEvmSigner(provider: IProvider, address: Address): WalletClient; /** * Wraps a fetch function so that 402 responses whose v2 payment requirements * arrive in the response body (instead of the PAYMENT-REQUIRED header) are * normalised: the body JSON is base64-encoded and promoted into the * PAYMENT-REQUIRED header so that the \@x402/fetch client library can process it. * * The \@x402/fetch library's body fallback only accepts x402Version === 1; * this shim bridges the gap for servers that send v2 data in the body. * * @param baseFetch - The underlying fetch implementation to wrap * @returns A fetch-compatible function with the shim applied */ export declare function withX402BodyShim(baseFetch: typeof fetch): typeof fetch; /** * Creates a payment-aware fetch function for a connected Solana wallet. * Registers the exact SVM payment scheme and applies the body-shim so that * servers returning v2 payment requirements in the response body are handled * transparently. * * @param wallet - Connected Solana wallet (must have an account) * @param walletAddress - The wallet's public key as a base58 address string * @param rpcUrl - Optional custom Solana RPC URL (defaults to public cluster endpoints) * @returns A fetch-compatible function that handles x402 payment flows */ export declare function createSolanaX402Fetch(wallet: Wallet, walletAddress: string, rpcUrl?: string): typeof fetch; /** * Creates a payment-aware fetch function for an EVM typed-data signer. * Registers the exact EVM payment scheme and applies the body-shim so that * servers returning v2 payment requirements in the response body are handled * transparently. * * @param signer - Minimal signer with an address and EIP-712 signTypedData implementation * @returns A fetch-compatible function that handles x402 payment flows */ export declare function createEvmX402Fetch(walletClient: WalletClient): typeof fetch;