import { Address, ContractFunctionParameters, Hex } from 'viem'; import { AuthenticationResponseJSON, PublicKeyCredentialRequestOptionsJSON, } from '@simplewebauthn/typescript-types'; import { CreateWalletResult, LinkTransferHistoryItem, PagingOptions, SwapHistoryItem, TransferHistoryItem, TransferByLinkResponse, DistributeRequest, GetLinkTransferResponse, TokenDistributeRequestEntity, SharedWalletList, TransferHistoryQuery, TokenHolder, TokenActivity, PumToken, PumActionHistory, PumTokenPrice, SubKeyMessage, } from '../types'; import { DutchOrder, FeeTier, SwapOrder } from '@prex0/prex-structs'; import { TransferOptions } from '../actions/transfer'; import { PrexSigner } from '../core/sign'; import { PublicActions } from 'viem'; export type FacilitatorConfig = { feeTiers: FeeTier[]; maxFeePerGas: string; maxPriorityFeePerGas: string; }; export interface PrexClientInterface { balances: Record; allowances: Record; getSigner(): PrexSigner | null; getPublicClient(): PublicActions | null; startHandler(): Promise; load(): Promise; getLinkTransfer(id: string): Promise; getLinkTransferBySecret( secret: string ): Promise; getUser(): any; fetchBalance( token: Address, owner?: Address ): Promise<{ balance: bigint | undefined; allowance: bigint | undefined }>; fetchBalanceBatch( tokens: Address[], user?: Address ): Promise<{ token: Address; balance: bigint | undefined; isSuccess: boolean }[]>; transfer( params: { token: Address; recipient: Address; amount: bigint; metadata?: Record; sender?: Address; }, options?: TransferOptions ): Promise<{ hash: Hex }>; transferByLink(params: { token: Address; amount: bigint; expiration: number; metadata?: Record; sender?: Address; }): Promise; receiveLinkTransfer(params: { secret: Hex; recipient?: Address; }): Promise<{ hash: Hex }>; getHistory( query?: TransferHistoryQuery, pagingOptions?: PagingOptions ): Promise; getOnetimeLockHistory( query?: | { user: Address; } | { token: Address; }, pagingOptions?: PagingOptions ): Promise; getTokenHolders( query: { token: Address }, pagingOptions?: PagingOptions ): Promise; getTokenHolder(query: { token: Address; address?: Address; }): Promise; getSwapHistory( query?: { user: Address }, pagingOptions?: PagingOptions ): Promise; mint(options: { token?: Address; recipient: Address; amount: bigint; }): Promise; quoteSwap(params: { tokenIn: Address; tokenOut: Address; amount: bigint; tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT'; swapper?: Address; recipient?: Address; slippageTolerance?: bigint; }): Promise<{ quote: bigint; route: Hex; order: DutchOrder; }>; swap(order: any, route: Hex): Promise<{ hash: Hex }>; distribute(): DistributeActionInterface; getProfileAction(): ProfileActionInterface; approve(params: { token: Address; amount?: bigint; from?: Address; }): Promise; backupByEOA(backupAddress: Address): Promise; backupByPasskey(ownerIndex?: number): Promise; registerNewPasskey(): Promise; recoverByEOA(backupPrivateKey: Hex): Promise; createWallet(options?: { userName?: string; withDeploy?: boolean; }): Promise; restoreWallet(): Promise; deployWallet(): Promise; updateNickName({ nickName, from, }: { nickName: string; from?: Address; }): Promise; uploadAvatar({ image, from }: { image: File; from?: Address }): Promise<{ path: string; fullPath: string; url: string; }>; logout(): Promise; authenticate( options: PublicKeyCredentialRequestOptionsJSON ): Promise; executeOperation( contracts: ContractFunctionParameters, from?: Address ): Promise<{ hash: `0x${string}`; }>; switchChain(chainId: number): Promise; getChainId(): Promise; setApiKey(apiKey: string): void; setProvider(provider: any): void; isPasskeyAvailable(): Promise; getTokenDetails( token: Address ): Promise<{ name: string; symbol: string; decimals: number }>; getTokenActivity(token: Address): Promise; getSharedWalletAddress(owners: Address[], nonce: number): Promise
; createSharedWallet({ name, owners, nonce, }: { name: string; owners: Address[]; nonce: number; }): Promise
; addOwnerAddress({ owner, from, }: { owner: Address; from?: Address; }): Promise; removeOwnerAtIndex({ index, owner, from, }: { index: number; owner: Address; from?: Address; }): Promise; getSharedWallets(): Promise; loadConfig(chainId: number): Promise; getProfile(address: Address): Promise<{ name?: string }>; getAddressByName({ baseName, name, }: { baseName?: string; name: string; }): Promise
; getPumAction(): PumpumActionInterface; signWithSubKey(params: { hash: Hex; from?: Address }): Promise<{ signature: Hex; message: SubKeyMessage; keyType: 'main' | 'sub'; }>; existsSubKey(): Promise; deleteSubKey(): Promise; } export interface ProfileActionInterface { updateProfile({ domain, name, avatar, metadata, from, }: { domain?: number; name: string; avatar: File; metadata: Hex; from?: Address; }): Promise; updateName({ domain, name, from, }: { domain?: number; name: string; from?: Address; }): Promise; updateAvatar({ avatar, from, }: { avatar: File; from?: Address; }): Promise; getProfile( address: Address ): Promise<{ domain: bigint; name: string; pictureHash: Hex; metadata: Hex }>; uploadAvatar({ image, from }: { image: File; from?: Address }): Promise<{ path: string; fullPath: string; url: string; }>; copyAvatar({ pictureUrl, from, }: { pictureUrl: string; from?: Address; }): Promise<{ path: string; fullPath: string; url: string; }>; } export interface DistributeActionInterface { submit(params: { token: Address; amount: bigint; amountPerWithdrawal: bigint; maxAmountPerAddress?: bigint; expiry: bigint; coolTime?: bigint; name: string; coordinate?: Hex; sender?: Address; registerPath?: string; }): Promise<{ id: string; secret: string; shortCode: string }>; generateSubSecret(id: Hex): Promise<{ id: string; secret: string }>; deposit(params: { amount: bigint; requestId: Hex; sender?: Address; }): Promise; cancel(params: { requestId: Hex; from?: Address }): Promise; prepareSecret(params: { path: string; auth?: string; requestId: Hex; shortCode: string; recipient?: Address; }): Promise<{ secret: string; }>; prepareReceive(params: { requestId: Hex; secret: string; recipient?: Address; }): Promise; receive(params: { requestId: Hex }): Promise; queryRequests( query?: { user: Address }, pagingOptions?: PagingOptions ): Promise; getRequest( id: Hex, { secret, coordinate, }: { secret?: Hex; coordinate?: Hex; } ): Promise; } export interface QuoteSwapParams { tokenIn: Address; tokenOut: Address; amount: bigint; tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT'; swapper: Address; recipient: Address; slippageTolerance?: bigint; } export interface PumpumActionInterface { quoteSwap(quoteParams: QuoteSwapParams): Promise; executeSwap(order: SwapOrder): Promise<{ hash: Hex; }>; issueTokens(params: { name: string; symbol: string; amount: bigint; metadata?: string; }): Promise<{ hash: Hex; result: Address; }>; buy(params: { dai: Address; amount: bigint }): Promise; getPumTokens(): Promise; getPumTimeline(pageOptions: PagingOptions): Promise; getPumActionHistory( user: Address, pageOptions: PagingOptions ): Promise; getPumTokenPrice( token: Address, interval: 'HOUR' | 'DAY', pageOptions: PagingOptions ): Promise; getMarketInfo(communityToken: Address): Promise<{ reserveCT: bigint; reserveStable: bigint; sellable: boolean; feePercent: bigint; }>; }