import { PaymentMaker, Logger, Currency, AccountId, Destination, PaymentIdentifier, JsonCache, Account as Account$1, ICache, Source, AuthorizeParams, AuthorizeResult } from '@atxp/common'; export { ATXPAccount, BrowserCache, ICache, MemoryCache } from '@atxp/common'; import BigNumber from 'bignumber.js'; import { Address, Account } from 'viem'; import { BundlerClient, SmartAccount } from 'viem/account-abstraction'; import { Hex } from '@atxp/client'; import { MiniKit } from '@worldcoin/minikit-js'; type MainWalletProvider = { request: (params: { method: string; params?: unknown[]; }) => Promise; }; declare class MainWalletPaymentMaker implements PaymentMaker { private walletAddress; private provider; private logger; private chainId; private customRpcUrl?; constructor(walletAddress: string, provider: MainWalletProvider, logger?: Logger, chainId?: number, customRpcUrl?: string); getSourceAddress(_params: { amount: BigNumber; currency: Currency; receiver: string; memo: string; }): string; generateJWT({ paymentRequestId, codeChallenge, accountId }: { paymentRequestId: string; codeChallenge: string; accountId?: AccountId | null; }): Promise; makePayment(destinations: Destination[], memo: string, _paymentRequestId?: string): Promise; } /** * Represents a spending permission with limits */ type SpendPermission = { /** UTC timestamp for when the permission was granted */ createdAt?: number; /** Hash of the permission in hex format */ permissionHash?: string; /** Cryptographic signature in hex format */ signature: string; /** Chain ID */ chainId?: number; /** The permission details */ permission: { /** Wallet address of the account */ account: string; /** Address of the contract/entity allowed to spend */ spender: string; /** Address of the token being spent */ token: string; /** Maximum amount allowed as base 10 numeric string */ allowance: string; /** Time period in seconds */ period: number; /** Start time in unix seconds */ start: number; /** Expiration time in unix seconds */ end: number; /** Salt as base 10 numeric string */ salt: string; /** Additional data in hex format */ extraData: string; }; }; type Eip1193Provider = { request: (params: { method: string; params?: unknown[]; }) => Promise; }; /** * Stored permission data structure */ interface Intermediary { /** Ephemeral wallet private key */ privateKey: Hex; /** Spend permission from World Chain */ permission: SpendPermission; } /** * Type-safe cache wrapper for permission data */ declare class IntermediaryCache extends JsonCache { } interface EphemeralSmartWallet { address: Address; client: BundlerClient; account: SmartAccount; signer: Account; } declare class WorldchainAccount implements Account$1 { readonly usesAccountsAuthorize = false; private _accountId; paymentMakers: PaymentMaker[]; private mainWalletAddress?; private ephemeralSmartWallet?; private chainId; private static toCacheKey; static initialize(config: { walletAddress: string; provider: Eip1193Provider; useEphemeralWallet?: boolean; allowance?: bigint; periodInDays?: number; cache?: ICache; logger?: Logger; chainId?: number; customRpcUrl?: string; }): Promise; private static loadSavedWalletAndPermission; private static deploySmartWallet; constructor(spendPermission: SpendPermission | null, ephemeralSmartWallet: EphemeralSmartWallet | null, logger?: Logger, mainWalletAddress?: string, provider?: MainWalletProvider, chainId?: number, customRpcUrl?: string); /** * Get the account ID */ getAccountId(): Promise; getSources(): Promise; static clearAllCachedData(userWalletAddress: string, cache?: ICache): void; /** * Create a spend permission for the given resource URL. * WorldchainAccount doesn't support spend permissions, so this returns null. */ createSpendPermission(_resourceUrl: string): Promise; /** * Authorize a payment through the appropriate channel for World Chain accounts. */ authorize(params: AuthorizeParams): Promise; } /** * Configuration for transaction confirmation delays */ interface ConfirmationDelays { /** Network propagation delay in milliseconds (must be >= 0) */ networkPropagationMs: number; /** Confirmation failed delay in milliseconds (must be >= 0) */ confirmationFailedMs: number; } /** * Options for configuring WorldchainPaymentMaker */ interface WorldchainPaymentMakerOptions { /** Logger instance for debug output */ logger?: Logger; /** Chain ID (defaults to World Chain Mainnet) */ chainId?: number; /** Custom RPC URL for the chain */ customRpcUrl?: string; /** Custom confirmation delays (defaults to production values) */ confirmationDelays?: ConfirmationDelays; } /** * Payment maker for World Chain transactions using smart wallets and spend permissions * * @example * ```typescript * // For production use (default delays) * const paymentMaker = new WorldchainPaymentMaker(permission, wallet); * * // For testing (fast delays) * const paymentMaker = new WorldchainPaymentMaker(permission, wallet, { * confirmationDelays: { networkPropagationMs: 10, confirmationFailedMs: 20 } * }); * * // With custom configuration * const paymentMaker = new WorldchainPaymentMaker(permission, wallet, { * chainId: 480, // World Chain Mainnet * customRpcUrl: 'https://my-rpc.com', * logger: myLogger * }); * ``` */ declare class WorldchainPaymentMaker implements PaymentMaker { private logger; private spendPermission; private smartWallet; private chainId; private customRpcUrl?; private confirmationDelays; /** * Creates a new WorldchainPaymentMaker instance * * @param spendPermission - The spend permission for transactions * @param smartWallet - The smart wallet instance to use * @param options - Optional configuration */ constructor(spendPermission: SpendPermission, smartWallet: EphemeralSmartWallet, options?: WorldchainPaymentMakerOptions); getSourceAddress(_params: { amount: BigNumber; currency: Currency; receiver: string; memo: string; }): string; generateJWT({ paymentRequestId, codeChallenge, accountId }: { paymentRequestId: string; codeChallenge: string; accountId?: AccountId | null; }): Promise; makePayment(destinations: Destination[], memo: string, _paymentRequestId?: string): Promise; } /** * Loads and initializes a Worldchain account with MiniKit integration * * This function creates a Worldchain account that can interact with the World Chain network * using MiniKit for transaction signing and wallet operations. It sets up a custom provider * that handles various Ethereum JSON-RPC methods through MiniKit's interface. * * @param walletAddress - The wallet address to use for the account * @param logger - Optional logger instance for debugging and monitoring * @param customRpcUrl - Optional custom RPC URL for Worldchain. If not provided, uses the public RPC endpoint * @param chainId - Optional chain ID (defaults to 480 for mainnet, can be 4801 for sepolia) * @param miniKit - The MiniKit instance to use for transactions and signing * @returns Promise that resolves to an initialized WorldchainAccount instance * * @example * ```typescript * // Using public RPC endpoint (mainnet) * const account = await createMiniKitWorldchainAccount({ * walletAddress: "0x1234...", * logger: new ConsoleLogger(), * miniKit: MiniKit * }); * * // Using sepolia testnet * const account = await createMiniKitWorldchainAccount({ * walletAddress: "0x1234...", * logger: new ConsoleLogger(), * chainId: 4801, * miniKit: MiniKit * }); * ``` * * @remarks * The function creates a custom provider that supports: * - `eth_accounts`: Returns the wallet address * - `eth_chainId`: Returns Worldchain chain ID (configurable) * - `eth_requestAccounts`: Returns the wallet address * - `eth_sendTransaction`: Handles USDC transfers and other transactions via MiniKit * - `personal_sign`: Signs messages using MiniKit * * The account is configured with: * - 10 USDC allowance * - 30-day period for permissions * - Worldchain RPC endpoint (public or custom) * - Regular wallet mode (no ephemeral wallet) * * @throws {Error} When MiniKit operations fail or unsupported transaction types are encountered */ declare const createMiniKitWorldchainAccount: ({ walletAddress, logger: loggerParam, customRpcUrl, chainId, miniKit }: { walletAddress: string; logger?: Logger; customRpcUrl?: string; chainId?: number; miniKit: typeof MiniKit; }) => Promise; export { MainWalletPaymentMaker, IntermediaryCache as PermissionCache, WorldchainAccount, WorldchainPaymentMaker, createMiniKitWorldchainAccount }; export type { Intermediary as CachedPermissionData, MainWalletProvider, SpendPermission };