@solana/react 7.0.0 → 7.1.0-canary-20260812160611
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 +117 -39
- package/dist/index.browser.cjs +64 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +58 -1
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.native.mjs +58 -1
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.node.cjs +64 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +58 -1
- package/dist/index.node.mjs.map +1 -1
- package/dist/query.browser.cjs +5 -52
- package/dist/query.browser.cjs.map +1 -1
- package/dist/query.browser.mjs +5 -52
- package/dist/query.browser.mjs.map +1 -1
- package/dist/query.native.mjs +5 -52
- package/dist/query.native.mjs.map +1 -1
- package/dist/query.node.cjs +5 -52
- package/dist/query.node.cjs.map +1 -1
- package/dist/query.node.mjs +5 -52
- package/dist/query.node.mjs.map +1 -1
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/query/useSubscriptionQuery.d.ts +5 -5
- package/dist/types/query/useSubscriptionQuery.d.ts.map +1 -1
- package/dist/types/query/useTrackedDataQuery.d.ts +2 -2
- package/dist/types/query/useTrackedDataQuery.d.ts.map +1 -1
- package/dist/types/useAirdrop.d.ts +40 -0
- package/dist/types/useAirdrop.d.ts.map +1 -0
- package/dist/types/useClient.d.ts +7 -6
- package/dist/types/useClient.d.ts.map +1 -1
- package/dist/types/useIdentity.d.ts +28 -0
- package/dist/types/useIdentity.d.ts.map +1 -0
- package/dist/types/usePayer.d.ts +27 -0
- package/dist/types/usePayer.d.ts.map +1 -0
- package/dist/types/usePlanTransaction.d.ts +25 -0
- package/dist/types/usePlanTransaction.d.ts.map +1 -0
- package/dist/types/usePlanTransactions.d.ts +26 -0
- package/dist/types/usePlanTransactions.d.ts.map +1 -0
- package/dist/types/useSendTransaction.d.ts +29 -0
- package/dist/types/useSendTransaction.d.ts.map +1 -0
- package/dist/types/useSendTransactions.d.ts +28 -0
- package/dist/types/useSendTransactions.d.ts.map +1 -0
- package/package.json +10 -10
- package/src/index.ts +7 -0
- package/src/query/__tests__/useRequestQuery-test.browser.tsx +2 -2
- package/src/query/__tests__/useSubscriptionQuery-test.browser.tsx +7 -9
- package/src/query/__tests__/useTrackedDataQuery-test.browser.tsx +3 -3
- package/src/query/useSubscriptionQuery.ts +9 -7
- package/src/query/useTrackedDataQuery.ts +9 -4
- package/src/swr/__tests__/useRequestSWR-test.browser.tsx +4 -6
- package/src/useAirdrop.ts +45 -0
- package/src/useClient.ts +7 -6
- package/src/useIdentity.ts +47 -0
- package/src/usePayer.ts +44 -0
- package/src/usePlanTransaction.ts +30 -0
- package/src/usePlanTransactions.ts +31 -0
- package/src/useSendTransaction.ts +34 -0
- package/src/useSendTransactions.ts +33 -0
- package/dist/types/query/bridgeStoreToAsyncIterable.d.ts +0 -39
- package/dist/types/query/bridgeStoreToAsyncIterable.d.ts.map +0 -1
- package/src/query/__tests__/bridgeStoreToAsyncIterable-test.ts +0 -188
- package/src/query/bridgeStoreToAsyncIterable.ts +0 -105
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/usePromise.ts","../src/ClientProvider.tsx","../src/useIsomorphicLayoutEffect.ts","../src/useAction.ts","../src/useClient.ts","../src/useClientCapability.ts","../src/staticStores.ts","../src/useLatest.ts","../src/useReactiveStoreLifecycle.ts","../src/useRequestResult.ts","../src/useRequest.ts","../src/useSignAndSendTransaction.ts","../src/useSubscriptionResult.ts","../src/useSubscription.ts","../src/useSignIn.ts","../src/useSignMessage.ts","../src/useSignTransaction.ts","../src/useTrackedDataResult.ts","../src/useTrackedData.ts","../src/useWalletAccountMessageSigner.ts","../src/useWalletAccountTransactionSigner.ts","../src/useWalletAccountTransactionSendingSigner.ts","../src/selectedWalletAccountContext.ts","../src/SelectedWalletAccountContextProvider.tsx"],"names":["React","useLayoutEffect","useEffect","useRef","useState","createReactiveActionStore","useSyncExternalStore","useMemo","SolanaError","SOLANA_ERROR__REACT__MISSING_PROVIDER","SOLANA_ERROR__REACT__MISSING_CAPABILITY","useCallback","WalletStandardError","WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED","SolanaSignAndSendTransaction","getWalletAccountFeature","getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","SolanaSignIn","getWalletFeature","getWalletForHandle_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","getOrCreateUiWalletAccountForStandardWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","SolanaSignMessage","SolanaSignTransaction","fireConnect","createReactiveStoreWithInitialValueAndSlotTracking","address","SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED","getAbortablePromise","bytesEqual","getTransactionCodec","assertIsTransactionWithinSizeLimit","compiledTransactionMessage","getCompiledTransactionMessageDecoder","getTransactionLifetimeConstraintFromCompiledTransactionMessage","getTransactionEncoder","createContext","useWallets","getUiWalletAccountStorageKey","uiWalletAccountsAreSame","uiWalletAccountBelongsToUiWallet"],"mappings":";;;;;;;;;;;;;;;;AAOA,IAAM,KAAA,uBAAY,OAAA,EAAmD;AAErE,SAAS,eAAkB,OAAA,EAA4C;AAInE,EAAA,OAAO,OAAA,CAAQ,IAAA;AAAA,IACX,CAAA,KAAA,KAAS;AACL,MAAA,KAAA,CAAM,IAAI,OAAA,EAAS,EAAE,MAAA,EAAQ,WAAA,EAAa,OAAO,CAAA;AAAA,IACrD,CAAA;AAAA,IACA,CAAA,MAAA,KAAU;AACN,MAAA,KAAA,CAAM,IAAI,OAAA,EAAS,EAAE,MAAA,EAAQ,MAAA,EAAQ,YAAY,CAAA;AAAA,IACrD;AAAA,GACJ;AACJ;AAWA,SAAS,eAAkB,OAAA,EAA4B;AACnD,EAAA,IAAI,KAAA,GAAQ,KAAA,CAAM,GAAA,CAAI,OAAO,CA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AA,IAAI,CAAC,qBAAA,EAAuB;AAC5B,IAAA,KAAA,MAAW,UAAU,eAAA,EAAiB;AAClC,MAAA,KAAA,MAAW,OAAA,IAAW,OAAO,QAAA,EAAU;AACnC,QAAA,IAAIsC,6BAAA,CAAwB,OAAA,EAAS,qBAAqB,CAAA,EAAG;AACzD,UAAA,OAAO,OAAA;AAAA,QACX;AAAA,MACJ;AACA,MAAA,IAAIC,uCAAiC,qBAAA,EAAuB,MAAM,KAAK,MAAA,CAAO,QAAA,CAAS,CAAC,CAAA,EAAG;AACvF,QAAA,OAAO,MAAA,CAAO,SAAS,CAAC,CAAA;AAAA,MAC5B;AAAA,IACJ;AAAA,EACJ,CAAA,EAAG,CAAC,qBAAA,EAAuB,eAAe,CAAC,CAAA;AAE3C,EAAAvC,uBAAAA,CAAM,UAAU,MAAM;AAKlB,IAAA,IAAI,CAAC,qBAAA,EAAuB;AAC5B,IAAA,IAAI,oBAAoB,OAAA,EAAS;AACjC,IAAA,IAAI,CAAC,aAAA,EAAe;AAChB,MAAA,gCAAA,CAAiC,MAAS,CAAA;AAAA,IAC9C;AAAA,EACJ,CAAA,EAAG,CAAC,qBAAA,EAAuB,aAAa,CAAC,CAAA;AAEzC,EAAA,uBACIA,uBAAAA,CAAA,aAAA,CAAC,4BAAA,CAA6B,QAAA,EAA7B,EAAsC,KAAA,EAAO,CAAC,aAAA,EAAe,wBAAA,EAA0B,eAAe,CAAA,EAAA,EAClG,QACL,CAAA;AAER","file":"index.browser.cjs","sourcesContent":["import React from 'react';\n\ntype CacheEntry<T> =\n | Readonly<{ promise: PromiseLike<unknown>; status: 'pending' }>\n | Readonly<{ reason: unknown; status: 'rejected' }>\n | Readonly<{ status: 'fulfilled'; value: T }>;\n\nconst cache = new WeakMap<PromiseLike<unknown>, CacheEntry<unknown>>();\n\nfunction trackedPromise<T>(promise: PromiseLike<T>): PromiseLike<void> {\n // Returns the *chained* promise (not the original). React subscribes to the thrown value to\n // know when to retry; throwing the chained one means retry runs strictly after our\n // cache-update handler, so the next render is guaranteed to see the settled entry.\n return promise.then(\n value => {\n cache.set(promise, { status: 'fulfilled', value });\n },\n reason => {\n cache.set(promise, { reason, status: 'rejected' });\n },\n );\n}\n\n/**\n * React 18 fallback for `React.use(promise)` — suspends by throwing the promise on first render,\n * returns the resolved value on subsequent renders, and re-throws the rejection if the promise\n * settles with an error.\n *\n * The promise identity must be stable across renders so the cache keyed off it can find the\n * settled entry on the second render. The {@link ClientProvider}'s consumer-facing contract\n * documents this — pass a memoised or module-scope promise.\n */\nfunction usePromiseShim<T>(promise: PromiseLike<T>): T {\n let entry = cache.get(promise) as CacheEntry<T> | undefined;\n if (entry == null) {\n const tracked = trackedPromise(promise);\n entry = { promise: tracked, status: 'pending' };\n cache.set(promise, entry);\n }\n if (entry.status === 'pending') throw entry.promise;\n if (entry.status === 'rejected') throw entry.reason;\n return entry.value;\n}\n\ntype ReactWithUse = typeof React & {\n use?: <T>(promise: PromiseLike<T>) => T;\n};\n\nfunction isPromiseLike<T>(value: PromiseLike<T> | T): value is PromiseLike<T> {\n return (\n !!value &&\n (typeof value === 'object' || typeof value === 'function') &&\n typeof (value as PromiseLike<T>).then === 'function'\n );\n}\n\n/**\n * Returns `value` directly if it is a plain value, or unwraps it (suspending the subtree until\n * it settles) if it is a {@link PromiseLike}. Designed to be invoked unconditionally so consumers\n * don't have to gate on the runtime shape of the input — that keeps the call site\n * rules-of-hooks-friendly even when the same provider sees both sync and async clients.\n *\n * The `React.use` lookup is deferred to call time so the module has no top-level side effects\n * (agadoo's tree-shake check fails otherwise on the property-access expression).\n */\nexport function usePromise<T>(value: PromiseLike<T> | T): T {\n if (!isPromiseLike(value)) return value;\n return ((React as ReactWithUse).use ?? usePromiseShim)(value);\n}\n","import type { Client } from '@solana/kit';\nimport React from 'react';\n\nimport { usePromise } from './usePromise';\n\nconst ClientContext = /*#__PURE__*/ React.createContext<Client<object> | null>(null);\n\n/**\n * The React context that holds the Kit client published by the nearest {@link ClientProvider}.\n * Exported for advanced cases such as third-party providers that wrap and extend the client; most\n * consumers should reach for {@link useClient} or one of the higher-level hooks instead.\n */\nexport { ClientContext };\n\n/**\n * Props accepted by {@link ClientProvider}.\n */\nexport type ClientProviderProps = Readonly<{\n children?: React.ReactNode;\n /**\n * The Kit client to publish to descendants, or a promise resolving to one (e.g. when the\n * client has async plugins). The reference must be stable across renders — build it at\n * module scope or memoise it with `useMemo` when its config is reactive.\n */\n client: Client<object> | Promise<Client<object>>;\n}>;\n\n/**\n * Publishes a caller-owned Kit client to its subtree. Required for `useClient`,\n * `useClientCapability`, and any plugin-specific hook that depends on a client capability.\n *\n * Plugin composition belongs in plain Kit — the provider does no composition, lifecycle\n * management, or disposal; it is a value channel, not a lifecycle channel. When config changes at\n * runtime (e.g. cluster toggle), rebuild the client in `useMemo` and pass the new reference; the\n * subtree resubscribes against the new client identity.\n *\n * Async client support: when `client` is a promise (e.g. `createClient().use(asyncPlugin())`),\n * the provider suspends the subtree via the nearest `<Suspense>` boundary until the promise\n * resolves. On React 19 this delegates to `React.use(promise)`; on React 18 a thrown-promise shim\n * keyed by promise identity preserves the same contract.\n *\n * @example Sync client\n * ```tsx\n * import { createClient } from '@solana/kit';\n * import { ClientProvider } from '@solana/react';\n *\n * const client = createClient(); // .use(...) plugins as needed\n *\n * function App() {\n * return (\n * <ClientProvider client={client}>\n * <MyApp />\n * </ClientProvider>\n * );\n * }\n * ```\n *\n * @example Async client (Suspense)\n * ```tsx\n * const clientPromise = useMemo(\n * () => createClient().use(someAsyncPlugin()),\n * [],\n * );\n *\n * <Suspense fallback={<Splash />}>\n * <ClientProvider client={clientPromise}>\n * <Shell />\n * </ClientProvider>\n * </Suspense>\n * ```\n *\n * @see {@link useClient}\n */\nexport function ClientProvider({ children, client }: ClientProviderProps): React.ReactElement {\n const resolved = usePromise(client);\n return <ClientContext.Provider value={resolved}>{children}</ClientContext.Provider>;\n}\n","import { useEffect, useLayoutEffect } from 'react';\n\n/**\n * `useLayoutEffect` warns when run on the server because layout effects only make sense after a\n * DOM is mounted. For our use, plain `useEffect` is functionally equivalent on the server (no\n * event handlers can fire mid-render anyway), so we pick at module load time and stay silent\n * during SSR.\n *\n * @internal\n */\nexport const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n","import { createReactiveActionStore } from '@solana/kit';\nimport { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\n\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\n/**\n * Reactive state and controls for an async action managed by {@link useAction}\n * (and plugin-specific hooks built on top of it).\n *\n * Lifecycle: starts at `idle`. Each `dispatch(...)` flips to `running`, then to `success` or\n * `error` depending on the outcome. `data` from a prior `success` and `error` from a prior failure\n * both persist through subsequent `running` states for stale-while-revalidate UX. `success` clears\n * `error`; only `reset()` clears `data`.\n *\n * Calling `dispatch(...)` while a previous call is in flight aborts the first via its\n * `AbortSignal` and replaces it. Fire-and-forget `dispatch` callers never observe this; awaiters of\n * a superseded `dispatchAsync` call see a rejection with an `AbortError`, filterable via\n * `isAbortError` from `@solana/promises`.\n *\n * @typeParam TArgs - The argument tuple `dispatch` accepts; forwarded to the wrapped function\n * after the abort signal.\n * @typeParam TResult - The value the wrapped function resolves to on success.\n */\nexport type ActionResult<TArgs extends readonly unknown[], TResult> = {\n /** The result on success, or `undefined` if no successful call has happened yet. */\n data: TResult | undefined;\n /**\n * Trigger the action and forget it. Returns `undefined` synchronously and never throws —\n * failures surface on `status` / `error`, and superseded or `reset()`-aborted calls produce no\n * state change. This is the variant to wire into UI event handlers (`onClick={() => dispatch()}`):\n * there is no promise to handle, so it can't produce an unhandled rejection. Calling `dispatch`\n * again while a prior call is in flight aborts the first. Stable reference.\n *\n * @see {@link ActionResult.dispatchAsync} when you need the resolved value or propagated errors.\n */\n dispatch: (...args: TArgs) => void;\n /**\n * Trigger the action and await the outcome. Resolves with the wrapped function's result, or\n * rejects with the thrown error. Calling `dispatch`/`dispatchAsync` again while a prior call is\n * in flight aborts the first and rejects its promise with an `AbortError`. Stable reference.\n *\n * Mirrors `ReactiveActionStore.dispatchAsync`. Use this from imperative callers that read the\n * resolved value (e.g. to navigate on success); filter supersede rejections with `isAbortError`\n * from `@solana/promises`. Prefer {@link ActionResult.dispatch} from event handlers that don't\n * await — its returned promise, left unhandled, surfaces every supersede/abort as an\n * `unhandledrejection`.\n */\n dispatchAsync: (...args: TArgs) => Promise<TResult>;\n /**\n * The error from the most recent failed call, or `undefined`. Persists through a subsequent\n * `running` state so UIs can keep showing the prior failure while a retry is in flight; a\n * subsequent `success` clears it.\n */\n error: unknown;\n /** `true` when `status === 'error'`. */\n isError: boolean;\n /** `true` when `status === 'idle'`. */\n isIdle: boolean;\n /** `true` when `status === 'running'` — a dispatch is in flight. */\n isRunning: boolean;\n /** `true` when `status === 'success'`. */\n isSuccess: boolean;\n /** Reset state back to `idle`, aborting any in-flight call. Stable reference. */\n reset: () => void;\n /**\n * The current lifecycle status as a discriminated string. The `isIdle` / `isRunning` /\n * `isSuccess` / `isError` booleans below are derived from this — pick whichever reads better\n * at the call site.\n */\n status: 'error' | 'idle' | 'running' | 'success';\n};\n\n/**\n * Bridge an arbitrary async function into a reactive {@link ActionResult}. Each `dispatch(...)`\n * call runs the function with a fresh {@link AbortSignal} and tracks its lifecycle through React\n * state; a second call while a first is in flight aborts the first.\n *\n * `fn` is held in a ref that always points at the latest closure — there is no `deps` array to\n * maintain. Each `dispatch(...)` invokes the most recently rendered `fn`, so values captured\n * inside (e.g. form state, route params) are always fresh without explicit dependency tracking.\n * In-flight calls are unaffected — they continue with the closure they captured at dispatch time.\n *\n * @typeParam TArgs - The argument tuple `dispatch` accepts; forwarded to `fn` after the abort\n * signal.\n * @typeParam TResult - The value `fn` resolves to on success.\n *\n * @example\n * ```tsx\n * import { useAction } from '@solana/react';\n *\n * function PostMessageButton({ url, body }: { url: string; body: string }) {\n * const { dispatch, isRunning, error } = useAction(async (signal, content: string) => {\n * const res = await fetch(url, { body: content, method: 'POST', signal });\n * if (!res.ok) throw new Error(`HTTP ${res.status}`);\n * return res.json() as Promise<{ id: string }>;\n * });\n * return (\n * <button disabled={isRunning} onClick={() => dispatch(body)}>\n * {isRunning ? 'Posting…' : error ? 'Retry' : 'Post'}\n * </button>\n * );\n * }\n * ```\n *\n * @see {@link ActionResult}\n */\nexport function useAction<TArgs extends readonly unknown[], TResult>(\n fn: (signal: AbortSignal, ...args: TArgs) => Promise<TResult>,\n): ActionResult<TArgs, TResult> {\n // Stable callback over the latest closure. Similar to `useEffectEvent`, but we need to\n // pass the callback to `createReactiveActionStore` so need to implement the pattern manually.\n const fnRef = useRef(fn);\n useIsomorphicLayoutEffect(() => {\n fnRef.current = fn;\n });\n\n // `createReactiveActionStore` only reads the callback when the returned `dispatch` is\n // called, not during render. The `react-hooks/refs` rule doesn't know that, so we silence it.\n // eslint-disable-next-line react-hooks/refs\n const [store] = useState(() =>\n createReactiveActionStore<TArgs, TResult>((signal, ...args) => fnRef.current(signal, ...args)),\n );\n\n // Reset on unmount so any in-flight call is aborted and state is dropped.\n useEffect(() => () => store.reset(), [store]);\n\n const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);\n\n return useMemo(\n () => ({\n data: state.data,\n dispatch: store.dispatch,\n dispatchAsync: store.dispatchAsync,\n error: state.error,\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n isRunning: state.status === 'running',\n isSuccess: state.status === 'success',\n reset: store.reset,\n status: state.status,\n }),\n [state, store],\n );\n}\n","import { type Client, SOLANA_ERROR__REACT__MISSING_PROVIDER, SolanaError } from '@solana/kit';\nimport React from 'react';\n\nimport { ClientContext } from './ClientProvider';\n\n/**\n * Reads the Kit client published by the nearest {@link ClientProvider}. Throws a\n * {@link SolanaError} with code {@link SOLANA_ERROR__REACT__MISSING_PROVIDER} if no provider is\n * mounted in the ancestor tree.\n *\n * Defaults to the base {@link Client} shape. Callers who know a specific plugin is installed may\n * widen the type via the generic — this is a pure cast with no runtime capability check, so reach\n * for {@link useClientCapability} when a missing plugin should fail loudly at mount instead of\n * surfacing later as `undefined`.\n *\n * @typeParam TClient - The shape the client is expected to satisfy. Pure type assertion.\n *\n * @example\n * ```tsx\n * import { ClientWithRpc, GetEpochInfoApi } from '@solana/kit';\n * import { useClient } from '@solana/react';\n *\n * function ManualSend() {\n * const client = useClient<ClientWithRpc<GetEpochInfoApi>>();\n * return <button onClick={() => client.rpc.getEpochInfo().send()}>Fetch</button>;\n * }\n * ```\n *\n * @see {@link ClientProvider}\n * @see {@link useClientCapability}\n */\nexport function useClient<TClient extends object = object>(): Client<TClient> {\n const client = React.useContext(ClientContext);\n if (client == null) {\n throw new SolanaError(SOLANA_ERROR__REACT__MISSING_PROVIDER, { hookName: 'useClient' });\n }\n return client as Client<TClient>;\n}\n","import { type Client, SOLANA_ERROR__REACT__MISSING_CAPABILITY, SolanaError } from '@solana/kit';\n\nimport { useClient } from './useClient';\n\n/**\n * Configuration for {@link useClientCapability}.\n */\nexport type UseClientCapabilityConfig = Readonly<{\n /**\n * The capability name (or names) the hook depends on. Each is checked against the client with\n * a runtime `in` test before the narrowed value is returned. Pass an array when the hook\n * needs multiple capabilities (e.g. `['rpc', 'rpcSubscriptions']`); the same `providerHint` is\n * used for any that's missing.\n */\n capability: string | readonly string[];\n /**\n * Name of the calling hook, surfaced in the missing-capability error so users can locate the\n * call site quickly.\n */\n hookName: string;\n /**\n * Free-form actionable hint shown alongside the error — usually a one-liner naming the plugin\n * (or family of plugins) the user should install.\n */\n providerHint: string;\n}>;\n\n/**\n * Reads the client from the nearest {@link ClientProvider} and asserts at mount that the\n * requested capability is installed, narrowing the return type via the generic. Throws a\n * {@link SolanaError} with code {@link SOLANA_ERROR__REACT__MISSING_CAPABILITY} when the\n * capability is absent — including the calling `hookName` and a `providerHint` so users can fix\n * the mistake without cross-referencing docs.\n *\n * Use this from the implementation of plugin-specific hooks. Apps that need ad-hoc access without\n * a runtime check can reach for {@link useClient} directly and supply their own type narrowing.\n *\n * @typeParam TClient - The narrowed client shape returned once the capability assertion passes.\n * Always pass this generic — the hook can't infer it from a string.\n *\n * @example\n * ```ts\n * import { ClientWithRpc, GetEpochInfoApi } from '@solana/kit';\n * import { useClientCapability } from '@solana/react';\n *\n * function useRpc() {\n * return useClientCapability<ClientWithRpc<GetEpochInfoApi>>({\n * capability: 'rpc',\n * hookName: 'useRpc',\n * providerHint: 'Install `solanaRpc()` on the client.',\n * });\n * }\n * ```\n *\n * @see {@link useClient}\n * @see {@link ClientProvider}\n */\nexport function useClientCapability<TClient extends object>({\n capability,\n hookName,\n providerHint,\n}: UseClientCapabilityConfig): Client<TClient> {\n const client = useClient<TClient>();\n const required = typeof capability === 'string' ? [capability] : capability;\n const missing = required.filter(name => !Object.hasOwn(client, name));\n if (missing.length > 0) {\n throw new SolanaError(SOLANA_ERROR__REACT__MISSING_CAPABILITY, {\n capabilities: missing,\n hookName,\n providerHint,\n });\n }\n return client;\n}\n","import { ReactiveActionStore, ReactiveState, ReactiveStreamStore } from '@solana/kit';\n\nconst DISABLED_ACTION_STATE = Object.freeze({\n data: undefined,\n error: undefined,\n status: 'idle' as const,\n});\n\nconst IDLE_STREAM_STATE: ReactiveState<never> = Object.freeze({\n data: undefined,\n error: undefined,\n status: 'idle',\n});\n\nconst noopUnsubscribe = () => {};\nconst noopSubscribe = () => noopUnsubscribe;\nconst rejectedAbortError = (): Promise<never> => Promise.reject(new DOMException('Aborted', 'AbortError'));\n\n/**\n * A {@link ReactiveActionStore} that never transitions out of `idle` and rejects any attempt to\n * dispatch. Returned by `useRequest` (and other action-store hooks) when their factory function\n * returns `null`, signalling that the call should be gated off — for example because a required\n * input (an address, a query string) is not yet known.\n *\n * The hook's result bridge maps this store's `idle` state to a `disabled` status so call sites\n * can distinguish \"not enabled\" from \"loading\" without an extra flag.\n */\nexport function disabledActionStore<T>(): ReactiveActionStore<[], T> {\n return {\n dispatch: noopUnsubscribe,\n dispatchAsync: rejectedAbortError,\n getState: () => DISABLED_ACTION_STATE,\n reset: noopUnsubscribe,\n subscribe: noopSubscribe,\n withSignal: () => ({\n dispatch: noopUnsubscribe,\n dispatchAsync: rejectedAbortError,\n }),\n };\n}\n\n/**\n * A {@link ReactiveStreamStore} that never transitions out of `idle` and ignores every\n * `connect` / `reset` / `subscribe` call. Returned by `useSubscription` when its\n * source is `null`, signalling that the subscription should be gated off — for example because\n * a required input (an address) is not yet known.\n *\n * The hook's result bridge maps this store's `idle` state to a `disabled` status so call sites\n * can distinguish \"not enabled\" from \"loading\" without an extra flag.\n */\nexport function disabledStreamStore<T>(): ReactiveStreamStore<T> {\n return {\n connect: noopUnsubscribe,\n getState: () => IDLE_STREAM_STATE,\n reset: noopUnsubscribe,\n subscribe: noopSubscribe,\n withSignal: () => ({ connect: noopUnsubscribe }),\n };\n}\n","import { type MutableRefObject, useRef } from 'react';\n\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\n/**\n * Hold `value` in a ref that is re-synced to the latest render's value after every commit.\n *\n * Lets a callback (or a store created once) read the freshest closure value at call time without\n * taking it as a dependency, so the consumer's own identity stays stable across renders. The sync\n * runs in a layout effect so the ref is current before passive effects and event handlers fire.\n *\n * @typeParam T - The type of the value being tracked.\n *\n * @returns A stable {@link MutableRefObject} whose `current` always reflects the most recent render.\n *\n * @internal\n */\nexport function useLatest<T>(value: T): MutableRefObject<T> {\n const ref = useRef(value);\n useIsomorphicLayoutEffect(() => {\n ref.current = value;\n });\n return ref;\n}\n","import { useCallback, useEffect, useRef } from 'react';\n\nimport { useLatest } from './useLatest';\n\n/**\n * Options accepted by the `refresh`-style callback returned from {@link useReactiveStoreLifecycle}.\n *\n * @internal\n */\ntype RefireOptions = {\n /**\n * Override the configured `getAbortSignal` factory for this attempt. Passing the key at all\n * (even as `undefined`) opts out of the factory; omitting it falls back to the factory.\n */\n abortSignal?: AbortSignal | undefined;\n};\n\n// In dev, warn when the store identity changes this many times inside `CHURN_WINDOW_MS`. A handful\n// of recreations is normal (StrictMode's mount/cleanup/mount, an occasional dependency change); a\n// burst this large within a second only happens when an unmemoized `source`/`spec` mints a fresh\n// store every render — the self-sustaining dispatch/abort loop. Set well above any legitimate churn.\nconst CHURN_WARNING_THRESHOLD = 25;\nconst CHURN_WINDOW_MS = 1_000;\n\n/**\n * Shared lifecycle for the source-keyed reactive-store hooks (`useRequest`, and the stream-store\n * hooks built on the same shape). Owns the three pieces each of them otherwise repeats verbatim:\n *\n * - ref-syncs `getAbortSignal` so an inline factory passed every render doesn't churn the caller's\n * store memo,\n * - fires the store on commit and resets it on teardown / store-identity change,\n * - returns a stable `refresh`-style callback carrying the presence-based signal override.\n *\n * `fire` performs the store's \"go\" verb — `dispatch` for action stores, `connect` for stream\n * stores — optionally with a per-attempt {@link AbortSignal}. Pass it as a stable (module-level)\n * function so the returned callback stays referentially stable.\n *\n * In development it also emits a `console.error` when the store identity changes far more often\n * than legitimate use would explain, which is the signature of an unmemoized `source`/`spec`\n * driving an infinite dispatch/abort loop.\n *\n * @typeParam TStore - The reactive store type; only its `reset()` method is needed here.\n *\n * @param store - The store to drive; recreated by the caller whenever the source identity changes.\n * @param fire - Performs the store's go verb, optionally with a per-attempt signal.\n * @param getAbortSignal - Optional factory invoked per attempt to mint a fresh signal.\n *\n * @returns A stable callback that re-fires the store, accepting the per-attempt signal override.\n *\n * @internal\n */\nexport function useReactiveStoreLifecycle<TStore extends { reset(): void }>(\n store: TStore,\n fire: (store: TStore, signal: AbortSignal | undefined) => void,\n getAbortSignal: (() => AbortSignal) | undefined,\n): (options?: RefireOptions) => void {\n const getAbortSignalRef = useLatest(getAbortSignal);\n\n const refresh = useCallback(\n (options?: RefireOptions) => {\n // Presence-based override: an explicit `abortSignal` key (even `undefined`) opts out\n // of the factory for this attempt. Omitting the key falls back to the factory.\n const signal = options && 'abortSignal' in options ? options.abortSignal : getAbortSignalRef.current?.();\n fire(store, signal);\n },\n // `getAbortSignalRef` is a stable ref and `fire` a stable (module-level) function, so\n // `refresh` only changes identity when `store` does.\n [fire, getAbortSignalRef, store],\n );\n\n // Dev-only churn guard. This effect re-runs once per store identity (deps include `store`), so\n // counting its runs within a rolling window flags an unmemoized `source`/`spec` that mints a\n // fresh store every render. Counting lives here, not in render, so there's no render-phase\n // ref mutation for StrictMode to flag.\n const churnRef = useRef({ count: 0, warned: false, windowStart: 0 });\n\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\") {\n const churn = churnRef.current;\n const now = Date.now();\n if (now - churn.windowStart > CHURN_WINDOW_MS) {\n churn.windowStart = now;\n churn.count = 0;\n }\n if (++churn.count > CHURN_WARNING_THRESHOLD && !churn.warned) {\n churn.warned = true;\n\n console.error(\n 'A reactive-store hook (e.g. `useRequest`) recreated its store %d times within ' +\n '1s. This almost always means the `source`/`spec` passed to it is a fresh ' +\n 'reference on every render — wrap it in `useMemo`/`useCallback` keyed on its ' +\n 'inputs. Each recreation aborts the in-flight request before it can complete, ' +\n 'so nothing ever loads.',\n churn.count,\n );\n }\n }\n refresh();\n return () => store.reset();\n }, [refresh, store]);\n\n return refresh;\n}\n","import { ReactiveActionStore } from '@solana/kit';\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { RequestResult } from './useRequest';\n\n/**\n * Subscribes to a {@link ReactiveActionStore} and maps its `idle | running | success | error`\n * lifecycle onto the {@link RequestResult} shape consumed by `useRequest`.\n *\n * `idle` is ambiguous on its own: it covers both \"no source — store is disabled\" and \"real source,\n * dispatch effect hasn't fired yet on the current render.\" The `disabled` flag disambiguates:\n * disabled → `status: 'disabled'`, enabled → `status: 'fetching'` (the dispatch is about to fire\n * on commit; consumers see a single `fetching` paint rather than briefly flashing `disabled`).\n *\n * - `idle` + disabled → `disabled`\n * - `idle` + enabled → `fetching` (first paint, dispatch effect about to commit)\n * - `running` → `fetching` (caller inspects `data` / `error` to know if there's stale content)\n * - `success` → `success`\n * - `error` → `error`\n *\n * The action store's built-in stale-while-revalidate carries `state.data` and `state.error`\n * across attempts, so the bridge doesn't need to mirror them.\n *\n * @internal\n */\nexport function useRequestResult<T>(\n store: ReactiveActionStore<[], T>,\n refresh: (options?: { abortSignal?: AbortSignal | undefined }) => void,\n disabled: boolean,\n): RequestResult<T> {\n const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);\n return useMemo(() => {\n const status: RequestResult<T>['status'] =\n state.status === 'idle'\n ? disabled\n ? 'disabled'\n : 'fetching'\n : state.status === 'running'\n ? 'fetching'\n : state.status; // 'success' | 'error'\n return {\n data: state.data,\n error: state.error,\n refresh,\n status,\n };\n }, [state, refresh, disabled]);\n}\n","import { createReactiveActionStore, ReactiveActionSource, ReactiveActionStore } from '@solana/kit';\nimport { useMemo } from 'react';\n\nimport { disabledActionStore } from './staticStores';\nimport { useReactiveStoreLifecycle } from './useReactiveStoreLifecycle';\nimport { useRequestResult } from './useRequestResult';\n\n// Module-level so it's a stable reference — keeps the `refresh` callback from\n// `useReactiveStoreLifecycle` referentially stable across renders.\nfunction fireAction<T>(store: ReactiveActionStore<[], T>, signal: AbortSignal | undefined): void {\n if (signal) store.withSignal(signal).dispatch();\n else store.dispatch();\n}\n\n/**\n * Reactive state for a one-shot request managed by {@link useRequest}.\n *\n * Lifecycle: starts at `fetching` (or `disabled` when the source is `null`) and auto-fires on\n * mount; transitions to `success` on success or `error` on failure. `refresh()` re-fires the\n * request — while a re-fire is in flight, `status` returns to `fetching` and the stale `data`\n * and/or `error` from the prior outcome remain populated (stale-while-revalidate).\n *\n * @typeParam T - The value the underlying request resolves to.\n */\nexport type RequestResult<T> = {\n /**\n * The most recent successful value, or `undefined` if no call has succeeded yet (or while\n * disabled). Persists across subsequent refreshes (including failed ones) until a new success\n * replaces it or `reset()` clears the store.\n */\n data: T | undefined;\n /**\n * The error from the most recent failed call, or `undefined` if no call has failed (or while\n * disabled). Persists across subsequent refreshes until a new success clears it. May coexist\n * with `data` when a successful attempt is followed by a failing one.\n */\n error: unknown;\n /**\n * Re-fire the request. By default each call mints a fresh signal from `getAbortSignal` (if\n * configured) and threads it through the underlying store's\n * `withSignal(signal).dispatch()`. Pass `{ abortSignal }` to override the configured factory\n * for just this attempt. Pass `{ abortSignal: undefined }` to opt out of the factory entirely\n * for this attempt and fire with no caller-provided signal.\n *\n * Stable reference.\n */\n refresh: (options?: { abortSignal?: AbortSignal | undefined }) => void;\n /**\n * Lifecycle status as a discriminated string:\n * - `fetching`: a request is in flight. `data` and `error` carry whatever stale content was\n * available before this attempt (both `undefined` on the first attempt; either or both\n * populated on a refresh after a prior outcome).\n * - `success`: most recent call succeeded; `data` holds the result.\n * - `error`: most recent call failed; `error` holds the reason.\n * - `disabled`: source was `null`.\n */\n status: 'disabled' | 'error' | 'fetching' | 'success';\n};\n\n/** Options accepted by {@link useRequest}. */\nexport type UseRequestOptions = {\n /**\n * Factory invoked on every attempt (initial fire + every `refresh()`). The returned signal is\n * attached to that attempt via the underlying store's `withSignal(signal).dispatch()`, so\n * aborting it cancels just the current attempt.\n *\n * The most common use is per-attempt timeouts: `getAbortSignal: () => AbortSignal.timeout(5000)`\n * gives every attempt its own 5-second clock that resets on `refresh()`.\n *\n * Held in a ref synced to the latest render's closure — there is no need to memoize an inline\n * factory.\n */\n getAbortSignal?: () => AbortSignal;\n};\n\n/**\n * Fire a one-shot request on mount and re-fire each time `source` changes identity or `refresh()`\n * is called. Returns reactive state tracking the call's lifecycle.\n *\n * Two ways to pass the work:\n *\n * - A {@link ReactiveActionSource} — the `{ reactiveStore() }` duck-type satisfied by\n * `PendingRpcRequest`.\n * - An async function `(signal: AbortSignal) => Promise<T>` — wrap any one-shot async source\n * (a `fetch`, a third-party SDK call, etc). Most general shape.\n *\n * Pass `null` to disable; the result reports `status: 'disabled'`.\n *\n * Memoize the input (`useMemo` for a source, `useCallback` for a function) keyed on whatever\n * inputs it depends on.\n *\n * @typeParam T - The value the underlying request resolves to.\n *\n * @example\n * ```tsx\n * function LatestBlockhash() {\n * const client = useClient<ClientWithRpc<GetLatestBlockhashApi>>();\n * const source = useMemo(() => client.rpc.getLatestBlockhash(), [client]);\n * const { data, error, refresh } = useRequest(source, {\n * getAbortSignal: () => AbortSignal.timeout(5_000),\n * });\n * if (error) return <button onClick={refresh}>Retry</button>;\n * return <p>{data ? `Blockhash: ${data.value.blockhash}` : 'Loading…'}</p>;\n * }\n *\n * // Function shape — wraps an arbitrary async call:\n * function Profile({ userId }: { userId: string }) {\n * const fetcher = useCallback(\n * (signal: AbortSignal) => fetch(`/api/users/${userId}`, { signal }).then(r => r.json()),\n * [userId],\n * );\n * const { data, error, refresh } = useRequest(fetcher);\n * if (error) return <button onClick={refresh}>Retry</button>;\n * return <p>{data ? data.name : 'Loading…'}</p>;\n * }\n * ```\n *\n * @see {@link RequestResult}\n * @see {@link UseRequestOptions}\n */\nexport function useRequest<T>(\n source: ReactiveActionSource<T> | ((signal: AbortSignal) => Promise<T>) | null,\n options?: UseRequestOptions,\n): RequestResult<T> {\n // One store per `source`. Both creation paths return an `idle` store; the initial dispatch\n // lives in the lifecycle effect below so the memo body stays pure (StrictMode's dev\n // double-render, and any future render-discard, won't fire a network request from a discarded\n // render).\n //\n // Note: `useMemo` is permitted to discard memoized values across renders (independent of deps);\n // if React ever does so here, the discard surfaces as a fresh store with empty `data` /\n // `error` and an immediate refetch — same shape as a remount. In practice this doesn't happen,\n // but if React changes and it becomes an issue, we'd need to rework this.\n const store = useMemo(() => {\n if (source == null) return disabledActionStore<T>();\n return typeof source === 'function' ? createReactiveActionStore<[], T>(source) : source.reactiveStore();\n }, [source]);\n\n // Fire on commit, reset on store change / unmount, and expose the stable `refresh` callback.\n // `store.reset()` aborts the in-flight request via the action store's internal controller, so\n // under StrictMode's mount → cleanup → mount sequence the first dispatch is properly aborted\n // before the second one fires.\n const refresh = useReactiveStoreLifecycle(store, fireAction, options?.getAbortSignal);\n\n return useRequestResult(store, refresh, source == null);\n}\n","import {\n SolanaSignAndSendTransaction,\n SolanaSignAndSendTransactionFeature,\n SolanaSignAndSendTransactionInput,\n SolanaSignAndSendTransactionOutput,\n} from '@solana/wallet-standard-features';\nimport {\n WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED,\n WalletStandardError,\n} from '@wallet-standard/errors';\nimport { getWalletAccountFeature, type UiWalletAccount } from '@wallet-standard/ui';\nimport { getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } from '@wallet-standard/ui-registry';\nimport { useCallback } from 'react';\n\nimport { OnlySolanaChains } from './chain';\n\ntype Input = Readonly<\n Omit<SolanaSignAndSendTransactionInput, 'account' | 'chain' | 'options'> & {\n options?: Readonly<{\n minContextSlot?: bigint;\n }>;\n }\n>;\ntype Output = SolanaSignAndSendTransactionOutput;\n\n/**\n * Use this to get a function capable of signing a serialized transaction with the private key of a\n * {@link UiWalletAccount} and sending it to the network for processing.\n *\n * @param chain The identifier of the chain the transaction is destined for. Wallets may use this to\n * simulate the transaction for the user.\n *\n * @example\n * ```tsx\n * import { getBase58Decoder } from '@solana/codecs-strings';\n * import { useSignAndSendTransaction } from '@solana/react';\n *\n * function SignAndSendTransactionButton({ account, transactionBytes }) {\n * const signAndSendTransaction = useSignAndSendTransaction(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const { signature } = await signAndSendTransaction({\n * transaction: transactionBytes,\n * });\n * const base58TransactionSignature = getBase58Decoder().decode(signature);\n * window.alert(\n * `View transaction: https://explorer.solana.com/tx/${base58TransactionSignature}?cluster=devnet`,\n * );\n * } catch (e) {\n * console.error('Failed to send transaction', e);\n * }\n * }}\n * >\n * Sign and Send Transaction\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignAndSendTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): (input: Input) => Promise<Output>;\nexport function useSignAndSendTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (input: Input) => Promise<Output>;\nexport function useSignAndSendTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (input: Input) => Promise<Output> {\n const signAndSendTransactions = useSignAndSendTransactions(uiWalletAccount, chain);\n return useCallback(\n async input => {\n const [result] = await signAndSendTransactions(input);\n return result;\n },\n [signAndSendTransactions],\n );\n}\n\n/**\n * Use this to get a function capable of signing one or more serialized transactions with the private\n * key of a {@link UiWalletAccount} and sending them to the network for processing. This supports\n * wallets that allow batching multiple transactions in a single request.\n *\n * @example\n * ```tsx\n * import { useSignAndSendTransactions } from '@solana/react';\n *\n * function SignAndSendTransactionsButton({ account, transactionBytes1, transactionBytes2 }) {\n * const signAndSendTransactions = useSignAndSendTransactions(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const [first, second] = await signAndSendTransactions(\n * { transaction: transactionBytes1 },\n * { transaction: transactionBytes2 },\n * );\n * window.alert(\n * `Transaction signatures: ${first.signature.toString()}, ${second.signature.toString()}`,\n * );\n * } catch (e) {\n * console.error('Failed to send transactions', e);\n * }\n * }}\n * >\n * Sign and Send Transactions\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignAndSendTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]>;\nexport function useSignAndSendTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]>;\nexport function useSignAndSendTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]> {\n if (!uiWalletAccount.chains.includes(chain)) {\n throw new WalletStandardError(WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED, {\n address: uiWalletAccount.address,\n chain,\n featureName: SolanaSignAndSendTransaction,\n supportedChains: [...uiWalletAccount.chains],\n supportedFeatures: [...uiWalletAccount.features],\n });\n }\n const signAndSendTransactionFeature = getWalletAccountFeature(\n uiWalletAccount,\n SolanaSignAndSendTransaction,\n ) as SolanaSignAndSendTransactionFeature[typeof SolanaSignAndSendTransaction];\n const account = getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWalletAccount);\n return useCallback(\n async (...inputs) => {\n if (inputs.length === 0) {\n return [];\n }\n const inputsWithChainAndAccount = inputs.map(({ options, ...rest }) => {\n const minContextSlot = options?.minContextSlot;\n return {\n ...rest,\n account,\n chain,\n ...(minContextSlot != null\n ? {\n options: {\n minContextSlot: Number(minContextSlot),\n },\n }\n : null),\n };\n });\n const results = await signAndSendTransactionFeature.signAndSendTransaction(...inputsWithChainAndAccount);\n return results;\n },\n [account, chain, signAndSendTransactionFeature],\n );\n}\n","import { ReactiveStreamStore } from '@solana/kit';\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { SubscriptionResult } from './useSubscription';\n\n/**\n * Subscribes to a {@link ReactiveStreamStore} and maps its\n * `idle | loading | loaded | error` lifecycle onto the {@link SubscriptionResult} shape\n * consumed by `useSubscription`. The notification passes through unchanged.\n *\n * For status we map the `idle` state to either `loading` or `disabled`, depending on the\n * `disabled` param. This is because `useSubscription` automatically connects, so we treat\n * `idle` as `loading` when a source is present and `disabled` when it's not.\n *\n * Stale-while-revalidate flows naturally through `state.data` / `state.error`, which the store\n * preserves across `loading` transitions, so the bridge doesn't need to mirror them.\n *\n * @param store - The store to subscribe to.\n * @param reconnect - A stable callback that re-opens the stream. Forwarded to the result so call\n * sites have a single, hook-owned recovery affordance.\n * @param disabled - When `true`, the result reports `status: 'disabled'`. Used by\n * `useSubscription` to signal the null-source case.\n *\n * @internal\n */\nexport function useSubscriptionResult<T>(\n store: ReactiveStreamStore<T>,\n reconnect: (options?: { abortSignal?: AbortSignal | undefined }) => void,\n disabled: boolean,\n): SubscriptionResult<T> {\n const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);\n return useMemo(() => {\n const status: SubscriptionResult<T>['status'] =\n state.status === 'idle' ? (disabled ? 'disabled' : 'loading') : state.status;\n return { data: state.data, error: state.error, reconnect, status };\n }, [state, reconnect, disabled]);\n}\n","import { ReactiveStreamSource, ReactiveStreamStore } from '@solana/kit';\nimport { useMemo } from 'react';\n\nimport { disabledStreamStore } from './staticStores';\nimport { useReactiveStoreLifecycle } from './useReactiveStoreLifecycle';\nimport { useSubscriptionResult } from './useSubscriptionResult';\n\n// Module-level so it's a stable reference — keeps the `reconnect` callback from\n// `useReactiveStoreLifecycle` referentially stable across renders.\nfunction fireConnect<T>(store: ReactiveStreamStore<T>, signal: AbortSignal | undefined): void {\n if (signal) store.withSignal(signal).connect();\n else store.connect();\n}\n\n/**\n * Reactive state for a subscription managed by {@link useSubscription} (and other stream-store\n * hooks built on top of it).\n *\n * Lifecycle: starts at `loading` (or `disabled` when the source is `null`) and opens the\n * underlying stream on mount; transitions to `loaded` on the first notification or `error` on\n * failure. `reconnect()` re-opens the stream — while a reconnect is in flight, `status` returns\n * to `loading` and the stale `data` and/or `error` from the prior connection remain populated\n * (stale-while-revalidate).\n *\n * @typeParam T - The notification type emitted by the underlying source.\n */\nexport type SubscriptionResult<T> = {\n /**\n * The latest notification. `undefined` on the first load and while disabled. On `loading`\n * after a prior outcome, on `error`, and on a subsequent reconnect, holds the last\n * received notification.\n */\n data: T | undefined;\n /**\n * Error from the subscription, or `undefined`. On `loading` after a prior `error`, holds the\n * stale error so UIs can keep showing the failure context (e.g. a banner) while the\n * reconnect is in flight. A subsequent `loaded` clears it.\n */\n error: unknown;\n /**\n * Re-open the stream. By default each call mints a fresh signal from `getAbortSignal` (if\n * configured) and threads it through the underlying store's `withSignal(signal).connect()`.\n * Pass `{ abortSignal }` to override the configured factory for just this attempt. Pass\n * `{ abortSignal: undefined }` to opt out of the factory entirely for this attempt and open\n * with no caller-provided signal.\n *\n * Stable reference. Safe to put in `onClick` handlers or effect deps — typically wired up\n * to a \"Reconnect\" button when `status === 'error'`. Calls `store.connect()` under the\n * hood, so it always (re)opens the stream regardless of current status; the bridge\n * transitions back through `loading` while preserving stale data and error.\n */\n reconnect: (options?: { abortSignal?: AbortSignal | undefined }) => void;\n /**\n * Lifecycle status as a discriminated string:\n * - `loading`: a connection is in progress. On the first connection, `data` and `error` are\n * `undefined`. After a reconnect, `data` and `error` hold the last known values from the\n * previous connection (stale-while-revalidate).\n * - `loaded`: at least one notification has arrived.\n * - `error`: the subscription failed; `data` holds the last known value (if any).\n * - `disabled`: source was `null` — no subscription was opened.\n */\n status: 'disabled' | 'error' | 'loaded' | 'loading';\n};\n\n/** Options accepted by {@link useSubscription}. */\nexport type UseSubscriptionOptions = {\n /**\n * Factory invoked on every connection (initial subscribe + every `reconnect()`). The returned\n * signal is attached to that connection via the underlying store's\n * `withSignal(signal).connect()`, so aborting it tears down that connection.\n *\n * The most common use is per-connection timeouts:\n * `getAbortSignal: () => AbortSignal.timeout(30_000)` gives every connection its own\n * 30-second clock that resets on `reconnect()`.\n *\n * Held in a ref synced to the latest render's closure — there is no need to memoize an inline\n * factory.\n */\n getAbortSignal?: () => AbortSignal;\n};\n\n/**\n * Subscribe to a stream-store source and surface the latest notification as reactive state. The\n * subscription opens on mount, re-opens whenever `source` changes identity, and tears down on\n * unmount.\n *\n * Accepts any {@link ReactiveStreamSource} — the `{ reactiveStore() }` duck-type satisfied by\n * `PendingRpcSubscriptionsRequest` (e.g. `client.rpcSubscriptions.accountNotifications(addr)`)\n * and any plugin-authored stream object that follows the same convention. Pass `null` to\n * disable; the result reports `status: 'disabled'`.\n *\n * Memoize the source with `useMemo` keyed on whatever inputs it depends on; stable identity is\n * how the hook knows when to tear down and re-open.\n *\n * SSR-safe — on the server the connect effect doesn't run, so the store stays `idle` and the\n * hook reports `status: 'loading'`. The first client render hydrates from that same `loading`\n * paint, then commits the connect effect.\n *\n * @typeParam T - The notification type emitted by the source.\n *\n * @example\n * ```tsx\n * function AccountBalance({ address }: { address: Address }) {\n * const client = useClient<ClientWithRpcSubscriptions<AccountNotificationsApi>>();\n * const source = useMemo(() => client.rpcSubscriptions.accountNotifications(address), [client, address]);\n * const { data, error, reconnect } = useSubscription(source);\n * if (error) return <button onClick={reconnect}>Reconnect</button>;\n * return <p>{data ? `${data.value.lamports} lamports at slot ${data.context.slot}` : 'Connecting…'}</p>;\n * }\n * ```\n *\n * @see {@link SubscriptionResult}\n * @see {@link UseSubscriptionOptions}\n */\nexport function useSubscription<T>(\n source: ReactiveStreamSource<T> | null,\n options?: UseSubscriptionOptions,\n): SubscriptionResult<T> {\n // One store per `source`. Both creation paths return an `idle` store; the initial connect\n // lives in the lifecycle effect below so the memo body stays pure (StrictMode's dev\n // double-render, and any future render-discard, won't open a subscription from a discarded\n // render).\n const store = useMemo(() => {\n if (source == null) return disabledStreamStore<T>();\n return source.reactiveStore();\n }, [source]);\n\n // Connect on commit, reset on store change / unmount, and expose the stable `reconnect`\n // callback. `store.reset()` aborts the active connection via the stream store's internal\n // controller, so under StrictMode's mount → cleanup → mount sequence the first connect is\n // properly aborted before the second one fires. `disabledStreamStore` returns a store whose\n // `connect`/`reset` are no-ops, so the null-source case needs no explicit gate.\n const reconnect = useReactiveStoreLifecycle(store, fireConnect, options?.getAbortSignal);\n\n return useSubscriptionResult(store, reconnect, source == null);\n}\n","import { Address } from '@solana/kit';\nimport {\n SolanaSignIn,\n SolanaSignInFeature,\n SolanaSignInInput,\n SolanaSignInOutput,\n} from '@solana/wallet-standard-features';\nimport {\n getWalletAccountFeature,\n getWalletFeature,\n UiWallet,\n UiWalletAccount,\n UiWalletHandle,\n} from '@wallet-standard/ui';\nimport {\n getOrCreateUiWalletAccountForStandardWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,\n getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,\n getWalletForHandle_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,\n} from '@wallet-standard/ui-registry';\nimport { useCallback } from 'react';\n\ntype Input = SolanaSignInInput;\ntype Output = Omit<SolanaSignInOutput, 'account' | 'signatureType'> &\n Readonly<{\n account: UiWalletAccount;\n }>;\n\n/**\n * Use the ['Sign In With Solana'](https://phantom.app/learn/developers/sign-in-with-solana) feature\n * of a {@link UiWallet} or {@link UiWalletAccount}.\n *\n * @returns A function that you can call to sign in with the particular wallet and address specified\n * by the supplied {@link UiWalletAccount}\n *\n * @example\n * ```tsx\n * import { useSignIn } from '@solana/react';\n *\n * function SignInButton({ wallet }) {\n * const csrfToken = useCsrfToken();\n * const signIn = useSignIn(wallet);\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const { account, signedMessage, signature } = await signIn({\n * requestId: csrfToken,\n * });\n * // Authenticate the user, typically on the server, by verifying that\n * // `signedMessage` was signed by the person who holds the private key for\n * // `account.publicKey`.\n * //\n * // Authorize the user, also on the server, by decoding `signedMessage` as the\n * // text of a Sign In With Solana message, verifying that it was not modified\n * // from the values your application expects, and that its content is sufficient\n * // to grant them access.\n * window.alert(`You are now signed in with the address ${account.address}`);\n * } catch (e) {\n * console.error('Failed to sign in', e);\n * }\n * }}\n * >\n * Sign In\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignIn(uiWalletAccount: UiWalletAccount): (input?: Omit<Input, 'address'>) => Promise<Output>;\n/**\n * @returns A function that you can call to sign in with the supplied {@link UiWallet}\n */\nexport function useSignIn(uiWallet: UiWallet): (input?: Input) => Promise<Output>;\nexport function useSignIn(uiWalletHandle: UiWalletHandle): (input?: Input) => Promise<Output> {\n const signIns = useSignIns(uiWalletHandle);\n return useCallback(\n async input => {\n const [result] = await signIns(input);\n return result;\n },\n [signIns],\n );\n}\n\nfunction useSignIns(\n uiWalletHandle: UiWalletHandle,\n): (...inputs: readonly (Input | undefined)[]) => Promise<readonly Output[]> {\n let signMessageFeature: SolanaSignInFeature[typeof SolanaSignIn];\n if ('address' in uiWalletHandle && typeof uiWalletHandle.address === 'string') {\n getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWalletHandle as UiWalletAccount);\n signMessageFeature = getWalletAccountFeature(\n uiWalletHandle as UiWalletAccount,\n SolanaSignIn,\n ) as SolanaSignInFeature[typeof SolanaSignIn];\n } else {\n signMessageFeature = getWalletFeature(uiWalletHandle, SolanaSignIn) as SolanaSignInFeature[typeof SolanaSignIn];\n }\n const wallet = getWalletForHandle_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWalletHandle);\n return useCallback(\n async (...inputs) => {\n const inputsWithAddressAndChainId = inputs.map(input => ({\n ...input,\n // Prioritize the `UiWalletAccount` address if it exists.\n ...('address' in uiWalletHandle ? { address: uiWalletHandle.address as Address } : null),\n }));\n const results = await signMessageFeature.signIn(...inputsWithAddressAndChainId);\n const resultsWithoutSignatureType = results.map(\n ({\n account,\n signatureType: _, // Solana signatures are always of type `ed25519` so drop this property.\n ...rest\n }) => ({\n ...rest,\n account: getOrCreateUiWalletAccountForStandardWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(\n wallet,\n account,\n ),\n }),\n );\n return resultsWithoutSignatureType;\n },\n [signMessageFeature, uiWalletHandle, wallet],\n );\n}\n","import {\n SolanaSignMessage,\n SolanaSignMessageFeature,\n SolanaSignMessageInput,\n SolanaSignMessageOutput,\n} from '@solana/wallet-standard-features';\nimport { getWalletAccountFeature, UiWalletAccount } from '@wallet-standard/ui';\nimport { getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } from '@wallet-standard/ui-registry';\nimport { useCallback } from 'react';\n\ntype Input = Omit<SolanaSignMessageInput, 'account'>;\ntype Output = Omit<SolanaSignMessageOutput, 'signatureType'>;\n\n/**\n * Use this to get a function capable of signing a message with the private key of a\n * {@link UiWalletAccount}\n *\n * @example\n * ```tsx\n * import { useSignMessage } from '@solana/react';\n *\n * function SignMessageButton({ account, messageBytes }) {\n * const signMessage = useSignMessage(account);\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const { signature } = await signMessage({\n * message: messageBytes,\n * });\n * window.alert(`Signature bytes: ${signature.toString()}`);\n * } catch (e) {\n * console.error('Failed to sign message', e);\n * }\n * }}\n * >\n * Sign Message\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignMessage<TWalletAccount extends UiWalletAccount>(\n ...config: Parameters<typeof useSignMessages<TWalletAccount>>\n): (input: Input) => Promise<Output> {\n const signMessages = useSignMessages(...config);\n return useCallback(\n async input => {\n const [result] = await signMessages(input);\n return result;\n },\n [signMessages],\n );\n}\n\nfunction useSignMessages<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]> {\n const signMessageFeature = getWalletAccountFeature(\n uiWalletAccount,\n SolanaSignMessage,\n ) as SolanaSignMessageFeature[typeof SolanaSignMessage];\n const account = getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWalletAccount);\n return useCallback(\n async (...inputs) => {\n const inputsWithAccount = inputs.map(input => ({ ...input, account }));\n const results = await signMessageFeature.signMessage(...inputsWithAccount);\n const resultsWithoutSignatureType = results.map(\n ({\n signatureType: _, // Solana signatures are always of type `ed25519` so drop this property.\n ...rest\n }) => rest,\n );\n return resultsWithoutSignatureType;\n },\n [signMessageFeature, account],\n );\n}\n","import {\n SolanaSignTransaction,\n SolanaSignTransactionFeature,\n SolanaSignTransactionInput,\n SolanaSignTransactionOutput,\n} from '@solana/wallet-standard-features';\nimport {\n WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED,\n WalletStandardError,\n} from '@wallet-standard/errors';\nimport { getWalletAccountFeature, UiWalletAccount } from '@wallet-standard/ui';\nimport { getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } from '@wallet-standard/ui-registry';\nimport { useCallback } from 'react';\n\nimport { OnlySolanaChains } from './chain';\n\ntype Input = Readonly<\n Omit<SolanaSignTransactionInput, 'account' | 'chain' | 'options'> & {\n options?: Readonly<{\n minContextSlot?: bigint;\n }>;\n }\n>;\ntype Output = SolanaSignTransactionOutput;\n\n/**\n * Use this to get a function capable of signing a serialized transaction with the private key of a\n * {@link UiWalletAccount}\n *\n * @param chain The identifier of the chain the transaction is destined for. Wallets may use this to\n * simulate the transaction for the user.\n *\n * @example\n * ```tsx\n * import { useSignTransaction } from '@solana/react';\n *\n * function SignTransactionButton({ account, transactionBytes }) {\n * const signTransaction = useSignTransaction(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const { signedTransaction } = await signTransaction({\n * transaction: transactionBytes,\n * });\n * window.alert(`Signed transaction bytes: ${signedTransaction.toString()}`);\n * } catch (e) {\n * console.error('Failed to sign transaction', e);\n * }\n * }}\n * >\n * Sign Transaction\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): (input: Input) => Promise<Output>;\nexport function useSignTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (input: Input) => Promise<Output>;\nexport function useSignTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (input: Input) => Promise<Output> {\n const signTransactions = useSignTransactions(uiWalletAccount, chain);\n return useCallback(\n async input => {\n const [result] = await signTransactions(input);\n return result;\n },\n [signTransactions],\n );\n}\n\n/**\n * Use this to get a function capable of signing one or more serialized transactions with the private\n * key of a {@link UiWalletAccount}. This supports batching multiple transactions in a single wallet\n * prompt when the wallet implementation allows it.\n *\n * @example\n * ```tsx\n * import { useSignTransactions } from '@solana/react';\n *\n * function SignTransactionsButton({ account, transactionBytes1, transactionBytes2 }) {\n * const signTransactions = useSignTransactions(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const [first, second] = await signTransactions(\n * { transaction: transactionBytes1 },\n * { transaction: transactionBytes2 },\n * );\n * window.alert(\n * `First transaction bytes: ${first.signedTransaction.toString()}, second transaction bytes: ${second.signedTransaction.toString()}`,\n * );\n * } catch (e) {\n * console.error('Failed to sign transactions', e);\n * }\n * }}\n * >\n * Sign Transactions\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]>;\nexport function useSignTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]>;\nexport function useSignTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]> {\n if (!uiWalletAccount.chains.includes(chain)) {\n throw new WalletStandardError(WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED, {\n address: uiWalletAccount.address,\n chain,\n featureName: SolanaSignTransaction,\n supportedChains: [...uiWalletAccount.chains],\n supportedFeatures: [...uiWalletAccount.features],\n });\n }\n const signTransactionFeature = getWalletAccountFeature(\n uiWalletAccount,\n SolanaSignTransaction,\n ) as SolanaSignTransactionFeature[typeof SolanaSignTransaction];\n const account = getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWalletAccount);\n return useCallback(\n async (...inputs) => {\n if (inputs.length === 0) {\n return [];\n }\n const inputsWithAccountAndChain = inputs.map(({ options, ...rest }) => {\n const minContextSlot = options?.minContextSlot;\n return {\n ...rest,\n account,\n chain,\n ...(minContextSlot != null\n ? {\n options: {\n minContextSlot: Number(minContextSlot),\n },\n }\n : null),\n };\n });\n const results = await signTransactionFeature.signTransaction(...inputsWithAccountAndChain);\n return results;\n },\n [signTransactionFeature, account, chain],\n );\n}\n","import type { ReactiveStreamStore, SolanaRpcResponse } from '@solana/kit';\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport type { TrackedDataResult } from './useTrackedData';\n\n/**\n * Subscribes to a {@link ReactiveStreamStore} whose value is always shaped as\n * `SolanaRpcResponse<TItem>` (which is what `createReactiveStoreWithInitialValueAndSlotTracking`\n * produces) and maps its `idle | loading | loaded | error` lifecycle onto the\n * {@link TrackedDataResult} shape consumed by `useTrackedData`. The envelope passes through\n * unchanged — callers read `data.value` and `data.context.slot` directly.\n *\n * `idle` is ambiguous on its own: it covers both \"no spec — store is disabled\" and \"real spec,\n * connect effect hasn't fired yet on the current render.\" The `disabled` flag disambiguates:\n * disabled → `status: 'disabled'`, enabled → `status: 'loading'` (the connect is about to fire\n * on commit; consumers see a single `loading` paint rather than briefly flashing `disabled`).\n *\n * Stale-while-revalidate flows naturally through `state.data` / `state.error`, which the store\n * preserves across `loading` transitions, so the bridge doesn't need to mirror them.\n *\n * @param store - The store to subscribe to.\n * @param refresh - A stable callback that re-runs the initial RPC and the subscription.\n * Forwarded to the result so call sites have a single, hook-owned recovery affordance.\n * @param disabled - When `true`, the result reports `status: 'disabled'`. Used by\n * `useTrackedData` to signal the null-spec case.\n *\n * @internal\n */\nexport function useTrackedDataResult<TItem>(\n store: ReactiveStreamStore<SolanaRpcResponse<TItem>>,\n refresh: (options?: { abortSignal?: AbortSignal | undefined }) => void,\n disabled: boolean,\n): TrackedDataResult<TItem> {\n const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);\n return useMemo(() => {\n const status: TrackedDataResult<TItem>['status'] =\n state.status === 'idle' ? (disabled ? 'disabled' : 'loading') : state.status;\n return { data: state.data, error: state.error, refresh, status };\n }, [state, refresh, disabled]);\n}\n","import {\n createReactiveStoreWithInitialValueAndSlotTracking,\n type CreateReactiveStoreWithInitialValueAndSlotTrackingConfig,\n type ReactiveStreamStore,\n type SolanaRpcResponse,\n} from '@solana/kit';\nimport { useMemo } from 'react';\n\nimport { disabledStreamStore } from './staticStores';\nimport { useReactiveStoreLifecycle } from './useReactiveStoreLifecycle';\nimport { useTrackedDataResult } from './useTrackedDataResult';\n\n// Module-level so it's a stable reference — keeps the `refresh` callback from\n// `useReactiveStoreLifecycle` referentially stable across renders.\nfunction fireConnect<T>(store: ReactiveStreamStore<T>, signal: AbortSignal | undefined): void {\n if (signal) store.withSignal(signal).connect();\n else store.connect();\n}\n\n/**\n * React-local alias for the Kit primitive's config. Lets the call site name the input shape as\n * `TrackedDataSpec<TInitialValue, TStreamValue, TItem>` instead of the verbose\n * `CreateReactiveStoreWithInitialValueAndSlotTrackingConfig<...>`.\n *\n * @typeParam TInitialValue - The value inside the initial RPC `SolanaRpcResponse` envelope.\n * @typeParam TStreamValue - The value inside subscription `SolanaRpcResponse` notifications.\n * @typeParam TItem - The unified item type produced by the two mappers and stored in the result.\n */\nexport type TrackedDataSpec<TInitialValue, TStreamValue, TItem> =\n CreateReactiveStoreWithInitialValueAndSlotTrackingConfig<TInitialValue, TStreamValue, TItem>;\n\n/**\n * Reactive state for tracked data managed by {@link useTrackedData}.\n *\n * Lifecycle: starts at `loading` (or `disabled` when the spec is `null`) and fires both the\n * initial RPC request and the subscription on mount; transitions to `loaded` on the first\n * value (from either source — the underlying store slot-dedupes so out-of-order arrivals never\n * regress) or `error` on failure. `refresh()` re-runs the whole pair — while a refresh is in\n * flight, `status` returns to `loading` and the stale `data` and/or `error` from the prior\n * outcome remain populated (stale-while-revalidate).\n *\n * @typeParam T - The unified item type held by the store, produced by the two mappers in the\n * spec.\n */\nexport type TrackedDataResult<T> = {\n /**\n * The latest value, slot-deduped across the initial RPC and the subscription, exactly as the\n * underlying kit primitive emits it: a `SolanaRpcResponse<T>` envelope (`{ context: { slot },\n * value }`). The primitive guarantees the envelope shape, so callers can read `data.value`\n * and `data.context.slot` directly without a runtime check. `undefined` on the first load\n * and while disabled. On `loading` after a prior outcome, on `error`, and on a subsequent\n * refresh, holds the last received envelope so UIs can show stale data rather than flashing\n * to blank.\n */\n data: SolanaRpcResponse<T> | undefined;\n /**\n * Error from either source, or `undefined`. Only the first error per connection window is\n * captured (the underlying store drops subsequent errors until the next `refresh()` /\n * connect). On `loading` after a prior `error`, holds the stale error so UIs can keep\n * showing the failure context while the refresh is in flight. A subsequent `loaded` clears\n * it.\n */\n error: unknown;\n /**\n * Re-run both the initial RPC request and the subscription. By default each call mints a\n * fresh signal from `getAbortSignal` (if configured) and threads it through the underlying\n * store's `withSignal(signal).connect()`. Pass `{ abortSignal }` to override the configured\n * factory for just this attempt. Pass `{ abortSignal: undefined }` to opt out of the\n * factory entirely for this attempt and run with no caller-provided signal.\n *\n * Stable reference. Safe to put in `onClick` handlers or effect deps — typically wired up\n * to a \"Refresh\" or \"Retry\" button. Calls `store.connect()` under the hood, so it always\n * (re)runs the pair regardless of current status; the bridge transitions back through\n * `loading` while preserving stale `data` and `error`.\n */\n refresh: (options?: { abortSignal?: AbortSignal | undefined }) => void;\n /**\n * Lifecycle status as a discriminated string:\n * - `loading`: an attempt is in progress. On the first attempt, `data` and `error` are\n * `undefined`. After a refresh, `data` and `error` hold the last known values from the\n * previous attempt (stale-while-revalidate).\n * - `loaded`: a value has arrived from either source and `error` is `undefined`.\n * - `error`: the attempt failed; `data` holds the last known value (if any).\n * - `disabled`: spec was `null` — no work was started.\n */\n status: 'disabled' | 'error' | 'loaded' | 'loading';\n};\n\n/** Options accepted by {@link useTrackedData}. */\nexport type UseTrackedDataOptions = {\n /**\n * Factory invoked on every attempt (initial run + every `refresh()`). The returned signal is\n * attached to that attempt via the underlying store's `withSignal(signal).connect()`, so\n * aborting it tears down both the in-flight RPC request and the subscription for that\n * attempt.\n *\n * The most common use is per-attempt timeouts:\n * `getAbortSignal: () => AbortSignal.timeout(30_000)` gives every attempt its own\n * 30-second clock that resets on `refresh()`.\n *\n * Held in a ref synced to the latest render's closure — there is no need to memoize an\n * inline factory.\n */\n getAbortSignal?: () => AbortSignal;\n};\n\n/**\n * Render reactive state for an RPC subscription seeded by a one-shot RPC fetch, slot-deduped.\n * The subscription (e.g. `accountNotifications`) is the primary source of live updates; the\n * initial fetch (e.g. `getBalance`) provides a value to surface as soon as it resolves —\n * typically before the first subscription notification arrives — so the `loading` paint is\n * shorter than subscription-only would give you. The underlying store slot-dedupes between the\n * two sources — out-of-order arrivals never regress the surfaced value.\n *\n * Pass a memoized {@link TrackedDataSpec} keyed on whatever inputs it depends on; stable identity\n * is how the hook knows when to tear down and re-run. Pass `null` to gate the work off — the\n * result reports `status: 'disabled'`.\n *\n * SSR-safe — on the server the connect effect doesn't run, so the store stays `idle` and the\n * hook reports `status: 'loading'`. The first client render hydrates from that same `loading`\n * paint, then commits the connect effect.\n *\n * @typeParam TInitialValue - The value inside the initial RPC `SolanaRpcResponse` envelope.\n * @typeParam TStreamValue - The value inside subscription `SolanaRpcResponse` notifications.\n * @typeParam TItem - The unified item type produced by the two mappers and stored in the result.\n *\n * @example\n * ```tsx\n * function AccountBalance({ address }: { address: Address }) {\n * const client = useClient<ClientWithRpc<GetBalanceApi> & ClientWithRpcSubscriptions<AccountNotificationsApi>>();\n * const spec = useMemo(() => ({\n * initialValueSource: client.rpc.getBalance(address),\n * initialValueMapper: (lamports: bigint) => lamports,\n * streamSource: client.rpcSubscriptions.accountNotifications(address),\n * streamValueMapper: ({ lamports }: { lamports: bigint }) => lamports,\n * }), [client, address]);\n * const { data, error, refresh } = useTrackedData(spec);\n * if (error) return <button onClick={refresh}>Retry</button>;\n * return <p>{data ? `${data.value} lamports at slot ${data.context.slot}` : 'Loading…'}</p>;\n * }\n * ```\n *\n * @see {@link TrackedDataResult}\n * @see {@link UseTrackedDataOptions}\n */\nexport function useTrackedData<TInitialValue, TStreamValue, TItem>(\n spec: TrackedDataSpec<TInitialValue, TStreamValue, TItem> | null,\n options?: UseTrackedDataOptions,\n): TrackedDataResult<TItem> {\n // One store per `spec`. Both creation paths return an `idle` store; the initial connect\n // lives in the lifecycle effect below so the memo body stays pure (StrictMode's dev\n // double-render, and any future render-discard, won't fire a network request from a\n // discarded render).\n const store = useMemo(() => {\n if (spec == null) return disabledStreamStore<SolanaRpcResponse<TItem>>();\n return createReactiveStoreWithInitialValueAndSlotTracking(spec);\n }, [spec]);\n\n // Connect on commit, reset on store change / unmount, and expose the stable `refresh`\n // callback. `store.reset()` aborts the active attempt via the store's internal controller, so\n // under StrictMode's mount → cleanup → mount sequence the first connect is properly aborted\n // before the second one fires. `disabledStreamStore` returns a store whose `connect`/`reset`\n // are no-ops, so the null-spec case needs no explicit gate.\n const refresh = useReactiveStoreLifecycle(store, fireConnect, options?.getAbortSignal);\n\n return useTrackedDataResult(store, refresh, spec == null);\n}\n","import {\n Address,\n address,\n bytesEqual,\n MessageModifyingSigner,\n SignableMessage,\n SignatureBytes,\n SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,\n SolanaError,\n} from '@solana/kit';\nimport { getAbortablePromise } from '@solana/promises';\nimport type { UiWalletAccount } from '@wallet-standard/ui';\nimport { useMemo } from 'react';\n\nimport { useSignMessage } from './useSignMessage';\n\n/**\n * Use this to get a {@link MessageSigner} capable of signing messages with the private key of a\n * {@link UiWalletAccount}\n *\n * @returns A {@link MessageModifyingSigner}. This is a conservative assumption based on the fact\n * that your application can not control whether or not the wallet will modify the message before\n * signing it. Otherwise this method could more specifically return a {@link MessageSigner} or a\n * {@link MessagePartialSigner}.\n *\n * @example\n * ```tsx\n * import { useWalletAccountMessageSigner } from '@solana/react';\n * import { createSignableMessage } from '@solana/kit';\n *\n * function SignMessageButton({ account, text }) {\n * const messageSigner = useWalletAccountMessageSigner(account);\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const signableMessage = createSignableMessage(text);\n * const [signedMessage] = await messageSigner.modifyAndSignMessages([signableMessage]);\n * const messageWasModified = signableMessage.content !== signedMessage.content;\n * const signatureBytes = signedMessage.signatures[messageSigner.address];\n * window.alert(\n * `Signature bytes: ${signatureBytes.toString()}${\n * messageWasModified ? ' (message was modified)' : ''\n * }`,\n * );\n * } catch (e) {\n * console.error('Failed to sign message', e);\n * }\n * }}\n * >\n * Sign Message: {text}\n * </button>\n * );\n * }\n * ```\n */\nexport function useWalletAccountMessageSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n): MessageModifyingSigner<TWalletAccount['address']> {\n const signMessage = useSignMessage(uiWalletAccount);\n return useMemo(\n () => ({\n address: address(uiWalletAccount.address),\n async modifyAndSignMessages(messages, config) {\n config?.abortSignal?.throwIfAborted();\n if (messages.length > 1) {\n throw new SolanaError(SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED);\n }\n if (messages.length === 0) {\n return messages;\n }\n const { content: originalMessage, signatures: originalSignatureMap } = messages[0];\n const input = {\n message: originalMessage,\n };\n const { signedMessage, signature } = await getAbortablePromise(signMessage(input), config?.abortSignal);\n const messageWasModified =\n originalMessage.length !== signedMessage.length ||\n originalMessage.some((originalByte, ii) => originalByte !== signedMessage[ii]);\n const originalSignature = originalSignatureMap[uiWalletAccount.address as Address<string>] as\n | SignatureBytes\n | undefined;\n const signatureIsNew = originalSignature === undefined || !bytesEqual(originalSignature, signature);\n if (!signatureIsNew && !messageWasModified) {\n // We already had this exact signature, and the message wasn't modified.\n // Don't replace the existing message object.\n return messages;\n }\n const nextSignatureMap = messageWasModified\n ? { [uiWalletAccount.address]: signature }\n : { ...originalSignatureMap, [uiWalletAccount.address]: signature };\n const outputMessages = Object.freeze([\n Object.freeze({\n content: signedMessage,\n signatures: Object.freeze(nextSignatureMap),\n }) as SignableMessage,\n ]);\n return outputMessages;\n },\n }),\n [uiWalletAccount, signMessage],\n );\n}\n","import {\n address,\n assertIsTransactionWithinSizeLimit,\n bytesEqual,\n getCompiledTransactionMessageDecoder,\n getTransactionCodec,\n getTransactionLifetimeConstraintFromCompiledTransactionMessage,\n SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,\n SolanaError,\n Transaction,\n TransactionModifyingSigner,\n TransactionWithinSizeLimit,\n TransactionWithLifetime,\n} from '@solana/kit';\nimport { getAbortablePromise } from '@solana/promises';\nimport { UiWalletAccount } from '@wallet-standard/ui';\nimport { useMemo, useRef } from 'react';\n\nimport { OnlySolanaChains } from './chain';\nimport { useSignTransaction } from './useSignTransaction';\n\n/**\n * Use this to get a {@link TransactionSigner} capable of signing serialized transactions with the\n * private key of a {@link UiWalletAccount}\n *\n * @returns A {@link TransactionModifyingSigner}. This is a conservative assumption based on the\n * fact that your application can not control whether or not the wallet will modify the transaction\n * before signing it (eg. to add guard instructions, or a priority fee budget). Otherwise this\n * method could more specifically return a {@link TransactionSigner} or a\n * {@link TransactionPartialSigner}.\n *\n * @example\n * ```tsx\n * import { useWalletAccountTransactionSigner } from '@solana/react';\n *\n * function SignTransactionButton({ account, transaction }) {\n * const transactionSigner = useWalletAccountTransactionSigner(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const [{ signatures }] = await transactionSigner.modifyAndSignTransactions([transaction]);\n * const signatureBytes = signatures[transactionSigner.address];\n * window.alert(`Signature bytes: ${signatureBytes.toString()}`);\n * } catch (e) {\n * console.error('Failed to sign transaction', e);\n * }\n * }}\n * >\n * Sign Transaction\n * </button>\n * );\n * }\n * ```\n */\nexport function useWalletAccountTransactionSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): TransactionModifyingSigner<TWalletAccount['address']>;\nexport function useWalletAccountTransactionSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): TransactionModifyingSigner<TWalletAccount['address']>;\nexport function useWalletAccountTransactionSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): TransactionModifyingSigner<TWalletAccount['address']> {\n const encoderRef = useRef<ReturnType<typeof getTransactionCodec> | null>(null);\n const signTransaction = useSignTransaction(uiWalletAccount, chain);\n return useMemo(\n () => ({\n address: address(uiWalletAccount.address),\n async modifyAndSignTransactions(transactions, config = {}) {\n const { abortSignal, ...options } = config;\n abortSignal?.throwIfAborted();\n const transactionCodec = (encoderRef.current ||= getTransactionCodec());\n if (transactions.length > 1) {\n throw new SolanaError(SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED);\n }\n if (transactions.length === 0) {\n return transactions as readonly (Transaction &\n TransactionWithinSizeLimit &\n TransactionWithLifetime)[];\n }\n const [transaction] = transactions;\n const wireTransactionBytes = transactionCodec.encode(transaction);\n const inputWithOptions = {\n ...options,\n transaction: wireTransactionBytes as Uint8Array,\n };\n const { signedTransaction } = await getAbortablePromise(signTransaction(inputWithOptions), abortSignal);\n const decodedSignedTransaction = transactionCodec.decode(\n signedTransaction,\n ) as (typeof transactions)[number];\n\n assertIsTransactionWithinSizeLimit(decodedSignedTransaction);\n\n const existingLifetime =\n 'lifetimeConstraint' in transaction\n ? (transaction as TransactionWithLifetime).lifetimeConstraint\n : undefined;\n\n if (existingLifetime) {\n if (bytesEqual(decodedSignedTransaction.messageBytes, transaction.messageBytes)) {\n // If the transaction has identical bytes, the lifetime won't have changed\n return Object.freeze([\n {\n ...decodedSignedTransaction,\n lifetimeConstraint: existingLifetime,\n },\n ]);\n }\n\n // If the transaction has changed, check the lifetime constraint field\n const compiledTransactionMessage = getCompiledTransactionMessageDecoder().decode(\n decodedSignedTransaction.messageBytes,\n );\n const currentToken =\n 'blockhash' in existingLifetime ? existingLifetime.blockhash : existingLifetime.nonce;\n\n if (compiledTransactionMessage.lifetimeToken === currentToken) {\n return Object.freeze([\n {\n ...decodedSignedTransaction,\n lifetimeConstraint: existingLifetime,\n },\n ]);\n }\n }\n\n // If we get here then there is no existing lifetime, or the lifetime has changed. We need to attach a new lifetime\n const compiledTransactionMessage = getCompiledTransactionMessageDecoder().decode(\n decodedSignedTransaction.messageBytes,\n );\n const lifetimeConstraint =\n await getTransactionLifetimeConstraintFromCompiledTransactionMessage(compiledTransactionMessage);\n return Object.freeze([\n {\n ...decodedSignedTransaction,\n lifetimeConstraint,\n },\n ]);\n },\n }),\n [uiWalletAccount.address, signTransaction],\n );\n}\n","import {\n address,\n getTransactionEncoder,\n SignatureBytes,\n SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,\n SolanaError,\n TransactionSendingSigner,\n} from '@solana/kit';\nimport { getAbortablePromise } from '@solana/promises';\nimport { UiWalletAccount } from '@wallet-standard/ui';\nimport { useMemo, useRef } from 'react';\n\nimport { OnlySolanaChains } from './chain';\nimport { useSignAndSendTransaction } from './useSignAndSendTransaction';\n\n/**\n * Use this to get a {@link TransactionSendingSigner} capable of signing a serialized transaction\n * with the private key of a {@link UiWalletAccount} and sending it to the network for processing.\n *\n * @param chain The identifier of the chain the transaction is destined for. Wallets may use this to\n * simulate the transaction for the user.\n *\n * @example\n * ```tsx\n * import { useWalletAccountTransactionSendingSigner } from '@solana/react';\n * import {\n * appendTransactionMessageInstruction,\n * createSolanaRpc,\n * getBase58Decoder,\n * pipe,\n * setTransactionMessageFeePayerSigner,\n * setTransactionMessageLifetimeUsingBlockhash,\n * signAndSendTransactionMessageWithSigners,\n * } from '@solana/kit';\n *\n * function RecordMemoButton({ account, rpc, text }) {\n * const signer = useWalletAccountTransactionSendingSigner(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const { value: latestBlockhash } = await createSolanaRpc('https://api.devnet.solana.com')\n * .getLatestBlockhash()\n * .send();\n * const message = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * m => setTransactionMessageFeePayerSigner(signer, m),\n * m => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, m),\n * m => appendTransactionMessageInstruction(getAddMemoInstruction({ memo: text }), m),\n * );\n * const signatureBytes = await signAndSendTransactionMessageWithSigners(message);\n * const base58Signature = getBase58Decoder().decode(signature);\n * window.alert(`View transaction: https://explorer.solana.com/tx/${base58Signature}?cluster=devnet`);\n * } catch (e) {\n * console.error('Failed to record memo', e);\n * }\n * }}\n * >\n * Record Memo\n * </button>\n * );\n * }\n * ```\n */\nexport function useWalletAccountTransactionSendingSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): TransactionSendingSigner<TWalletAccount['address']>;\nexport function useWalletAccountTransactionSendingSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): TransactionSendingSigner<TWalletAccount['address']>;\nexport function useWalletAccountTransactionSendingSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): TransactionSendingSigner<TWalletAccount['address']> {\n const encoderRef = useRef<ReturnType<typeof getTransactionEncoder> | null>(null);\n const signAndSendTransaction = useSignAndSendTransaction(uiWalletAccount, chain);\n return useMemo(\n () => ({\n address: address(uiWalletAccount.address),\n async signAndSendTransactions(transactions, config = {}) {\n const { abortSignal, ...options } = config;\n abortSignal?.throwIfAborted();\n const transactionEncoder = (encoderRef.current ||= getTransactionEncoder());\n if (transactions.length > 1) {\n throw new SolanaError(SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED);\n }\n if (transactions.length === 0) {\n return [];\n }\n const [transaction] = transactions;\n const wireTransactionBytes = transactionEncoder.encode(transaction);\n const inputWithOptions = {\n ...options,\n transaction: wireTransactionBytes as Uint8Array,\n };\n const { signature } = await getAbortablePromise(signAndSendTransaction(inputWithOptions), abortSignal);\n return Object.freeze([signature as SignatureBytes]);\n },\n }),\n [signAndSendTransaction, uiWalletAccount.address],\n );\n}\n","import { UiWallet, UiWalletAccount } from '@wallet-standard/react';\nimport React, { createContext } from 'react';\n\nexport type SelectedWalletAccountState = UiWalletAccount | undefined;\n\nexport type SelectedWalletAccountContextValue = readonly [\n selectedWalletAccount: SelectedWalletAccountState,\n setSelectedWalletAccount: React.Dispatch<React.SetStateAction<SelectedWalletAccountState>>,\n filteredWallets: UiWallet[],\n];\n\nexport const SelectedWalletAccountContext = /*#__PURE__*/ createContext<SelectedWalletAccountContextValue>([\n undefined,\n () => {},\n [],\n]);\n\nexport function useSelectedWalletAccount() {\n const ctx = React.useContext(SelectedWalletAccountContext);\n return ctx;\n}\n","import type { UiWallet, UiWalletAccount } from '@wallet-standard/react';\nimport {\n getUiWalletAccountStorageKey,\n uiWalletAccountBelongsToUiWallet,\n uiWalletAccountsAreSame,\n useWallets,\n} from '@wallet-standard/react';\nimport React from 'react';\n\nimport { SelectedWalletAccountContext, SelectedWalletAccountState } from './selectedWalletAccountContext';\n\nexport type SelectedWalletAccountContextProviderProps = {\n filterWallets: (wallet: UiWallet) => boolean;\n stateSync: {\n deleteSelectedWallet: () => void;\n getSelectedWallet: () => string | null;\n storeSelectedWallet: (accountKey: string) => void;\n };\n} & { children: React.ReactNode };\n\n/**\n * Returns the saved wallet account when its corresponding wallet, and account is available.\n * @param wallets All wallets available to select in the app\n * @param savedWalletKey The saved wallet account storage key\n * @returns The saved wallet account, or undefined if not found\n */\nfunction findSavedWalletAccount(\n wallets: readonly UiWallet[],\n savedWalletKey: string | null,\n): UiWalletAccount | undefined {\n if (!savedWalletKey) {\n return;\n }\n const [savedWalletName, savedWalletAddress] = savedWalletKey.split(':');\n if (!savedWalletName || !savedWalletAddress) {\n return;\n }\n for (const wallet of wallets) {\n if (wallet.name !== savedWalletName) continue;\n for (const account of wallet.accounts) {\n if (account.address === savedWalletAddress) {\n return account;\n }\n }\n }\n}\n\n/**\n * Saves the selected wallet account's storage key to a persistant storage. In future\n * sessions it will try to return that same wallet account, or at least one from the same brand of\n * wallet if the wallet from which it came is still in the Wallet Standard registry.\n * @param children The child components that will have access to the selected wallet account context\n * @param filterWallets A function to filter which wallets are available in the app\n * @param stateSync An object with methods to synchronize the selected wallet account state with persistent storage\n * @returns A React component that provides the selected wallet account context to its children\n */\nexport function SelectedWalletAccountContextProvider({\n children,\n filterWallets,\n stateSync,\n}: SelectedWalletAccountContextProviderProps) {\n const wallets = useWallets();\n const filteredWallets = React.useMemo(() => wallets.filter(filterWallets), [wallets, filterWallets]);\n const wasSetterInvokedRef = React.useRef(false);\n\n const [selectedWalletAccount, setSelectedWalletAccountInternal] = React.useState<SelectedWalletAccountState>(() => {\n const savedWalletKey = stateSync.getSelectedWallet();\n const savedWalletAccount = findSavedWalletAccount(filteredWallets, savedWalletKey);\n return savedWalletAccount;\n });\n\n // Public setter: mark the per-instance ref synchronously to avoid races, then schedule state update.\n // useCallback stabilises the setter for consumers.\n const setSelectedWalletAccount: React.Dispatch<React.SetStateAction<SelectedWalletAccountState>> =\n React.useCallback(\n setStateAction => {\n wasSetterInvokedRef.current = true;\n setSelectedWalletAccountInternal(prevSelectedWalletAccount => {\n const nextWalletAccount =\n typeof setStateAction === 'function'\n ? setStateAction(prevSelectedWalletAccount)\n : setStateAction;\n return nextWalletAccount;\n });\n },\n [setSelectedWalletAccountInternal],\n );\n\n //Sync to persistant storage when selectedWalletAccount changes\n React.useEffect(() => {\n if (!wasSetterInvokedRef.current) return;\n\n const accountKey = selectedWalletAccount ? getUiWalletAccountStorageKey(selectedWalletAccount) : undefined;\n\n if (accountKey) {\n stateSync.storeSelectedWallet(accountKey);\n } else {\n stateSync.deleteSelectedWallet();\n }\n }, [selectedWalletAccount, stateSync]);\n\n //Auto-restore saved wallet account if it appears later,\n //and if the user hasn't made an explicit choice yet.\n React.useEffect(() => {\n if (wasSetterInvokedRef.current) return;\n const savedWalletKey = stateSync.getSelectedWallet();\n const savedAccount = findSavedWalletAccount(filteredWallets, savedWalletKey);\n if (savedAccount && selectedWalletAccount && uiWalletAccountsAreSame(savedAccount, selectedWalletAccount)) {\n return;\n }\n if (savedAccount) {\n setSelectedWalletAccountInternal(savedAccount);\n }\n }, [filteredWallets, stateSync, selectedWalletAccount]);\n\n const walletAccount = React.useMemo(() => {\n if (!selectedWalletAccount) return;\n for (const wallet of filteredWallets) {\n for (const account of wallet.accounts) {\n if (uiWalletAccountsAreSame(account, selectedWalletAccount)) {\n return account;\n }\n }\n if (uiWalletAccountBelongsToUiWallet(selectedWalletAccount, wallet) && wallet.accounts[0]) {\n return wallet.accounts[0];\n }\n }\n }, [selectedWalletAccount, filteredWallets]);\n\n React.useEffect(() => {\n // If there is a selected wallet account but the wallet to which it belongs has since\n // disconnected, clear the selected wallet. This is an automatic cleanup and should not\n // mark the 'wasSetterInvoked' ref (so we use the internal setter).\n // Cleanup shouldn't be run if user has made a selection or selectedWalletAccount/walletAccount are loading or undefined\n if (!selectedWalletAccount) return; //still loading ...\n if (wasSetterInvokedRef.current) return; //user made a selection\n if (!walletAccount) {\n setSelectedWalletAccountInternal(undefined);\n }\n }, [selectedWalletAccount, walletAccount]);\n\n return (\n <SelectedWalletAccountContext.Provider value={[walletAccount, setSelectedWalletAccount, filteredWallets]}>\n {children}\n </SelectedWalletAccountContext.Provider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/usePromise.ts","../src/ClientProvider.tsx","../src/useIsomorphicLayoutEffect.ts","../src/useAction.ts","../src/useAirdrop.ts","../src/useClient.ts","../src/useClientCapability.ts","../src/useIdentity.ts","../src/usePayer.ts","../src/usePlanTransaction.ts","../src/usePlanTransactions.ts","../src/staticStores.ts","../src/useLatest.ts","../src/useReactiveStoreLifecycle.ts","../src/useRequestResult.ts","../src/useRequest.ts","../src/useSendTransaction.ts","../src/useSendTransactions.ts","../src/useSignAndSendTransaction.ts","../src/useSubscriptionResult.ts","../src/useSubscription.ts","../src/useSignIn.ts","../src/useSignMessage.ts","../src/useSignTransaction.ts","../src/useTrackedDataResult.ts","../src/useTrackedData.ts","../src/useWalletAccountMessageSigner.ts","../src/useWalletAccountTransactionSigner.ts","../src/useWalletAccountTransactionSendingSigner.ts","../src/selectedWalletAccountContext.ts","../src/SelectedWalletAccountContextProvider.tsx"],"names":["React","useLayoutEffect","useEffect","useRef","useState","createReactiveActionStore","useSyncExternalStore","useMemo","address","SolanaError","SOLANA_ERROR__REACT__MISSING_PROVIDER","SOLANA_ERROR__REACT__MISSING_CAPABILITY","useCallback","NOOP_UNSUBSCRIBE","WalletStandardError","WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED","SolanaSignAndSendTransaction","getWalletAccountFeature","getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","SolanaSignIn","getWalletFeature","getWalletForHandle_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","getOrCreateUiWalletAccountForStandardWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","SolanaSignMessage","SolanaSignTransaction","fireConnect","createReactiveStoreWithInitialValueAndSlotTracking","SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED","getAbortablePromise","bytesEqual","getTransactionCodec","assertIsTransactionWithinSizeLimit","compiledTransactionMessage","getCompiledTransactionMessageDecoder","getTransactionLifetimeConstraintFromCompiledTransactionMessage","getTransactionEncoder","createContext","useWallets","getUiWalletAccountStorageKey","uiWalletAccountsAreSame","uiWalletAccountBelongsToUiWallet"],"mappings":";;;;;;;;;;;;;;;;AAOA,IAAM,KAAA,uBAAY,OAAA,EAAmD;AAErE,SAAS,eAAkB,OAAA,EAA4C;AAInE,EAAA,OAAO,OAAA,CAAQ,IAAA;AAAA,IACX,CAAA,KAAA,KAAS;AACL,MAAA,KAAA,CAAM,IAAI,OAAA,EAAS,EAAE,MAAA,EAAQ,WAAA,EAAa,OAAO,CAAA;AAAA,IACrD,CAAA;AAAA,IACA,CAAA,MAAA,KAAU;AACN,MAAA,KAAA,CAAM,IAAI,OAAA,EAAS,EAAE,MAAA,EAAQ,MAAA,EAAQ,YAAY,CAAA;AAAA,IACrD;AAAA,GACJ;AACJ;AAWA,SAAS,eAAkB,OAAA,EAA4B;AACnD,EAAA,IAAI,KAAA,GAAQ,KAAA,CAAM,GAAA,CAAI,OAAO,CAAA;AAC7B,EAAA,IAAI,SAAS,IAAA,EAAM;AACf,IAAA,MAAM,OAAA,GAAU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,EAAe;AAChB,MAAA,gCAAA,CAAiC,MAAS,CAAA;AAAA,IAC9C;AAAA,EACJ,CAAA,EAAG,CAAC,qBAAA,EAAuB,aAAa,CAAC,CAAA;AAEzC,EAAA,uBACIA,uBAAAA,CAAA,aAAA,CAAC,4BAAA,CAA6B,QAAA,EAA7B,EAAsC,KAAA,EAAO,CAAC,aAAA,EAAe,wBAAA,EAA0B,eAAe,CAAA,EAAA,EAClG,QACL,CAAA;AAER","file":"index.browser.cjs","sourcesContent":["import React from 'react';\n\ntype CacheEntry<T> =\n | Readonly<{ promise: PromiseLike<unknown>; status: 'pending' }>\n | Readonly<{ reason: unknown; status: 'rejected' }>\n | Readonly<{ status: 'fulfilled'; value: T }>;\n\nconst cache = new WeakMap<PromiseLike<unknown>, CacheEntry<unknown>>();\n\nfunction trackedPromise<T>(promise: PromiseLike<T>): PromiseLike<void> {\n // Returns the *chained* promise (not the original). React subscribes to the thrown value to\n // know when to retry; throwing the chained one means retry runs strictly after our\n // cache-update handler, so the next render is guaranteed to see the settled entry.\n return promise.then(\n value => {\n cache.set(promise, { status: 'fulfilled', value });\n },\n reason => {\n cache.set(promise, { reason, status: 'rejected' });\n },\n );\n}\n\n/**\n * React 18 fallback for `React.use(promise)` — suspends by throwing the promise on first render,\n * returns the resolved value on subsequent renders, and re-throws the rejection if the promise\n * settles with an error.\n *\n * The promise identity must be stable across renders so the cache keyed off it can find the\n * settled entry on the second render. The {@link ClientProvider}'s consumer-facing contract\n * documents this — pass a memoised or module-scope promise.\n */\nfunction usePromiseShim<T>(promise: PromiseLike<T>): T {\n let entry = cache.get(promise) as CacheEntry<T> | undefined;\n if (entry == null) {\n const tracked = trackedPromise(promise);\n entry = { promise: tracked, status: 'pending' };\n cache.set(promise, entry);\n }\n if (entry.status === 'pending') throw entry.promise;\n if (entry.status === 'rejected') throw entry.reason;\n return entry.value;\n}\n\ntype ReactWithUse = typeof React & {\n use?: <T>(promise: PromiseLike<T>) => T;\n};\n\nfunction isPromiseLike<T>(value: PromiseLike<T> | T): value is PromiseLike<T> {\n return (\n !!value &&\n (typeof value === 'object' || typeof value === 'function') &&\n typeof (value as PromiseLike<T>).then === 'function'\n );\n}\n\n/**\n * Returns `value` directly if it is a plain value, or unwraps it (suspending the subtree until\n * it settles) if it is a {@link PromiseLike}. Designed to be invoked unconditionally so consumers\n * don't have to gate on the runtime shape of the input — that keeps the call site\n * rules-of-hooks-friendly even when the same provider sees both sync and async clients.\n *\n * The `React.use` lookup is deferred to call time so the module has no top-level side effects\n * (agadoo's tree-shake check fails otherwise on the property-access expression).\n */\nexport function usePromise<T>(value: PromiseLike<T> | T): T {\n if (!isPromiseLike(value)) return value;\n return ((React as ReactWithUse).use ?? usePromiseShim)(value);\n}\n","import type { Client } from '@solana/kit';\nimport React from 'react';\n\nimport { usePromise } from './usePromise';\n\nconst ClientContext = /*#__PURE__*/ React.createContext<Client<object> | null>(null);\n\n/**\n * The React context that holds the Kit client published by the nearest {@link ClientProvider}.\n * Exported for advanced cases such as third-party providers that wrap and extend the client; most\n * consumers should reach for {@link useClient} or one of the higher-level hooks instead.\n */\nexport { ClientContext };\n\n/**\n * Props accepted by {@link ClientProvider}.\n */\nexport type ClientProviderProps = Readonly<{\n children?: React.ReactNode;\n /**\n * The Kit client to publish to descendants, or a promise resolving to one (e.g. when the\n * client has async plugins). The reference must be stable across renders — build it at\n * module scope or memoise it with `useMemo` when its config is reactive.\n */\n client: Client<object> | Promise<Client<object>>;\n}>;\n\n/**\n * Publishes a caller-owned Kit client to its subtree. Required for `useClient`,\n * `useClientCapability`, and any plugin-specific hook that depends on a client capability.\n *\n * Plugin composition belongs in plain Kit — the provider does no composition, lifecycle\n * management, or disposal; it is a value channel, not a lifecycle channel. When config changes at\n * runtime (e.g. cluster toggle), rebuild the client in `useMemo` and pass the new reference; the\n * subtree resubscribes against the new client identity.\n *\n * Async client support: when `client` is a promise (e.g. `createClient().use(asyncPlugin())`),\n * the provider suspends the subtree via the nearest `<Suspense>` boundary until the promise\n * resolves. On React 19 this delegates to `React.use(promise)`; on React 18 a thrown-promise shim\n * keyed by promise identity preserves the same contract.\n *\n * @example Sync client\n * ```tsx\n * import { createClient } from '@solana/kit';\n * import { ClientProvider } from '@solana/react';\n *\n * const client = createClient(); // .use(...) plugins as needed\n *\n * function App() {\n * return (\n * <ClientProvider client={client}>\n * <MyApp />\n * </ClientProvider>\n * );\n * }\n * ```\n *\n * @example Async client (Suspense)\n * ```tsx\n * const clientPromise = useMemo(\n * () => createClient().use(someAsyncPlugin()),\n * [],\n * );\n *\n * <Suspense fallback={<Splash />}>\n * <ClientProvider client={clientPromise}>\n * <Shell />\n * </ClientProvider>\n * </Suspense>\n * ```\n *\n * @see {@link useClient}\n */\nexport function ClientProvider({ children, client }: ClientProviderProps): React.ReactElement {\n const resolved = usePromise(client);\n return <ClientContext.Provider value={resolved}>{children}</ClientContext.Provider>;\n}\n","import { useEffect, useLayoutEffect } from 'react';\n\n/**\n * `useLayoutEffect` warns when run on the server because layout effects only make sense after a\n * DOM is mounted. For our use, plain `useEffect` is functionally equivalent on the server (no\n * event handlers can fire mid-render anyway), so we pick at module load time and stay silent\n * during SSR.\n *\n * @internal\n */\nexport const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n","import { createReactiveActionStore } from '@solana/kit';\nimport { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\n\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\n/**\n * Reactive state and controls for an async action managed by {@link useAction}\n * (and plugin-specific hooks built on top of it).\n *\n * Lifecycle: starts at `idle`. Each `dispatch(...)` flips to `running`, then to `success` or\n * `error` depending on the outcome. `data` from a prior `success` and `error` from a prior failure\n * both persist through subsequent `running` states for stale-while-revalidate UX. `success` clears\n * `error`; only `reset()` clears `data`.\n *\n * Calling `dispatch(...)` while a previous call is in flight aborts the first via its\n * `AbortSignal` and replaces it. Fire-and-forget `dispatch` callers never observe this; awaiters of\n * a superseded `dispatchAsync` call see a rejection with an `AbortError`, filterable via\n * `isAbortError` from `@solana/promises`.\n *\n * @typeParam TArgs - The argument tuple `dispatch` accepts; forwarded to the wrapped function\n * after the abort signal.\n * @typeParam TResult - The value the wrapped function resolves to on success.\n */\nexport type ActionResult<TArgs extends readonly unknown[], TResult> = {\n /** The result on success, or `undefined` if no successful call has happened yet. */\n data: TResult | undefined;\n /**\n * Trigger the action and forget it. Returns `undefined` synchronously and never throws —\n * failures surface on `status` / `error`, and superseded or `reset()`-aborted calls produce no\n * state change. This is the variant to wire into UI event handlers (`onClick={() => dispatch()}`):\n * there is no promise to handle, so it can't produce an unhandled rejection. Calling `dispatch`\n * again while a prior call is in flight aborts the first. Stable reference.\n *\n * @see {@link ActionResult.dispatchAsync} when you need the resolved value or propagated errors.\n */\n dispatch: (...args: TArgs) => void;\n /**\n * Trigger the action and await the outcome. Resolves with the wrapped function's result, or\n * rejects with the thrown error. Calling `dispatch`/`dispatchAsync` again while a prior call is\n * in flight aborts the first and rejects its promise with an `AbortError`. Stable reference.\n *\n * Mirrors `ReactiveActionStore.dispatchAsync`. Use this from imperative callers that read the\n * resolved value (e.g. to navigate on success); filter supersede rejections with `isAbortError`\n * from `@solana/promises`. Prefer {@link ActionResult.dispatch} from event handlers that don't\n * await — its returned promise, left unhandled, surfaces every supersede/abort as an\n * `unhandledrejection`.\n */\n dispatchAsync: (...args: TArgs) => Promise<TResult>;\n /**\n * The error from the most recent failed call, or `undefined`. Persists through a subsequent\n * `running` state so UIs can keep showing the prior failure while a retry is in flight; a\n * subsequent `success` clears it.\n */\n error: unknown;\n /** `true` when `status === 'error'`. */\n isError: boolean;\n /** `true` when `status === 'idle'`. */\n isIdle: boolean;\n /** `true` when `status === 'running'` — a dispatch is in flight. */\n isRunning: boolean;\n /** `true` when `status === 'success'`. */\n isSuccess: boolean;\n /** Reset state back to `idle`, aborting any in-flight call. Stable reference. */\n reset: () => void;\n /**\n * The current lifecycle status as a discriminated string. The `isIdle` / `isRunning` /\n * `isSuccess` / `isError` booleans below are derived from this — pick whichever reads better\n * at the call site.\n */\n status: 'error' | 'idle' | 'running' | 'success';\n};\n\n/**\n * Bridge an arbitrary async function into a reactive {@link ActionResult}. Each `dispatch(...)`\n * call runs the function with a fresh {@link AbortSignal} and tracks its lifecycle through React\n * state; a second call while a first is in flight aborts the first.\n *\n * `fn` is held in a ref that always points at the latest closure — there is no `deps` array to\n * maintain. Each `dispatch(...)` invokes the most recently rendered `fn`, so values captured\n * inside (e.g. form state, route params) are always fresh without explicit dependency tracking.\n * In-flight calls are unaffected — they continue with the closure they captured at dispatch time.\n *\n * @typeParam TArgs - The argument tuple `dispatch` accepts; forwarded to `fn` after the abort\n * signal.\n * @typeParam TResult - The value `fn` resolves to on success.\n *\n * @example\n * ```tsx\n * import { useAction } from '@solana/react';\n *\n * function PostMessageButton({ url, body }: { url: string; body: string }) {\n * const { dispatch, isRunning, error } = useAction(async (signal, content: string) => {\n * const res = await fetch(url, { body: content, method: 'POST', signal });\n * if (!res.ok) throw new Error(`HTTP ${res.status}`);\n * return res.json() as Promise<{ id: string }>;\n * });\n * return (\n * <button disabled={isRunning} onClick={() => dispatch(body)}>\n * {isRunning ? 'Posting…' : error ? 'Retry' : 'Post'}\n * </button>\n * );\n * }\n * ```\n *\n * @see {@link ActionResult}\n */\nexport function useAction<TArgs extends readonly unknown[], TResult>(\n fn: (signal: AbortSignal, ...args: TArgs) => Promise<TResult>,\n): ActionResult<TArgs, TResult> {\n // Stable callback over the latest closure. Similar to `useEffectEvent`, but we need to\n // pass the callback to `createReactiveActionStore` so need to implement the pattern manually.\n const fnRef = useRef(fn);\n useIsomorphicLayoutEffect(() => {\n fnRef.current = fn;\n });\n\n // `createReactiveActionStore` only reads the callback when the returned `dispatch` is\n // called, not during render. The `react-hooks/refs` rule doesn't know that, so we silence it.\n // eslint-disable-next-line react-hooks/refs\n const [store] = useState(() =>\n createReactiveActionStore<TArgs, TResult>((signal, ...args) => fnRef.current(signal, ...args)),\n );\n\n // Reset on unmount so any in-flight call is aborted and state is dropped.\n useEffect(() => () => store.reset(), [store]);\n\n const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);\n\n return useMemo(\n () => ({\n data: state.data,\n dispatch: store.dispatch,\n dispatchAsync: store.dispatchAsync,\n error: state.error,\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n isRunning: state.status === 'running',\n isSuccess: state.status === 'success',\n reset: store.reset,\n status: state.status,\n }),\n [state, store],\n );\n}\n","import type { Address, ClientWithAirdrop, Lamports, Signature } from '@solana/kit';\n\nimport { type ActionResult, useAction } from './useAction';\n\n/**\n * Requests an airdrop of SOL to an address, as a reactive action.\n *\n * Wraps `client.airdrop` with {@link useAction}: each `dispatch(address, amount)` runs the airdrop\n * with a fresh `AbortSignal` and tracks its lifecycle through React state. Calling `dispatch` again\n * while a previous airdrop is in flight aborts the first. This is a great fit for a devnet or\n * localnet \"fund this account\" button, where the `isRunning` / `data` / `error` tracking drives the\n * UI directly.\n *\n * The airdrop capability is typically available on test networks (devnet, testnet) and local\n * validators. Some implementations (e.g. LiteSVM) update balances directly without sending a\n * transaction, in which case the resolved `data` is `undefined` rather than a {@link Signature}.\n *\n * @param client - A client with an airdrop plugin installed (`ClientWithAirdrop`).\n * @returns An {@link ActionResult} whose `dispatch`/`dispatchAsync` take the recipient `address` and\n * the `amount` of lamports, and resolve with the transaction {@link Signature}, or `undefined`\n * when the airdrop was performed without a transaction.\n *\n * @example\n * ```tsx\n * import { useAirdrop } from '@solana/react';\n * import { lamports } from '@solana/kit';\n *\n * function AirdropButton({ client, address }) {\n * const { dispatch, isRunning } = useAirdrop(client);\n * return (\n * <button disabled={isRunning} onClick={() => dispatch(address, lamports(1_000_000_000n))}>\n * {isRunning ? 'Airdropping…' : 'Airdrop 1 SOL'}\n * </button>\n * );\n * }\n * ```\n *\n * @see {@link ActionResult}\n * @see {@link useAction}\n */\nexport function useAirdrop(\n client: ClientWithAirdrop,\n): ActionResult<[address: Address, amount: Lamports], Signature | undefined> {\n return useAction((abortSignal, address: Address, amount: Lamports) => client.airdrop(address, amount, abortSignal));\n}\n","import { type Client, SOLANA_ERROR__REACT__MISSING_PROVIDER, SolanaError } from '@solana/kit';\nimport React from 'react';\n\nimport { ClientContext } from './ClientProvider';\n\n/**\n * Reads the Kit client published by the nearest {@link ClientProvider}. Throws a\n * {@link SolanaError} with code {@link SOLANA_ERROR__REACT__MISSING_PROVIDER} if no provider is\n * mounted in the ancestor tree.\n *\n * Pass the shape of your client through the generic (typically the `AppClient` type you export\n * alongside the client) so every installed capability is typed at the call site. This is a pure\n * cast with no runtime capability check, so reach for {@link useClientCapability} when a missing\n * plugin should fail loudly at mount instead of surfacing later as `undefined`.\n *\n * @typeParam TClient - The shape the client is expected to satisfy. Pure type assertion, so this\n * must always be supplied — the hook can't infer it from its (absent) arguments.\n *\n * @example\n * ```tsx\n * import { ClientWithRpc, GetEpochInfoApi } from '@solana/kit';\n * import { useClient } from '@solana/react';\n *\n * function ManualSend() {\n * const client = useClient<ClientWithRpc<GetEpochInfoApi>>();\n * return <button onClick={() => client.rpc.getEpochInfo().send()}>Fetch</button>;\n * }\n * ```\n *\n * @see {@link ClientProvider}\n * @see {@link useClientCapability}\n */\nexport function useClient<TClient extends object>(): Client<TClient> {\n const client = React.useContext(ClientContext);\n if (client == null) {\n throw new SolanaError(SOLANA_ERROR__REACT__MISSING_PROVIDER, { hookName: 'useClient' });\n }\n return client as Client<TClient>;\n}\n","import { type Client, SOLANA_ERROR__REACT__MISSING_CAPABILITY, SolanaError } from '@solana/kit';\n\nimport { useClient } from './useClient';\n\n/**\n * Configuration for {@link useClientCapability}.\n */\nexport type UseClientCapabilityConfig = Readonly<{\n /**\n * The capability name (or names) the hook depends on. Each is checked against the client with\n * a runtime `in` test before the narrowed value is returned. Pass an array when the hook\n * needs multiple capabilities (e.g. `['rpc', 'rpcSubscriptions']`); the same `providerHint` is\n * used for any that's missing.\n */\n capability: string | readonly string[];\n /**\n * Name of the calling hook, surfaced in the missing-capability error so users can locate the\n * call site quickly.\n */\n hookName: string;\n /**\n * Free-form actionable hint shown alongside the error — usually a one-liner naming the plugin\n * (or family of plugins) the user should install.\n */\n providerHint: string;\n}>;\n\n/**\n * Reads the client from the nearest {@link ClientProvider} and asserts at mount that the\n * requested capability is installed, narrowing the return type via the generic. Throws a\n * {@link SolanaError} with code {@link SOLANA_ERROR__REACT__MISSING_CAPABILITY} when the\n * capability is absent — including the calling `hookName` and a `providerHint` so users can fix\n * the mistake without cross-referencing docs.\n *\n * Use this from the implementation of plugin-specific hooks. Apps that need ad-hoc access without\n * a runtime check can reach for {@link useClient} directly and supply their own type narrowing.\n *\n * @typeParam TClient - The narrowed client shape returned once the capability assertion passes.\n * Always pass this generic — the hook can't infer it from a string.\n *\n * @example\n * ```ts\n * import { ClientWithRpc, GetEpochInfoApi } from '@solana/kit';\n * import { useClientCapability } from '@solana/react';\n *\n * function useRpc() {\n * return useClientCapability<ClientWithRpc<GetEpochInfoApi>>({\n * capability: 'rpc',\n * hookName: 'useRpc',\n * providerHint: 'Install `solanaRpc()` on the client.',\n * });\n * }\n * ```\n *\n * @see {@link useClient}\n * @see {@link ClientProvider}\n */\nexport function useClientCapability<TClient extends object>({\n capability,\n hookName,\n providerHint,\n}: UseClientCapabilityConfig): Client<TClient> {\n const client = useClient<TClient>();\n const required = typeof capability === 'string' ? [capability] : capability;\n const missing = required.filter(name => !Object.hasOwn(client, name));\n if (missing.length > 0) {\n throw new SolanaError(SOLANA_ERROR__REACT__MISSING_CAPABILITY, {\n capabilities: missing,\n hookName,\n providerHint,\n });\n }\n return client;\n}\n","import type { ClientWithIdentity, ClientWithSubscribeToIdentity, TransactionSigner } from '@solana/kit';\nimport { useCallback, useSyncExternalStore } from 'react';\n\nconst NOOP_UNSUBSCRIBE = () => {};\n\n/**\n * Reads `client.identity` and re-renders whenever it changes, returning `undefined` while no\n * identity is available.\n *\n * The identity is the {@link TransactionSigner} representing the wallet whose on-chain assets the\n * application is acting upon.\n *\n * When the client advertises {@link ClientWithSubscribeToIdentity},\n * this hook subscribes via `client.subscribeToIdentity` so the returned value always reflects the\n * latest identity. For a client whose identity is fixed for its lifetime, the hook falls back to a\n * no-op subscription and simply reads the value once.\n *\n * @param client - A client with an identity plugin installed. If it also advertises\n * `subscribeToIdentity`, the hook tracks changes reactively.\n * @returns The current `client.identity` signer, or `undefined` if no identity is currently\n * available.\n *\n * @example\n * ```tsx\n * const identity = useIdentity(client);\n * return <span>{identity ? `Signed in as ${identity.address}` : 'Signed out'}</span>;\n * ```\n *\n * @see {@link usePayer}\n */\nexport function useIdentity(\n client: ClientWithIdentity & Partial<ClientWithSubscribeToIdentity>,\n): TransactionSigner | undefined {\n const subscribe = useCallback(\n (onStoreChange: () => void) =>\n client.subscribeToIdentity ? client.subscribeToIdentity(onStoreChange) : NOOP_UNSUBSCRIBE,\n [client],\n );\n const getSnapshot = useCallback((): TransactionSigner | undefined => {\n try {\n return client.identity;\n } catch {\n return undefined;\n }\n }, [client]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import type { ClientWithPayer, ClientWithSubscribeToPayer, TransactionSigner } from '@solana/kit';\nimport { useCallback, useSyncExternalStore } from 'react';\n\nconst NOOP_UNSUBSCRIBE = () => {};\n\n/**\n * Reads `client.payer` and re-renders whenever it changes, returning `undefined` while no payer is\n * available.\n *\n * The payer is the {@link TransactionSigner} a client uses to sign and pay for transactions by\n * default.\n *\n * When the client advertises {@link ClientWithSubscribeToPayer}, this hook subscribes via\n * `client.subscribeToPayer` so the returned value always reflects the latest payer. For a client\n * whose payer is fixed for its lifetime, the hook falls back to a no-op subscription and simply\n * reads the value once.\n *\n * @param client - A client with a payer plugin installed. If it also advertises\n * `subscribeToPayer`, the hook tracks changes reactively.\n * @returns The current `client.payer` signer, or `undefined` if no payer is currently available.\n *\n * @example\n * ```tsx\n * const payer = usePayer(client);\n * return <span>{payer ? `Paying with ${payer.address}` : 'No payer'}</span>;\n * ```\n *\n * @see {@link useIdentity}\n */\nexport function usePayer(client: ClientWithPayer & Partial<ClientWithSubscribeToPayer>): TransactionSigner | undefined {\n const subscribe = useCallback(\n (onStoreChange: () => void) =>\n client.subscribeToPayer ? client.subscribeToPayer(onStoreChange) : NOOP_UNSUBSCRIBE,\n [client],\n );\n const getSnapshot = useCallback((): TransactionSigner | undefined => {\n try {\n return client.payer;\n } catch {\n return undefined;\n }\n }, [client]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import type { ClientWithTransactionPlanning, InstructionPlanInput, SingleTransactionPlan } from '@solana/kit';\n\nimport { type ActionResult, useAction } from './useAction';\n\n/**\n * Plans a single transaction from an instruction input, as a reactive action.\n *\n * Wraps `client.planTransaction` with {@link useAction}: each `dispatch(input)` runs the plan with a\n * fresh `AbortSignal` and tracks its lifecycle through React state. Calling `dispatch` again while a\n * previous plan is in flight aborts the first. Use this when you expect all instructions to fit in a\n * single transaction; reach for {@link usePlanTransactions} when they might need splitting.\n *\n * @param client - A client with a transaction-planning plugin installed.\n * @returns An {@link ActionResult} whose `dispatch`/`dispatchAsync` take the\n * {@link InstructionPlanInput} and resolve with the planned transaction message.\n *\n * @example\n * ```tsx\n * const { dispatch, data, isRunning } = usePlanTransaction(client);\n * <button disabled={isRunning} onClick={() => dispatch(instructions)}>Plan</button>\n * ```\n *\n * @see {@link usePlanTransactions}\n * @see {@link useSendTransaction}\n */\nexport function usePlanTransaction(\n client: ClientWithTransactionPlanning,\n): ActionResult<[input: InstructionPlanInput], SingleTransactionPlan['message']> {\n return useAction((abortSignal, input: InstructionPlanInput) => client.planTransaction(input, { abortSignal }));\n}\n","import type { ClientWithTransactionPlanning, InstructionPlanInput, TransactionPlan } from '@solana/kit';\n\nimport { type ActionResult, useAction } from './useAction';\n\n/**\n * Plans one or more transactions from an instruction input, as a reactive action.\n *\n * Wraps `client.planTransactions` with {@link useAction}: each `dispatch(input)` runs the plan with a\n * fresh `AbortSignal` and tracks its lifecycle through React state. Calling `dispatch` again while a\n * previous plan is in flight aborts the first. Use this when the instructions might be split across\n * multiple transactions due to size limits; reach for {@link usePlanTransaction} for the single-\n * transaction case.\n *\n * @param client - A client with a transaction-planning plugin installed.\n * @returns An {@link ActionResult} whose `dispatch`/`dispatchAsync` take the\n * {@link InstructionPlanInput} and resolve with the full {@link TransactionPlan}.\n *\n * @example\n * ```tsx\n * const { dispatch, data, isRunning } = usePlanTransactions(client);\n * <button disabled={isRunning} onClick={() => dispatch(instructions)}>Plan</button>\n * ```\n *\n * @see {@link usePlanTransaction}\n * @see {@link useSendTransactions}\n */\nexport function usePlanTransactions(\n client: ClientWithTransactionPlanning,\n): ActionResult<[input: InstructionPlanInput], TransactionPlan> {\n return useAction((abortSignal, input: InstructionPlanInput) => client.planTransactions(input, { abortSignal }));\n}\n","import { ReactiveActionStore, ReactiveState, ReactiveStreamStore } from '@solana/kit';\n\nconst DISABLED_ACTION_STATE = Object.freeze({\n data: undefined,\n error: undefined,\n status: 'idle' as const,\n});\n\nconst IDLE_STREAM_STATE: ReactiveState<never> = Object.freeze({\n data: undefined,\n error: undefined,\n status: 'idle',\n});\n\nconst noopUnsubscribe = () => {};\nconst noopSubscribe = () => noopUnsubscribe;\nconst rejectedAbortError = (): Promise<never> => Promise.reject(new DOMException('Aborted', 'AbortError'));\n\n/**\n * A {@link ReactiveActionStore} that never transitions out of `idle` and rejects any attempt to\n * dispatch. Returned by `useRequest` (and other action-store hooks) when their factory function\n * returns `null`, signalling that the call should be gated off — for example because a required\n * input (an address, a query string) is not yet known.\n *\n * The hook's result bridge maps this store's `idle` state to a `disabled` status so call sites\n * can distinguish \"not enabled\" from \"loading\" without an extra flag.\n */\nexport function disabledActionStore<T>(): ReactiveActionStore<[], T> {\n return {\n dispatch: noopUnsubscribe,\n dispatchAsync: rejectedAbortError,\n getState: () => DISABLED_ACTION_STATE,\n reset: noopUnsubscribe,\n subscribe: noopSubscribe,\n withSignal: () => ({\n dispatch: noopUnsubscribe,\n dispatchAsync: rejectedAbortError,\n }),\n };\n}\n\n/**\n * A {@link ReactiveStreamStore} that never transitions out of `idle` and ignores every\n * `connect` / `reset` / `subscribe` call. Returned by `useSubscription` when its\n * source is `null`, signalling that the subscription should be gated off — for example because\n * a required input (an address) is not yet known.\n *\n * The hook's result bridge maps this store's `idle` state to a `disabled` status so call sites\n * can distinguish \"not enabled\" from \"loading\" without an extra flag.\n */\nexport function disabledStreamStore<T>(): ReactiveStreamStore<T> {\n return {\n connect: noopUnsubscribe,\n getState: () => IDLE_STREAM_STATE,\n reset: noopUnsubscribe,\n subscribe: noopSubscribe,\n withSignal: () => ({ connect: noopUnsubscribe }),\n };\n}\n","import { type MutableRefObject, useRef } from 'react';\n\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\n/**\n * Hold `value` in a ref that is re-synced to the latest render's value after every commit.\n *\n * Lets a callback (or a store created once) read the freshest closure value at call time without\n * taking it as a dependency, so the consumer's own identity stays stable across renders. The sync\n * runs in a layout effect so the ref is current before passive effects and event handlers fire.\n *\n * @typeParam T - The type of the value being tracked.\n *\n * @returns A stable {@link MutableRefObject} whose `current` always reflects the most recent render.\n *\n * @internal\n */\nexport function useLatest<T>(value: T): MutableRefObject<T> {\n const ref = useRef(value);\n useIsomorphicLayoutEffect(() => {\n ref.current = value;\n });\n return ref;\n}\n","import { useCallback, useEffect, useRef } from 'react';\n\nimport { useLatest } from './useLatest';\n\n/**\n * Options accepted by the `refresh`-style callback returned from {@link useReactiveStoreLifecycle}.\n *\n * @internal\n */\ntype RefireOptions = {\n /**\n * Override the configured `getAbortSignal` factory for this attempt. Passing the key at all\n * (even as `undefined`) opts out of the factory; omitting it falls back to the factory.\n */\n abortSignal?: AbortSignal | undefined;\n};\n\n// In dev, warn when the store identity changes this many times inside `CHURN_WINDOW_MS`. A handful\n// of recreations is normal (StrictMode's mount/cleanup/mount, an occasional dependency change); a\n// burst this large within a second only happens when an unmemoized `source`/`spec` mints a fresh\n// store every render — the self-sustaining dispatch/abort loop. Set well above any legitimate churn.\nconst CHURN_WARNING_THRESHOLD = 25;\nconst CHURN_WINDOW_MS = 1_000;\n\n/**\n * Shared lifecycle for the source-keyed reactive-store hooks (`useRequest`, and the stream-store\n * hooks built on the same shape). Owns the three pieces each of them otherwise repeats verbatim:\n *\n * - ref-syncs `getAbortSignal` so an inline factory passed every render doesn't churn the caller's\n * store memo,\n * - fires the store on commit and resets it on teardown / store-identity change,\n * - returns a stable `refresh`-style callback carrying the presence-based signal override.\n *\n * `fire` performs the store's \"go\" verb — `dispatch` for action stores, `connect` for stream\n * stores — optionally with a per-attempt {@link AbortSignal}. Pass it as a stable (module-level)\n * function so the returned callback stays referentially stable.\n *\n * In development it also emits a `console.error` when the store identity changes far more often\n * than legitimate use would explain, which is the signature of an unmemoized `source`/`spec`\n * driving an infinite dispatch/abort loop.\n *\n * @typeParam TStore - The reactive store type; only its `reset()` method is needed here.\n *\n * @param store - The store to drive; recreated by the caller whenever the source identity changes.\n * @param fire - Performs the store's go verb, optionally with a per-attempt signal.\n * @param getAbortSignal - Optional factory invoked per attempt to mint a fresh signal.\n *\n * @returns A stable callback that re-fires the store, accepting the per-attempt signal override.\n *\n * @internal\n */\nexport function useReactiveStoreLifecycle<TStore extends { reset(): void }>(\n store: TStore,\n fire: (store: TStore, signal: AbortSignal | undefined) => void,\n getAbortSignal: (() => AbortSignal) | undefined,\n): (options?: RefireOptions) => void {\n const getAbortSignalRef = useLatest(getAbortSignal);\n\n const refresh = useCallback(\n (options?: RefireOptions) => {\n // Presence-based override: an explicit `abortSignal` key (even `undefined`) opts out\n // of the factory for this attempt. Omitting the key falls back to the factory.\n const signal = options && 'abortSignal' in options ? options.abortSignal : getAbortSignalRef.current?.();\n fire(store, signal);\n },\n // `getAbortSignalRef` is a stable ref and `fire` a stable (module-level) function, so\n // `refresh` only changes identity when `store` does.\n [fire, getAbortSignalRef, store],\n );\n\n // Dev-only churn guard. This effect re-runs once per store identity (deps include `store`), so\n // counting its runs within a rolling window flags an unmemoized `source`/`spec` that mints a\n // fresh store every render. Counting lives here, not in render, so there's no render-phase\n // ref mutation for StrictMode to flag.\n const churnRef = useRef({ count: 0, warned: false, windowStart: 0 });\n\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\") {\n const churn = churnRef.current;\n const now = Date.now();\n if (now - churn.windowStart > CHURN_WINDOW_MS) {\n churn.windowStart = now;\n churn.count = 0;\n }\n if (++churn.count > CHURN_WARNING_THRESHOLD && !churn.warned) {\n churn.warned = true;\n\n console.error(\n 'A reactive-store hook (e.g. `useRequest`) recreated its store %d times within ' +\n '1s. This almost always means the `source`/`spec` passed to it is a fresh ' +\n 'reference on every render — wrap it in `useMemo`/`useCallback` keyed on its ' +\n 'inputs. Each recreation aborts the in-flight request before it can complete, ' +\n 'so nothing ever loads.',\n churn.count,\n );\n }\n }\n refresh();\n return () => store.reset();\n }, [refresh, store]);\n\n return refresh;\n}\n","import { ReactiveActionStore } from '@solana/kit';\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { RequestResult } from './useRequest';\n\n/**\n * Subscribes to a {@link ReactiveActionStore} and maps its `idle | running | success | error`\n * lifecycle onto the {@link RequestResult} shape consumed by `useRequest`.\n *\n * `idle` is ambiguous on its own: it covers both \"no source — store is disabled\" and \"real source,\n * dispatch effect hasn't fired yet on the current render.\" The `disabled` flag disambiguates:\n * disabled → `status: 'disabled'`, enabled → `status: 'fetching'` (the dispatch is about to fire\n * on commit; consumers see a single `fetching` paint rather than briefly flashing `disabled`).\n *\n * - `idle` + disabled → `disabled`\n * - `idle` + enabled → `fetching` (first paint, dispatch effect about to commit)\n * - `running` → `fetching` (caller inspects `data` / `error` to know if there's stale content)\n * - `success` → `success`\n * - `error` → `error`\n *\n * The action store's built-in stale-while-revalidate carries `state.data` and `state.error`\n * across attempts, so the bridge doesn't need to mirror them.\n *\n * @internal\n */\nexport function useRequestResult<T>(\n store: ReactiveActionStore<[], T>,\n refresh: (options?: { abortSignal?: AbortSignal | undefined }) => void,\n disabled: boolean,\n): RequestResult<T> {\n const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);\n return useMemo(() => {\n const status: RequestResult<T>['status'] =\n state.status === 'idle'\n ? disabled\n ? 'disabled'\n : 'fetching'\n : state.status === 'running'\n ? 'fetching'\n : state.status; // 'success' | 'error'\n return {\n data: state.data,\n error: state.error,\n refresh,\n status,\n };\n }, [state, refresh, disabled]);\n}\n","import { createReactiveActionStore, ReactiveActionSource, ReactiveActionStore } from '@solana/kit';\nimport { useMemo } from 'react';\n\nimport { disabledActionStore } from './staticStores';\nimport { useReactiveStoreLifecycle } from './useReactiveStoreLifecycle';\nimport { useRequestResult } from './useRequestResult';\n\n// Module-level so it's a stable reference — keeps the `refresh` callback from\n// `useReactiveStoreLifecycle` referentially stable across renders.\nfunction fireAction<T>(store: ReactiveActionStore<[], T>, signal: AbortSignal | undefined): void {\n if (signal) store.withSignal(signal).dispatch();\n else store.dispatch();\n}\n\n/**\n * Reactive state for a one-shot request managed by {@link useRequest}.\n *\n * Lifecycle: starts at `fetching` (or `disabled` when the source is `null`) and auto-fires on\n * mount; transitions to `success` on success or `error` on failure. `refresh()` re-fires the\n * request — while a re-fire is in flight, `status` returns to `fetching` and the stale `data`\n * and/or `error` from the prior outcome remain populated (stale-while-revalidate).\n *\n * @typeParam T - The value the underlying request resolves to.\n */\nexport type RequestResult<T> = {\n /**\n * The most recent successful value, or `undefined` if no call has succeeded yet (or while\n * disabled). Persists across subsequent refreshes (including failed ones) until a new success\n * replaces it or `reset()` clears the store.\n */\n data: T | undefined;\n /**\n * The error from the most recent failed call, or `undefined` if no call has failed (or while\n * disabled). Persists across subsequent refreshes until a new success clears it. May coexist\n * with `data` when a successful attempt is followed by a failing one.\n */\n error: unknown;\n /**\n * Re-fire the request. By default each call mints a fresh signal from `getAbortSignal` (if\n * configured) and threads it through the underlying store's\n * `withSignal(signal).dispatch()`. Pass `{ abortSignal }` to override the configured factory\n * for just this attempt. Pass `{ abortSignal: undefined }` to opt out of the factory entirely\n * for this attempt and fire with no caller-provided signal.\n *\n * Stable reference.\n */\n refresh: (options?: { abortSignal?: AbortSignal | undefined }) => void;\n /**\n * Lifecycle status as a discriminated string:\n * - `fetching`: a request is in flight. `data` and `error` carry whatever stale content was\n * available before this attempt (both `undefined` on the first attempt; either or both\n * populated on a refresh after a prior outcome).\n * - `success`: most recent call succeeded; `data` holds the result.\n * - `error`: most recent call failed; `error` holds the reason.\n * - `disabled`: source was `null`.\n */\n status: 'disabled' | 'error' | 'fetching' | 'success';\n};\n\n/** Options accepted by {@link useRequest}. */\nexport type UseRequestOptions = {\n /**\n * Factory invoked on every attempt (initial fire + every `refresh()`). The returned signal is\n * attached to that attempt via the underlying store's `withSignal(signal).dispatch()`, so\n * aborting it cancels just the current attempt.\n *\n * The most common use is per-attempt timeouts: `getAbortSignal: () => AbortSignal.timeout(5000)`\n * gives every attempt its own 5-second clock that resets on `refresh()`.\n *\n * Held in a ref synced to the latest render's closure — there is no need to memoize an inline\n * factory.\n */\n getAbortSignal?: () => AbortSignal;\n};\n\n/**\n * Fire a one-shot request on mount and re-fire each time `source` changes identity or `refresh()`\n * is called. Returns reactive state tracking the call's lifecycle.\n *\n * Two ways to pass the work:\n *\n * - A {@link ReactiveActionSource} — the `{ reactiveStore() }` duck-type satisfied by\n * `PendingRpcRequest`.\n * - An async function `(signal: AbortSignal) => Promise<T>` — wrap any one-shot async source\n * (a `fetch`, a third-party SDK call, etc). Most general shape.\n *\n * Pass `null` to disable; the result reports `status: 'disabled'`.\n *\n * Memoize the input (`useMemo` for a source, `useCallback` for a function) keyed on whatever\n * inputs it depends on.\n *\n * @typeParam T - The value the underlying request resolves to.\n *\n * @example\n * ```tsx\n * function LatestBlockhash() {\n * const client = useClient<ClientWithRpc<GetLatestBlockhashApi>>();\n * const source = useMemo(() => client.rpc.getLatestBlockhash(), [client]);\n * const { data, error, refresh } = useRequest(source, {\n * getAbortSignal: () => AbortSignal.timeout(5_000),\n * });\n * if (error) return <button onClick={refresh}>Retry</button>;\n * return <p>{data ? `Blockhash: ${data.value.blockhash}` : 'Loading…'}</p>;\n * }\n *\n * // Function shape — wraps an arbitrary async call:\n * function Profile({ userId }: { userId: string }) {\n * const fetcher = useCallback(\n * (signal: AbortSignal) => fetch(`/api/users/${userId}`, { signal }).then(r => r.json()),\n * [userId],\n * );\n * const { data, error, refresh } = useRequest(fetcher);\n * if (error) return <button onClick={refresh}>Retry</button>;\n * return <p>{data ? data.name : 'Loading…'}</p>;\n * }\n * ```\n *\n * @see {@link RequestResult}\n * @see {@link UseRequestOptions}\n */\nexport function useRequest<T>(\n source: ReactiveActionSource<T> | ((signal: AbortSignal) => Promise<T>) | null,\n options?: UseRequestOptions,\n): RequestResult<T> {\n // One store per `source`. Both creation paths return an `idle` store; the initial dispatch\n // lives in the lifecycle effect below so the memo body stays pure (StrictMode's dev\n // double-render, and any future render-discard, won't fire a network request from a discarded\n // render).\n //\n // Note: `useMemo` is permitted to discard memoized values across renders (independent of deps);\n // if React ever does so here, the discard surfaces as a fresh store with empty `data` /\n // `error` and an immediate refetch — same shape as a remount. In practice this doesn't happen,\n // but if React changes and it becomes an issue, we'd need to rework this.\n const store = useMemo(() => {\n if (source == null) return disabledActionStore<T>();\n return typeof source === 'function' ? createReactiveActionStore<[], T>(source) : source.reactiveStore();\n }, [source]);\n\n // Fire on commit, reset on store change / unmount, and expose the stable `refresh` callback.\n // `store.reset()` aborts the in-flight request via the action store's internal controller, so\n // under StrictMode's mount → cleanup → mount sequence the first dispatch is properly aborted\n // before the second one fires.\n const refresh = useReactiveStoreLifecycle(store, fireAction, options?.getAbortSignal);\n\n return useRequestResult(store, refresh, source == null);\n}\n","import type { ClientWithTransactionSending, SuccessfulSingleTransactionPlanResult } from '@solana/kit';\n\nimport { type ActionResult, useAction } from './useAction';\n\ntype SendTransactionInput = Parameters<ClientWithTransactionSending['sendTransaction']>[0];\n\n/**\n * Sends a single transaction to the network, as a reactive action.\n *\n * Wraps `client.sendTransaction` with {@link useAction}, which handles signing, submission, and\n * confirmation. Each `dispatch(input)` runs with a fresh `AbortSignal` and tracks its lifecycle\n * through React state; calling `dispatch` again while a previous send is in flight aborts the first.\n * Accepts flexible input: instructions, an instruction plan, a single transaction message, or a\n * single transaction plan. Use {@link useSendTransactions} when the work may span multiple\n * transactions.\n *\n * @param client - A client with a transaction-sending plugin installed.\n * @returns An {@link ActionResult} whose `dispatch`/`dispatchAsync` take the input and resolve with\n * the {@link SuccessfulSingleTransactionPlanResult}.\n *\n * @example\n * ```tsx\n * const { dispatch, data, isRunning } = useSendTransaction(client);\n * <button disabled={isRunning} onClick={() => dispatch(instructions)}>Send</button>\n * ```\n *\n * @see {@link useSendTransactions}\n * @see {@link usePlanTransaction}\n */\nexport function useSendTransaction(\n client: ClientWithTransactionSending,\n): ActionResult<[input: SendTransactionInput], SuccessfulSingleTransactionPlanResult> {\n return useAction((abortSignal, input: SendTransactionInput) => client.sendTransaction(input, { abortSignal }));\n}\n","import type { ClientWithTransactionSending, TransactionPlanResult } from '@solana/kit';\n\nimport { type ActionResult, useAction } from './useAction';\n\ntype SendTransactionsInput = Parameters<ClientWithTransactionSending['sendTransactions']>[0];\n\n/**\n * Sends one or more transactions to the network, as a reactive action.\n *\n * Wraps `client.sendTransactions` with {@link useAction}, which handles signing, submission, and\n * confirmation. Each `dispatch(input)` runs with a fresh `AbortSignal` and tracks its lifecycle\n * through React state; calling `dispatch` again while a previous send is in flight aborts the first.\n * Accepts flexible input: instructions, an instruction plan, or a transaction plan. Use\n * {@link useSendTransaction} for the single-transaction case.\n *\n * @param client - A client with a transaction-sending plugin installed.\n * @returns An {@link ActionResult} whose `dispatch`/`dispatchAsync` take the input and resolve with\n * the {@link TransactionPlanResult} for all transactions.\n *\n * @example\n * ```tsx\n * const { dispatch, data, isRunning } = useSendTransactions(client);\n * <button disabled={isRunning} onClick={() => dispatch(instructions)}>Send</button>\n * ```\n *\n * @see {@link useSendTransaction}\n * @see {@link usePlanTransactions}\n */\nexport function useSendTransactions(\n client: ClientWithTransactionSending,\n): ActionResult<[input: SendTransactionsInput], TransactionPlanResult> {\n return useAction((abortSignal, input: SendTransactionsInput) => client.sendTransactions(input, { abortSignal }));\n}\n","import {\n SolanaSignAndSendTransaction,\n SolanaSignAndSendTransactionFeature,\n SolanaSignAndSendTransactionInput,\n SolanaSignAndSendTransactionOutput,\n} from '@solana/wallet-standard-features';\nimport {\n WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED,\n WalletStandardError,\n} from '@wallet-standard/errors';\nimport { getWalletAccountFeature, type UiWalletAccount } from '@wallet-standard/ui';\nimport { getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } from '@wallet-standard/ui-registry';\nimport { useCallback } from 'react';\n\nimport { OnlySolanaChains } from './chain';\n\ntype Input = Readonly<\n Omit<SolanaSignAndSendTransactionInput, 'account' | 'chain' | 'options'> & {\n options?: Readonly<{\n minContextSlot?: bigint;\n }>;\n }\n>;\ntype Output = SolanaSignAndSendTransactionOutput;\n\n/**\n * Use this to get a function capable of signing a serialized transaction with the private key of a\n * {@link UiWalletAccount} and sending it to the network for processing.\n *\n * @param chain The identifier of the chain the transaction is destined for. Wallets may use this to\n * simulate the transaction for the user.\n *\n * @example\n * ```tsx\n * import { getBase58Decoder } from '@solana/codecs-strings';\n * import { useSignAndSendTransaction } from '@solana/react';\n *\n * function SignAndSendTransactionButton({ account, transactionBytes }) {\n * const signAndSendTransaction = useSignAndSendTransaction(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const { signature } = await signAndSendTransaction({\n * transaction: transactionBytes,\n * });\n * const base58TransactionSignature = getBase58Decoder().decode(signature);\n * window.alert(\n * `View transaction: https://explorer.solana.com/tx/${base58TransactionSignature}?cluster=devnet`,\n * );\n * } catch (e) {\n * console.error('Failed to send transaction', e);\n * }\n * }}\n * >\n * Sign and Send Transaction\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignAndSendTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): (input: Input) => Promise<Output>;\nexport function useSignAndSendTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (input: Input) => Promise<Output>;\nexport function useSignAndSendTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (input: Input) => Promise<Output> {\n const signAndSendTransactions = useSignAndSendTransactions(uiWalletAccount, chain);\n return useCallback(\n async input => {\n const [result] = await signAndSendTransactions(input);\n return result;\n },\n [signAndSendTransactions],\n );\n}\n\n/**\n * Use this to get a function capable of signing one or more serialized transactions with the private\n * key of a {@link UiWalletAccount} and sending them to the network for processing. This supports\n * wallets that allow batching multiple transactions in a single request.\n *\n * @example\n * ```tsx\n * import { useSignAndSendTransactions } from '@solana/react';\n *\n * function SignAndSendTransactionsButton({ account, transactionBytes1, transactionBytes2 }) {\n * const signAndSendTransactions = useSignAndSendTransactions(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const [first, second] = await signAndSendTransactions(\n * { transaction: transactionBytes1 },\n * { transaction: transactionBytes2 },\n * );\n * window.alert(\n * `Transaction signatures: ${first.signature.toString()}, ${second.signature.toString()}`,\n * );\n * } catch (e) {\n * console.error('Failed to send transactions', e);\n * }\n * }}\n * >\n * Sign and Send Transactions\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignAndSendTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]>;\nexport function useSignAndSendTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]>;\nexport function useSignAndSendTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]> {\n if (!uiWalletAccount.chains.includes(chain)) {\n throw new WalletStandardError(WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED, {\n address: uiWalletAccount.address,\n chain,\n featureName: SolanaSignAndSendTransaction,\n supportedChains: [...uiWalletAccount.chains],\n supportedFeatures: [...uiWalletAccount.features],\n });\n }\n const signAndSendTransactionFeature = getWalletAccountFeature(\n uiWalletAccount,\n SolanaSignAndSendTransaction,\n ) as SolanaSignAndSendTransactionFeature[typeof SolanaSignAndSendTransaction];\n const account = getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWalletAccount);\n return useCallback(\n async (...inputs) => {\n if (inputs.length === 0) {\n return [];\n }\n const inputsWithChainAndAccount = inputs.map(({ options, ...rest }) => {\n const minContextSlot = options?.minContextSlot;\n return {\n ...rest,\n account,\n chain,\n ...(minContextSlot != null\n ? {\n options: {\n minContextSlot: Number(minContextSlot),\n },\n }\n : null),\n };\n });\n const results = await signAndSendTransactionFeature.signAndSendTransaction(...inputsWithChainAndAccount);\n return results;\n },\n [account, chain, signAndSendTransactionFeature],\n );\n}\n","import { ReactiveStreamStore } from '@solana/kit';\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { SubscriptionResult } from './useSubscription';\n\n/**\n * Subscribes to a {@link ReactiveStreamStore} and maps its\n * `idle | loading | loaded | error` lifecycle onto the {@link SubscriptionResult} shape\n * consumed by `useSubscription`. The notification passes through unchanged.\n *\n * For status we map the `idle` state to either `loading` or `disabled`, depending on the\n * `disabled` param. This is because `useSubscription` automatically connects, so we treat\n * `idle` as `loading` when a source is present and `disabled` when it's not.\n *\n * Stale-while-revalidate flows naturally through `state.data` / `state.error`, which the store\n * preserves across `loading` transitions, so the bridge doesn't need to mirror them.\n *\n * @param store - The store to subscribe to.\n * @param reconnect - A stable callback that re-opens the stream. Forwarded to the result so call\n * sites have a single, hook-owned recovery affordance.\n * @param disabled - When `true`, the result reports `status: 'disabled'`. Used by\n * `useSubscription` to signal the null-source case.\n *\n * @internal\n */\nexport function useSubscriptionResult<T>(\n store: ReactiveStreamStore<T>,\n reconnect: (options?: { abortSignal?: AbortSignal | undefined }) => void,\n disabled: boolean,\n): SubscriptionResult<T> {\n const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);\n return useMemo(() => {\n const status: SubscriptionResult<T>['status'] =\n state.status === 'idle' ? (disabled ? 'disabled' : 'loading') : state.status;\n return { data: state.data, error: state.error, reconnect, status };\n }, [state, reconnect, disabled]);\n}\n","import { ReactiveStreamSource, ReactiveStreamStore } from '@solana/kit';\nimport { useMemo } from 'react';\n\nimport { disabledStreamStore } from './staticStores';\nimport { useReactiveStoreLifecycle } from './useReactiveStoreLifecycle';\nimport { useSubscriptionResult } from './useSubscriptionResult';\n\n// Module-level so it's a stable reference — keeps the `reconnect` callback from\n// `useReactiveStoreLifecycle` referentially stable across renders.\nfunction fireConnect<T>(store: ReactiveStreamStore<T>, signal: AbortSignal | undefined): void {\n if (signal) store.withSignal(signal).connect();\n else store.connect();\n}\n\n/**\n * Reactive state for a subscription managed by {@link useSubscription} (and other stream-store\n * hooks built on top of it).\n *\n * Lifecycle: starts at `loading` (or `disabled` when the source is `null`) and opens the\n * underlying stream on mount; transitions to `loaded` on the first notification or `error` on\n * failure. `reconnect()` re-opens the stream — while a reconnect is in flight, `status` returns\n * to `loading` and the stale `data` and/or `error` from the prior connection remain populated\n * (stale-while-revalidate).\n *\n * @typeParam T - The notification type emitted by the underlying source.\n */\nexport type SubscriptionResult<T> = {\n /**\n * The latest notification. `undefined` on the first load and while disabled. On `loading`\n * after a prior outcome, on `error`, and on a subsequent reconnect, holds the last\n * received notification.\n */\n data: T | undefined;\n /**\n * Error from the subscription, or `undefined`. On `loading` after a prior `error`, holds the\n * stale error so UIs can keep showing the failure context (e.g. a banner) while the\n * reconnect is in flight. A subsequent `loaded` clears it.\n */\n error: unknown;\n /**\n * Re-open the stream. By default each call mints a fresh signal from `getAbortSignal` (if\n * configured) and threads it through the underlying store's `withSignal(signal).connect()`.\n * Pass `{ abortSignal }` to override the configured factory for just this attempt. Pass\n * `{ abortSignal: undefined }` to opt out of the factory entirely for this attempt and open\n * with no caller-provided signal.\n *\n * Stable reference. Safe to put in `onClick` handlers or effect deps — typically wired up\n * to a \"Reconnect\" button when `status === 'error'`. Calls `store.connect()` under the\n * hood, so it always (re)opens the stream regardless of current status; the bridge\n * transitions back through `loading` while preserving stale data and error.\n */\n reconnect: (options?: { abortSignal?: AbortSignal | undefined }) => void;\n /**\n * Lifecycle status as a discriminated string:\n * - `loading`: a connection is in progress. On the first connection, `data` and `error` are\n * `undefined`. After a reconnect, `data` and `error` hold the last known values from the\n * previous connection (stale-while-revalidate).\n * - `loaded`: at least one notification has arrived.\n * - `error`: the subscription failed; `data` holds the last known value (if any).\n * - `disabled`: source was `null` — no subscription was opened.\n */\n status: 'disabled' | 'error' | 'loaded' | 'loading';\n};\n\n/** Options accepted by {@link useSubscription}. */\nexport type UseSubscriptionOptions = {\n /**\n * Factory invoked on every connection (initial subscribe + every `reconnect()`). The returned\n * signal is attached to that connection via the underlying store's\n * `withSignal(signal).connect()`, so aborting it tears down that connection.\n *\n * The most common use is per-connection timeouts:\n * `getAbortSignal: () => AbortSignal.timeout(30_000)` gives every connection its own\n * 30-second clock that resets on `reconnect()`.\n *\n * Held in a ref synced to the latest render's closure — there is no need to memoize an inline\n * factory.\n */\n getAbortSignal?: () => AbortSignal;\n};\n\n/**\n * Subscribe to a stream-store source and surface the latest notification as reactive state. The\n * subscription opens on mount, re-opens whenever `source` changes identity, and tears down on\n * unmount.\n *\n * Accepts any {@link ReactiveStreamSource} — the `{ reactiveStore() }` duck-type satisfied by\n * `PendingRpcSubscriptionsRequest` (e.g. `client.rpcSubscriptions.accountNotifications(addr)`)\n * and any plugin-authored stream object that follows the same convention. Pass `null` to\n * disable; the result reports `status: 'disabled'`.\n *\n * Memoize the source with `useMemo` keyed on whatever inputs it depends on; stable identity is\n * how the hook knows when to tear down and re-open.\n *\n * SSR-safe — on the server the connect effect doesn't run, so the store stays `idle` and the\n * hook reports `status: 'loading'`. The first client render hydrates from that same `loading`\n * paint, then commits the connect effect.\n *\n * @typeParam T - The notification type emitted by the source.\n *\n * @example\n * ```tsx\n * function AccountBalance({ address }: { address: Address }) {\n * const client = useClient<ClientWithRpcSubscriptions<AccountNotificationsApi>>();\n * const source = useMemo(() => client.rpcSubscriptions.accountNotifications(address), [client, address]);\n * const { data, error, reconnect } = useSubscription(source);\n * if (error) return <button onClick={reconnect}>Reconnect</button>;\n * return <p>{data ? `${data.value.lamports} lamports at slot ${data.context.slot}` : 'Connecting…'}</p>;\n * }\n * ```\n *\n * @see {@link SubscriptionResult}\n * @see {@link UseSubscriptionOptions}\n */\nexport function useSubscription<T>(\n source: ReactiveStreamSource<T> | null,\n options?: UseSubscriptionOptions,\n): SubscriptionResult<T> {\n // One store per `source`. Both creation paths return an `idle` store; the initial connect\n // lives in the lifecycle effect below so the memo body stays pure (StrictMode's dev\n // double-render, and any future render-discard, won't open a subscription from a discarded\n // render).\n const store = useMemo(() => {\n if (source == null) return disabledStreamStore<T>();\n return source.reactiveStore();\n }, [source]);\n\n // Connect on commit, reset on store change / unmount, and expose the stable `reconnect`\n // callback. `store.reset()` aborts the active connection via the stream store's internal\n // controller, so under StrictMode's mount → cleanup → mount sequence the first connect is\n // properly aborted before the second one fires. `disabledStreamStore` returns a store whose\n // `connect`/`reset` are no-ops, so the null-source case needs no explicit gate.\n const reconnect = useReactiveStoreLifecycle(store, fireConnect, options?.getAbortSignal);\n\n return useSubscriptionResult(store, reconnect, source == null);\n}\n","import { Address } from '@solana/kit';\nimport {\n SolanaSignIn,\n SolanaSignInFeature,\n SolanaSignInInput,\n SolanaSignInOutput,\n} from '@solana/wallet-standard-features';\nimport {\n getWalletAccountFeature,\n getWalletFeature,\n UiWallet,\n UiWalletAccount,\n UiWalletHandle,\n} from '@wallet-standard/ui';\nimport {\n getOrCreateUiWalletAccountForStandardWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,\n getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,\n getWalletForHandle_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,\n} from '@wallet-standard/ui-registry';\nimport { useCallback } from 'react';\n\ntype Input = SolanaSignInInput;\ntype Output = Omit<SolanaSignInOutput, 'account' | 'signatureType'> &\n Readonly<{\n account: UiWalletAccount;\n }>;\n\n/**\n * Use the ['Sign In With Solana'](https://phantom.app/learn/developers/sign-in-with-solana) feature\n * of a {@link UiWallet} or {@link UiWalletAccount}.\n *\n * @returns A function that you can call to sign in with the particular wallet and address specified\n * by the supplied {@link UiWalletAccount}\n *\n * @example\n * ```tsx\n * import { useSignIn } from '@solana/react';\n *\n * function SignInButton({ wallet }) {\n * const csrfToken = useCsrfToken();\n * const signIn = useSignIn(wallet);\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const { account, signedMessage, signature } = await signIn({\n * requestId: csrfToken,\n * });\n * // Authenticate the user, typically on the server, by verifying that\n * // `signedMessage` was signed by the person who holds the private key for\n * // `account.publicKey`.\n * //\n * // Authorize the user, also on the server, by decoding `signedMessage` as the\n * // text of a Sign In With Solana message, verifying that it was not modified\n * // from the values your application expects, and that its content is sufficient\n * // to grant them access.\n * window.alert(`You are now signed in with the address ${account.address}`);\n * } catch (e) {\n * console.error('Failed to sign in', e);\n * }\n * }}\n * >\n * Sign In\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignIn(uiWalletAccount: UiWalletAccount): (input?: Omit<Input, 'address'>) => Promise<Output>;\n/**\n * @returns A function that you can call to sign in with the supplied {@link UiWallet}\n */\nexport function useSignIn(uiWallet: UiWallet): (input?: Input) => Promise<Output>;\nexport function useSignIn(uiWalletHandle: UiWalletHandle): (input?: Input) => Promise<Output> {\n const signIns = useSignIns(uiWalletHandle);\n return useCallback(\n async input => {\n const [result] = await signIns(input);\n return result;\n },\n [signIns],\n );\n}\n\nfunction useSignIns(\n uiWalletHandle: UiWalletHandle,\n): (...inputs: readonly (Input | undefined)[]) => Promise<readonly Output[]> {\n let signMessageFeature: SolanaSignInFeature[typeof SolanaSignIn];\n if ('address' in uiWalletHandle && typeof uiWalletHandle.address === 'string') {\n getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWalletHandle as UiWalletAccount);\n signMessageFeature = getWalletAccountFeature(\n uiWalletHandle as UiWalletAccount,\n SolanaSignIn,\n ) as SolanaSignInFeature[typeof SolanaSignIn];\n } else {\n signMessageFeature = getWalletFeature(uiWalletHandle, SolanaSignIn) as SolanaSignInFeature[typeof SolanaSignIn];\n }\n const wallet = getWalletForHandle_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWalletHandle);\n return useCallback(\n async (...inputs) => {\n const inputsWithAddressAndChainId = inputs.map(input => ({\n ...input,\n // Prioritize the `UiWalletAccount` address if it exists.\n ...('address' in uiWalletHandle ? { address: uiWalletHandle.address as Address } : null),\n }));\n const results = await signMessageFeature.signIn(...inputsWithAddressAndChainId);\n const resultsWithoutSignatureType = results.map(\n ({\n account,\n signatureType: _, // Solana signatures are always of type `ed25519` so drop this property.\n ...rest\n }) => ({\n ...rest,\n account: getOrCreateUiWalletAccountForStandardWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(\n wallet,\n account,\n ),\n }),\n );\n return resultsWithoutSignatureType;\n },\n [signMessageFeature, uiWalletHandle, wallet],\n );\n}\n","import {\n SolanaSignMessage,\n SolanaSignMessageFeature,\n SolanaSignMessageInput,\n SolanaSignMessageOutput,\n} from '@solana/wallet-standard-features';\nimport { getWalletAccountFeature, UiWalletAccount } from '@wallet-standard/ui';\nimport { getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } from '@wallet-standard/ui-registry';\nimport { useCallback } from 'react';\n\ntype Input = Omit<SolanaSignMessageInput, 'account'>;\ntype Output = Omit<SolanaSignMessageOutput, 'signatureType'>;\n\n/**\n * Use this to get a function capable of signing a message with the private key of a\n * {@link UiWalletAccount}\n *\n * @example\n * ```tsx\n * import { useSignMessage } from '@solana/react';\n *\n * function SignMessageButton({ account, messageBytes }) {\n * const signMessage = useSignMessage(account);\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const { signature } = await signMessage({\n * message: messageBytes,\n * });\n * window.alert(`Signature bytes: ${signature.toString()}`);\n * } catch (e) {\n * console.error('Failed to sign message', e);\n * }\n * }}\n * >\n * Sign Message\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignMessage<TWalletAccount extends UiWalletAccount>(\n ...config: Parameters<typeof useSignMessages<TWalletAccount>>\n): (input: Input) => Promise<Output> {\n const signMessages = useSignMessages(...config);\n return useCallback(\n async input => {\n const [result] = await signMessages(input);\n return result;\n },\n [signMessages],\n );\n}\n\nfunction useSignMessages<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]> {\n const signMessageFeature = getWalletAccountFeature(\n uiWalletAccount,\n SolanaSignMessage,\n ) as SolanaSignMessageFeature[typeof SolanaSignMessage];\n const account = getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWalletAccount);\n return useCallback(\n async (...inputs) => {\n const inputsWithAccount = inputs.map(input => ({ ...input, account }));\n const results = await signMessageFeature.signMessage(...inputsWithAccount);\n const resultsWithoutSignatureType = results.map(\n ({\n signatureType: _, // Solana signatures are always of type `ed25519` so drop this property.\n ...rest\n }) => rest,\n );\n return resultsWithoutSignatureType;\n },\n [signMessageFeature, account],\n );\n}\n","import {\n SolanaSignTransaction,\n SolanaSignTransactionFeature,\n SolanaSignTransactionInput,\n SolanaSignTransactionOutput,\n} from '@solana/wallet-standard-features';\nimport {\n WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED,\n WalletStandardError,\n} from '@wallet-standard/errors';\nimport { getWalletAccountFeature, UiWalletAccount } from '@wallet-standard/ui';\nimport { getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } from '@wallet-standard/ui-registry';\nimport { useCallback } from 'react';\n\nimport { OnlySolanaChains } from './chain';\n\ntype Input = Readonly<\n Omit<SolanaSignTransactionInput, 'account' | 'chain' | 'options'> & {\n options?: Readonly<{\n minContextSlot?: bigint;\n }>;\n }\n>;\ntype Output = SolanaSignTransactionOutput;\n\n/**\n * Use this to get a function capable of signing a serialized transaction with the private key of a\n * {@link UiWalletAccount}\n *\n * @param chain The identifier of the chain the transaction is destined for. Wallets may use this to\n * simulate the transaction for the user.\n *\n * @example\n * ```tsx\n * import { useSignTransaction } from '@solana/react';\n *\n * function SignTransactionButton({ account, transactionBytes }) {\n * const signTransaction = useSignTransaction(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const { signedTransaction } = await signTransaction({\n * transaction: transactionBytes,\n * });\n * window.alert(`Signed transaction bytes: ${signedTransaction.toString()}`);\n * } catch (e) {\n * console.error('Failed to sign transaction', e);\n * }\n * }}\n * >\n * Sign Transaction\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): (input: Input) => Promise<Output>;\nexport function useSignTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (input: Input) => Promise<Output>;\nexport function useSignTransaction<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (input: Input) => Promise<Output> {\n const signTransactions = useSignTransactions(uiWalletAccount, chain);\n return useCallback(\n async input => {\n const [result] = await signTransactions(input);\n return result;\n },\n [signTransactions],\n );\n}\n\n/**\n * Use this to get a function capable of signing one or more serialized transactions with the private\n * key of a {@link UiWalletAccount}. This supports batching multiple transactions in a single wallet\n * prompt when the wallet implementation allows it.\n *\n * @example\n * ```tsx\n * import { useSignTransactions } from '@solana/react';\n *\n * function SignTransactionsButton({ account, transactionBytes1, transactionBytes2 }) {\n * const signTransactions = useSignTransactions(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const [first, second] = await signTransactions(\n * { transaction: transactionBytes1 },\n * { transaction: transactionBytes2 },\n * );\n * window.alert(\n * `First transaction bytes: ${first.signedTransaction.toString()}, second transaction bytes: ${second.signedTransaction.toString()}`,\n * );\n * } catch (e) {\n * console.error('Failed to sign transactions', e);\n * }\n * }}\n * >\n * Sign Transactions\n * </button>\n * );\n * }\n * ```\n */\nexport function useSignTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]>;\nexport function useSignTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]>;\nexport function useSignTransactions<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): (...inputs: readonly Input[]) => Promise<readonly Output[]> {\n if (!uiWalletAccount.chains.includes(chain)) {\n throw new WalletStandardError(WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED, {\n address: uiWalletAccount.address,\n chain,\n featureName: SolanaSignTransaction,\n supportedChains: [...uiWalletAccount.chains],\n supportedFeatures: [...uiWalletAccount.features],\n });\n }\n const signTransactionFeature = getWalletAccountFeature(\n uiWalletAccount,\n SolanaSignTransaction,\n ) as SolanaSignTransactionFeature[typeof SolanaSignTransaction];\n const account = getWalletAccountForUiWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWalletAccount);\n return useCallback(\n async (...inputs) => {\n if (inputs.length === 0) {\n return [];\n }\n const inputsWithAccountAndChain = inputs.map(({ options, ...rest }) => {\n const minContextSlot = options?.minContextSlot;\n return {\n ...rest,\n account,\n chain,\n ...(minContextSlot != null\n ? {\n options: {\n minContextSlot: Number(minContextSlot),\n },\n }\n : null),\n };\n });\n const results = await signTransactionFeature.signTransaction(...inputsWithAccountAndChain);\n return results;\n },\n [signTransactionFeature, account, chain],\n );\n}\n","import type { ReactiveStreamStore, SolanaRpcResponse } from '@solana/kit';\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport type { TrackedDataResult } from './useTrackedData';\n\n/**\n * Subscribes to a {@link ReactiveStreamStore} whose value is always shaped as\n * `SolanaRpcResponse<TItem>` (which is what `createReactiveStoreWithInitialValueAndSlotTracking`\n * produces) and maps its `idle | loading | loaded | error` lifecycle onto the\n * {@link TrackedDataResult} shape consumed by `useTrackedData`. The envelope passes through\n * unchanged — callers read `data.value` and `data.context.slot` directly.\n *\n * `idle` is ambiguous on its own: it covers both \"no spec — store is disabled\" and \"real spec,\n * connect effect hasn't fired yet on the current render.\" The `disabled` flag disambiguates:\n * disabled → `status: 'disabled'`, enabled → `status: 'loading'` (the connect is about to fire\n * on commit; consumers see a single `loading` paint rather than briefly flashing `disabled`).\n *\n * Stale-while-revalidate flows naturally through `state.data` / `state.error`, which the store\n * preserves across `loading` transitions, so the bridge doesn't need to mirror them.\n *\n * @param store - The store to subscribe to.\n * @param refresh - A stable callback that re-runs the initial RPC and the subscription.\n * Forwarded to the result so call sites have a single, hook-owned recovery affordance.\n * @param disabled - When `true`, the result reports `status: 'disabled'`. Used by\n * `useTrackedData` to signal the null-spec case.\n *\n * @internal\n */\nexport function useTrackedDataResult<TItem>(\n store: ReactiveStreamStore<SolanaRpcResponse<TItem>>,\n refresh: (options?: { abortSignal?: AbortSignal | undefined }) => void,\n disabled: boolean,\n): TrackedDataResult<TItem> {\n const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);\n return useMemo(() => {\n const status: TrackedDataResult<TItem>['status'] =\n state.status === 'idle' ? (disabled ? 'disabled' : 'loading') : state.status;\n return { data: state.data, error: state.error, refresh, status };\n }, [state, refresh, disabled]);\n}\n","import {\n createReactiveStoreWithInitialValueAndSlotTracking,\n type CreateReactiveStoreWithInitialValueAndSlotTrackingConfig,\n type ReactiveStreamStore,\n type SolanaRpcResponse,\n} from '@solana/kit';\nimport { useMemo } from 'react';\n\nimport { disabledStreamStore } from './staticStores';\nimport { useReactiveStoreLifecycle } from './useReactiveStoreLifecycle';\nimport { useTrackedDataResult } from './useTrackedDataResult';\n\n// Module-level so it's a stable reference — keeps the `refresh` callback from\n// `useReactiveStoreLifecycle` referentially stable across renders.\nfunction fireConnect<T>(store: ReactiveStreamStore<T>, signal: AbortSignal | undefined): void {\n if (signal) store.withSignal(signal).connect();\n else store.connect();\n}\n\n/**\n * React-local alias for the Kit primitive's config. Lets the call site name the input shape as\n * `TrackedDataSpec<TInitialValue, TStreamValue, TItem>` instead of the verbose\n * `CreateReactiveStoreWithInitialValueAndSlotTrackingConfig<...>`.\n *\n * @typeParam TInitialValue - The value inside the initial RPC `SolanaRpcResponse` envelope.\n * @typeParam TStreamValue - The value inside subscription `SolanaRpcResponse` notifications.\n * @typeParam TItem - The unified item type produced by the two mappers and stored in the result.\n */\nexport type TrackedDataSpec<TInitialValue, TStreamValue, TItem> =\n CreateReactiveStoreWithInitialValueAndSlotTrackingConfig<TInitialValue, TStreamValue, TItem>;\n\n/**\n * Reactive state for tracked data managed by {@link useTrackedData}.\n *\n * Lifecycle: starts at `loading` (or `disabled` when the spec is `null`) and fires both the\n * initial RPC request and the subscription on mount; transitions to `loaded` on the first\n * value (from either source — the underlying store slot-dedupes so out-of-order arrivals never\n * regress) or `error` on failure. `refresh()` re-runs the whole pair — while a refresh is in\n * flight, `status` returns to `loading` and the stale `data` and/or `error` from the prior\n * outcome remain populated (stale-while-revalidate).\n *\n * @typeParam T - The unified item type held by the store, produced by the two mappers in the\n * spec.\n */\nexport type TrackedDataResult<T> = {\n /**\n * The latest value, slot-deduped across the initial RPC and the subscription, exactly as the\n * underlying kit primitive emits it: a `SolanaRpcResponse<T>` envelope (`{ context: { slot },\n * value }`). The primitive guarantees the envelope shape, so callers can read `data.value`\n * and `data.context.slot` directly without a runtime check. `undefined` on the first load\n * and while disabled. On `loading` after a prior outcome, on `error`, and on a subsequent\n * refresh, holds the last received envelope so UIs can show stale data rather than flashing\n * to blank.\n */\n data: SolanaRpcResponse<T> | undefined;\n /**\n * Error from either source, or `undefined`. Only the first error per connection window is\n * captured (the underlying store drops subsequent errors until the next `refresh()` /\n * connect). On `loading` after a prior `error`, holds the stale error so UIs can keep\n * showing the failure context while the refresh is in flight. A subsequent `loaded` clears\n * it.\n */\n error: unknown;\n /**\n * Re-run both the initial RPC request and the subscription. By default each call mints a\n * fresh signal from `getAbortSignal` (if configured) and threads it through the underlying\n * store's `withSignal(signal).connect()`. Pass `{ abortSignal }` to override the configured\n * factory for just this attempt. Pass `{ abortSignal: undefined }` to opt out of the\n * factory entirely for this attempt and run with no caller-provided signal.\n *\n * Stable reference. Safe to put in `onClick` handlers or effect deps — typically wired up\n * to a \"Refresh\" or \"Retry\" button. Calls `store.connect()` under the hood, so it always\n * (re)runs the pair regardless of current status; the bridge transitions back through\n * `loading` while preserving stale `data` and `error`.\n */\n refresh: (options?: { abortSignal?: AbortSignal | undefined }) => void;\n /**\n * Lifecycle status as a discriminated string:\n * - `loading`: an attempt is in progress. On the first attempt, `data` and `error` are\n * `undefined`. After a refresh, `data` and `error` hold the last known values from the\n * previous attempt (stale-while-revalidate).\n * - `loaded`: a value has arrived from either source and `error` is `undefined`.\n * - `error`: the attempt failed; `data` holds the last known value (if any).\n * - `disabled`: spec was `null` — no work was started.\n */\n status: 'disabled' | 'error' | 'loaded' | 'loading';\n};\n\n/** Options accepted by {@link useTrackedData}. */\nexport type UseTrackedDataOptions = {\n /**\n * Factory invoked on every attempt (initial run + every `refresh()`). The returned signal is\n * attached to that attempt via the underlying store's `withSignal(signal).connect()`, so\n * aborting it tears down both the in-flight RPC request and the subscription for that\n * attempt.\n *\n * The most common use is per-attempt timeouts:\n * `getAbortSignal: () => AbortSignal.timeout(30_000)` gives every attempt its own\n * 30-second clock that resets on `refresh()`.\n *\n * Held in a ref synced to the latest render's closure — there is no need to memoize an\n * inline factory.\n */\n getAbortSignal?: () => AbortSignal;\n};\n\n/**\n * Render reactive state for an RPC subscription seeded by a one-shot RPC fetch, slot-deduped.\n * The subscription (e.g. `accountNotifications`) is the primary source of live updates; the\n * initial fetch (e.g. `getBalance`) provides a value to surface as soon as it resolves —\n * typically before the first subscription notification arrives — so the `loading` paint is\n * shorter than subscription-only would give you. The underlying store slot-dedupes between the\n * two sources — out-of-order arrivals never regress the surfaced value.\n *\n * Pass a memoized {@link TrackedDataSpec} keyed on whatever inputs it depends on; stable identity\n * is how the hook knows when to tear down and re-run. Pass `null` to gate the work off — the\n * result reports `status: 'disabled'`.\n *\n * SSR-safe — on the server the connect effect doesn't run, so the store stays `idle` and the\n * hook reports `status: 'loading'`. The first client render hydrates from that same `loading`\n * paint, then commits the connect effect.\n *\n * @typeParam TInitialValue - The value inside the initial RPC `SolanaRpcResponse` envelope.\n * @typeParam TStreamValue - The value inside subscription `SolanaRpcResponse` notifications.\n * @typeParam TItem - The unified item type produced by the two mappers and stored in the result.\n *\n * @example\n * ```tsx\n * function AccountBalance({ address }: { address: Address }) {\n * const client = useClient<ClientWithRpc<GetBalanceApi> & ClientWithRpcSubscriptions<AccountNotificationsApi>>();\n * const spec = useMemo(() => ({\n * initialValueSource: client.rpc.getBalance(address),\n * initialValueMapper: (lamports: bigint) => lamports,\n * streamSource: client.rpcSubscriptions.accountNotifications(address),\n * streamValueMapper: ({ lamports }: { lamports: bigint }) => lamports,\n * }), [client, address]);\n * const { data, error, refresh } = useTrackedData(spec);\n * if (error) return <button onClick={refresh}>Retry</button>;\n * return <p>{data ? `${data.value} lamports at slot ${data.context.slot}` : 'Loading…'}</p>;\n * }\n * ```\n *\n * @see {@link TrackedDataResult}\n * @see {@link UseTrackedDataOptions}\n */\nexport function useTrackedData<TInitialValue, TStreamValue, TItem>(\n spec: TrackedDataSpec<TInitialValue, TStreamValue, TItem> | null,\n options?: UseTrackedDataOptions,\n): TrackedDataResult<TItem> {\n // One store per `spec`. Both creation paths return an `idle` store; the initial connect\n // lives in the lifecycle effect below so the memo body stays pure (StrictMode's dev\n // double-render, and any future render-discard, won't fire a network request from a\n // discarded render).\n const store = useMemo(() => {\n if (spec == null) return disabledStreamStore<SolanaRpcResponse<TItem>>();\n return createReactiveStoreWithInitialValueAndSlotTracking(spec);\n }, [spec]);\n\n // Connect on commit, reset on store change / unmount, and expose the stable `refresh`\n // callback. `store.reset()` aborts the active attempt via the store's internal controller, so\n // under StrictMode's mount → cleanup → mount sequence the first connect is properly aborted\n // before the second one fires. `disabledStreamStore` returns a store whose `connect`/`reset`\n // are no-ops, so the null-spec case needs no explicit gate.\n const refresh = useReactiveStoreLifecycle(store, fireConnect, options?.getAbortSignal);\n\n return useTrackedDataResult(store, refresh, spec == null);\n}\n","import {\n Address,\n address,\n bytesEqual,\n MessageModifyingSigner,\n SignableMessage,\n SignatureBytes,\n SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,\n SolanaError,\n} from '@solana/kit';\nimport { getAbortablePromise } from '@solana/promises';\nimport type { UiWalletAccount } from '@wallet-standard/ui';\nimport { useMemo } from 'react';\n\nimport { useSignMessage } from './useSignMessage';\n\n/**\n * Use this to get a {@link MessageSigner} capable of signing messages with the private key of a\n * {@link UiWalletAccount}\n *\n * @returns A {@link MessageModifyingSigner}. This is a conservative assumption based on the fact\n * that your application can not control whether or not the wallet will modify the message before\n * signing it. Otherwise this method could more specifically return a {@link MessageSigner} or a\n * {@link MessagePartialSigner}.\n *\n * @example\n * ```tsx\n * import { useWalletAccountMessageSigner } from '@solana/react';\n * import { createSignableMessage } from '@solana/kit';\n *\n * function SignMessageButton({ account, text }) {\n * const messageSigner = useWalletAccountMessageSigner(account);\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const signableMessage = createSignableMessage(text);\n * const [signedMessage] = await messageSigner.modifyAndSignMessages([signableMessage]);\n * const messageWasModified = signableMessage.content !== signedMessage.content;\n * const signatureBytes = signedMessage.signatures[messageSigner.address];\n * window.alert(\n * `Signature bytes: ${signatureBytes.toString()}${\n * messageWasModified ? ' (message was modified)' : ''\n * }`,\n * );\n * } catch (e) {\n * console.error('Failed to sign message', e);\n * }\n * }}\n * >\n * Sign Message: {text}\n * </button>\n * );\n * }\n * ```\n */\nexport function useWalletAccountMessageSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n): MessageModifyingSigner<TWalletAccount['address']> {\n const signMessage = useSignMessage(uiWalletAccount);\n return useMemo(\n () => ({\n address: address(uiWalletAccount.address),\n async modifyAndSignMessages(messages, config) {\n config?.abortSignal?.throwIfAborted();\n if (messages.length > 1) {\n throw new SolanaError(SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED);\n }\n if (messages.length === 0) {\n return messages;\n }\n const { content: originalMessage, signatures: originalSignatureMap } = messages[0];\n const input = {\n message: originalMessage,\n };\n const { signedMessage, signature } = await getAbortablePromise(signMessage(input), config?.abortSignal);\n const messageWasModified =\n originalMessage.length !== signedMessage.length ||\n originalMessage.some((originalByte, ii) => originalByte !== signedMessage[ii]);\n const originalSignature = originalSignatureMap[uiWalletAccount.address as Address<string>] as\n | SignatureBytes\n | undefined;\n const signatureIsNew = originalSignature === undefined || !bytesEqual(originalSignature, signature);\n if (!signatureIsNew && !messageWasModified) {\n // We already had this exact signature, and the message wasn't modified.\n // Don't replace the existing message object.\n return messages;\n }\n const nextSignatureMap = messageWasModified\n ? { [uiWalletAccount.address]: signature }\n : { ...originalSignatureMap, [uiWalletAccount.address]: signature };\n const outputMessages = Object.freeze([\n Object.freeze({\n content: signedMessage,\n signatures: Object.freeze(nextSignatureMap),\n }) as SignableMessage,\n ]);\n return outputMessages;\n },\n }),\n [uiWalletAccount, signMessage],\n );\n}\n","import {\n address,\n assertIsTransactionWithinSizeLimit,\n bytesEqual,\n getCompiledTransactionMessageDecoder,\n getTransactionCodec,\n getTransactionLifetimeConstraintFromCompiledTransactionMessage,\n SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,\n SolanaError,\n Transaction,\n TransactionModifyingSigner,\n TransactionWithinSizeLimit,\n TransactionWithLifetime,\n} from '@solana/kit';\nimport { getAbortablePromise } from '@solana/promises';\nimport { UiWalletAccount } from '@wallet-standard/ui';\nimport { useMemo, useRef } from 'react';\n\nimport { OnlySolanaChains } from './chain';\nimport { useSignTransaction } from './useSignTransaction';\n\n/**\n * Use this to get a {@link TransactionSigner} capable of signing serialized transactions with the\n * private key of a {@link UiWalletAccount}\n *\n * @returns A {@link TransactionModifyingSigner}. This is a conservative assumption based on the\n * fact that your application can not control whether or not the wallet will modify the transaction\n * before signing it (eg. to add guard instructions, or a priority fee budget). Otherwise this\n * method could more specifically return a {@link TransactionSigner} or a\n * {@link TransactionPartialSigner}.\n *\n * @example\n * ```tsx\n * import { useWalletAccountTransactionSigner } from '@solana/react';\n *\n * function SignTransactionButton({ account, transaction }) {\n * const transactionSigner = useWalletAccountTransactionSigner(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const [{ signatures }] = await transactionSigner.modifyAndSignTransactions([transaction]);\n * const signatureBytes = signatures[transactionSigner.address];\n * window.alert(`Signature bytes: ${signatureBytes.toString()}`);\n * } catch (e) {\n * console.error('Failed to sign transaction', e);\n * }\n * }}\n * >\n * Sign Transaction\n * </button>\n * );\n * }\n * ```\n */\nexport function useWalletAccountTransactionSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): TransactionModifyingSigner<TWalletAccount['address']>;\nexport function useWalletAccountTransactionSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): TransactionModifyingSigner<TWalletAccount['address']>;\nexport function useWalletAccountTransactionSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): TransactionModifyingSigner<TWalletAccount['address']> {\n const encoderRef = useRef<ReturnType<typeof getTransactionCodec> | null>(null);\n const signTransaction = useSignTransaction(uiWalletAccount, chain);\n return useMemo(\n () => ({\n address: address(uiWalletAccount.address),\n async modifyAndSignTransactions(transactions, config = {}) {\n const { abortSignal, ...options } = config;\n abortSignal?.throwIfAborted();\n const transactionCodec = (encoderRef.current ||= getTransactionCodec());\n if (transactions.length > 1) {\n throw new SolanaError(SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED);\n }\n if (transactions.length === 0) {\n return transactions as readonly (Transaction &\n TransactionWithinSizeLimit &\n TransactionWithLifetime)[];\n }\n const [transaction] = transactions;\n const wireTransactionBytes = transactionCodec.encode(transaction);\n const inputWithOptions = {\n ...options,\n transaction: wireTransactionBytes as Uint8Array,\n };\n const { signedTransaction } = await getAbortablePromise(signTransaction(inputWithOptions), abortSignal);\n const decodedSignedTransaction = transactionCodec.decode(\n signedTransaction,\n ) as (typeof transactions)[number];\n\n assertIsTransactionWithinSizeLimit(decodedSignedTransaction);\n\n const existingLifetime =\n 'lifetimeConstraint' in transaction\n ? (transaction as TransactionWithLifetime).lifetimeConstraint\n : undefined;\n\n if (existingLifetime) {\n if (bytesEqual(decodedSignedTransaction.messageBytes, transaction.messageBytes)) {\n // If the transaction has identical bytes, the lifetime won't have changed\n return Object.freeze([\n {\n ...decodedSignedTransaction,\n lifetimeConstraint: existingLifetime,\n },\n ]);\n }\n\n // If the transaction has changed, check the lifetime constraint field\n const compiledTransactionMessage = getCompiledTransactionMessageDecoder().decode(\n decodedSignedTransaction.messageBytes,\n );\n const currentToken =\n 'blockhash' in existingLifetime ? existingLifetime.blockhash : existingLifetime.nonce;\n\n if (compiledTransactionMessage.lifetimeToken === currentToken) {\n return Object.freeze([\n {\n ...decodedSignedTransaction,\n lifetimeConstraint: existingLifetime,\n },\n ]);\n }\n }\n\n // If we get here then there is no existing lifetime, or the lifetime has changed. We need to attach a new lifetime\n const compiledTransactionMessage = getCompiledTransactionMessageDecoder().decode(\n decodedSignedTransaction.messageBytes,\n );\n const lifetimeConstraint =\n await getTransactionLifetimeConstraintFromCompiledTransactionMessage(compiledTransactionMessage);\n return Object.freeze([\n {\n ...decodedSignedTransaction,\n lifetimeConstraint,\n },\n ]);\n },\n }),\n [uiWalletAccount.address, signTransaction],\n );\n}\n","import {\n address,\n getTransactionEncoder,\n SignatureBytes,\n SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,\n SolanaError,\n TransactionSendingSigner,\n} from '@solana/kit';\nimport { getAbortablePromise } from '@solana/promises';\nimport { UiWalletAccount } from '@wallet-standard/ui';\nimport { useMemo, useRef } from 'react';\n\nimport { OnlySolanaChains } from './chain';\nimport { useSignAndSendTransaction } from './useSignAndSendTransaction';\n\n/**\n * Use this to get a {@link TransactionSendingSigner} capable of signing a serialized transaction\n * with the private key of a {@link UiWalletAccount} and sending it to the network for processing.\n *\n * @param chain The identifier of the chain the transaction is destined for. Wallets may use this to\n * simulate the transaction for the user.\n *\n * @example\n * ```tsx\n * import { useWalletAccountTransactionSendingSigner } from '@solana/react';\n * import {\n * appendTransactionMessageInstruction,\n * createSolanaRpc,\n * getBase58Decoder,\n * pipe,\n * setTransactionMessageFeePayerSigner,\n * setTransactionMessageLifetimeUsingBlockhash,\n * signAndSendTransactionMessageWithSigners,\n * } from '@solana/kit';\n *\n * function RecordMemoButton({ account, rpc, text }) {\n * const signer = useWalletAccountTransactionSendingSigner(account, 'solana:devnet');\n * return (\n * <button\n * onClick={async () => {\n * try {\n * const { value: latestBlockhash } = await createSolanaRpc('https://api.devnet.solana.com')\n * .getLatestBlockhash()\n * .send();\n * const message = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * m => setTransactionMessageFeePayerSigner(signer, m),\n * m => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, m),\n * m => appendTransactionMessageInstruction(getAddMemoInstruction({ memo: text }), m),\n * );\n * const signatureBytes = await signAndSendTransactionMessageWithSigners(message);\n * const base58Signature = getBase58Decoder().decode(signature);\n * window.alert(`View transaction: https://explorer.solana.com/tx/${base58Signature}?cluster=devnet`);\n * } catch (e) {\n * console.error('Failed to record memo', e);\n * }\n * }}\n * >\n * Record Memo\n * </button>\n * );\n * }\n * ```\n */\nexport function useWalletAccountTransactionSendingSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: OnlySolanaChains<TWalletAccount['chains']>,\n): TransactionSendingSigner<TWalletAccount['address']>;\nexport function useWalletAccountTransactionSendingSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): TransactionSendingSigner<TWalletAccount['address']>;\nexport function useWalletAccountTransactionSendingSigner<TWalletAccount extends UiWalletAccount>(\n uiWalletAccount: TWalletAccount,\n chain: `solana:${string}`,\n): TransactionSendingSigner<TWalletAccount['address']> {\n const encoderRef = useRef<ReturnType<typeof getTransactionEncoder> | null>(null);\n const signAndSendTransaction = useSignAndSendTransaction(uiWalletAccount, chain);\n return useMemo(\n () => ({\n address: address(uiWalletAccount.address),\n async signAndSendTransactions(transactions, config = {}) {\n const { abortSignal, ...options } = config;\n abortSignal?.throwIfAborted();\n const transactionEncoder = (encoderRef.current ||= getTransactionEncoder());\n if (transactions.length > 1) {\n throw new SolanaError(SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED);\n }\n if (transactions.length === 0) {\n return [];\n }\n const [transaction] = transactions;\n const wireTransactionBytes = transactionEncoder.encode(transaction);\n const inputWithOptions = {\n ...options,\n transaction: wireTransactionBytes as Uint8Array,\n };\n const { signature } = await getAbortablePromise(signAndSendTransaction(inputWithOptions), abortSignal);\n return Object.freeze([signature as SignatureBytes]);\n },\n }),\n [signAndSendTransaction, uiWalletAccount.address],\n );\n}\n","import { UiWallet, UiWalletAccount } from '@wallet-standard/react';\nimport React, { createContext } from 'react';\n\nexport type SelectedWalletAccountState = UiWalletAccount | undefined;\n\nexport type SelectedWalletAccountContextValue = readonly [\n selectedWalletAccount: SelectedWalletAccountState,\n setSelectedWalletAccount: React.Dispatch<React.SetStateAction<SelectedWalletAccountState>>,\n filteredWallets: UiWallet[],\n];\n\nexport const SelectedWalletAccountContext = /*#__PURE__*/ createContext<SelectedWalletAccountContextValue>([\n undefined,\n () => {},\n [],\n]);\n\nexport function useSelectedWalletAccount() {\n const ctx = React.useContext(SelectedWalletAccountContext);\n return ctx;\n}\n","import type { UiWallet, UiWalletAccount } from '@wallet-standard/react';\nimport {\n getUiWalletAccountStorageKey,\n uiWalletAccountBelongsToUiWallet,\n uiWalletAccountsAreSame,\n useWallets,\n} from '@wallet-standard/react';\nimport React from 'react';\n\nimport { SelectedWalletAccountContext, SelectedWalletAccountState } from './selectedWalletAccountContext';\n\nexport type SelectedWalletAccountContextProviderProps = {\n filterWallets: (wallet: UiWallet) => boolean;\n stateSync: {\n deleteSelectedWallet: () => void;\n getSelectedWallet: () => string | null;\n storeSelectedWallet: (accountKey: string) => void;\n };\n} & { children: React.ReactNode };\n\n/**\n * Returns the saved wallet account when its corresponding wallet, and account is available.\n * @param wallets All wallets available to select in the app\n * @param savedWalletKey The saved wallet account storage key\n * @returns The saved wallet account, or undefined if not found\n */\nfunction findSavedWalletAccount(\n wallets: readonly UiWallet[],\n savedWalletKey: string | null,\n): UiWalletAccount | undefined {\n if (!savedWalletKey) {\n return;\n }\n const [savedWalletName, savedWalletAddress] = savedWalletKey.split(':');\n if (!savedWalletName || !savedWalletAddress) {\n return;\n }\n for (const wallet of wallets) {\n if (wallet.name !== savedWalletName) continue;\n for (const account of wallet.accounts) {\n if (account.address === savedWalletAddress) {\n return account;\n }\n }\n }\n}\n\n/**\n * Saves the selected wallet account's storage key to a persistant storage. In future\n * sessions it will try to return that same wallet account, or at least one from the same brand of\n * wallet if the wallet from which it came is still in the Wallet Standard registry.\n * @param children The child components that will have access to the selected wallet account context\n * @param filterWallets A function to filter which wallets are available in the app\n * @param stateSync An object with methods to synchronize the selected wallet account state with persistent storage\n * @returns A React component that provides the selected wallet account context to its children\n */\nexport function SelectedWalletAccountContextProvider({\n children,\n filterWallets,\n stateSync,\n}: SelectedWalletAccountContextProviderProps) {\n const wallets = useWallets();\n const filteredWallets = React.useMemo(() => wallets.filter(filterWallets), [wallets, filterWallets]);\n const wasSetterInvokedRef = React.useRef(false);\n\n const [selectedWalletAccount, setSelectedWalletAccountInternal] = React.useState<SelectedWalletAccountState>(() => {\n const savedWalletKey = stateSync.getSelectedWallet();\n const savedWalletAccount = findSavedWalletAccount(filteredWallets, savedWalletKey);\n return savedWalletAccount;\n });\n\n // Public setter: mark the per-instance ref synchronously to avoid races, then schedule state update.\n // useCallback stabilises the setter for consumers.\n const setSelectedWalletAccount: React.Dispatch<React.SetStateAction<SelectedWalletAccountState>> =\n React.useCallback(\n setStateAction => {\n wasSetterInvokedRef.current = true;\n setSelectedWalletAccountInternal(prevSelectedWalletAccount => {\n const nextWalletAccount =\n typeof setStateAction === 'function'\n ? setStateAction(prevSelectedWalletAccount)\n : setStateAction;\n return nextWalletAccount;\n });\n },\n [setSelectedWalletAccountInternal],\n );\n\n //Sync to persistant storage when selectedWalletAccount changes\n React.useEffect(() => {\n if (!wasSetterInvokedRef.current) return;\n\n const accountKey = selectedWalletAccount ? getUiWalletAccountStorageKey(selectedWalletAccount) : undefined;\n\n if (accountKey) {\n stateSync.storeSelectedWallet(accountKey);\n } else {\n stateSync.deleteSelectedWallet();\n }\n }, [selectedWalletAccount, stateSync]);\n\n //Auto-restore saved wallet account if it appears later,\n //and if the user hasn't made an explicit choice yet.\n React.useEffect(() => {\n if (wasSetterInvokedRef.current) return;\n const savedWalletKey = stateSync.getSelectedWallet();\n const savedAccount = findSavedWalletAccount(filteredWallets, savedWalletKey);\n if (savedAccount && selectedWalletAccount && uiWalletAccountsAreSame(savedAccount, selectedWalletAccount)) {\n return;\n }\n if (savedAccount) {\n setSelectedWalletAccountInternal(savedAccount);\n }\n }, [filteredWallets, stateSync, selectedWalletAccount]);\n\n const walletAccount = React.useMemo(() => {\n if (!selectedWalletAccount) return;\n for (const wallet of filteredWallets) {\n for (const account of wallet.accounts) {\n if (uiWalletAccountsAreSame(account, selectedWalletAccount)) {\n return account;\n }\n }\n if (uiWalletAccountBelongsToUiWallet(selectedWalletAccount, wallet) && wallet.accounts[0]) {\n return wallet.accounts[0];\n }\n }\n }, [selectedWalletAccount, filteredWallets]);\n\n React.useEffect(() => {\n // If there is a selected wallet account but the wallet to which it belongs has since\n // disconnected, clear the selected wallet. This is an automatic cleanup and should not\n // mark the 'wasSetterInvoked' ref (so we use the internal setter).\n // Cleanup shouldn't be run if user has made a selection or selectedWalletAccount/walletAccount are loading or undefined\n if (!selectedWalletAccount) return; //still loading ...\n if (wasSetterInvokedRef.current) return; //user made a selection\n if (!walletAccount) {\n setSelectedWalletAccountInternal(undefined);\n }\n }, [selectedWalletAccount, walletAccount]);\n\n return (\n <SelectedWalletAccountContext.Provider value={[walletAccount, setSelectedWalletAccount, filteredWallets]}>\n {children}\n </SelectedWalletAccountContext.Provider>\n );\n}\n"]}
|