@solana/react-hooks 0.3.0 → 0.5.1
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 +43 -21
- package/dist/index.browser.cjs +152 -98
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +147 -96
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.native.mjs +147 -96
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.node.cjs +152 -98
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +147 -96
- package/dist/index.node.mjs.map +1 -1
- package/dist/types/QueryProvider.d.ts.map +1 -1
- package/dist/types/context.d.ts +3 -0
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/hooks.d.ts +59 -17
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/query.d.ts +2 -1
- package/dist/types/query.d.ts.map +1 -1
- package/dist/types/queryHooks.d.ts +18 -10
- package/dist/types/queryHooks.d.ts.map +1 -1
- package/dist/types/queryKeys.d.ts +8 -0
- package/dist/types/queryKeys.d.ts.map +1 -0
- package/dist/types/ui.d.ts +10 -11
- package/dist/types/ui.d.ts.map +1 -1
- package/dist/types/useClientStore.d.ts +4 -3
- package/dist/types/useClientStore.d.ts.map +1 -1
- package/package.json +3 -8
package/dist/index.node.cjs
CHANGED
|
@@ -62,11 +62,11 @@ var QUERY_NAMESPACE = "@solana/react-hooks";
|
|
|
62
62
|
function useSolanaRpcQuery(scope, args, fetcher, options = {}) {
|
|
63
63
|
const client = useSolanaClient();
|
|
64
64
|
const cluster = useClientStore((state) => state.cluster);
|
|
65
|
-
const { disabled = false,
|
|
65
|
+
const { disabled = false, swr } = options;
|
|
66
66
|
const providerSuspensePreference = useQuerySuspensePreference();
|
|
67
67
|
const suspenseEnabled = !disabled && Boolean(providerSuspensePreference);
|
|
68
68
|
const swrOptions = {
|
|
69
|
-
...
|
|
69
|
+
...swr ?? {},
|
|
70
70
|
suspense: suspenseEnabled
|
|
71
71
|
};
|
|
72
72
|
const key = react.useMemo(() => {
|
|
@@ -75,59 +75,105 @@ function useSolanaRpcQuery(scope, args, fetcher, options = {}) {
|
|
|
75
75
|
}
|
|
76
76
|
return [QUERY_NAMESPACE, scope, cluster.endpoint, cluster.commitment, ...args];
|
|
77
77
|
}, [cluster.commitment, cluster.endpoint, args, scope, disabled]);
|
|
78
|
-
const
|
|
78
|
+
const swrResponse = useSWR__default.default(key, () => fetcher(client), swrOptions);
|
|
79
79
|
const [dataUpdatedAt, setDataUpdatedAt] = react.useState(
|
|
80
|
-
() =>
|
|
80
|
+
() => swrResponse.data !== void 0 ? Date.now() : void 0
|
|
81
81
|
);
|
|
82
82
|
react.useEffect(() => {
|
|
83
|
-
if (
|
|
83
|
+
if (swrResponse.data !== void 0) {
|
|
84
84
|
setDataUpdatedAt(Date.now());
|
|
85
85
|
}
|
|
86
|
-
}, [
|
|
87
|
-
const status =
|
|
88
|
-
const refresh = react.useCallback(() =>
|
|
86
|
+
}, [swrResponse.data]);
|
|
87
|
+
const status = swrResponse.error ? "error" : swrResponse.isLoading ? "loading" : swrResponse.data !== void 0 ? "success" : "idle";
|
|
88
|
+
const refresh = react.useCallback(() => swrResponse.mutate(void 0, { revalidate: true }), [swrResponse.mutate]);
|
|
89
89
|
return {
|
|
90
|
-
data:
|
|
90
|
+
data: swrResponse.data,
|
|
91
91
|
dataUpdatedAt,
|
|
92
|
-
error:
|
|
92
|
+
error: swrResponse.error ?? null,
|
|
93
93
|
isError: status === "error",
|
|
94
|
-
isLoading:
|
|
94
|
+
isLoading: swrResponse.isLoading,
|
|
95
95
|
isSuccess: status === "success",
|
|
96
|
-
isValidating:
|
|
97
|
-
mutate:
|
|
96
|
+
isValidating: swrResponse.isValidating,
|
|
97
|
+
mutate: swrResponse.mutate,
|
|
98
98
|
refresh,
|
|
99
99
|
status
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
__name(useSolanaRpcQuery, "useSolanaRpcQuery");
|
|
103
|
+
function getLatestBlockhashKey(params = {}) {
|
|
104
|
+
const { commitment = null, minContextSlot = null } = params;
|
|
105
|
+
return ["latestBlockhash", commitment, normalizeBigint(minContextSlot)];
|
|
106
|
+
}
|
|
107
|
+
__name(getLatestBlockhashKey, "getLatestBlockhashKey");
|
|
108
|
+
function getProgramAccountsKey(params = {}) {
|
|
109
|
+
const { programAddress, config } = params;
|
|
110
|
+
const address = programAddress ? client.toAddress(programAddress) : void 0;
|
|
111
|
+
const addressKey = address ? client.toAddressString(address) : null;
|
|
112
|
+
const configKey = client.stableStringify(config ?? null);
|
|
113
|
+
return ["programAccounts", addressKey, configKey];
|
|
114
|
+
}
|
|
115
|
+
__name(getProgramAccountsKey, "getProgramAccountsKey");
|
|
116
|
+
function getSimulateTransactionKey(params = {}) {
|
|
117
|
+
const { transaction, config } = params;
|
|
118
|
+
const wire = transaction ? normalizeWire(transaction) : null;
|
|
119
|
+
const configKey = client.stableStringify(config ?? null);
|
|
120
|
+
return ["simulateTransaction", wire, configKey];
|
|
121
|
+
}
|
|
122
|
+
__name(getSimulateTransactionKey, "getSimulateTransactionKey");
|
|
123
|
+
function getSignatureStatusKey(params = {}) {
|
|
124
|
+
const { config, signature } = params;
|
|
125
|
+
const signatureKey = signature?.toString() ?? null;
|
|
126
|
+
const configKey = JSON.stringify(config ?? null);
|
|
127
|
+
return ["signatureStatus", signatureKey, configKey];
|
|
128
|
+
}
|
|
129
|
+
__name(getSignatureStatusKey, "getSignatureStatusKey");
|
|
130
|
+
function normalizeBigint(value) {
|
|
131
|
+
if (value === void 0 || value === null) return null;
|
|
132
|
+
return typeof value === "bigint" ? value : BigInt(Math.floor(value));
|
|
133
|
+
}
|
|
134
|
+
__name(normalizeBigint, "normalizeBigint");
|
|
135
|
+
function normalizeWire(input) {
|
|
136
|
+
if (!input) return null;
|
|
137
|
+
if (typeof input === "string") {
|
|
138
|
+
return input;
|
|
139
|
+
}
|
|
140
|
+
return kit.getBase64EncodedWireTransaction(input);
|
|
141
|
+
}
|
|
142
|
+
__name(normalizeWire, "normalizeWire");
|
|
143
|
+
|
|
144
|
+
// src/queryHooks.ts
|
|
103
145
|
var DEFAULT_BLOCKHASH_REFRESH_INTERVAL = 3e4;
|
|
104
|
-
function useLatestBlockhash(options) {
|
|
105
|
-
const {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
const keyArgs = react.useMemo(
|
|
113
|
-
() => [commitment ?? null, normalizedMinContextSlot ?? null],
|
|
114
|
-
[commitment, normalizedMinContextSlot]
|
|
115
|
-
);
|
|
146
|
+
function useLatestBlockhash(options = {}) {
|
|
147
|
+
const {
|
|
148
|
+
commitment,
|
|
149
|
+
minContextSlot,
|
|
150
|
+
refreshInterval = DEFAULT_BLOCKHASH_REFRESH_INTERVAL,
|
|
151
|
+
disabled = false,
|
|
152
|
+
swr
|
|
153
|
+
} = options;
|
|
116
154
|
const fetcher = react.useCallback(
|
|
117
155
|
async (client) => {
|
|
118
156
|
const fallbackCommitment = commitment ?? client.store.getState().cluster.commitment;
|
|
119
157
|
const plan = client.runtime.rpc.getLatestBlockhash({
|
|
120
158
|
commitment: fallbackCommitment,
|
|
121
|
-
minContextSlot:
|
|
159
|
+
minContextSlot: normalizeMinContextSlot(minContextSlot)
|
|
122
160
|
});
|
|
123
161
|
return plan.send({ abortSignal: AbortSignal.timeout(15e3) });
|
|
124
162
|
},
|
|
125
|
-
[commitment,
|
|
163
|
+
[commitment, minContextSlot]
|
|
164
|
+
);
|
|
165
|
+
const query = useSolanaRpcQuery(
|
|
166
|
+
"latestBlockhash",
|
|
167
|
+
getLatestBlockhashKey(options),
|
|
168
|
+
fetcher,
|
|
169
|
+
{
|
|
170
|
+
disabled,
|
|
171
|
+
swr: {
|
|
172
|
+
refreshInterval,
|
|
173
|
+
...swr
|
|
174
|
+
}
|
|
175
|
+
}
|
|
126
176
|
);
|
|
127
|
-
const query = useSolanaRpcQuery("latestBlockhash", keyArgs, fetcher, {
|
|
128
|
-
refreshInterval,
|
|
129
|
-
...rest
|
|
130
|
-
});
|
|
131
177
|
return {
|
|
132
178
|
...query,
|
|
133
179
|
blockhash: query.data?.value.blockhash ?? null,
|
|
@@ -137,31 +183,33 @@ function useLatestBlockhash(options) {
|
|
|
137
183
|
}
|
|
138
184
|
__name(useLatestBlockhash, "useLatestBlockhash");
|
|
139
185
|
function useProgramAccounts(programAddress, options) {
|
|
140
|
-
const { commitment, config,
|
|
141
|
-
const { disabled: disabledOption, ...restQueryOptions } = queryOptions;
|
|
142
|
-
const address = react.useMemo(() => programAddress ? client.toAddress(programAddress) : void 0, [programAddress]);
|
|
143
|
-
const addressKey = react.useMemo(() => address ? client.toAddressString(address) : null, [address]);
|
|
144
|
-
const configKey = react.useMemo(() => client.stableStringify(config ?? null), [config]);
|
|
186
|
+
const { commitment, config, swr, disabled: disabledOption } = options ?? {};
|
|
145
187
|
const fetcher = react.useCallback(
|
|
146
|
-
async (client) => {
|
|
188
|
+
async (client$1) => {
|
|
189
|
+
const address = programAddress ? client.toAddress(programAddress) : void 0;
|
|
147
190
|
if (!address) {
|
|
148
191
|
throw new Error("Provide a program address before querying program accounts.");
|
|
149
192
|
}
|
|
150
|
-
const fallbackCommitment = commitment ?? config?.commitment ?? client.store.getState().cluster.commitment;
|
|
193
|
+
const fallbackCommitment = commitment ?? config?.commitment ?? client$1.store.getState().cluster.commitment;
|
|
151
194
|
const mergedConfig = {
|
|
152
195
|
...config ?? {},
|
|
153
196
|
commitment: fallbackCommitment
|
|
154
197
|
};
|
|
155
|
-
const plan = client.runtime.rpc.getProgramAccounts(address, mergedConfig);
|
|
198
|
+
const plan = client$1.runtime.rpc.getProgramAccounts(address, mergedConfig);
|
|
156
199
|
return plan.send({ abortSignal: AbortSignal.timeout(2e4) });
|
|
157
200
|
},
|
|
158
|
-
[
|
|
201
|
+
[commitment, config, programAddress]
|
|
202
|
+
);
|
|
203
|
+
const disabled = disabledOption ?? !programAddress;
|
|
204
|
+
const query = useSolanaRpcQuery(
|
|
205
|
+
"programAccounts",
|
|
206
|
+
getProgramAccountsKey({ programAddress, config }),
|
|
207
|
+
fetcher,
|
|
208
|
+
{
|
|
209
|
+
disabled,
|
|
210
|
+
swr
|
|
211
|
+
}
|
|
159
212
|
);
|
|
160
|
-
const disabled = disabledOption ?? !address;
|
|
161
|
-
const query = useSolanaRpcQuery("programAccounts", [addressKey, configKey], fetcher, {
|
|
162
|
-
...restQueryOptions,
|
|
163
|
-
disabled
|
|
164
|
-
});
|
|
165
213
|
return {
|
|
166
214
|
...query,
|
|
167
215
|
accounts: query.data ?? []
|
|
@@ -169,8 +217,7 @@ function useProgramAccounts(programAddress, options) {
|
|
|
169
217
|
}
|
|
170
218
|
__name(useProgramAccounts, "useProgramAccounts");
|
|
171
219
|
function useSimulateTransaction(transaction, options) {
|
|
172
|
-
const { commitment, config, refreshInterval,
|
|
173
|
-
const { disabled: disabledOption, revalidateIfStale, revalidateOnFocus, ...queryOptions } = rest;
|
|
220
|
+
const { commitment, config, refreshInterval, disabled: disabledOption, swr } = options ?? {};
|
|
174
221
|
const wire = react.useMemo(() => {
|
|
175
222
|
if (!transaction) {
|
|
176
223
|
return null;
|
|
@@ -180,7 +227,6 @@ function useSimulateTransaction(transaction, options) {
|
|
|
180
227
|
}
|
|
181
228
|
return kit.getBase64EncodedWireTransaction(transaction);
|
|
182
229
|
}, [transaction]);
|
|
183
|
-
const configKey = react.useMemo(() => client.stableStringify(config ?? null), [config]);
|
|
184
230
|
const fetcher = react.useCallback(
|
|
185
231
|
async (client) => {
|
|
186
232
|
if (!wire) {
|
|
@@ -196,19 +242,31 @@ function useSimulateTransaction(transaction, options) {
|
|
|
196
242
|
[commitment, config, wire]
|
|
197
243
|
);
|
|
198
244
|
const disabled = disabledOption ?? !wire;
|
|
199
|
-
const query = useSolanaRpcQuery(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
245
|
+
const query = useSolanaRpcQuery(
|
|
246
|
+
"simulateTransaction",
|
|
247
|
+
getSimulateTransactionKey({ transaction, config }),
|
|
248
|
+
fetcher,
|
|
249
|
+
{
|
|
250
|
+
disabled,
|
|
251
|
+
swr: {
|
|
252
|
+
refreshInterval,
|
|
253
|
+
revalidateIfStale: false,
|
|
254
|
+
revalidateOnFocus: false,
|
|
255
|
+
...swr
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
);
|
|
206
259
|
return {
|
|
207
260
|
...query,
|
|
208
261
|
logs: query.data?.value.logs ?? []
|
|
209
262
|
};
|
|
210
263
|
}
|
|
211
264
|
__name(useSimulateTransaction, "useSimulateTransaction");
|
|
265
|
+
function normalizeMinContextSlot(minContextSlot) {
|
|
266
|
+
if (minContextSlot === void 0) return void 0;
|
|
267
|
+
return typeof minContextSlot === "bigint" ? minContextSlot : BigInt(Math.floor(minContextSlot));
|
|
268
|
+
}
|
|
269
|
+
__name(normalizeMinContextSlot, "normalizeMinContextSlot");
|
|
212
270
|
|
|
213
271
|
// src/hooks.ts
|
|
214
272
|
function createClusterSelector() {
|
|
@@ -358,10 +416,19 @@ function useSplToken(mint, options = {}) {
|
|
|
358
416
|
}
|
|
359
417
|
return helper.fetchBalance(owner, options.commitment);
|
|
360
418
|
}, [helper, owner, options.commitment]);
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
419
|
+
const swrOptions = react.useMemo(
|
|
420
|
+
() => ({
|
|
421
|
+
revalidateOnFocus: options.revalidateOnFocus ?? false,
|
|
422
|
+
suspense,
|
|
423
|
+
...options.swr ?? {}
|
|
424
|
+
}),
|
|
425
|
+
[options.revalidateOnFocus, options.swr, suspense]
|
|
426
|
+
);
|
|
427
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR__default.default(
|
|
428
|
+
balanceKey,
|
|
429
|
+
fetchBalance,
|
|
430
|
+
swrOptions
|
|
431
|
+
);
|
|
365
432
|
const sessionRef = react.useRef(session);
|
|
366
433
|
react.useEffect(() => {
|
|
367
434
|
sessionRef.current = session;
|
|
@@ -527,24 +594,6 @@ function useBalance(addressLike, options = {}) {
|
|
|
527
594
|
);
|
|
528
595
|
}
|
|
529
596
|
__name(useBalance, "useBalance");
|
|
530
|
-
function useWalletStandardConnectors(options) {
|
|
531
|
-
const overrides = options?.overrides;
|
|
532
|
-
const disabled = options?.disabled ?? false;
|
|
533
|
-
const memoisedOptions = react.useMemo(() => overrides ? { overrides } : void 0, [overrides]);
|
|
534
|
-
const [connectors, setConnectors] = react.useState(
|
|
535
|
-
() => disabled ? [] : client.getWalletStandardConnectors(memoisedOptions ?? {})
|
|
536
|
-
);
|
|
537
|
-
react.useEffect(() => {
|
|
538
|
-
if (disabled) return;
|
|
539
|
-
setConnectors(client.getWalletStandardConnectors(memoisedOptions ?? {}));
|
|
540
|
-
const unwatch = client.watchWalletStandardConnectors(setConnectors, memoisedOptions ?? {});
|
|
541
|
-
return () => {
|
|
542
|
-
unwatch();
|
|
543
|
-
};
|
|
544
|
-
}, [disabled, memoisedOptions]);
|
|
545
|
-
return connectors;
|
|
546
|
-
}
|
|
547
|
-
__name(useWalletStandardConnectors, "useWalletStandardConnectors");
|
|
548
597
|
function useTransactionPool(config = {}) {
|
|
549
598
|
const initialInstructions = react.useMemo(
|
|
550
599
|
() => config.instructions ?? [],
|
|
@@ -552,7 +601,9 @@ function useTransactionPool(config = {}) {
|
|
|
552
601
|
);
|
|
553
602
|
const client$1 = useSolanaClient();
|
|
554
603
|
const helper = client$1.helpers.transaction;
|
|
555
|
-
const
|
|
604
|
+
const swrRefreshInterval = config.latestBlockhash?.swr?.refreshInterval;
|
|
605
|
+
const blockhashRefreshInterval = config.latestBlockhash?.refreshInterval ?? (typeof swrRefreshInterval === "number" ? swrRefreshInterval : void 0);
|
|
606
|
+
const blockhashMaxAgeMs = blockhashRefreshInterval ?? 3e4;
|
|
556
607
|
const controller = react.useMemo(
|
|
557
608
|
() => client.createTransactionPoolController({
|
|
558
609
|
blockhashMaxAgeMs,
|
|
@@ -678,10 +729,9 @@ function useSendTransaction() {
|
|
|
678
729
|
}
|
|
679
730
|
__name(useSendTransaction, "useSendTransaction");
|
|
680
731
|
function useSignatureStatus(signatureInput, options = {}) {
|
|
681
|
-
const { config,
|
|
732
|
+
const { config, disabled: disabledOption, swr } = options;
|
|
682
733
|
const signature = react.useMemo(() => client.normalizeSignature(signatureInput), [signatureInput]);
|
|
683
734
|
const signatureKey = signature?.toString() ?? null;
|
|
684
|
-
const configKey = react.useMemo(() => JSON.stringify(config ?? null), [config]);
|
|
685
735
|
const fetcher = react.useCallback(
|
|
686
736
|
async (client$1) => {
|
|
687
737
|
if (!signatureKey) {
|
|
@@ -696,14 +746,14 @@ function useSignatureStatus(signatureInput, options = {}) {
|
|
|
696
746
|
},
|
|
697
747
|
[config, signature, signatureKey]
|
|
698
748
|
);
|
|
699
|
-
const disabled =
|
|
749
|
+
const disabled = disabledOption ?? !signatureKey;
|
|
700
750
|
const query = useSolanaRpcQuery(
|
|
701
751
|
"signatureStatus",
|
|
702
|
-
|
|
752
|
+
getSignatureStatusKey({ signature: signatureInput, config }),
|
|
703
753
|
fetcher,
|
|
704
754
|
{
|
|
705
|
-
|
|
706
|
-
|
|
755
|
+
disabled,
|
|
756
|
+
swr
|
|
707
757
|
}
|
|
708
758
|
);
|
|
709
759
|
const confirmationStatus = client.deriveConfirmationStatus(query.data ?? null);
|
|
@@ -722,14 +772,17 @@ function useWaitForSignature(signatureInput, options = {}) {
|
|
|
722
772
|
watchCommitment,
|
|
723
773
|
...signatureStatusOptions
|
|
724
774
|
} = options;
|
|
725
|
-
const {
|
|
775
|
+
const { swr, ...restStatusOptions } = signatureStatusOptions;
|
|
726
776
|
const subscribeCommitment = watchCommitment ?? commitment;
|
|
727
777
|
const client$1 = useSolanaClient();
|
|
728
778
|
const normalizedSignature = react.useMemo(() => client.normalizeSignature(signatureInput), [signatureInput]);
|
|
729
779
|
const disabled = disabledOption ?? !normalizedSignature;
|
|
730
780
|
const statusQuery = useSignatureStatus(signatureInput, {
|
|
731
781
|
...restStatusOptions,
|
|
732
|
-
|
|
782
|
+
swr: {
|
|
783
|
+
refreshInterval: 2e3,
|
|
784
|
+
...swr
|
|
785
|
+
},
|
|
733
786
|
disabled
|
|
734
787
|
});
|
|
735
788
|
const [subscriptionSettled, setSubscriptionSettled] = react.useState(false);
|
|
@@ -785,10 +838,11 @@ function useWaitForSignature(signatureInput, options = {}) {
|
|
|
785
838
|
__name(useWaitForSignature, "useWaitForSignature");
|
|
786
839
|
var createCache = /* @__PURE__ */ __name(() => /* @__PURE__ */ new Map(), "createCache");
|
|
787
840
|
var DEFAULT_QUERY_CONFIG = Object.freeze({
|
|
788
|
-
dedupingInterval:
|
|
789
|
-
focusThrottleInterval:
|
|
841
|
+
dedupingInterval: 2e3,
|
|
842
|
+
focusThrottleInterval: 5e3,
|
|
790
843
|
provider: /* @__PURE__ */ __name(() => createCache(), "provider"),
|
|
791
|
-
|
|
844
|
+
revalidateIfStale: true,
|
|
845
|
+
revalidateOnFocus: true,
|
|
792
846
|
revalidateOnReconnect: true
|
|
793
847
|
});
|
|
794
848
|
function SolanaQueryProvider({
|
|
@@ -976,12 +1030,7 @@ function useWalletConnection(options = {}) {
|
|
|
976
1030
|
const connectWallet = useConnectWallet();
|
|
977
1031
|
const disconnectWallet = useDisconnectWallet();
|
|
978
1032
|
const client = useSolanaClient();
|
|
979
|
-
const
|
|
980
|
-
const discovered = useWalletStandardConnectors({
|
|
981
|
-
...options.discoveryOptions,
|
|
982
|
-
disabled: !shouldDiscover
|
|
983
|
-
});
|
|
984
|
-
const connectors = options.connectors ?? (client.connectors.all.length > 0 ? client.connectors.all : discovered);
|
|
1033
|
+
const connectors = options.connectors ?? client.connectors.all;
|
|
985
1034
|
const connect = react.useCallback(
|
|
986
1035
|
(connectorId, connectOptions) => connectWallet(connectorId, connectOptions),
|
|
987
1036
|
[connectWallet]
|
|
@@ -989,6 +1038,7 @@ function useWalletConnection(options = {}) {
|
|
|
989
1038
|
const disconnect = react.useCallback(() => disconnectWallet(), [disconnectWallet]);
|
|
990
1039
|
const state = react.useMemo(() => {
|
|
991
1040
|
const connectorId = "connectorId" in wallet ? wallet.connectorId : void 0;
|
|
1041
|
+
const currentConnector = connectorId ? connectors.find((connector) => connector.id === connectorId) : void 0;
|
|
992
1042
|
const session = wallet.status === "connected" ? wallet.session : void 0;
|
|
993
1043
|
const error = wallet.status === "error" ? wallet.error ?? null : null;
|
|
994
1044
|
return {
|
|
@@ -997,6 +1047,7 @@ function useWalletConnection(options = {}) {
|
|
|
997
1047
|
connecting: wallet.status === "connecting",
|
|
998
1048
|
connectors,
|
|
999
1049
|
connectorId,
|
|
1050
|
+
currentConnector,
|
|
1000
1051
|
disconnect,
|
|
1001
1052
|
error,
|
|
1002
1053
|
status: wallet.status,
|
|
@@ -1006,8 +1057,8 @@ function useWalletConnection(options = {}) {
|
|
|
1006
1057
|
return state;
|
|
1007
1058
|
}
|
|
1008
1059
|
__name(useWalletConnection, "useWalletConnection");
|
|
1009
|
-
function WalletConnectionManager({ children, connectors
|
|
1010
|
-
const state = useWalletConnection({ connectors
|
|
1060
|
+
function WalletConnectionManager({ children, connectors }) {
|
|
1061
|
+
const state = useWalletConnection({ connectors });
|
|
1011
1062
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children(state) });
|
|
1012
1063
|
}
|
|
1013
1064
|
__name(WalletConnectionManager, "WalletConnectionManager");
|
|
@@ -1047,6 +1098,10 @@ exports.SolanaClientProvider = SolanaClientProvider;
|
|
|
1047
1098
|
exports.SolanaProvider = SolanaProvider;
|
|
1048
1099
|
exports.SolanaQueryProvider = SolanaQueryProvider;
|
|
1049
1100
|
exports.WalletConnectionManager = WalletConnectionManager;
|
|
1101
|
+
exports.getLatestBlockhashKey = getLatestBlockhashKey;
|
|
1102
|
+
exports.getProgramAccountsKey = getProgramAccountsKey;
|
|
1103
|
+
exports.getSignatureStatusKey = getSignatureStatusKey;
|
|
1104
|
+
exports.getSimulateTransactionKey = getSimulateTransactionKey;
|
|
1050
1105
|
exports.useAccount = useAccount;
|
|
1051
1106
|
exports.useBalance = useBalance;
|
|
1052
1107
|
exports.useClientStore = useClientStore;
|
|
@@ -1069,6 +1124,5 @@ exports.useWalletActions = useWalletActions;
|
|
|
1069
1124
|
exports.useWalletConnection = useWalletConnection;
|
|
1070
1125
|
exports.useWalletModalState = useWalletModalState;
|
|
1071
1126
|
exports.useWalletSession = useWalletSession;
|
|
1072
|
-
exports.useWalletStandardConnectors = useWalletStandardConnectors;
|
|
1073
1127
|
//# sourceMappingURL=index.node.cjs.map
|
|
1074
1128
|
//# sourceMappingURL=index.node.cjs.map
|