@dynamic-labs/sdk-react-core 2.0.0-alpha.6 → 2.0.0-alpha.8
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 +21 -0
- package/package.cjs +4 -4
- package/package.js +4 -4
- package/package.json +16 -16
- package/src/index.cjs +3 -7
- package/src/index.d.ts +1 -2
- package/src/index.js +2 -2
- package/src/lib/components/Alert/Alert.cjs +1 -0
- package/src/lib/components/Alert/Alert.js +1 -0
- package/src/lib/components/Alert/Alert.types.d.ts +1 -1
- package/src/lib/components/ErrorContainer/ErrorContainer.cjs +1 -1
- package/src/lib/components/ErrorContainer/ErrorContainer.js +1 -1
- package/src/lib/components/NetworkPicker/NetworkPicker.cjs +4 -2
- package/src/lib/components/NetworkPicker/NetworkPicker.js +4 -2
- package/src/lib/components/ShadowDOM/ShadowDOM.cjs +2 -0
- package/src/lib/components/ShadowDOM/ShadowDOM.js +2 -1
- package/src/lib/components/SyncEmbeddedWalletAuthFlow/SyncEmbeddedWalletAuthFlow.cjs +26 -10
- package/src/lib/components/SyncEmbeddedWalletAuthFlow/SyncEmbeddedWalletAuthFlow.js +27 -11
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +16 -17
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +3 -4
- package/src/lib/context/DynamicContext/DynamicContext.js +17 -18
- package/src/lib/context/DynamicContext/helpers/helpers.cjs +10 -0
- package/src/lib/context/DynamicContext/helpers/helpers.d.ts +5 -0
- package/src/lib/context/DynamicContext/helpers/helpers.js +10 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +1 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +1 -1
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.cjs +1 -0
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.d.ts +8 -7
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.js +1 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +14 -2
- package/src/lib/context/ErrorContext/ErrorContext.cjs +4 -0
- package/src/lib/context/ErrorContext/ErrorContext.d.ts +1 -0
- package/src/lib/context/ErrorContext/ErrorContext.js +4 -0
- package/src/lib/context/FundingContext/FundingContext.cjs +3 -1
- package/src/lib/context/FundingContext/FundingContext.js +3 -1
- package/src/lib/context/PasskeyContext/PasskeyContext.cjs +1 -0
- package/src/lib/context/PasskeyContext/PasskeyContext.js +1 -0
- package/src/lib/context/ViewContext/ViewContext.cjs +7 -0
- package/src/lib/context/ViewContext/ViewContext.js +7 -0
- package/src/lib/context/ViewContext/types/index.d.ts +5 -3
- package/src/lib/locale/en/translation.cjs +30 -16
- package/src/lib/locale/en/translation.d.ts +22 -8
- package/src/lib/locale/en/translation.js +30 -16
- package/src/lib/shared/types/localStorage.d.ts +1 -1
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.cjs +10 -28
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.d.ts +1 -5
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.js +10 -28
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/mergeNetworks/index.d.ts +1 -0
- package/src/lib/utils/functions/mergeNetworks/mergeNetworks.cjs +26 -0
- package/src/lib/utils/functions/mergeNetworks/mergeNetworks.d.ts +13 -0
- package/src/lib/utils/functions/mergeNetworks/mergeNetworks.js +22 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +4 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +4 -2
- package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js +1 -0
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +3 -13
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +3 -13
- 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/useEmailProvider/useEmailProvider.cjs +1 -0
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.js +1 -0
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +33 -8
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +33 -8
- package/src/lib/utils/hooks/useEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +1 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +1 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +27 -5
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +27 -5
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +7 -6
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.d.ts +1 -1
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +7 -6
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +2 -6
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +2 -6
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.cjs +20 -54
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.d.ts +5 -3
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.js +20 -54
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +38 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.d.ts +2 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +34 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +1 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +8 -11
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +8 -11
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +1 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +1 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -0
- package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.cjs +4 -7
- package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.js +4 -7
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +1 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +1 -1
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.cjs +1 -1
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.js +1 -1
- package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.cjs +1 -1
- package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.js +1 -1
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +3 -8
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +3 -8
- package/src/lib/views/{CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.cjs → CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.cjs} +5 -4
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.d.ts +13 -0
- package/src/lib/views/{CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.js → CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.js} +5 -4
- package/src/lib/views/CollectUserDataViewNoWallet/index.d.ts +1 -0
- package/src/lib/views/CreatePasswordView/CreatePasswordStep/CreatePasswordStep.cjs +17 -2
- package/src/lib/views/CreatePasswordView/CreatePasswordStep/CreatePasswordStep.js +17 -2
- package/src/lib/views/CreatePasswordView/CreatePasswordView.cjs +12 -13
- package/src/lib/views/CreatePasswordView/CreatePasswordView.d.ts +2 -0
- package/src/lib/views/CreatePasswordView/CreatePasswordView.js +12 -13
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +1 -0
- package/src/lib/views/EmailUpdate/EmailUpdate.js +1 -0
- package/src/lib/views/EmailVerification/EmailVerification.cjs +10 -17
- package/src/lib/views/EmailVerification/EmailVerification.js +10 -17
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +40 -13
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.d.ts +2 -3
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +40 -13
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.d.ts +1 -1
- package/src/lib/views/EnterPasswordView/EnterPasswordView.cjs +8 -1
- package/src/lib/views/EnterPasswordView/EnterPasswordView.js +8 -1
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.cjs +1 -0
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.js +1 -0
- package/src/lib/views/LoginView/useLoginView/useLoginView.cjs +11 -5
- package/src/lib/views/LoginView/useLoginView/useLoginView.js +11 -5
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +1 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +1 -0
- package/src/lib/views/Passkey/EmbeddedAuthChoice/EmbeddedAuthChoice.d.ts +2 -3
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.d.ts +2 -3
- package/src/lib/views/Passkey/PasskeyRecovery/InitRecovery/PasskeyInitRecovery.d.ts +2 -3
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.cjs +1 -0
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.js +1 -0
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +31 -7
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +31 -7
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -0
- package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -0
- package/src/lib/views/viewToComponentMap.cjs +4 -4
- package/src/lib/views/viewToComponentMap.d.ts +60 -2
- package/src/lib/views/viewToComponentMap.js +4 -4
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.cjs +6 -4
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.js +6 -4
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +5 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +5 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.cjs +2 -14
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.js +2 -14
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.cjs +3 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.js +4 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.cjs +2 -14
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.js +2 -14
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.cjs +18 -9
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.js +18 -9
- package/src/lib/utils/functions/isSameWalletName/index.d.ts +0 -1
- package/src/lib/utils/functions/isSameWalletName/isSameWalletName.cjs +0 -9
- package/src/lib/utils/functions/isSameWalletName/isSameWalletName.d.ts +0 -1
- package/src/lib/utils/functions/isSameWalletName/isSameWalletName.js +0 -5
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/utils/index.d.ts +0 -1
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +0 -1
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +0 -16
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +0 -2
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +0 -12
- package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.d.ts +0 -2
- package/src/lib/views/CollectUserDataViewLoginWithEmail/index.d.ts +0 -1
|
@@ -66,6 +66,7 @@ require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Secon
|
|
|
66
66
|
require('i18next');
|
|
67
67
|
require('@hcaptcha/react-hcaptcha');
|
|
68
68
|
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
69
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
69
70
|
require('../../../context/FooterAnimationContext/index.cjs');
|
|
70
71
|
require('../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.cjs');
|
|
71
72
|
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
@@ -96,7 +97,7 @@ const useEmbeddedWalletPassword = () => {
|
|
|
96
97
|
dynamicEvents.dynamicEvents.once('embeddedWalletCreatePasswordFailed', (error) => reject(error));
|
|
97
98
|
});
|
|
98
99
|
}), [setShowAuthFlow, setView]);
|
|
99
|
-
const
|
|
100
|
+
const claimWallet = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
100
101
|
var _a;
|
|
101
102
|
try {
|
|
102
103
|
if (!primaryWallet) {
|
|
@@ -106,13 +107,13 @@ const useEmbeddedWalletPassword = () => {
|
|
|
106
107
|
const refreshedToken = yield api.claimEmbeddedWallet({ environmentId, walletId: primaryWallet.id }, jwt);
|
|
107
108
|
// if an error occurs while calling the api, the user won't be logged out
|
|
108
109
|
if ('code' in refreshedToken) {
|
|
109
|
-
logger.logger.error('Error updating jwt after
|
|
110
|
+
logger.logger.error('Error updating jwt after claiming wallet');
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
113
|
const updatedJwt = refreshedToken.jwt;
|
|
113
114
|
const decodedJwt = decodeJwt.decodeJwt(updatedJwt);
|
|
114
115
|
if (!decodedJwt) {
|
|
115
|
-
logger.logger.error('Error updating jwt after
|
|
116
|
+
logger.logger.error('Error updating jwt after claiming wallet');
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
119
|
const user = createUserProfile.createUserProfile(decodedJwt);
|
|
@@ -120,12 +121,12 @@ const useEmbeddedWalletPassword = () => {
|
|
|
120
121
|
setUser(user);
|
|
121
122
|
}
|
|
122
123
|
catch (error) {
|
|
123
|
-
logger.logger.error('Error
|
|
124
|
-
throw new Error('Error
|
|
124
|
+
logger.logger.error('Error claiming wallet', error);
|
|
125
|
+
throw new Error('Error claiming wallet');
|
|
125
126
|
}
|
|
126
127
|
}), [environmentId, onboardingOnlyJwt, primaryWallet, setUser]);
|
|
127
128
|
return {
|
|
128
|
-
|
|
129
|
+
claimWallet,
|
|
129
130
|
createPassword,
|
|
130
131
|
};
|
|
131
132
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const useEmbeddedWalletPassword: () => {
|
|
2
|
-
readonly
|
|
2
|
+
readonly claimWallet: () => Promise<void>;
|
|
3
3
|
readonly createPassword: (isClaim?: boolean, isSignUp?: boolean) => Promise<string>;
|
|
4
4
|
};
|
|
@@ -62,6 +62,7 @@ import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Second
|
|
|
62
62
|
import 'i18next';
|
|
63
63
|
import '@hcaptcha/react-hcaptcha';
|
|
64
64
|
import '../../../context/LoadingContext/LoadingContext.js';
|
|
65
|
+
import '../../../config/ApiEndpoint.js';
|
|
65
66
|
import '../../../context/FooterAnimationContext/index.js';
|
|
66
67
|
import '../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.js';
|
|
67
68
|
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
@@ -92,7 +93,7 @@ const useEmbeddedWalletPassword = () => {
|
|
|
92
93
|
dynamicEvents.once('embeddedWalletCreatePasswordFailed', (error) => reject(error));
|
|
93
94
|
});
|
|
94
95
|
}), [setShowAuthFlow, setView]);
|
|
95
|
-
const
|
|
96
|
+
const claimWallet = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
97
|
var _a;
|
|
97
98
|
try {
|
|
98
99
|
if (!primaryWallet) {
|
|
@@ -102,13 +103,13 @@ const useEmbeddedWalletPassword = () => {
|
|
|
102
103
|
const refreshedToken = yield claimEmbeddedWallet({ environmentId, walletId: primaryWallet.id }, jwt);
|
|
103
104
|
// if an error occurs while calling the api, the user won't be logged out
|
|
104
105
|
if ('code' in refreshedToken) {
|
|
105
|
-
logger.error('Error updating jwt after
|
|
106
|
+
logger.error('Error updating jwt after claiming wallet');
|
|
106
107
|
return;
|
|
107
108
|
}
|
|
108
109
|
const updatedJwt = refreshedToken.jwt;
|
|
109
110
|
const decodedJwt = decodeJwt(updatedJwt);
|
|
110
111
|
if (!decodedJwt) {
|
|
111
|
-
logger.error('Error updating jwt after
|
|
112
|
+
logger.error('Error updating jwt after claiming wallet');
|
|
112
113
|
return;
|
|
113
114
|
}
|
|
114
115
|
const user = createUserProfile(decodedJwt);
|
|
@@ -116,12 +117,12 @@ const useEmbeddedWalletPassword = () => {
|
|
|
116
117
|
setUser(user);
|
|
117
118
|
}
|
|
118
119
|
catch (error) {
|
|
119
|
-
logger.error('Error
|
|
120
|
-
throw new Error('Error
|
|
120
|
+
logger.error('Error claiming wallet', error);
|
|
121
|
+
throw new Error('Error claiming wallet');
|
|
121
122
|
}
|
|
122
123
|
}), [environmentId, onboardingOnlyJwt, primaryWallet, setUser]);
|
|
123
124
|
return {
|
|
124
|
-
|
|
125
|
+
claimWallet,
|
|
125
126
|
createPassword,
|
|
126
127
|
};
|
|
127
128
|
};
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
7
|
require('@dynamic-labs/sdk-api');
|
|
9
8
|
require('../../../shared/logger.cjs');
|
|
10
9
|
require('@dynamic-labs/iconic');
|
|
10
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
11
11
|
require('react/jsx-runtime');
|
|
12
12
|
require('../../../context/ViewContext/ViewContext.cjs');
|
|
13
13
|
require('@dynamic-labs/wallet-book');
|
|
@@ -45,11 +45,7 @@ const useHandleUnlinkWallet = ({ verifiedCredentials, environmentId, primaryWall
|
|
|
45
45
|
setUser(newUser);
|
|
46
46
|
}
|
|
47
47
|
const wallet = secondaryWallets.find((w) => w.id === walletId);
|
|
48
|
-
|
|
49
|
-
// https://linear.app/dynamic-labs/issue/QNTM-846/remove-usage-of-walletwalletconnectorwname-to-instead-use
|
|
50
|
-
const numberOfLinkedWallets = verifiedCredentials.filter((account) => account.walletName &&
|
|
51
|
-
walletConnectorCore.normalizeWalletName(account.walletName) ===
|
|
52
|
-
((wallet === null || wallet === void 0 ? void 0 : wallet.connector.key) || '')).length;
|
|
48
|
+
const numberOfLinkedWallets = verifiedCredentials.filter((account) => account.walletName === ((wallet === null || wallet === void 0 ? void 0 : wallet.connector.key) || '')).length;
|
|
53
49
|
// If there's only 1, it's the one being removed and we can kill the session
|
|
54
50
|
if (numberOfLinkedWallets === 1) {
|
|
55
51
|
yield (wallet === null || wallet === void 0 ? void 0 : wallet.connector.endSession());
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { normalizeWalletName } from '@dynamic-labs/wallet-connector-core';
|
|
4
3
|
import '@dynamic-labs/sdk-api';
|
|
5
4
|
import '../../../shared/logger.js';
|
|
6
5
|
import '@dynamic-labs/iconic';
|
|
6
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
7
7
|
import 'react/jsx-runtime';
|
|
8
8
|
import '../../../context/ViewContext/ViewContext.js';
|
|
9
9
|
import '@dynamic-labs/wallet-book';
|
|
@@ -41,11 +41,7 @@ const useHandleUnlinkWallet = ({ verifiedCredentials, environmentId, primaryWall
|
|
|
41
41
|
setUser(newUser);
|
|
42
42
|
}
|
|
43
43
|
const wallet = secondaryWallets.find((w) => w.id === walletId);
|
|
44
|
-
|
|
45
|
-
// https://linear.app/dynamic-labs/issue/QNTM-846/remove-usage-of-walletwalletconnectorwname-to-instead-use
|
|
46
|
-
const numberOfLinkedWallets = verifiedCredentials.filter((account) => account.walletName &&
|
|
47
|
-
normalizeWalletName(account.walletName) ===
|
|
48
|
-
((wallet === null || wallet === void 0 ? void 0 : wallet.connector.key) || '')).length;
|
|
44
|
+
const numberOfLinkedWallets = verifiedCredentials.filter((account) => account.walletName === ((wallet === null || wallet === void 0 ? void 0 : wallet.connector.key) || '')).length;
|
|
49
45
|
// If there's only 1, it's the one being removed and we can kill the session
|
|
50
46
|
if (numberOfLinkedWallets === 1) {
|
|
51
47
|
yield (wallet === null || wallet === void 0 ? void 0 : wallet.connector.endSession());
|
package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.cjs
CHANGED
|
@@ -19,22 +19,17 @@ require('viem');
|
|
|
19
19
|
var useLocalStorage = require('../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
20
20
|
require('@dynamic-labs/utils');
|
|
21
21
|
require('../../../shared/consts/index.cjs');
|
|
22
|
-
var usePrevious = require('../usePrevious/usePrevious.cjs');
|
|
23
|
-
var mergeCustomerEvmNetworksWithServerNetworks = require('./utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs');
|
|
24
22
|
|
|
25
|
-
const useProcessNetworkConfigurations = ({ authToken, environmentId,
|
|
26
|
-
var _a;
|
|
23
|
+
const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworksOverrides, projectSettings, }) => {
|
|
27
24
|
/**
|
|
28
25
|
* This is the version of the local storage object. If the version changes, the local storage object will be removed.
|
|
29
26
|
* This is used in case we need to change the structure of the local storage object.
|
|
30
27
|
*/
|
|
31
|
-
const VERSION =
|
|
28
|
+
const VERSION = 3;
|
|
32
29
|
const [lsNetworks, setLsNetworks, removeLsNetworks] = useLocalStorage.useLocalStorage(localStorage.NETWORKS_STORAGE_KEY, undefined, validators.validateLocalStorageExpiry);
|
|
33
30
|
const [loading, setLoading] = React.useState(false);
|
|
34
|
-
const [
|
|
35
|
-
|
|
36
|
-
// Stringify the objects for easy comparison
|
|
37
|
-
const customerEvmNetworksJson = customerEvmNetworks === null || customerEvmNetworks === void 0 ? void 0 : customerEvmNetworks.map((network) => JSON.stringify(network));
|
|
31
|
+
const [lsNetworksExists, setlsNetworksExists] = React.useState(Boolean(lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.networkConfigurations) &&
|
|
32
|
+
(lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.version) === VERSION);
|
|
38
33
|
const handleRemoveLsNetworks = React.useCallback(() => {
|
|
39
34
|
removeLsNetworks();
|
|
40
35
|
setlsNetworksExists(false);
|
|
@@ -46,7 +41,8 @@ const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks
|
|
|
46
41
|
if (lsNetworks && lsNetworks.version !== VERSION) {
|
|
47
42
|
handleRemoveLsNetworks();
|
|
48
43
|
}
|
|
49
|
-
}, [environmentId, handleRemoveLsNetworks, lsNetworks
|
|
44
|
+
}, [environmentId, handleRemoveLsNetworks, lsNetworks]);
|
|
45
|
+
// Erase network data if user is not logged in
|
|
50
46
|
React.useEffect(() => {
|
|
51
47
|
const connectedWalletData = localStorage$1.LocalStorage.getFromLS(localStorage.CONNECTED_WALLETS_INFO) || [];
|
|
52
48
|
if (!authToken && !(connectedWalletData === null || connectedWalletData === void 0 ? void 0 : connectedWalletData.length)) {
|
|
@@ -54,33 +50,10 @@ const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks
|
|
|
54
50
|
}
|
|
55
51
|
}, [authToken, handleRemoveLsNetworks]);
|
|
56
52
|
// When customer networks change, we need to update ls networks
|
|
57
|
-
const previousCustomerEvmNetworks = usePrevious.usePrevious(customerEvmNetworks);
|
|
58
53
|
React.useEffect(() => {
|
|
59
|
-
if (JSON.stringify(customerEvmNetworks) ===
|
|
60
|
-
JSON.stringify(previousCustomerEvmNetworks))
|
|
61
|
-
return;
|
|
62
54
|
setlsNetworksExists(false);
|
|
63
|
-
}, [
|
|
64
|
-
|
|
65
|
-
var _a, _b;
|
|
66
|
-
if (lsNetworksExists && customerEvmNetworksJson && !completed) {
|
|
67
|
-
const localStorageNetworksJson = (_b = (_a = lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations) === null || _a === void 0 ? void 0 : _a.evm) === null || _b === void 0 ? void 0 : _b.map((network) => JSON.stringify(network));
|
|
68
|
-
if (localStorageNetworksJson) {
|
|
69
|
-
const fullMatch = customerEvmNetworksJson.every((network) => localStorageNetworksJson.indexOf(network) !== -1);
|
|
70
|
-
if (!fullMatch) {
|
|
71
|
-
handleRemoveLsNetworks();
|
|
72
|
-
}
|
|
73
|
-
setCompleted(true);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, [
|
|
77
|
-
lsNetworksExists,
|
|
78
|
-
customerEvmNetworksJson,
|
|
79
|
-
(_a = lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations) === null || _a === void 0 ? void 0 : _a.evm,
|
|
80
|
-
completed,
|
|
81
|
-
setCompleted,
|
|
82
|
-
handleRemoveLsNetworks,
|
|
83
|
-
]);
|
|
55
|
+
}, [evmNetworksOverrides]);
|
|
56
|
+
// Generate and store networks object
|
|
84
57
|
React.useEffect(() => {
|
|
85
58
|
var _a, _b, _c, _d;
|
|
86
59
|
if (!lsNetworksExists && !loading && (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks)) {
|
|
@@ -91,7 +64,6 @@ const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks
|
|
|
91
64
|
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
92
65
|
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
93
66
|
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
94
|
-
let mergedEvmNetworks;
|
|
95
67
|
const createNetwork = (network, parser = (input) => input) => ({
|
|
96
68
|
blockExplorerUrls: network.blockExplorerUrls,
|
|
97
69
|
chainId: parser(network.chainId),
|
|
@@ -105,30 +77,24 @@ const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks
|
|
|
105
77
|
vanityName: network.vanityName,
|
|
106
78
|
});
|
|
107
79
|
const cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
108
|
-
|
|
80
|
+
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
109
81
|
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
110
82
|
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
if (serverNetworks !== undefined &&
|
|
118
|
-
serverNetworks.length &&
|
|
119
|
-
customerEvmNetworks !== undefined &&
|
|
120
|
-
customerEvmNetworks.length) {
|
|
121
|
-
mergedEvmNetworks = mergeCustomerEvmNetworksWithServerNetworks.mergeCustomerEvmNetworksWithServerNetworks(customerEvmNetworks, serverNetworks);
|
|
83
|
+
if (evmNetworksOverrides) {
|
|
84
|
+
if (Array.isArray(evmNetworksOverrides))
|
|
85
|
+
evmNetworks = evmNetworksOverrides;
|
|
86
|
+
else
|
|
87
|
+
evmNetworks = evmNetworksOverrides(evmNetworks !== null && evmNetworks !== void 0 ? evmNetworks : []);
|
|
122
88
|
}
|
|
123
89
|
setLsNetworks({
|
|
124
|
-
|
|
90
|
+
environmentId,
|
|
91
|
+
expiry,
|
|
92
|
+
networkConfigurations: {
|
|
125
93
|
cosmos: cosmosNetworks,
|
|
126
|
-
evm:
|
|
94
|
+
evm: evmNetworks,
|
|
127
95
|
solana: solanaNetworks,
|
|
128
96
|
starknet: starknetNetworks,
|
|
129
97
|
},
|
|
130
|
-
environmentId,
|
|
131
|
-
expiry,
|
|
132
98
|
version: VERSION,
|
|
133
99
|
});
|
|
134
100
|
setlsNetworksExists(true);
|
|
@@ -137,14 +103,14 @@ const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks
|
|
|
137
103
|
}, [
|
|
138
104
|
environmentId,
|
|
139
105
|
loading,
|
|
140
|
-
customerEvmNetworks,
|
|
141
106
|
lsNetworksExists,
|
|
142
107
|
setLsNetworks,
|
|
143
108
|
projectSettings,
|
|
109
|
+
evmNetworksOverrides,
|
|
144
110
|
]);
|
|
145
111
|
return {
|
|
146
|
-
configurations: lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations,
|
|
147
112
|
handleRemoveLsNetworks,
|
|
113
|
+
networkConfigurations: lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.networkConfigurations,
|
|
148
114
|
};
|
|
149
115
|
};
|
|
150
116
|
|
package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
2
2
|
import { GenericNetwork } from '@dynamic-labs/types';
|
|
3
|
-
|
|
3
|
+
import { EvmNetworksOverrides } from '../../../context/DynamicContext/types';
|
|
4
|
+
export type FetchNetworkConfigurationsProps = {
|
|
4
5
|
authToken: string | undefined;
|
|
5
6
|
environmentId: string;
|
|
6
7
|
evmNetworks?: GenericNetwork[];
|
|
8
|
+
evmNetworksOverrides?: EvmNetworksOverrides;
|
|
7
9
|
projectSettings?: ProjectSettings;
|
|
8
10
|
};
|
|
9
|
-
export declare const useProcessNetworkConfigurations: ({ authToken, environmentId,
|
|
10
|
-
configurations: import("@dynamic-labs/types").NetworkConfigurationMap | undefined;
|
|
11
|
+
export declare const useProcessNetworkConfigurations: ({ authToken, environmentId, evmNetworksOverrides, projectSettings, }: FetchNetworkConfigurationsProps) => {
|
|
11
12
|
handleRemoveLsNetworks: () => void;
|
|
13
|
+
networkConfigurations: import("@dynamic-labs/types").NetworkConfigurationMap | undefined;
|
|
12
14
|
};
|
package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.js
CHANGED
|
@@ -15,22 +15,17 @@ import 'viem';
|
|
|
15
15
|
import { useLocalStorage } from '../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
16
16
|
import '@dynamic-labs/utils';
|
|
17
17
|
import '../../../shared/consts/index.js';
|
|
18
|
-
import { usePrevious } from '../usePrevious/usePrevious.js';
|
|
19
|
-
import { mergeCustomerEvmNetworksWithServerNetworks } from './utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js';
|
|
20
18
|
|
|
21
|
-
const useProcessNetworkConfigurations = ({ authToken, environmentId,
|
|
22
|
-
var _a;
|
|
19
|
+
const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworksOverrides, projectSettings, }) => {
|
|
23
20
|
/**
|
|
24
21
|
* This is the version of the local storage object. If the version changes, the local storage object will be removed.
|
|
25
22
|
* This is used in case we need to change the structure of the local storage object.
|
|
26
23
|
*/
|
|
27
|
-
const VERSION =
|
|
24
|
+
const VERSION = 3;
|
|
28
25
|
const [lsNetworks, setLsNetworks, removeLsNetworks] = useLocalStorage(NETWORKS_STORAGE_KEY, undefined, validateLocalStorageExpiry);
|
|
29
26
|
const [loading, setLoading] = useState(false);
|
|
30
|
-
const [
|
|
31
|
-
|
|
32
|
-
// Stringify the objects for easy comparison
|
|
33
|
-
const customerEvmNetworksJson = customerEvmNetworks === null || customerEvmNetworks === void 0 ? void 0 : customerEvmNetworks.map((network) => JSON.stringify(network));
|
|
27
|
+
const [lsNetworksExists, setlsNetworksExists] = useState(Boolean(lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.networkConfigurations) &&
|
|
28
|
+
(lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.version) === VERSION);
|
|
34
29
|
const handleRemoveLsNetworks = useCallback(() => {
|
|
35
30
|
removeLsNetworks();
|
|
36
31
|
setlsNetworksExists(false);
|
|
@@ -42,7 +37,8 @@ const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks
|
|
|
42
37
|
if (lsNetworks && lsNetworks.version !== VERSION) {
|
|
43
38
|
handleRemoveLsNetworks();
|
|
44
39
|
}
|
|
45
|
-
}, [environmentId, handleRemoveLsNetworks, lsNetworks
|
|
40
|
+
}, [environmentId, handleRemoveLsNetworks, lsNetworks]);
|
|
41
|
+
// Erase network data if user is not logged in
|
|
46
42
|
useEffect(() => {
|
|
47
43
|
const connectedWalletData = LocalStorage.getFromLS(CONNECTED_WALLETS_INFO) || [];
|
|
48
44
|
if (!authToken && !(connectedWalletData === null || connectedWalletData === void 0 ? void 0 : connectedWalletData.length)) {
|
|
@@ -50,33 +46,10 @@ const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks
|
|
|
50
46
|
}
|
|
51
47
|
}, [authToken, handleRemoveLsNetworks]);
|
|
52
48
|
// When customer networks change, we need to update ls networks
|
|
53
|
-
const previousCustomerEvmNetworks = usePrevious(customerEvmNetworks);
|
|
54
49
|
useEffect(() => {
|
|
55
|
-
if (JSON.stringify(customerEvmNetworks) ===
|
|
56
|
-
JSON.stringify(previousCustomerEvmNetworks))
|
|
57
|
-
return;
|
|
58
50
|
setlsNetworksExists(false);
|
|
59
|
-
}, [
|
|
60
|
-
|
|
61
|
-
var _a, _b;
|
|
62
|
-
if (lsNetworksExists && customerEvmNetworksJson && !completed) {
|
|
63
|
-
const localStorageNetworksJson = (_b = (_a = lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations) === null || _a === void 0 ? void 0 : _a.evm) === null || _b === void 0 ? void 0 : _b.map((network) => JSON.stringify(network));
|
|
64
|
-
if (localStorageNetworksJson) {
|
|
65
|
-
const fullMatch = customerEvmNetworksJson.every((network) => localStorageNetworksJson.indexOf(network) !== -1);
|
|
66
|
-
if (!fullMatch) {
|
|
67
|
-
handleRemoveLsNetworks();
|
|
68
|
-
}
|
|
69
|
-
setCompleted(true);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}, [
|
|
73
|
-
lsNetworksExists,
|
|
74
|
-
customerEvmNetworksJson,
|
|
75
|
-
(_a = lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations) === null || _a === void 0 ? void 0 : _a.evm,
|
|
76
|
-
completed,
|
|
77
|
-
setCompleted,
|
|
78
|
-
handleRemoveLsNetworks,
|
|
79
|
-
]);
|
|
51
|
+
}, [evmNetworksOverrides]);
|
|
52
|
+
// Generate and store networks object
|
|
80
53
|
useEffect(() => {
|
|
81
54
|
var _a, _b, _c, _d;
|
|
82
55
|
if (!lsNetworksExists && !loading && (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks)) {
|
|
@@ -87,7 +60,6 @@ const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks
|
|
|
87
60
|
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
88
61
|
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
89
62
|
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
90
|
-
let mergedEvmNetworks;
|
|
91
63
|
const createNetwork = (network, parser = (input) => input) => ({
|
|
92
64
|
blockExplorerUrls: network.blockExplorerUrls,
|
|
93
65
|
chainId: parser(network.chainId),
|
|
@@ -101,30 +73,24 @@ const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks
|
|
|
101
73
|
vanityName: network.vanityName,
|
|
102
74
|
});
|
|
103
75
|
const cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
104
|
-
|
|
76
|
+
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
105
77
|
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
106
78
|
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
if (serverNetworks !== undefined &&
|
|
114
|
-
serverNetworks.length &&
|
|
115
|
-
customerEvmNetworks !== undefined &&
|
|
116
|
-
customerEvmNetworks.length) {
|
|
117
|
-
mergedEvmNetworks = mergeCustomerEvmNetworksWithServerNetworks(customerEvmNetworks, serverNetworks);
|
|
79
|
+
if (evmNetworksOverrides) {
|
|
80
|
+
if (Array.isArray(evmNetworksOverrides))
|
|
81
|
+
evmNetworks = evmNetworksOverrides;
|
|
82
|
+
else
|
|
83
|
+
evmNetworks = evmNetworksOverrides(evmNetworks !== null && evmNetworks !== void 0 ? evmNetworks : []);
|
|
118
84
|
}
|
|
119
85
|
setLsNetworks({
|
|
120
|
-
|
|
86
|
+
environmentId,
|
|
87
|
+
expiry,
|
|
88
|
+
networkConfigurations: {
|
|
121
89
|
cosmos: cosmosNetworks,
|
|
122
|
-
evm:
|
|
90
|
+
evm: evmNetworks,
|
|
123
91
|
solana: solanaNetworks,
|
|
124
92
|
starknet: starknetNetworks,
|
|
125
93
|
},
|
|
126
|
-
environmentId,
|
|
127
|
-
expiry,
|
|
128
94
|
version: VERSION,
|
|
129
95
|
});
|
|
130
96
|
setlsNetworksExists(true);
|
|
@@ -133,14 +99,14 @@ const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks
|
|
|
133
99
|
}, [
|
|
134
100
|
environmentId,
|
|
135
101
|
loading,
|
|
136
|
-
customerEvmNetworks,
|
|
137
102
|
lsNetworksExists,
|
|
138
103
|
setLsNetworks,
|
|
139
104
|
projectSettings,
|
|
105
|
+
evmNetworksOverrides,
|
|
140
106
|
]);
|
|
141
107
|
return {
|
|
142
|
-
configurations: lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations,
|
|
143
108
|
handleRemoveLsNetworks,
|
|
109
|
+
networkConfigurations: lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.networkConfigurations,
|
|
144
110
|
};
|
|
145
111
|
};
|
|
146
112
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSetWalletConnectorFetchers } from './useSetWalletConnectorFetchers';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
6
|
+
require('@dynamic-labs/sdk-api');
|
|
7
|
+
require('../../../shared/logger.cjs');
|
|
8
|
+
require('@dynamic-labs/iconic');
|
|
9
|
+
require('react/jsx-runtime');
|
|
10
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
11
|
+
require('react');
|
|
12
|
+
require('@dynamic-labs/wallet-book');
|
|
13
|
+
require('../../constants/colors.cjs');
|
|
14
|
+
require('../../constants/values.cjs');
|
|
15
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
16
|
+
require('viem');
|
|
17
|
+
require('@dynamic-labs/utils');
|
|
18
|
+
require('../../../shared/consts/index.cjs');
|
|
19
|
+
require('../../../../../_virtual/_tslib.cjs');
|
|
20
|
+
require('@dynamic-labs/multi-wallet');
|
|
21
|
+
require('react-international-phone');
|
|
22
|
+
require('viem/chains');
|
|
23
|
+
var getCoinbaseMPCConnectorFetchers = require('../../functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.cjs');
|
|
24
|
+
|
|
25
|
+
const useSetWalletConnectorFetchers = (authToken, walletOptions, environmentId) => {
|
|
26
|
+
if (!authToken || !(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
27
|
+
return;
|
|
28
|
+
const { fetchAuthToken, fetchBackupCode, fetchPasscode } = getCoinbaseMPCConnectorFetchers.getCoinbaseMPCConnectorFetchers({ authToken, environmentId });
|
|
29
|
+
walletOptions.forEach((walletOption) => {
|
|
30
|
+
if (walletConnectorCore.isCoinbaseMpcWalletConnector(walletOption.walletConnector)) {
|
|
31
|
+
walletOption.walletConnector.setAuthTokenFetcher(fetchAuthToken);
|
|
32
|
+
walletOption.walletConnector.setBackupCodeFetcher(fetchBackupCode);
|
|
33
|
+
walletOption.walletConnector.setPasscodeFetcher(fetchPasscode);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.useSetWalletConnectorFetchers = useSetWalletConnectorFetchers;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isCoinbaseMpcWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import '@dynamic-labs/sdk-api';
|
|
3
|
+
import '../../../shared/logger.js';
|
|
4
|
+
import '@dynamic-labs/iconic';
|
|
5
|
+
import 'react/jsx-runtime';
|
|
6
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
7
|
+
import 'react';
|
|
8
|
+
import '@dynamic-labs/wallet-book';
|
|
9
|
+
import '../../constants/colors.js';
|
|
10
|
+
import '../../constants/values.js';
|
|
11
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
12
|
+
import 'viem';
|
|
13
|
+
import '@dynamic-labs/utils';
|
|
14
|
+
import '../../../shared/consts/index.js';
|
|
15
|
+
import '../../../../../_virtual/_tslib.js';
|
|
16
|
+
import '@dynamic-labs/multi-wallet';
|
|
17
|
+
import 'react-international-phone';
|
|
18
|
+
import 'viem/chains';
|
|
19
|
+
import { getCoinbaseMPCConnectorFetchers } from '../../functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.js';
|
|
20
|
+
|
|
21
|
+
const useSetWalletConnectorFetchers = (authToken, walletOptions, environmentId) => {
|
|
22
|
+
if (!authToken || !(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
23
|
+
return;
|
|
24
|
+
const { fetchAuthToken, fetchBackupCode, fetchPasscode } = getCoinbaseMPCConnectorFetchers({ authToken, environmentId });
|
|
25
|
+
walletOptions.forEach((walletOption) => {
|
|
26
|
+
if (isCoinbaseMpcWalletConnector(walletOption.walletConnector)) {
|
|
27
|
+
walletOption.walletConnector.setAuthTokenFetcher(fetchAuthToken);
|
|
28
|
+
walletOption.walletConnector.setBackupCodeFetcher(fetchBackupCode);
|
|
29
|
+
walletOption.walletConnector.setPasscodeFetcher(fetchPasscode);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { useSetWalletConnectorFetchers };
|
|
@@ -68,6 +68,7 @@ require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Secon
|
|
|
68
68
|
require('i18next');
|
|
69
69
|
require('@hcaptcha/react-hcaptcha');
|
|
70
70
|
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
71
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
71
72
|
require('../../../context/FooterAnimationContext/index.cjs');
|
|
72
73
|
require('../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.cjs');
|
|
73
74
|
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
@@ -64,6 +64,7 @@ import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Second
|
|
|
64
64
|
import 'i18next';
|
|
65
65
|
import '@hcaptcha/react-hcaptcha';
|
|
66
66
|
import '../../../context/LoadingContext/LoadingContext.js';
|
|
67
|
+
import '../../../config/ApiEndpoint.js';
|
|
67
68
|
import '../../../context/FooterAnimationContext/index.js';
|
|
68
69
|
import '../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.js';
|
|
69
70
|
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
@@ -73,6 +73,7 @@ require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Secon
|
|
|
73
73
|
require('i18next');
|
|
74
74
|
require('@hcaptcha/react-hcaptcha');
|
|
75
75
|
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
76
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
76
77
|
require('../../../context/FooterAnimationContext/index.cjs');
|
|
77
78
|
require('../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.cjs');
|
|
78
79
|
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
@@ -195,7 +196,9 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
195
196
|
const decodedJwt = decodeJwt.decodeJwt(jwt);
|
|
196
197
|
if (decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields.length) {
|
|
197
198
|
setOnboardingOnlyJwt(jwt);
|
|
198
|
-
setView('collect-user-data-login-
|
|
199
|
+
setView('collect-user-data-login-no-wallet', {
|
|
200
|
+
userIdentification: 'email',
|
|
201
|
+
});
|
|
199
202
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
200
203
|
return;
|
|
201
204
|
}
|
|
@@ -206,16 +209,10 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
206
209
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
207
210
|
return;
|
|
208
211
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
214
|
-
}
|
|
215
|
-
catch (e) {
|
|
216
|
-
setShowAuthFlow(false, { emitCancelAuth: true });
|
|
217
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
218
|
-
}
|
|
212
|
+
// this function will check turnkey wallet enabled and create wallet if needed
|
|
213
|
+
// if not enabled, it will throw an error.
|
|
214
|
+
yield createEmbeddedWallet().catch(() => setShowAuthFlow(false));
|
|
215
|
+
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
219
216
|
}
|
|
220
217
|
catch (error) {
|
|
221
218
|
if (error instanceof utils.NoAccessError) {
|
|
@@ -69,6 +69,7 @@ import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Second
|
|
|
69
69
|
import 'i18next';
|
|
70
70
|
import '@hcaptcha/react-hcaptcha';
|
|
71
71
|
import '../../../context/LoadingContext/LoadingContext.js';
|
|
72
|
+
import '../../../config/ApiEndpoint.js';
|
|
72
73
|
import '../../../context/FooterAnimationContext/index.js';
|
|
73
74
|
import '../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.js';
|
|
74
75
|
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
@@ -191,7 +192,9 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
191
192
|
const decodedJwt = decodeJwt(jwt);
|
|
192
193
|
if (decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields.length) {
|
|
193
194
|
setOnboardingOnlyJwt(jwt);
|
|
194
|
-
setView('collect-user-data-login-
|
|
195
|
+
setView('collect-user-data-login-no-wallet', {
|
|
196
|
+
userIdentification: 'email',
|
|
197
|
+
});
|
|
195
198
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
196
199
|
return;
|
|
197
200
|
}
|
|
@@ -202,16 +205,10 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
202
205
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
203
206
|
return;
|
|
204
207
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
210
|
-
}
|
|
211
|
-
catch (e) {
|
|
212
|
-
setShowAuthFlow(false, { emitCancelAuth: true });
|
|
213
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
214
|
-
}
|
|
208
|
+
// this function will check turnkey wallet enabled and create wallet if needed
|
|
209
|
+
// if not enabled, it will throw an error.
|
|
210
|
+
yield createEmbeddedWallet().catch(() => setShowAuthFlow(false));
|
|
211
|
+
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
215
212
|
}
|
|
216
213
|
catch (error) {
|
|
217
214
|
if (error instanceof NoAccessError) {
|