@dynamic-labs/sdk-react-core 4.48.2 → 4.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/index.cjs +6 -4
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -1
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +10 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +10 -0
- package/src/lib/context/OnrampContext/OnrampContext.cjs +4 -2
- package/src/lib/context/OnrampContext/OnrampContext.d.ts +1 -0
- package/src/lib/context/OnrampContext/OnrampContext.js +4 -2
- package/src/lib/context/OnrampContext/types.d.ts +1 -0
- package/src/lib/context/OnrampContext/utils/getOnrampProviders.cjs +2 -1
- package/src/lib/context/OnrampContext/utils/getOnrampProviders.d.ts +1 -1
- package/src/lib/context/OnrampContext/utils/getOnrampProviders.js +2 -1
- package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.cjs +38 -6
- package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.d.ts +2 -2
- package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.js +39 -8
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +108 -16
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +108 -16
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/data/api/onramp/onramp.cjs +2 -1
- package/src/lib/data/api/onramp/onramp.d.ts +2 -1
- package/src/lib/data/api/onramp/onramp.js +2 -1
- package/src/lib/events/dynamicEvents.cjs +2 -0
- package/src/lib/events/dynamicEvents.d.ts +1 -1
- package/src/lib/events/dynamicEvents.js +2 -0
- package/src/lib/shared/assets/backup-waas.cjs +4 -4
- package/src/lib/shared/assets/backup-waas.js +4 -4
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +4 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/authViewLayoutChecks.cjs +13 -0
- package/src/lib/utils/constants/authViewLayoutChecks.js +13 -0
- package/src/lib/utils/functions/generateMessages/index.cjs +11 -2
- package/src/lib/utils/functions/generateMessages/index.js +11 -2
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.cjs +27 -1
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.js +27 -1
- package/src/lib/utils/functions/index.d.ts +0 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/useAuthenticatePasskeyMFA/useAuthenticatePasskeyMFA.cjs +5 -1
- package/src/lib/utils/hooks/useAuthenticatePasskeyMFA/useAuthenticatePasskeyMFA.js +5 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +35 -5
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +1 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +35 -5
- package/src/lib/utils/hooks/useFunding/useFunding.d.ts +1 -0
- package/src/lib/utils/hooks/useOnramp/useOnramp.cjs +14 -29
- package/src/lib/utils/hooks/useOnramp/useOnramp.d.ts +14 -18
- package/src/lib/utils/hooks/useOnramp/useOnramp.js +14 -29
- package/src/lib/utils/hooks/usePhantomRedirectEvents/index.d.ts +1 -0
- package/src/lib/utils/hooks/usePhantomRedirectEvents/usePhantomRedirectEvents.cjs +65 -0
- package/src/lib/utils/hooks/usePhantomRedirectEvents/usePhantomRedirectEvents.d.ts +36 -0
- package/src/lib/utils/hooks/usePhantomRedirectEvents/usePhantomRedirectEvents.js +61 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +17 -14
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +17 -14
- package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.cjs +106 -1
- package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.js +106 -1
- package/src/lib/utils/hooks/useSmartWallets/useSmartWallets.cjs +1 -1
- package/src/lib/utils/hooks/useSmartWallets/useSmartWallets.js +1 -1
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +1 -1
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +1 -1
- package/src/lib/utils/hooks/useWalletBackup/index.d.ts +1 -0
- package/src/lib/utils/hooks/useWalletBackup/useWalletBackup.cjs +339 -0
- package/src/lib/utils/hooks/useWalletBackup/useWalletBackup.d.ts +49 -0
- package/src/lib/utils/hooks/useWalletBackup/useWalletBackup.js +332 -0
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +2 -2
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +2 -2
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs +1 -0
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.js +1 -0
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +13 -0
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +14 -1
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +9 -6
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +9 -6
- package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.cjs +13 -0
- package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.js +14 -1
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -0
- package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -0
- package/src/lib/views/viewToComponentMap.cjs +15 -3
- package/src/lib/views/viewToComponentMap.d.ts +6 -0
- package/src/lib/views/viewToComponentMap.js +15 -3
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +97 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +97 -3
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.cjs +16 -14
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.js +16 -14
- package/src/lib/widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.cjs +3 -1
- package/src/lib/widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js +3 -1
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/BackupStepper.cjs +37 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/BackupStepper.d.ts +7 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/BackupStepper.js +33 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.cjs +49 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.js +45 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupDownloadView.cjs +53 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupDownloadView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupDownloadView.js +49 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.cjs +9 -18
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.js +10 -19
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.cjs +52 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.js +48 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.cjs +131 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.d.ts +5 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.js +127 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.cjs +45 -104
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.js +47 -106
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/index.d.ts +6 -1
- package/src/lib/utils/functions/downloadFile/downloadFile.cjs +0 -15
- package/src/lib/utils/functions/downloadFile/downloadFile.d.ts +0 -1
- package/src/lib/utils/functions/downloadFile/downloadFile.js +0 -11
- package/src/lib/utils/functions/downloadFile/index.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.50.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.49.0...v4.50.0) (2025-12-09)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add usePhantomRedirectEvents hook ([#10030](https://github.com/dynamic-labs/dynamic-auth/issues/10030)) ([fb8585e](https://github.com/dynamic-labs/dynamic-auth/commit/fb8585eec9847cd350be71d28291e9831a3f31b1))
|
|
8
|
+
* introduce embedded wallet reveal complete events ([#10068](https://github.com/dynamic-labs/dynamic-auth/issues/10068)) ([8ea79ce](https://github.com/dynamic-labs/dynamic-auth/commit/8ea79ceaba36745d46759c8e8c6681895b092096))
|
|
9
|
+
* **react-native:** add download file ([#9954](https://github.com/dynamic-labs/dynamic-auth/issues/9954)) ([408b00f](https://github.com/dynamic-labs/dynamic-auth/commit/408b00fabd2afbd87d12efb51e78ecbd89a323d3))
|
|
10
|
+
* **react-native:** add solana Phantom support with client module for listening to events ([#10033](https://github.com/dynamic-labs/dynamic-auth/issues/10033)) ([a5a2d11](https://github.com/dynamic-labs/dynamic-auth/commit/a5a2d11ccd3c102e22dece808a0ba4116155a582))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* remove overflow from token balance dropdown ([#10044](https://github.com/dynamic-labs/dynamic-auth/issues/10044)) ([b37c5bb](https://github.com/dynamic-labs/dynamic-auth/commit/b37c5bb8e8c916b8d685b495555a3a3481cd5f0d))
|
|
16
|
+
|
|
17
|
+
## [4.49.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.48.2...v4.49.0) (2025-12-05)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add merchant name support for crypto.com onramp ([#10021](https://github.com/dynamic-labs/dynamic-auth/issues/10021)) ([846250f](https://github.com/dynamic-labs/dynamic-auth/commit/846250f3d61b182ec3ae2174c953536e0be3e7ca))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* listen for secondary wallet change in bridge mode ([#10024](https://github.com/dynamic-labs/dynamic-auth/issues/10024)) ([d4d7bb5](https://github.com/dynamic-labs/dynamic-auth/commit/d4d7bb54db9cc4922b57b0cae2d26ac2afd4d21d))
|
|
28
|
+
|
|
2
29
|
### [4.48.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.48.1...v4.48.2) (2025-12-03)
|
|
3
30
|
|
|
4
31
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.50.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.831",
|
|
6
6
|
"@dynamic-labs-sdk/client": "0.1.0-alpha.33",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"react-international-phone": "4.5.0",
|
|
17
17
|
"bs58": "5.0.0",
|
|
18
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
19
|
-
"@dynamic-labs/iconic": "4.
|
|
20
|
-
"@dynamic-labs/locale": "4.
|
|
21
|
-
"@dynamic-labs/logger": "4.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "4.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
24
|
-
"@dynamic-labs/store": "4.
|
|
25
|
-
"@dynamic-labs/types": "4.
|
|
26
|
-
"@dynamic-labs/utils": "4.
|
|
27
|
-
"@dynamic-labs/wallet-book": "4.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
18
|
+
"@dynamic-labs/assert-package-version": "4.50.1",
|
|
19
|
+
"@dynamic-labs/iconic": "4.50.1",
|
|
20
|
+
"@dynamic-labs/locale": "4.50.1",
|
|
21
|
+
"@dynamic-labs/logger": "4.50.1",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "4.50.1",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "4.50.1",
|
|
24
|
+
"@dynamic-labs/store": "4.50.1",
|
|
25
|
+
"@dynamic-labs/types": "4.50.1",
|
|
26
|
+
"@dynamic-labs/utils": "4.50.1",
|
|
27
|
+
"@dynamic-labs/wallet-book": "4.50.1",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.50.1",
|
|
29
29
|
"eventemitter3": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
package/src/index.cjs
CHANGED
|
@@ -134,8 +134,9 @@ require('./lib/components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanne
|
|
|
134
134
|
require('./lib/context/PasskeyContext/PasskeyContext.cjs');
|
|
135
135
|
require('./lib/widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs');
|
|
136
136
|
var useEmbeddedReveal = require('./lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs');
|
|
137
|
-
var
|
|
137
|
+
var useDynamicWaas = require('./lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs');
|
|
138
138
|
var useRefreshUser = require('./lib/utils/hooks/useRefreshUser/useRefreshUser.cjs');
|
|
139
|
+
var useEmbeddedWalletAuthenticator = require('./lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.cjs');
|
|
139
140
|
require('./lib/widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.cjs');
|
|
140
141
|
require('./lib/context/OnrampContext/OnrampContext.cjs');
|
|
141
142
|
var index$2 = require('./lib/utils/functions/walletFilters/index.cjs');
|
|
@@ -154,7 +155,6 @@ var FarcasterConnectView = require('./lib/views/FarcasterConnectView/FarcasterCo
|
|
|
154
155
|
var NetworkNotSupportedSwitchManual = require('./lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs');
|
|
155
156
|
var viewToComponentMap = require('./lib/views/viewToComponentMap.cjs');
|
|
156
157
|
require('./lib/store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
157
|
-
var useDynamicWaas = require('./lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs');
|
|
158
158
|
var useGetMfaToken = require('./lib/utils/hooks/useGetMfaToken/useGetMfaToken.cjs');
|
|
159
159
|
var useDynamicModals = require('./lib/utils/hooks/useDynamicModals/useDynamicModals.cjs');
|
|
160
160
|
var useMfa = require('./lib/utils/hooks/useMfa/useMfa.cjs');
|
|
@@ -201,6 +201,7 @@ var useOpenFundingOptions = require('./lib/utils/hooks/useOpenFundingOptions/use
|
|
|
201
201
|
var SendBalanceContext = require('./lib/context/SendBalanceContext/SendBalanceContext.cjs');
|
|
202
202
|
require('./lib/context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
203
203
|
var useConnectWithOtp = require('./lib/context/ConnectWithOtpContext/useConnectWithOtp.cjs');
|
|
204
|
+
var usePhantomRedirectEvents = require('./lib/utils/hooks/usePhantomRedirectEvents/usePhantomRedirectEvents.cjs');
|
|
204
205
|
var useSwitchNetwork = require('./lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.cjs');
|
|
205
206
|
var ReinitializeContextProvider = require('./lib/context/ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
206
207
|
|
|
@@ -284,8 +285,9 @@ exports.DynamicWidgetContextProvider = DynamicWidgetContext.DynamicWidgetContext
|
|
|
284
285
|
exports.useWalletDelegation = useWalletDelegation.useWalletDelegation;
|
|
285
286
|
exports.useSwitchWallet = useSwitchWallet.useSwitchWallet;
|
|
286
287
|
exports.useEmbeddedReveal = useEmbeddedReveal.useEmbeddedReveal;
|
|
287
|
-
exports.
|
|
288
|
+
exports.useDynamicWaas = useDynamicWaas.useDynamicWaas;
|
|
288
289
|
exports.useRefreshUser = useRefreshUser.useRefreshUser;
|
|
290
|
+
exports.useEmbeddedWalletAuthenticator = useEmbeddedWalletAuthenticator.useEmbeddedWalletAuthenticator;
|
|
289
291
|
exports.FilterAndSortWallets = index$2.FilterAndSortWallets;
|
|
290
292
|
exports.FilterBridgeChainsName = index$2.FilterBridgeChainsName;
|
|
291
293
|
exports.FilterChain = index$2.FilterChain;
|
|
@@ -304,7 +306,6 @@ exports.WalletList = WalletList.WalletList;
|
|
|
304
306
|
exports.FarcasterConnectView = FarcasterConnectView.FarcasterConnectView;
|
|
305
307
|
exports.NetworkNotSupportedSwitchManual = NetworkNotSupportedSwitchManual.NetworkNotSupportedSwitchManual;
|
|
306
308
|
exports.viewToComponentMap = viewToComponentMap.viewToComponentMap;
|
|
307
|
-
exports.useDynamicWaas = useDynamicWaas.useDynamicWaas;
|
|
308
309
|
exports.useGetMfaToken = useGetMfaToken.useGetMfaToken;
|
|
309
310
|
exports.useDynamicModals = useDynamicModals.useDynamicModals;
|
|
310
311
|
exports.useMfa = useMfa.useMfa;
|
|
@@ -352,5 +353,6 @@ exports.useOnramp = useOnramp.useOnramp;
|
|
|
352
353
|
exports.useOpenFundingOptions = useOpenFundingOptions.useOpenFundingOptions;
|
|
353
354
|
exports.useSendBalance = SendBalanceContext.useSendBalance;
|
|
354
355
|
exports.useConnectWithOtp = useConnectWithOtp.useConnectWithOtp;
|
|
356
|
+
exports.usePhantomRedirectEvents = usePhantomRedirectEvents.usePhantomRedirectEvents;
|
|
355
357
|
exports.useSwitchNetwork = useSwitchNetwork.useSwitchNetwork;
|
|
356
358
|
exports.useReinitialize = ReinitializeContextProvider.useReinitialize;
|
package/src/index.d.ts
CHANGED
|
@@ -139,6 +139,7 @@ export { useSendBalance } from './lib/context/SendBalanceContext';
|
|
|
139
139
|
export type { LocaleResource } from '@dynamic-labs/locale';
|
|
140
140
|
export { useConnectWithOtp } from './lib/context/ConnectWithOtpContext';
|
|
141
141
|
export { useDynamicEvents } from './lib/utils/hooks/events/useDynamicEvents';
|
|
142
|
+
export { usePhantomRedirectEvents, type UsePhantomRedirectEventsProps, } from './lib/utils/hooks/usePhantomRedirectEvents';
|
|
142
143
|
export { useSwitchNetwork } from './lib/utils/hooks/useSwitchNetwork';
|
|
143
144
|
export { useReinitialize } from './lib/context/ReinitializeContext';
|
|
144
145
|
export { useExternalAuth } from './lib/utils/hooks/useExternalAuth';
|
package/src/index.js
CHANGED
|
@@ -130,8 +130,9 @@ import './lib/components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner
|
|
|
130
130
|
import './lib/context/PasskeyContext/PasskeyContext.js';
|
|
131
131
|
import './lib/widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
|
|
132
132
|
export { useEmbeddedReveal } from './lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js';
|
|
133
|
-
export {
|
|
133
|
+
export { useDynamicWaas } from './lib/utils/hooks/useDynamicWaas/useDynamicWaas.js';
|
|
134
134
|
export { useRefreshUser } from './lib/utils/hooks/useRefreshUser/useRefreshUser.js';
|
|
135
|
+
export { useEmbeddedWalletAuthenticator } from './lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.js';
|
|
135
136
|
import './lib/widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js';
|
|
136
137
|
import './lib/context/OnrampContext/OnrampContext.js';
|
|
137
138
|
export { FilterAndSortWallets, FilterBridgeChainsName, FilterChain, FilterWallets, RemoveWallets, SortWallets, UniswapFilter } from './lib/utils/functions/walletFilters/index.js';
|
|
@@ -150,7 +151,6 @@ export { FarcasterConnectView } from './lib/views/FarcasterConnectView/Farcaster
|
|
|
150
151
|
export { NetworkNotSupportedSwitchManual } from './lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js';
|
|
151
152
|
export { viewToComponentMap } from './lib/views/viewToComponentMap.js';
|
|
152
153
|
import './lib/store/state/connectorsInitializing/connectorsInitializing.js';
|
|
153
|
-
export { useDynamicWaas } from './lib/utils/hooks/useDynamicWaas/useDynamicWaas.js';
|
|
154
154
|
export { useGetMfaToken } from './lib/utils/hooks/useGetMfaToken/useGetMfaToken.js';
|
|
155
155
|
export { useDynamicModals } from './lib/utils/hooks/useDynamicModals/useDynamicModals.js';
|
|
156
156
|
export { useMfa } from './lib/utils/hooks/useMfa/useMfa.js';
|
|
@@ -197,6 +197,7 @@ export { useOpenFundingOptions } from './lib/utils/hooks/useOpenFundingOptions/u
|
|
|
197
197
|
export { useSendBalance } from './lib/context/SendBalanceContext/SendBalanceContext.js';
|
|
198
198
|
import './lib/context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
199
199
|
export { useConnectWithOtp } from './lib/context/ConnectWithOtpContext/useConnectWithOtp.js';
|
|
200
|
+
export { usePhantomRedirectEvents } from './lib/utils/hooks/usePhantomRedirectEvents/usePhantomRedirectEvents.js';
|
|
200
201
|
export { useSwitchNetwork } from './lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.js';
|
|
201
202
|
export { useReinitialize } from './lib/context/ReinitializeContext/ReinitializeContextProvider.js';
|
|
202
203
|
|
|
@@ -334,7 +334,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
334
334
|
useSetWalletConnectorVerifiedCredentials.useSetWalletConnectorVerifiedCredentials(user !== null && user !== void 0 ? user : userWithMissingInfo, walletConnectorOptions);
|
|
335
335
|
useSetWalletConnectorFetchers.useSetWalletConnectorFetchers(walletConnectorOptions, environmentId, projectSettings);
|
|
336
336
|
const { primaryWallet, showQrcodeModal, secondaryWallets, setPrimaryWallet, setShowQrcodeModal, wallets: linkedOrConnectedWallets, } = useWalletConnectors.useWalletConnectors({
|
|
337
|
-
canHaveMultipleWalletsConnected: multiWallet,
|
|
337
|
+
canHaveMultipleWalletsConnected: multiWallet || isBridgeFlow,
|
|
338
338
|
connectedWallets,
|
|
339
339
|
primaryWalletId: primaryWalletId$1,
|
|
340
340
|
separateSmartWalletAndSigner: (_p = (_o = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _o === void 0 ? void 0 : _o.accountAbstraction) === null || _p === void 0 ? void 0 : _p.separateSmartWalletAndSigner,
|
|
@@ -330,7 +330,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
330
330
|
useSetWalletConnectorVerifiedCredentials(user !== null && user !== void 0 ? user : userWithMissingInfo, walletConnectorOptions);
|
|
331
331
|
useSetWalletConnectorFetchers(walletConnectorOptions, environmentId, projectSettings);
|
|
332
332
|
const { primaryWallet, showQrcodeModal, secondaryWallets, setPrimaryWallet, setShowQrcodeModal, wallets: linkedOrConnectedWallets, } = useWalletConnectors({
|
|
333
|
-
canHaveMultipleWalletsConnected: multiWallet,
|
|
333
|
+
canHaveMultipleWalletsConnected: multiWallet || isBridgeFlow,
|
|
334
334
|
connectedWallets,
|
|
335
335
|
primaryWalletId,
|
|
336
336
|
separateSmartWalletAndSigner: (_p = (_o = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _o === void 0 ? void 0 : _o.accountAbstraction) === null || _p === void 0 ? void 0 : _p.separateSmartWalletAndSigner,
|
package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs
CHANGED
|
@@ -146,6 +146,16 @@ const useTieCallbacksToEvents = ({ clientCallbacks, user, }) => {
|
|
|
146
146
|
});
|
|
147
147
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onEmbeddedWalletCreated) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, jwtVerifiedCredential, user);
|
|
148
148
|
});
|
|
149
|
+
useDynamicEvents.useInternalDynamicEvents('embeddedWalletRevealCompleted', (wallet) => {
|
|
150
|
+
var _a;
|
|
151
|
+
logger.logger.debug('[embeddedWalletRevealCompleted]', { wallet });
|
|
152
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onEmbeddedWalletRevealSuccess) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, wallet);
|
|
153
|
+
});
|
|
154
|
+
useDynamicEvents.useInternalDynamicEvents('embeddedWalletRevealFailed', (error) => {
|
|
155
|
+
var _a;
|
|
156
|
+
logger.logger.debug('[embeddedWalletRevealFailed]', { error });
|
|
157
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onEmbeddedWalletRevealFailure) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, error);
|
|
158
|
+
});
|
|
149
159
|
useDynamicEvents.useInternalDynamicEvents('logout', () => {
|
|
150
160
|
var _a;
|
|
151
161
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onLogout) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, user);
|
package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js
CHANGED
|
@@ -142,6 +142,16 @@ const useTieCallbacksToEvents = ({ clientCallbacks, user, }) => {
|
|
|
142
142
|
});
|
|
143
143
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onEmbeddedWalletCreated) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, jwtVerifiedCredential, user);
|
|
144
144
|
});
|
|
145
|
+
useInternalDynamicEvents('embeddedWalletRevealCompleted', (wallet) => {
|
|
146
|
+
var _a;
|
|
147
|
+
logger.debug('[embeddedWalletRevealCompleted]', { wallet });
|
|
148
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onEmbeddedWalletRevealSuccess) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, wallet);
|
|
149
|
+
});
|
|
150
|
+
useInternalDynamicEvents('embeddedWalletRevealFailed', (error) => {
|
|
151
|
+
var _a;
|
|
152
|
+
logger.debug('[embeddedWalletRevealFailed]', { error });
|
|
153
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onEmbeddedWalletRevealFailure) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, error);
|
|
154
|
+
});
|
|
145
155
|
useInternalDynamicEvents('logout', () => {
|
|
146
156
|
var _a;
|
|
147
157
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onLogout) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, user);
|
|
@@ -215,7 +215,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
215
215
|
onrampOverrides,
|
|
216
216
|
overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions,
|
|
217
217
|
]);
|
|
218
|
-
const openOnramp = React.useCallback((_f) => _tslib.__awaiter(void 0, [_f], void 0, function* ({ onrampProvider, address, token, tokenAmount, network: networkOverride, chainName, currency, overrideOnRamp, payingWithDynamic, }) {
|
|
218
|
+
const openOnramp = React.useCallback((_f) => _tslib.__awaiter(void 0, [_f], void 0, function* ({ onrampProvider, address, token, tokenAmount, network: networkOverride, chainName, currency, overrideOnRamp, payingWithDynamic, merchantName, }) {
|
|
219
219
|
var _g, _h, _j, _k;
|
|
220
220
|
if (!onrampEnabled && !overrideOnRamp && !payingWithDynamic) {
|
|
221
221
|
throw new Error('Onramp is not enabled');
|
|
@@ -237,7 +237,8 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
237
237
|
Boolean(networkOverride) ||
|
|
238
238
|
Boolean(tokenAmount) ||
|
|
239
239
|
Boolean(chainName) ||
|
|
240
|
-
Boolean(currency)
|
|
240
|
+
Boolean(currency) ||
|
|
241
|
+
Boolean(merchantName);
|
|
241
242
|
const allPayingParameters = Boolean(chainName) &&
|
|
242
243
|
Boolean(networkToUse) &&
|
|
243
244
|
Boolean(token) &&
|
|
@@ -257,6 +258,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
257
258
|
currency,
|
|
258
259
|
environmentId,
|
|
259
260
|
includeDisabled: overrideOnRamp,
|
|
261
|
+
merchantName,
|
|
260
262
|
network: networkToUse,
|
|
261
263
|
primaryWallet,
|
|
262
264
|
token,
|
|
@@ -211,7 +211,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
211
211
|
onrampOverrides,
|
|
212
212
|
overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions,
|
|
213
213
|
]);
|
|
214
|
-
const openOnramp = useCallback((_f) => __awaiter(void 0, [_f], void 0, function* ({ onrampProvider, address, token, tokenAmount, network: networkOverride, chainName, currency, overrideOnRamp, payingWithDynamic, }) {
|
|
214
|
+
const openOnramp = useCallback((_f) => __awaiter(void 0, [_f], void 0, function* ({ onrampProvider, address, token, tokenAmount, network: networkOverride, chainName, currency, overrideOnRamp, payingWithDynamic, merchantName, }) {
|
|
215
215
|
var _g, _h, _j, _k;
|
|
216
216
|
if (!onrampEnabled && !overrideOnRamp && !payingWithDynamic) {
|
|
217
217
|
throw new Error('Onramp is not enabled');
|
|
@@ -233,7 +233,8 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
233
233
|
Boolean(networkOverride) ||
|
|
234
234
|
Boolean(tokenAmount) ||
|
|
235
235
|
Boolean(chainName) ||
|
|
236
|
-
Boolean(currency)
|
|
236
|
+
Boolean(currency) ||
|
|
237
|
+
Boolean(merchantName);
|
|
237
238
|
const allPayingParameters = Boolean(chainName) &&
|
|
238
239
|
Boolean(networkToUse) &&
|
|
239
240
|
Boolean(token) &&
|
|
@@ -253,6 +254,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
253
254
|
currency,
|
|
254
255
|
environmentId,
|
|
255
256
|
includeDisabled: overrideOnRamp,
|
|
257
|
+
merchantName,
|
|
256
258
|
network: networkToUse,
|
|
257
259
|
primaryWallet,
|
|
258
260
|
token,
|
|
@@ -11,7 +11,7 @@ var getWalletAdditionalAddressByType = require('../../../utils/functions/getWall
|
|
|
11
11
|
|
|
12
12
|
const DEFAULT_NETWORK = 'evm';
|
|
13
13
|
const DEFAULT_CHAIN = '1';
|
|
14
|
-
const getOnrampProviders = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ address, chainName, environmentId, network, primaryWallet, token, tokenAmount, currency, includeDisabled = false, }) {
|
|
14
|
+
const getOnrampProviders = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ address, chainName, environmentId, network, primaryWallet, token, tokenAmount, currency, includeDisabled = false, merchantName, }) {
|
|
15
15
|
var _b;
|
|
16
16
|
const tempChainNameToUse = (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain)
|
|
17
17
|
? (_b = walletConnectorCore.getChainInfo(primaryWallet.chain)) === null || _b === void 0 ? void 0 : _b.name
|
|
@@ -39,6 +39,7 @@ const getOnrampProviders = (_a) => _tslib.__awaiter(void 0, [_a], void 0, functi
|
|
|
39
39
|
currency,
|
|
40
40
|
environmentId,
|
|
41
41
|
includeDisabled,
|
|
42
|
+
merchantName,
|
|
42
43
|
networkId: networkToUse,
|
|
43
44
|
token,
|
|
44
45
|
tokenAmount,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { RampConfiguration } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { GetProvidersParams } from '../types';
|
|
3
|
-
export declare const getOnrampProviders: ({ address, chainName, environmentId, network, primaryWallet, token, tokenAmount, currency, includeDisabled, }: GetProvidersParams) => Promise<RampConfiguration[]>;
|
|
3
|
+
export declare const getOnrampProviders: ({ address, chainName, environmentId, network, primaryWallet, token, tokenAmount, currency, includeDisabled, merchantName, }: GetProvidersParams) => Promise<RampConfiguration[]>;
|
|
@@ -7,7 +7,7 @@ import { getWalletAdditionalAddressByType } from '../../../utils/functions/getWa
|
|
|
7
7
|
|
|
8
8
|
const DEFAULT_NETWORK = 'evm';
|
|
9
9
|
const DEFAULT_CHAIN = '1';
|
|
10
|
-
const getOnrampProviders = (_a) => __awaiter(void 0, [_a], void 0, function* ({ address, chainName, environmentId, network, primaryWallet, token, tokenAmount, currency, includeDisabled = false, }) {
|
|
10
|
+
const getOnrampProviders = (_a) => __awaiter(void 0, [_a], void 0, function* ({ address, chainName, environmentId, network, primaryWallet, token, tokenAmount, currency, includeDisabled = false, merchantName, }) {
|
|
11
11
|
var _b;
|
|
12
12
|
const tempChainNameToUse = (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain)
|
|
13
13
|
? (_b = getChainInfo(primaryWallet.chain)) === null || _b === void 0 ? void 0 : _b.name
|
|
@@ -35,6 +35,7 @@ const getOnrampProviders = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
35
35
|
currency,
|
|
36
36
|
environmentId,
|
|
37
37
|
includeDisabled,
|
|
38
|
+
merchantName,
|
|
38
39
|
networkId: networkToUse,
|
|
39
40
|
token,
|
|
40
41
|
tokenAmount,
|
|
@@ -11,7 +11,7 @@ require('../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
|
11
11
|
require('@dynamic-labs/iconic');
|
|
12
12
|
require('@dynamic-labs/wallet-connector-core');
|
|
13
13
|
require('../ViewContext/ViewContext.cjs');
|
|
14
|
-
require('../../shared/logger.cjs');
|
|
14
|
+
var logger = require('../../shared/logger.cjs');
|
|
15
15
|
require('@dynamic-labs/wallet-book');
|
|
16
16
|
require('../../utils/constants/colors.cjs');
|
|
17
17
|
require('../../utils/constants/values.cjs');
|
|
@@ -110,11 +110,27 @@ const PhantomRedirectContextProvider = ({ children, }) => {
|
|
|
110
110
|
// Track the last processed redirect params to prevent infinite loops
|
|
111
111
|
// when useEffect re-runs due to callback dependency changes
|
|
112
112
|
const lastProcessedParamsRef = React.useRef('');
|
|
113
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Process Phantom redirect response from URL params.
|
|
115
|
+
* This is called both on initial render and when URL updates (for native mobile deep links).
|
|
116
|
+
*/
|
|
117
|
+
const processPhantomRedirect = React.useCallback((url) => {
|
|
118
|
+
const hasData = url.searchParams.has('data');
|
|
119
|
+
const hasConnect = url.searchParams.has('phantom_encryption_public_key');
|
|
120
|
+
const hasError = url.searchParams.has('errorCode');
|
|
121
|
+
// Only log if there's something relevant to process
|
|
122
|
+
if (hasData || hasConnect || hasError) {
|
|
123
|
+
logger.logger.logVerboseTroubleshootingMessage('[PhantomRedirectContext] processPhantomRedirect', {
|
|
124
|
+
hasConnect,
|
|
125
|
+
hasData,
|
|
126
|
+
hasError,
|
|
127
|
+
sdkHasLoaded,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
114
130
|
if (!phantomRedirectConnector || !utils.isMobile() || !sdkHasLoaded) {
|
|
115
131
|
return;
|
|
116
132
|
}
|
|
117
|
-
const params =
|
|
133
|
+
const params = url.searchParams;
|
|
118
134
|
// Create a unique key from the relevant params to track if we've already processed this redirect
|
|
119
135
|
const paramsKey = [
|
|
120
136
|
params.get('errorCode'),
|
|
@@ -125,9 +141,9 @@ const PhantomRedirectContextProvider = ({ children, }) => {
|
|
|
125
141
|
.filter(Boolean)
|
|
126
142
|
.join('|');
|
|
127
143
|
// If we've already processed these exact params, skip to prevent infinite loop
|
|
128
|
-
// This prevents the
|
|
129
|
-
// when callback dependencies change and cause the effect to re-run
|
|
144
|
+
// This prevents the callback from processing the same redirect multiple times
|
|
130
145
|
if (paramsKey && paramsKey === lastProcessedParamsRef.current) {
|
|
146
|
+
logger.logger.logVerboseTroubleshootingMessage('[PhantomRedirectContext] skipping - already processed');
|
|
131
147
|
return;
|
|
132
148
|
}
|
|
133
149
|
// Update the ref before processing to mark these params as processed
|
|
@@ -135,19 +151,21 @@ const PhantomRedirectContextProvider = ({ children, }) => {
|
|
|
135
151
|
lastProcessedParamsRef.current = paramsKey;
|
|
136
152
|
}
|
|
137
153
|
if (params.has('errorCode')) {
|
|
154
|
+
logger.logger.logVerboseTroubleshootingMessage('[PhantomRedirectContext] handling errorCode response');
|
|
138
155
|
handleErrorResponse(params);
|
|
139
156
|
return;
|
|
140
157
|
}
|
|
141
158
|
// handle response of connect method
|
|
142
159
|
if (params.has('phantom_encryption_public_key')) {
|
|
160
|
+
logger.logger.logVerboseTroubleshootingMessage('[PhantomRedirectContext] handling connect response');
|
|
143
161
|
handleConnectResponse();
|
|
144
162
|
return;
|
|
145
163
|
}
|
|
146
164
|
// handle response of the following methods:
|
|
147
165
|
// signMessage, signTransaction, signAndSendTransaction or signAllTransactions
|
|
148
166
|
if (params.has('data')) {
|
|
167
|
+
logger.logger.logVerboseTroubleshootingMessage('[PhantomRedirectContext] handling user response (data)');
|
|
149
168
|
handleUserResponse();
|
|
150
|
-
return;
|
|
151
169
|
}
|
|
152
170
|
}, [
|
|
153
171
|
handleConnectResponse,
|
|
@@ -156,10 +174,24 @@ const PhantomRedirectContextProvider = ({ children, }) => {
|
|
|
156
174
|
phantomRedirectConnector,
|
|
157
175
|
sdkHasLoaded,
|
|
158
176
|
]);
|
|
177
|
+
// Process redirect on initial render and dependency changes
|
|
178
|
+
React.useEffect(() => {
|
|
179
|
+
processPhantomRedirect(utils.PlatformService.getUrl());
|
|
180
|
+
}, [processPhantomRedirect]);
|
|
181
|
+
// Listen for URL updates from native mobile deep links
|
|
182
|
+
React.useEffect(() => utils.PlatformService.onUrlUpdate(processPhantomRedirect), [processPhantomRedirect]);
|
|
159
183
|
return (jsxRuntime.jsx(PhantomRedirectContext.Provider, { value: {
|
|
160
184
|
phantomRedirectConnector,
|
|
161
185
|
}, children: children }));
|
|
162
186
|
};
|
|
187
|
+
const usePhantomRedirectContext = () => {
|
|
188
|
+
const context = React.useContext(PhantomRedirectContext);
|
|
189
|
+
if (context === undefined) {
|
|
190
|
+
throw new Error('usePhantomRedirectContext must be used within a PhantomRedirectContextProvider');
|
|
191
|
+
}
|
|
192
|
+
return context;
|
|
193
|
+
};
|
|
163
194
|
|
|
164
195
|
exports.PhantomRedirectContext = PhantomRedirectContext;
|
|
165
196
|
exports.PhantomRedirectContextProvider = PhantomRedirectContextProvider;
|
|
197
|
+
exports.usePhantomRedirectContext = usePhantomRedirectContext;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { IPhantomRedirectConnectorWithEvents } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
export type PhantomContextReturnType = {
|
|
4
|
-
phantomRedirectConnector:
|
|
4
|
+
phantomRedirectConnector: IPhantomRedirectConnectorWithEvents | undefined;
|
|
5
5
|
};
|
|
6
6
|
export declare const PhantomRedirectContext: import("react").Context<PhantomContextReturnType | undefined>;
|
|
7
7
|
export declare const PhantomRedirectContextProvider: ({ children, }: {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useRef, useEffect } from 'react';
|
|
3
|
+
import { createContext, useContext, useRef, useCallback, useEffect } from 'react';
|
|
4
4
|
import { isMobile, PlatformService } from '@dynamic-labs/utils';
|
|
5
5
|
import '../DynamicContext/DynamicContext.js';
|
|
6
6
|
import '../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
7
7
|
import '@dynamic-labs/iconic';
|
|
8
8
|
import '@dynamic-labs/wallet-connector-core';
|
|
9
9
|
import '../ViewContext/ViewContext.js';
|
|
10
|
-
import '../../shared/logger.js';
|
|
10
|
+
import { logger } from '../../shared/logger.js';
|
|
11
11
|
import '@dynamic-labs/wallet-book';
|
|
12
12
|
import '../../utils/constants/colors.js';
|
|
13
13
|
import '../../utils/constants/values.js';
|
|
@@ -106,11 +106,27 @@ const PhantomRedirectContextProvider = ({ children, }) => {
|
|
|
106
106
|
// Track the last processed redirect params to prevent infinite loops
|
|
107
107
|
// when useEffect re-runs due to callback dependency changes
|
|
108
108
|
const lastProcessedParamsRef = useRef('');
|
|
109
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Process Phantom redirect response from URL params.
|
|
111
|
+
* This is called both on initial render and when URL updates (for native mobile deep links).
|
|
112
|
+
*/
|
|
113
|
+
const processPhantomRedirect = useCallback((url) => {
|
|
114
|
+
const hasData = url.searchParams.has('data');
|
|
115
|
+
const hasConnect = url.searchParams.has('phantom_encryption_public_key');
|
|
116
|
+
const hasError = url.searchParams.has('errorCode');
|
|
117
|
+
// Only log if there's something relevant to process
|
|
118
|
+
if (hasData || hasConnect || hasError) {
|
|
119
|
+
logger.logVerboseTroubleshootingMessage('[PhantomRedirectContext] processPhantomRedirect', {
|
|
120
|
+
hasConnect,
|
|
121
|
+
hasData,
|
|
122
|
+
hasError,
|
|
123
|
+
sdkHasLoaded,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
110
126
|
if (!phantomRedirectConnector || !isMobile() || !sdkHasLoaded) {
|
|
111
127
|
return;
|
|
112
128
|
}
|
|
113
|
-
const params =
|
|
129
|
+
const params = url.searchParams;
|
|
114
130
|
// Create a unique key from the relevant params to track if we've already processed this redirect
|
|
115
131
|
const paramsKey = [
|
|
116
132
|
params.get('errorCode'),
|
|
@@ -121,9 +137,9 @@ const PhantomRedirectContextProvider = ({ children, }) => {
|
|
|
121
137
|
.filter(Boolean)
|
|
122
138
|
.join('|');
|
|
123
139
|
// If we've already processed these exact params, skip to prevent infinite loop
|
|
124
|
-
// This prevents the
|
|
125
|
-
// when callback dependencies change and cause the effect to re-run
|
|
140
|
+
// This prevents the callback from processing the same redirect multiple times
|
|
126
141
|
if (paramsKey && paramsKey === lastProcessedParamsRef.current) {
|
|
142
|
+
logger.logVerboseTroubleshootingMessage('[PhantomRedirectContext] skipping - already processed');
|
|
127
143
|
return;
|
|
128
144
|
}
|
|
129
145
|
// Update the ref before processing to mark these params as processed
|
|
@@ -131,19 +147,21 @@ const PhantomRedirectContextProvider = ({ children, }) => {
|
|
|
131
147
|
lastProcessedParamsRef.current = paramsKey;
|
|
132
148
|
}
|
|
133
149
|
if (params.has('errorCode')) {
|
|
150
|
+
logger.logVerboseTroubleshootingMessage('[PhantomRedirectContext] handling errorCode response');
|
|
134
151
|
handleErrorResponse(params);
|
|
135
152
|
return;
|
|
136
153
|
}
|
|
137
154
|
// handle response of connect method
|
|
138
155
|
if (params.has('phantom_encryption_public_key')) {
|
|
156
|
+
logger.logVerboseTroubleshootingMessage('[PhantomRedirectContext] handling connect response');
|
|
139
157
|
handleConnectResponse();
|
|
140
158
|
return;
|
|
141
159
|
}
|
|
142
160
|
// handle response of the following methods:
|
|
143
161
|
// signMessage, signTransaction, signAndSendTransaction or signAllTransactions
|
|
144
162
|
if (params.has('data')) {
|
|
163
|
+
logger.logVerboseTroubleshootingMessage('[PhantomRedirectContext] handling user response (data)');
|
|
145
164
|
handleUserResponse();
|
|
146
|
-
return;
|
|
147
165
|
}
|
|
148
166
|
}, [
|
|
149
167
|
handleConnectResponse,
|
|
@@ -152,9 +170,22 @@ const PhantomRedirectContextProvider = ({ children, }) => {
|
|
|
152
170
|
phantomRedirectConnector,
|
|
153
171
|
sdkHasLoaded,
|
|
154
172
|
]);
|
|
173
|
+
// Process redirect on initial render and dependency changes
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
processPhantomRedirect(PlatformService.getUrl());
|
|
176
|
+
}, [processPhantomRedirect]);
|
|
177
|
+
// Listen for URL updates from native mobile deep links
|
|
178
|
+
useEffect(() => PlatformService.onUrlUpdate(processPhantomRedirect), [processPhantomRedirect]);
|
|
155
179
|
return (jsx(PhantomRedirectContext.Provider, { value: {
|
|
156
180
|
phantomRedirectConnector,
|
|
157
181
|
}, children: children }));
|
|
158
182
|
};
|
|
183
|
+
const usePhantomRedirectContext = () => {
|
|
184
|
+
const context = useContext(PhantomRedirectContext);
|
|
185
|
+
if (context === undefined) {
|
|
186
|
+
throw new Error('usePhantomRedirectContext must be used within a PhantomRedirectContextProvider');
|
|
187
|
+
}
|
|
188
|
+
return context;
|
|
189
|
+
};
|
|
159
190
|
|
|
160
|
-
export { PhantomRedirectContext, PhantomRedirectContextProvider };
|
|
191
|
+
export { PhantomRedirectContext, PhantomRedirectContextProvider, usePhantomRedirectContext };
|