@qorechain/react 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -111,7 +111,7 @@ await connect({ kind: "keplr" }); // or "leap" | "evm" | "svm"
|
|
|
111
111
|
|
|
112
112
|
| Wallet kind | Adapter | Result |
|
|
113
113
|
| --- | --- | --- |
|
|
114
|
-
| `keplr` / `leap` | `getCosmosWallet` (
|
|
114
|
+
| `keplr` / `leap` | `getCosmosWallet` (Native) — suggests + enables the chain, returns a CosmJS signer wired into a `TxClient` | `addresses.native`, signing enabled |
|
|
115
115
|
| `evm` | injected EIP-1193 provider (`window.ethereum`, e.g. MetaMask) via `eth_requestAccounts` | `addresses.evm` |
|
|
116
116
|
| `svm` | injected Wallet-Standard provider (`window.solana`, e.g. Phantom) via `connect()` | `addresses.svm` |
|
|
117
117
|
|
|
@@ -122,7 +122,7 @@ EVM/SVM tooling pair this with `@qorechain/evm` / `@qorechain/svm`.
|
|
|
122
122
|
|
|
123
123
|
### `useTx()`
|
|
124
124
|
|
|
125
|
-
Sign + broadcast with the connected
|
|
125
|
+
Sign + broadcast with the connected Native signer. Returns
|
|
126
126
|
`{ send, sendTokens, status, data, error, isPending, reset }`.
|
|
127
127
|
|
|
128
128
|
```ts
|
package/dist/index.cjs
CHANGED
|
@@ -201,7 +201,7 @@ function useTx() {
|
|
|
201
201
|
const requireTx = react.useCallback(() => {
|
|
202
202
|
if (!tx) {
|
|
203
203
|
throw new Error(
|
|
204
|
-
"useTx: no connected signer. Connect a
|
|
204
|
+
"useTx: no connected signer. Connect a Native wallet (Keplr/Leap) via useConnect() first."
|
|
205
205
|
);
|
|
206
206
|
}
|
|
207
207
|
return tx;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context.tsx","../src/hooks/useQoreClient.ts","../src/hooks/useAccount.ts","../src/hooks/useBalance.ts","../src/hooks/useConnect.ts","../src/hooks/useTx.ts","../src/hooks/usePqcStatus.ts","../src/components/ConnectButton.tsx","../src/components/QuantumSafeBadge.tsx"],"names":["createContext","useMemo","createClient","useState","useRef","useCallback","jsx","useContext","useEffect","getCosmosWallet","provider","getPqcStatus","jsxs"],"mappings":";;;;;;;AAmGA,IAAM,WAAA,GAAcA,oBAAuC,IAAI,CAAA;AASxD,SAAS,kBAAkB,KAAA,EAA0C;AAC1E,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,UAAS,GAAI,KAAA;AAO/C,EAAA,MAAM,EAAE,OAAA,EAAS,OAAA,EAAQ,GAAI,MAAA;AAC7B,EAAA,MAAM,YAAY,MAAA,CAAO,SAAA;AACzB,EAAA,MAAM,OAAO,MAAA,CAAO,IAAA;AACpB,EAAA,MAAM,MAAA,GAASC,cAAyB,MAAM;AAC5C,IAAA,IAAI,UAAU,OAAO,QAAA;AACrB,IAAA,OAAOC,iBAAa,EAAE,OAAA,EAAS,SAAA,EAAW,OAAA,EAAS,MAAM,CAAA;AAAA,EAC3D,GAAG,CAAC,QAAA,EAAU,SAAS,OAAA,EAAS,SAAA,EAAW,IAAI,CAAC,CAAA;AAEhD,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAIC,eAA2B,cAAc,CAAA;AACrE,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAIA,cAAA,CAA6B,EAAE,CAAA;AACjE,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAIA,cAAA;AAAA,IAC1B;AAAA,GACF;AACA,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,eAA4B,MAAS,CAAA;AAG/D,EA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AAN,cAAAA,CAAC,MAAA,EAAA,EAAK,aAAA,EAAY,MAAA,EAAO,QAAA,EAAA,iBAAA,EAAG,CAAA;AAAA,QAC3B,MAAM,SAAA,IAAa;AAAA;AAAA;AAAA,GACtB;AAEJ","file":"index.cjs","sourcesContent":["/**\n * The QoreChain React context: a {@link QoreChainProvider} that holds a single\n * composed {@link QoreChainClient} (from `@qorechain/sdk`'s {@link createClient})\n * plus the live wallet connection state, and the {@link useQoreContext} hook the\n * other hooks build on.\n *\n * One provider near the root of the app is enough; every hook\n * ({@link useQoreClient}, {@link useAccount}, {@link useBalance},\n * {@link useConnect}, {@link useTx}, {@link usePqcStatus}) reads from it.\n */\n\nimport {\n createContext,\n useContext,\n useMemo,\n useRef,\n useState,\n useCallback,\n type ReactNode,\n} from \"react\";\nimport {\n createClient,\n type QoreChainClient,\n type CreateClientOptions,\n type TxClient,\n} from \"@qorechain/sdk\";\n\n/** A connected wallet's resolved addresses, by VM family. */\nexport interface ConnectedAddresses {\n /** Native bech32 (`qor1...`) address, when a Cosmos wallet is connected. */\n native?: string;\n /** EVM (`0x...`) address, when an EVM wallet is connected. */\n evm?: string;\n /** SVM (base58) address, when an SVM wallet is connected. */\n svm?: string;\n}\n\n/** The live connection status of the provider. */\nexport type ConnectionStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"error\";\n\n/** Which wallet family is connected. */\nexport type ConnectedWalletKind = \"keplr\" | \"leap\" | \"evm\" | \"svm\";\n\n/** The full context value exposed by {@link QoreChainProvider}. */\nexport interface QoreContextValue {\n /** The composed read client (created once from the provider config). */\n client: QoreChainClient;\n /** Current connection status. */\n status: ConnectionStatus;\n /** The connected addresses, keyed by VM family. Empty when disconnected. */\n addresses: ConnectedAddresses;\n /** Which wallet is connected, if any. */\n wallet?: ConnectedWalletKind;\n /** The connected signing client, if any (set by `useConnect`). */\n tx?: TxClient;\n /** The last connection error, if `status === \"error\"`. */\n error?: Error;\n /**\n * Internal: replace the connection state. Used by {@link useConnect}; apps use\n * the hooks rather than calling this directly.\n */\n setConnection(next: {\n status: ConnectionStatus;\n addresses?: ConnectedAddresses;\n wallet?: ConnectedWalletKind;\n tx?: TxClient;\n error?: Error;\n }): void;\n}\n\n/** Configuration for {@link QoreChainProvider}, forwarded to `createClient`. */\nexport interface QoreChainProviderConfig {\n /** Network preset to target. Defaults to `\"testnet\"`. */\n network?: CreateClientOptions[\"network\"];\n /** Endpoint overrides merged over the preset's defaults. */\n endpoints?: CreateClientOptions[\"endpoints\"];\n /** Chain id override. */\n chainId?: CreateClientOptions[\"chainId\"];\n /** Additional HTTP transport options shared by the read clients. */\n http?: CreateClientOptions[\"http\"];\n}\n\n/** Props for {@link QoreChainProvider}. */\nexport interface QoreChainProviderProps {\n /** Network + endpoint configuration for the underlying read client. */\n config: QoreChainProviderConfig;\n /**\n * A pre-built client to use instead of constructing one from `config`. Useful\n * for tests (inject a mocked client) and advanced composition.\n */\n client?: QoreChainClient;\n /** The app subtree that consumes the QoreChain hooks. */\n children: ReactNode;\n}\n\nconst QoreContext = createContext<QoreContextValue | null>(null);\n\n/**\n * Provide a single composed QoreChain client + connection state to the subtree.\n *\n * The client is created once (memoized on the config identity), so place the\n * provider above any component that uses the hooks. Pass `client` to inject a\n * pre-built (or mocked) client instead.\n */\nexport function QoreChainProvider(props: QoreChainProviderProps): ReactNode {\n const { config, client: injected, children } = props;\n\n // Build the read client once. When `injected` is provided it always wins.\n // The config object is treated as stable for the provider's lifetime; callers\n // that need to switch networks should remount the provider with a new `key`.\n // Memoize on the config's primitive fields so a new (but equal) config object\n // identity does not rebuild the client every render.\n const { network, chainId } = config;\n const endpoints = config.endpoints;\n const http = config.http;\n const client = useMemo<QoreChainClient>(() => {\n if (injected) return injected;\n return createClient({ network, endpoints, chainId, http });\n }, [injected, network, chainId, endpoints, http]);\n\n const [status, setStatus] = useState<ConnectionStatus>(\"disconnected\");\n const [addresses, setAddresses] = useState<ConnectedAddresses>({});\n const [wallet, setWallet] = useState<ConnectedWalletKind | undefined>(\n undefined,\n );\n const [error, setError] = useState<Error | undefined>(undefined);\n // The TxClient is not React state we render off of; keep it in a ref but mirror\n // a setter for hooks. We store it in state too so `useTx` re-renders on connect.\n const txRef = useRef<TxClient | undefined>(undefined);\n const [tx, setTx] = useState<TxClient | undefined>(undefined);\n\n const setConnection = useCallback<QoreContextValue[\"setConnection\"]>(\n (next) => {\n setStatus(next.status);\n setAddresses(next.addresses ?? {});\n setWallet(next.wallet);\n txRef.current = next.tx;\n setTx(next.tx);\n setError(next.error);\n },\n [],\n );\n\n const value = useMemo<QoreContextValue>(\n () => ({ client, status, addresses, wallet, tx, error, setConnection }),\n [client, status, addresses, wallet, tx, error, setConnection],\n );\n\n return <QoreContext.Provider value={value}>{children}</QoreContext.Provider>;\n}\n\n/**\n * Read the raw {@link QoreContextValue}. Throws when used outside a\n * {@link QoreChainProvider}. Most apps use the purpose-built hooks instead.\n */\nexport function useQoreContext(): QoreContextValue {\n const ctx = useContext(QoreContext);\n if (!ctx) {\n throw new Error(\n \"useQoreContext: no QoreChainProvider found. Wrap your app in <QoreChainProvider config={...}>.\",\n );\n }\n return ctx;\n}\n","/**\n * {@link useQoreClient} — the composed read client held by the provider.\n */\n\nimport type { QoreChainClient } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/**\n * Return the {@link QoreChainClient} created by the nearest\n * {@link QoreChainProvider}. Use it for ad-hoc reads (`client.rest`,\n * `client.qor`, `client.fees`, ...) not already covered by a dedicated hook.\n */\nexport function useQoreClient(): QoreChainClient {\n return useQoreContext().client;\n}\n","/**\n * {@link useAccount} — the connected wallet's addresses and status.\n */\n\nimport { useQoreContext } from \"../context\";\nimport type {\n ConnectedAddresses,\n ConnectionStatus,\n ConnectedWalletKind,\n} from \"../context\";\n\n/** The shape returned by {@link useAccount}. */\nexport interface UseAccountResult {\n /** All connected addresses, by VM family (native / evm / svm). */\n addresses: ConnectedAddresses;\n /** The primary address (native preferred, then evm, then svm), if any. */\n address?: string;\n /** Whether a wallet is connected. */\n isConnected: boolean;\n /** The current connection status. */\n status: ConnectionStatus;\n /** Which wallet is connected, if any. */\n wallet?: ConnectedWalletKind;\n}\n\n/**\n * Return the connected account's address(es) — native (bech32), EVM (`0x...`),\n * and/or SVM (base58) — plus a convenience primary `address` and connection\n * status. Empty until a wallet is connected via {@link useConnect}.\n */\nexport function useAccount(): UseAccountResult {\n const { addresses, status, wallet } = useQoreContext();\n const address = addresses.native ?? addresses.evm ?? addresses.svm;\n return {\n addresses,\n address,\n isConnected: status === \"connected\" && address !== undefined,\n status,\n wallet,\n };\n}\n","/**\n * {@link useBalance} — a bank balance with optional auto-refresh.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { Coin } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** Options for {@link useBalance}. */\nexport interface UseBalanceOptions {\n /**\n * The denom to read. Defaults to the network's base denom (e.g. `uqor`).\n */\n denom?: string;\n /**\n * Auto-refresh interval in milliseconds. `0` (the default) disables polling;\n * the balance is then fetched once on mount / address change.\n */\n refreshInterval?: number;\n /** Skip fetching entirely (e.g. while disconnected). Defaults to `false`. */\n enabled?: boolean;\n}\n\n/** The shape returned by {@link useBalance}. */\nexport interface UseBalanceResult {\n /** The balance coin (`{ denom, amount }`), once loaded. */\n data?: Coin;\n /** Whether a fetch is in flight. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n /** Manually re-fetch the balance. */\n refetch(): Promise<void>;\n}\n\n/**\n * Read the bank balance of `address` (or the connected account when omitted) in\n * a denom. Re-fetches on address / denom change and, when `refreshInterval > 0`,\n * polls on that interval. Returns `{ data, isLoading, error, refetch }`.\n */\nexport function useBalance(\n address?: string,\n options: UseBalanceOptions = {},\n): UseBalanceResult {\n const { client, addresses } = useQoreContext();\n const resolvedAddress = address ?? addresses.native;\n const denom = options.denom ?? client.network.coin.base;\n const refreshInterval = options.refreshInterval ?? 0;\n const enabled = options.enabled ?? true;\n\n const [data, setData] = useState<Coin | undefined>(undefined);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n // Guard against setting state after unmount / stale responses.\n const activeRef = useRef(true);\n useEffect(() => {\n activeRef.current = true;\n return () => {\n activeRef.current = false;\n };\n }, []);\n\n const refetch = useCallback(async (): Promise<void> => {\n if (!resolvedAddress || !enabled) return;\n setIsLoading(true);\n setError(undefined);\n try {\n const res = await client.rest.getBalance(resolvedAddress, denom);\n if (activeRef.current) {\n setData(res.balance ?? { denom, amount: \"0\" });\n }\n } catch (err) {\n if (activeRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n } finally {\n if (activeRef.current) setIsLoading(false);\n }\n }, [client, resolvedAddress, denom, enabled]);\n\n useEffect(() => {\n void refetch();\n if (refreshInterval > 0 && resolvedAddress && enabled) {\n const id = setInterval(() => {\n void refetch();\n }, refreshInterval);\n return () => clearInterval(id);\n }\n return undefined;\n }, [refetch, refreshInterval, resolvedAddress, enabled]);\n\n return { data, isLoading, error, refetch };\n}\n","/**\n * {@link useConnect} / {@link useWallet} — multi-wallet connect.\n *\n * Wraps the EXISTING wallet adapters so a component connects with one call and\n * the resolved signer + addresses land in the provider's connection state:\n * - Keplr / Leap (Cosmos) via `@qorechain/sdk`'s {@link getCosmosWallet}, which\n * suggests + enables the chain and returns a CosmJS signer; the signer is\n * connected through `client.connectTx` so `useTx` can sign.\n * - MetaMask / any EIP-1193 wallet (EVM) via `eth_requestAccounts` on the\n * injected provider (`window.ethereum` by default).\n * - Phantom / Wallet-Standard (SVM) via the injected Solana provider\n * (`window.solana`); returns the connected base58 address.\n *\n * The hook keeps its dependencies light: the EVM and SVM paths talk to the\n * injected provider's standard request API directly, so neither viem nor a\n * Solana SDK is pulled in. For full EVM/SVM tooling, use `@qorechain/evm` /\n * `@qorechain/svm` alongside this hook.\n */\n\nimport { useCallback } from \"react\";\nimport {\n getCosmosWallet,\n type CosmosWalletName,\n} from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\nimport type { ConnectedWalletKind } from \"../context\";\n\n/** A minimal EIP-1193 provider surface (MetaMask et al.). */\nexport interface Eip1193Like {\n request(args: { method: string; params?: unknown[] }): Promise<unknown>;\n}\n\n/** A minimal injected Solana provider surface (Phantom / Wallet-Standard). */\nexport interface SolanaProviderLike {\n connect(): Promise<{ publicKey: { toString(): string } }>;\n publicKey?: { toString(): string } | null;\n}\n\n/** Which wallet to connect via {@link UseConnectResult.connect}. */\nexport type ConnectKind = \"keplr\" | \"leap\" | \"evm\" | \"svm\";\n\n/** Options for a single {@link UseConnectResult.connect} call. */\nexport interface ConnectOptions {\n /** Which wallet to connect. Defaults to `\"keplr\"`. */\n kind?: ConnectKind;\n /**\n * Inject the wallet provider directly instead of reading it off `window`\n * (primarily for tests). The accepted shape depends on `kind`.\n */\n provider?: unknown;\n /** Use Amino signing for the Cosmos path (forwarded to `getCosmosWallet`). */\n preferAmino?: boolean;\n}\n\n/** The shape returned by {@link useConnect} / {@link useWallet}. */\nexport interface UseConnectResult {\n /** Connect a wallet; updates the provider's connection state. */\n connect(opts?: ConnectOptions): Promise<void>;\n /** Disconnect: clears the connection state. */\n disconnect(): void;\n /** The current connection status. */\n status: ReturnType<typeof useQoreContext>[\"status\"];\n /** Whether a connection attempt is in flight. */\n isConnecting: boolean;\n /** The last connection error, if any. */\n error?: Error;\n}\n\nfunction getWindow(): Record<string, unknown> | undefined {\n return typeof window === \"undefined\"\n ? undefined\n : (window as unknown as Record<string, unknown>);\n}\n\n/**\n * Multi-wallet connect bound to the {@link QoreChainProvider}.\n *\n * On success the provider's connection state holds the resolved addresses, the\n * connected wallet kind, and (for Cosmos) a `TxClient` for signing.\n */\nexport function useConnect(): UseConnectResult {\n const ctx = useQoreContext();\n const { client, status, error, setConnection } = ctx;\n\n const connect = useCallback(\n async (opts: ConnectOptions = {}): Promise<void> => {\n const kind: ConnectKind = opts.kind ?? \"keplr\";\n setConnection({ status: \"connecting\", addresses: ctx.addresses });\n\n try {\n if (kind === \"keplr\" || kind === \"leap\") {\n const conn = await getCosmosWallet({\n wallet: kind as CosmosWalletName,\n network: client.network,\n provider: opts.provider as never,\n preferAmino: opts.preferAmino,\n });\n const native = conn.accounts[0]?.address;\n const tx = await client.connectTx(conn.signer as never);\n setConnection({\n status: \"connected\",\n addresses: { native },\n wallet: kind as ConnectedWalletKind,\n tx,\n });\n return;\n }\n\n if (kind === \"evm\") {\n const provider = (opts.provider ??\n getWindow()?.ethereum) as Eip1193Like | undefined;\n if (!provider) {\n throw new Error(\n \"useConnect(evm): no EIP-1193 provider found (window.ethereum). Install MetaMask, or pass `provider`.\",\n );\n }\n const accounts = (await provider.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n const evm = accounts?.[0];\n if (!evm) throw new Error(\"useConnect(evm): no account returned\");\n setConnection({\n status: \"connected\",\n addresses: { evm },\n wallet: \"evm\",\n });\n return;\n }\n\n // kind === \"svm\"\n const provider = (opts.provider ??\n getWindow()?.solana) as SolanaProviderLike | undefined;\n if (!provider) {\n throw new Error(\n \"useConnect(svm): no Solana / Wallet-Standard provider found (window.solana). Install Phantom, or pass `provider`.\",\n );\n }\n const { publicKey } = await provider.connect();\n const svm = publicKey?.toString();\n if (!svm) throw new Error(\"useConnect(svm): no public key returned\");\n setConnection({\n status: \"connected\",\n addresses: { svm },\n wallet: \"svm\",\n });\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setConnection({ status: \"error\", error: e });\n throw e;\n }\n },\n [client, ctx.addresses, setConnection],\n );\n\n const disconnect = useCallback((): void => {\n setConnection({ status: \"disconnected\", addresses: {} });\n }, [setConnection]);\n\n return {\n connect,\n disconnect,\n status,\n isConnecting: status === \"connecting\",\n error,\n };\n}\n\n/** Alias for {@link useConnect} — the multi-wallet connect hook. */\nexport const useWallet = useConnect;\n","/**\n * {@link useTx} — send a transaction and track its status.\n */\n\nimport { useCallback, useState } from \"react\";\nimport type {\n EncodeObject,\n BroadcastResult,\n TxFeeInput,\n Coin,\n} from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** The lifecycle status of a {@link useTx} send. */\nexport type TxStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Options for {@link UseTxResult.send}. */\nexport interface SendOptions {\n /** Fee: an explicit `StdFee` or `\"auto\"`. Default `\"auto\"`. */\n fee?: TxFeeInput;\n /** Optional memo. */\n memo?: string;\n}\n\n/** The shape returned by {@link useTx}. */\nexport interface UseTxResult {\n /** Sign + broadcast arbitrary messages with the connected signer. */\n send(messages: EncodeObject[], opts?: SendOptions): Promise<BroadcastResult>;\n /** Convenience: send a bank transfer of `amount` to `toAddress`. */\n sendTokens(\n toAddress: string,\n amount: Coin[],\n opts?: SendOptions,\n ): Promise<BroadcastResult>;\n /** The current send status. */\n status: TxStatus;\n /** The last broadcast result, on success. */\n data?: BroadcastResult;\n /** The last error, on failure. */\n error?: Error;\n /** Whether a send is in flight. */\n isPending: boolean;\n /** Reset status/data/error back to idle. */\n reset(): void;\n}\n\n/**\n * Send transactions with the connected signer and track `{ status, data, error }`.\n *\n * Requires a connected wallet that produced a `TxClient` (the Cosmos path of\n * {@link useConnect}). `send` takes raw `{ typeUrl, value }` messages (use the\n * `msg.*` composers from `@qorechain/sdk`); `sendTokens` is a bank-transfer\n * shortcut.\n */\nexport function useTx(): UseTxResult {\n const { tx } = useQoreContext();\n const [status, setStatus] = useState<TxStatus>(\"idle\");\n const [data, setData] = useState<BroadcastResult | undefined>(undefined);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n const requireTx = useCallback(() => {\n if (!tx) {\n throw new Error(\n \"useTx: no connected signer. Connect a Cosmos wallet (Keplr/Leap) via useConnect() first.\",\n );\n }\n return tx;\n }, [tx]);\n\n const run = useCallback(\n async (fn: () => Promise<BroadcastResult>): Promise<BroadcastResult> => {\n setStatus(\"pending\");\n setError(undefined);\n try {\n const res = await fn();\n setData(res);\n setStatus(\"success\");\n return res;\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setError(e);\n setStatus(\"error\");\n throw e;\n }\n },\n [],\n );\n\n const send = useCallback(\n (messages: EncodeObject[], opts: SendOptions = {}) =>\n run(() =>\n requireTx().signAndBroadcast(messages, opts.fee ?? \"auto\", opts.memo ?? \"\"),\n ),\n [run, requireTx],\n );\n\n const sendTokens = useCallback(\n (toAddress: string, amount: Coin[], opts: SendOptions = {}) =>\n run(() =>\n requireTx().bankSend(toAddress, amount, {\n fee: opts.fee ?? \"auto\",\n memo: opts.memo ?? \"\",\n }),\n ),\n [run, requireTx],\n );\n\n const reset = useCallback(() => {\n setStatus(\"idle\");\n setData(undefined);\n setError(undefined);\n }, []);\n\n return {\n send,\n sendTokens,\n status,\n data,\n error,\n isPending: status === \"pending\",\n reset,\n };\n}\n","/**\n * {@link usePqcStatus} — read an address's quantum-safe (PQC) registration state.\n *\n * Built on the SDK's quantum-safe DX helpers ({@link getPqcStatus} /\n * {@link isPqcRegistered}), which call `qor_getPQCKeyStatus`. Powers the\n * {@link QuantumSafeBadge} component.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { getPqcStatus, type PqcStatus } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** Options for {@link usePqcStatus}. */\nexport interface UsePqcStatusOptions {\n /** Skip fetching (e.g. while disconnected). Defaults to `false`. */\n enabled?: boolean;\n /**\n * Auto-refresh interval in milliseconds. `0` (default) disables polling; the\n * status is fetched once per address change.\n */\n refreshInterval?: number;\n}\n\n/** The shape returned by {@link usePqcStatus}. */\nexport interface UsePqcStatusResult {\n /** The normalized PQC status, once loaded. */\n data?: PqcStatus;\n /** Whether the address has a registered PQC key (convenience). */\n isRegistered: boolean;\n /** Whether a fetch is in flight. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n /** Manually re-fetch the status. */\n refetch(): Promise<void>;\n}\n\n/**\n * Read whether `address` (or the connected account when omitted) is quantum-safe\n * — i.e. has a registered PQC key on QoreChain. Returns\n * `{ data, isRegistered, isLoading, error, refetch }`.\n */\nexport function usePqcStatus(\n address?: string,\n options: UsePqcStatusOptions = {},\n): UsePqcStatusResult {\n const { client, addresses } = useQoreContext();\n const resolvedAddress = address ?? addresses.native ?? addresses.evm;\n const enabled = options.enabled ?? true;\n const refreshInterval = options.refreshInterval ?? 0;\n\n const [data, setData] = useState<PqcStatus | undefined>(undefined);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n const activeRef = useRef(true);\n useEffect(() => {\n activeRef.current = true;\n return () => {\n activeRef.current = false;\n };\n }, []);\n\n const refetch = useCallback(async (): Promise<void> => {\n if (!resolvedAddress || !enabled) return;\n setIsLoading(true);\n setError(undefined);\n try {\n const status = await getPqcStatus(client, resolvedAddress);\n if (activeRef.current) setData(status);\n } catch (err) {\n if (activeRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n } finally {\n if (activeRef.current) setIsLoading(false);\n }\n }, [client, resolvedAddress, enabled]);\n\n useEffect(() => {\n void refetch();\n if (refreshInterval > 0 && resolvedAddress && enabled) {\n const id = setInterval(() => {\n void refetch();\n }, refreshInterval);\n return () => clearInterval(id);\n }\n return undefined;\n }, [refetch, refreshInterval, resolvedAddress, enabled]);\n\n return {\n data,\n isRegistered: data?.registered ?? false,\n isLoading,\n error,\n refetch,\n };\n}\n","/**\n * {@link ConnectButton} — a minimal, headless-ish multi-wallet connect control.\n *\n * Renders a connect button (or a small picker when multiple wallet kinds are\n * offered) wired to {@link useConnect}; once connected it shows the truncated\n * address and a disconnect action. Styling is intentionally light — pass\n * `className` / `style` to theme it, or rebuild your own UI on the hooks.\n */\n\nimport { type CSSProperties, type ReactNode } from \"react\";\nimport { useConnect, type ConnectKind } from \"../hooks/useConnect\";\nimport { useAccount } from \"../hooks/useAccount\";\n\n/** Props for {@link ConnectButton}. */\nexport interface ConnectButtonProps {\n /**\n * The wallet kinds to offer. With one entry the button connects it directly;\n * with several it renders a button per kind. Defaults to `[\"keplr\"]`.\n */\n wallets?: ConnectKind[];\n /** Optional class applied to the root element. */\n className?: string;\n /** Optional inline styles merged onto the root element. */\n style?: CSSProperties;\n /** Label shown before connecting. Defaults to `\"Connect Wallet\"`. */\n label?: string;\n /** Render-prop override: full control over the rendered UI. */\n children?: (state: ConnectButtonRenderState) => ReactNode;\n}\n\n/** State passed to the {@link ConnectButtonProps.children} render-prop. */\nexport interface ConnectButtonRenderState {\n /** Whether a wallet is connected. */\n isConnected: boolean;\n /** Whether a connection attempt is in flight. */\n isConnecting: boolean;\n /** The connected primary address, if any. */\n address?: string;\n /** Connect a specific wallet kind. */\n connect(kind?: ConnectKind): void;\n /** Disconnect. */\n disconnect(): void;\n /** The last connection error, if any. */\n error?: Error;\n}\n\nconst WALLET_LABEL: Record<ConnectKind, string> = {\n keplr: \"Keplr\",\n leap: \"Leap\",\n evm: \"MetaMask\",\n svm: \"Phantom\",\n};\n\n/** Truncate a long address for compact display (`qor1ab…xyz`). */\nfunction truncate(addr: string): string {\n if (addr.length <= 13) return addr;\n return `${addr.slice(0, 8)}…${addr.slice(-5)}`;\n}\n\nconst baseButtonStyle: CSSProperties = {\n font: \"inherit\",\n padding: \"0.5rem 0.9rem\",\n borderRadius: \"0.5rem\",\n border: \"1px solid currentColor\",\n background: \"transparent\",\n cursor: \"pointer\",\n};\n\n/**\n * A small connect / disconnect control. Single-wallet by default; pass\n * `wallets` for a multi-wallet picker, or `children` for full custom rendering.\n */\nexport function ConnectButton(props: ConnectButtonProps): ReactNode {\n const wallets = props.wallets ?? [\"keplr\"];\n const { connect, disconnect, isConnecting, error } = useConnect();\n const { isConnected, address } = useAccount();\n\n const doConnect = (kind?: ConnectKind): void => {\n void connect({ kind: kind ?? wallets[0] }).catch(() => {\n // The error is surfaced via the hook's `error`; swallow the rejection so\n // an unhandled promise does not bubble out of the click handler.\n });\n };\n\n if (props.children) {\n return props.children({\n isConnected,\n isConnecting,\n address,\n connect: doConnect,\n disconnect,\n error,\n });\n }\n\n if (isConnected && address) {\n return (\n <span className={props.className} style={props.style}>\n <span style={{ marginRight: \"0.5rem\" }}>{truncate(address)}</span>\n <button\n type=\"button\"\n style={baseButtonStyle}\n onClick={() => disconnect()}\n >\n Disconnect\n </button>\n </span>\n );\n }\n\n const label = props.label ?? \"Connect Wallet\";\n\n return (\n <span className={props.className} style={props.style}>\n {wallets.length === 1 ? (\n <button\n type=\"button\"\n style={baseButtonStyle}\n disabled={isConnecting}\n onClick={() => doConnect(wallets[0])}\n >\n {isConnecting ? \"Connecting…\" : label}\n </button>\n ) : (\n wallets.map((kind) => (\n <button\n key={kind}\n type=\"button\"\n style={{ ...baseButtonStyle, marginRight: \"0.4rem\" }}\n disabled={isConnecting}\n onClick={() => doConnect(kind)}\n >\n {WALLET_LABEL[kind]}\n </button>\n ))\n )}\n </span>\n );\n}\n","/**\n * {@link QuantumSafeBadge} — a \"Quantum-safe\" indicator for an address.\n *\n * Reads the address's PQC registration via {@link usePqcStatus} and renders a\n * compact badge: a positive \"Quantum-safe\" state when a PQC key is registered,\n * otherwise a muted \"Not quantum-safe\" state (or nothing, with\n * `hideWhenUnsafe`). Styling is minimal; theme it via `className` / `style` or\n * supply a `children` render-prop.\n */\n\nimport { type CSSProperties, type ReactNode } from \"react\";\nimport { usePqcStatus } from \"../hooks/usePqcStatus\";\n\n/** Props for {@link QuantumSafeBadge}. */\nexport interface QuantumSafeBadgeProps {\n /** Address to check. Defaults to the connected account. */\n address?: string;\n /** When `true`, render nothing if the address is not quantum-safe. */\n hideWhenUnsafe?: boolean;\n /** Label for the safe state. Defaults to `\"Quantum-safe\"`. */\n safeLabel?: string;\n /** Label for the unsafe state. Defaults to `\"Not quantum-safe\"`. */\n unsafeLabel?: string;\n /** Optional class applied to the root element. */\n className?: string;\n /** Optional inline styles merged onto the root element. */\n style?: CSSProperties;\n /** Render-prop override for full control over the rendered UI. */\n children?: (state: QuantumSafeRenderState) => ReactNode;\n}\n\n/** State passed to the {@link QuantumSafeBadgeProps.children} render-prop. */\nexport interface QuantumSafeRenderState {\n /** Whether the address has a registered PQC key. */\n isRegistered: boolean;\n /** Whether the status is still loading. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n}\n\nconst baseStyle: CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"0.35rem\",\n font: \"inherit\",\n fontSize: \"0.85em\",\n padding: \"0.15rem 0.55rem\",\n borderRadius: \"999px\",\n border: \"1px solid currentColor\",\n lineHeight: 1.4,\n};\n\n/**\n * A badge showing whether an address is quantum-safe (has a registered PQC key).\n */\nexport function QuantumSafeBadge(props: QuantumSafeBadgeProps): ReactNode {\n const { isRegistered, isLoading, error } = usePqcStatus(props.address);\n\n if (props.children) {\n return props.children({ isRegistered, isLoading, error });\n }\n\n if (isLoading && !isRegistered) {\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, opacity: 0.6, ...props.style }}\n data-quantum-safe=\"loading\"\n >\n Checking…\n </span>\n );\n }\n\n if (!isRegistered) {\n if (props.hideWhenUnsafe) return null;\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, opacity: 0.7, ...props.style }}\n data-quantum-safe=\"false\"\n title=\"No post-quantum key registered for this address\"\n >\n <span aria-hidden=\"true\">○</span>\n {props.unsafeLabel ?? \"Not quantum-safe\"}\n </span>\n );\n }\n\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, ...props.style }}\n data-quantum-safe=\"true\"\n title=\"Post-quantum (ML-DSA-87) key registered — transactions can be hybrid-signed\"\n >\n <span aria-hidden=\"true\">🛡️</span>\n {props.safeLabel ?? \"Quantum-safe\"}\n </span>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/context.tsx","../src/hooks/useQoreClient.ts","../src/hooks/useAccount.ts","../src/hooks/useBalance.ts","../src/hooks/useConnect.ts","../src/hooks/useTx.ts","../src/hooks/usePqcStatus.ts","../src/components/ConnectButton.tsx","../src/components/QuantumSafeBadge.tsx"],"names":["createContext","useMemo","createClient","useState","useRef","useCallback","jsx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KAAA,EAAO,EAAE,GAAG,SAAA,EAAW,SAAS,GAAA,EAAK,GAAG,MAAM,KAAA,EAAM;AAAA,QACpD,mBAAA,EAAkB,SAAA;AAAA,QACnB,QAAA,EAAA;AAAA;AAAA,KAED;AAAA,EAEJ;AAEA,EAAA,IAAI,CAAC,YAAA,EAAc;AACjB,IAAA,IAAI,KAAA,CAAM,gBAAgB,OAAO,IAAA;AACjC,IAAA,uBACEM,eAAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,WAAW,KAAA,CAAM,SAAA;AAAA,QACjB,KAAA,EAAO,EAAE,GAAG,SAAA,EAAW,SAAS,GAAA,EAAK,GAAG,MAAM,KAAA,EAAM;AAAA,QACpD,mBAAA,EAAkB,OAAA;AAAA,QAClB,KAAA,EAAM,iDAAA;AAAA,QAEN,QAAA,EAAA;AAAA,0BAAAN,cAAAA,CAAC,MAAA,EAAA,EAAK,aAAA,EAAY,MAAA,EAAO,QAAA,EAAA,QAAA,EAAC,CAAA;AAAA,UACzB,MAAM,WAAA,IAAe;AAAA;AAAA;AAAA,KACxB;AAAA,EAEJ;AAEA,EAAA,uBACEM,eAAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,WAAW,KAAA,CAAM,SAAA;AAAA,MACjB,OAAO,EAAE,GAAG,SAAA,EAAW,GAAG,MAAM,KAAA,EAAM;AAAA,MACtC,mBAAA,EAAkB,MAAA;AAAA,MAClB,KAAA,EAAM,kFAAA;AAAA,MAEN,QAAA,EAAA;AAAA,wBAAAN,cAAAA,CAAC,MAAA,EAAA,EAAK,aAAA,EAAY,MAAA,EAAO,QAAA,EAAA,iBAAA,EAAG,CAAA;AAAA,QAC3B,MAAM,SAAA,IAAa;AAAA;AAAA;AAAA,GACtB;AAEJ","file":"index.cjs","sourcesContent":["/**\n * The QoreChain React context: a {@link QoreChainProvider} that holds a single\n * composed {@link QoreChainClient} (from `@qorechain/sdk`'s {@link createClient})\n * plus the live wallet connection state, and the {@link useQoreContext} hook the\n * other hooks build on.\n *\n * One provider near the root of the app is enough; every hook\n * ({@link useQoreClient}, {@link useAccount}, {@link useBalance},\n * {@link useConnect}, {@link useTx}, {@link usePqcStatus}) reads from it.\n */\n\nimport {\n createContext,\n useContext,\n useMemo,\n useRef,\n useState,\n useCallback,\n type ReactNode,\n} from \"react\";\nimport {\n createClient,\n type QoreChainClient,\n type CreateClientOptions,\n type TxClient,\n} from \"@qorechain/sdk\";\n\n/** A connected wallet's resolved addresses, by VM family. */\nexport interface ConnectedAddresses {\n /** Native bech32 (`qor1...`) address, when a Native wallet is connected. */\n native?: string;\n /** EVM (`0x...`) address, when an EVM wallet is connected. */\n evm?: string;\n /** SVM (base58) address, when an SVM wallet is connected. */\n svm?: string;\n}\n\n/** The live connection status of the provider. */\nexport type ConnectionStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"error\";\n\n/** Which wallet family is connected. */\nexport type ConnectedWalletKind = \"keplr\" | \"leap\" | \"evm\" | \"svm\";\n\n/** The full context value exposed by {@link QoreChainProvider}. */\nexport interface QoreContextValue {\n /** The composed read client (created once from the provider config). */\n client: QoreChainClient;\n /** Current connection status. */\n status: ConnectionStatus;\n /** The connected addresses, keyed by VM family. Empty when disconnected. */\n addresses: ConnectedAddresses;\n /** Which wallet is connected, if any. */\n wallet?: ConnectedWalletKind;\n /** The connected signing client, if any (set by `useConnect`). */\n tx?: TxClient;\n /** The last connection error, if `status === \"error\"`. */\n error?: Error;\n /**\n * Internal: replace the connection state. Used by {@link useConnect}; apps use\n * the hooks rather than calling this directly.\n */\n setConnection(next: {\n status: ConnectionStatus;\n addresses?: ConnectedAddresses;\n wallet?: ConnectedWalletKind;\n tx?: TxClient;\n error?: Error;\n }): void;\n}\n\n/** Configuration for {@link QoreChainProvider}, forwarded to `createClient`. */\nexport interface QoreChainProviderConfig {\n /** Network preset to target. Defaults to `\"testnet\"`. */\n network?: CreateClientOptions[\"network\"];\n /** Endpoint overrides merged over the preset's defaults. */\n endpoints?: CreateClientOptions[\"endpoints\"];\n /** Chain id override. */\n chainId?: CreateClientOptions[\"chainId\"];\n /** Additional HTTP transport options shared by the read clients. */\n http?: CreateClientOptions[\"http\"];\n}\n\n/** Props for {@link QoreChainProvider}. */\nexport interface QoreChainProviderProps {\n /** Network + endpoint configuration for the underlying read client. */\n config: QoreChainProviderConfig;\n /**\n * A pre-built client to use instead of constructing one from `config`. Useful\n * for tests (inject a mocked client) and advanced composition.\n */\n client?: QoreChainClient;\n /** The app subtree that consumes the QoreChain hooks. */\n children: ReactNode;\n}\n\nconst QoreContext = createContext<QoreContextValue | null>(null);\n\n/**\n * Provide a single composed QoreChain client + connection state to the subtree.\n *\n * The client is created once (memoized on the config identity), so place the\n * provider above any component that uses the hooks. Pass `client` to inject a\n * pre-built (or mocked) client instead.\n */\nexport function QoreChainProvider(props: QoreChainProviderProps): ReactNode {\n const { config, client: injected, children } = props;\n\n // Build the read client once. When `injected` is provided it always wins.\n // The config object is treated as stable for the provider's lifetime; callers\n // that need to switch networks should remount the provider with a new `key`.\n // Memoize on the config's primitive fields so a new (but equal) config object\n // identity does not rebuild the client every render.\n const { network, chainId } = config;\n const endpoints = config.endpoints;\n const http = config.http;\n const client = useMemo<QoreChainClient>(() => {\n if (injected) return injected;\n return createClient({ network, endpoints, chainId, http });\n }, [injected, network, chainId, endpoints, http]);\n\n const [status, setStatus] = useState<ConnectionStatus>(\"disconnected\");\n const [addresses, setAddresses] = useState<ConnectedAddresses>({});\n const [wallet, setWallet] = useState<ConnectedWalletKind | undefined>(\n undefined,\n );\n const [error, setError] = useState<Error | undefined>(undefined);\n // The TxClient is not React state we render off of; keep it in a ref but mirror\n // a setter for hooks. We store it in state too so `useTx` re-renders on connect.\n const txRef = useRef<TxClient | undefined>(undefined);\n const [tx, setTx] = useState<TxClient | undefined>(undefined);\n\n const setConnection = useCallback<QoreContextValue[\"setConnection\"]>(\n (next) => {\n setStatus(next.status);\n setAddresses(next.addresses ?? {});\n setWallet(next.wallet);\n txRef.current = next.tx;\n setTx(next.tx);\n setError(next.error);\n },\n [],\n );\n\n const value = useMemo<QoreContextValue>(\n () => ({ client, status, addresses, wallet, tx, error, setConnection }),\n [client, status, addresses, wallet, tx, error, setConnection],\n );\n\n return <QoreContext.Provider value={value}>{children}</QoreContext.Provider>;\n}\n\n/**\n * Read the raw {@link QoreContextValue}. Throws when used outside a\n * {@link QoreChainProvider}. Most apps use the purpose-built hooks instead.\n */\nexport function useQoreContext(): QoreContextValue {\n const ctx = useContext(QoreContext);\n if (!ctx) {\n throw new Error(\n \"useQoreContext: no QoreChainProvider found. Wrap your app in <QoreChainProvider config={...}>.\",\n );\n }\n return ctx;\n}\n","/**\n * {@link useQoreClient} — the composed read client held by the provider.\n */\n\nimport type { QoreChainClient } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/**\n * Return the {@link QoreChainClient} created by the nearest\n * {@link QoreChainProvider}. Use it for ad-hoc reads (`client.rest`,\n * `client.qor`, `client.fees`, ...) not already covered by a dedicated hook.\n */\nexport function useQoreClient(): QoreChainClient {\n return useQoreContext().client;\n}\n","/**\n * {@link useAccount} — the connected wallet's addresses and status.\n */\n\nimport { useQoreContext } from \"../context\";\nimport type {\n ConnectedAddresses,\n ConnectionStatus,\n ConnectedWalletKind,\n} from \"../context\";\n\n/** The shape returned by {@link useAccount}. */\nexport interface UseAccountResult {\n /** All connected addresses, by VM family (native / evm / svm). */\n addresses: ConnectedAddresses;\n /** The primary address (native preferred, then evm, then svm), if any. */\n address?: string;\n /** Whether a wallet is connected. */\n isConnected: boolean;\n /** The current connection status. */\n status: ConnectionStatus;\n /** Which wallet is connected, if any. */\n wallet?: ConnectedWalletKind;\n}\n\n/**\n * Return the connected account's address(es) — native (bech32), EVM (`0x...`),\n * and/or SVM (base58) — plus a convenience primary `address` and connection\n * status. Empty until a wallet is connected via {@link useConnect}.\n */\nexport function useAccount(): UseAccountResult {\n const { addresses, status, wallet } = useQoreContext();\n const address = addresses.native ?? addresses.evm ?? addresses.svm;\n return {\n addresses,\n address,\n isConnected: status === \"connected\" && address !== undefined,\n status,\n wallet,\n };\n}\n","/**\n * {@link useBalance} — a bank balance with optional auto-refresh.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { Coin } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** Options for {@link useBalance}. */\nexport interface UseBalanceOptions {\n /**\n * The denom to read. Defaults to the network's base denom (e.g. `uqor`).\n */\n denom?: string;\n /**\n * Auto-refresh interval in milliseconds. `0` (the default) disables polling;\n * the balance is then fetched once on mount / address change.\n */\n refreshInterval?: number;\n /** Skip fetching entirely (e.g. while disconnected). Defaults to `false`. */\n enabled?: boolean;\n}\n\n/** The shape returned by {@link useBalance}. */\nexport interface UseBalanceResult {\n /** The balance coin (`{ denom, amount }`), once loaded. */\n data?: Coin;\n /** Whether a fetch is in flight. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n /** Manually re-fetch the balance. */\n refetch(): Promise<void>;\n}\n\n/**\n * Read the bank balance of `address` (or the connected account when omitted) in\n * a denom. Re-fetches on address / denom change and, when `refreshInterval > 0`,\n * polls on that interval. Returns `{ data, isLoading, error, refetch }`.\n */\nexport function useBalance(\n address?: string,\n options: UseBalanceOptions = {},\n): UseBalanceResult {\n const { client, addresses } = useQoreContext();\n const resolvedAddress = address ?? addresses.native;\n const denom = options.denom ?? client.network.coin.base;\n const refreshInterval = options.refreshInterval ?? 0;\n const enabled = options.enabled ?? true;\n\n const [data, setData] = useState<Coin | undefined>(undefined);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n // Guard against setting state after unmount / stale responses.\n const activeRef = useRef(true);\n useEffect(() => {\n activeRef.current = true;\n return () => {\n activeRef.current = false;\n };\n }, []);\n\n const refetch = useCallback(async (): Promise<void> => {\n if (!resolvedAddress || !enabled) return;\n setIsLoading(true);\n setError(undefined);\n try {\n const res = await client.rest.getBalance(resolvedAddress, denom);\n if (activeRef.current) {\n setData(res.balance ?? { denom, amount: \"0\" });\n }\n } catch (err) {\n if (activeRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n } finally {\n if (activeRef.current) setIsLoading(false);\n }\n }, [client, resolvedAddress, denom, enabled]);\n\n useEffect(() => {\n void refetch();\n if (refreshInterval > 0 && resolvedAddress && enabled) {\n const id = setInterval(() => {\n void refetch();\n }, refreshInterval);\n return () => clearInterval(id);\n }\n return undefined;\n }, [refetch, refreshInterval, resolvedAddress, enabled]);\n\n return { data, isLoading, error, refetch };\n}\n","/**\n * {@link useConnect} / {@link useWallet} — multi-wallet connect.\n *\n * Wraps the EXISTING wallet adapters so a component connects with one call and\n * the resolved signer + addresses land in the provider's connection state:\n * - Keplr / Leap (Native) via `@qorechain/sdk`'s {@link getCosmosWallet}, which\n * suggests + enables the chain and returns a CosmJS signer; the signer is\n * connected through `client.connectTx` so `useTx` can sign.\n * - MetaMask / any EIP-1193 wallet (EVM) via `eth_requestAccounts` on the\n * injected provider (`window.ethereum` by default).\n * - Phantom / Wallet-Standard (SVM) via the injected Solana provider\n * (`window.solana`); returns the connected base58 address.\n *\n * The hook keeps its dependencies light: the EVM and SVM paths talk to the\n * injected provider's standard request API directly, so neither viem nor a\n * Solana SDK is pulled in. For full EVM/SVM tooling, use `@qorechain/evm` /\n * `@qorechain/svm` alongside this hook.\n */\n\nimport { useCallback } from \"react\";\nimport {\n getCosmosWallet,\n type CosmosWalletName,\n} from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\nimport type { ConnectedWalletKind } from \"../context\";\n\n/** A minimal EIP-1193 provider surface (MetaMask et al.). */\nexport interface Eip1193Like {\n request(args: { method: string; params?: unknown[] }): Promise<unknown>;\n}\n\n/** A minimal injected Solana provider surface (Phantom / Wallet-Standard). */\nexport interface SolanaProviderLike {\n connect(): Promise<{ publicKey: { toString(): string } }>;\n publicKey?: { toString(): string } | null;\n}\n\n/** Which wallet to connect via {@link UseConnectResult.connect}. */\nexport type ConnectKind = \"keplr\" | \"leap\" | \"evm\" | \"svm\";\n\n/** Options for a single {@link UseConnectResult.connect} call. */\nexport interface ConnectOptions {\n /** Which wallet to connect. Defaults to `\"keplr\"`. */\n kind?: ConnectKind;\n /**\n * Inject the wallet provider directly instead of reading it off `window`\n * (primarily for tests). The accepted shape depends on `kind`.\n */\n provider?: unknown;\n /** Use Amino signing for the Native path (forwarded to `getCosmosWallet`). */\n preferAmino?: boolean;\n}\n\n/** The shape returned by {@link useConnect} / {@link useWallet}. */\nexport interface UseConnectResult {\n /** Connect a wallet; updates the provider's connection state. */\n connect(opts?: ConnectOptions): Promise<void>;\n /** Disconnect: clears the connection state. */\n disconnect(): void;\n /** The current connection status. */\n status: ReturnType<typeof useQoreContext>[\"status\"];\n /** Whether a connection attempt is in flight. */\n isConnecting: boolean;\n /** The last connection error, if any. */\n error?: Error;\n}\n\nfunction getWindow(): Record<string, unknown> | undefined {\n return typeof window === \"undefined\"\n ? undefined\n : (window as unknown as Record<string, unknown>);\n}\n\n/**\n * Multi-wallet connect bound to the {@link QoreChainProvider}.\n *\n * On success the provider's connection state holds the resolved addresses, the\n * connected wallet kind, and (for Native) a `TxClient` for signing.\n */\nexport function useConnect(): UseConnectResult {\n const ctx = useQoreContext();\n const { client, status, error, setConnection } = ctx;\n\n const connect = useCallback(\n async (opts: ConnectOptions = {}): Promise<void> => {\n const kind: ConnectKind = opts.kind ?? \"keplr\";\n setConnection({ status: \"connecting\", addresses: ctx.addresses });\n\n try {\n if (kind === \"keplr\" || kind === \"leap\") {\n const conn = await getCosmosWallet({\n wallet: kind as CosmosWalletName,\n network: client.network,\n provider: opts.provider as never,\n preferAmino: opts.preferAmino,\n });\n const native = conn.accounts[0]?.address;\n const tx = await client.connectTx(conn.signer as never);\n setConnection({\n status: \"connected\",\n addresses: { native },\n wallet: kind as ConnectedWalletKind,\n tx,\n });\n return;\n }\n\n if (kind === \"evm\") {\n const provider = (opts.provider ??\n getWindow()?.ethereum) as Eip1193Like | undefined;\n if (!provider) {\n throw new Error(\n \"useConnect(evm): no EIP-1193 provider found (window.ethereum). Install MetaMask, or pass `provider`.\",\n );\n }\n const accounts = (await provider.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n const evm = accounts?.[0];\n if (!evm) throw new Error(\"useConnect(evm): no account returned\");\n setConnection({\n status: \"connected\",\n addresses: { evm },\n wallet: \"evm\",\n });\n return;\n }\n\n // kind === \"svm\"\n const provider = (opts.provider ??\n getWindow()?.solana) as SolanaProviderLike | undefined;\n if (!provider) {\n throw new Error(\n \"useConnect(svm): no Solana / Wallet-Standard provider found (window.solana). Install Phantom, or pass `provider`.\",\n );\n }\n const { publicKey } = await provider.connect();\n const svm = publicKey?.toString();\n if (!svm) throw new Error(\"useConnect(svm): no public key returned\");\n setConnection({\n status: \"connected\",\n addresses: { svm },\n wallet: \"svm\",\n });\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setConnection({ status: \"error\", error: e });\n throw e;\n }\n },\n [client, ctx.addresses, setConnection],\n );\n\n const disconnect = useCallback((): void => {\n setConnection({ status: \"disconnected\", addresses: {} });\n }, [setConnection]);\n\n return {\n connect,\n disconnect,\n status,\n isConnecting: status === \"connecting\",\n error,\n };\n}\n\n/** Alias for {@link useConnect} — the multi-wallet connect hook. */\nexport const useWallet = useConnect;\n","/**\n * {@link useTx} — send a transaction and track its status.\n */\n\nimport { useCallback, useState } from \"react\";\nimport type {\n EncodeObject,\n BroadcastResult,\n TxFeeInput,\n Coin,\n} from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** The lifecycle status of a {@link useTx} send. */\nexport type TxStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Options for {@link UseTxResult.send}. */\nexport interface SendOptions {\n /** Fee: an explicit `StdFee` or `\"auto\"`. Default `\"auto\"`. */\n fee?: TxFeeInput;\n /** Optional memo. */\n memo?: string;\n}\n\n/** The shape returned by {@link useTx}. */\nexport interface UseTxResult {\n /** Sign + broadcast arbitrary messages with the connected signer. */\n send(messages: EncodeObject[], opts?: SendOptions): Promise<BroadcastResult>;\n /** Convenience: send a bank transfer of `amount` to `toAddress`. */\n sendTokens(\n toAddress: string,\n amount: Coin[],\n opts?: SendOptions,\n ): Promise<BroadcastResult>;\n /** The current send status. */\n status: TxStatus;\n /** The last broadcast result, on success. */\n data?: BroadcastResult;\n /** The last error, on failure. */\n error?: Error;\n /** Whether a send is in flight. */\n isPending: boolean;\n /** Reset status/data/error back to idle. */\n reset(): void;\n}\n\n/**\n * Send transactions with the connected signer and track `{ status, data, error }`.\n *\n * Requires a connected wallet that produced a `TxClient` (the Native path of\n * {@link useConnect}). `send` takes raw `{ typeUrl, value }` messages (use the\n * `msg.*` composers from `@qorechain/sdk`); `sendTokens` is a bank-transfer\n * shortcut.\n */\nexport function useTx(): UseTxResult {\n const { tx } = useQoreContext();\n const [status, setStatus] = useState<TxStatus>(\"idle\");\n const [data, setData] = useState<BroadcastResult | undefined>(undefined);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n const requireTx = useCallback(() => {\n if (!tx) {\n throw new Error(\n \"useTx: no connected signer. Connect a Native wallet (Keplr/Leap) via useConnect() first.\",\n );\n }\n return tx;\n }, [tx]);\n\n const run = useCallback(\n async (fn: () => Promise<BroadcastResult>): Promise<BroadcastResult> => {\n setStatus(\"pending\");\n setError(undefined);\n try {\n const res = await fn();\n setData(res);\n setStatus(\"success\");\n return res;\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setError(e);\n setStatus(\"error\");\n throw e;\n }\n },\n [],\n );\n\n const send = useCallback(\n (messages: EncodeObject[], opts: SendOptions = {}) =>\n run(() =>\n requireTx().signAndBroadcast(messages, opts.fee ?? \"auto\", opts.memo ?? \"\"),\n ),\n [run, requireTx],\n );\n\n const sendTokens = useCallback(\n (toAddress: string, amount: Coin[], opts: SendOptions = {}) =>\n run(() =>\n requireTx().bankSend(toAddress, amount, {\n fee: opts.fee ?? \"auto\",\n memo: opts.memo ?? \"\",\n }),\n ),\n [run, requireTx],\n );\n\n const reset = useCallback(() => {\n setStatus(\"idle\");\n setData(undefined);\n setError(undefined);\n }, []);\n\n return {\n send,\n sendTokens,\n status,\n data,\n error,\n isPending: status === \"pending\",\n reset,\n };\n}\n","/**\n * {@link usePqcStatus} — read an address's quantum-safe (PQC) registration state.\n *\n * Built on the SDK's quantum-safe DX helpers ({@link getPqcStatus} /\n * {@link isPqcRegistered}), which call `qor_getPQCKeyStatus`. Powers the\n * {@link QuantumSafeBadge} component.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { getPqcStatus, type PqcStatus } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** Options for {@link usePqcStatus}. */\nexport interface UsePqcStatusOptions {\n /** Skip fetching (e.g. while disconnected). Defaults to `false`. */\n enabled?: boolean;\n /**\n * Auto-refresh interval in milliseconds. `0` (default) disables polling; the\n * status is fetched once per address change.\n */\n refreshInterval?: number;\n}\n\n/** The shape returned by {@link usePqcStatus}. */\nexport interface UsePqcStatusResult {\n /** The normalized PQC status, once loaded. */\n data?: PqcStatus;\n /** Whether the address has a registered PQC key (convenience). */\n isRegistered: boolean;\n /** Whether a fetch is in flight. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n /** Manually re-fetch the status. */\n refetch(): Promise<void>;\n}\n\n/**\n * Read whether `address` (or the connected account when omitted) is quantum-safe\n * — i.e. has a registered PQC key on QoreChain. Returns\n * `{ data, isRegistered, isLoading, error, refetch }`.\n */\nexport function usePqcStatus(\n address?: string,\n options: UsePqcStatusOptions = {},\n): UsePqcStatusResult {\n const { client, addresses } = useQoreContext();\n const resolvedAddress = address ?? addresses.native ?? addresses.evm;\n const enabled = options.enabled ?? true;\n const refreshInterval = options.refreshInterval ?? 0;\n\n const [data, setData] = useState<PqcStatus | undefined>(undefined);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n const activeRef = useRef(true);\n useEffect(() => {\n activeRef.current = true;\n return () => {\n activeRef.current = false;\n };\n }, []);\n\n const refetch = useCallback(async (): Promise<void> => {\n if (!resolvedAddress || !enabled) return;\n setIsLoading(true);\n setError(undefined);\n try {\n const status = await getPqcStatus(client, resolvedAddress);\n if (activeRef.current) setData(status);\n } catch (err) {\n if (activeRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n } finally {\n if (activeRef.current) setIsLoading(false);\n }\n }, [client, resolvedAddress, enabled]);\n\n useEffect(() => {\n void refetch();\n if (refreshInterval > 0 && resolvedAddress && enabled) {\n const id = setInterval(() => {\n void refetch();\n }, refreshInterval);\n return () => clearInterval(id);\n }\n return undefined;\n }, [refetch, refreshInterval, resolvedAddress, enabled]);\n\n return {\n data,\n isRegistered: data?.registered ?? false,\n isLoading,\n error,\n refetch,\n };\n}\n","/**\n * {@link ConnectButton} — a minimal, headless-ish multi-wallet connect control.\n *\n * Renders a connect button (or a small picker when multiple wallet kinds are\n * offered) wired to {@link useConnect}; once connected it shows the truncated\n * address and a disconnect action. Styling is intentionally light — pass\n * `className` / `style` to theme it, or rebuild your own UI on the hooks.\n */\n\nimport { type CSSProperties, type ReactNode } from \"react\";\nimport { useConnect, type ConnectKind } from \"../hooks/useConnect\";\nimport { useAccount } from \"../hooks/useAccount\";\n\n/** Props for {@link ConnectButton}. */\nexport interface ConnectButtonProps {\n /**\n * The wallet kinds to offer. With one entry the button connects it directly;\n * with several it renders a button per kind. Defaults to `[\"keplr\"]`.\n */\n wallets?: ConnectKind[];\n /** Optional class applied to the root element. */\n className?: string;\n /** Optional inline styles merged onto the root element. */\n style?: CSSProperties;\n /** Label shown before connecting. Defaults to `\"Connect Wallet\"`. */\n label?: string;\n /** Render-prop override: full control over the rendered UI. */\n children?: (state: ConnectButtonRenderState) => ReactNode;\n}\n\n/** State passed to the {@link ConnectButtonProps.children} render-prop. */\nexport interface ConnectButtonRenderState {\n /** Whether a wallet is connected. */\n isConnected: boolean;\n /** Whether a connection attempt is in flight. */\n isConnecting: boolean;\n /** The connected primary address, if any. */\n address?: string;\n /** Connect a specific wallet kind. */\n connect(kind?: ConnectKind): void;\n /** Disconnect. */\n disconnect(): void;\n /** The last connection error, if any. */\n error?: Error;\n}\n\nconst WALLET_LABEL: Record<ConnectKind, string> = {\n keplr: \"Keplr\",\n leap: \"Leap\",\n evm: \"MetaMask\",\n svm: \"Phantom\",\n};\n\n/** Truncate a long address for compact display (`qor1ab…xyz`). */\nfunction truncate(addr: string): string {\n if (addr.length <= 13) return addr;\n return `${addr.slice(0, 8)}…${addr.slice(-5)}`;\n}\n\nconst baseButtonStyle: CSSProperties = {\n font: \"inherit\",\n padding: \"0.5rem 0.9rem\",\n borderRadius: \"0.5rem\",\n border: \"1px solid currentColor\",\n background: \"transparent\",\n cursor: \"pointer\",\n};\n\n/**\n * A small connect / disconnect control. Single-wallet by default; pass\n * `wallets` for a multi-wallet picker, or `children` for full custom rendering.\n */\nexport function ConnectButton(props: ConnectButtonProps): ReactNode {\n const wallets = props.wallets ?? [\"keplr\"];\n const { connect, disconnect, isConnecting, error } = useConnect();\n const { isConnected, address } = useAccount();\n\n const doConnect = (kind?: ConnectKind): void => {\n void connect({ kind: kind ?? wallets[0] }).catch(() => {\n // The error is surfaced via the hook's `error`; swallow the rejection so\n // an unhandled promise does not bubble out of the click handler.\n });\n };\n\n if (props.children) {\n return props.children({\n isConnected,\n isConnecting,\n address,\n connect: doConnect,\n disconnect,\n error,\n });\n }\n\n if (isConnected && address) {\n return (\n <span className={props.className} style={props.style}>\n <span style={{ marginRight: \"0.5rem\" }}>{truncate(address)}</span>\n <button\n type=\"button\"\n style={baseButtonStyle}\n onClick={() => disconnect()}\n >\n Disconnect\n </button>\n </span>\n );\n }\n\n const label = props.label ?? \"Connect Wallet\";\n\n return (\n <span className={props.className} style={props.style}>\n {wallets.length === 1 ? (\n <button\n type=\"button\"\n style={baseButtonStyle}\n disabled={isConnecting}\n onClick={() => doConnect(wallets[0])}\n >\n {isConnecting ? \"Connecting…\" : label}\n </button>\n ) : (\n wallets.map((kind) => (\n <button\n key={kind}\n type=\"button\"\n style={{ ...baseButtonStyle, marginRight: \"0.4rem\" }}\n disabled={isConnecting}\n onClick={() => doConnect(kind)}\n >\n {WALLET_LABEL[kind]}\n </button>\n ))\n )}\n </span>\n );\n}\n","/**\n * {@link QuantumSafeBadge} — a \"Quantum-safe\" indicator for an address.\n *\n * Reads the address's PQC registration via {@link usePqcStatus} and renders a\n * compact badge: a positive \"Quantum-safe\" state when a PQC key is registered,\n * otherwise a muted \"Not quantum-safe\" state (or nothing, with\n * `hideWhenUnsafe`). Styling is minimal; theme it via `className` / `style` or\n * supply a `children` render-prop.\n */\n\nimport { type CSSProperties, type ReactNode } from \"react\";\nimport { usePqcStatus } from \"../hooks/usePqcStatus\";\n\n/** Props for {@link QuantumSafeBadge}. */\nexport interface QuantumSafeBadgeProps {\n /** Address to check. Defaults to the connected account. */\n address?: string;\n /** When `true`, render nothing if the address is not quantum-safe. */\n hideWhenUnsafe?: boolean;\n /** Label for the safe state. Defaults to `\"Quantum-safe\"`. */\n safeLabel?: string;\n /** Label for the unsafe state. Defaults to `\"Not quantum-safe\"`. */\n unsafeLabel?: string;\n /** Optional class applied to the root element. */\n className?: string;\n /** Optional inline styles merged onto the root element. */\n style?: CSSProperties;\n /** Render-prop override for full control over the rendered UI. */\n children?: (state: QuantumSafeRenderState) => ReactNode;\n}\n\n/** State passed to the {@link QuantumSafeBadgeProps.children} render-prop. */\nexport interface QuantumSafeRenderState {\n /** Whether the address has a registered PQC key. */\n isRegistered: boolean;\n /** Whether the status is still loading. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n}\n\nconst baseStyle: CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"0.35rem\",\n font: \"inherit\",\n fontSize: \"0.85em\",\n padding: \"0.15rem 0.55rem\",\n borderRadius: \"999px\",\n border: \"1px solid currentColor\",\n lineHeight: 1.4,\n};\n\n/**\n * A badge showing whether an address is quantum-safe (has a registered PQC key).\n */\nexport function QuantumSafeBadge(props: QuantumSafeBadgeProps): ReactNode {\n const { isRegistered, isLoading, error } = usePqcStatus(props.address);\n\n if (props.children) {\n return props.children({ isRegistered, isLoading, error });\n }\n\n if (isLoading && !isRegistered) {\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, opacity: 0.6, ...props.style }}\n data-quantum-safe=\"loading\"\n >\n Checking…\n </span>\n );\n }\n\n if (!isRegistered) {\n if (props.hideWhenUnsafe) return null;\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, opacity: 0.7, ...props.style }}\n data-quantum-safe=\"false\"\n title=\"No post-quantum key registered for this address\"\n >\n <span aria-hidden=\"true\">○</span>\n {props.unsafeLabel ?? \"Not quantum-safe\"}\n </span>\n );\n }\n\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, ...props.style }}\n data-quantum-safe=\"true\"\n title=\"Post-quantum (ML-DSA-87) key registered — transactions can be hybrid-signed\"\n >\n <span aria-hidden=\"true\">🛡️</span>\n {props.safeLabel ?? \"Quantum-safe\"}\n </span>\n );\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -14,7 +14,7 @@ import { CreateClientOptions, QoreChainClient, TxClient, Coin, TxFeeInput, Encod
|
|
|
14
14
|
|
|
15
15
|
/** A connected wallet's resolved addresses, by VM family. */
|
|
16
16
|
interface ConnectedAddresses {
|
|
17
|
-
/** Native bech32 (`qor1...`) address, when a
|
|
17
|
+
/** Native bech32 (`qor1...`) address, when a Native wallet is connected. */
|
|
18
18
|
native?: string;
|
|
19
19
|
/** EVM (`0x...`) address, when an EVM wallet is connected. */
|
|
20
20
|
evm?: string;
|
|
@@ -164,7 +164,7 @@ declare function useBalance(address?: string, options?: UseBalanceOptions): UseB
|
|
|
164
164
|
*
|
|
165
165
|
* Wraps the EXISTING wallet adapters so a component connects with one call and
|
|
166
166
|
* the resolved signer + addresses land in the provider's connection state:
|
|
167
|
-
* - Keplr / Leap (
|
|
167
|
+
* - Keplr / Leap (Native) via `@qorechain/sdk`'s {@link getCosmosWallet}, which
|
|
168
168
|
* suggests + enables the chain and returns a CosmJS signer; the signer is
|
|
169
169
|
* connected through `client.connectTx` so `useTx` can sign.
|
|
170
170
|
* - MetaMask / any EIP-1193 wallet (EVM) via `eth_requestAccounts` on the
|
|
@@ -207,7 +207,7 @@ interface ConnectOptions {
|
|
|
207
207
|
* (primarily for tests). The accepted shape depends on `kind`.
|
|
208
208
|
*/
|
|
209
209
|
provider?: unknown;
|
|
210
|
-
/** Use Amino signing for the
|
|
210
|
+
/** Use Amino signing for the Native path (forwarded to `getCosmosWallet`). */
|
|
211
211
|
preferAmino?: boolean;
|
|
212
212
|
}
|
|
213
213
|
/** The shape returned by {@link useConnect} / {@link useWallet}. */
|
|
@@ -227,7 +227,7 @@ interface UseConnectResult {
|
|
|
227
227
|
* Multi-wallet connect bound to the {@link QoreChainProvider}.
|
|
228
228
|
*
|
|
229
229
|
* On success the provider's connection state holds the resolved addresses, the
|
|
230
|
-
* connected wallet kind, and (for
|
|
230
|
+
* connected wallet kind, and (for Native) a `TxClient` for signing.
|
|
231
231
|
*/
|
|
232
232
|
declare function useConnect(): UseConnectResult;
|
|
233
233
|
/** Alias for {@link useConnect} — the multi-wallet connect hook. */
|
|
@@ -266,7 +266,7 @@ interface UseTxResult {
|
|
|
266
266
|
/**
|
|
267
267
|
* Send transactions with the connected signer and track `{ status, data, error }`.
|
|
268
268
|
*
|
|
269
|
-
* Requires a connected wallet that produced a `TxClient` (the
|
|
269
|
+
* Requires a connected wallet that produced a `TxClient` (the Native path of
|
|
270
270
|
* {@link useConnect}). `send` takes raw `{ typeUrl, value }` messages (use the
|
|
271
271
|
* `msg.*` composers from `@qorechain/sdk`); `sendTokens` is a bank-transfer
|
|
272
272
|
* shortcut.
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { CreateClientOptions, QoreChainClient, TxClient, Coin, TxFeeInput, Encod
|
|
|
14
14
|
|
|
15
15
|
/** A connected wallet's resolved addresses, by VM family. */
|
|
16
16
|
interface ConnectedAddresses {
|
|
17
|
-
/** Native bech32 (`qor1...`) address, when a
|
|
17
|
+
/** Native bech32 (`qor1...`) address, when a Native wallet is connected. */
|
|
18
18
|
native?: string;
|
|
19
19
|
/** EVM (`0x...`) address, when an EVM wallet is connected. */
|
|
20
20
|
evm?: string;
|
|
@@ -164,7 +164,7 @@ declare function useBalance(address?: string, options?: UseBalanceOptions): UseB
|
|
|
164
164
|
*
|
|
165
165
|
* Wraps the EXISTING wallet adapters so a component connects with one call and
|
|
166
166
|
* the resolved signer + addresses land in the provider's connection state:
|
|
167
|
-
* - Keplr / Leap (
|
|
167
|
+
* - Keplr / Leap (Native) via `@qorechain/sdk`'s {@link getCosmosWallet}, which
|
|
168
168
|
* suggests + enables the chain and returns a CosmJS signer; the signer is
|
|
169
169
|
* connected through `client.connectTx` so `useTx` can sign.
|
|
170
170
|
* - MetaMask / any EIP-1193 wallet (EVM) via `eth_requestAccounts` on the
|
|
@@ -207,7 +207,7 @@ interface ConnectOptions {
|
|
|
207
207
|
* (primarily for tests). The accepted shape depends on `kind`.
|
|
208
208
|
*/
|
|
209
209
|
provider?: unknown;
|
|
210
|
-
/** Use Amino signing for the
|
|
210
|
+
/** Use Amino signing for the Native path (forwarded to `getCosmosWallet`). */
|
|
211
211
|
preferAmino?: boolean;
|
|
212
212
|
}
|
|
213
213
|
/** The shape returned by {@link useConnect} / {@link useWallet}. */
|
|
@@ -227,7 +227,7 @@ interface UseConnectResult {
|
|
|
227
227
|
* Multi-wallet connect bound to the {@link QoreChainProvider}.
|
|
228
228
|
*
|
|
229
229
|
* On success the provider's connection state holds the resolved addresses, the
|
|
230
|
-
* connected wallet kind, and (for
|
|
230
|
+
* connected wallet kind, and (for Native) a `TxClient` for signing.
|
|
231
231
|
*/
|
|
232
232
|
declare function useConnect(): UseConnectResult;
|
|
233
233
|
/** Alias for {@link useConnect} — the multi-wallet connect hook. */
|
|
@@ -266,7 +266,7 @@ interface UseTxResult {
|
|
|
266
266
|
/**
|
|
267
267
|
* Send transactions with the connected signer and track `{ status, data, error }`.
|
|
268
268
|
*
|
|
269
|
-
* Requires a connected wallet that produced a `TxClient` (the
|
|
269
|
+
* Requires a connected wallet that produced a `TxClient` (the Native path of
|
|
270
270
|
* {@link useConnect}). `send` takes raw `{ typeUrl, value }` messages (use the
|
|
271
271
|
* `msg.*` composers from `@qorechain/sdk`); `sendTokens` is a bank-transfer
|
|
272
272
|
* shortcut.
|
package/dist/index.js
CHANGED
|
@@ -199,7 +199,7 @@ function useTx() {
|
|
|
199
199
|
const requireTx = useCallback(() => {
|
|
200
200
|
if (!tx) {
|
|
201
201
|
throw new Error(
|
|
202
|
-
"useTx: no connected signer. Connect a
|
|
202
|
+
"useTx: no connected signer. Connect a Native wallet (Keplr/Leap) via useConnect() first."
|
|
203
203
|
);
|
|
204
204
|
}
|
|
205
205
|
return tx;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context.tsx","../src/hooks/useQoreClient.ts","../src/hooks/useAccount.ts","../src/hooks/useBalance.ts","../src/hooks/useConnect.ts","../src/hooks/useTx.ts","../src/hooks/usePqcStatus.ts","../src/components/ConnectButton.tsx","../src/components/QuantumSafeBadge.tsx"],"names":["useState","useRef","useCallback","provider","useEffect","jsx","jsxs"],"mappings":";;;;;AAmGA,IAAM,WAAA,GAAc,cAAuC,IAAI,CAAA;AASxD,SAAS,kBAAkB,KAAA,EAA0C;AAC1E,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,UAAS,GAAI,KAAA;AAO/C,EAAA,MAAM,EAAE,OAAA,EAAS,OAAA,EAAQ,GAAI,MAAA;AAC7B,EAAA,MAAM,YAAY,MAAA,CAAO,SAAA;AACzB,EAAA,MAAM,OAAO,MAAA,CAAO,IAAA;AACpB,EAAA,MAAM,MAAA,GAAS,QAAyB,MAAM;AAC5C,IAAA,IA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A;AAAA,QAClB,KAAA,EAAM,iDAAA;AAAA,QAEN,QAAA,EAAA;AAAA,0BAAAD,GAAAA,CAAC,MAAA,EAAA,EAAK,aAAA,EAAY,MAAA,EAAO,QAAA,EAAA,QAAA,EAAC,CAAA;AAAA,UACzB,MAAM,WAAA,IAAe;AAAA;AAAA;AAAA,KACxB;AAAA,EAEJ;AAEA,EAAA,uBACEC,IAAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,WAAW,KAAA,CAAM,SAAA;AAAA,MACjB,OAAO,EAAE,GAAG,SAAA,EAAW,GAAG,MAAM,KAAA,EAAM;AAAA,MACtC,mBAAA,EAAkB,MAAA;AAAA,MAClB,KAAA,EAAM,kFAAA;AAAA,MAEN,QAAA,EAAA;AAAA,wBAAAD,GAAAA,CAAC,MAAA,EAAA,EAAK,aAAA,EAAY,MAAA,EAAO,QAAA,EAAA,iBAAA,EAAG,CAAA;AAAA,QAC3B,MAAM,SAAA,IAAa;AAAA;AAAA;AAAA,GACtB;AAEJ","file":"index.js","sourcesContent":["/**\n * The QoreChain React context: a {@link QoreChainProvider} that holds a single\n * composed {@link QoreChainClient} (from `@qorechain/sdk`'s {@link createClient})\n * plus the live wallet connection state, and the {@link useQoreContext} hook the\n * other hooks build on.\n *\n * One provider near the root of the app is enough; every hook\n * ({@link useQoreClient}, {@link useAccount}, {@link useBalance},\n * {@link useConnect}, {@link useTx}, {@link usePqcStatus}) reads from it.\n */\n\nimport {\n createContext,\n useContext,\n useMemo,\n useRef,\n useState,\n useCallback,\n type ReactNode,\n} from \"react\";\nimport {\n createClient,\n type QoreChainClient,\n type CreateClientOptions,\n type TxClient,\n} from \"@qorechain/sdk\";\n\n/** A connected wallet's resolved addresses, by VM family. */\nexport interface ConnectedAddresses {\n /** Native bech32 (`qor1...`) address, when a Cosmos wallet is connected. */\n native?: string;\n /** EVM (`0x...`) address, when an EVM wallet is connected. */\n evm?: string;\n /** SVM (base58) address, when an SVM wallet is connected. */\n svm?: string;\n}\n\n/** The live connection status of the provider. */\nexport type ConnectionStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"error\";\n\n/** Which wallet family is connected. */\nexport type ConnectedWalletKind = \"keplr\" | \"leap\" | \"evm\" | \"svm\";\n\n/** The full context value exposed by {@link QoreChainProvider}. */\nexport interface QoreContextValue {\n /** The composed read client (created once from the provider config). */\n client: QoreChainClient;\n /** Current connection status. */\n status: ConnectionStatus;\n /** The connected addresses, keyed by VM family. Empty when disconnected. */\n addresses: ConnectedAddresses;\n /** Which wallet is connected, if any. */\n wallet?: ConnectedWalletKind;\n /** The connected signing client, if any (set by `useConnect`). */\n tx?: TxClient;\n /** The last connection error, if `status === \"error\"`. */\n error?: Error;\n /**\n * Internal: replace the connection state. Used by {@link useConnect}; apps use\n * the hooks rather than calling this directly.\n */\n setConnection(next: {\n status: ConnectionStatus;\n addresses?: ConnectedAddresses;\n wallet?: ConnectedWalletKind;\n tx?: TxClient;\n error?: Error;\n }): void;\n}\n\n/** Configuration for {@link QoreChainProvider}, forwarded to `createClient`. */\nexport interface QoreChainProviderConfig {\n /** Network preset to target. Defaults to `\"testnet\"`. */\n network?: CreateClientOptions[\"network\"];\n /** Endpoint overrides merged over the preset's defaults. */\n endpoints?: CreateClientOptions[\"endpoints\"];\n /** Chain id override. */\n chainId?: CreateClientOptions[\"chainId\"];\n /** Additional HTTP transport options shared by the read clients. */\n http?: CreateClientOptions[\"http\"];\n}\n\n/** Props for {@link QoreChainProvider}. */\nexport interface QoreChainProviderProps {\n /** Network + endpoint configuration for the underlying read client. */\n config: QoreChainProviderConfig;\n /**\n * A pre-built client to use instead of constructing one from `config`. Useful\n * for tests (inject a mocked client) and advanced composition.\n */\n client?: QoreChainClient;\n /** The app subtree that consumes the QoreChain hooks. */\n children: ReactNode;\n}\n\nconst QoreContext = createContext<QoreContextValue | null>(null);\n\n/**\n * Provide a single composed QoreChain client + connection state to the subtree.\n *\n * The client is created once (memoized on the config identity), so place the\n * provider above any component that uses the hooks. Pass `client` to inject a\n * pre-built (or mocked) client instead.\n */\nexport function QoreChainProvider(props: QoreChainProviderProps): ReactNode {\n const { config, client: injected, children } = props;\n\n // Build the read client once. When `injected` is provided it always wins.\n // The config object is treated as stable for the provider's lifetime; callers\n // that need to switch networks should remount the provider with a new `key`.\n // Memoize on the config's primitive fields so a new (but equal) config object\n // identity does not rebuild the client every render.\n const { network, chainId } = config;\n const endpoints = config.endpoints;\n const http = config.http;\n const client = useMemo<QoreChainClient>(() => {\n if (injected) return injected;\n return createClient({ network, endpoints, chainId, http });\n }, [injected, network, chainId, endpoints, http]);\n\n const [status, setStatus] = useState<ConnectionStatus>(\"disconnected\");\n const [addresses, setAddresses] = useState<ConnectedAddresses>({});\n const [wallet, setWallet] = useState<ConnectedWalletKind | undefined>(\n undefined,\n );\n const [error, setError] = useState<Error | undefined>(undefined);\n // The TxClient is not React state we render off of; keep it in a ref but mirror\n // a setter for hooks. We store it in state too so `useTx` re-renders on connect.\n const txRef = useRef<TxClient | undefined>(undefined);\n const [tx, setTx] = useState<TxClient | undefined>(undefined);\n\n const setConnection = useCallback<QoreContextValue[\"setConnection\"]>(\n (next) => {\n setStatus(next.status);\n setAddresses(next.addresses ?? {});\n setWallet(next.wallet);\n txRef.current = next.tx;\n setTx(next.tx);\n setError(next.error);\n },\n [],\n );\n\n const value = useMemo<QoreContextValue>(\n () => ({ client, status, addresses, wallet, tx, error, setConnection }),\n [client, status, addresses, wallet, tx, error, setConnection],\n );\n\n return <QoreContext.Provider value={value}>{children}</QoreContext.Provider>;\n}\n\n/**\n * Read the raw {@link QoreContextValue}. Throws when used outside a\n * {@link QoreChainProvider}. Most apps use the purpose-built hooks instead.\n */\nexport function useQoreContext(): QoreContextValue {\n const ctx = useContext(QoreContext);\n if (!ctx) {\n throw new Error(\n \"useQoreContext: no QoreChainProvider found. Wrap your app in <QoreChainProvider config={...}>.\",\n );\n }\n return ctx;\n}\n","/**\n * {@link useQoreClient} — the composed read client held by the provider.\n */\n\nimport type { QoreChainClient } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/**\n * Return the {@link QoreChainClient} created by the nearest\n * {@link QoreChainProvider}. Use it for ad-hoc reads (`client.rest`,\n * `client.qor`, `client.fees`, ...) not already covered by a dedicated hook.\n */\nexport function useQoreClient(): QoreChainClient {\n return useQoreContext().client;\n}\n","/**\n * {@link useAccount} — the connected wallet's addresses and status.\n */\n\nimport { useQoreContext } from \"../context\";\nimport type {\n ConnectedAddresses,\n ConnectionStatus,\n ConnectedWalletKind,\n} from \"../context\";\n\n/** The shape returned by {@link useAccount}. */\nexport interface UseAccountResult {\n /** All connected addresses, by VM family (native / evm / svm). */\n addresses: ConnectedAddresses;\n /** The primary address (native preferred, then evm, then svm), if any. */\n address?: string;\n /** Whether a wallet is connected. */\n isConnected: boolean;\n /** The current connection status. */\n status: ConnectionStatus;\n /** Which wallet is connected, if any. */\n wallet?: ConnectedWalletKind;\n}\n\n/**\n * Return the connected account's address(es) — native (bech32), EVM (`0x...`),\n * and/or SVM (base58) — plus a convenience primary `address` and connection\n * status. Empty until a wallet is connected via {@link useConnect}.\n */\nexport function useAccount(): UseAccountResult {\n const { addresses, status, wallet } = useQoreContext();\n const address = addresses.native ?? addresses.evm ?? addresses.svm;\n return {\n addresses,\n address,\n isConnected: status === \"connected\" && address !== undefined,\n status,\n wallet,\n };\n}\n","/**\n * {@link useBalance} — a bank balance with optional auto-refresh.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { Coin } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** Options for {@link useBalance}. */\nexport interface UseBalanceOptions {\n /**\n * The denom to read. Defaults to the network's base denom (e.g. `uqor`).\n */\n denom?: string;\n /**\n * Auto-refresh interval in milliseconds. `0` (the default) disables polling;\n * the balance is then fetched once on mount / address change.\n */\n refreshInterval?: number;\n /** Skip fetching entirely (e.g. while disconnected). Defaults to `false`. */\n enabled?: boolean;\n}\n\n/** The shape returned by {@link useBalance}. */\nexport interface UseBalanceResult {\n /** The balance coin (`{ denom, amount }`), once loaded. */\n data?: Coin;\n /** Whether a fetch is in flight. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n /** Manually re-fetch the balance. */\n refetch(): Promise<void>;\n}\n\n/**\n * Read the bank balance of `address` (or the connected account when omitted) in\n * a denom. Re-fetches on address / denom change and, when `refreshInterval > 0`,\n * polls on that interval. Returns `{ data, isLoading, error, refetch }`.\n */\nexport function useBalance(\n address?: string,\n options: UseBalanceOptions = {},\n): UseBalanceResult {\n const { client, addresses } = useQoreContext();\n const resolvedAddress = address ?? addresses.native;\n const denom = options.denom ?? client.network.coin.base;\n const refreshInterval = options.refreshInterval ?? 0;\n const enabled = options.enabled ?? true;\n\n const [data, setData] = useState<Coin | undefined>(undefined);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n // Guard against setting state after unmount / stale responses.\n const activeRef = useRef(true);\n useEffect(() => {\n activeRef.current = true;\n return () => {\n activeRef.current = false;\n };\n }, []);\n\n const refetch = useCallback(async (): Promise<void> => {\n if (!resolvedAddress || !enabled) return;\n setIsLoading(true);\n setError(undefined);\n try {\n const res = await client.rest.getBalance(resolvedAddress, denom);\n if (activeRef.current) {\n setData(res.balance ?? { denom, amount: \"0\" });\n }\n } catch (err) {\n if (activeRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n } finally {\n if (activeRef.current) setIsLoading(false);\n }\n }, [client, resolvedAddress, denom, enabled]);\n\n useEffect(() => {\n void refetch();\n if (refreshInterval > 0 && resolvedAddress && enabled) {\n const id = setInterval(() => {\n void refetch();\n }, refreshInterval);\n return () => clearInterval(id);\n }\n return undefined;\n }, [refetch, refreshInterval, resolvedAddress, enabled]);\n\n return { data, isLoading, error, refetch };\n}\n","/**\n * {@link useConnect} / {@link useWallet} — multi-wallet connect.\n *\n * Wraps the EXISTING wallet adapters so a component connects with one call and\n * the resolved signer + addresses land in the provider's connection state:\n * - Keplr / Leap (Cosmos) via `@qorechain/sdk`'s {@link getCosmosWallet}, which\n * suggests + enables the chain and returns a CosmJS signer; the signer is\n * connected through `client.connectTx` so `useTx` can sign.\n * - MetaMask / any EIP-1193 wallet (EVM) via `eth_requestAccounts` on the\n * injected provider (`window.ethereum` by default).\n * - Phantom / Wallet-Standard (SVM) via the injected Solana provider\n * (`window.solana`); returns the connected base58 address.\n *\n * The hook keeps its dependencies light: the EVM and SVM paths talk to the\n * injected provider's standard request API directly, so neither viem nor a\n * Solana SDK is pulled in. For full EVM/SVM tooling, use `@qorechain/evm` /\n * `@qorechain/svm` alongside this hook.\n */\n\nimport { useCallback } from \"react\";\nimport {\n getCosmosWallet,\n type CosmosWalletName,\n} from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\nimport type { ConnectedWalletKind } from \"../context\";\n\n/** A minimal EIP-1193 provider surface (MetaMask et al.). */\nexport interface Eip1193Like {\n request(args: { method: string; params?: unknown[] }): Promise<unknown>;\n}\n\n/** A minimal injected Solana provider surface (Phantom / Wallet-Standard). */\nexport interface SolanaProviderLike {\n connect(): Promise<{ publicKey: { toString(): string } }>;\n publicKey?: { toString(): string } | null;\n}\n\n/** Which wallet to connect via {@link UseConnectResult.connect}. */\nexport type ConnectKind = \"keplr\" | \"leap\" | \"evm\" | \"svm\";\n\n/** Options for a single {@link UseConnectResult.connect} call. */\nexport interface ConnectOptions {\n /** Which wallet to connect. Defaults to `\"keplr\"`. */\n kind?: ConnectKind;\n /**\n * Inject the wallet provider directly instead of reading it off `window`\n * (primarily for tests). The accepted shape depends on `kind`.\n */\n provider?: unknown;\n /** Use Amino signing for the Cosmos path (forwarded to `getCosmosWallet`). */\n preferAmino?: boolean;\n}\n\n/** The shape returned by {@link useConnect} / {@link useWallet}. */\nexport interface UseConnectResult {\n /** Connect a wallet; updates the provider's connection state. */\n connect(opts?: ConnectOptions): Promise<void>;\n /** Disconnect: clears the connection state. */\n disconnect(): void;\n /** The current connection status. */\n status: ReturnType<typeof useQoreContext>[\"status\"];\n /** Whether a connection attempt is in flight. */\n isConnecting: boolean;\n /** The last connection error, if any. */\n error?: Error;\n}\n\nfunction getWindow(): Record<string, unknown> | undefined {\n return typeof window === \"undefined\"\n ? undefined\n : (window as unknown as Record<string, unknown>);\n}\n\n/**\n * Multi-wallet connect bound to the {@link QoreChainProvider}.\n *\n * On success the provider's connection state holds the resolved addresses, the\n * connected wallet kind, and (for Cosmos) a `TxClient` for signing.\n */\nexport function useConnect(): UseConnectResult {\n const ctx = useQoreContext();\n const { client, status, error, setConnection } = ctx;\n\n const connect = useCallback(\n async (opts: ConnectOptions = {}): Promise<void> => {\n const kind: ConnectKind = opts.kind ?? \"keplr\";\n setConnection({ status: \"connecting\", addresses: ctx.addresses });\n\n try {\n if (kind === \"keplr\" || kind === \"leap\") {\n const conn = await getCosmosWallet({\n wallet: kind as CosmosWalletName,\n network: client.network,\n provider: opts.provider as never,\n preferAmino: opts.preferAmino,\n });\n const native = conn.accounts[0]?.address;\n const tx = await client.connectTx(conn.signer as never);\n setConnection({\n status: \"connected\",\n addresses: { native },\n wallet: kind as ConnectedWalletKind,\n tx,\n });\n return;\n }\n\n if (kind === \"evm\") {\n const provider = (opts.provider ??\n getWindow()?.ethereum) as Eip1193Like | undefined;\n if (!provider) {\n throw new Error(\n \"useConnect(evm): no EIP-1193 provider found (window.ethereum). Install MetaMask, or pass `provider`.\",\n );\n }\n const accounts = (await provider.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n const evm = accounts?.[0];\n if (!evm) throw new Error(\"useConnect(evm): no account returned\");\n setConnection({\n status: \"connected\",\n addresses: { evm },\n wallet: \"evm\",\n });\n return;\n }\n\n // kind === \"svm\"\n const provider = (opts.provider ??\n getWindow()?.solana) as SolanaProviderLike | undefined;\n if (!provider) {\n throw new Error(\n \"useConnect(svm): no Solana / Wallet-Standard provider found (window.solana). Install Phantom, or pass `provider`.\",\n );\n }\n const { publicKey } = await provider.connect();\n const svm = publicKey?.toString();\n if (!svm) throw new Error(\"useConnect(svm): no public key returned\");\n setConnection({\n status: \"connected\",\n addresses: { svm },\n wallet: \"svm\",\n });\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setConnection({ status: \"error\", error: e });\n throw e;\n }\n },\n [client, ctx.addresses, setConnection],\n );\n\n const disconnect = useCallback((): void => {\n setConnection({ status: \"disconnected\", addresses: {} });\n }, [setConnection]);\n\n return {\n connect,\n disconnect,\n status,\n isConnecting: status === \"connecting\",\n error,\n };\n}\n\n/** Alias for {@link useConnect} — the multi-wallet connect hook. */\nexport const useWallet = useConnect;\n","/**\n * {@link useTx} — send a transaction and track its status.\n */\n\nimport { useCallback, useState } from \"react\";\nimport type {\n EncodeObject,\n BroadcastResult,\n TxFeeInput,\n Coin,\n} from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** The lifecycle status of a {@link useTx} send. */\nexport type TxStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Options for {@link UseTxResult.send}. */\nexport interface SendOptions {\n /** Fee: an explicit `StdFee` or `\"auto\"`. Default `\"auto\"`. */\n fee?: TxFeeInput;\n /** Optional memo. */\n memo?: string;\n}\n\n/** The shape returned by {@link useTx}. */\nexport interface UseTxResult {\n /** Sign + broadcast arbitrary messages with the connected signer. */\n send(messages: EncodeObject[], opts?: SendOptions): Promise<BroadcastResult>;\n /** Convenience: send a bank transfer of `amount` to `toAddress`. */\n sendTokens(\n toAddress: string,\n amount: Coin[],\n opts?: SendOptions,\n ): Promise<BroadcastResult>;\n /** The current send status. */\n status: TxStatus;\n /** The last broadcast result, on success. */\n data?: BroadcastResult;\n /** The last error, on failure. */\n error?: Error;\n /** Whether a send is in flight. */\n isPending: boolean;\n /** Reset status/data/error back to idle. */\n reset(): void;\n}\n\n/**\n * Send transactions with the connected signer and track `{ status, data, error }`.\n *\n * Requires a connected wallet that produced a `TxClient` (the Cosmos path of\n * {@link useConnect}). `send` takes raw `{ typeUrl, value }` messages (use the\n * `msg.*` composers from `@qorechain/sdk`); `sendTokens` is a bank-transfer\n * shortcut.\n */\nexport function useTx(): UseTxResult {\n const { tx } = useQoreContext();\n const [status, setStatus] = useState<TxStatus>(\"idle\");\n const [data, setData] = useState<BroadcastResult | undefined>(undefined);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n const requireTx = useCallback(() => {\n if (!tx) {\n throw new Error(\n \"useTx: no connected signer. Connect a Cosmos wallet (Keplr/Leap) via useConnect() first.\",\n );\n }\n return tx;\n }, [tx]);\n\n const run = useCallback(\n async (fn: () => Promise<BroadcastResult>): Promise<BroadcastResult> => {\n setStatus(\"pending\");\n setError(undefined);\n try {\n const res = await fn();\n setData(res);\n setStatus(\"success\");\n return res;\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setError(e);\n setStatus(\"error\");\n throw e;\n }\n },\n [],\n );\n\n const send = useCallback(\n (messages: EncodeObject[], opts: SendOptions = {}) =>\n run(() =>\n requireTx().signAndBroadcast(messages, opts.fee ?? \"auto\", opts.memo ?? \"\"),\n ),\n [run, requireTx],\n );\n\n const sendTokens = useCallback(\n (toAddress: string, amount: Coin[], opts: SendOptions = {}) =>\n run(() =>\n requireTx().bankSend(toAddress, amount, {\n fee: opts.fee ?? \"auto\",\n memo: opts.memo ?? \"\",\n }),\n ),\n [run, requireTx],\n );\n\n const reset = useCallback(() => {\n setStatus(\"idle\");\n setData(undefined);\n setError(undefined);\n }, []);\n\n return {\n send,\n sendTokens,\n status,\n data,\n error,\n isPending: status === \"pending\",\n reset,\n };\n}\n","/**\n * {@link usePqcStatus} — read an address's quantum-safe (PQC) registration state.\n *\n * Built on the SDK's quantum-safe DX helpers ({@link getPqcStatus} /\n * {@link isPqcRegistered}), which call `qor_getPQCKeyStatus`. Powers the\n * {@link QuantumSafeBadge} component.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { getPqcStatus, type PqcStatus } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** Options for {@link usePqcStatus}. */\nexport interface UsePqcStatusOptions {\n /** Skip fetching (e.g. while disconnected). Defaults to `false`. */\n enabled?: boolean;\n /**\n * Auto-refresh interval in milliseconds. `0` (default) disables polling; the\n * status is fetched once per address change.\n */\n refreshInterval?: number;\n}\n\n/** The shape returned by {@link usePqcStatus}. */\nexport interface UsePqcStatusResult {\n /** The normalized PQC status, once loaded. */\n data?: PqcStatus;\n /** Whether the address has a registered PQC key (convenience). */\n isRegistered: boolean;\n /** Whether a fetch is in flight. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n /** Manually re-fetch the status. */\n refetch(): Promise<void>;\n}\n\n/**\n * Read whether `address` (or the connected account when omitted) is quantum-safe\n * — i.e. has a registered PQC key on QoreChain. Returns\n * `{ data, isRegistered, isLoading, error, refetch }`.\n */\nexport function usePqcStatus(\n address?: string,\n options: UsePqcStatusOptions = {},\n): UsePqcStatusResult {\n const { client, addresses } = useQoreContext();\n const resolvedAddress = address ?? addresses.native ?? addresses.evm;\n const enabled = options.enabled ?? true;\n const refreshInterval = options.refreshInterval ?? 0;\n\n const [data, setData] = useState<PqcStatus | undefined>(undefined);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n const activeRef = useRef(true);\n useEffect(() => {\n activeRef.current = true;\n return () => {\n activeRef.current = false;\n };\n }, []);\n\n const refetch = useCallback(async (): Promise<void> => {\n if (!resolvedAddress || !enabled) return;\n setIsLoading(true);\n setError(undefined);\n try {\n const status = await getPqcStatus(client, resolvedAddress);\n if (activeRef.current) setData(status);\n } catch (err) {\n if (activeRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n } finally {\n if (activeRef.current) setIsLoading(false);\n }\n }, [client, resolvedAddress, enabled]);\n\n useEffect(() => {\n void refetch();\n if (refreshInterval > 0 && resolvedAddress && enabled) {\n const id = setInterval(() => {\n void refetch();\n }, refreshInterval);\n return () => clearInterval(id);\n }\n return undefined;\n }, [refetch, refreshInterval, resolvedAddress, enabled]);\n\n return {\n data,\n isRegistered: data?.registered ?? false,\n isLoading,\n error,\n refetch,\n };\n}\n","/**\n * {@link ConnectButton} — a minimal, headless-ish multi-wallet connect control.\n *\n * Renders a connect button (or a small picker when multiple wallet kinds are\n * offered) wired to {@link useConnect}; once connected it shows the truncated\n * address and a disconnect action. Styling is intentionally light — pass\n * `className` / `style` to theme it, or rebuild your own UI on the hooks.\n */\n\nimport { type CSSProperties, type ReactNode } from \"react\";\nimport { useConnect, type ConnectKind } from \"../hooks/useConnect\";\nimport { useAccount } from \"../hooks/useAccount\";\n\n/** Props for {@link ConnectButton}. */\nexport interface ConnectButtonProps {\n /**\n * The wallet kinds to offer. With one entry the button connects it directly;\n * with several it renders a button per kind. Defaults to `[\"keplr\"]`.\n */\n wallets?: ConnectKind[];\n /** Optional class applied to the root element. */\n className?: string;\n /** Optional inline styles merged onto the root element. */\n style?: CSSProperties;\n /** Label shown before connecting. Defaults to `\"Connect Wallet\"`. */\n label?: string;\n /** Render-prop override: full control over the rendered UI. */\n children?: (state: ConnectButtonRenderState) => ReactNode;\n}\n\n/** State passed to the {@link ConnectButtonProps.children} render-prop. */\nexport interface ConnectButtonRenderState {\n /** Whether a wallet is connected. */\n isConnected: boolean;\n /** Whether a connection attempt is in flight. */\n isConnecting: boolean;\n /** The connected primary address, if any. */\n address?: string;\n /** Connect a specific wallet kind. */\n connect(kind?: ConnectKind): void;\n /** Disconnect. */\n disconnect(): void;\n /** The last connection error, if any. */\n error?: Error;\n}\n\nconst WALLET_LABEL: Record<ConnectKind, string> = {\n keplr: \"Keplr\",\n leap: \"Leap\",\n evm: \"MetaMask\",\n svm: \"Phantom\",\n};\n\n/** Truncate a long address for compact display (`qor1ab…xyz`). */\nfunction truncate(addr: string): string {\n if (addr.length <= 13) return addr;\n return `${addr.slice(0, 8)}…${addr.slice(-5)}`;\n}\n\nconst baseButtonStyle: CSSProperties = {\n font: \"inherit\",\n padding: \"0.5rem 0.9rem\",\n borderRadius: \"0.5rem\",\n border: \"1px solid currentColor\",\n background: \"transparent\",\n cursor: \"pointer\",\n};\n\n/**\n * A small connect / disconnect control. Single-wallet by default; pass\n * `wallets` for a multi-wallet picker, or `children` for full custom rendering.\n */\nexport function ConnectButton(props: ConnectButtonProps): ReactNode {\n const wallets = props.wallets ?? [\"keplr\"];\n const { connect, disconnect, isConnecting, error } = useConnect();\n const { isConnected, address } = useAccount();\n\n const doConnect = (kind?: ConnectKind): void => {\n void connect({ kind: kind ?? wallets[0] }).catch(() => {\n // The error is surfaced via the hook's `error`; swallow the rejection so\n // an unhandled promise does not bubble out of the click handler.\n });\n };\n\n if (props.children) {\n return props.children({\n isConnected,\n isConnecting,\n address,\n connect: doConnect,\n disconnect,\n error,\n });\n }\n\n if (isConnected && address) {\n return (\n <span className={props.className} style={props.style}>\n <span style={{ marginRight: \"0.5rem\" }}>{truncate(address)}</span>\n <button\n type=\"button\"\n style={baseButtonStyle}\n onClick={() => disconnect()}\n >\n Disconnect\n </button>\n </span>\n );\n }\n\n const label = props.label ?? \"Connect Wallet\";\n\n return (\n <span className={props.className} style={props.style}>\n {wallets.length === 1 ? (\n <button\n type=\"button\"\n style={baseButtonStyle}\n disabled={isConnecting}\n onClick={() => doConnect(wallets[0])}\n >\n {isConnecting ? \"Connecting…\" : label}\n </button>\n ) : (\n wallets.map((kind) => (\n <button\n key={kind}\n type=\"button\"\n style={{ ...baseButtonStyle, marginRight: \"0.4rem\" }}\n disabled={isConnecting}\n onClick={() => doConnect(kind)}\n >\n {WALLET_LABEL[kind]}\n </button>\n ))\n )}\n </span>\n );\n}\n","/**\n * {@link QuantumSafeBadge} — a \"Quantum-safe\" indicator for an address.\n *\n * Reads the address's PQC registration via {@link usePqcStatus} and renders a\n * compact badge: a positive \"Quantum-safe\" state when a PQC key is registered,\n * otherwise a muted \"Not quantum-safe\" state (or nothing, with\n * `hideWhenUnsafe`). Styling is minimal; theme it via `className` / `style` or\n * supply a `children` render-prop.\n */\n\nimport { type CSSProperties, type ReactNode } from \"react\";\nimport { usePqcStatus } from \"../hooks/usePqcStatus\";\n\n/** Props for {@link QuantumSafeBadge}. */\nexport interface QuantumSafeBadgeProps {\n /** Address to check. Defaults to the connected account. */\n address?: string;\n /** When `true`, render nothing if the address is not quantum-safe. */\n hideWhenUnsafe?: boolean;\n /** Label for the safe state. Defaults to `\"Quantum-safe\"`. */\n safeLabel?: string;\n /** Label for the unsafe state. Defaults to `\"Not quantum-safe\"`. */\n unsafeLabel?: string;\n /** Optional class applied to the root element. */\n className?: string;\n /** Optional inline styles merged onto the root element. */\n style?: CSSProperties;\n /** Render-prop override for full control over the rendered UI. */\n children?: (state: QuantumSafeRenderState) => ReactNode;\n}\n\n/** State passed to the {@link QuantumSafeBadgeProps.children} render-prop. */\nexport interface QuantumSafeRenderState {\n /** Whether the address has a registered PQC key. */\n isRegistered: boolean;\n /** Whether the status is still loading. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n}\n\nconst baseStyle: CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"0.35rem\",\n font: \"inherit\",\n fontSize: \"0.85em\",\n padding: \"0.15rem 0.55rem\",\n borderRadius: \"999px\",\n border: \"1px solid currentColor\",\n lineHeight: 1.4,\n};\n\n/**\n * A badge showing whether an address is quantum-safe (has a registered PQC key).\n */\nexport function QuantumSafeBadge(props: QuantumSafeBadgeProps): ReactNode {\n const { isRegistered, isLoading, error } = usePqcStatus(props.address);\n\n if (props.children) {\n return props.children({ isRegistered, isLoading, error });\n }\n\n if (isLoading && !isRegistered) {\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, opacity: 0.6, ...props.style }}\n data-quantum-safe=\"loading\"\n >\n Checking…\n </span>\n );\n }\n\n if (!isRegistered) {\n if (props.hideWhenUnsafe) return null;\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, opacity: 0.7, ...props.style }}\n data-quantum-safe=\"false\"\n title=\"No post-quantum key registered for this address\"\n >\n <span aria-hidden=\"true\">○</span>\n {props.unsafeLabel ?? \"Not quantum-safe\"}\n </span>\n );\n }\n\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, ...props.style }}\n data-quantum-safe=\"true\"\n title=\"Post-quantum (ML-DSA-87) key registered — transactions can be hybrid-signed\"\n >\n <span aria-hidden=\"true\">🛡️</span>\n {props.safeLabel ?? \"Quantum-safe\"}\n </span>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/context.tsx","../src/hooks/useQoreClient.ts","../src/hooks/useAccount.ts","../src/hooks/useBalance.ts","../src/hooks/useConnect.ts","../src/hooks/useTx.ts","../src/hooks/usePqcStatus.ts","../src/components/ConnectButton.tsx","../src/components/QuantumSafeBadge.tsx"],"names":["useState","useRef","useCallback","provider","useEffect","jsx","jsxs"],"mappings":";;;;;AAmGA,IAAM,WAAA,GAAc,cAAuC,IAAI,CAAA;AASxD,SAAS,kBAAkB,KAAA,EAA0C;AAC1E,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,UAAS,GAAI,KAAA;AAO/C,EAAA,MAAM,EAAE,OAAA,EAAS,OAAA,EAAQ,GAAI,MAAA;AAC7B,EAAA,MAAM,YAAY,MAAA,CAAO,SAAA;AACzB,EAAA,MAAM,OAAO,MAAA,CAAO,IAAA;AACpB,EAAA,MAAM,MAAA,GAAS,QAAyB,MAAM;AAC5C,IAAA,IAAI,UAAU,OAAO,QAAA;AACrB,IAAA,OAAO,aAAa,EAAE,OAAA,EAAS,SAAA,EAAW,OAAA,EAAS,MAAM,CAAA;AAAA,EAC3D,GAAG,CAAC,QAAA,EAAU,SAAS,OAAA,EAAS,SAAA,EAAW,IAAI,CAAC,CAAA;AAEhD,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAA2B,cAAc,CAAA;AACrE,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,QAAA,CAA6B,EAAE,CAAA;AACjE,EAAA,MAAM,CAAC,MAAA,EA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AA,EAAM;AAAA,MACtC,mBAAA,EAAkB,MAAA;AAAA,MAClB,KAAA,EAAM,kFAAA;AAAA,MAEN,QAAA,EAAA;AAAA,wBAAAD,GAAAA,CAAC,MAAA,EAAA,EAAK,aAAA,EAAY,MAAA,EAAO,QAAA,EAAA,iBAAA,EAAG,CAAA;AAAA,QAC3B,MAAM,SAAA,IAAa;AAAA;AAAA;AAAA,GACtB;AAEJ","file":"index.js","sourcesContent":["/**\n * The QoreChain React context: a {@link QoreChainProvider} that holds a single\n * composed {@link QoreChainClient} (from `@qorechain/sdk`'s {@link createClient})\n * plus the live wallet connection state, and the {@link useQoreContext} hook the\n * other hooks build on.\n *\n * One provider near the root of the app is enough; every hook\n * ({@link useQoreClient}, {@link useAccount}, {@link useBalance},\n * {@link useConnect}, {@link useTx}, {@link usePqcStatus}) reads from it.\n */\n\nimport {\n createContext,\n useContext,\n useMemo,\n useRef,\n useState,\n useCallback,\n type ReactNode,\n} from \"react\";\nimport {\n createClient,\n type QoreChainClient,\n type CreateClientOptions,\n type TxClient,\n} from \"@qorechain/sdk\";\n\n/** A connected wallet's resolved addresses, by VM family. */\nexport interface ConnectedAddresses {\n /** Native bech32 (`qor1...`) address, when a Native wallet is connected. */\n native?: string;\n /** EVM (`0x...`) address, when an EVM wallet is connected. */\n evm?: string;\n /** SVM (base58) address, when an SVM wallet is connected. */\n svm?: string;\n}\n\n/** The live connection status of the provider. */\nexport type ConnectionStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"error\";\n\n/** Which wallet family is connected. */\nexport type ConnectedWalletKind = \"keplr\" | \"leap\" | \"evm\" | \"svm\";\n\n/** The full context value exposed by {@link QoreChainProvider}. */\nexport interface QoreContextValue {\n /** The composed read client (created once from the provider config). */\n client: QoreChainClient;\n /** Current connection status. */\n status: ConnectionStatus;\n /** The connected addresses, keyed by VM family. Empty when disconnected. */\n addresses: ConnectedAddresses;\n /** Which wallet is connected, if any. */\n wallet?: ConnectedWalletKind;\n /** The connected signing client, if any (set by `useConnect`). */\n tx?: TxClient;\n /** The last connection error, if `status === \"error\"`. */\n error?: Error;\n /**\n * Internal: replace the connection state. Used by {@link useConnect}; apps use\n * the hooks rather than calling this directly.\n */\n setConnection(next: {\n status: ConnectionStatus;\n addresses?: ConnectedAddresses;\n wallet?: ConnectedWalletKind;\n tx?: TxClient;\n error?: Error;\n }): void;\n}\n\n/** Configuration for {@link QoreChainProvider}, forwarded to `createClient`. */\nexport interface QoreChainProviderConfig {\n /** Network preset to target. Defaults to `\"testnet\"`. */\n network?: CreateClientOptions[\"network\"];\n /** Endpoint overrides merged over the preset's defaults. */\n endpoints?: CreateClientOptions[\"endpoints\"];\n /** Chain id override. */\n chainId?: CreateClientOptions[\"chainId\"];\n /** Additional HTTP transport options shared by the read clients. */\n http?: CreateClientOptions[\"http\"];\n}\n\n/** Props for {@link QoreChainProvider}. */\nexport interface QoreChainProviderProps {\n /** Network + endpoint configuration for the underlying read client. */\n config: QoreChainProviderConfig;\n /**\n * A pre-built client to use instead of constructing one from `config`. Useful\n * for tests (inject a mocked client) and advanced composition.\n */\n client?: QoreChainClient;\n /** The app subtree that consumes the QoreChain hooks. */\n children: ReactNode;\n}\n\nconst QoreContext = createContext<QoreContextValue | null>(null);\n\n/**\n * Provide a single composed QoreChain client + connection state to the subtree.\n *\n * The client is created once (memoized on the config identity), so place the\n * provider above any component that uses the hooks. Pass `client` to inject a\n * pre-built (or mocked) client instead.\n */\nexport function QoreChainProvider(props: QoreChainProviderProps): ReactNode {\n const { config, client: injected, children } = props;\n\n // Build the read client once. When `injected` is provided it always wins.\n // The config object is treated as stable for the provider's lifetime; callers\n // that need to switch networks should remount the provider with a new `key`.\n // Memoize on the config's primitive fields so a new (but equal) config object\n // identity does not rebuild the client every render.\n const { network, chainId } = config;\n const endpoints = config.endpoints;\n const http = config.http;\n const client = useMemo<QoreChainClient>(() => {\n if (injected) return injected;\n return createClient({ network, endpoints, chainId, http });\n }, [injected, network, chainId, endpoints, http]);\n\n const [status, setStatus] = useState<ConnectionStatus>(\"disconnected\");\n const [addresses, setAddresses] = useState<ConnectedAddresses>({});\n const [wallet, setWallet] = useState<ConnectedWalletKind | undefined>(\n undefined,\n );\n const [error, setError] = useState<Error | undefined>(undefined);\n // The TxClient is not React state we render off of; keep it in a ref but mirror\n // a setter for hooks. We store it in state too so `useTx` re-renders on connect.\n const txRef = useRef<TxClient | undefined>(undefined);\n const [tx, setTx] = useState<TxClient | undefined>(undefined);\n\n const setConnection = useCallback<QoreContextValue[\"setConnection\"]>(\n (next) => {\n setStatus(next.status);\n setAddresses(next.addresses ?? {});\n setWallet(next.wallet);\n txRef.current = next.tx;\n setTx(next.tx);\n setError(next.error);\n },\n [],\n );\n\n const value = useMemo<QoreContextValue>(\n () => ({ client, status, addresses, wallet, tx, error, setConnection }),\n [client, status, addresses, wallet, tx, error, setConnection],\n );\n\n return <QoreContext.Provider value={value}>{children}</QoreContext.Provider>;\n}\n\n/**\n * Read the raw {@link QoreContextValue}. Throws when used outside a\n * {@link QoreChainProvider}. Most apps use the purpose-built hooks instead.\n */\nexport function useQoreContext(): QoreContextValue {\n const ctx = useContext(QoreContext);\n if (!ctx) {\n throw new Error(\n \"useQoreContext: no QoreChainProvider found. Wrap your app in <QoreChainProvider config={...}>.\",\n );\n }\n return ctx;\n}\n","/**\n * {@link useQoreClient} — the composed read client held by the provider.\n */\n\nimport type { QoreChainClient } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/**\n * Return the {@link QoreChainClient} created by the nearest\n * {@link QoreChainProvider}. Use it for ad-hoc reads (`client.rest`,\n * `client.qor`, `client.fees`, ...) not already covered by a dedicated hook.\n */\nexport function useQoreClient(): QoreChainClient {\n return useQoreContext().client;\n}\n","/**\n * {@link useAccount} — the connected wallet's addresses and status.\n */\n\nimport { useQoreContext } from \"../context\";\nimport type {\n ConnectedAddresses,\n ConnectionStatus,\n ConnectedWalletKind,\n} from \"../context\";\n\n/** The shape returned by {@link useAccount}. */\nexport interface UseAccountResult {\n /** All connected addresses, by VM family (native / evm / svm). */\n addresses: ConnectedAddresses;\n /** The primary address (native preferred, then evm, then svm), if any. */\n address?: string;\n /** Whether a wallet is connected. */\n isConnected: boolean;\n /** The current connection status. */\n status: ConnectionStatus;\n /** Which wallet is connected, if any. */\n wallet?: ConnectedWalletKind;\n}\n\n/**\n * Return the connected account's address(es) — native (bech32), EVM (`0x...`),\n * and/or SVM (base58) — plus a convenience primary `address` and connection\n * status. Empty until a wallet is connected via {@link useConnect}.\n */\nexport function useAccount(): UseAccountResult {\n const { addresses, status, wallet } = useQoreContext();\n const address = addresses.native ?? addresses.evm ?? addresses.svm;\n return {\n addresses,\n address,\n isConnected: status === \"connected\" && address !== undefined,\n status,\n wallet,\n };\n}\n","/**\n * {@link useBalance} — a bank balance with optional auto-refresh.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { Coin } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** Options for {@link useBalance}. */\nexport interface UseBalanceOptions {\n /**\n * The denom to read. Defaults to the network's base denom (e.g. `uqor`).\n */\n denom?: string;\n /**\n * Auto-refresh interval in milliseconds. `0` (the default) disables polling;\n * the balance is then fetched once on mount / address change.\n */\n refreshInterval?: number;\n /** Skip fetching entirely (e.g. while disconnected). Defaults to `false`. */\n enabled?: boolean;\n}\n\n/** The shape returned by {@link useBalance}. */\nexport interface UseBalanceResult {\n /** The balance coin (`{ denom, amount }`), once loaded. */\n data?: Coin;\n /** Whether a fetch is in flight. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n /** Manually re-fetch the balance. */\n refetch(): Promise<void>;\n}\n\n/**\n * Read the bank balance of `address` (or the connected account when omitted) in\n * a denom. Re-fetches on address / denom change and, when `refreshInterval > 0`,\n * polls on that interval. Returns `{ data, isLoading, error, refetch }`.\n */\nexport function useBalance(\n address?: string,\n options: UseBalanceOptions = {},\n): UseBalanceResult {\n const { client, addresses } = useQoreContext();\n const resolvedAddress = address ?? addresses.native;\n const denom = options.denom ?? client.network.coin.base;\n const refreshInterval = options.refreshInterval ?? 0;\n const enabled = options.enabled ?? true;\n\n const [data, setData] = useState<Coin | undefined>(undefined);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n // Guard against setting state after unmount / stale responses.\n const activeRef = useRef(true);\n useEffect(() => {\n activeRef.current = true;\n return () => {\n activeRef.current = false;\n };\n }, []);\n\n const refetch = useCallback(async (): Promise<void> => {\n if (!resolvedAddress || !enabled) return;\n setIsLoading(true);\n setError(undefined);\n try {\n const res = await client.rest.getBalance(resolvedAddress, denom);\n if (activeRef.current) {\n setData(res.balance ?? { denom, amount: \"0\" });\n }\n } catch (err) {\n if (activeRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n } finally {\n if (activeRef.current) setIsLoading(false);\n }\n }, [client, resolvedAddress, denom, enabled]);\n\n useEffect(() => {\n void refetch();\n if (refreshInterval > 0 && resolvedAddress && enabled) {\n const id = setInterval(() => {\n void refetch();\n }, refreshInterval);\n return () => clearInterval(id);\n }\n return undefined;\n }, [refetch, refreshInterval, resolvedAddress, enabled]);\n\n return { data, isLoading, error, refetch };\n}\n","/**\n * {@link useConnect} / {@link useWallet} — multi-wallet connect.\n *\n * Wraps the EXISTING wallet adapters so a component connects with one call and\n * the resolved signer + addresses land in the provider's connection state:\n * - Keplr / Leap (Native) via `@qorechain/sdk`'s {@link getCosmosWallet}, which\n * suggests + enables the chain and returns a CosmJS signer; the signer is\n * connected through `client.connectTx` so `useTx` can sign.\n * - MetaMask / any EIP-1193 wallet (EVM) via `eth_requestAccounts` on the\n * injected provider (`window.ethereum` by default).\n * - Phantom / Wallet-Standard (SVM) via the injected Solana provider\n * (`window.solana`); returns the connected base58 address.\n *\n * The hook keeps its dependencies light: the EVM and SVM paths talk to the\n * injected provider's standard request API directly, so neither viem nor a\n * Solana SDK is pulled in. For full EVM/SVM tooling, use `@qorechain/evm` /\n * `@qorechain/svm` alongside this hook.\n */\n\nimport { useCallback } from \"react\";\nimport {\n getCosmosWallet,\n type CosmosWalletName,\n} from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\nimport type { ConnectedWalletKind } from \"../context\";\n\n/** A minimal EIP-1193 provider surface (MetaMask et al.). */\nexport interface Eip1193Like {\n request(args: { method: string; params?: unknown[] }): Promise<unknown>;\n}\n\n/** A minimal injected Solana provider surface (Phantom / Wallet-Standard). */\nexport interface SolanaProviderLike {\n connect(): Promise<{ publicKey: { toString(): string } }>;\n publicKey?: { toString(): string } | null;\n}\n\n/** Which wallet to connect via {@link UseConnectResult.connect}. */\nexport type ConnectKind = \"keplr\" | \"leap\" | \"evm\" | \"svm\";\n\n/** Options for a single {@link UseConnectResult.connect} call. */\nexport interface ConnectOptions {\n /** Which wallet to connect. Defaults to `\"keplr\"`. */\n kind?: ConnectKind;\n /**\n * Inject the wallet provider directly instead of reading it off `window`\n * (primarily for tests). The accepted shape depends on `kind`.\n */\n provider?: unknown;\n /** Use Amino signing for the Native path (forwarded to `getCosmosWallet`). */\n preferAmino?: boolean;\n}\n\n/** The shape returned by {@link useConnect} / {@link useWallet}. */\nexport interface UseConnectResult {\n /** Connect a wallet; updates the provider's connection state. */\n connect(opts?: ConnectOptions): Promise<void>;\n /** Disconnect: clears the connection state. */\n disconnect(): void;\n /** The current connection status. */\n status: ReturnType<typeof useQoreContext>[\"status\"];\n /** Whether a connection attempt is in flight. */\n isConnecting: boolean;\n /** The last connection error, if any. */\n error?: Error;\n}\n\nfunction getWindow(): Record<string, unknown> | undefined {\n return typeof window === \"undefined\"\n ? undefined\n : (window as unknown as Record<string, unknown>);\n}\n\n/**\n * Multi-wallet connect bound to the {@link QoreChainProvider}.\n *\n * On success the provider's connection state holds the resolved addresses, the\n * connected wallet kind, and (for Native) a `TxClient` for signing.\n */\nexport function useConnect(): UseConnectResult {\n const ctx = useQoreContext();\n const { client, status, error, setConnection } = ctx;\n\n const connect = useCallback(\n async (opts: ConnectOptions = {}): Promise<void> => {\n const kind: ConnectKind = opts.kind ?? \"keplr\";\n setConnection({ status: \"connecting\", addresses: ctx.addresses });\n\n try {\n if (kind === \"keplr\" || kind === \"leap\") {\n const conn = await getCosmosWallet({\n wallet: kind as CosmosWalletName,\n network: client.network,\n provider: opts.provider as never,\n preferAmino: opts.preferAmino,\n });\n const native = conn.accounts[0]?.address;\n const tx = await client.connectTx(conn.signer as never);\n setConnection({\n status: \"connected\",\n addresses: { native },\n wallet: kind as ConnectedWalletKind,\n tx,\n });\n return;\n }\n\n if (kind === \"evm\") {\n const provider = (opts.provider ??\n getWindow()?.ethereum) as Eip1193Like | undefined;\n if (!provider) {\n throw new Error(\n \"useConnect(evm): no EIP-1193 provider found (window.ethereum). Install MetaMask, or pass `provider`.\",\n );\n }\n const accounts = (await provider.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n const evm = accounts?.[0];\n if (!evm) throw new Error(\"useConnect(evm): no account returned\");\n setConnection({\n status: \"connected\",\n addresses: { evm },\n wallet: \"evm\",\n });\n return;\n }\n\n // kind === \"svm\"\n const provider = (opts.provider ??\n getWindow()?.solana) as SolanaProviderLike | undefined;\n if (!provider) {\n throw new Error(\n \"useConnect(svm): no Solana / Wallet-Standard provider found (window.solana). Install Phantom, or pass `provider`.\",\n );\n }\n const { publicKey } = await provider.connect();\n const svm = publicKey?.toString();\n if (!svm) throw new Error(\"useConnect(svm): no public key returned\");\n setConnection({\n status: \"connected\",\n addresses: { svm },\n wallet: \"svm\",\n });\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setConnection({ status: \"error\", error: e });\n throw e;\n }\n },\n [client, ctx.addresses, setConnection],\n );\n\n const disconnect = useCallback((): void => {\n setConnection({ status: \"disconnected\", addresses: {} });\n }, [setConnection]);\n\n return {\n connect,\n disconnect,\n status,\n isConnecting: status === \"connecting\",\n error,\n };\n}\n\n/** Alias for {@link useConnect} — the multi-wallet connect hook. */\nexport const useWallet = useConnect;\n","/**\n * {@link useTx} — send a transaction and track its status.\n */\n\nimport { useCallback, useState } from \"react\";\nimport type {\n EncodeObject,\n BroadcastResult,\n TxFeeInput,\n Coin,\n} from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** The lifecycle status of a {@link useTx} send. */\nexport type TxStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Options for {@link UseTxResult.send}. */\nexport interface SendOptions {\n /** Fee: an explicit `StdFee` or `\"auto\"`. Default `\"auto\"`. */\n fee?: TxFeeInput;\n /** Optional memo. */\n memo?: string;\n}\n\n/** The shape returned by {@link useTx}. */\nexport interface UseTxResult {\n /** Sign + broadcast arbitrary messages with the connected signer. */\n send(messages: EncodeObject[], opts?: SendOptions): Promise<BroadcastResult>;\n /** Convenience: send a bank transfer of `amount` to `toAddress`. */\n sendTokens(\n toAddress: string,\n amount: Coin[],\n opts?: SendOptions,\n ): Promise<BroadcastResult>;\n /** The current send status. */\n status: TxStatus;\n /** The last broadcast result, on success. */\n data?: BroadcastResult;\n /** The last error, on failure. */\n error?: Error;\n /** Whether a send is in flight. */\n isPending: boolean;\n /** Reset status/data/error back to idle. */\n reset(): void;\n}\n\n/**\n * Send transactions with the connected signer and track `{ status, data, error }`.\n *\n * Requires a connected wallet that produced a `TxClient` (the Native path of\n * {@link useConnect}). `send` takes raw `{ typeUrl, value }` messages (use the\n * `msg.*` composers from `@qorechain/sdk`); `sendTokens` is a bank-transfer\n * shortcut.\n */\nexport function useTx(): UseTxResult {\n const { tx } = useQoreContext();\n const [status, setStatus] = useState<TxStatus>(\"idle\");\n const [data, setData] = useState<BroadcastResult | undefined>(undefined);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n const requireTx = useCallback(() => {\n if (!tx) {\n throw new Error(\n \"useTx: no connected signer. Connect a Native wallet (Keplr/Leap) via useConnect() first.\",\n );\n }\n return tx;\n }, [tx]);\n\n const run = useCallback(\n async (fn: () => Promise<BroadcastResult>): Promise<BroadcastResult> => {\n setStatus(\"pending\");\n setError(undefined);\n try {\n const res = await fn();\n setData(res);\n setStatus(\"success\");\n return res;\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setError(e);\n setStatus(\"error\");\n throw e;\n }\n },\n [],\n );\n\n const send = useCallback(\n (messages: EncodeObject[], opts: SendOptions = {}) =>\n run(() =>\n requireTx().signAndBroadcast(messages, opts.fee ?? \"auto\", opts.memo ?? \"\"),\n ),\n [run, requireTx],\n );\n\n const sendTokens = useCallback(\n (toAddress: string, amount: Coin[], opts: SendOptions = {}) =>\n run(() =>\n requireTx().bankSend(toAddress, amount, {\n fee: opts.fee ?? \"auto\",\n memo: opts.memo ?? \"\",\n }),\n ),\n [run, requireTx],\n );\n\n const reset = useCallback(() => {\n setStatus(\"idle\");\n setData(undefined);\n setError(undefined);\n }, []);\n\n return {\n send,\n sendTokens,\n status,\n data,\n error,\n isPending: status === \"pending\",\n reset,\n };\n}\n","/**\n * {@link usePqcStatus} — read an address's quantum-safe (PQC) registration state.\n *\n * Built on the SDK's quantum-safe DX helpers ({@link getPqcStatus} /\n * {@link isPqcRegistered}), which call `qor_getPQCKeyStatus`. Powers the\n * {@link QuantumSafeBadge} component.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { getPqcStatus, type PqcStatus } from \"@qorechain/sdk\";\nimport { useQoreContext } from \"../context\";\n\n/** Options for {@link usePqcStatus}. */\nexport interface UsePqcStatusOptions {\n /** Skip fetching (e.g. while disconnected). Defaults to `false`. */\n enabled?: boolean;\n /**\n * Auto-refresh interval in milliseconds. `0` (default) disables polling; the\n * status is fetched once per address change.\n */\n refreshInterval?: number;\n}\n\n/** The shape returned by {@link usePqcStatus}. */\nexport interface UsePqcStatusResult {\n /** The normalized PQC status, once loaded. */\n data?: PqcStatus;\n /** Whether the address has a registered PQC key (convenience). */\n isRegistered: boolean;\n /** Whether a fetch is in flight. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n /** Manually re-fetch the status. */\n refetch(): Promise<void>;\n}\n\n/**\n * Read whether `address` (or the connected account when omitted) is quantum-safe\n * — i.e. has a registered PQC key on QoreChain. Returns\n * `{ data, isRegistered, isLoading, error, refetch }`.\n */\nexport function usePqcStatus(\n address?: string,\n options: UsePqcStatusOptions = {},\n): UsePqcStatusResult {\n const { client, addresses } = useQoreContext();\n const resolvedAddress = address ?? addresses.native ?? addresses.evm;\n const enabled = options.enabled ?? true;\n const refreshInterval = options.refreshInterval ?? 0;\n\n const [data, setData] = useState<PqcStatus | undefined>(undefined);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n const activeRef = useRef(true);\n useEffect(() => {\n activeRef.current = true;\n return () => {\n activeRef.current = false;\n };\n }, []);\n\n const refetch = useCallback(async (): Promise<void> => {\n if (!resolvedAddress || !enabled) return;\n setIsLoading(true);\n setError(undefined);\n try {\n const status = await getPqcStatus(client, resolvedAddress);\n if (activeRef.current) setData(status);\n } catch (err) {\n if (activeRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n } finally {\n if (activeRef.current) setIsLoading(false);\n }\n }, [client, resolvedAddress, enabled]);\n\n useEffect(() => {\n void refetch();\n if (refreshInterval > 0 && resolvedAddress && enabled) {\n const id = setInterval(() => {\n void refetch();\n }, refreshInterval);\n return () => clearInterval(id);\n }\n return undefined;\n }, [refetch, refreshInterval, resolvedAddress, enabled]);\n\n return {\n data,\n isRegistered: data?.registered ?? false,\n isLoading,\n error,\n refetch,\n };\n}\n","/**\n * {@link ConnectButton} — a minimal, headless-ish multi-wallet connect control.\n *\n * Renders a connect button (or a small picker when multiple wallet kinds are\n * offered) wired to {@link useConnect}; once connected it shows the truncated\n * address and a disconnect action. Styling is intentionally light — pass\n * `className` / `style` to theme it, or rebuild your own UI on the hooks.\n */\n\nimport { type CSSProperties, type ReactNode } from \"react\";\nimport { useConnect, type ConnectKind } from \"../hooks/useConnect\";\nimport { useAccount } from \"../hooks/useAccount\";\n\n/** Props for {@link ConnectButton}. */\nexport interface ConnectButtonProps {\n /**\n * The wallet kinds to offer. With one entry the button connects it directly;\n * with several it renders a button per kind. Defaults to `[\"keplr\"]`.\n */\n wallets?: ConnectKind[];\n /** Optional class applied to the root element. */\n className?: string;\n /** Optional inline styles merged onto the root element. */\n style?: CSSProperties;\n /** Label shown before connecting. Defaults to `\"Connect Wallet\"`. */\n label?: string;\n /** Render-prop override: full control over the rendered UI. */\n children?: (state: ConnectButtonRenderState) => ReactNode;\n}\n\n/** State passed to the {@link ConnectButtonProps.children} render-prop. */\nexport interface ConnectButtonRenderState {\n /** Whether a wallet is connected. */\n isConnected: boolean;\n /** Whether a connection attempt is in flight. */\n isConnecting: boolean;\n /** The connected primary address, if any. */\n address?: string;\n /** Connect a specific wallet kind. */\n connect(kind?: ConnectKind): void;\n /** Disconnect. */\n disconnect(): void;\n /** The last connection error, if any. */\n error?: Error;\n}\n\nconst WALLET_LABEL: Record<ConnectKind, string> = {\n keplr: \"Keplr\",\n leap: \"Leap\",\n evm: \"MetaMask\",\n svm: \"Phantom\",\n};\n\n/** Truncate a long address for compact display (`qor1ab…xyz`). */\nfunction truncate(addr: string): string {\n if (addr.length <= 13) return addr;\n return `${addr.slice(0, 8)}…${addr.slice(-5)}`;\n}\n\nconst baseButtonStyle: CSSProperties = {\n font: \"inherit\",\n padding: \"0.5rem 0.9rem\",\n borderRadius: \"0.5rem\",\n border: \"1px solid currentColor\",\n background: \"transparent\",\n cursor: \"pointer\",\n};\n\n/**\n * A small connect / disconnect control. Single-wallet by default; pass\n * `wallets` for a multi-wallet picker, or `children` for full custom rendering.\n */\nexport function ConnectButton(props: ConnectButtonProps): ReactNode {\n const wallets = props.wallets ?? [\"keplr\"];\n const { connect, disconnect, isConnecting, error } = useConnect();\n const { isConnected, address } = useAccount();\n\n const doConnect = (kind?: ConnectKind): void => {\n void connect({ kind: kind ?? wallets[0] }).catch(() => {\n // The error is surfaced via the hook's `error`; swallow the rejection so\n // an unhandled promise does not bubble out of the click handler.\n });\n };\n\n if (props.children) {\n return props.children({\n isConnected,\n isConnecting,\n address,\n connect: doConnect,\n disconnect,\n error,\n });\n }\n\n if (isConnected && address) {\n return (\n <span className={props.className} style={props.style}>\n <span style={{ marginRight: \"0.5rem\" }}>{truncate(address)}</span>\n <button\n type=\"button\"\n style={baseButtonStyle}\n onClick={() => disconnect()}\n >\n Disconnect\n </button>\n </span>\n );\n }\n\n const label = props.label ?? \"Connect Wallet\";\n\n return (\n <span className={props.className} style={props.style}>\n {wallets.length === 1 ? (\n <button\n type=\"button\"\n style={baseButtonStyle}\n disabled={isConnecting}\n onClick={() => doConnect(wallets[0])}\n >\n {isConnecting ? \"Connecting…\" : label}\n </button>\n ) : (\n wallets.map((kind) => (\n <button\n key={kind}\n type=\"button\"\n style={{ ...baseButtonStyle, marginRight: \"0.4rem\" }}\n disabled={isConnecting}\n onClick={() => doConnect(kind)}\n >\n {WALLET_LABEL[kind]}\n </button>\n ))\n )}\n </span>\n );\n}\n","/**\n * {@link QuantumSafeBadge} — a \"Quantum-safe\" indicator for an address.\n *\n * Reads the address's PQC registration via {@link usePqcStatus} and renders a\n * compact badge: a positive \"Quantum-safe\" state when a PQC key is registered,\n * otherwise a muted \"Not quantum-safe\" state (or nothing, with\n * `hideWhenUnsafe`). Styling is minimal; theme it via `className` / `style` or\n * supply a `children` render-prop.\n */\n\nimport { type CSSProperties, type ReactNode } from \"react\";\nimport { usePqcStatus } from \"../hooks/usePqcStatus\";\n\n/** Props for {@link QuantumSafeBadge}. */\nexport interface QuantumSafeBadgeProps {\n /** Address to check. Defaults to the connected account. */\n address?: string;\n /** When `true`, render nothing if the address is not quantum-safe. */\n hideWhenUnsafe?: boolean;\n /** Label for the safe state. Defaults to `\"Quantum-safe\"`. */\n safeLabel?: string;\n /** Label for the unsafe state. Defaults to `\"Not quantum-safe\"`. */\n unsafeLabel?: string;\n /** Optional class applied to the root element. */\n className?: string;\n /** Optional inline styles merged onto the root element. */\n style?: CSSProperties;\n /** Render-prop override for full control over the rendered UI. */\n children?: (state: QuantumSafeRenderState) => ReactNode;\n}\n\n/** State passed to the {@link QuantumSafeBadgeProps.children} render-prop. */\nexport interface QuantumSafeRenderState {\n /** Whether the address has a registered PQC key. */\n isRegistered: boolean;\n /** Whether the status is still loading. */\n isLoading: boolean;\n /** The last fetch error, if any. */\n error?: Error;\n}\n\nconst baseStyle: CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"0.35rem\",\n font: \"inherit\",\n fontSize: \"0.85em\",\n padding: \"0.15rem 0.55rem\",\n borderRadius: \"999px\",\n border: \"1px solid currentColor\",\n lineHeight: 1.4,\n};\n\n/**\n * A badge showing whether an address is quantum-safe (has a registered PQC key).\n */\nexport function QuantumSafeBadge(props: QuantumSafeBadgeProps): ReactNode {\n const { isRegistered, isLoading, error } = usePqcStatus(props.address);\n\n if (props.children) {\n return props.children({ isRegistered, isLoading, error });\n }\n\n if (isLoading && !isRegistered) {\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, opacity: 0.6, ...props.style }}\n data-quantum-safe=\"loading\"\n >\n Checking…\n </span>\n );\n }\n\n if (!isRegistered) {\n if (props.hideWhenUnsafe) return null;\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, opacity: 0.7, ...props.style }}\n data-quantum-safe=\"false\"\n title=\"No post-quantum key registered for this address\"\n >\n <span aria-hidden=\"true\">○</span>\n {props.unsafeLabel ?? \"Not quantum-safe\"}\n </span>\n );\n }\n\n return (\n <span\n className={props.className}\n style={{ ...baseStyle, ...props.style }}\n data-quantum-safe=\"true\"\n title=\"Post-quantum (ML-DSA-87) key registered — transactions can be hybrid-signed\"\n >\n <span aria-hidden=\"true\">🛡️</span>\n {props.safeLabel ?? \"Quantum-safe\"}\n </span>\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qorechain/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Official React hooks and components for building quantum-safe QoreChain dApps.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "QoreChain",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"react": "^18.0.0 || ^19.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@qorechain/sdk": "0.
|
|
38
|
+
"@qorechain/sdk": "0.6.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@testing-library/react": "^16.0.1",
|