@solana/react 7.0.0 → 7.1.0-canary-20260812151931
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
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ The Kit client is a plugin-extensible value built outside the React tree (`creat
|
|
|
19
19
|
|
|
20
20
|
### `ClientProvider`
|
|
21
21
|
|
|
22
|
-
Publishes a caller-owned Kit client to its subtree. Required for `useClient
|
|
22
|
+
Publishes a caller-owned Kit client to its subtree. Required for `useClient` and any plugin-specific hook that reads a client capability. Generic primitives like `useAction` work against arbitrary async functions and don't need a provider.
|
|
23
23
|
|
|
24
24
|
```tsx
|
|
25
25
|
import { createClient } from '@solana/kit';
|
|
@@ -59,38 +59,58 @@ function Root() {
|
|
|
59
59
|
|
|
60
60
|
Reads the Kit client published by the nearest `ClientProvider`. Throws a `SolanaError` with code `SOLANA_ERROR__REACT__MISSING_PROVIDER` if no provider is mounted.
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
Pass your client's type through the generic to get the capabilities you installed typed at the call site. The ergonomic way is to **reuse the type of the client you already built** — export it from wherever you compose the client and hand that to `useClient`, so the hook's type stays in sync with your real plugin composition automatically:
|
|
63
63
|
|
|
64
64
|
```tsx
|
|
65
|
-
|
|
65
|
+
// client.ts — where you build the client
|
|
66
|
+
import { createClient } from '@solana/kit';
|
|
67
|
+
import { solanaDevnetRpc } from '@solana/kit-plugin-rpc';
|
|
68
|
+
import { generatedSigner } from '@solana/kit-plugin-signer';
|
|
69
|
+
|
|
70
|
+
export const client = createClient().use(generatedSigner()).use(solanaDevnetRpc());
|
|
71
|
+
|
|
72
|
+
// `Awaited<…>` resolves the promise when any plugin is async (e.g. `generatedSigner()`);
|
|
73
|
+
// for a fully-synchronous client it is simply `typeof client`.
|
|
74
|
+
export type AppClient = Awaited<typeof client>;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
// any component
|
|
66
79
|
import { useClient } from '@solana/react';
|
|
80
|
+
import type { AppClient } from './client';
|
|
67
81
|
|
|
68
82
|
function ManualSend() {
|
|
69
|
-
const client = useClient<
|
|
83
|
+
const client = useClient<AppClient>(); // rpc, signers, … all typed
|
|
70
84
|
return <button onClick={() => client.rpc.getEpochInfo().send()}>Fetch</button>;
|
|
71
85
|
}
|
|
72
86
|
```
|
|
73
87
|
|
|
88
|
+
`useClient` is a pure type assertion with no runtime check.
|
|
89
|
+
|
|
74
90
|
### `useClientCapability<TClient>(config)`
|
|
75
91
|
|
|
76
|
-
|
|
92
|
+
A runtime escape hatch for the uncommon case where the client isn't precisely typed — a loosely-typed `Client` read from context, say — and you want a clear failure at mount rather than a downstream `undefined`. It reads the client, asserts at mount that the requested capability is installed, and narrows the return type via the generic, throwing a `SolanaError` with code `SOLANA_ERROR__REACT__MISSING_CAPABILITY` (with your `hookName` and `providerHint`) when the capability is absent.
|
|
77
93
|
|
|
78
|
-
|
|
94
|
+
When you type your client with `useClient<AppClient>()`, the compiler already guarantees the capability is present, so you rarely need this.
|
|
79
95
|
|
|
80
96
|
```tsx
|
|
81
97
|
import { ClientWithRpc, GetEpochInfoApi } from '@solana/kit';
|
|
82
98
|
import { useClientCapability } from '@solana/react';
|
|
83
99
|
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
// The provider holds a loosely-typed `Client` (built elsewhere, or by a
|
|
101
|
+
// third party), so `useClient` can't prove `rpc` is installed. Assert it here
|
|
102
|
+
// and get a clear mount-time error — with your hint — if it isn't.
|
|
103
|
+
function EpochBadge() {
|
|
104
|
+
const client = useClientCapability<ClientWithRpc<GetEpochInfoApi>>({
|
|
86
105
|
capability: 'rpc',
|
|
87
|
-
hookName: '
|
|
106
|
+
hookName: 'EpochBadge',
|
|
88
107
|
providerHint: 'Install `solanaRpc()` on the client.',
|
|
89
108
|
});
|
|
109
|
+
return <button onClick={() => client.rpc.getEpochInfo().send()}>Refresh epoch</button>;
|
|
90
110
|
}
|
|
91
111
|
```
|
|
92
112
|
|
|
93
|
-
Pass an array of capability names when
|
|
113
|
+
Pass an array of capability names when you need more than one (e.g. `['rpc', 'rpcSubscriptions']`) — the same `providerHint` is surfaced for whichever is missing.
|
|
94
114
|
|
|
95
115
|
### `useAction(fn)`
|
|
96
116
|
|
|
@@ -129,6 +149,73 @@ try {
|
|
|
129
149
|
}
|
|
130
150
|
```
|
|
131
151
|
|
|
152
|
+
### Transaction planning & sending
|
|
153
|
+
|
|
154
|
+
Wrap a client's transaction-planning and -sending capabilities as tracked actions. Each hook takes the client and returns the same `ActionResult` as [`useAction`](#useactionfn) — `{ data, dispatch, dispatchAsync, error, isRunning, status, reset, ... }` — with `dispatch(input)` supplying the input and the hook injecting the `AbortSignal` for you.
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
import { usePlanTransaction, useSendTransaction } from '@solana/react';
|
|
158
|
+
|
|
159
|
+
function SendButton({ client, instructions }) {
|
|
160
|
+
const { dispatch, isRunning } = useSendTransaction(client);
|
|
161
|
+
return (
|
|
162
|
+
<button disabled={isRunning} onClick={() => dispatch(instructions)}>
|
|
163
|
+
{isRunning ? 'Sending…' : 'Send'}
|
|
164
|
+
</button>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
- **`usePlanTransaction(client)`** / **`usePlanTransactions(client)`** — plan a single, or multiple, transaction message(s) from an instruction input. Requires a client with transaction planning installed (`ClientWithTransactionPlanning`). `usePlanTransaction` resolves with a single transaction message; `usePlanTransactions` resolves with the full transaction plan.
|
|
170
|
+
- **`useSendTransaction(client)`** / **`useSendTransactions(client)`** — sign, submit, and confirm a single, or multiple, transaction(s). Requires a client with transaction sending installed (`ClientWithTransactionSending`). Both accept flexible input (instructions, an instruction plan, or a transaction plan); `useSendTransaction` additionally accepts a single transaction message.
|
|
171
|
+
|
|
172
|
+
### `useAirdrop(client)`
|
|
173
|
+
|
|
174
|
+
Request an airdrop of SOL to an address as a tracked action. Requires a client with an airdrop plugin installed (`ClientWithAirdrop`) — typically available on devnet, testnet, and local validators. Returns the same `ActionResult` as [`useAction`](#useactionfn); `dispatch(address, amount)` supplies the recipient and lamport amount while the hook injects the `AbortSignal`. A natural fit for a devnet "fund this account" button.
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
import { useAirdrop } from '@solana/react';
|
|
178
|
+
import { lamports } from '@solana/kit';
|
|
179
|
+
import type { Address } from '@solana/kit';
|
|
180
|
+
|
|
181
|
+
function AirdropButton({ client, address }: { client: ClientWithAirdrop; address: Address }) {
|
|
182
|
+
const { dispatch, isRunning } = useAirdrop(client);
|
|
183
|
+
return (
|
|
184
|
+
<button disabled={isRunning} onClick={() => dispatch(address, lamports(1_000_000_000n))}>
|
|
185
|
+
{isRunning ? 'Airdropping…' : 'Airdrop 1 SOL'}
|
|
186
|
+
</button>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
`data` resolves to the transaction `Signature`, or `undefined` when the airdrop was applied without a transaction (some implementations, e.g. LiteSVM, adjust balances directly) — null-check it before use.
|
|
192
|
+
|
|
193
|
+
### Payer & identity
|
|
194
|
+
|
|
195
|
+
Read the signer a client uses to pay for transactions (`payer`), or the wallet whose on-chain assets the app acts upon (`identity`), and re-render whenever it changes. Both hooks return the current `TransactionSigner`, or `undefined` while none is available.
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
import { useClient, useIdentity, usePayer } from '@solana/react';
|
|
199
|
+
import type { AppClient } from './client';
|
|
200
|
+
|
|
201
|
+
function AccountBar() {
|
|
202
|
+
const client = useClient<AppClient>();
|
|
203
|
+
const identity = useIdentity(client);
|
|
204
|
+
const payer = usePayer(client);
|
|
205
|
+
return (
|
|
206
|
+
<div>
|
|
207
|
+
<span>{identity ? `Signed in as ${identity.address}` : 'Signed out'}</span>
|
|
208
|
+
<span>{payer ? `Paying with ${payer.address}` : 'No payer'}</span>
|
|
209
|
+
</div>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
- **`usePayer(client)`** — reads `client.payer`. Requires a client with a payer plugin installed (`ClientWithPayer`).
|
|
215
|
+
- **`useIdentity(client)`** — reads `client.identity`. Requires a client with an identity plugin installed (`ClientWithIdentity`).
|
|
216
|
+
|
|
217
|
+
When the client also advertises `subscribeToPayer` / `subscribeToIdentity` (`ClientWithSubscribeToPayer` / `ClientWithSubscribeToIdentity`), each hook subscribes so the returned value always reflects the latest signer. For a client whose payer or identity is fixed for its lifetime, it falls back to a no-op subscription and reads the value once.
|
|
218
|
+
|
|
132
219
|
### `useRequest(source, options?)`
|
|
133
220
|
|
|
134
221
|
Fires a one-shot request on mount and re-fires whenever `source` changes identity. Returns `{ data, error, status, refresh }` where `status` is one of `'fetching' | 'success' | 'error' | 'disabled'`. Use it for RPC reads, or for any other one-shot async work an app needs (a `fetch`, a third-party SDK call, etc.).
|
|
@@ -139,10 +226,10 @@ Fires a one-shot request on mount and re-fires whenever `source` changes identit
|
|
|
139
226
|
|
|
140
227
|
```tsx
|
|
141
228
|
import { useClient, useRequest } from '@solana/react';
|
|
142
|
-
import type {
|
|
229
|
+
import type { AppClient } from './client';
|
|
143
230
|
|
|
144
231
|
function LatestBlockhash() {
|
|
145
|
-
const client = useClient<
|
|
232
|
+
const client = useClient<AppClient>();
|
|
146
233
|
const source = useMemo(() => client.rpc.getLatestBlockhash(), [client]);
|
|
147
234
|
const { data, error, refresh } = useRequest(source);
|
|
148
235
|
if (error) return <button onClick={refresh}>Retry</button>;
|
|
@@ -154,7 +241,7 @@ function LatestBlockhash() {
|
|
|
154
241
|
|
|
155
242
|
```tsx
|
|
156
243
|
function Balance({ address }: { address: Address | null }) {
|
|
157
|
-
const client = useClient<
|
|
244
|
+
const client = useClient<AppClient>();
|
|
158
245
|
// Disabled until an address is selected.
|
|
159
246
|
const source = useMemo(() => (address ? client.rpc.getBalance(address) : null), [client, address]);
|
|
160
247
|
const { data, status } = useRequest(source);
|
|
@@ -209,10 +296,11 @@ Subscribe to a stream-store source and surface the latest notification as reacti
|
|
|
209
296
|
|
|
210
297
|
```tsx
|
|
211
298
|
import { useClient, useSubscription } from '@solana/react';
|
|
212
|
-
import type { Address
|
|
299
|
+
import type { Address } from '@solana/kit';
|
|
300
|
+
import type { AppClient } from './client';
|
|
213
301
|
|
|
214
302
|
function AccountBalance({ address }: { address: Address }) {
|
|
215
|
-
const client = useClient<
|
|
303
|
+
const client = useClient<AppClient>();
|
|
216
304
|
const source = useMemo(() => client.rpcSubscriptions.accountNotifications(address), [client, address]);
|
|
217
305
|
const { data, error, reconnect } = useSubscription(source);
|
|
218
306
|
if (error) return <button onClick={reconnect}>Reconnect</button>;
|
|
@@ -252,16 +340,11 @@ Render reactive state for an RPC subscription seeded by a one-shot RPC fetch, sl
|
|
|
252
340
|
|
|
253
341
|
```tsx
|
|
254
342
|
import { useClient, useTrackedData } from '@solana/react';
|
|
255
|
-
import type {
|
|
256
|
-
|
|
257
|
-
AccountNotificationsApi,
|
|
258
|
-
ClientWithRpc,
|
|
259
|
-
ClientWithRpcSubscriptions,
|
|
260
|
-
GetBalanceApi,
|
|
261
|
-
} from '@solana/kit';
|
|
343
|
+
import type { Address } from '@solana/kit';
|
|
344
|
+
import type { AppClient } from './client';
|
|
262
345
|
|
|
263
346
|
function AccountBalance({ address }: { address: Address }) {
|
|
264
|
-
const client = useClient<
|
|
347
|
+
const client = useClient<AppClient>();
|
|
265
348
|
const spec = useMemo(
|
|
266
349
|
() => ({
|
|
267
350
|
rpcRequest: client.rpc.getBalance(address),
|
|
@@ -312,10 +395,10 @@ SWR-backed counterpart to `useRequest`. Same `source` shape (a `ReactiveActionSo
|
|
|
312
395
|
```tsx
|
|
313
396
|
import { useClient } from '@solana/react';
|
|
314
397
|
import { useRequestSWR } from '@solana/react/swr';
|
|
315
|
-
import type {
|
|
398
|
+
import type { AppClient } from './client';
|
|
316
399
|
|
|
317
400
|
function LatestBlockhash() {
|
|
318
|
-
const client = useClient<
|
|
401
|
+
const client = useClient<AppClient>();
|
|
319
402
|
const { data, error, isLoading, mutate } = useRequestSWR(['latestBlockhash'], client.rpc.getLatestBlockhash());
|
|
320
403
|
if (error) return <button onClick={() => mutate()}>Retry</button>;
|
|
321
404
|
if (isLoading) return <p>Loading…</p>;
|
|
@@ -360,7 +443,7 @@ SWR-backed counterpart to `useSubscription`. Routes a `ReactiveStreamSource<T>`
|
|
|
360
443
|
|
|
361
444
|
```tsx
|
|
362
445
|
function AccountBalance({ address }: { address: Address }) {
|
|
363
|
-
const client = useClient<
|
|
446
|
+
const client = useClient<AppClient>();
|
|
364
447
|
const { data, error } = useSubscriptionSWR(
|
|
365
448
|
address ? ['account', address] : null,
|
|
366
449
|
address ? client.rpcSubscriptions.accountNotifications(address) : null,
|
|
@@ -383,7 +466,7 @@ SWR-backed counterpart to `useTrackedData`. Takes the same `TrackedDataSpec` (RP
|
|
|
383
466
|
|
|
384
467
|
```tsx
|
|
385
468
|
function AccountBalance({ address }: { address: Address }) {
|
|
386
|
-
const client = useClient<
|
|
469
|
+
const client = useClient<AppClient>();
|
|
387
470
|
const spec = useMemo(
|
|
388
471
|
() =>
|
|
389
472
|
address
|
|
@@ -418,10 +501,10 @@ TanStack Query-backed counterpart to `useRequest`. Same `source` shape (a `React
|
|
|
418
501
|
```tsx
|
|
419
502
|
import { useClient } from '@solana/react';
|
|
420
503
|
import { useRequestQuery } from '@solana/react/query';
|
|
421
|
-
import type {
|
|
504
|
+
import type { AppClient } from './client';
|
|
422
505
|
|
|
423
506
|
function LatestBlockhash() {
|
|
424
|
-
const client = useClient<
|
|
507
|
+
const client = useClient<AppClient>();
|
|
425
508
|
const { data, error, isLoading, refetch } = useRequestQuery(['latestBlockhash'], client.rpc.getLatestBlockhash());
|
|
426
509
|
if (error) return <button onClick={() => refetch()}>Retry</button>;
|
|
427
510
|
if (isLoading) return <p>Loading…</p>;
|
|
@@ -463,10 +546,10 @@ Returns TanStack's native `UseQueryResult<T>`. `data` is the raw notification, e
|
|
|
463
546
|
```tsx
|
|
464
547
|
import { useClient } from '@solana/react';
|
|
465
548
|
import { useSubscriptionQuery } from '@solana/react/query';
|
|
466
|
-
import type {
|
|
549
|
+
import type { AppClient } from './client';
|
|
467
550
|
|
|
468
551
|
function SlotHeight() {
|
|
469
|
-
const client = useClient<
|
|
552
|
+
const client = useClient<AppClient>();
|
|
470
553
|
const { data, error } = useSubscriptionQuery(['slot'], client.rpcSubscriptions.slotNotifications());
|
|
471
554
|
if (error) return <p>Disconnected.</p>;
|
|
472
555
|
if (!data) return <p>Connecting…</p>;
|
|
@@ -494,16 +577,11 @@ Returns TanStack's native `UseQueryResult`. `data` is the `SolanaRpcResponse<TIt
|
|
|
494
577
|
```tsx
|
|
495
578
|
import { useClient } from '@solana/react';
|
|
496
579
|
import { useTrackedDataQuery } from '@solana/react/query';
|
|
497
|
-
import type {
|
|
498
|
-
|
|
499
|
-
AccountNotificationsApi,
|
|
500
|
-
ClientWithRpc,
|
|
501
|
-
ClientWithRpcSubscriptions,
|
|
502
|
-
GetBalanceApi,
|
|
503
|
-
} from '@solana/kit';
|
|
580
|
+
import type { Address } from '@solana/kit';
|
|
581
|
+
import type { AppClient } from './client';
|
|
504
582
|
|
|
505
583
|
function AccountBalance({ address }: { address: Address }) {
|
|
506
|
-
const client = useClient<
|
|
584
|
+
const client = useClient<AppClient>();
|
|
507
585
|
const spec = useMemo(
|
|
508
586
|
() => ({
|
|
509
587
|
initialValueSource: client.rpc.getBalance(address),
|
package/dist/index.browser.cjs
CHANGED
|
@@ -79,6 +79,11 @@ function useAction(fn) {
|
|
|
79
79
|
[state, store]
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
// src/useAirdrop.ts
|
|
84
|
+
function useAirdrop(client) {
|
|
85
|
+
return useAction((abortSignal, address4, amount) => client.airdrop(address4, amount, abortSignal));
|
|
86
|
+
}
|
|
82
87
|
function useClient() {
|
|
83
88
|
const client = React5__default.default.useContext(ClientContext);
|
|
84
89
|
if (client == null) {
|
|
@@ -103,6 +108,48 @@ function useClientCapability({
|
|
|
103
108
|
}
|
|
104
109
|
return client;
|
|
105
110
|
}
|
|
111
|
+
var NOOP_UNSUBSCRIBE = () => {
|
|
112
|
+
};
|
|
113
|
+
function useIdentity(client) {
|
|
114
|
+
const subscribe = React5.useCallback(
|
|
115
|
+
(onStoreChange) => client.subscribeToIdentity ? client.subscribeToIdentity(onStoreChange) : NOOP_UNSUBSCRIBE,
|
|
116
|
+
[client]
|
|
117
|
+
);
|
|
118
|
+
const getSnapshot = React5.useCallback(() => {
|
|
119
|
+
try {
|
|
120
|
+
return client.identity;
|
|
121
|
+
} catch {
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
}, [client]);
|
|
125
|
+
return React5.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
126
|
+
}
|
|
127
|
+
var NOOP_UNSUBSCRIBE2 = () => {
|
|
128
|
+
};
|
|
129
|
+
function usePayer(client) {
|
|
130
|
+
const subscribe = React5.useCallback(
|
|
131
|
+
(onStoreChange) => client.subscribeToPayer ? client.subscribeToPayer(onStoreChange) : NOOP_UNSUBSCRIBE2,
|
|
132
|
+
[client]
|
|
133
|
+
);
|
|
134
|
+
const getSnapshot = React5.useCallback(() => {
|
|
135
|
+
try {
|
|
136
|
+
return client.payer;
|
|
137
|
+
} catch {
|
|
138
|
+
return void 0;
|
|
139
|
+
}
|
|
140
|
+
}, [client]);
|
|
141
|
+
return React5.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/usePlanTransaction.ts
|
|
145
|
+
function usePlanTransaction(client) {
|
|
146
|
+
return useAction((abortSignal, input) => client.planTransaction(input, { abortSignal }));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/usePlanTransactions.ts
|
|
150
|
+
function usePlanTransactions(client) {
|
|
151
|
+
return useAction((abortSignal, input) => client.planTransactions(input, { abortSignal }));
|
|
152
|
+
}
|
|
106
153
|
|
|
107
154
|
// src/staticStores.ts
|
|
108
155
|
var DISABLED_ACTION_STATE = Object.freeze({
|
|
@@ -211,6 +258,16 @@ function useRequest(source, options) {
|
|
|
211
258
|
const refresh = useReactiveStoreLifecycle(store, fireAction, options?.getAbortSignal);
|
|
212
259
|
return useRequestResult(store, refresh, source == null);
|
|
213
260
|
}
|
|
261
|
+
|
|
262
|
+
// src/useSendTransaction.ts
|
|
263
|
+
function useSendTransaction(client) {
|
|
264
|
+
return useAction((abortSignal, input) => client.sendTransaction(input, { abortSignal }));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/useSendTransactions.ts
|
|
268
|
+
function useSendTransactions(client) {
|
|
269
|
+
return useAction((abortSignal, input) => client.sendTransactions(input, { abortSignal }));
|
|
270
|
+
}
|
|
214
271
|
function useSignAndSendTransaction(uiWalletAccount, chain) {
|
|
215
272
|
const signAndSendTransactions = useSignAndSendTransactions(uiWalletAccount, chain);
|
|
216
273
|
return React5.useCallback(
|
|
@@ -663,10 +720,17 @@ exports.ClientProvider = ClientProvider;
|
|
|
663
720
|
exports.SelectedWalletAccountContext = SelectedWalletAccountContext;
|
|
664
721
|
exports.SelectedWalletAccountContextProvider = SelectedWalletAccountContextProvider;
|
|
665
722
|
exports.useAction = useAction;
|
|
723
|
+
exports.useAirdrop = useAirdrop;
|
|
666
724
|
exports.useClient = useClient;
|
|
667
725
|
exports.useClientCapability = useClientCapability;
|
|
726
|
+
exports.useIdentity = useIdentity;
|
|
727
|
+
exports.usePayer = usePayer;
|
|
728
|
+
exports.usePlanTransaction = usePlanTransaction;
|
|
729
|
+
exports.usePlanTransactions = usePlanTransactions;
|
|
668
730
|
exports.useRequest = useRequest;
|
|
669
731
|
exports.useSelectedWalletAccount = useSelectedWalletAccount;
|
|
732
|
+
exports.useSendTransaction = useSendTransaction;
|
|
733
|
+
exports.useSendTransactions = useSendTransactions;
|
|
670
734
|
exports.useSignAndSendTransaction = useSignAndSendTransaction;
|
|
671
735
|
exports.useSignAndSendTransactions = useSignAndSendTransactions;
|
|
672
736
|
exports.useSignIn = useSignIn;
|