import type { WalletConnectParameters } from '../wagmi/connectors'; import type { Connector, CreateConnectorFn } from '../wagmi/hooks'; import type { RelayVmType, RelayWallet } from '@funkit/fun-relay'; import type { TransactionReceipt, TypedDataDomain } from 'viem'; import type { CoinbaseWalletOptions } from './walletConnectors/coinbaseWallet/coinbaseWallet'; import type { WalletConnectWalletOptions } from './walletConnectors/walletConnectWallet/walletConnectWallet'; export { isSolanaWithdrawalClient, type SolanaWithdrawalClient, } from '@funkit/connect-core/clients/solana'; export type InstructionStepName = 'install' | 'create' | 'scan' | 'connect' | 'refresh'; type FunkitSdkConnector = { mobile?: { getUri?: (uri: string) => string; }; desktop?: { getUri?: (uri: string) => string; instructions?: { learnMoreUrl: string; steps: { step: InstructionStepName; title: string; description: string; }[]; }; }; qrCode?: { getUri: (uri: string) => string; instructions?: { learnMoreUrl: string; steps: { step: InstructionStepName; title: string; description: string; }[]; }; }; extension?: { instructions?: { learnMoreUrl: string; steps: { step: InstructionStepName; title: string; description: string; }[]; }; }; }; export type Wallet = { id: string; name: string; rdns?: string; shortName?: string; iconUrl: string | (() => Promise); iconAccent?: string; iconBackground: string; installed?: boolean; isCustomWallet?: boolean; downloadUrls?: { android?: string; ios?: string; mobile?: string; qrCode?: string; chrome?: string; edge?: string; firefox?: string; opera?: string; safari?: string; browserExtension?: string; macos?: string; windows?: string; linux?: string; desktop?: string; }; hidden?: () => boolean; createConnector: (walletDetails: WalletDetailsParams) => CreateConnectorFn; } & FunkitSdkConnector; export interface DefaultWalletOptions { projectId: string; walletConnectParameters?: FunkitConnectWalletConnectParameters; } export type CreateWalletFn = (createWalletParams: CoinbaseWalletOptions & Omit & DefaultWalletOptions) => Wallet; type WalletListEntry = { groupName: string; wallets: CreateWalletFn[]; }; export type WalletList = [WalletListEntry, ...WalletListEntry[]]; export type FunkitConnectWalletConnectParameters = Omit; export type FunkitConnectDetails = Omit & { index: number; groupIndex: number; groupName: string; isWalletConnectModalConnector?: boolean; isFunkitSdkConnector: boolean; walletConnectModalConnector?: Connector; showQrModal?: true; }; export type WalletDetailsParams = { fkcDetails: FunkitConnectDetails; }; export type CreateConnector = (walletDetails: { fkcDetails: FunkitConnectDetails; }) => CreateConnectorFn; export type WagmiConnectorInstance = Connector & { fkcDetails?: FunkitConnectDetails; }; export type WalletInstance = Connector & FunkitConnectDetails; export type WithdrawalTransaction = { to: string; data: string; value: string; }; /** * Withdrawal context sent with the batch so the integrator can check what it * signs. `targetChainId` is Fun's chain id: Solana and Tron destinations use * Fun's own ids and their native address formats, so a host check must not * assume an EVM chain id or run `isAddress` on every destination. */ export type WithdrawalSignContext = { /** The format follows `targetChainId`: 0x hex for EVM, native for Solana and Tron. */ destinationAddress: string; targetChainId: number; }; /** EIP-712 payload passed to {@link WithdrawalClient.signTypedData}. */ export type WithdrawalTypedData = { domain: TypedDataDomain; types: Record; primaryType: string; message: Record; }; /** EVM is excluded: those sources still need the chain switch and allowance * reset that direct execution skips for a pre-built wallet. */ export type NonEvmRelayWallet = RelayWallet>; export interface WithdrawalClient { adaptedWallet?: NonEvmRelayWallet; getChainId: () => Promise; switchChain: (chainId: number) => Promise; sendTransaction: (chainId: number, transaction: WithdrawalTransaction) => Promise; /** * Optional batched submitter. When provided, the SDK collapses approve + * swap/deposit steps into a single user signature via this method (e.g. * EIP-5792 `wallet_sendCalls` with `forceAtomic`). * * Must return a tx hash that {@link confirmTransaction} can wait on. * Implementations using `wallet_sendCalls` should map the calls-id back to * the underlying tx hash via `waitForCallsStatus` → * `receipts[0].transactionHash`. * * `signContext` is sent with batched sends only. Gasless and * single-transaction steps (`sendTransaction`, `signTypedData`, * `signMessage`) omit it. */ sendTransactions?: (chainId: number, transactions: WithdrawalTransaction[], signContext?: WithdrawalSignContext) => Promise; confirmTransaction: (txHash: string, chainId: number) => Promise; address: () => string; /** * Optional signers for gasless relay routes (permit / EIP-3009), where Relay * returns a signature step instead of a transaction. Implemented by * connected-wallet clients (see `clients/mallard.tsx`). */ signTypedData?: (typedData: WithdrawalTypedData) => Promise; /** 32-byte hashes arrive as `{ raw }` — sign as raw bytes. */ signMessage?: (message: string | { raw: string; }) => Promise; } /** * WithdrawalClient variant for Lighter (LVM). Satisfies WithdrawalClient for * address lookup and display, but also carries the relay-sdk AdaptedWallet so * startRelayDirectExecution can execute the LVM steps directly instead of * wrapping in an EVM shim. */ export interface LighterWithdrawalClient extends WithdrawalClient { readonly _type: 'lighter'; readonly adaptedWallet: import('@funkit/fun-relay').LighterWallet; } export interface HypercoreWithdrawalClient extends WithdrawalClient { readonly _type: 'hypercore'; readonly adaptedWallet: import('@funkit/fun-relay').HypercoreWallet; } export declare function isHypercoreWithdrawalClient(client: WithdrawalClient): client is HypercoreWithdrawalClient; export declare function isLighterWithdrawalClient(client: WithdrawalClient): client is LighterWithdrawalClient;