import { SpokeChainKey, GetChainType, ChainType, ChainKey, EvmChainKey, XToken, GetWalletProviderType } from '@sodax/types'; export { IWalletProvider } from '@sodax/types'; import { X as XAccount, I as IXConnector, b as XConnection, d as XService, c as XConnector } from './XConnector-12q0OVe5.js'; export { a as IXService } from './XConnector-12q0OVe5.js'; import * as react from 'react'; import { ReactNode } from 'react'; import { S as SodaxWalletConfig, C as ChainEntry, W as WalletDefaultsByKey, e as EvmChainEntry } from './config-DfVq3n0Q.js'; export { B as BitcoinChainEntry, a as BitcoinTypeConfig, b as ChainMeta, c as ChainTypeConfig, d as ChainTypeOf, E as EvmAdapterFields, f as EvmTypeConfig, I as IconChainEntry, g as IconTypeConfig, h as InjectiveChainEntry, i as InjectiveTypeConfig, N as NearChainEntry, j as NearTypeConfig, k as SolanaAdapterFields, l as SolanaChainEntry, m as SolanaTypeConfig, n as StacksChainEntry, o as StacksTypeConfig, p as StellarChainEntry, q as StellarTypeConfig, r as SuiAdapterFields, s as SuiChainEntry, t as SuiTypeConfig } from './config-DfVq3n0Q.js'; import { UseMutationResult } from '@tanstack/react-query'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { EvmWalletDefaults } from '@sodax/wallet-sdk-core'; import 'wagmi'; import 'wagmi/connectors'; /** * `GetChainType` only accepts `SpokeChainKey | ChainType` — it cannot be given `undefined`. * When the generic may include `undefined`, narrow with `Exclude` and only union `undefined` on the result. */ type GetXChainReturnType = K extends SpokeChainKey ? GetChainType : K extends undefined ? undefined : ChainType | undefined; declare function getXChainType(xChainId: K | undefined): GetXChainReturnType; type ChainActions = { connect: (xConnectorId: string) => Promise; disconnect: () => Promise; getConnectors: () => IXConnector[]; getConnection: () => XConnection | undefined; signMessage?: (message: string) => Promise; }; type ChainActionsRegistry = Partial>; declare function getXService(xChainType: ChainType): XService; declare const WalletConfigProvider: react.Provider; declare function useWalletConfig(): SodaxWalletConfig; /** A chain type is "enabled" only when its slot is present in SodaxWalletConfig. */ declare function useIsChainEnabled(chainType: ChainType): boolean; /** See {@link useIsChainEnabled} for the "enabled" semantic. */ declare function useEnabledChainTypes(): ChainType[]; type SortConnectorsOptions = { /** Connector IDs to prioritize. Earlier entries win. */ preferred?: readonly string[]; }; /** * Stable sort of connectors for display. Ranking (highest first): * 1. Appears in `preferred[]` — earlier entries rank higher * 2. `connector.isInstalled === true` * 3. Original order (stable) * * Pure function — does not subscribe or read window. */ declare function sortConnectors(connectors: readonly T[], options?: SortConnectorsOptions): T[]; /** * Extract `defaults` from a chain entry. Returns undefined when the entry is * missing, or for Stacks's preset-name string variant (no `defaults` slot). */ declare function getEntryDefaults(entry: ChainEntry | undefined): WalletDefaultsByKey | undefined; /** * Extract `rpcUrl` from a chain entry. Use for chains whose underlying factory * expects a bare URL string (EVM/Solana/Sui/Icon/Near). Returns undefined for * missing entries and for non-rpcUrl forms (Stacks preset name, object entries * lacking the field) — downstream falls back to a public default. */ declare function getRpcUrl(entry: ChainEntry | undefined): string | undefined; /** * Resolve EVM wallet provider defaults for the chain currently active on a * wagmi-supplied client. Used by `EvmHydrator` so the provider re-instantiates * with the right defaults when wagmi swaps clients on chain switch. * * `getEvmChainKeyByChainId` lives in `@sodax/types` (alongside `baseChainInfo`, * the data source); this helper composes it with the `SodaxWalletConfig.EVM.chains` * lookup, which is React-layer concern. */ declare function resolveEvmDefaults(activeChainId: number | undefined, evmChains: Partial> | undefined): EvmWalletDefaults | undefined; declare const isNativeToken: (xToken: XToken) => boolean; declare const getWagmiChainId: (xChainId: SpokeChainKey) => number; type UseXAccountOptions = { xChainId: SpokeChainKey; xChainType?: never; } | { xChainType: ChainType; xChainId?: never; }; /** * Returns the connected `XAccount` for a chain family. * * Pass either `xChainId` (a `SpokeChainKey` — auto-resolved to its family) or * `xChainType` (a `ChainType` directly), never both. EVM is family-level — wagmi * maintains a single connection across every configured EVM network. * * Always returns a populated object, never `undefined`. When no wallet is connected, * `address` is `undefined` but `xChainType` is filled — consumers can render * `account.address ?? ` without null-checking the wrapper. * * @see {@link https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECT_FLOW.md#read-connected-account-state | Connect Flow — Read state} */ declare function useXAccount({ xChainId, xChainType }: UseXAccountOptions): XAccount; /** * Returns connected accounts for every enabled chain type, keyed by `ChainType`. * * Each entry is always populated — disconnected chains have `address: undefined`, * mirroring `useXAccount`'s shape. Iterates `enabledChains` so the result reflects * exactly the slots present in `SodaxWalletProvider` config. * * Useful for "manage connections" panels and multi-chain status badges. For an * enriched view with connector metadata (name, icon), use `useConnectedChains` — * which also exposes a hydration `status` flag to gate first-paint UI. * * @see {@link https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECT_FLOW.md#read-connected-account-state | Connect Flow — Read state} */ declare function useXAccounts(): Partial>; /** * React Query mutation that connects a wallet via the supplied `IXConnector`. * * Pass an `IXConnector` (from `useXConnectors` / `useXConnectorsByChain`) to * `mutate` / `mutateAsync`. The hook delegates to the chain's `ChainActions.connect()` * and writes the resulting connection state into the store on success. * * **Provider-managed chains caveat** (EVM/Solana/Sui): the mutation resolves with * `undefined` because connection state is set reactively by the chain's Hydrator * after the native SDK reports `connected`. Read the resolved account via * `useXAccount` / `useXConnection`, not the mutation's return value. * * **Non-provider chains** (Bitcoin, ICON, Injective, Stellar, NEAR, Stacks) return * the resolved `XAccount` directly. Code defensively if your component supports * both — `useXAccount` works for both cases. * * Throws `Error('Chain "" is not enabled or ChainActions not registered')` when * the connector's chain type isn't mounted in `SodaxWalletProvider` config. * * @see {@link https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECT_FLOW.md#connect-a-wallet | Connect Flow — Connect} */ declare function useXConnect(): UseMutationResult; type UseXConnectionOptions = { xChainType?: ChainType; }; /** * Returns the active `XConnection` for a chain type — `{ xAccount, xConnectorId }` — * or `undefined` when no wallet is connected. * * Use this when you need the connector identity (e.g. to label a disconnect button * with the wallet name or icon). For just the address, prefer `useXAccount`, which * always returns a populated object and saves a null check. * * Returns `undefined` when `xChainType` is omitted — the field is optional to * accommodate consumers that branch on chain availability. */ declare function useXConnection({ xChainType }?: UseXConnectionOptions): XConnection | undefined; /** * Returns active wallet connections keyed by `ChainType`. * * Only chains with a connected wallet have entries — disconnected chains are absent * from the map (unlike `useXAccounts`, which always populates every enabled chain). * * The returned object reference is the persisted `xConnections` slice — stable * across re-renders that don't change connection state. Mutate via `useXConnect` / * `useXDisconnect`, never directly. */ declare function useXConnections(): Partial>; type UseXConnectorsOptions = { xChainType?: ChainType; }; /** * Returns available wallet connectors for a specific chain type, with enriched * metadata (`isInstalled`, `installUrl`, `icon`). * * Each `connector.isInstalled` reads `window.*` at access time — no extra subscription * is installed. Components receive fresh values through normal React render triggers * (store updates, parent re-renders). * * Returns `[]` when the chain isn't enabled in `SodaxWalletProvider` config and logs a * one-time warning per chain to help debug missing connector lists. For multi-chain * pickers, prefer `useXConnectorsByChain` which avoids the warning per chain. * * Pair with `sortConnectors(connectors, { preferred })` to rank installed/preferred wallets * first. `preferred` matches by exact `connector.id` — for substring/case-insensitive matching, * use `useIsWalletInstalled`. * * @see {@link https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECT_FLOW.md#discover-connectors | Connect Flow — Discover} */ declare function useXConnectors({ xChainType }?: UseXConnectorsOptions): IXConnector[]; /** * Returns the connector list for every enabled chain type, grouped by `ChainType`. * * Used for multi-chain wallet pickers (e.g. listing every available wallet across * EVM, Solana, Bitcoin in one render). For a single chain, prefer `useXConnectors` * which also emits a one-time warning if the chain isn't enabled. * * Each connector's `isInstalled` reads `window.*` at access time — values stay * fresh through normal React render triggers. */ declare function useXConnectorsByChain(): Partial>; /** * Either `connectors`, `chainType`, or both. The union prevents an empty * `{}` at the type level — the hook must narrow at least one axis so the * return value has a meaningful interpretation (not "is any wallet installed * anywhere", which is rarely the intent). */ type UseIsWalletInstalledOptions = { /** * Wallet brand identifiers (e.g. `'hana'`, `'phantom'`). Matched via * case-insensitive substring against `connector.id` and `connector.name` — * see {@link matchesConnectorIdentifier}. Returns `true` if ANY identifier * matches an installed connector. Mirrors the `connectors` parameter of * `useBatchConnect` / `useBatchDisconnect`. */ connectors: readonly string[]; chainType?: ChainType; } | { connectors?: readonly string[]; /** Restrict the scan to a single chain. */ chainType: ChainType; }; /** * True when at least one connector across the configured chains is installed * AND matches the supplied filters. `connectors` and `chainType` AND together; * at least one of them must be supplied (enforced at the type level). * * @example * // Single wallet across every chain * const isHanaInstalled = useIsWalletInstalled({ connectors: ['hana'] }); * * @example * // Any of these wallets * const hasMultiChainWallet = useIsWalletInstalled({ connectors: ['hana', 'okx', 'phantom'] }); * * @example * // Any wallet on a specific chain * const hasBitcoin = useIsWalletInstalled({ chainType: 'BITCOIN' }); * * @example * // AND — Hana specifically on EVM * const hanaOnEvm = useIsWalletInstalled({ connectors: ['hana'], chainType: 'EVM' }); */ declare function useIsWalletInstalled(options: UseIsWalletInstalledOptions): boolean; type ChainGroup = { chainType: ChainType; /** All SpokeChainKeys that share this ChainType — e.g. every EVM network for `chainType: 'EVM'`. */ chainIds: readonly SpokeChainKey[]; displayName: string; /** Icon URL from chainRegistry. `undefined` when SDK doesn't ship a default — consumer provides. */ iconUrl: string | undefined; isConnected: boolean; account: XAccount | undefined; connectorId: string | undefined; }; type UseChainGroupsOptions = { /** * Display order by `chainType`. Chains not listed fall to the bottom, * sorted alphabetically among themselves. Omit to follow the insertion * order of `enabledChains` (driven by `SodaxWalletProvider` config). */ order?: readonly ChainType[]; }; /** * Returns one `ChainGroup` per enabled chain type. EVM collapses to a single * group covering every EVM network via `chainIds`. Use for rendering modal * chain-pickers. * * @example * const groups = useChainGroups(); * return groups.map(g => ( * * )); * * @example * // Deterministic display order — useful when the chain picker must render * // hub-first regardless of enabledChains insertion order. * const groups = useChainGroups({ order: ['EVM', 'ICON', 'SOLANA'] }); */ declare function useChainGroups({ order }?: UseChainGroupsOptions): ChainGroup[]; type ConnectedChain = { chainType: ChainType; account: XAccount; connectorId: string; connectorName: string | undefined; connectorIcon: string | undefined; }; type UseConnectedChainsResult = { /** One entry per chain currently holding a connected account. */ chains: ConnectedChain[]; /** Number of connected chains. */ total: number; /** * `'loading'` until the store rehydrates from localStorage. Gate UI that * switches visibly on connection state (e.g. `total >= 1 ? Connected : Cta`) * with this flag to avoid flicker on reload. */ status: 'loading' | 'ready'; }; type UseConnectedChainsOptions = { /** * Display order by `chainType`. Chains not listed fall to the bottom, * sorted alphabetically among themselves. Omit to use the default * `ChainTypeArr` order from `@sodax/types` (stable across page reloads). */ order?: readonly ChainType[]; }; /** * Aggregate view of every currently-connected chain with enriched connector * metadata (name + icon) looked up from the store. Useful for "Manage * connections" UIs and status badges. * * Gate rendering on `status === 'ready'` to avoid the "Connect wallet" to * "Connected" flicker on reload while the store rehydrates from localStorage. * * @example * const { chains, total, status } = useConnectedChains(); * if (status === 'loading') return ; * return total >= 1 ? : ; * * @example * // Deterministic display order, required if rendering a list that must * // be stable across page reloads (hydrator race otherwise randomizes * // insertion order). * const { chains } = useConnectedChains({ order: ['EVM', 'ICON', 'SOLANA'] }); */ declare function useConnectedChains({ order }?: UseConnectedChainsOptions): UseConnectedChainsResult; type UseXDisconnectArgs = { xChainType: ChainType; }; /** * Returns a callback that disconnects the wallet for a given chain type. * * The callback delegates to the chain's `ChainActions.disconnect()` — provider-managed * chains (EVM/Solana/Sui) trigger native SDK disconnect and let the Hydrator clear the * store; non-provider chains call `unsetXConnection` directly. * * **Never throws.** When no `ChainActions` are registered (chain not enabled in * `SodaxWalletProvider` config), the callback logs a warning and resolves silently. * Even if the wallet's native disconnect throws, the store is cleared — the UI never * gets stuck on "connected" state. * * @see {@link https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECT_FLOW.md#disconnect | Connect Flow — Disconnect} */ declare function useXDisconnect(): (args: UseXDisconnectArgs) => Promise; type ConnectionStatus = 'idle' | 'connecting' | 'success' | 'error'; type UseConnectionFlowResult = { /** `'idle' | 'connecting' | 'success' | 'error'` — reflects the last attempt. */ status: ConnectionStatus; /** Raw error from the last failed attempt; null when no error. Inspect `activeConnector.isInstalled` for the install-CTA branch. */ error: Error | null; /** Connector the current / last attempt targeted. */ activeConnector: XConnector | null; /** Chain the current / last attempt targeted. */ activeChainType: ChainType | null; /** Connect and return the resolved account. Errors populate `error` instead of throwing. */ connect: (connector: XConnector) => Promise; /** Disconnect a specific chain. Matches `useXDisconnect` semantics. */ disconnect: (args: UseXDisconnectArgs) => Promise; /** Re-runs the last attempted `connect(connector)`. No-op if no prior attempt. */ retry: () => Promise; /** Clears `status`, `error`, and `activeConnector`. */ reset: () => void; }; /** * Wrapper around `useXConnect` + `useXDisconnect` that surfaces the raw error * on state instead of throwing, plus tracks the active connector and exposes * `retry()`. Unlike calling `useXConnect` directly, `connect()` here never * throws — errors flow into `error` so render code stays linear. * * For the "install CTA" branch, read `activeConnector.isInstalled` and * `activeConnector.installUrl` (populated by Phase 1). No error classification * is done here — consumers log the raw error for unrecognized cases. * * @example * const { status, error, connect, retry, activeConnector } = useConnectionFlow(); * * if (status === 'error' && error) { * if (activeConnector && !activeConnector.isInstalled) { * return Install →; * } * return ; * } * * return ( * * ); */ declare function useConnectionFlow(): UseConnectionFlowResult; /** Lifecycle of a sequential batch operation (`useBatchConnect`, `useBatchDisconnect`). */ type BatchOperationStatus = 'idle' | 'running' | 'done'; /** * Per-target event emitted by `onProgress` as the batch advances. Lets consumers * render a live "EVM: connecting… done; ICON: skipped; SUI: connecting…" log * instead of waiting for the final `run()` promise. */ type BatchConnectProgressEvent = { chainType: ChainType; outcome: 'success'; } | { chainType: ChainType; outcome: 'failure'; error: Error; } | { chainType: ChainType; outcome: 'skipped'; }; type BatchConnectResult = { /** Chain types where the connect attempt succeeded. */ successful: ChainType[]; /** Chain types where the connect attempt threw, paired with the raw error. */ failed: Array<{ chainType: ChainType; error: Error; }>; /** Chain types skipped because `{ skipConnected: true }` and an account was already present. */ skipped: ChainType[]; }; type UseBatchConnectOptions = { /** * Wallet brand identifiers (e.g. `'hana'`, `'phantom'`). Matched via * case-insensitive substring against `connector.id` and `connector.name` — * see {@link matchesConnectorIdentifier}. * * Resolution is **per-chain priority with fallback-on-failure**: for each * chain, every matching connector is queued in identifier order. The runner * tries them sequentially and stops at the first one that connects. If an * earlier identifier's connector fails (popup denied, extension error, …), * the next identifier's connector is tried. Subsequent identifiers are * silently skipped once a chain succeeds — only one popup per chain on the * happy path. * * To target a specific connector (not a brand), use * `useXConnectors(chainType).find(c => c.id === '...')` directly instead of * this API. * * @example ['hana'] // Hana across every chain it supports * @example ['hana', 'phantom'] // prefer Hana per chain; if Hana fails or * // is unavailable on a chain, fall back to * // Phantom (e.g. Solana). */ connectors: readonly string[]; /** Skip chains whose account is already connected at `run()` time. */ skipConnected?: boolean; /** * Fires once per target as the batch progresses. Useful for live progress UI * (a spinner-per-chain list). Errors thrown from `onProgress` are caught and * logged — they do NOT fail the batch. */ onProgress?: (event: BatchConnectProgressEvent) => void; }; type UseBatchConnectResult = { run: () => Promise; status: BatchOperationStatus; result: BatchConnectResult | null; /** * Clears `status` and `result`. Calling `reset()` while `status === 'running'` * only clears the observable state — the in-flight batch is NOT aborted * (there is no cancellation signal). When the batch eventually resolves, * `status` flips to `'done'` and `result` populates again. Typical usage * is to call `reset()` only after `status === 'done'`. */ reset: () => void; }; /** * Connect every chain where one of the supplied wallet identifiers matches * an available connector. Sequential (safe for extensions that share popup * singletons); errors never throw from `run()` — failures are collected into * `result.failed`. * * Replaces the apps/web-era per-wallet wrappers * (`useConnectAllWithHana`, `useConnectRestWithHana`): pass the wallet name(s) * and the hook discovers all compatible chains from the registry. * * @example * // Connect Hana on every chain it supports (EVM, ICON, Solana, Sui, Stellar...) * const { run, status, result } = useBatchConnect({ connectors: ['hana'] }); * await run(); * * @example * // Only connect chains not already connected * const { run } = useBatchConnect({ connectors: ['hana'], skipConnected: true }); * await run(); */ declare function useBatchConnect({ connectors, skipConnected, onProgress, }: UseBatchConnectOptions): UseBatchConnectResult; /** * Per-target event emitted by `onProgress` as the batch advances. */ type BatchDisconnectProgressEvent = { chainType: ChainType; outcome: 'success'; } | { chainType: ChainType; outcome: 'failure'; error: Error; }; type BatchDisconnectResult = { /** Chain types where disconnect succeeded. */ successful: ChainType[]; /** Chain types where disconnect threw, paired with the raw error. */ failed: Array<{ chainType: ChainType; error: Error; }>; }; type UseBatchDisconnectOptions = { /** * Wallet brand identifiers to scope the disconnect (e.g. `'hana'`, * `'xverse'`). Matched via case-insensitive substring against * `connector.id` and `connector.name` — see {@link matchesConnectorIdentifier}. * Only chains whose *currently active* connector matches at least one * identifier are disconnected. * * Omit this field to disconnect every currently-connected chain regardless * of which wallet is active. * * To target a specific connector (not a brand), use * `useXConnectors(chainType).find(c => c.id === '...')` + `useXDisconnect` * directly instead of this API. * * @example ['hana'] // disconnect every chain Hana is connected on * @example ['hana', 'xverse'] // disconnect chains with Hana OR Xverse active */ connectors?: readonly string[]; /** * Fires once per target as the batch progresses. Errors thrown from * `onProgress` are caught and logged — they do NOT fail the batch. */ onProgress?: (event: BatchDisconnectProgressEvent) => void; }; type UseBatchDisconnectResult = { run: () => Promise; status: BatchOperationStatus; result: BatchDisconnectResult | null; /** * Clears `status` and `result`. Calling `reset()` while `status === 'running'` * only clears the observable state — the in-flight batch is NOT aborted * (there is no cancellation signal). When the batch eventually resolves, * `status` flips to `'done'` and `result` populates again. Typical usage * is to call `reset()` only after `status === 'done'`. */ reset: () => void; }; /** * Disconnect chains sequentially, optionally scoped to a specific wallet. * Mirrors {@link useBatchConnect}'s identifier-based API: * * @example * // Disconnect every chain Hana is currently connected on * const { run } = useBatchDisconnect({ connectors: ['hana'] }); * await run(); * * @example * // Disconnect every currently-connected chain regardless of wallet * const { run } = useBatchDisconnect(); * await run(); * * Best-effort: errors are collected, not thrown. `run()` is idempotent — a * double-invocation while one batch is in flight returns the same promise. */ declare function useBatchDisconnect({ connectors, onProgress, }?: UseBatchDisconnectOptions): UseBatchDisconnectResult; /** * Discriminated union for the wallet-modal flow state machine. * See `useWalletModal()` for transitions and consumer usage. */ type WalletModalState = { kind: 'closed'; } | { kind: 'chainSelect'; } | { kind: 'walletSelect'; chainType: ChainType; } | { kind: 'connecting'; chainType: ChainType; connector: XConnector; } | { kind: 'success'; chainType: ChainType; connector: XConnector; account: XAccount; } | { kind: 'error'; chainType: ChainType; connector: XConnector; error: Error; }; type UseWalletModalOptions = { /** * Fires once after a successful connect attempt initiated through the modal, * before the consumer transitions away from the `success` state. Side-effects * the SDK shouldn't bake in (registration check, terms-of-service modal, app * routing) belong here. */ onConnected?: (chainType: ChainType, account: XAccount) => void | Promise; /** * How long (ms) to wait for a provider-managed chain's Hydrator to populate * `xConnections[chainType]` with an account whose `xConnectorId` matches the * connector the user picked. Defaults to 5000ms. Raise this for slow * networks / wallets that take a long time to surface the account after * the user approves the popup. Ignored for non-provider chains (Bitcoin, * ICON, Stellar, NEAR, Stacks, Injective) — those return the account * directly from `connect()`. */ hydrationTimeoutMs?: number; }; /** * WalletConnect UX caveat * ----------------------- * When the user picks an EVM WalletConnect connector, wagmi opens its own QR * modal as a third-party UI. While that QR modal is visible, `useWalletModal` * stays in `connecting` — the consumer may prefer to auto-hide the Sodax * modal to avoid two dialogs stacking. Detect WC via * `state.kind === 'connecting' && state.connector.id === 'walletConnect'` * (wagmi's connector id) and conditionally render `null` until the attempt * resolves. Not wired into the SDK because partners integrating their own * dialog system decide the policy (hide, fade, keep). */ type UseWalletModalResult = { /** Discriminated union — switch on `state.kind` for type-narrowed fields. */ state: WalletModalState; /** Transition `closed → chainSelect`. No-op if already open. */ open: () => void; /** Transition any → `closed`. */ close: () => void; /** * Smart back: walletSelect → chainSelect; connecting/error → walletSelect * (preserve chainType so user can pick another wallet or retry); success → closed; * closed/chainSelect → no-op. */ back: () => void; /** Transition `chainSelect → walletSelect(chainType)`. */ selectChain: (chainType: ChainType) => void; /** * Transition `walletSelect → connecting → success | error`. Composes * `useXConnect` internally; failures populate `state.error` instead of * throwing. * * Concurrency: * - Same connector already in flight → returns the same promise (dedupes * double-clicks). * - Different connector clicked before the previous attempt settles → starts * a new attempt; the previous attempt's late resolution is dropped and * does not overwrite the current state. * - User calls `back()` / `close()` mid-connect → the in-flight attempt's * late resolution is dropped and does not transition to `success`/`error`. * * `back()` / `close()` mid-connect caveat: if the wallet already approved * before the transition, `xConnections` is populated by `useXConnect` / * the Hydrator independently of the modal state machine. Leaving the * `connecting` state only drops the pending `success`/`error` transition * — the account stays connected. Call `useXDisconnect(chainType)` from * the same handler that calls `back()` / `close()` if a full rollback is * required. */ selectWallet: (connector: XConnector) => Promise; /** Re-runs the last `selectWallet` from an `error` state. No-op otherwise. */ retry: () => Promise; }; /** * Headless modal lifecycle for multi-chain wallet connection. Owns the flow * `closed → chainSelect → walletSelect → connecting → success | error` as a * Zustand slice so multiple components (header CTA, inline buttons, settings) * see the same lifecycle without prop drilling. * * The hook is render-agnostic — pair it with any dialog/drawer/inline UI: * * @example * const modal = useWalletModal({ * onConnected: async (chainType, account) => { * // App-specific side effect (e.g. terms-of-service check) * await registerIfNew(chainType, account.address); * }, * }); * * switch (modal.state.kind) { * case 'closed': return ; * case 'chainSelect': return ; * case 'walletSelect': return ; * case 'connecting': return ; * case 'success': return null; // onConnected fired; consumer can call modal.close() * case 'error': return ; * } */ declare function useWalletModal({ onConnected, hydrationTimeoutMs, }?: UseWalletModalOptions): UseWalletModalResult; type UseXServiceOptions = { xChainType?: ChainType; }; /** * Returns the chain-specific `XService` instance for advanced reads — balance lookups * (`xService.getBalance(address, xToken)`), connector enumeration, or chain-specific * methods on concrete subclasses. * * Most consumers don't need this — `useWalletProvider` is the higher-level bridge to * `@sodax/sdk`, and `useXConnectors` returns the connector list directly. Reach for * `useXService` only when you need the service object itself (e.g. passing it to * `useXBalances` from `@sodax/dapp-kit`). * * Returns `undefined` when `xChainType` is omitted or the chain isn't enabled. */ declare function useXService({ xChainType }?: UseXServiceOptions): XService | undefined; /** * Returns the `XService` instance for every enabled chain, keyed by `ChainType`. * * Each service singleton owns its connector list and exposes balance readers; concrete * subclasses (e.g. `EvmXService`, `BitcoinXService`) carry chain-specific methods. For * a single chain, prefer `useXService` which is keyed by `xChainType` directly. */ declare function useXServices(): Partial>; /** * Reads the list of `ChainType`s currently enabled in `SodaxWalletProvider` config. * * Reflects which chain-type slots are present (`config.EVM`, `config.SOLANA`, …) — not * which chains have a wallet connected. Use `useConnectedChains` for the latter. * * @returns Stable array reference; re-renders only when `enabledChains` changes (i.e. on * `initChainServices` after mount, never afterwards because config is captured once). */ declare function useEnabledChains(): ChainType[]; type UseEvmSwitchChainOptions = { xChainId: SpokeChainKey; }; type UseEvmSwitchChainReturn = { isWrongChain: boolean; handleSwitchChain: () => void; }; /** * Hook to handle EVM chain switching functionality. * Safe to call when EVM is disabled — returns no-op values. * * Conditionally delegates to useEvmSwitchChainInner which uses wagmi hooks * (useAccount, useSwitchChain) that require WagmiProvider. When EVM is disabled, * WagmiProvider is not mounted, so we must not call those hooks. * * This technically violates Rules of Hooks (conditional hook call), but is safe * because `evmEnabled` is derived from config which is immutable after mount — * the branch never changes during the component's lifetime. */ declare function useEvmSwitchChain({ xChainId }: UseEvmSwitchChainOptions): UseEvmSwitchChainReturn; /** Empty slot in `walletProviders` is normal before a wallet is connected. */ type GetWalletProviderReturnType = K extends ChainType ? GetWalletProviderType | undefined : undefined; type UseWalletProviderOptions = { xChainId?: SpokeChainKey; xChainType?: ChainType; }; /** * Returns the typed `IXxxWalletProvider` instance for the requested chain — ready to plug * into any `@sodax/sdk` call's `walletProvider` slot. * * Pass either `xChainId` (a `SpokeChainKey`) or `xChainType` (a `ChainType` family), * never both. The chain key form gives the narrowest TypeScript inference (e.g. * `xChainId: ChainKeys.BSC_MAINNET` → `IEvmWalletProvider | undefined`). * * Returns `undefined` when: * - The chain isn't enabled in `SodaxWalletProvider` config (logs a one-time warning). * - No wallet is connected for that chain yet. * * For provider-managed chains (EVM/Solana/Sui), the returned provider is rebuilt by the * Hydrator whenever the underlying client changes (chain switch, wallet swap). For * non-provider chains, the provider is created as a side-effect of `setXConnection`. * * @see {@link https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/WALLET_PROVIDER_BRIDGE.md | Wallet Provider Bridge} */ declare function useWalletProvider(options: { xChainId: S; xChainType?: never; }): GetWalletProviderType> | undefined; declare function useWalletProvider(options?: { xChainId?: never; xChainType?: K; }): GetWalletProviderReturnType | undefined; type SignMessageReturnType = `0x${string}` | Uint8Array | string | undefined; type XSignMessageVariables = { xChainType: ChainType; message: string; }; /** * React Query mutation that delegates message signing to the connected wallet via * `ChainActions.signMessage` — registered per chain by the `chainRegistry` (non-provider * chains) or by the `Actions` component (provider-managed chains). * * The signature shape varies by chain: hex `\`0x${string}\`` for EVM, `Uint8Array` for * Solana, base64 `string` for Stellar/Sui, etc. Branch on `xChainType` when consuming. * * **Bitcoin auto-selects** between BIP-322 (P2WPKH/P2TR) and ECDSA (P2SH/P2PKH) based * on the connected address type — same dispatch logic as the SDK's * `BitcoinSpokeProvider.authenticateWithWallet`. * * **Returns `undefined`** when the chain doesn't implement `signMessage` — currently * only ICON (Hana wallet exposes no signing API). A one-time `console.warn` accompanies * the `undefined`. * * @see {@link https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/SIGN_MESSAGE.md | Sign Message} */ declare function useXSignMessage(): UseMutationResult; type SodaxWalletProviderProps = { children: ReactNode; /** * Captured once on mount. Dynamic changes require remounting `SodaxWalletProvider` * — passing a new reference on subsequent renders has no effect. */ config: SodaxWalletConfig; }; /** * Root provider for SODAX wallet connectivity. Mounts only the chain-type adapters opted * into via `config` and bridges to `@sodax/wallet-sdk-core` so SDK calls receive a typed * `IXxxWalletProvider`. * * Top-level keys on `SodaxWalletConfig` are chain-type slots (`EVM`, `SOLANA`, `BITCOIN`, …). * Omit a slot to skip mounting that adapter; pass `{}` to mount with SDK defaults. Provider- * managed chains (EVM/Solana/Sui) wrap their native React adapter (wagmi / wallet-adapter / * dapp-kit) plus a `` that syncs adapter state into the Zustand store; non-provider * chains register `ChainActions` directly during `useInitChainServices`. * * **Config is captured once on mount** via `useRef` — subsequent re-renders with a new * reference have no effect. To swap config at runtime, remount with a new `key` prop. * * Must be wrapped by `` from `@tanstack/react-query` (or, if also * using `@sodax/dapp-kit`, see Setup skill for the full provider-stack ordering). * * @see {@link https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONFIGURE_PROVIDER.md | Configure SodaxWalletProvider} */ declare const SodaxWalletProvider: ({ children, config }: SodaxWalletProviderProps) => react_jsx_runtime.JSX.Element; export { type BatchConnectProgressEvent, type BatchConnectResult, type BatchDisconnectProgressEvent, type BatchDisconnectResult, type BatchOperationStatus, type ChainActions, type ChainActionsRegistry, ChainEntry, type ChainGroup, type ConnectedChain, type ConnectionStatus, EvmChainEntry, IXConnector, SodaxWalletConfig, SodaxWalletProvider, type SodaxWalletProviderProps, type SortConnectorsOptions, type UseBatchConnectOptions, type UseBatchConnectResult, type UseBatchDisconnectOptions, type UseBatchDisconnectResult, type UseChainGroupsOptions, type UseConnectedChainsOptions, type UseConnectedChainsResult, type UseConnectionFlowResult, type UseEvmSwitchChainOptions, type UseEvmSwitchChainReturn, type UseIsWalletInstalledOptions, type UseWalletModalOptions, type UseWalletModalResult, type UseWalletProviderOptions, type UseXAccountOptions, type UseXConnectionOptions, type UseXConnectorsOptions, type UseXDisconnectArgs, type UseXServiceOptions, WalletConfigProvider, WalletDefaultsByKey, type WalletModalState, XAccount, XConnection, XConnector, XService, type XSignMessageVariables, getEntryDefaults, getRpcUrl, getWagmiChainId, getXChainType, getXService, isNativeToken, resolveEvmDefaults, sortConnectors, useBatchConnect, useBatchDisconnect, useChainGroups, useConnectedChains, useConnectionFlow, useEnabledChainTypes, useEnabledChains, useEvmSwitchChain, useIsChainEnabled, useIsWalletInstalled, useWalletConfig, useWalletModal, useWalletProvider, useXAccount, useXAccounts, useXConnect, useXConnection, useXConnections, useXConnectors, useXConnectorsByChain, useXDisconnect, useXService, useXServices, useXSignMessage };