@dynamic-labs/sdk-react-core 4.22.8 → 4.23.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 +16 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +13 -13
- package/src/index.cjs +2 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -1
- package/src/lib/client/client.cjs +2 -0
- package/src/lib/client/client.d.ts +1 -0
- package/src/lib/client/client.js +2 -1
- package/src/lib/client/extension/hooks/useInitializeSdkClient/fetchOverride/fetchOverride.cjs +5 -1
- package/src/lib/client/extension/hooks/useInitializeSdkClient/fetchOverride/fetchOverride.js +5 -1
- package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.cjs +24 -6
- package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.d.ts +1 -1
- package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.js +26 -8
- package/src/lib/components/MenuList/DropdownMenu/DropdownMenu.cjs +1 -1
- package/src/lib/components/MenuList/DropdownMenu/DropdownMenu.js +1 -1
- package/src/lib/components/Search/Search.cjs +5 -1
- package/src/lib/components/Search/Search.js +5 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +1 -1
- package/src/lib/context/DynamicContext/types/DynamicContextProps.d.ts +9 -2
- package/src/lib/events/dynamicEvents.cjs +1 -0
- package/src/lib/events/dynamicEvents.d.ts +2 -2
- package/src/lib/events/dynamicEvents.js +1 -0
- package/src/lib/events/wallets.d.ts +2 -0
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.cjs +1 -1
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.js +1 -1
- package/src/lib/locale/en/translation.cjs +30 -0
- package/src/lib/locale/en/translation.d.ts +30 -0
- package/src/lib/locale/en/translation.js +30 -0
- package/src/lib/shared/logger.cjs +1 -1
- package/src/lib/shared/logger.js +2 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/getSessionInformation/getSessionInformation.cjs +1 -1
- package/src/lib/utils/functions/getSessionInformation/getSessionInformation.js +1 -1
- package/src/lib/utils/functions/getTimeSince/index.d.ts +1 -0
- package/src/lib/utils/functions/updatePrimaryWalletId/updatePrimaryWalletId.cjs +1 -1
- package/src/lib/utils/functions/updatePrimaryWalletId/updatePrimaryWalletId.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/helpers/isConnectOnly.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/helpers/isConnectOnly.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +1 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/index.d.ts +3 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.cjs +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.js +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +1 -1
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +1 -1
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +1 -1
- package/src/lib/utils/hooks/useConnectWallet/HandleConnectWalletRejectionError.cjs +15 -0
- package/src/lib/utils/hooks/useConnectWallet/HandleConnectWalletRejectionError.d.ts +6 -0
- package/src/lib/utils/hooks/useConnectWallet/HandleConnectWalletRejectionError.js +11 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +13 -6
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +2 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +13 -6
- package/src/lib/utils/hooks/useIsLoadingEmbeddedWallet/useIsLoadingEmbeddedWallet.cjs +1 -1
- package/src/lib/utils/hooks/useIsLoadingEmbeddedWallet/useIsLoadingEmbeddedWallet.js +1 -1
- package/src/lib/utils/hooks/useIsMfaEnabled/index.d.ts +1 -0
- package/src/lib/utils/hooks/useIsMfaEnabled/useIsMfaEnabled.cjs +15 -0
- package/src/lib/utils/hooks/useIsMfaEnabled/useIsMfaEnabled.d.ts +1 -0
- package/src/lib/utils/hooks/useIsMfaEnabled/useIsMfaEnabled.js +11 -0
- package/src/lib/utils/hooks/useIsPasskeysMfaEnabled/index.d.ts +1 -0
- package/src/lib/utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.cjs +15 -0
- package/src/lib/utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.d.ts +1 -0
- package/src/lib/utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.js +11 -0
- package/src/lib/utils/hooks/useIsTotpMfaEnabled/index.d.ts +1 -0
- package/src/lib/utils/hooks/useIsTotpMfaEnabled/useIsTotpMfaEnabled.cjs +15 -0
- package/src/lib/utils/hooks/useIsTotpMfaEnabled/useIsTotpMfaEnabled.d.ts +1 -0
- package/src/lib/utils/hooks/useIsTotpMfaEnabled/useIsTotpMfaEnabled.js +11 -0
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +1 -1
- package/src/lib/utils/hooks/useMfa/useMfa.js +1 -1
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.cjs +33 -18
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.d.ts +4 -0
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.js +33 -18
- package/src/lib/utils/hooks/useRefreshUserState/useRefreshUserState.cjs +1 -1
- package/src/lib/utils/hooks/useRefreshUserState/useRefreshUserState.js +1 -1
- package/src/lib/utils/hooks/useRegisterPasskey/useRegisterPasskey.d.ts +2 -2
- package/src/lib/utils/hooks/useSubmitExchangeFunding/useSubmitExchangeFunding.cjs +11 -2
- package/src/lib/utils/hooks/useSubmitExchangeFunding/useSubmitExchangeFunding.js +11 -2
- 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/useTokenBalances/useTokenBalances.cjs +1 -1
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +1 -1
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.cjs +1 -1
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.js +1 -1
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +1 -1
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +1 -1
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +43 -6
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.d.ts +2 -1
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +43 -6
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +17 -8
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.d.ts +1 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +17 -8
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.cjs +8 -2
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.js +8 -2
- package/src/lib/views/ExchangeList/ExchangeList.cjs +9 -14
- package/src/lib/views/ExchangeList/ExchangeList.js +10 -15
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.cjs +2 -2
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.js +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +1 -1
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +1 -1
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.cjs +4 -2
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.d.ts +2 -2
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.js +4 -2
- package/src/lib/views/WalletList/WalletList.cjs +1 -1
- package/src/lib/views/WalletList/WalletList.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +2 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +3 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +4 -4
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +4 -4
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +1 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +2 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.js +2 -2
- package/src/lib/widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs +0 -6
- package/src/lib/widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js +1 -6
- package/src/lib/widgets/DynamicWidget/helpers/helpers.cjs +0 -1
- package/src/lib/widgets/DynamicWidget/helpers/helpers.d.ts +0 -1
- package/src/lib/widgets/DynamicWidget/helpers/helpers.js +0 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchNameService/useFetchNameService.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchNameService/useFetchNameService.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +42 -106
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +43 -107
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +119 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.d.ts +6 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +115 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/WalletSecuritySection/WalletSecuritySection.cjs +170 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/WalletSecuritySection/WalletSecuritySection.d.ts +7 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/WalletSecuritySection/WalletSecuritySection.js +166 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/WalletSecuritySection/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExchangeFunding/useStartExchangeFunding.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExchangeFunding/useStartExchangeFunding.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/DepositedExchangeView/DepositedExchangeView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/DepositedExchangeView/DepositedExchangeView.js +2 -2
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView/ManageMfaWidgetView.cjs → ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.cjs} +8 -7
- package/src/lib/widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView/ManageMfaWidgetView.js → ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.js} +7 -6
- package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/UserDeviceTile.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/UserDeviceTile.js +3 -3
- package/src/lib/widgets/DynamicWidget/views/ManageTotpMfaWidgetView/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +5 -4
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +5 -4
- package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/ManageMfaWidgetView.d.ts +0 -2
- package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/index.d.ts +0 -1
- /package/src/lib/{widgets/DynamicWidget/helpers → utils/functions/getTimeSince}/getTimeSince.cjs +0 -0
- /package/src/lib/{widgets/DynamicWidget/helpers → utils/functions/getTimeSince}/getTimeSince.d.ts +0 -0
- /package/src/lib/{widgets/DynamicWidget/helpers → utils/functions/getTimeSince}/getTimeSince.js +0 -0
- /package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/UserDeviceTile.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/index.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/utils/sort.cjs +0 -0
- /package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/utils/sort.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/utils/sort.js +0 -0
|
@@ -9,8 +9,8 @@ require('@dynamic-labs-sdk/client/core');
|
|
|
9
9
|
require('@dynamic-labs/sdk-api-core');
|
|
10
10
|
require('@dynamic-labs-sdk/client');
|
|
11
11
|
require('../../../client/client.cjs');
|
|
12
|
-
require('../../constants/values.cjs');
|
|
13
12
|
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../constants/values.cjs');
|
|
14
14
|
require('@dynamic-labs/multi-wallet');
|
|
15
15
|
require('../../../shared/logger.cjs');
|
|
16
16
|
require('../../constants/colors.cjs');
|
|
@@ -23,7 +23,7 @@ require('@dynamic-labs/wallet-book');
|
|
|
23
23
|
require('../../../shared/consts/index.cjs');
|
|
24
24
|
require('../../../store/state/nonce/nonce.cjs');
|
|
25
25
|
require('../../../config/ApiEndpoint.cjs');
|
|
26
|
-
|
|
26
|
+
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
27
27
|
require('../../../locale/locale.cjs');
|
|
28
28
|
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
29
29
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
@@ -96,79 +96,94 @@ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCa
|
|
|
96
96
|
require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
97
97
|
require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
98
98
|
require('../../../../index.cjs');
|
|
99
|
+
var useIsMfaEnabled = require('../useIsMfaEnabled/useIsMfaEnabled.cjs');
|
|
100
|
+
var useIsTotpMfaEnabled = require('../useIsTotpMfaEnabled/useIsTotpMfaEnabled.cjs');
|
|
99
101
|
require('../../../store/state/tokenBalances.cjs');
|
|
100
102
|
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
101
103
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
102
104
|
|
|
103
105
|
const useMfaModals = () => {
|
|
104
|
-
var _a;
|
|
105
106
|
const { setShowAuthFlow, setShowDynamicUserProfile } = useInternalDynamicContext.useInternalDynamicContext();
|
|
106
|
-
const projectSettings$1 = projectSettings.useProjectSettings();
|
|
107
107
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
108
108
|
const { clearStackAndPush } = ViewContext.useViewContext();
|
|
109
|
-
const isMfaEnabled = (
|
|
110
|
-
const
|
|
109
|
+
const isMfaEnabled = useIsMfaEnabled.useIsMfaEnabled();
|
|
110
|
+
const isTotpMfaEnabled = useIsTotpMfaEnabled.useIsTotpMfaEnabled();
|
|
111
|
+
const setShowTotpMfaManage = React.useCallback((value) => {
|
|
111
112
|
if (value) {
|
|
112
|
-
if (!
|
|
113
|
+
if (!isTotpMfaEnabled) {
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
|
-
setDynamicWidgetView('manage-mfa-no-footer');
|
|
116
|
+
setDynamicWidgetView('manage-totp-mfa-no-footer');
|
|
116
117
|
}
|
|
117
118
|
setShowDynamicUserProfile(value);
|
|
118
|
-
}, [
|
|
119
|
+
}, [isTotpMfaEnabled, setShowDynamicUserProfile, setDynamicWidgetView]);
|
|
119
120
|
const setShowMfaChooseType = React.useCallback((value) => {
|
|
120
121
|
if (value) {
|
|
121
|
-
if (!isMfaEnabled)
|
|
122
|
+
if (!isMfaEnabled) {
|
|
122
123
|
return;
|
|
124
|
+
}
|
|
123
125
|
clearStackAndPush('mfa-choose-device');
|
|
124
126
|
}
|
|
125
127
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
126
128
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
127
129
|
const setShowMfaQRCode = React.useCallback((value) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
128
130
|
if (value) {
|
|
129
|
-
if (!
|
|
131
|
+
if (!isTotpMfaEnabled) {
|
|
130
132
|
return;
|
|
133
|
+
}
|
|
131
134
|
const user = getUserProfile.getUserProfile();
|
|
132
135
|
// Already have MFA configured
|
|
133
136
|
if (user === null || user === void 0 ? void 0 : user.mfaBackupCodeAcknowledgement) {
|
|
134
|
-
|
|
137
|
+
setShowTotpMfaManage(true);
|
|
135
138
|
return;
|
|
136
139
|
}
|
|
137
140
|
clearStackAndPush('mfa-secure-device', { isInitialSetup: true });
|
|
138
141
|
}
|
|
139
142
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
140
|
-
}), [
|
|
143
|
+
}), [
|
|
144
|
+
isTotpMfaEnabled,
|
|
145
|
+
setShowAuthFlow,
|
|
146
|
+
clearStackAndPush,
|
|
147
|
+
setShowTotpMfaManage,
|
|
148
|
+
]);
|
|
141
149
|
const setShowOTPVerification = React.useCallback((value) => {
|
|
142
150
|
if (value) {
|
|
143
|
-
if (!
|
|
151
|
+
if (!isTotpMfaEnabled) {
|
|
144
152
|
return;
|
|
153
|
+
}
|
|
145
154
|
clearStackAndPush('mfa-verification');
|
|
146
155
|
}
|
|
147
156
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
148
|
-
}, [
|
|
157
|
+
}, [isTotpMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
149
158
|
const setShowMfaViewBackupCodes = React.useCallback((value) => {
|
|
150
159
|
if (value) {
|
|
151
|
-
if (!isMfaEnabled)
|
|
160
|
+
if (!isMfaEnabled) {
|
|
152
161
|
return;
|
|
162
|
+
}
|
|
153
163
|
clearStackAndPush('mfa-display-backup-codes');
|
|
154
164
|
}
|
|
155
165
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
156
166
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
157
167
|
const setShowMfaEnterBackupCodes = React.useCallback((value) => {
|
|
158
168
|
if (value) {
|
|
159
|
-
if (!isMfaEnabled)
|
|
169
|
+
if (!isMfaEnabled) {
|
|
160
170
|
return;
|
|
171
|
+
}
|
|
161
172
|
clearStackAndPush('mfa-recovery');
|
|
162
173
|
}
|
|
163
174
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
164
175
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
165
176
|
return {
|
|
166
|
-
|
|
177
|
+
/**
|
|
178
|
+
* @deprecated use setShowTotpMfaManage instead
|
|
179
|
+
*/
|
|
180
|
+
setShowMFAManage: setShowTotpMfaManage,
|
|
167
181
|
setShowMfaChooseType,
|
|
168
182
|
setShowMfaEnterBackupCodes,
|
|
169
183
|
setShowMfaQRCode,
|
|
170
184
|
setShowMfaViewBackupCodes,
|
|
171
185
|
setShowOTPVerification,
|
|
186
|
+
setShowTotpMfaManage,
|
|
172
187
|
};
|
|
173
188
|
};
|
|
174
189
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
export declare const useMfaModals: () => {
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated use setShowTotpMfaManage instead
|
|
5
|
+
*/
|
|
3
6
|
setShowMFAManage: Dispatch<SetStateAction<boolean>>;
|
|
4
7
|
setShowMfaChooseType: Dispatch<SetStateAction<boolean>>;
|
|
5
8
|
setShowMfaEnterBackupCodes: Dispatch<SetStateAction<boolean>>;
|
|
6
9
|
setShowMfaQRCode: Dispatch<SetStateAction<boolean>>;
|
|
7
10
|
setShowMfaViewBackupCodes: Dispatch<SetStateAction<boolean>>;
|
|
8
11
|
setShowOTPVerification: Dispatch<SetStateAction<boolean>>;
|
|
12
|
+
setShowTotpMfaManage: Dispatch<SetStateAction<boolean>>;
|
|
9
13
|
};
|
|
@@ -5,8 +5,8 @@ import '@dynamic-labs-sdk/client/core';
|
|
|
5
5
|
import '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import '@dynamic-labs-sdk/client';
|
|
7
7
|
import '../../../client/client.js';
|
|
8
|
-
import '../../constants/values.js';
|
|
9
8
|
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../constants/values.js';
|
|
10
10
|
import '@dynamic-labs/multi-wallet';
|
|
11
11
|
import '../../../shared/logger.js';
|
|
12
12
|
import '../../constants/colors.js';
|
|
@@ -19,7 +19,7 @@ import '@dynamic-labs/wallet-book';
|
|
|
19
19
|
import '../../../shared/consts/index.js';
|
|
20
20
|
import '../../../store/state/nonce/nonce.js';
|
|
21
21
|
import '../../../config/ApiEndpoint.js';
|
|
22
|
-
import
|
|
22
|
+
import '../../../store/state/projectSettings/projectSettings.js';
|
|
23
23
|
import '../../../locale/locale.js';
|
|
24
24
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
25
25
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
@@ -92,79 +92,94 @@ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCar
|
|
|
92
92
|
import '../../../context/OnrampContext/OnrampContext.js';
|
|
93
93
|
import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
94
94
|
import '../../../../index.js';
|
|
95
|
+
import { useIsMfaEnabled } from '../useIsMfaEnabled/useIsMfaEnabled.js';
|
|
96
|
+
import { useIsTotpMfaEnabled } from '../useIsTotpMfaEnabled/useIsTotpMfaEnabled.js';
|
|
95
97
|
import '../../../store/state/tokenBalances.js';
|
|
96
98
|
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
97
99
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
98
100
|
|
|
99
101
|
const useMfaModals = () => {
|
|
100
|
-
var _a;
|
|
101
102
|
const { setShowAuthFlow, setShowDynamicUserProfile } = useInternalDynamicContext();
|
|
102
|
-
const projectSettings = useProjectSettings();
|
|
103
103
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
104
104
|
const { clearStackAndPush } = useViewContext();
|
|
105
|
-
const isMfaEnabled = (
|
|
106
|
-
const
|
|
105
|
+
const isMfaEnabled = useIsMfaEnabled();
|
|
106
|
+
const isTotpMfaEnabled = useIsTotpMfaEnabled();
|
|
107
|
+
const setShowTotpMfaManage = useCallback((value) => {
|
|
107
108
|
if (value) {
|
|
108
|
-
if (!
|
|
109
|
+
if (!isTotpMfaEnabled) {
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
111
|
-
setDynamicWidgetView('manage-mfa-no-footer');
|
|
112
|
+
setDynamicWidgetView('manage-totp-mfa-no-footer');
|
|
112
113
|
}
|
|
113
114
|
setShowDynamicUserProfile(value);
|
|
114
|
-
}, [
|
|
115
|
+
}, [isTotpMfaEnabled, setShowDynamicUserProfile, setDynamicWidgetView]);
|
|
115
116
|
const setShowMfaChooseType = useCallback((value) => {
|
|
116
117
|
if (value) {
|
|
117
|
-
if (!isMfaEnabled)
|
|
118
|
+
if (!isMfaEnabled) {
|
|
118
119
|
return;
|
|
120
|
+
}
|
|
119
121
|
clearStackAndPush('mfa-choose-device');
|
|
120
122
|
}
|
|
121
123
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
122
124
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
123
125
|
const setShowMfaQRCode = useCallback((value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
126
|
if (value) {
|
|
125
|
-
if (!
|
|
127
|
+
if (!isTotpMfaEnabled) {
|
|
126
128
|
return;
|
|
129
|
+
}
|
|
127
130
|
const user = getUserProfile();
|
|
128
131
|
// Already have MFA configured
|
|
129
132
|
if (user === null || user === void 0 ? void 0 : user.mfaBackupCodeAcknowledgement) {
|
|
130
|
-
|
|
133
|
+
setShowTotpMfaManage(true);
|
|
131
134
|
return;
|
|
132
135
|
}
|
|
133
136
|
clearStackAndPush('mfa-secure-device', { isInitialSetup: true });
|
|
134
137
|
}
|
|
135
138
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
136
|
-
}), [
|
|
139
|
+
}), [
|
|
140
|
+
isTotpMfaEnabled,
|
|
141
|
+
setShowAuthFlow,
|
|
142
|
+
clearStackAndPush,
|
|
143
|
+
setShowTotpMfaManage,
|
|
144
|
+
]);
|
|
137
145
|
const setShowOTPVerification = useCallback((value) => {
|
|
138
146
|
if (value) {
|
|
139
|
-
if (!
|
|
147
|
+
if (!isTotpMfaEnabled) {
|
|
140
148
|
return;
|
|
149
|
+
}
|
|
141
150
|
clearStackAndPush('mfa-verification');
|
|
142
151
|
}
|
|
143
152
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
144
|
-
}, [
|
|
153
|
+
}, [isTotpMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
145
154
|
const setShowMfaViewBackupCodes = useCallback((value) => {
|
|
146
155
|
if (value) {
|
|
147
|
-
if (!isMfaEnabled)
|
|
156
|
+
if (!isMfaEnabled) {
|
|
148
157
|
return;
|
|
158
|
+
}
|
|
149
159
|
clearStackAndPush('mfa-display-backup-codes');
|
|
150
160
|
}
|
|
151
161
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
152
162
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
153
163
|
const setShowMfaEnterBackupCodes = useCallback((value) => {
|
|
154
164
|
if (value) {
|
|
155
|
-
if (!isMfaEnabled)
|
|
165
|
+
if (!isMfaEnabled) {
|
|
156
166
|
return;
|
|
167
|
+
}
|
|
157
168
|
clearStackAndPush('mfa-recovery');
|
|
158
169
|
}
|
|
159
170
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
160
171
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
161
172
|
return {
|
|
162
|
-
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated use setShowTotpMfaManage instead
|
|
175
|
+
*/
|
|
176
|
+
setShowMFAManage: setShowTotpMfaManage,
|
|
163
177
|
setShowMfaChooseType,
|
|
164
178
|
setShowMfaEnterBackupCodes,
|
|
165
179
|
setShowMfaQRCode,
|
|
166
180
|
setShowMfaViewBackupCodes,
|
|
167
181
|
setShowOTPVerification,
|
|
182
|
+
setShowTotpMfaManage,
|
|
168
183
|
};
|
|
169
184
|
};
|
|
170
185
|
|
|
@@ -9,8 +9,8 @@ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
|
9
9
|
require('@dynamic-labs-sdk/client/core');
|
|
10
10
|
require('@dynamic-labs-sdk/client');
|
|
11
11
|
require('../../../client/client.cjs');
|
|
12
|
-
require('../../constants/values.cjs');
|
|
13
12
|
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../constants/values.cjs');
|
|
14
14
|
require('@dynamic-labs/multi-wallet');
|
|
15
15
|
var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
|
|
16
16
|
var logger = require('../../../shared/logger.cjs');
|
|
@@ -5,8 +5,8 @@ import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
|
5
5
|
import '@dynamic-labs-sdk/client/core';
|
|
6
6
|
import '@dynamic-labs-sdk/client';
|
|
7
7
|
import '../../../client/client.js';
|
|
8
|
-
import '../../constants/values.js';
|
|
9
8
|
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../constants/values.js';
|
|
10
10
|
import '@dynamic-labs/multi-wallet';
|
|
11
11
|
import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
12
12
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VerifyResponse } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
/**
|
|
3
3
|
* Register passkey
|
|
4
4
|
*
|
|
@@ -18,4 +18,4 @@ import { UserPasskey } from '@dynamic-labs/sdk-api-core';
|
|
|
18
18
|
* );
|
|
19
19
|
* }
|
|
20
20
|
*/
|
|
21
|
-
export declare const useRegisterPasskey: () => (() => Promise<
|
|
21
|
+
export declare const useRegisterPasskey: () => (() => Promise<VerifyResponse>);
|
|
@@ -105,7 +105,7 @@ const useSubmitExchangeFunding = () => {
|
|
|
105
105
|
const { exchangeTransfer } = useExchangeAccounts.useExchangeAccounts();
|
|
106
106
|
const { setDynamicWidgetView, goToInitialDynamicWidgetView, setHeaderAlert } = DynamicWidgetContext.useWidgetContext();
|
|
107
107
|
const { clearStackAndPush } = ViewContext.useViewContext();
|
|
108
|
-
const {
|
|
108
|
+
const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
109
109
|
const { t } = reactI18next.useTranslation();
|
|
110
110
|
const submit = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ tokenAmount, exchange, tokenSymbol, mfaCode, toAddress, props, }) {
|
|
111
111
|
if (!tokenAmount)
|
|
@@ -161,6 +161,16 @@ const useSubmitExchangeFunding = () => {
|
|
|
161
161
|
showError = true;
|
|
162
162
|
errorMessage = t('dyn_exchange_transfer_errors.invalid_balance');
|
|
163
163
|
}
|
|
164
|
+
else if (error.code ===
|
|
165
|
+
sdkApiCore.UnprocessableEntityErrorCode.TransferAmountTooSmall) {
|
|
166
|
+
showError = true;
|
|
167
|
+
errorMessage = t('dyn_exchange_transfer_errors.amount_too_small');
|
|
168
|
+
}
|
|
169
|
+
else if (error.code ===
|
|
170
|
+
sdkApiCore.UnprocessableEntityErrorCode.TransferAddressNotWhitelisted) {
|
|
171
|
+
showError = true;
|
|
172
|
+
errorMessage = t('dyn_exchange_transfer_errors.address_not_whitelisted');
|
|
173
|
+
}
|
|
164
174
|
else {
|
|
165
175
|
showError = true;
|
|
166
176
|
errorMessage = t('dyn_exchange_transfer_errors.unknown');
|
|
@@ -179,7 +189,6 @@ const useSubmitExchangeFunding = () => {
|
|
|
179
189
|
clearStackAndPush,
|
|
180
190
|
exchangeTransfer,
|
|
181
191
|
goToInitialDynamicWidgetView,
|
|
182
|
-
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector,
|
|
183
192
|
setDynamicWidgetView,
|
|
184
193
|
setHeaderAlert,
|
|
185
194
|
setShowAuthFlow,
|
|
@@ -101,7 +101,7 @@ const useSubmitExchangeFunding = () => {
|
|
|
101
101
|
const { exchangeTransfer } = useExchangeAccounts();
|
|
102
102
|
const { setDynamicWidgetView, goToInitialDynamicWidgetView, setHeaderAlert } = useWidgetContext();
|
|
103
103
|
const { clearStackAndPush } = useViewContext();
|
|
104
|
-
const {
|
|
104
|
+
const { setShowAuthFlow } = useInternalDynamicContext();
|
|
105
105
|
const { t } = useTranslation();
|
|
106
106
|
const submit = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ tokenAmount, exchange, tokenSymbol, mfaCode, toAddress, props, }) {
|
|
107
107
|
if (!tokenAmount)
|
|
@@ -157,6 +157,16 @@ const useSubmitExchangeFunding = () => {
|
|
|
157
157
|
showError = true;
|
|
158
158
|
errorMessage = t('dyn_exchange_transfer_errors.invalid_balance');
|
|
159
159
|
}
|
|
160
|
+
else if (error.code ===
|
|
161
|
+
UnprocessableEntityErrorCode.TransferAmountTooSmall) {
|
|
162
|
+
showError = true;
|
|
163
|
+
errorMessage = t('dyn_exchange_transfer_errors.amount_too_small');
|
|
164
|
+
}
|
|
165
|
+
else if (error.code ===
|
|
166
|
+
UnprocessableEntityErrorCode.TransferAddressNotWhitelisted) {
|
|
167
|
+
showError = true;
|
|
168
|
+
errorMessage = t('dyn_exchange_transfer_errors.address_not_whitelisted');
|
|
169
|
+
}
|
|
160
170
|
else {
|
|
161
171
|
showError = true;
|
|
162
172
|
errorMessage = t('dyn_exchange_transfer_errors.unknown');
|
|
@@ -175,7 +185,6 @@ const useSubmitExchangeFunding = () => {
|
|
|
175
185
|
clearStackAndPush,
|
|
176
186
|
exchangeTransfer,
|
|
177
187
|
goToInitialDynamicWidgetView,
|
|
178
|
-
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector,
|
|
179
188
|
setDynamicWidgetView,
|
|
180
189
|
setHeaderAlert,
|
|
181
190
|
setShowAuthFlow,
|
|
@@ -9,8 +9,8 @@ var client = require('../../../client/client.cjs');
|
|
|
9
9
|
require('@dynamic-labs-sdk/client/core');
|
|
10
10
|
require('@dynamic-labs/sdk-api-core');
|
|
11
11
|
require('@dynamic-labs-sdk/client');
|
|
12
|
-
require('../../constants/values.cjs');
|
|
13
12
|
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../constants/values.cjs');
|
|
14
14
|
require('@dynamic-labs/multi-wallet');
|
|
15
15
|
var logger = require('../../../shared/logger.cjs');
|
|
16
16
|
require('../../constants/colors.cjs');
|
|
@@ -5,8 +5,8 @@ import { getDynamicClient } from '../../../client/client.js';
|
|
|
5
5
|
import '@dynamic-labs-sdk/client/core';
|
|
6
6
|
import '@dynamic-labs/sdk-api-core';
|
|
7
7
|
import '@dynamic-labs-sdk/client';
|
|
8
|
-
import '../../constants/values.js';
|
|
9
8
|
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../constants/values.js';
|
|
10
10
|
import '@dynamic-labs/multi-wallet';
|
|
11
11
|
import { logger } from '../../../shared/logger.js';
|
|
12
12
|
import '../../constants/colors.js';
|
|
@@ -9,8 +9,8 @@ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
|
9
9
|
require('@dynamic-labs-sdk/client/core');
|
|
10
10
|
require('@dynamic-labs-sdk/client');
|
|
11
11
|
require('../../../client/client.cjs');
|
|
12
|
-
require('../../constants/values.cjs');
|
|
13
12
|
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../constants/values.cjs');
|
|
14
14
|
var errors = require('../../constants/errors.cjs');
|
|
15
15
|
require('@dynamic-labs/multi-wallet');
|
|
16
16
|
var logger = require('../../../shared/logger.cjs');
|
|
@@ -5,8 +5,8 @@ import { ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
|
5
5
|
import '@dynamic-labs-sdk/client/core';
|
|
6
6
|
import '@dynamic-labs-sdk/client';
|
|
7
7
|
import '../../../client/client.js';
|
|
8
|
-
import '../../constants/values.js';
|
|
9
8
|
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../constants/values.js';
|
|
10
10
|
import { USER_NOT_LOGGED_IN } from '../../constants/errors.js';
|
|
11
11
|
import '@dynamic-labs/multi-wallet';
|
|
12
12
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -9,8 +9,8 @@ require('@dynamic-labs/sdk-api-core');
|
|
|
9
9
|
require('react');
|
|
10
10
|
require('@dynamic-labs-sdk/client');
|
|
11
11
|
require('../../../../client/client.cjs');
|
|
12
|
-
require('../../../constants/values.cjs');
|
|
13
12
|
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../../constants/values.cjs');
|
|
14
14
|
require('@dynamic-labs/multi-wallet');
|
|
15
15
|
require('../../../../shared/logger.cjs');
|
|
16
16
|
require('../../../constants/colors.cjs');
|
|
@@ -5,8 +5,8 @@ import '@dynamic-labs/sdk-api-core';
|
|
|
5
5
|
import 'react';
|
|
6
6
|
import '@dynamic-labs-sdk/client';
|
|
7
7
|
import '../../../../client/client.js';
|
|
8
|
-
import '../../../constants/values.js';
|
|
9
8
|
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../../constants/values.js';
|
|
10
10
|
import '@dynamic-labs/multi-wallet';
|
|
11
11
|
import '../../../../shared/logger.js';
|
|
12
12
|
import '../../../constants/colors.js';
|
|
@@ -13,8 +13,8 @@ require('@dynamic-labs/sdk-api-core');
|
|
|
13
13
|
var useInitStatus = require('../../../client/extension/hooks/useClientInitStatus/useInitStatus.cjs');
|
|
14
14
|
require('@dynamic-labs-sdk/client');
|
|
15
15
|
require('../../../client/client.cjs');
|
|
16
|
-
require('../../constants/values.cjs');
|
|
17
16
|
require('@dynamic-labs/utils');
|
|
17
|
+
require('../../constants/values.cjs');
|
|
18
18
|
require('@dynamic-labs/multi-wallet');
|
|
19
19
|
require('../../constants/colors.cjs');
|
|
20
20
|
require('react-international-phone');
|
|
@@ -9,8 +9,8 @@ import '@dynamic-labs/sdk-api-core';
|
|
|
9
9
|
import { useClientInitStatus } from '../../../client/extension/hooks/useClientInitStatus/useInitStatus.js';
|
|
10
10
|
import '@dynamic-labs-sdk/client';
|
|
11
11
|
import '../../../client/client.js';
|
|
12
|
-
import '../../constants/values.js';
|
|
13
12
|
import '@dynamic-labs/utils';
|
|
13
|
+
import '../../constants/values.js';
|
|
14
14
|
import '@dynamic-labs/multi-wallet';
|
|
15
15
|
import '../../constants/colors.js';
|
|
16
16
|
import 'react-international-phone';
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
6
|
var React = require('react');
|
|
8
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
10
9
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
11
10
|
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
12
11
|
require('@dynamic-labs/sdk-api-core');
|
|
@@ -19,7 +18,8 @@ require('../../constants/colors.cjs');
|
|
|
19
18
|
require('../../constants/values.cjs');
|
|
20
19
|
var isWalletGroup = require('../../functions/walletListBuilder/utils/isWalletGroup/isWalletGroup.cjs');
|
|
21
20
|
require('../../../shared/consts/index.cjs');
|
|
22
|
-
require('../../../events/dynamicEvents.cjs');
|
|
21
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
22
|
+
require('../../../../../_virtual/_tslib.cjs');
|
|
23
23
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
24
24
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
25
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -133,7 +133,7 @@ const useWalletOptions = () => {
|
|
|
133
133
|
});
|
|
134
134
|
}, [walletConnectorOptions, walletGroups]);
|
|
135
135
|
const allWalletOptions = React.useMemo(() => getFilteredWalletOptions((options) => options), [getFilteredWalletOptions]);
|
|
136
|
-
const selectWalletOption = React.useCallback((
|
|
136
|
+
const selectWalletOption = React.useCallback((walletKey, selectGroupIfAvailable = true) => new Promise((resolve, reject) => {
|
|
137
137
|
const group = groupWalletOptions.groupWalletOptions(walletGroups, walletConnectorOptions);
|
|
138
138
|
const walletGroup = group.find((wallet) => wallet.key === walletKey);
|
|
139
139
|
const walletOption = walletConnectorOptions === null || walletConnectorOptions === void 0 ? void 0 : walletConnectorOptions.find((wallet) => wallet.key === walletKey);
|
|
@@ -143,9 +143,12 @@ const useWalletOptions = () => {
|
|
|
143
143
|
walletOption: walletOption === null || walletOption === void 0 ? void 0 : walletOption.key,
|
|
144
144
|
});
|
|
145
145
|
if (!walletOption) {
|
|
146
|
-
|
|
146
|
+
reject(new utils.DynamicError('Invalid wallet option key provided.'));
|
|
147
|
+
return;
|
|
147
148
|
}
|
|
148
|
-
if (selectGroupIfAvailable &&
|
|
149
|
+
if (selectGroupIfAvailable &&
|
|
150
|
+
walletGroup &&
|
|
151
|
+
isWalletGroup.isWalletGroup(walletGroup)) {
|
|
149
152
|
navigateToWalletGroup(walletGroup);
|
|
150
153
|
}
|
|
151
154
|
else if (walletConnectorCore.isHardwareWalletConnector(walletOption.walletConnector) &&
|
|
@@ -159,6 +162,40 @@ const useWalletOptions = () => {
|
|
|
159
162
|
handleWalletItemClick(walletOption);
|
|
160
163
|
}
|
|
161
164
|
setShowAuthFlow(true);
|
|
165
|
+
const walletAdded = (wallet) => {
|
|
166
|
+
if (wallet.key !== walletKey) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
resolve(wallet);
|
|
170
|
+
setShowAuthFlow(false);
|
|
171
|
+
cleanup();
|
|
172
|
+
};
|
|
173
|
+
const walletConnectionFailed = (walletConnector, error) => {
|
|
174
|
+
if (walletConnector.key !== walletKey) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
reject(error);
|
|
178
|
+
setShowAuthFlow(false);
|
|
179
|
+
cleanup();
|
|
180
|
+
};
|
|
181
|
+
const authFailure = (method, reason) => {
|
|
182
|
+
if (method.type !== 'wallet' ||
|
|
183
|
+
method.connectorName !== walletOption.walletConnector.name) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const error = typeof reason === 'object' ? reason.error : reason;
|
|
187
|
+
reject(error);
|
|
188
|
+
setShowAuthFlow(false);
|
|
189
|
+
cleanup();
|
|
190
|
+
};
|
|
191
|
+
const cleanup = () => {
|
|
192
|
+
dynamicEvents.dynamicEvents.off('walletConnectionFailed', walletConnectionFailed);
|
|
193
|
+
dynamicEvents.dynamicEvents.off('authFailure', authFailure);
|
|
194
|
+
dynamicEvents.dynamicEvents.off('walletAdded', walletAdded);
|
|
195
|
+
};
|
|
196
|
+
dynamicEvents.dynamicEvents.on('walletAdded', walletAdded);
|
|
197
|
+
dynamicEvents.dynamicEvents.on('walletConnectionFailed', walletConnectionFailed);
|
|
198
|
+
dynamicEvents.dynamicEvents.on('authFailure', authFailure);
|
|
162
199
|
}), [
|
|
163
200
|
handleWalletItemClick,
|
|
164
201
|
navigateToWalletGroup,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
1
2
|
import { WalletOption } from '../../../shared';
|
|
2
3
|
export declare const useWalletOptions: () => {
|
|
3
4
|
getFilteredWalletOptions: (filter: (options: WalletOption[]) => WalletOption[]) => {
|
|
@@ -9,7 +10,7 @@ export declare const useWalletOptions: () => {
|
|
|
9
10
|
key: string;
|
|
10
11
|
name: string;
|
|
11
12
|
}[];
|
|
12
|
-
selectWalletOption: (walletKey: string, selectGroupIfAvailable?: boolean) => Promise<
|
|
13
|
+
selectWalletOption: (walletKey: string, selectGroupIfAvailable?: boolean) => Promise<Wallet<import("@dynamic-labs/wallet-connector-core").WalletConnectorCore.WalletConnector>>;
|
|
13
14
|
walletOptions: {
|
|
14
15
|
chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" | "BTC" | "ECLIPSE" | "SUI";
|
|
15
16
|
group: string | undefined;
|