@dynamic-labs-sdk/react-hooks 1.17.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/index.d.ts +5 -0
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/foundation/useBaseQuery/index.d.ts +1 -1
- package/dist/foundation/useBaseQuery/index.d.ts.map +1 -1
- package/dist/foundation/useBaseQuery/useBaseQuery.d.ts +29 -15
- package/dist/foundation/useBaseQuery/useBaseQuery.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useDeletePasskey/useDeletePasskey.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetActiveNetworkData/useGetActiveNetworkData.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetActiveNetworkId/useGetActiveNetworkId.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetAvailableWalletProvidersData/useGetAvailableWalletProvidersData.d.ts +4 -1
- package/dist/hooks/wrappers/functions/useGetAvailableWalletProvidersData/useGetAvailableWalletProvidersData.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetConnectedAddresses/useGetConnectedAddresses.d.ts +4 -1
- package/dist/hooks/wrappers/functions/useGetConnectedAddresses/useGetConnectedAddresses.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetGoogleDriveBackupReadiness/useGetGoogleDriveBackupReadiness.d.ts +4 -0
- package/dist/hooks/wrappers/functions/useGetGoogleDriveBackupReadiness/useGetGoogleDriveBackupReadiness.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetKrakenAccounts/useGetKrakenAccounts.d.ts +4 -0
- package/dist/hooks/wrappers/functions/useGetKrakenAccounts/useGetKrakenAccounts.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetKrakenWhitelistedAddresses/useGetKrakenWhitelistedAddresses.d.ts +4 -0
- package/dist/hooks/wrappers/functions/useGetKrakenWhitelistedAddresses/useGetKrakenWhitelistedAddresses.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetMfaDevices/useGetMfaDevices.d.ts +4 -0
- package/dist/hooks/wrappers/functions/useGetMfaDevices/useGetMfaDevices.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetMfaMethods/useGetMfaMethods.d.ts +4 -0
- package/dist/hooks/wrappers/functions/useGetMfaMethods/useGetMfaMethods.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetMfaRecoveryCodes/useGetMfaRecoveryCodes.d.ts +4 -0
- package/dist/hooks/wrappers/functions/useGetMfaRecoveryCodes/useGetMfaRecoveryCodes.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetNativeBalance/useGetNativeBalance.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetPasskeys/useGetPasskeys.d.ts +4 -0
- package/dist/hooks/wrappers/functions/useGetPasskeys/useGetPasskeys.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetRegisteredDevices/useGetRegisteredDevices.d.ts +4 -0
- package/dist/hooks/wrappers/functions/useGetRegisteredDevices/useGetRegisteredDevices.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetTokenBalances/useGetTokenBalances.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetTransactionHistory/useGetTransactionHistory.d.ts +1 -1
- package/dist/hooks/wrappers/functions/useGetTransactionHistory/useGetTransactionHistory.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetUserSocialAccounts/useGetUserSocialAccounts.d.ts +3 -1
- package/dist/hooks/wrappers/functions/useGetUserSocialAccounts/useGetUserSocialAccounts.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetWalletOptionsCatalogue/useGetWalletOptionsCatalogue.d.ts +8 -1
- package/dist/hooks/wrappers/functions/useGetWalletOptionsCatalogue/useGetWalletOptionsCatalogue.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useGetWalletProviderDataByKey/index.d.ts +2 -0
- package/dist/hooks/wrappers/functions/useGetWalletProviderDataByKey/index.d.ts.map +1 -0
- package/dist/hooks/wrappers/functions/useGetWalletProviderDataByKey/useGetWalletProviderDataByKey.d.ts +37 -0
- package/dist/hooks/wrappers/functions/useGetWalletProviderDataByKey/useGetWalletProviderDataByKey.d.ts.map +1 -0
- package/dist/hooks/wrappers/functions/useIsDeviceRegistrationRequired/index.d.ts +2 -0
- package/dist/hooks/wrappers/functions/useIsDeviceRegistrationRequired/index.d.ts.map +1 -0
- package/dist/hooks/wrappers/functions/useIsDeviceRegistrationRequired/useIsDeviceRegistrationRequired.d.ts +8 -0
- package/dist/hooks/wrappers/functions/useIsDeviceRegistrationRequired/useIsDeviceRegistrationRequired.d.ts.map +1 -0
- package/dist/hooks/wrappers/functions/useIsPendingRecoveryCodesAcknowledgment/index.d.ts +2 -0
- package/dist/hooks/wrappers/functions/useIsPendingRecoveryCodesAcknowledgment/index.d.ts.map +1 -0
- package/dist/hooks/wrappers/functions/useIsPendingRecoveryCodesAcknowledgment/useIsPendingRecoveryCodesAcknowledgment.d.ts +9 -0
- package/dist/hooks/wrappers/functions/useIsPendingRecoveryCodesAcknowledgment/useIsPendingRecoveryCodesAcknowledgment.d.ts.map +1 -0
- package/dist/hooks/wrappers/functions/useIsUserMissingMfaAuth/index.d.ts +2 -0
- package/dist/hooks/wrappers/functions/useIsUserMissingMfaAuth/index.d.ts.map +1 -0
- package/dist/hooks/wrappers/functions/useIsUserMissingMfaAuth/useIsUserMissingMfaAuth.d.ts +8 -0
- package/dist/hooks/wrappers/functions/useIsUserMissingMfaAuth/useIsUserMissingMfaAuth.d.ts.map +1 -0
- package/dist/hooks/wrappers/functions/useIsUserOnboardingComplete/index.d.ts +2 -0
- package/dist/hooks/wrappers/functions/useIsUserOnboardingComplete/index.d.ts.map +1 -0
- package/dist/hooks/wrappers/functions/useIsUserOnboardingComplete/useIsUserOnboardingComplete.d.ts +9 -0
- package/dist/hooks/wrappers/functions/useIsUserOnboardingComplete/useIsUserOnboardingComplete.d.ts.map +1 -0
- package/dist/hooks/wrappers/functions/useOnWalletProviderEvent/useOnWalletProviderEvent.d.ts +17 -2
- package/dist/hooks/wrappers/functions/useOnWalletProviderEvent/useOnWalletProviderEvent.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useRegisterPasskey/useRegisterPasskey.d.ts.map +1 -1
- package/dist/hooks/wrappers/functions/useSwitchActiveNetwork/useSwitchActiveNetwork.d.ts.map +1 -1
- package/dist/index.cjs +407 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +404 -62
- package/dist/index.esm.js.map +1 -1
- package/dist/middlewares/invalidateOnEvent/index.d.ts +2 -0
- package/dist/middlewares/invalidateOnEvent/index.d.ts.map +1 -0
- package/dist/middlewares/invalidateOnEvent/invalidateOnEvent.d.ts +29 -0
- package/dist/middlewares/invalidateOnEvent/invalidateOnEvent.d.ts.map +1 -0
- package/dist/middlewares/invalidateOnUserSwitch/index.d.ts +2 -0
- package/dist/middlewares/invalidateOnUserSwitch/index.d.ts.map +1 -0
- package/dist/middlewares/invalidateOnUserSwitch/invalidateOnUserSwitch.d.ts +27 -0
- package/dist/middlewares/invalidateOnUserSwitch/invalidateOnUserSwitch.d.ts.map +1 -0
- package/dist/middlewares/invalidateOnWalletProviderEvent/index.d.ts +2 -0
- package/dist/middlewares/invalidateOnWalletProviderEvent/index.d.ts.map +1 -0
- package/dist/middlewares/invalidateOnWalletProviderEvent/invalidateOnWalletProviderEvent.d.ts +36 -0
- package/dist/middlewares/invalidateOnWalletProviderEvent/invalidateOnWalletProviderEvent.d.ts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
|
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
9
|
var name = "@dynamic-labs-sdk/react-hooks";
|
|
10
|
-
var version = "1.
|
|
10
|
+
var version = "1.18.0";
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/modules/DynamicContext/DynamicContext.ts
|
|
@@ -132,8 +132,8 @@ const QUERY_KEY_PREFIX = [HOOK_KEY_NAMESPACE, "query"];
|
|
|
132
132
|
//#endregion
|
|
133
133
|
//#region src/foundation/useBaseQuery/useBaseQuery.ts
|
|
134
134
|
/**
|
|
135
|
-
* Stable empty default for the `middlewares` param so the common
|
|
136
|
-
*
|
|
135
|
+
* Stable empty default for the `middlewares` param so the common case never
|
|
136
|
+
* allocates a fresh array per render.
|
|
137
137
|
*/
|
|
138
138
|
const EMPTY_MIDDLEWARES = [];
|
|
139
139
|
/**
|
|
@@ -147,24 +147,117 @@ const EMPTY_MIDDLEWARES = [];
|
|
|
147
147
|
* so consumers can opt into retries / custom staleTime / etc.
|
|
148
148
|
* - Callers pass `enabled: false` (typically derived from whether their
|
|
149
149
|
* pseudo-required arguments are present) to short-circuit fetches.
|
|
150
|
-
* - Callers pass `middlewares` (named hooks that
|
|
151
|
-
*
|
|
152
|
-
* `true`.
|
|
150
|
+
* - Callers pass `middlewares` (named hooks that run reactive subscriptions
|
|
151
|
+
* such as cache invalidation); each runs on every render.
|
|
153
152
|
*
|
|
154
153
|
* Returns the full `useQuery` result — `data`, `error`, `isLoading`,
|
|
155
154
|
* `isFetching`, `isSuccess`, `refetch`, `status`, etc.
|
|
156
155
|
*/
|
|
157
156
|
const useBaseQuery = ({ enabled = true, middlewares = EMPTY_MIDDLEWARES, queryFn, queryKey, queryParams }) => {
|
|
158
157
|
const client = useDynamicClient();
|
|
159
|
-
const
|
|
158
|
+
const fullQueryKey = (0, react.useMemo)(() => [...QUERY_KEY_PREFIX, ...queryKey], [queryKey]);
|
|
159
|
+
middlewares.forEach((useMiddleware) => useMiddleware({ queryKey: fullQueryKey }));
|
|
160
160
|
return (0, _tanstack_react_query.useQuery)({
|
|
161
161
|
queryFn: async () => {
|
|
162
162
|
await (0, _dynamic_labs_sdk_client.waitForClientInitialized)(client);
|
|
163
163
|
return queryFn(client);
|
|
164
164
|
},
|
|
165
|
-
queryKey:
|
|
165
|
+
queryKey: fullQueryKey,
|
|
166
166
|
...queryParams,
|
|
167
|
-
enabled: enabled &&
|
|
167
|
+
enabled: enabled && queryParams?.enabled !== false
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/hooks/wrappers/functions/useOnWalletProviderEvent/useOnWalletProviderEvent.ts
|
|
173
|
+
/**
|
|
174
|
+
* Subscribes to an event emitted by a specific wallet provider.
|
|
175
|
+
*
|
|
176
|
+
* Wraps `onWalletProviderEvent` from `@dynamic-labs-sdk/client`. Uses a ref to
|
|
177
|
+
* always call the latest callback without re-subscribing, and cleans up the
|
|
178
|
+
* subscription on unmount or when `event` / `walletProviderKey` change. When
|
|
179
|
+
* `walletProviderKey` is `undefined` the hook subscribes to nothing. When the
|
|
180
|
+
* provider cannot be subscribed to (not registered on this client, or it does
|
|
181
|
+
* not expose `events`), the hook logs and subscribes to nothing rather than
|
|
182
|
+
* throwing — an effect throw would unmount the entire app.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```tsx
|
|
186
|
+
* useOnWalletProviderEvent({
|
|
187
|
+
* walletProviderKey: 'metamaskevm',
|
|
188
|
+
* event: 'accountsChanged',
|
|
189
|
+
* callback: ({ addresses }) => console.log(addresses),
|
|
190
|
+
* });
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
const useOnWalletProviderEvent = ({ callback, event, walletProviderKey }) => {
|
|
194
|
+
const client = useDynamicClient();
|
|
195
|
+
const callbackRef = (0, react.useRef)(callback);
|
|
196
|
+
callbackRef.current = callback;
|
|
197
|
+
(0, react.useEffect)(() => {
|
|
198
|
+
if (walletProviderKey === void 0) return;
|
|
199
|
+
try {
|
|
200
|
+
return (0, _dynamic_labs_sdk_client.onWalletProviderEvent)({
|
|
201
|
+
callback: ((...args) => {
|
|
202
|
+
callbackRef.current(...args);
|
|
203
|
+
}),
|
|
204
|
+
event,
|
|
205
|
+
walletProviderKey
|
|
206
|
+
}, client);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
(0, _dynamic_labs_sdk_client_core.getCore)(client).logger.debug("[useOnWalletProviderEvent] failed to subscribe to wallet provider event", {
|
|
209
|
+
error,
|
|
210
|
+
event,
|
|
211
|
+
walletProviderKey
|
|
212
|
+
});
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
}, [
|
|
216
|
+
event,
|
|
217
|
+
walletProviderKey,
|
|
218
|
+
client
|
|
219
|
+
]);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/middlewares/invalidateOnWalletProviderEvent/invalidateOnWalletProviderEvent.ts
|
|
224
|
+
/**
|
|
225
|
+
* Query middleware factory that refetches the query whenever the given wallet
|
|
226
|
+
* account's provider emits `event` (e.g. `networkChanged`).
|
|
227
|
+
*
|
|
228
|
+
* It only wires up the subscription, invalidating the query's own cache key so
|
|
229
|
+
* any mounted consumer refetches. This replaces the manual
|
|
230
|
+
* `useOnWalletProviderEvent` + `refetch` boilerplate consumers would otherwise
|
|
231
|
+
* pair with the hook. When `walletAccount` is undefined the subscription is a
|
|
232
|
+
* no-op. The subscription lives here, not in `useBaseQuery`.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* useBaseQuery({
|
|
237
|
+
* middlewares: [
|
|
238
|
+
* invalidateOnWalletProviderEvent({ event: 'networkChanged', walletAccount }),
|
|
239
|
+
* ],
|
|
240
|
+
* queryFn: (client) => getActiveNetworkData({ walletAccount }, client),
|
|
241
|
+
* queryKey: ['useGetActiveNetworkData', walletAccount],
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
const invalidateOnWalletProviderEvent = ({ event, walletAccount }) => (context) => {
|
|
246
|
+
const client = useDynamicClient();
|
|
247
|
+
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
248
|
+
useOnWalletProviderEvent({
|
|
249
|
+
callback: () => {
|
|
250
|
+
if (!context) return;
|
|
251
|
+
queryClient.invalidateQueries({ queryKey: context.queryKey }).catch((error) => {
|
|
252
|
+
(0, _dynamic_labs_sdk_client_core.getCore)(client).logger.debug("[invalidateOnWalletProviderEvent] failed to invalidate query", {
|
|
253
|
+
error,
|
|
254
|
+
queryKey: context.queryKey,
|
|
255
|
+
stack: error instanceof Error ? error.stack : void 0
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
event,
|
|
260
|
+
walletProviderKey: walletAccount?.walletProviderKey
|
|
168
261
|
});
|
|
169
262
|
};
|
|
170
263
|
|
|
@@ -179,6 +272,10 @@ const useBaseQuery = ({ enabled = true, middlewares = EMPTY_MIDDLEWARES, queryFn
|
|
|
179
272
|
* ```
|
|
180
273
|
*/
|
|
181
274
|
const useGetActiveNetworkData = ({ queryParams, ...args }) => useBaseQuery({
|
|
275
|
+
middlewares: [invalidateOnWalletProviderEvent({
|
|
276
|
+
event: "networkChanged",
|
|
277
|
+
walletAccount: args.walletAccount
|
|
278
|
+
})],
|
|
182
279
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getActiveNetworkData)(args, client),
|
|
183
280
|
queryKey: ["useGetActiveNetworkData", args],
|
|
184
281
|
queryParams
|
|
@@ -192,6 +289,10 @@ const useGetActiveNetworkData = ({ queryParams, ...args }) => useBaseQuery({
|
|
|
192
289
|
* Wraps `getActiveNetworkId` from `@dynamic-labs-sdk/client`.
|
|
193
290
|
*/
|
|
194
291
|
const useGetActiveNetworkId = ({ queryParams, ...args }) => useBaseQuery({
|
|
292
|
+
middlewares: [invalidateOnWalletProviderEvent({
|
|
293
|
+
event: "networkChanged",
|
|
294
|
+
walletAccount: args.walletAccount
|
|
295
|
+
})],
|
|
195
296
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getActiveNetworkId)(args, client),
|
|
196
297
|
queryKey: ["useGetActiveNetworkId", args],
|
|
197
298
|
queryParams
|
|
@@ -484,11 +585,17 @@ const useBaseState = ({ event, queryKey, queryParams, selector, defaultValue, sk
|
|
|
484
585
|
/**
|
|
485
586
|
* Returns the available wallet providers and their data.
|
|
486
587
|
*
|
|
487
|
-
* Re-renders when
|
|
588
|
+
* Re-renders when the wallet provider registry changes. `walletProviderChanged`
|
|
589
|
+
* fires on register / priority update but NOT on removal, so
|
|
590
|
+
* `walletProviderUnregistered` is wired too — otherwise a removed provider
|
|
591
|
+
* would linger in the returned list.
|
|
488
592
|
*/
|
|
489
593
|
const useGetAvailableWalletProvidersData = () => useBaseState({
|
|
490
594
|
defaultValue: [],
|
|
491
|
-
event:
|
|
595
|
+
event: {
|
|
596
|
+
walletProviderChanged: true,
|
|
597
|
+
walletProviderUnregistered: true
|
|
598
|
+
},
|
|
492
599
|
queryKey: ["useGetAvailableWalletProvidersData"],
|
|
493
600
|
selector: (client) => (0, _dynamic_labs_sdk_client.getAvailableWalletProvidersData)(client)
|
|
494
601
|
});
|
|
@@ -698,14 +805,82 @@ const useConnectAndVerifyWithWalletProvider = ({ mutateParams } = {}) => useBase
|
|
|
698
805
|
mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.connectAndVerifyWithWalletProvider)(variables, client)
|
|
699
806
|
});
|
|
700
807
|
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/hooks/wrappers/functions/useOnEvent/useOnEvent.ts
|
|
810
|
+
/**
|
|
811
|
+
* Subscribes to a Dynamic client event.
|
|
812
|
+
*
|
|
813
|
+
* Uses a ref to always call the latest listener without re-subscribing,
|
|
814
|
+
* and cleans up the subscription on unmount or event name change.
|
|
815
|
+
*/
|
|
816
|
+
const useOnEvent = ({ event, listener }) => {
|
|
817
|
+
const client = useDynamicClient();
|
|
818
|
+
const callbackRef = (0, react.useRef)(listener);
|
|
819
|
+
callbackRef.current = listener;
|
|
820
|
+
(0, react.useEffect)(() => (0, _dynamic_labs_sdk_client.onEvent)({
|
|
821
|
+
event,
|
|
822
|
+
listener: (...args) => {
|
|
823
|
+
callbackRef.current(...args);
|
|
824
|
+
}
|
|
825
|
+
}, client), [event, client]);
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
//#endregion
|
|
829
|
+
//#region src/middlewares/invalidateOnEvent/invalidateOnEvent.ts
|
|
830
|
+
/**
|
|
831
|
+
* Query middleware factory that refetches the query whenever the given client
|
|
832
|
+
* event fires (e.g. `walletAccountsChanged`).
|
|
833
|
+
*
|
|
834
|
+
* It only wires up the subscription, invalidating the query's own cache key so
|
|
835
|
+
* any mounted consumer refetches. This replaces the manual `useOnEvent` +
|
|
836
|
+
* `refetch` boilerplate consumers would otherwise pair with the hook. It is the
|
|
837
|
+
* client-event counterpart to `invalidateOnWalletProviderEvent` (which listens
|
|
838
|
+
* on a single wallet account's provider). The subscription lives here, not in
|
|
839
|
+
* `useBaseQuery`.
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* ```ts
|
|
843
|
+
* useBaseQuery({
|
|
844
|
+
* middlewares: [invalidateOnEvent({ event: 'walletAccountsChanged' })],
|
|
845
|
+
* queryFn: (client) => getConnectedAddresses(args, client),
|
|
846
|
+
* queryKey: ['useGetConnectedAddresses', args],
|
|
847
|
+
* });
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
const invalidateOnEvent = ({ event }) => (context) => {
|
|
851
|
+
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
852
|
+
const client = useDynamicClient();
|
|
853
|
+
useOnEvent({
|
|
854
|
+
event,
|
|
855
|
+
listener: (() => {
|
|
856
|
+
if (!context) return;
|
|
857
|
+
(0, _dynamic_labs_sdk_client_core.getCore)(client).logger.debug("[invalidateOnEvent] invalidating query on event", {
|
|
858
|
+
event,
|
|
859
|
+
queryKey: context.queryKey
|
|
860
|
+
});
|
|
861
|
+
queryClient.invalidateQueries({ queryKey: context.queryKey }).catch((error) => {
|
|
862
|
+
(0, _dynamic_labs_sdk_client_core.getCore)(client).logger.debug("[invalidateOnEvent] failed to invalidate query", {
|
|
863
|
+
error,
|
|
864
|
+
queryKey: context.queryKey,
|
|
865
|
+
stack: error instanceof Error ? error.stack : void 0
|
|
866
|
+
});
|
|
867
|
+
});
|
|
868
|
+
})
|
|
869
|
+
});
|
|
870
|
+
};
|
|
871
|
+
|
|
701
872
|
//#endregion
|
|
702
873
|
//#region src/hooks/wrappers/functions/useGetConnectedAddresses/useGetConnectedAddresses.ts
|
|
703
874
|
/**
|
|
704
875
|
* Returns the connected addresses for the given wallet provider.
|
|
705
876
|
*
|
|
706
|
-
* Wraps `getConnectedAddresses` from `@dynamic-labs-sdk/client`.
|
|
877
|
+
* Wraps `getConnectedAddresses` from `@dynamic-labs-sdk/client`. Automatically
|
|
878
|
+
* refetches when wallet accounts change (connect / disconnect / verify), so
|
|
879
|
+
* consumers don't have to pair it with a manual `walletAccountsChanged`
|
|
880
|
+
* listener.
|
|
707
881
|
*/
|
|
708
882
|
const useGetConnectedAddresses = ({ queryParams, ...args }) => useBaseQuery({
|
|
883
|
+
middlewares: [invalidateOnEvent({ event: "walletAccountsChanged" })],
|
|
709
884
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getConnectedAddresses)(args, client),
|
|
710
885
|
queryKey: ["useGetConnectedAddresses", args],
|
|
711
886
|
queryParams
|
|
@@ -837,6 +1012,7 @@ const useDeleteMfaDevice = ({ mutateParams } = {}) => {
|
|
|
837
1012
|
* ```
|
|
838
1013
|
*/
|
|
839
1014
|
const useDeletePasskey = ({ mutateParams } = {}) => useBaseMutation({
|
|
1015
|
+
middlewares: [invalidatesQueries("useGetPasskeys")],
|
|
840
1016
|
mutateParams,
|
|
841
1017
|
mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.deletePasskey)(variables, client)
|
|
842
1018
|
});
|
|
@@ -863,26 +1039,6 @@ const useDeleteUser = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
863
1039
|
mutationFn: ({ client }) => (0, _dynamic_labs_sdk_client.deleteUser)(client)
|
|
864
1040
|
});
|
|
865
1041
|
|
|
866
|
-
//#endregion
|
|
867
|
-
//#region src/hooks/wrappers/functions/useOnEvent/useOnEvent.ts
|
|
868
|
-
/**
|
|
869
|
-
* Subscribes to a Dynamic client event.
|
|
870
|
-
*
|
|
871
|
-
* Uses a ref to always call the latest listener without re-subscribing,
|
|
872
|
-
* and cleans up the subscription on unmount or event name change.
|
|
873
|
-
*/
|
|
874
|
-
const useOnEvent = ({ event, listener }) => {
|
|
875
|
-
const client = useDynamicClient();
|
|
876
|
-
const callbackRef = (0, react.useRef)(listener);
|
|
877
|
-
callbackRef.current = listener;
|
|
878
|
-
(0, react.useEffect)(() => (0, _dynamic_labs_sdk_client.onEvent)({
|
|
879
|
-
event,
|
|
880
|
-
listener: (...args) => {
|
|
881
|
-
callbackRef.current(...args);
|
|
882
|
-
}
|
|
883
|
-
}, client), [event, client]);
|
|
884
|
-
};
|
|
885
|
-
|
|
886
1042
|
//#endregion
|
|
887
1043
|
//#region src/hooks/wrappers/functions/useExecuteSwapTransaction/useExecuteSwapTransaction.ts
|
|
888
1044
|
/**
|
|
@@ -961,17 +1117,73 @@ const usePrepareFlowSigning = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
961
1117
|
mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.prepareFlowSigning)(variables, client)
|
|
962
1118
|
});
|
|
963
1119
|
|
|
1120
|
+
//#endregion
|
|
1121
|
+
//#region src/middlewares/invalidateOnUserSwitch/invalidateOnUserSwitch.ts
|
|
1122
|
+
const USER_CHANGED_EVENT = "userChanged";
|
|
1123
|
+
/**
|
|
1124
|
+
* Query middleware factory that refetches the query when a *different* user
|
|
1125
|
+
* becomes the current user (login or account switch).
|
|
1126
|
+
*
|
|
1127
|
+
* Unlike `invalidateOnEvent({ event: 'userChanged' })`, this never invalidates
|
|
1128
|
+
* on:
|
|
1129
|
+
* - logout (the user becomes `undefined`) — the refetch would just 401 and the
|
|
1130
|
+
* cleared session leaves nothing to refetch; and
|
|
1131
|
+
* - same-user `userChanged` fires (e.g. linking a credential or a profile
|
|
1132
|
+
* update) — the data still belongs to the same user, whose own mutations
|
|
1133
|
+
* already invalidate it within the session.
|
|
1134
|
+
*
|
|
1135
|
+
* It tracks the previous user id across renders (seeded from the user present
|
|
1136
|
+
* at mount) and only invalidates when the new id is defined and differs.
|
|
1137
|
+
*
|
|
1138
|
+
* @example
|
|
1139
|
+
* ```ts
|
|
1140
|
+
* useBaseQuery({
|
|
1141
|
+
* middlewares: [invalidateOnUserSwitch()],
|
|
1142
|
+
* queryFn: (client) => getMfaDevices(client),
|
|
1143
|
+
* queryKey: ['useGetMfaDevices'],
|
|
1144
|
+
* });
|
|
1145
|
+
* ```
|
|
1146
|
+
*/
|
|
1147
|
+
const invalidateOnUserSwitch = () => (context) => {
|
|
1148
|
+
const client = useDynamicClient();
|
|
1149
|
+
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
1150
|
+
const previousUserIdRef = (0, react.useRef)(client.user?.id);
|
|
1151
|
+
useOnEvent({
|
|
1152
|
+
event: USER_CHANGED_EVENT,
|
|
1153
|
+
listener: ((args) => {
|
|
1154
|
+
const nextUserId = args.user?.id;
|
|
1155
|
+
const previousUserId = previousUserIdRef.current;
|
|
1156
|
+
previousUserIdRef.current = nextUserId;
|
|
1157
|
+
if (nextUserId === void 0 || nextUserId === previousUserId) return;
|
|
1158
|
+
if (!context) return;
|
|
1159
|
+
(0, _dynamic_labs_sdk_client_core.getCore)(client).logger.debug("[invalidateOnUserSwitch] invalidating query on new user", { queryKey: context.queryKey });
|
|
1160
|
+
queryClient.invalidateQueries({ queryKey: context.queryKey }).catch((error) => {
|
|
1161
|
+
(0, _dynamic_labs_sdk_client_core.getCore)(client).logger.debug("[invalidateOnUserSwitch] failed to invalidate query", {
|
|
1162
|
+
error,
|
|
1163
|
+
queryKey: context.queryKey,
|
|
1164
|
+
stack: error instanceof Error ? error.stack : void 0
|
|
1165
|
+
});
|
|
1166
|
+
});
|
|
1167
|
+
})
|
|
1168
|
+
});
|
|
1169
|
+
};
|
|
1170
|
+
|
|
964
1171
|
//#endregion
|
|
965
1172
|
//#region src/hooks/wrappers/functions/useGetGoogleDriveBackupReadiness/useGetGoogleDriveBackupReadiness.ts
|
|
966
1173
|
/**
|
|
967
1174
|
* Wraps `getGoogleDriveBackupReadiness` from `@dynamic-labs-sdk/client`. Reports whether the user's Google Drive backup is set up and available.
|
|
968
1175
|
*
|
|
1176
|
+
* Automatically refetches when a different user becomes current (login or
|
|
1177
|
+
* account switch), so consumers don't have to pair it with a manual
|
|
1178
|
+
* `userChanged` listener.
|
|
1179
|
+
*
|
|
969
1180
|
* @example
|
|
970
1181
|
* ```tsx
|
|
971
1182
|
* const { data: readiness, isLoading } = useGetGoogleDriveBackupReadiness();
|
|
972
1183
|
* ```
|
|
973
1184
|
*/
|
|
974
1185
|
const useGetGoogleDriveBackupReadiness = ({ queryParams } = {}) => useBaseQuery({
|
|
1186
|
+
middlewares: [invalidateOnUserSwitch()],
|
|
975
1187
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getGoogleDriveBackupReadiness)(client),
|
|
976
1188
|
queryKey: ["useGetGoogleDriveBackupReadiness"],
|
|
977
1189
|
queryParams
|
|
@@ -995,12 +1207,17 @@ const useIsMfaRequiredForAction = ({ queryParams, ...args }) => useBaseQuery({
|
|
|
995
1207
|
/**
|
|
996
1208
|
* Wraps `getKrakenAccounts` from `@dynamic-labs-sdk/client`. Returns the authenticated user's Kraken accounts (with balances), optionally filtered by chain/network.
|
|
997
1209
|
*
|
|
1210
|
+
* Automatically refetches when a different user becomes current (login or
|
|
1211
|
+
* account switch), so consumers don't have to pair it with a manual
|
|
1212
|
+
* `userChanged` listener.
|
|
1213
|
+
*
|
|
998
1214
|
* @example
|
|
999
1215
|
* ```tsx
|
|
1000
1216
|
* const { data: accounts, isLoading } = useGetKrakenAccounts();
|
|
1001
1217
|
* ```
|
|
1002
1218
|
*/
|
|
1003
1219
|
const useGetKrakenAccounts = ({ queryParams, ...args } = {}) => useBaseQuery({
|
|
1220
|
+
middlewares: [invalidateOnUserSwitch()],
|
|
1004
1221
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getKrakenAccounts)(args, client),
|
|
1005
1222
|
queryKey: ["useGetKrakenAccounts", args],
|
|
1006
1223
|
queryParams
|
|
@@ -1027,12 +1244,17 @@ const useCreateKrakenExchangeTransfer = ({ mutateParams } = {}) => useBaseMutati
|
|
|
1027
1244
|
/**
|
|
1028
1245
|
* Wraps `getKrakenWhitelistedAddresses` from `@dynamic-labs-sdk/client`. Returns the destination addresses whitelisted for Kraken withdrawals.
|
|
1029
1246
|
*
|
|
1247
|
+
* Automatically refetches when a different user becomes current (login or
|
|
1248
|
+
* account switch), so consumers don't have to pair it with a manual
|
|
1249
|
+
* `userChanged` listener.
|
|
1250
|
+
*
|
|
1030
1251
|
* @example
|
|
1031
1252
|
* ```tsx
|
|
1032
1253
|
* const { data: addresses, isLoading } = useGetKrakenWhitelistedAddresses();
|
|
1033
1254
|
* ```
|
|
1034
1255
|
*/
|
|
1035
1256
|
const useGetKrakenWhitelistedAddresses = ({ queryParams } = {}) => useBaseQuery({
|
|
1257
|
+
middlewares: [invalidateOnUserSwitch()],
|
|
1036
1258
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getKrakenWhitelistedAddresses)(client),
|
|
1037
1259
|
queryKey: ["useGetKrakenWhitelistedAddresses"],
|
|
1038
1260
|
queryParams
|
|
@@ -1065,12 +1287,17 @@ const useLogout = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
1065
1287
|
*
|
|
1066
1288
|
* Wraps `getMfaDevices` from `@dynamic-labs-sdk/client`.
|
|
1067
1289
|
*
|
|
1290
|
+
* Automatically refetches when a different user becomes current (login or
|
|
1291
|
+
* account switch), so consumers don't have to pair it with a manual
|
|
1292
|
+
* `userChanged` listener.
|
|
1293
|
+
*
|
|
1068
1294
|
* @example
|
|
1069
1295
|
* ```tsx
|
|
1070
1296
|
* const { data: mfaDevices, isLoading, refetch } = useGetMfaDevices();
|
|
1071
1297
|
* ```
|
|
1072
1298
|
*/
|
|
1073
1299
|
const useGetMfaDevices = ({ queryParams } = {}) => useBaseQuery({
|
|
1300
|
+
middlewares: [invalidateOnUserSwitch()],
|
|
1074
1301
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getMfaDevices)(client),
|
|
1075
1302
|
queryKey: ["useGetMfaDevices"],
|
|
1076
1303
|
queryParams
|
|
@@ -1084,12 +1311,17 @@ const useGetMfaDevices = ({ queryParams } = {}) => useBaseQuery({
|
|
|
1084
1311
|
*
|
|
1085
1312
|
* Wraps `getMfaMethods` from `@dynamic-labs-sdk/client`.
|
|
1086
1313
|
*
|
|
1314
|
+
* Automatically refetches when a different user becomes current (login or
|
|
1315
|
+
* account switch), so consumers don't have to pair it with a manual
|
|
1316
|
+
* `userChanged` listener.
|
|
1317
|
+
*
|
|
1087
1318
|
* @example
|
|
1088
1319
|
* ```tsx
|
|
1089
1320
|
* const { data: mfaMethods, isLoading, refetch } = useGetMfaMethods();
|
|
1090
1321
|
* ```
|
|
1091
1322
|
*/
|
|
1092
1323
|
const useGetMfaMethods = ({ queryParams } = {}) => useBaseQuery({
|
|
1324
|
+
middlewares: [invalidateOnUserSwitch()],
|
|
1093
1325
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getMfaMethods)(client),
|
|
1094
1326
|
queryKey: ["useGetMfaMethods"],
|
|
1095
1327
|
queryParams
|
|
@@ -1102,12 +1334,17 @@ const useGetMfaMethods = ({ queryParams } = {}) => useBaseQuery({
|
|
|
1102
1334
|
*
|
|
1103
1335
|
* Wraps `getMfaRecoveryCodes` from `@dynamic-labs-sdk/client`.
|
|
1104
1336
|
*
|
|
1337
|
+
* Automatically refetches when a different user becomes current (login or
|
|
1338
|
+
* account switch), so consumers don't have to pair it with a manual
|
|
1339
|
+
* `userChanged` listener.
|
|
1340
|
+
*
|
|
1105
1341
|
* @example
|
|
1106
1342
|
* ```tsx
|
|
1107
1343
|
* const { data: recoveryCodes, isLoading, refetch } = useGetMfaRecoveryCodes();
|
|
1108
1344
|
* ```
|
|
1109
1345
|
*/
|
|
1110
1346
|
const useGetMfaRecoveryCodes = ({ queryParams } = {}) => useBaseQuery({
|
|
1347
|
+
middlewares: [invalidateOnUserSwitch()],
|
|
1111
1348
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getMfaRecoveryCodes)(client),
|
|
1112
1349
|
queryKey: ["useGetMfaRecoveryCodes"],
|
|
1113
1350
|
queryParams
|
|
@@ -1185,6 +1422,10 @@ const useGetMultichainTokenBalances = ({ balanceRequest, queryParams }) => useBa
|
|
|
1185
1422
|
*/
|
|
1186
1423
|
const useGetNativeBalance = ({ walletAccount, queryParams }) => useBaseQuery({
|
|
1187
1424
|
enabled: walletAccount !== void 0,
|
|
1425
|
+
middlewares: [invalidateOnWalletProviderEvent({
|
|
1426
|
+
event: "networkChanged",
|
|
1427
|
+
walletAccount
|
|
1428
|
+
})],
|
|
1188
1429
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getNativeBalance)({ walletAccount }, client),
|
|
1189
1430
|
queryKey: ["useGetNativeBalance", walletAccount?.id],
|
|
1190
1431
|
queryParams
|
|
@@ -1226,12 +1467,17 @@ const useOnceEvent = ({ event, listener }) => {
|
|
|
1226
1467
|
*
|
|
1227
1468
|
* Wraps `getPasskeys` from `@dynamic-labs-sdk/client`.
|
|
1228
1469
|
*
|
|
1470
|
+
* Automatically refetches when a different user becomes current (login or
|
|
1471
|
+
* account switch), so consumers don't have to pair it with a manual
|
|
1472
|
+
* `userChanged` listener.
|
|
1473
|
+
*
|
|
1229
1474
|
* @example
|
|
1230
1475
|
* ```tsx
|
|
1231
1476
|
* const { data: passkeys, isLoading, refetch } = useGetPasskeys();
|
|
1232
1477
|
* ```
|
|
1233
1478
|
*/
|
|
1234
1479
|
const useGetPasskeys = ({ queryParams } = {}) => useBaseQuery({
|
|
1480
|
+
middlewares: [invalidateOnUserSwitch()],
|
|
1235
1481
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getPasskeys)(client),
|
|
1236
1482
|
queryKey: ["useGetPasskeys"],
|
|
1237
1483
|
queryParams
|
|
@@ -1281,12 +1527,17 @@ const useRefreshAuth = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
1281
1527
|
* {@link useRevokeRegisteredDevice} to let users revoke a device from the
|
|
1282
1528
|
* list.
|
|
1283
1529
|
*
|
|
1530
|
+
* Automatically refetches when a different user becomes current (login or
|
|
1531
|
+
* account switch), so consumers don't have to pair it with a manual
|
|
1532
|
+
* `userChanged` listener.
|
|
1533
|
+
*
|
|
1284
1534
|
* @example
|
|
1285
1535
|
* ```tsx
|
|
1286
1536
|
* const { data: devices, isLoading, refetch } = useGetRegisteredDevices();
|
|
1287
1537
|
* ```
|
|
1288
1538
|
*/
|
|
1289
1539
|
const useGetRegisteredDevices = ({ queryParams } = {}) => useBaseQuery({
|
|
1540
|
+
middlewares: [invalidateOnUserSwitch()],
|
|
1290
1541
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getRegisteredDevices)(client),
|
|
1291
1542
|
queryKey: ["useGetRegisteredDevices"],
|
|
1292
1543
|
queryParams
|
|
@@ -1310,6 +1561,7 @@ const useGetRegisteredDevices = ({ queryParams } = {}) => useBaseQuery({
|
|
|
1310
1561
|
* ```
|
|
1311
1562
|
*/
|
|
1312
1563
|
const useRegisterPasskey = ({ mutateParams } = {}) => useBaseMutation({
|
|
1564
|
+
middlewares: [invalidatesQueries("useGetPasskeys")],
|
|
1313
1565
|
mutateParams,
|
|
1314
1566
|
mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.registerPasskey)(variables, client)
|
|
1315
1567
|
});
|
|
@@ -1680,6 +1932,7 @@ const useGetSwapStatus = ({ queryParams, ...args }) => useBaseQuery({
|
|
|
1680
1932
|
* ```
|
|
1681
1933
|
*/
|
|
1682
1934
|
const useSwitchActiveNetwork = ({ mutateParams } = {}) => useBaseMutation({
|
|
1935
|
+
middlewares: [invalidatesQueries("useGetActiveNetworkData", "useGetActiveNetworkId")],
|
|
1683
1936
|
mutateParams,
|
|
1684
1937
|
mutationFn: ({ client, variables }) => (0, _dynamic_labs_sdk_client.switchActiveNetwork)(variables, client)
|
|
1685
1938
|
});
|
|
@@ -1703,6 +1956,10 @@ const useSwitchActiveNetwork = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
1703
1956
|
*/
|
|
1704
1957
|
const useGetTokenBalances = ({ walletAccount, queryParams, ...rest }) => useBaseQuery({
|
|
1705
1958
|
enabled: walletAccount !== void 0,
|
|
1959
|
+
middlewares: [invalidateOnWalletProviderEvent({
|
|
1960
|
+
event: "networkChanged",
|
|
1961
|
+
walletAccount
|
|
1962
|
+
})],
|
|
1706
1963
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getTokenBalances)({
|
|
1707
1964
|
walletAccount,
|
|
1708
1965
|
...rest
|
|
@@ -1845,13 +2102,15 @@ const useUpdateUser = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
1845
2102
|
/**
|
|
1846
2103
|
* Returns the current user's linked social accounts.
|
|
1847
2104
|
*
|
|
1848
|
-
* Re-renders when the user changes.
|
|
2105
|
+
* Re-renders when the user changes. Resolves to an empty list while no user is
|
|
2106
|
+
* authenticated — the guard is required because the selector runs synchronously
|
|
2107
|
+
* and `getUserSocialAccounts` throws (`assertDefined`) when there is no user.
|
|
1849
2108
|
*/
|
|
1850
2109
|
const useGetUserSocialAccounts = () => useBaseState({
|
|
1851
2110
|
defaultValue: [],
|
|
1852
2111
|
event: "userChanged",
|
|
1853
2112
|
queryKey: ["useGetUserSocialAccounts"],
|
|
1854
|
-
selector: (client) => (0, _dynamic_labs_sdk_client.getUserSocialAccounts)(client)
|
|
2113
|
+
selector: (client) => client.user ? (0, _dynamic_labs_sdk_client.getUserSocialAccounts)(client) : []
|
|
1855
2114
|
});
|
|
1856
2115
|
|
|
1857
2116
|
//#endregion
|
|
@@ -1965,53 +2224,136 @@ const useGetWalletConnectCatalogWalletByWalletProviderKey = ({ queryParams, ...a
|
|
|
1965
2224
|
//#endregion
|
|
1966
2225
|
//#region src/hooks/wrappers/functions/useGetWalletOptionsCatalogue/useGetWalletOptionsCatalogue.ts
|
|
1967
2226
|
/**
|
|
2227
|
+
* Freshness window for the catalogue, in milliseconds.
|
|
2228
|
+
*
|
|
2229
|
+
* The catalogue is derived from two near-static sources: the in-memory wallet
|
|
2230
|
+
* provider registry and the wallet-book document served from a CDN. With
|
|
2231
|
+
* react-query's default `staleTime: 0` the data is stale the instant it
|
|
2232
|
+
* arrives, so every new mount/observer (e.g. reopening the wallet list)
|
|
2233
|
+
* refetches the CDN document even though nothing changed — needlessly
|
|
2234
|
+
* hammering the CDN. A 1h window serves cached data to remounts; the registry
|
|
2235
|
+
* event middlewares below still force an immediate refetch on any real change,
|
|
2236
|
+
* so reactivity is preserved.
|
|
2237
|
+
*/
|
|
2238
|
+
const CATALOGUE_STALE_TIME_MS = 36e5;
|
|
2239
|
+
/**
|
|
1968
2240
|
* Wraps `getWalletOptionsCatalogue` from `@dynamic-labs-sdk/client`. Returns the catalogue of wallet options the project supports.
|
|
1969
2241
|
*
|
|
2242
|
+
* Automatically refetches when the wallet provider registry changes: EIP-6963
|
|
2243
|
+
* wallets fill the registry asynchronously after mount, and the registry emits
|
|
2244
|
+
* `walletProviderChanged` (on register / priority update) and
|
|
2245
|
+
* `walletProviderUnregistered` (on removal). Wiring both keeps the catalogue in
|
|
2246
|
+
* sync without consumers pairing the hook with a manual listener.
|
|
2247
|
+
*
|
|
1970
2248
|
* @example
|
|
1971
2249
|
* ```tsx
|
|
1972
2250
|
* const { data: catalogue, isLoading } = useGetWalletOptionsCatalogue();
|
|
1973
2251
|
* ```
|
|
1974
2252
|
*/
|
|
1975
2253
|
const useGetWalletOptionsCatalogue = ({ queryParams, ...args } = {}) => useBaseQuery({
|
|
2254
|
+
middlewares: [invalidateOnEvent({ event: "walletProviderChanged" }), invalidateOnEvent({ event: "walletProviderUnregistered" })],
|
|
1976
2255
|
queryFn: (client) => (0, _dynamic_labs_sdk_client.getWalletOptionsCatalogue)(args, client),
|
|
1977
2256
|
queryKey: ["useGetWalletOptionsCatalogue", args],
|
|
1978
|
-
queryParams
|
|
2257
|
+
queryParams: {
|
|
2258
|
+
retry: false,
|
|
2259
|
+
staleTime: CATALOGUE_STALE_TIME_MS,
|
|
2260
|
+
...queryParams
|
|
2261
|
+
}
|
|
1979
2262
|
});
|
|
1980
2263
|
|
|
1981
2264
|
//#endregion
|
|
1982
|
-
//#region src/hooks/wrappers/functions/
|
|
2265
|
+
//#region src/hooks/wrappers/functions/useGetWalletProviderDataByKey/useGetWalletProviderDataByKey.ts
|
|
1983
2266
|
/**
|
|
1984
|
-
*
|
|
2267
|
+
* Wraps `getWalletProviderDataByKey` from `@dynamic-labs-sdk/client`. Returns
|
|
2268
|
+
* the display/connection data for a single wallet provider, by key.
|
|
1985
2269
|
*
|
|
1986
|
-
*
|
|
1987
|
-
*
|
|
1988
|
-
*
|
|
2270
|
+
* The underlying data is read from the in-memory wallet provider registry,
|
|
2271
|
+
* which EIP-6963 wallets fill asynchronously after mount. The registry emits
|
|
2272
|
+
* `walletProviderChanged` on register / priority update, so wiring it keeps the
|
|
2273
|
+
* provider data in sync without consumers pairing the hook with a manual
|
|
2274
|
+
* `useOnEvent` + `refetch` listener.
|
|
2275
|
+
*
|
|
2276
|
+
* `walletProviderUnregistered` is intentionally not wired here: this hook reads
|
|
2277
|
+
* a single key, and once that key is removed there is no replacement data to
|
|
2278
|
+
* fetch — refetching would only make `getWalletProviderDataByKey` throw
|
|
2279
|
+
* `NoWalletProviderFoundError`. Skipping it keeps the last-known data instead of
|
|
2280
|
+
* forcing the query into an error state.
|
|
1989
2281
|
*
|
|
1990
2282
|
* @example
|
|
1991
2283
|
* ```tsx
|
|
1992
|
-
*
|
|
1993
|
-
* walletProviderKey
|
|
1994
|
-
* event: 'accountsChanged',
|
|
1995
|
-
* callback: ({ addresses }) => console.log(addresses),
|
|
2284
|
+
* const { data: walletProviderData } = useGetWalletProviderDataByKey({
|
|
2285
|
+
* walletProviderKey,
|
|
1996
2286
|
* });
|
|
1997
2287
|
* ```
|
|
1998
2288
|
*/
|
|
1999
|
-
const
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2289
|
+
const useGetWalletProviderDataByKey = ({ queryParams, ...args }) => useBaseQuery({
|
|
2290
|
+
middlewares: [invalidateOnEvent({ event: "walletProviderChanged" })],
|
|
2291
|
+
queryFn: (client) => Promise.resolve((0, _dynamic_labs_sdk_client.getWalletProviderDataByKey)(args, client)),
|
|
2292
|
+
queryKey: ["useGetWalletProviderDataByKey", args],
|
|
2293
|
+
queryParams
|
|
2294
|
+
});
|
|
2295
|
+
|
|
2296
|
+
//#endregion
|
|
2297
|
+
//#region src/hooks/wrappers/functions/useIsDeviceRegistrationRequired/useIsDeviceRegistrationRequired.ts
|
|
2298
|
+
/**
|
|
2299
|
+
* Returns whether the current user still needs to register this device.
|
|
2300
|
+
*
|
|
2301
|
+
* Re-renders when the user changes (login, logout, completing device
|
|
2302
|
+
* registration). Resolves to `false` while no user is authenticated.
|
|
2303
|
+
*/
|
|
2304
|
+
const useIsDeviceRegistrationRequired = () => useBaseState({
|
|
2305
|
+
defaultValue: false,
|
|
2306
|
+
event: "userChanged",
|
|
2307
|
+
queryKey: ["useIsDeviceRegistrationRequired"],
|
|
2308
|
+
selector: (client) => client.user ? (0, _dynamic_labs_sdk_client.isDeviceRegistrationRequired)(client.user) : false
|
|
2309
|
+
});
|
|
2310
|
+
|
|
2311
|
+
//#endregion
|
|
2312
|
+
//#region src/hooks/wrappers/functions/useIsUserMissingMfaAuth/useIsUserMissingMfaAuth.ts
|
|
2313
|
+
/**
|
|
2314
|
+
* Returns whether the current user still needs to complete an MFA challenge.
|
|
2315
|
+
*
|
|
2316
|
+
* Re-renders when the user changes (login, logout, completing the MFA
|
|
2317
|
+
* challenge). Resolves to `false` while no user is authenticated.
|
|
2318
|
+
*/
|
|
2319
|
+
const useIsUserMissingMfaAuth = () => useBaseState({
|
|
2320
|
+
defaultValue: false,
|
|
2321
|
+
event: "userChanged",
|
|
2322
|
+
queryKey: ["useIsUserMissingMfaAuth"],
|
|
2323
|
+
selector: (client) => client.user ? (0, _dynamic_labs_sdk_client.isUserMissingMfaAuth)(client) : false
|
|
2324
|
+
});
|
|
2325
|
+
|
|
2326
|
+
//#endregion
|
|
2327
|
+
//#region src/hooks/wrappers/functions/useIsPendingRecoveryCodesAcknowledgment/useIsPendingRecoveryCodesAcknowledgment.ts
|
|
2328
|
+
/**
|
|
2329
|
+
* Returns whether the current user still needs to acknowledge their MFA
|
|
2330
|
+
* recovery codes.
|
|
2331
|
+
*
|
|
2332
|
+
* Re-renders when the user changes (login, logout, acknowledging the recovery
|
|
2333
|
+
* codes). Resolves to `false` while no user is authenticated.
|
|
2334
|
+
*/
|
|
2335
|
+
const useIsPendingRecoveryCodesAcknowledgment = () => useBaseState({
|
|
2336
|
+
defaultValue: false,
|
|
2337
|
+
event: "userChanged",
|
|
2338
|
+
queryKey: ["useIsPendingRecoveryCodesAcknowledgment"],
|
|
2339
|
+
selector: (client) => client.user ? (0, _dynamic_labs_sdk_client.isPendingRecoveryCodesAcknowledgment)(client) : false
|
|
2340
|
+
});
|
|
2341
|
+
|
|
2342
|
+
//#endregion
|
|
2343
|
+
//#region src/hooks/wrappers/functions/useIsUserOnboardingComplete/useIsUserOnboardingComplete.ts
|
|
2344
|
+
/**
|
|
2345
|
+
* Returns whether the current user has completed every onboarding requirement
|
|
2346
|
+
* (KYC fields, MFA, recovery codes acknowledgment, device registration).
|
|
2347
|
+
*
|
|
2348
|
+
* Re-renders when the user changes (login, logout, completing any onboarding
|
|
2349
|
+
* step). Resolves to `false` while no user is authenticated.
|
|
2350
|
+
*/
|
|
2351
|
+
const useIsUserOnboardingComplete = () => useBaseState({
|
|
2352
|
+
defaultValue: false,
|
|
2353
|
+
event: "userChanged",
|
|
2354
|
+
queryKey: ["useIsUserOnboardingComplete"],
|
|
2355
|
+
selector: (client) => client.user ? (0, _dynamic_labs_sdk_client.isUserOnboardingComplete)(client) : false
|
|
2356
|
+
});
|
|
2015
2357
|
|
|
2016
2358
|
//#endregion
|
|
2017
2359
|
//#region src/hooks/wrappers/state/useInitStatus/useInitStatus.ts
|
|
@@ -2144,8 +2486,13 @@ exports.useGetWalletAccounts = useGetWalletAccounts;
|
|
|
2144
2486
|
exports.useGetWalletConnectCatalog = useGetWalletConnectCatalog;
|
|
2145
2487
|
exports.useGetWalletConnectCatalogWalletByWalletProviderKey = useGetWalletConnectCatalogWalletByWalletProviderKey;
|
|
2146
2488
|
exports.useGetWalletOptionsCatalogue = useGetWalletOptionsCatalogue;
|
|
2489
|
+
exports.useGetWalletProviderDataByKey = useGetWalletProviderDataByKey;
|
|
2147
2490
|
exports.useInitStatus = useInitStatus;
|
|
2491
|
+
exports.useIsDeviceRegistrationRequired = useIsDeviceRegistrationRequired;
|
|
2148
2492
|
exports.useIsMfaRequiredForAction = useIsMfaRequiredForAction;
|
|
2493
|
+
exports.useIsPendingRecoveryCodesAcknowledgment = useIsPendingRecoveryCodesAcknowledgment;
|
|
2494
|
+
exports.useIsUserMissingMfaAuth = useIsUserMissingMfaAuth;
|
|
2495
|
+
exports.useIsUserOnboardingComplete = useIsUserOnboardingComplete;
|
|
2149
2496
|
exports.useLogout = useLogout;
|
|
2150
2497
|
exports.useOnEvent = useOnEvent;
|
|
2151
2498
|
exports.useOnWalletProviderEvent = useOnWalletProviderEvent;
|