@dynamic-labs/sdk-react-core 4.61.7 → 4.63.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/CHANGELOG.md +25 -0
- package/package.cjs +4 -4
- package/package.js +4 -4
- package/package.json +15 -15
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +4 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +4 -0
- package/src/lib/events/dynamicEvents.cjs +1 -0
- package/src/lib/events/dynamicEvents.d.ts +1 -1
- package/src/lib/events/dynamicEvents.js +1 -0
- package/src/lib/events/wallets.d.ts +4 -0
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +8 -0
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/useGetMultichainTokenBalances/useGetMultichainTokenBalances.cjs +5 -1
- package/src/lib/utils/hooks/useGetMultichainTokenBalances/useGetMultichainTokenBalances.js +5 -1
- package/src/lib/utils/hooks/useWalletReturnRoute/index.d.ts +1 -0
- package/src/lib/utils/hooks/useWalletReturnRoute/useWalletReturnRoute.cjs +37 -0
- package/src/lib/utils/hooks/useWalletReturnRoute/useWalletReturnRoute.d.ts +8 -0
- package/src/lib/utils/hooks/useWalletReturnRoute/useWalletReturnRoute.js +33 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.63.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.62.0...v4.63.0) (2026-02-24)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **react-native:** raise walletReturnFromDeepLink event to allow redirecting back to the same route as before ([#10364](https://github.com/dynamic-labs/dynamic-auth/issues/10364)) ([cd56fd0](https://github.com/dynamic-labs/dynamic-auth/commit/cd56fd089e867bb5ed09a7c999b04480d8f59f81))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **react-native:** include redirectUrl in WalletConnect connection deep links on iOS and add session redirect metadata for Solana ([#10479](https://github.com/dynamic-labs/dynamic-auth/issues/10479)) ([68829f9](https://github.com/dynamic-labs/dynamic-auth/commit/68829f9ef39c845917ce49bfd63922e5252c2299))
|
|
13
|
+
* ton external wallet connection ([#10460](https://github.com/dynamic-labs/dynamic-auth/issues/10460)) ([7431a74](https://github.com/dynamic-labs/dynamic-auth/commit/7431a74fcd0bcd04755e6a81b49aa24dfc261f09))
|
|
14
|
+
|
|
15
|
+
## [4.62.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.61.7...v4.62.0) (2026-02-23)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add stellar waas connector ([#10472](https://github.com/dynamic-labs/dynamic-auth/issues/10472)) ([8349afe](https://github.com/dynamic-labs/dynamic-auth/commit/8349afece59b430ef398585b372d4cd2733c0ce4))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* **react-native:** ensure transaction confirmation UI is displayed ([#10488](https://github.com/dynamic-labs/dynamic-auth/issues/10488)) ([dfa2304](https://github.com/dynamic-labs/dynamic-auth/commit/dfa230435a9ce0febc5b66fcca5098cbe979f8d7))
|
|
26
|
+
|
|
2
27
|
### [4.61.7](https://github.com/dynamic-labs/dynamic-auth/compare/v4.61.6...v4.61.7) (2026-02-20)
|
|
3
28
|
|
|
4
29
|
|
package/package.cjs
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var version = "4.
|
|
6
|
+
var version = "4.63.0";
|
|
7
7
|
var dependencies = {
|
|
8
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
9
|
-
"@dynamic-labs-sdk/client": "0.
|
|
10
|
-
"@dynamic-labs-wallet/browser-wallet-client": "0.0.
|
|
8
|
+
"@dynamic-labs/sdk-api-core": "0.0.875",
|
|
9
|
+
"@dynamic-labs-sdk/client": "0.12.1",
|
|
10
|
+
"@dynamic-labs-wallet/browser-wallet-client": "0.0.276",
|
|
11
11
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
12
12
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
13
13
|
"country-list": "2.3.0",
|
package/package.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var version = "4.
|
|
2
|
+
var version = "4.63.0";
|
|
3
3
|
var dependencies = {
|
|
4
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
5
|
-
"@dynamic-labs-sdk/client": "0.
|
|
6
|
-
"@dynamic-labs-wallet/browser-wallet-client": "0.0.
|
|
4
|
+
"@dynamic-labs/sdk-api-core": "0.0.875",
|
|
5
|
+
"@dynamic-labs-sdk/client": "0.12.1",
|
|
6
|
+
"@dynamic-labs-wallet/browser-wallet-client": "0.0.276",
|
|
7
7
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
8
8
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
9
9
|
"country-list": "2.3.0",
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.63.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
6
|
-
"@dynamic-labs-sdk/client": "0.
|
|
7
|
-
"@dynamic-labs-wallet/browser-wallet-client": "0.0.
|
|
5
|
+
"@dynamic-labs/sdk-api-core": "0.0.875",
|
|
6
|
+
"@dynamic-labs-sdk/client": "0.12.1",
|
|
7
|
+
"@dynamic-labs-wallet/browser-wallet-client": "0.0.276",
|
|
8
8
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
9
9
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
10
10
|
"country-list": "2.3.0",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"yup": "0.32.11",
|
|
17
17
|
"react-international-phone": "4.5.0",
|
|
18
18
|
"bs58": "5.0.0",
|
|
19
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
20
|
-
"@dynamic-labs/iconic": "4.
|
|
21
|
-
"@dynamic-labs/locale": "4.
|
|
22
|
-
"@dynamic-labs/logger": "4.
|
|
23
|
-
"@dynamic-labs/multi-wallet": "4.
|
|
24
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
25
|
-
"@dynamic-labs/store": "4.
|
|
26
|
-
"@dynamic-labs/types": "4.
|
|
27
|
-
"@dynamic-labs/utils": "4.
|
|
28
|
-
"@dynamic-labs/wallet-book": "4.
|
|
29
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
19
|
+
"@dynamic-labs/assert-package-version": "4.63.0",
|
|
20
|
+
"@dynamic-labs/iconic": "4.63.0",
|
|
21
|
+
"@dynamic-labs/locale": "4.63.0",
|
|
22
|
+
"@dynamic-labs/logger": "4.63.0",
|
|
23
|
+
"@dynamic-labs/multi-wallet": "4.63.0",
|
|
24
|
+
"@dynamic-labs/rpc-providers": "4.63.0",
|
|
25
|
+
"@dynamic-labs/store": "4.63.0",
|
|
26
|
+
"@dynamic-labs/types": "4.63.0",
|
|
27
|
+
"@dynamic-labs/utils": "4.63.0",
|
|
28
|
+
"@dynamic-labs/wallet-book": "4.63.0",
|
|
29
|
+
"@dynamic-labs/wallet-connector-core": "4.63.0",
|
|
30
30
|
"eventemitter3": "5.0.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -153,6 +153,7 @@ var PhantomRedirectContext = require('../PhantomRedirectContext/PhantomRedirectC
|
|
|
153
153
|
var ReinitializeContextProvider = require('../ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
154
154
|
var SendBalanceContext = require('../SendBalanceContext/SendBalanceContext.cjs');
|
|
155
155
|
var UseNetworkValidation = require('../UseNetworkValidation/UseNetworkValidation.cjs');
|
|
156
|
+
var useWalletReturnRoute = require('../../utils/hooks/useWalletReturnRoute/useWalletReturnRoute.cjs');
|
|
156
157
|
var onReinitialize = require('./functions/onReinitialize/onReinitialize.cjs');
|
|
157
158
|
var helpers = require('./helpers/helpers.cjs');
|
|
158
159
|
var useDisplayOrderState = require('./hooks/useDisplayOrderState/useDisplayOrderState.cjs');
|
|
@@ -416,6 +417,8 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
416
417
|
clientCallbacks: settings$1.events,
|
|
417
418
|
user,
|
|
418
419
|
});
|
|
420
|
+
// Listen for wallet deep link returns and emit events (mobile only)
|
|
421
|
+
useWalletReturnRoute.useWalletReturnRoute();
|
|
419
422
|
const removeWallet = useRemoveWallet.useRemoveWallet({
|
|
420
423
|
handleLogOut,
|
|
421
424
|
secondaryWallets,
|
|
@@ -149,6 +149,7 @@ import { PhantomRedirectContextProvider } from '../PhantomRedirectContext/Phanto
|
|
|
149
149
|
import { useReinitializeState, ReinitializeContextProvider } from '../ReinitializeContext/ReinitializeContextProvider.js';
|
|
150
150
|
import { SendBalanceContextProvider } from '../SendBalanceContext/SendBalanceContext.js';
|
|
151
151
|
import { UseNetworkValidation } from '../UseNetworkValidation/UseNetworkValidation.js';
|
|
152
|
+
import { useWalletReturnRoute } from '../../utils/hooks/useWalletReturnRoute/useWalletReturnRoute.js';
|
|
152
153
|
import { onReinitialize } from './functions/onReinitialize/onReinitialize.js';
|
|
153
154
|
import { resolveNetworkValidationMode, getDeepLinkPreference } from './helpers/helpers.js';
|
|
154
155
|
import { useDisplayOrderState } from './hooks/useDisplayOrderState/useDisplayOrderState.js';
|
|
@@ -412,6 +413,8 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
412
413
|
clientCallbacks: settings.events,
|
|
413
414
|
user,
|
|
414
415
|
});
|
|
416
|
+
// Listen for wallet deep link returns and emit events (mobile only)
|
|
417
|
+
useWalletReturnRoute();
|
|
415
418
|
const removeWallet = useRemoveWallet({
|
|
416
419
|
handleLogOut,
|
|
417
420
|
secondaryWallets,
|
package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs
CHANGED
|
@@ -186,6 +186,10 @@ const useTieCallbacksToEvents = ({ clientCallbacks, user, }) => {
|
|
|
186
186
|
var _a;
|
|
187
187
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletConnectionFailed) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, walletConnector, error);
|
|
188
188
|
});
|
|
189
|
+
useDynamicEvents.useInternalDynamicEvents('walletReturnFromDeepLink', (params) => {
|
|
190
|
+
var _a;
|
|
191
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletReturnFromDeepLink) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, params);
|
|
192
|
+
});
|
|
189
193
|
};
|
|
190
194
|
|
|
191
195
|
exports.useTieCallbacksToEvents = useTieCallbacksToEvents;
|
package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js
CHANGED
|
@@ -182,6 +182,10 @@ const useTieCallbacksToEvents = ({ clientCallbacks, user, }) => {
|
|
|
182
182
|
var _a;
|
|
183
183
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletConnectionFailed) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, walletConnector, error);
|
|
184
184
|
});
|
|
185
|
+
useInternalDynamicEvents('walletReturnFromDeepLink', (params) => {
|
|
186
|
+
var _a;
|
|
187
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletReturnFromDeepLink) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, params);
|
|
188
|
+
});
|
|
185
189
|
};
|
|
186
190
|
|
|
187
191
|
export { useTieCallbacksToEvents };
|
|
@@ -14,7 +14,7 @@ import { WalletEvents } from './wallets';
|
|
|
14
14
|
export type DynamicEvents = AuthEvents & UIEvents & OTPEvents & WalletEvents & PasskeyEvents & SocialEvents & EmbeddedWalletEvents & MultiWalletInternalEvents & TokenBalancesEvents & UserEvents & FundingEvents;
|
|
15
15
|
type PublicDynamicEvents = Pick<DynamicEvents, typeof externalEvents[number]>;
|
|
16
16
|
/** Which events are accessible by our clients */
|
|
17
|
-
export declare const externalEvents: ("authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "walletTabSelected" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "walletConnectionFailed" | "walletConnectionQrCodeReady" | "embeddedWalletCreated" | "embeddedWalletRevealCompleted" | "embeddedWalletRevealFailed" | "walletConnectedForFunding")[];
|
|
17
|
+
export declare const externalEvents: ("authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "walletTabSelected" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "walletConnectionFailed" | "walletConnectionQrCodeReady" | "walletReturnFromDeepLink" | "embeddedWalletCreated" | "embeddedWalletRevealCompleted" | "embeddedWalletRevealFailed" | "walletConnectedForFunding")[];
|
|
18
18
|
export declare const dynamicEvents: EventEmitter<DynamicEvents, any>;
|
|
19
19
|
export declare const publicDynamicEvents: EventEmitter<PublicDynamicEvents, any>;
|
|
20
20
|
export type DynamicEventEmitter = typeof dynamicEvents;
|
|
@@ -39,4 +39,8 @@ export type WalletEvents = {
|
|
|
39
39
|
walletConnectionFailed: (walletConnector: WalletConnector, error: unknown) => void;
|
|
40
40
|
/** Triggered when a wallet connection QR code is ready */
|
|
41
41
|
walletConnectionQrCodeReady: (qrCodeUri: string) => void;
|
|
42
|
+
/** Triggered when the app returns from a wallet deep link (mobile only) */
|
|
43
|
+
walletReturnFromDeepLink: (params: {
|
|
44
|
+
previousRoute: string;
|
|
45
|
+
}) => void;
|
|
42
46
|
};
|
|
@@ -39,6 +39,14 @@ export type DynamicEventsCallbacks = {
|
|
|
39
39
|
index: number;
|
|
40
40
|
tab: WalletListViewTabItem;
|
|
41
41
|
}) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Called when the app returns from a wallet deep link (mobile only).
|
|
44
|
+
* Use this to navigate back to the route the user was on before
|
|
45
|
+
* the wallet operation.
|
|
46
|
+
*/
|
|
47
|
+
onWalletReturnFromDeepLink?: (params: {
|
|
48
|
+
previousRoute: string;
|
|
49
|
+
}) => void;
|
|
42
50
|
};
|
|
43
51
|
export type OnAuthSuccess = (params: {
|
|
44
52
|
handleLogOut: () => Promise<void>;
|
|
@@ -4,5 +4,5 @@ type DynamicEventListener<E extends keyof DynamicEvents> = (...args: EventArgs<D
|
|
|
4
4
|
/** Allows us to subscribe to all dynamicEvents with a hook, even the internal ones */
|
|
5
5
|
export declare const useInternalDynamicEvents: <E extends keyof import("../../../../events/auth").AuthEvents | keyof import("../../../../events/ui").UIEvents | keyof import("../../../../events/otp").OTPEvents | keyof import("../../../../events/wallets").WalletEvents | keyof import("../../../../events/passkey").PasskeyEvents | "farcasterConnectCancelled" | keyof import("../../../../events/embeddedWallet").EmbeddedWalletEvents | keyof import("../../../../events/multiWallet").MultiWalletInternalEvents | "tokenBalancesChanged" | "userProfileUpdated" | "walletConnectedForFunding">(event: E, listener: DynamicEventListener<E>) => void;
|
|
6
6
|
/** Allows subscribing to dynamic events directly inside components with a hook */
|
|
7
|
-
export declare const useDynamicEvents: <E extends "authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "walletTabSelected" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "walletConnectionFailed" | "walletConnectionQrCodeReady" | "embeddedWalletCreated" | "embeddedWalletRevealCompleted" | "embeddedWalletRevealFailed" | "walletConnectedForFunding">(event: E, listener: DynamicEventListener<E>) => void;
|
|
7
|
+
export declare const useDynamicEvents: <E extends "authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "walletTabSelected" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "walletConnectionFailed" | "walletConnectionQrCodeReady" | "walletReturnFromDeepLink" | "embeddedWalletCreated" | "embeddedWalletRevealCompleted" | "embeddedWalletRevealFailed" | "walletConnectedForFunding">(event: E, listener: DynamicEventListener<E>) => void;
|
|
8
8
|
export {};
|
|
@@ -42,6 +42,10 @@ var client = require('@dynamic-labs-sdk/client');
|
|
|
42
42
|
* );
|
|
43
43
|
* }
|
|
44
44
|
*/
|
|
45
|
-
const useGetMultichainTokenBalances = () => React.useCallback((props) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
const useGetMultichainTokenBalances = () => React.useCallback((props) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
return client.getMultichainBalances({
|
|
47
|
+
balanceRequest: props,
|
|
48
|
+
});
|
|
49
|
+
}), []);
|
|
46
50
|
|
|
47
51
|
exports.useGetMultichainTokenBalances = useGetMultichainTokenBalances;
|
|
@@ -38,6 +38,10 @@ import { getMultichainBalances } from '@dynamic-labs-sdk/client';
|
|
|
38
38
|
* );
|
|
39
39
|
* }
|
|
40
40
|
*/
|
|
41
|
-
const useGetMultichainTokenBalances = () => useCallback((props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
const useGetMultichainTokenBalances = () => useCallback((props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
return getMultichainBalances({
|
|
43
|
+
balanceRequest: props,
|
|
44
|
+
});
|
|
45
|
+
}), []);
|
|
42
46
|
|
|
43
47
|
export { useGetMultichainTokenBalances };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useWalletReturnRoute } from './useWalletReturnRoute';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook that listens for URL updates (from wallet deep link returns) and
|
|
12
|
+
* emits the walletReturnFromDeepLink event with the previous route.
|
|
13
|
+
*
|
|
14
|
+
* This allows customers to navigate back to where the user was before
|
|
15
|
+
* the wallet operation.
|
|
16
|
+
*/
|
|
17
|
+
const useWalletReturnRoute = () => {
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
// Check immediately on mount in case the WebView was unmounted while the wallet
|
|
20
|
+
// was open and the URL redirect arrived before listeners were registered
|
|
21
|
+
const routeOnMount = utils.walletReturnRoute.getAndClear();
|
|
22
|
+
if (routeOnMount) {
|
|
23
|
+
dynamicEvents.dynamicEvents.emit('walletReturnFromDeepLink', {
|
|
24
|
+
previousRoute: routeOnMount,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const unsubscribe = utils.PlatformService.onUrlUpdate(() => {
|
|
28
|
+
const previousRoute = utils.walletReturnRoute.getAndClear();
|
|
29
|
+
if (previousRoute) {
|
|
30
|
+
dynamicEvents.dynamicEvents.emit('walletReturnFromDeepLink', { previousRoute });
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return unsubscribe;
|
|
34
|
+
}, []);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.useWalletReturnRoute = useWalletReturnRoute;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook that listens for URL updates (from wallet deep link returns) and
|
|
3
|
+
* emits the walletReturnFromDeepLink event with the previous route.
|
|
4
|
+
*
|
|
5
|
+
* This allows customers to navigate back to where the user was before
|
|
6
|
+
* the wallet operation.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useWalletReturnRoute: () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { walletReturnRoute, PlatformService } from '@dynamic-labs/utils';
|
|
4
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook that listens for URL updates (from wallet deep link returns) and
|
|
8
|
+
* emits the walletReturnFromDeepLink event with the previous route.
|
|
9
|
+
*
|
|
10
|
+
* This allows customers to navigate back to where the user was before
|
|
11
|
+
* the wallet operation.
|
|
12
|
+
*/
|
|
13
|
+
const useWalletReturnRoute = () => {
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
// Check immediately on mount in case the WebView was unmounted while the wallet
|
|
16
|
+
// was open and the URL redirect arrived before listeners were registered
|
|
17
|
+
const routeOnMount = walletReturnRoute.getAndClear();
|
|
18
|
+
if (routeOnMount) {
|
|
19
|
+
dynamicEvents.emit('walletReturnFromDeepLink', {
|
|
20
|
+
previousRoute: routeOnMount,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const unsubscribe = PlatformService.onUrlUpdate(() => {
|
|
24
|
+
const previousRoute = walletReturnRoute.getAndClear();
|
|
25
|
+
if (previousRoute) {
|
|
26
|
+
dynamicEvents.emit('walletReturnFromDeepLink', { previousRoute });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return unsubscribe;
|
|
30
|
+
}, []);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { useWalletReturnRoute };
|