@dynamic-labs-sdk/react-hooks 1.6.0 → 1.7.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 +23 -1
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/hooks/useAcknowledgeRecoveryCodes/index.d.ts +2 -0
- package/dist/hooks/useAcknowledgeRecoveryCodes/index.d.ts.map +1 -0
- package/dist/hooks/useAcknowledgeRecoveryCodes/useAcknowledgeRecoveryCodes.d.ts +24 -0
- package/dist/hooks/useAcknowledgeRecoveryCodes/useAcknowledgeRecoveryCodes.d.ts.map +1 -0
- package/dist/hooks/useActiveNetworkData/index.d.ts +2 -0
- package/dist/hooks/useActiveNetworkData/index.d.ts.map +1 -0
- package/dist/hooks/useActiveNetworkData/useActiveNetworkData.d.ts +24 -0
- package/dist/hooks/useActiveNetworkData/useActiveNetworkData.d.ts.map +1 -0
- package/dist/hooks/useAddNetwork/index.d.ts +2 -0
- package/dist/hooks/useAddNetwork/index.d.ts.map +1 -0
- package/dist/hooks/useAddNetwork/useAddNetwork.d.ts +31 -0
- package/dist/hooks/useAddNetwork/useAddNetwork.d.ts.map +1 -0
- package/dist/hooks/useBalanceForAddress/index.d.ts +2 -0
- package/dist/hooks/useBalanceForAddress/index.d.ts.map +1 -0
- package/dist/hooks/useBalanceForAddress/useBalanceForAddress.d.ts +24 -0
- package/dist/hooks/useBalanceForAddress/useBalanceForAddress.d.ts.map +1 -0
- package/dist/hooks/useCoinbaseBuyUrl/index.d.ts +2 -0
- package/dist/hooks/useCoinbaseBuyUrl/index.d.ts.map +1 -0
- package/dist/hooks/useCoinbaseBuyUrl/useCoinbaseBuyUrl.d.ts +22 -0
- package/dist/hooks/useCoinbaseBuyUrl/useCoinbaseBuyUrl.d.ts.map +1 -0
- package/dist/hooks/useCompleteDeviceRegistration/index.d.ts +2 -0
- package/dist/hooks/useCompleteDeviceRegistration/index.d.ts.map +1 -0
- package/dist/hooks/useCompleteDeviceRegistration/useCompleteDeviceRegistration.d.ts +26 -0
- package/dist/hooks/useCompleteDeviceRegistration/useCompleteDeviceRegistration.d.ts.map +1 -0
- package/dist/hooks/useCompleteSocialRedirect/index.d.ts +2 -0
- package/dist/hooks/useCompleteSocialRedirect/index.d.ts.map +1 -0
- package/dist/hooks/useCompleteSocialRedirect/useCompleteSocialRedirect.d.ts +24 -0
- package/dist/hooks/useCompleteSocialRedirect/useCompleteSocialRedirect.d.ts.map +1 -0
- package/dist/hooks/useConfirmTransaction/index.d.ts +2 -0
- package/dist/hooks/useConfirmTransaction/index.d.ts.map +1 -0
- package/dist/hooks/useConfirmTransaction/useConfirmTransaction.d.ts +23 -0
- package/dist/hooks/useConfirmTransaction/useConfirmTransaction.d.ts.map +1 -0
- package/dist/hooks/useCreateCoinbaseOnrampOrder/index.d.ts +2 -0
- package/dist/hooks/useCreateCoinbaseOnrampOrder/index.d.ts.map +1 -0
- package/dist/hooks/useCreateCoinbaseOnrampOrder/useCreateCoinbaseOnrampOrder.d.ts +23 -0
- package/dist/hooks/useCreateCoinbaseOnrampOrder/useCreateCoinbaseOnrampOrder.d.ts.map +1 -0
- package/dist/hooks/useCreateCryptoDotComPayment/index.d.ts +2 -0
- package/dist/hooks/useCreateCryptoDotComPayment/index.d.ts.map +1 -0
- package/dist/hooks/useCreateCryptoDotComPayment/useCreateCryptoDotComPayment.d.ts +24 -0
- package/dist/hooks/useCreateCryptoDotComPayment/useCreateCryptoDotComPayment.d.ts.map +1 -0
- package/dist/hooks/useExecuteSwapTransaction/index.d.ts +2 -0
- package/dist/hooks/useExecuteSwapTransaction/index.d.ts.map +1 -0
- package/dist/hooks/useExecuteSwapTransaction/useExecuteSwapTransaction.d.ts +25 -0
- package/dist/hooks/useExecuteSwapTransaction/useExecuteSwapTransaction.d.ts.map +1 -0
- package/dist/hooks/useGoogleDriveBackupReadiness/index.d.ts +2 -0
- package/dist/hooks/useGoogleDriveBackupReadiness/index.d.ts.map +1 -0
- package/dist/hooks/useGoogleDriveBackupReadiness/useGoogleDriveBackupReadiness.d.ts +21 -0
- package/dist/hooks/useGoogleDriveBackupReadiness/useGoogleDriveBackupReadiness.d.ts.map +1 -0
- package/dist/hooks/useKrakenWhitelistedAddresses/index.d.ts +2 -0
- package/dist/hooks/useKrakenWhitelistedAddresses/index.d.ts.map +1 -0
- package/dist/hooks/useKrakenWhitelistedAddresses/useKrakenWhitelistedAddresses.d.ts +21 -0
- package/dist/hooks/useKrakenWhitelistedAddresses/useKrakenWhitelistedAddresses.d.ts.map +1 -0
- package/dist/hooks/useProveWalletAccountOwnership/index.d.ts +2 -0
- package/dist/hooks/useProveWalletAccountOwnership/index.d.ts.map +1 -0
- package/dist/hooks/useProveWalletAccountOwnership/useProveWalletAccountOwnership.d.ts +29 -0
- package/dist/hooks/useProveWalletAccountOwnership/useProveWalletAccountOwnership.d.ts.map +1 -0
- package/dist/hooks/useRefreshAuth/index.d.ts +2 -0
- package/dist/hooks/useRefreshAuth/index.d.ts.map +1 -0
- package/dist/hooks/useRefreshAuth/useRefreshAuth.d.ts +24 -0
- package/dist/hooks/useRefreshAuth/useRefreshAuth.d.ts.map +1 -0
- package/dist/hooks/useRequestExternalAuthElevatedToken/index.d.ts +2 -0
- package/dist/hooks/useRequestExternalAuthElevatedToken/index.d.ts.map +1 -0
- package/dist/hooks/useRequestExternalAuthElevatedToken/useRequestExternalAuthElevatedToken.d.ts +26 -0
- package/dist/hooks/useRequestExternalAuthElevatedToken/useRequestExternalAuthElevatedToken.d.ts.map +1 -0
- package/dist/hooks/useRevokeAllRegisteredDevices/index.d.ts +2 -0
- package/dist/hooks/useRevokeAllRegisteredDevices/index.d.ts.map +1 -0
- package/dist/hooks/useRevokeAllRegisteredDevices/useRevokeAllRegisteredDevices.d.ts +25 -0
- package/dist/hooks/useRevokeAllRegisteredDevices/useRevokeAllRegisteredDevices.d.ts.map +1 -0
- package/dist/hooks/useSignInWithExternalJwt/index.d.ts +2 -0
- package/dist/hooks/useSignInWithExternalJwt/index.d.ts.map +1 -0
- package/dist/hooks/useSignInWithExternalJwt/useSignInWithExternalJwt.d.ts +26 -0
- package/dist/hooks/useSignInWithExternalJwt/useSignInWithExternalJwt.d.ts.map +1 -0
- package/dist/hooks/useSignInWithSocialPopUp/index.d.ts +2 -0
- package/dist/hooks/useSignInWithSocialPopUp/index.d.ts.map +1 -0
- package/dist/hooks/useSignInWithSocialPopUp/useSignInWithSocialPopUp.d.ts +24 -0
- package/dist/hooks/useSignInWithSocialPopUp/useSignInWithSocialPopUp.d.ts.map +1 -0
- package/dist/hooks/useSignInWithSocialRedirect/index.d.ts +2 -0
- package/dist/hooks/useSignInWithSocialRedirect/index.d.ts.map +1 -0
- package/dist/hooks/useSignInWithSocialRedirect/useSignInWithSocialRedirect.d.ts +23 -0
- package/dist/hooks/useSignInWithSocialRedirect/useSignInWithSocialRedirect.d.ts.map +1 -0
- package/dist/hooks/useTransferAmount/index.d.ts +2 -0
- package/dist/hooks/useTransferAmount/index.d.ts.map +1 -0
- package/dist/hooks/useTransferAmount/useTransferAmount.d.ts +25 -0
- package/dist/hooks/useTransferAmount/useTransferAmount.d.ts.map +1 -0
- package/dist/hooks/useTransferWalletAccount/index.d.ts +2 -0
- package/dist/hooks/useTransferWalletAccount/index.d.ts.map +1 -0
- package/dist/hooks/useTransferWalletAccount/useTransferWalletAccount.d.ts +26 -0
- package/dist/hooks/useTransferWalletAccount/useTransferWalletAccount.d.ts.map +1 -0
- package/dist/index.cjs +428 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +408 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
2
|
-
import { BaseError, authenticateMfaRecoveryCode, authenticatePasskeyMFA, authenticateTotpMfaDevice, consumeMfaToken, createNewMfaRecoveryCodes, deleteMfaDevice, deletePasskey, deleteUser, getAvailableWalletProvidersData, getMfaDevices, getMfaMethods, getMfaRecoveryCodes, getMultichainTokenBalances, getNativeBalance, getNetworksData, getPasskeys, getRegisteredDevices, getTokenBalances, getTransactionHistory, getUserSocialAccounts, getWalletAccounts, isCaptchaRequired, isUserMissingMfaAuth, isUserOnboardingComplete, logout, onEvent, registerPasskey, registerTotpMfaDevice, removeWalletAccount, revokeRegisteredDevice, sendEmailOTP, sendSmsOTP, setDefaultMfaDevice, signInWithPasskey, signMessage, switchActiveNetwork, unlinkSocialAccount, updateUser, verifyOTP, verifyWalletAccount, waitForClientInitialized } from "@dynamic-labs-sdk/client";
|
|
2
|
+
import { BaseError, acknowledgeRecoveryCodes, addNetwork, authenticateMfaRecoveryCode, authenticatePasskeyMFA, authenticateTotpMfaDevice, completeDeviceRegistration, completeSocialRedirect, confirmTransaction, consumeMfaToken, createCoinbaseOnrampOrder, createCryptoDotComPayment, createNewMfaRecoveryCodes, deleteMfaDevice, deletePasskey, deleteUser, executeSwapTransaction, getActiveNetworkData, getAvailableWalletProvidersData, getBalanceForAddress, getCoinbaseBuyUrl, getGoogleDriveBackupReadiness, getKrakenWhitelistedAddresses, getMfaDevices, getMfaMethods, getMfaRecoveryCodes, getMultichainTokenBalances, getNativeBalance, getNetworksData, getPasskeys, getRegisteredDevices, getTokenBalances, getTransactionHistory, getUserSocialAccounts, getWalletAccounts, isCaptchaRequired, isUserMissingMfaAuth, isUserOnboardingComplete, logout, onEvent, proveWalletAccountOwnership, refreshAuth, registerPasskey, registerTotpMfaDevice, removeWalletAccount, requestExternalAuthElevatedToken, revokeAllRegisteredDevices, revokeRegisteredDevice, sendEmailOTP, sendSmsOTP, setDefaultMfaDevice, signInWithExternalJwt, signInWithPasskey, signInWithSocialPopUp, signInWithSocialRedirect, signMessage, switchActiveNetwork, transferAmount, transferWalletAccount, unlinkSocialAccount, updateUser, verifyOTP, verifyWalletAccount, waitForClientInitialized } from "@dynamic-labs-sdk/client";
|
|
3
3
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { createContext, useContext, useEffect, useMemo, useRef } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -7,7 +7,7 @@ import { getCore } from "@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.7.0";
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/modules/DynamicContext/DynamicContext.ts
|
|
@@ -85,6 +85,95 @@ const useBaseMutation = ({ mutationFn, mutateParams }) => {
|
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/hooks/useAcknowledgeRecoveryCodes/useAcknowledgeRecoveryCodes.ts
|
|
90
|
+
/**
|
|
91
|
+
* Marks the current user's MFA recovery codes as acknowledged. Takes no arguments — call `mutate()` after the user confirms they have stored the codes shown by {@link useMfaRecoveryCodes}.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx
|
|
95
|
+
* const { mutate: acknowledge, isPending } = useAcknowledgeRecoveryCodes();
|
|
96
|
+
* <button onClick={() => acknowledge()} disabled={isPending}>
|
|
97
|
+
* I've saved my recovery codes
|
|
98
|
+
* </button>
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
const useAcknowledgeRecoveryCodes = ({ mutateParams } = {}) => useBaseMutation({
|
|
102
|
+
mutateParams,
|
|
103
|
+
mutationFn: ({ client }) => acknowledgeRecoveryCodes(client)
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/foundation/useBaseQuery/useBaseQuery.ts
|
|
108
|
+
/**
|
|
109
|
+
* Internal hook that wraps a react-query `useQuery` with the conventions used
|
|
110
|
+
* by every async-read hook in this package:
|
|
111
|
+
*
|
|
112
|
+
* - `queryFn` receives the resolved `DynamicClient` from context, and is
|
|
113
|
+
* gated behind `waitForClientInitialized` so customers never see "client
|
|
114
|
+
* not ready" errors on first render.
|
|
115
|
+
* - Callers pass `queryParams` to override any default `UseQueryOptions`,
|
|
116
|
+
* so consumers can opt into retries / custom staleTime / etc.
|
|
117
|
+
* - Callers pass `enabled: false` (typically derived from whether their
|
|
118
|
+
* pseudo-required arguments are present) to short-circuit fetches.
|
|
119
|
+
*
|
|
120
|
+
* Returns the full `useQuery` result — `data`, `error`, `isLoading`,
|
|
121
|
+
* `isFetching`, `isSuccess`, `refetch`, `status`, etc.
|
|
122
|
+
*/
|
|
123
|
+
const useBaseQuery = ({ queryFn, queryKey, queryParams, enabled = true }) => {
|
|
124
|
+
const client = useDynamicClient();
|
|
125
|
+
return useQuery({
|
|
126
|
+
queryFn: async () => {
|
|
127
|
+
await waitForClientInitialized(client);
|
|
128
|
+
return queryFn(client);
|
|
129
|
+
},
|
|
130
|
+
queryKey: useMemo(() => [
|
|
131
|
+
"@dynamic-labs-sdk/react-hooks",
|
|
132
|
+
"query",
|
|
133
|
+
...queryKey
|
|
134
|
+
], [queryKey]),
|
|
135
|
+
...queryParams,
|
|
136
|
+
enabled: enabled && queryParams?.enabled !== false
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/hooks/useActiveNetworkData/useActiveNetworkData.ts
|
|
142
|
+
/**
|
|
143
|
+
* Wraps `getActiveNetworkData` from `@dynamic-labs-sdk/client`. Returns the network the given wallet account is currently on.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```tsx
|
|
147
|
+
* const { data: network, isLoading } = useActiveNetworkData({ walletAccount });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
const useActiveNetworkData = ({ queryParams, ...args }) => useBaseQuery({
|
|
151
|
+
queryFn: (client) => getActiveNetworkData(args, client),
|
|
152
|
+
queryKey: ["useActiveNetworkData", args],
|
|
153
|
+
queryParams
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/hooks/useAddNetwork/useAddNetwork.ts
|
|
158
|
+
/**
|
|
159
|
+
* Wraps `addNetwork` from `@dynamic-labs-sdk/client`. Call `mutate({ networkData, walletAccount })` to register a custom network on the given wallet account.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```tsx
|
|
163
|
+
* const { mutate: addNetwork, isPending } = useAddNetwork();
|
|
164
|
+
* <button
|
|
165
|
+
* onClick={() => addNetwork({ networkData, walletAccount })}
|
|
166
|
+
* disabled={isPending}
|
|
167
|
+
* >
|
|
168
|
+
* Add network
|
|
169
|
+
* </button>
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
const useAddNetwork = ({ mutateParams } = {}) => useBaseMutation({
|
|
173
|
+
mutateParams,
|
|
174
|
+
mutationFn: ({ client, variables }) => addNetwork(variables, client)
|
|
175
|
+
});
|
|
176
|
+
|
|
88
177
|
//#endregion
|
|
89
178
|
//#region src/hooks/useAuthenticateMfaRecoveryCode/useAuthenticateMfaRecoveryCode.ts
|
|
90
179
|
/**
|
|
@@ -280,6 +369,88 @@ const useAvailableWalletProvidersData = () => useBaseState({
|
|
|
280
369
|
selector: (client) => getAvailableWalletProvidersData(client)
|
|
281
370
|
});
|
|
282
371
|
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region src/hooks/useBalanceForAddress/useBalanceForAddress.ts
|
|
374
|
+
/**
|
|
375
|
+
* Wraps `getBalanceForAddress` from `@dynamic-labs-sdk/client`. Returns the native-token balance for an arbitrary address on the given chain/network.
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```tsx
|
|
379
|
+
* const { data, isLoading } = useBalanceForAddress({ address, chain, networkId });
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
const useBalanceForAddress = ({ queryParams, ...args }) => useBaseQuery({
|
|
383
|
+
queryFn: (client) => getBalanceForAddress(args, client),
|
|
384
|
+
queryKey: ["useBalanceForAddress", args],
|
|
385
|
+
queryParams
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/hooks/useCoinbaseBuyUrl/useCoinbaseBuyUrl.ts
|
|
390
|
+
/**
|
|
391
|
+
* Wraps `getCoinbaseBuyUrl` from `@dynamic-labs-sdk/client`. Returns a Coinbase onramp buy URL for the given parameters.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```tsx
|
|
395
|
+
* const { data: buyUrl, isLoading } = useCoinbaseBuyUrl(buyUrlParams);
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
const useCoinbaseBuyUrl = ({ queryParams, ...args }) => useBaseQuery({
|
|
399
|
+
queryFn: (client) => getCoinbaseBuyUrl(args, client),
|
|
400
|
+
queryKey: ["useCoinbaseBuyUrl", args],
|
|
401
|
+
queryParams
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/hooks/useCompleteDeviceRegistration/useCompleteDeviceRegistration.ts
|
|
406
|
+
/**
|
|
407
|
+
* Wraps `completeDeviceRegistration` from `@dynamic-labs-sdk/client`. Call `mutate({ deviceToken })` with the device token parsed from the redirect URL; the resolved `data` is a `VerifyResponse`.
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```tsx
|
|
411
|
+
* const { mutate: completeRegistration, isPending } =
|
|
412
|
+
* useCompleteDeviceRegistration();
|
|
413
|
+
* completeRegistration({ deviceToken });
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
const useCompleteDeviceRegistration = ({ mutateParams } = {}) => useBaseMutation({
|
|
417
|
+
mutateParams,
|
|
418
|
+
mutationFn: ({ client, variables }) => completeDeviceRegistration(variables, client)
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/hooks/useCompleteSocialRedirect/useCompleteSocialRedirect.ts
|
|
423
|
+
/**
|
|
424
|
+
* Wraps `completeSocialRedirect` from `@dynamic-labs-sdk/client`. Call `mutate(params)` with the OAuth callback URL once the provider has redirected back to finish the sign-in; the resolved `data` is the signed-in `User` (or `null`).
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```tsx
|
|
428
|
+
* const { mutate: completeSocialRedirect, data: user } =
|
|
429
|
+
* useCompleteSocialRedirect();
|
|
430
|
+
* completeSocialRedirect({ url: new URL(window.location.href) });
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
const useCompleteSocialRedirect = ({ mutateParams } = {}) => useBaseMutation({
|
|
434
|
+
mutateParams,
|
|
435
|
+
mutationFn: ({ client, variables }) => completeSocialRedirect(variables, client)
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region src/hooks/useConfirmTransaction/useConfirmTransaction.ts
|
|
440
|
+
/**
|
|
441
|
+
* Wraps `confirmTransaction` from `@dynamic-labs-sdk/client`. Call `mutate({ walletAccount, transactionHash })` to await confirmation of a submitted transaction; the resolved `data` is `void`.
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* ```tsx
|
|
445
|
+
* const { mutate: confirmTransaction, isPending } = useConfirmTransaction();
|
|
446
|
+
* confirmTransaction({ walletAccount, transactionHash });
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
const useConfirmTransaction = ({ mutateParams } = {}) => useBaseMutation({
|
|
450
|
+
mutateParams,
|
|
451
|
+
mutationFn: ({ client, variables }) => confirmTransaction(variables, client)
|
|
452
|
+
});
|
|
453
|
+
|
|
283
454
|
//#endregion
|
|
284
455
|
//#region src/hooks/useConsumeMfaToken/useConsumeMfaToken.ts
|
|
285
456
|
/**
|
|
@@ -301,6 +472,39 @@ const useConsumeMfaToken = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
301
472
|
mutationFn: ({ client }) => Promise.resolve(consumeMfaToken(client))
|
|
302
473
|
});
|
|
303
474
|
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/hooks/useCreateCoinbaseOnrampOrder/useCreateCoinbaseOnrampOrder.ts
|
|
477
|
+
/**
|
|
478
|
+
* Wraps `createCoinbaseOnrampOrder` from `@dynamic-labs-sdk/client`. Call `mutate(orderParams)` to create a Coinbase onramp order; the resolved `data` is the order response.
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```tsx
|
|
482
|
+
* const { mutate: createOrder, data: order } = useCreateCoinbaseOnrampOrder();
|
|
483
|
+
* createOrder(orderParams);
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
const useCreateCoinbaseOnrampOrder = ({ mutateParams } = {}) => useBaseMutation({
|
|
487
|
+
mutateParams,
|
|
488
|
+
mutationFn: ({ client, variables }) => createCoinbaseOnrampOrder(variables, client)
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region src/hooks/useCreateCryptoDotComPayment/useCreateCryptoDotComPayment.ts
|
|
493
|
+
/**
|
|
494
|
+
* Wraps `createCryptoDotComPayment` from `@dynamic-labs-sdk/client`. Call `mutate(paymentParams)` to create a Crypto.com Pay payment; the resolved `data` is the payment response.
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```tsx
|
|
498
|
+
* const { mutate: createPayment, data: payment } =
|
|
499
|
+
* useCreateCryptoDotComPayment();
|
|
500
|
+
* createPayment(paymentParams);
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
const useCreateCryptoDotComPayment = ({ mutateParams } = {}) => useBaseMutation({
|
|
504
|
+
mutateParams,
|
|
505
|
+
mutationFn: ({ client, variables }) => createCryptoDotComPayment(variables, client)
|
|
506
|
+
});
|
|
507
|
+
|
|
304
508
|
//#endregion
|
|
305
509
|
//#region src/hooks/useCreateNewMfaRecoveryCodes/useCreateNewMfaRecoveryCodes.ts
|
|
306
510
|
/**
|
|
@@ -410,6 +614,38 @@ const useEvent = ({ event, listener }) => {
|
|
|
410
614
|
}, client), [event, client]);
|
|
411
615
|
};
|
|
412
616
|
|
|
617
|
+
//#endregion
|
|
618
|
+
//#region src/hooks/useExecuteSwapTransaction/useExecuteSwapTransaction.ts
|
|
619
|
+
/**
|
|
620
|
+
* Wraps `executeSwapTransaction` from `@dynamic-labs-sdk/client`. Call `mutate({ walletAccount, signingPayload })` (using a payload from {@link useSwapQuote}) to execute a swap; the resolved `data` is `{ transactionHash }`.
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* ```tsx
|
|
624
|
+
* const { mutate: executeSwap, data } = useExecuteSwapTransaction();
|
|
625
|
+
* executeSwap({ walletAccount, signingPayload });
|
|
626
|
+
* ```
|
|
627
|
+
*/
|
|
628
|
+
const useExecuteSwapTransaction = ({ mutateParams } = {}) => useBaseMutation({
|
|
629
|
+
mutateParams,
|
|
630
|
+
mutationFn: ({ client, variables }) => executeSwapTransaction(variables, client)
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
//#endregion
|
|
634
|
+
//#region src/hooks/useGoogleDriveBackupReadiness/useGoogleDriveBackupReadiness.ts
|
|
635
|
+
/**
|
|
636
|
+
* Wraps `getGoogleDriveBackupReadiness` from `@dynamic-labs-sdk/client`. Reports whether the user's Google Drive backup is set up and available.
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```tsx
|
|
640
|
+
* const { data: readiness, isLoading } = useGoogleDriveBackupReadiness();
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
const useGoogleDriveBackupReadiness = ({ queryParams } = {}) => useBaseQuery({
|
|
644
|
+
queryFn: (client) => getGoogleDriveBackupReadiness(client),
|
|
645
|
+
queryKey: ["useGoogleDriveBackupReadiness"],
|
|
646
|
+
queryParams
|
|
647
|
+
});
|
|
648
|
+
|
|
413
649
|
//#endregion
|
|
414
650
|
//#region src/hooks/useInitStatus/useInitStatus.ts
|
|
415
651
|
/**
|
|
@@ -489,6 +725,22 @@ const useIsUserOnboardingComplete = () => useBaseState({
|
|
|
489
725
|
selector: (client) => client.user === null ? false : isUserOnboardingComplete(client)
|
|
490
726
|
});
|
|
491
727
|
|
|
728
|
+
//#endregion
|
|
729
|
+
//#region src/hooks/useKrakenWhitelistedAddresses/useKrakenWhitelistedAddresses.ts
|
|
730
|
+
/**
|
|
731
|
+
* Wraps `getKrakenWhitelistedAddresses` from `@dynamic-labs-sdk/client`. Returns the destination addresses whitelisted for Kraken withdrawals.
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* ```tsx
|
|
735
|
+
* const { data: addresses, isLoading } = useKrakenWhitelistedAddresses();
|
|
736
|
+
* ```
|
|
737
|
+
*/
|
|
738
|
+
const useKrakenWhitelistedAddresses = ({ queryParams } = {}) => useBaseQuery({
|
|
739
|
+
queryFn: (client) => getKrakenWhitelistedAddresses(client),
|
|
740
|
+
queryKey: ["useKrakenWhitelistedAddresses"],
|
|
741
|
+
queryParams
|
|
742
|
+
});
|
|
743
|
+
|
|
492
744
|
//#endregion
|
|
493
745
|
//#region src/hooks/useLogout/useLogout.ts
|
|
494
746
|
/**
|
|
@@ -508,40 +760,6 @@ const useLogout = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
508
760
|
mutationFn: ({ client }) => logout(client)
|
|
509
761
|
});
|
|
510
762
|
|
|
511
|
-
//#endregion
|
|
512
|
-
//#region src/foundation/useBaseQuery/useBaseQuery.ts
|
|
513
|
-
/**
|
|
514
|
-
* Internal hook that wraps a react-query `useQuery` with the conventions used
|
|
515
|
-
* by every async-read hook in this package:
|
|
516
|
-
*
|
|
517
|
-
* - `queryFn` receives the resolved `DynamicClient` from context, and is
|
|
518
|
-
* gated behind `waitForClientInitialized` so customers never see "client
|
|
519
|
-
* not ready" errors on first render.
|
|
520
|
-
* - Callers pass `queryParams` to override any default `UseQueryOptions`,
|
|
521
|
-
* so consumers can opt into retries / custom staleTime / etc.
|
|
522
|
-
* - Callers pass `enabled: false` (typically derived from whether their
|
|
523
|
-
* pseudo-required arguments are present) to short-circuit fetches.
|
|
524
|
-
*
|
|
525
|
-
* Returns the full `useQuery` result — `data`, `error`, `isLoading`,
|
|
526
|
-
* `isFetching`, `isSuccess`, `refetch`, `status`, etc.
|
|
527
|
-
*/
|
|
528
|
-
const useBaseQuery = ({ queryFn, queryKey, queryParams, enabled = true }) => {
|
|
529
|
-
const client = useDynamicClient();
|
|
530
|
-
return useQuery({
|
|
531
|
-
queryFn: async () => {
|
|
532
|
-
await waitForClientInitialized(client);
|
|
533
|
-
return queryFn(client);
|
|
534
|
-
},
|
|
535
|
-
queryKey: useMemo(() => [
|
|
536
|
-
"@dynamic-labs-sdk/react-hooks",
|
|
537
|
-
"query",
|
|
538
|
-
...queryKey
|
|
539
|
-
], [queryKey]),
|
|
540
|
-
...queryParams,
|
|
541
|
-
enabled: enabled && queryParams?.enabled !== false
|
|
542
|
-
});
|
|
543
|
-
};
|
|
544
|
-
|
|
545
763
|
//#endregion
|
|
546
764
|
//#region src/hooks/useMfaDevices/useMfaDevices.ts
|
|
547
765
|
/**
|
|
@@ -675,6 +893,41 @@ const usePasskeys = ({ queryParams } = {}) => useBaseQuery({
|
|
|
675
893
|
queryParams
|
|
676
894
|
});
|
|
677
895
|
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region src/hooks/useProveWalletAccountOwnership/useProveWalletAccountOwnership.ts
|
|
898
|
+
/**
|
|
899
|
+
* Wraps `proveWalletAccountOwnership` from `@dynamic-labs-sdk/client`. Call `mutate({ walletAccount })` to prove ownership of a connected wallet account by signing a challenge.
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* ```tsx
|
|
903
|
+
* const { mutate: proveOwnership, isPending } =
|
|
904
|
+
* useProveWalletAccountOwnership();
|
|
905
|
+
* proveOwnership({ walletAccount });
|
|
906
|
+
* ```
|
|
907
|
+
*/
|
|
908
|
+
const useProveWalletAccountOwnership = ({ mutateParams } = {}) => useBaseMutation({
|
|
909
|
+
mutateParams,
|
|
910
|
+
mutationFn: ({ client, variables }) => proveWalletAccountOwnership(variables, client)
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
//#endregion
|
|
914
|
+
//#region src/hooks/useRefreshAuth/useRefreshAuth.ts
|
|
915
|
+
/**
|
|
916
|
+
* Wraps `refreshAuth` from `@dynamic-labs-sdk/client`. Takes no arguments — call `mutate()` to refresh the session/JWT; the resolved `data` is a `VerifyResponse`.
|
|
917
|
+
*
|
|
918
|
+
* @example
|
|
919
|
+
* ```tsx
|
|
920
|
+
* const { mutate: refreshAuth, isPending } = useRefreshAuth();
|
|
921
|
+
* <button onClick={() => refreshAuth()} disabled={isPending}>
|
|
922
|
+
* Refresh session
|
|
923
|
+
* </button>
|
|
924
|
+
* ```
|
|
925
|
+
*/
|
|
926
|
+
const useRefreshAuth = ({ mutateParams } = {}) => useBaseMutation({
|
|
927
|
+
mutateParams,
|
|
928
|
+
mutationFn: ({ client }) => refreshAuth(client)
|
|
929
|
+
});
|
|
930
|
+
|
|
678
931
|
//#endregion
|
|
679
932
|
//#region src/hooks/useRegisteredDevices/useRegisteredDevices.ts
|
|
680
933
|
/**
|
|
@@ -764,6 +1017,42 @@ const useRemoveWalletAccount = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
764
1017
|
mutationFn: ({ client, variables }) => removeWalletAccount(variables, client)
|
|
765
1018
|
});
|
|
766
1019
|
|
|
1020
|
+
//#endregion
|
|
1021
|
+
//#region src/hooks/useRequestExternalAuthElevatedToken/useRequestExternalAuthElevatedToken.ts
|
|
1022
|
+
/**
|
|
1023
|
+
* Wraps `requestExternalAuthElevatedToken` from `@dynamic-labs-sdk/client`. Call `mutate({ externalJwt })` to exchange an externally issued JWT for an elevated-access token.
|
|
1024
|
+
*
|
|
1025
|
+
* @example
|
|
1026
|
+
* ```tsx
|
|
1027
|
+
* const { mutate: requestElevatedToken } =
|
|
1028
|
+
* useRequestExternalAuthElevatedToken();
|
|
1029
|
+
* requestElevatedToken({ externalJwt });
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
1032
|
+
const useRequestExternalAuthElevatedToken = ({ mutateParams } = {}) => useBaseMutation({
|
|
1033
|
+
mutateParams,
|
|
1034
|
+
mutationFn: ({ client, variables }) => requestExternalAuthElevatedToken(variables, client)
|
|
1035
|
+
});
|
|
1036
|
+
|
|
1037
|
+
//#endregion
|
|
1038
|
+
//#region src/hooks/useRevokeAllRegisteredDevices/useRevokeAllRegisteredDevices.ts
|
|
1039
|
+
/**
|
|
1040
|
+
* Wraps `revokeAllRegisteredDevices` from `@dynamic-labs-sdk/client`. Takes no arguments — call `mutate()` to revoke every device registered to the current user; the resolved `data` is `void`.
|
|
1041
|
+
*
|
|
1042
|
+
* @example
|
|
1043
|
+
* ```tsx
|
|
1044
|
+
* const { mutate: revokeAllDevices, isPending } =
|
|
1045
|
+
* useRevokeAllRegisteredDevices();
|
|
1046
|
+
* <button onClick={() => revokeAllDevices()} disabled={isPending}>
|
|
1047
|
+
* Revoke all devices
|
|
1048
|
+
* </button>
|
|
1049
|
+
* ```
|
|
1050
|
+
*/
|
|
1051
|
+
const useRevokeAllRegisteredDevices = ({ mutateParams } = {}) => useBaseMutation({
|
|
1052
|
+
mutateParams,
|
|
1053
|
+
mutationFn: ({ client }) => revokeAllRegisteredDevices(client)
|
|
1054
|
+
});
|
|
1055
|
+
|
|
767
1056
|
//#endregion
|
|
768
1057
|
//#region src/hooks/useRevokeRegisteredDevice/useRevokeRegisteredDevice.ts
|
|
769
1058
|
/**
|
|
@@ -881,6 +1170,22 @@ const useSetDefaultMfaDevice = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
881
1170
|
mutationFn: ({ client, variables }) => setDefaultMfaDevice(variables, client)
|
|
882
1171
|
});
|
|
883
1172
|
|
|
1173
|
+
//#endregion
|
|
1174
|
+
//#region src/hooks/useSignInWithExternalJwt/useSignInWithExternalJwt.ts
|
|
1175
|
+
/**
|
|
1176
|
+
* Wraps `signInWithExternalJwt` from `@dynamic-labs-sdk/client`. Call `mutate({ externalJwt })` to authenticate the user with a JWT issued by an external auth provider.
|
|
1177
|
+
*
|
|
1178
|
+
* @example
|
|
1179
|
+
* ```tsx
|
|
1180
|
+
* const { mutate: signInWithJwt, isPending } = useSignInWithExternalJwt();
|
|
1181
|
+
* signInWithJwt({ externalJwt });
|
|
1182
|
+
* ```
|
|
1183
|
+
*/
|
|
1184
|
+
const useSignInWithExternalJwt = ({ mutateParams } = {}) => useBaseMutation({
|
|
1185
|
+
mutateParams,
|
|
1186
|
+
mutationFn: ({ client, variables }) => signInWithExternalJwt(variables, client)
|
|
1187
|
+
});
|
|
1188
|
+
|
|
884
1189
|
//#endregion
|
|
885
1190
|
//#region src/hooks/useSignInWithPasskey/useSignInWithPasskey.ts
|
|
886
1191
|
/**
|
|
@@ -903,6 +1208,39 @@ const useSignInWithPasskey = ({ mutateParams } = {}) => useBaseMutation({
|
|
|
903
1208
|
mutationFn: ({ client, variables }) => signInWithPasskey(variables, client)
|
|
904
1209
|
});
|
|
905
1210
|
|
|
1211
|
+
//#endregion
|
|
1212
|
+
//#region src/hooks/useSignInWithSocialPopUp/useSignInWithSocialPopUp.ts
|
|
1213
|
+
/**
|
|
1214
|
+
* Wraps `signInWithSocialPopUp` from `@dynamic-labs-sdk/client`. Call `mutate({ provider })` to open the provider's OAuth popup; the resolved `data` is the signed-in `User` (or `null`).
|
|
1215
|
+
*
|
|
1216
|
+
* @example
|
|
1217
|
+
* ```tsx
|
|
1218
|
+
* const { mutate: signInWithPopUp, data: user } =
|
|
1219
|
+
* useSignInWithSocialPopUp();
|
|
1220
|
+
* signInWithPopUp({ provider: 'google' });
|
|
1221
|
+
* ```
|
|
1222
|
+
*/
|
|
1223
|
+
const useSignInWithSocialPopUp = ({ mutateParams } = {}) => useBaseMutation({
|
|
1224
|
+
mutateParams,
|
|
1225
|
+
mutationFn: ({ client, variables }) => signInWithSocialPopUp(variables, client)
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
//#endregion
|
|
1229
|
+
//#region src/hooks/useSignInWithSocialRedirect/useSignInWithSocialRedirect.ts
|
|
1230
|
+
/**
|
|
1231
|
+
* Wraps `signInWithSocialRedirect` from `@dynamic-labs-sdk/client`. Call `mutate({ provider, redirectUrl })` to redirect the user to the provider's OAuth page; complete the flow with {@link useCompleteSocialAuthentication}.
|
|
1232
|
+
*
|
|
1233
|
+
* @example
|
|
1234
|
+
* ```tsx
|
|
1235
|
+
* const { mutate: signInWithRedirect } = useSignInWithSocialRedirect();
|
|
1236
|
+
* signInWithRedirect({ provider: 'google', redirectUrl });
|
|
1237
|
+
* ```
|
|
1238
|
+
*/
|
|
1239
|
+
const useSignInWithSocialRedirect = ({ mutateParams } = {}) => useBaseMutation({
|
|
1240
|
+
mutateParams,
|
|
1241
|
+
mutationFn: ({ client, variables }) => signInWithSocialRedirect(variables, client)
|
|
1242
|
+
});
|
|
1243
|
+
|
|
906
1244
|
//#endregion
|
|
907
1245
|
//#region src/hooks/useSignMessage/useSignMessage.ts
|
|
908
1246
|
/**
|
|
@@ -1024,6 +1362,39 @@ const useTransactionHistory = ({ address, chain, networkId, queryParams, ...rest
|
|
|
1024
1362
|
queryParams
|
|
1025
1363
|
});
|
|
1026
1364
|
|
|
1365
|
+
//#endregion
|
|
1366
|
+
//#region src/hooks/useTransferAmount/useTransferAmount.ts
|
|
1367
|
+
/**
|
|
1368
|
+
* Wraps `transferAmount` from `@dynamic-labs-sdk/client`. Call `mutate({ walletAccount, amount, recipient, token })` to send tokens; the resolved `data` is `{ transactionHash }`.
|
|
1369
|
+
*
|
|
1370
|
+
* @example
|
|
1371
|
+
* ```tsx
|
|
1372
|
+
* const { mutate: transfer, data } = useTransferAmount();
|
|
1373
|
+
* transfer({ walletAccount, amount, recipient, token });
|
|
1374
|
+
* ```
|
|
1375
|
+
*/
|
|
1376
|
+
const useTransferAmount = ({ mutateParams } = {}) => useBaseMutation({
|
|
1377
|
+
mutateParams,
|
|
1378
|
+
mutationFn: ({ client, variables }) => transferAmount(variables, client)
|
|
1379
|
+
});
|
|
1380
|
+
|
|
1381
|
+
//#endregion
|
|
1382
|
+
//#region src/hooks/useTransferWalletAccount/useTransferWalletAccount.ts
|
|
1383
|
+
/**
|
|
1384
|
+
* Wraps `transferWalletAccount` from `@dynamic-labs-sdk/client`. Call `mutate({ walletProviderKey })` to transfer (hand off) a wallet account to the given provider.
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```tsx
|
|
1388
|
+
* const { mutate: transferWalletAccount, isPending } =
|
|
1389
|
+
* useTransferWalletAccount();
|
|
1390
|
+
* transferWalletAccount({ walletProviderKey });
|
|
1391
|
+
* ```
|
|
1392
|
+
*/
|
|
1393
|
+
const useTransferWalletAccount = ({ mutateParams } = {}) => useBaseMutation({
|
|
1394
|
+
mutateParams,
|
|
1395
|
+
mutationFn: ({ client, variables }) => transferWalletAccount(variables, client)
|
|
1396
|
+
});
|
|
1397
|
+
|
|
1027
1398
|
//#endregion
|
|
1028
1399
|
//#region src/hooks/useUnlinkSocialAccount/useUnlinkSocialAccount.ts
|
|
1029
1400
|
/**
|
|
@@ -1186,5 +1557,5 @@ const useWalletAccounts = () => useBaseState({
|
|
|
1186
1557
|
assertPackageVersion(name, version);
|
|
1187
1558
|
|
|
1188
1559
|
//#endregion
|
|
1189
|
-
export { DynamicProvider, useAuthenticateMfaRecoveryCode, useAuthenticatePasskeyMfa, useAuthenticateTotpMfaDevice, useAvailableWalletProvidersData, useConsumeMfaToken, useCreateNewMfaRecoveryCodes, useDeleteMfaDevice, useDeletePasskey, useDeleteUser, useDynamicClient, useEvent, useInitStatus, useIsCaptchaRequired, useIsUserMissingMfaAuth, useIsUserOnboardingComplete, useLogout, useMfaDevices, useMfaMethods, useMfaRecoveryCodes, useMultichainTokenBalances, useNativeBalance, useNetworksData, usePasskeys, useRegisterPasskey, useRegisterTotpMfaDevice, useRegisteredDevices, useRemoveWalletAccount, useRevokeRegisteredDevice, useSendEmailOtp, useSendSmsOtp, useSessionExpiresAt, useSetDefaultMfaDevice, useSignInWithPasskey, useSignMessage, useSwitchActiveNetwork, useTokenBalances, useTransactionHistory, useUnlinkSocialAccount, useUpdateUser, useUser, useUserSocialAccounts, useVerifyOtp, useVerifyWalletAccount, useWalletAccounts };
|
|
1560
|
+
export { DynamicProvider, useAcknowledgeRecoveryCodes, useActiveNetworkData, useAddNetwork, useAuthenticateMfaRecoveryCode, useAuthenticatePasskeyMfa, useAuthenticateTotpMfaDevice, useAvailableWalletProvidersData, useBalanceForAddress, useCoinbaseBuyUrl, useCompleteDeviceRegistration, useCompleteSocialRedirect, useConfirmTransaction, useConsumeMfaToken, useCreateCoinbaseOnrampOrder, useCreateCryptoDotComPayment, useCreateNewMfaRecoveryCodes, useDeleteMfaDevice, useDeletePasskey, useDeleteUser, useDynamicClient, useEvent, useExecuteSwapTransaction, useGoogleDriveBackupReadiness, useInitStatus, useIsCaptchaRequired, useIsUserMissingMfaAuth, useIsUserOnboardingComplete, useKrakenWhitelistedAddresses, useLogout, useMfaDevices, useMfaMethods, useMfaRecoveryCodes, useMultichainTokenBalances, useNativeBalance, useNetworksData, usePasskeys, useProveWalletAccountOwnership, useRefreshAuth, useRegisterPasskey, useRegisterTotpMfaDevice, useRegisteredDevices, useRemoveWalletAccount, useRequestExternalAuthElevatedToken, useRevokeAllRegisteredDevices, useRevokeRegisteredDevice, useSendEmailOtp, useSendSmsOtp, useSessionExpiresAt, useSetDefaultMfaDevice, useSignInWithExternalJwt, useSignInWithPasskey, useSignInWithSocialPopUp, useSignInWithSocialRedirect, useSignMessage, useSwitchActiveNetwork, useTokenBalances, useTransactionHistory, useTransferAmount, useTransferWalletAccount, useUnlinkSocialAccount, useUpdateUser, useUser, useUserSocialAccounts, useVerifyOtp, useVerifyWalletAccount, useWalletAccounts };
|
|
1190
1561
|
//# sourceMappingURL=index.esm.js.map
|