@dynamic-labs/sdk-react-core 1.1.0-alpha.7 → 1.1.0-alpha.9
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 +31 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -11
- package/src/index.cjs +4 -2
- package/src/index.js +2 -1
- package/src/lib/Main.cjs +4 -5
- package/src/lib/Main.js +4 -5
- package/src/lib/components/ChainCard/ChainCard.d.ts +2 -2
- package/src/lib/components/SelectWalletChainLayout/SelectWalletChainLayout.cjs +5 -1
- package/src/lib/components/SelectWalletChainLayout/SelectWalletChainLayout.js +5 -1
- package/src/lib/components/Toggle/Toggle.cjs +14 -0
- package/src/lib/components/Toggle/Toggle.d.ts +7 -0
- package/src/lib/components/Toggle/Toggle.js +10 -0
- package/src/lib/components/Toggle/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +42 -34
- package/src/lib/context/DynamicContext/DynamicContext.js +43 -35
- package/src/lib/context/DynamicContext/hooks/index.d.ts +1 -1
- package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModal/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.cjs +48 -0
- package/src/lib/context/DynamicContext/hooks/{useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.d.ts → useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.d.ts} +4 -7
- package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.js +44 -0
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.cjs +59 -0
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.d.ts +37 -0
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.js +55 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +1 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +1 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +11 -7
- package/src/lib/context/DynamicContext/useDynamicContext.cjs +8 -2
- package/src/lib/context/DynamicContext/useDynamicContext.d.ts +4 -1
- package/src/lib/context/DynamicContext/useDynamicContext.js +8 -2
- package/src/lib/context/FundingContext/FundingContext.cjs +4 -1
- package/src/lib/context/FundingContext/FundingContext.js +4 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -1
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/events/dynamicEvents.d.ts +3 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.cjs +2 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.js +2 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.cjs +5 -5
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.js +5 -5
- package/src/lib/locale/en/translation.cjs +18 -2
- package/src/lib/locale/en/translation.d.ts +17 -1
- package/src/lib/locale/en/translation.js +18 -2
- package/src/lib/shared/assets/alt-key.cjs +54 -0
- package/src/lib/shared/assets/alt-key.js +30 -0
- package/src/lib/shared/assets/index.d.ts +1 -0
- package/src/lib/shared/types/index.d.ts +3 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/isSelectedWalletAlreadyConnected/isSelectedWalletAlreadyConnected.cjs +2 -4
- package/src/lib/utils/functions/isSelectedWalletAlreadyConnected/isSelectedWalletAlreadyConnected.js +2 -4
- package/src/lib/utils/functions/walletListBuilder/utils/filterConnectedWallets/filterConnectedWallets.cjs +13 -2
- package/src/lib/utils/functions/walletListBuilder/utils/filterConnectedWallets/filterConnectedWallets.js +13 -2
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +3 -3
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +4 -4
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +1 -1
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +3 -2
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +6 -1
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +3 -2
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
- package/src/lib/utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.cjs +3 -3
- package/src/lib/utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.js +3 -3
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +1 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +2 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +1 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +2 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +23 -13
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.d.ts +1 -1
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +23 -13
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +9 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +9 -6
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +5 -3
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +5 -3
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +6 -8
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +6 -8
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.cjs +8 -5
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.js +8 -5
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -2
- package/src/lib/utils/hooks/useWalletConnectorNetwork/index.d.ts +1 -0
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.cjs +42 -0
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.d.ts +18 -0
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.js +38 -0
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +2 -2
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +2 -2
- package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.cjs +5 -2
- package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.js +5 -2
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.cjs +1 -1
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.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/BridgeWelcomeView/BridgeWelcomeView.cjs +1 -1
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.js +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +20 -18
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +20 -18
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +55 -30
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.d.ts +7 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +55 -31
- package/src/lib/views/LoginView/LoginView.cjs +60 -7
- package/src/lib/views/LoginView/LoginView.js +60 -7
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +1 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +1 -1
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +3 -4
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +3 -4
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +3 -6
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +3 -6
- package/src/lib/views/Passkey/PasskeyRecovery/InitRecovery/PasskeyInitRecovery.cjs +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/InitRecovery/PasskeyInitRecovery.js +1 -1
- package/src/lib/views/QrCodeView/QRCode.cjs +2 -3
- package/src/lib/views/QrCodeView/QRCode.js +2 -3
- package/src/lib/views/WalletGroupView/WalletGroupView.cjs +72 -1
- package/src/lib/views/WalletGroupView/WalletGroupView.js +73 -2
- package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/HardwareWalletToggle.cjs +74 -0
- package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/HardwareWalletToggle.d.ts +7 -0
- package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/HardwareWalletToggle.js +70 -0
- package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/index.d.ts +1 -0
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.cjs +2 -4
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.d.ts +2 -1
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.js +2 -4
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +5 -5
- package/src/lib/views/WalletUsedView/WalletUsedView.js +5 -5
- package/src/lib/views/viewToComponentMap.cjs +1 -0
- package/src/lib/views/viewToComponentMap.js +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.cjs +6 -3
- package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.js +6 -3
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/ActiveBitcoinWalletAddresses.cjs +76 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/ActiveBitcoinWalletAddresses.d.ts +9 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/ActiveBitcoinWalletAddresses.js +72 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.cjs +67 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.d.ts +9 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.js +63 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +9 -8
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +9 -8
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.cjs +66 -21
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.js +67 -22
- package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.js +2 -2
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +7 -3
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +7 -3
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.cjs +8 -6
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.js +8 -6
- package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.js +2 -2
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/index.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.cjs +0 -33
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.js +0 -29
package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.cjs
CHANGED
|
@@ -12,14 +12,17 @@ var dynamicEvents = require('../../../../events/dynamicEvents.cjs');
|
|
|
12
12
|
var validateUpdateRequest = require('./validateUpdateRequest/validateUpdateRequest.cjs');
|
|
13
13
|
|
|
14
14
|
/** Saves the values updated by the user */
|
|
15
|
-
const saveUserValues = ({ fields: newValues, updateUserResult: { isEmailVerificationRequired }, },
|
|
15
|
+
const saveUserValues = ({ fields: newValues, updateUserResult: { isEmailVerificationRequired }, }, setShowAuthFlow, setView, resolve, reject) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
// If no verification is needed, we are done
|
|
17
17
|
if (!isEmailVerificationRequired) {
|
|
18
18
|
resolve(newValues);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
// Show email verification view
|
|
22
|
-
|
|
22
|
+
setShowAuthFlow(true, {
|
|
23
|
+
ignoreIfIsEmbeddedWidget: false,
|
|
24
|
+
performMultiWalletChecks: false,
|
|
25
|
+
});
|
|
23
26
|
setView('verify-email');
|
|
24
27
|
// Subscribe to email verification result
|
|
25
28
|
dynamicEvents.dynamicEvents.once('emailVerificationResult', (wasSuccessful, newEmail) => {
|
|
@@ -35,7 +38,7 @@ const saveUserValues = ({ fields: newValues, updateUserResult: { isEmailVerifica
|
|
|
35
38
|
* The fields must have been previously enabled in the dashboard
|
|
36
39
|
*/
|
|
37
40
|
const useUpdateUserWithModal = (updateUser) => {
|
|
38
|
-
const { user, projectSettings,
|
|
41
|
+
const { user, projectSettings, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
39
42
|
const { setView } = ViewContext.useViewContext();
|
|
40
43
|
const editorContext = React.useContext(UserFieldEditorContext.UserFieldEditorContext);
|
|
41
44
|
if (!editorContext)
|
|
@@ -55,7 +58,7 @@ const useUpdateUserWithModal = (updateUser) => {
|
|
|
55
58
|
subtitle: options === null || options === void 0 ? void 0 : options.subtitle,
|
|
56
59
|
title: options === null || options === void 0 ? void 0 : options.title,
|
|
57
60
|
}, updateUser)
|
|
58
|
-
.then((updateValues) => saveUserValues(updateValues,
|
|
61
|
+
.then((updateValues) => saveUserValues(updateValues, setShowAuthFlow, setView, resolve, reject))
|
|
59
62
|
.catch((error) => {
|
|
60
63
|
if (/email already exists/gi.test(error))
|
|
61
64
|
throw error;
|
|
@@ -66,7 +69,7 @@ const useUpdateUserWithModal = (updateUser) => {
|
|
|
66
69
|
projectSettings,
|
|
67
70
|
promptUserForValues,
|
|
68
71
|
updateUser,
|
|
69
|
-
|
|
72
|
+
setShowAuthFlow,
|
|
70
73
|
setView,
|
|
71
74
|
]);
|
|
72
75
|
return updateUserWithModal;
|
package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.js
CHANGED
|
@@ -8,14 +8,17 @@ import { dynamicEvents } from '../../../../events/dynamicEvents.js';
|
|
|
8
8
|
import { validateUpdateRequest } from './validateUpdateRequest/validateUpdateRequest.js';
|
|
9
9
|
|
|
10
10
|
/** Saves the values updated by the user */
|
|
11
|
-
const saveUserValues = ({ fields: newValues, updateUserResult: { isEmailVerificationRequired }, },
|
|
11
|
+
const saveUserValues = ({ fields: newValues, updateUserResult: { isEmailVerificationRequired }, }, setShowAuthFlow, setView, resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
12
|
// If no verification is needed, we are done
|
|
13
13
|
if (!isEmailVerificationRequired) {
|
|
14
14
|
resolve(newValues);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
// Show email verification view
|
|
18
|
-
|
|
18
|
+
setShowAuthFlow(true, {
|
|
19
|
+
ignoreIfIsEmbeddedWidget: false,
|
|
20
|
+
performMultiWalletChecks: false,
|
|
21
|
+
});
|
|
19
22
|
setView('verify-email');
|
|
20
23
|
// Subscribe to email verification result
|
|
21
24
|
dynamicEvents.once('emailVerificationResult', (wasSuccessful, newEmail) => {
|
|
@@ -31,7 +34,7 @@ const saveUserValues = ({ fields: newValues, updateUserResult: { isEmailVerifica
|
|
|
31
34
|
* The fields must have been previously enabled in the dashboard
|
|
32
35
|
*/
|
|
33
36
|
const useUpdateUserWithModal = (updateUser) => {
|
|
34
|
-
const { user, projectSettings,
|
|
37
|
+
const { user, projectSettings, setShowAuthFlow } = useInternalDynamicContext();
|
|
35
38
|
const { setView } = useViewContext();
|
|
36
39
|
const editorContext = useContext(UserFieldEditorContext);
|
|
37
40
|
if (!editorContext)
|
|
@@ -51,7 +54,7 @@ const useUpdateUserWithModal = (updateUser) => {
|
|
|
51
54
|
subtitle: options === null || options === void 0 ? void 0 : options.subtitle,
|
|
52
55
|
title: options === null || options === void 0 ? void 0 : options.title,
|
|
53
56
|
}, updateUser)
|
|
54
|
-
.then((updateValues) => saveUserValues(updateValues,
|
|
57
|
+
.then((updateValues) => saveUserValues(updateValues, setShowAuthFlow, setView, resolve, reject))
|
|
55
58
|
.catch((error) => {
|
|
56
59
|
if (/email already exists/gi.test(error))
|
|
57
60
|
throw error;
|
|
@@ -62,7 +65,7 @@ const useUpdateUserWithModal = (updateUser) => {
|
|
|
62
65
|
projectSettings,
|
|
63
66
|
promptUserForValues,
|
|
64
67
|
updateUser,
|
|
65
|
-
|
|
68
|
+
setShowAuthFlow,
|
|
66
69
|
setView,
|
|
67
70
|
]);
|
|
68
71
|
return updateUserWithModal;
|
|
@@ -38,7 +38,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
38
38
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
39
39
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
40
40
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
41
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
41
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
42
42
|
// If the user is not already logged it means that we only need to verify
|
|
43
43
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
44
44
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -80,7 +80,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
80
80
|
if (newSelectedCredentialWallet) {
|
|
81
81
|
const currentPrimaryWallet = user.verifiedCredentials.find((a) => a.id === primaryWalletId);
|
|
82
82
|
if (verifyOnly ||
|
|
83
|
-
|
|
83
|
+
!primaryWallet ||
|
|
84
84
|
(multiWalletWidgetState === 'awaiting_signature' &&
|
|
85
85
|
newSelectedCredentialWallet.walletName ===
|
|
86
86
|
(currentPrimaryWallet === null || currentPrimaryWallet === void 0 ? void 0 : currentPrimaryWallet.walletName)) ||
|
|
@@ -34,7 +34,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
34
34
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
35
35
|
const { setView, goToInitialView } = useViewContext();
|
|
36
36
|
const { setErrorMessage, setError } = useErrorContext();
|
|
37
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, } = useInternalDynamicContext();
|
|
37
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, primaryWallet, } = useInternalDynamicContext();
|
|
38
38
|
// If the user is not already logged it means that we only need to verify
|
|
39
39
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
40
40
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -76,7 +76,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
76
76
|
if (newSelectedCredentialWallet) {
|
|
77
77
|
const currentPrimaryWallet = user.verifiedCredentials.find((a) => a.id === primaryWalletId);
|
|
78
78
|
if (verifyOnly ||
|
|
79
|
-
|
|
79
|
+
!primaryWallet ||
|
|
80
80
|
(multiWalletWidgetState === 'awaiting_signature' &&
|
|
81
81
|
newSelectedCredentialWallet.walletName ===
|
|
82
82
|
(currentPrimaryWallet === null || currentPrimaryWallet === void 0 ? void 0 : currentPrimaryWallet.walletName)) ||
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useWalletConnectorNetwork } from './useWalletConnectorNetwork';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var usePromise = require('../usePromise/usePromise.cjs');
|
|
7
|
+
require('../../../events/dynamicEvents.cjs');
|
|
8
|
+
var useWalletConnectorEvent = require('../events/useWalletConnectorEvent/useWalletConnectorEvent.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Sync wallet connector network.
|
|
12
|
+
*
|
|
13
|
+
* @param walletConnector - The WalletConnector instance to be used.
|
|
14
|
+
*
|
|
15
|
+
* @returns {{ network: string | number | undefined }} An object containing the current network state.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Example of using the useWalletConnectorNetwork hook
|
|
19
|
+
* const { network } = useWalletConnectorNetwork(walletConnector);
|
|
20
|
+
*
|
|
21
|
+
* // You can then use the 'network' state in your component
|
|
22
|
+
* return <div>Current Network: {network}</div>;
|
|
23
|
+
*/
|
|
24
|
+
const useWalletConnectorNetwork = (walletConnector) => {
|
|
25
|
+
const [network, setNetwork] = React.useState();
|
|
26
|
+
usePromise.usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), {
|
|
27
|
+
onResolve: (network) => setNetwork(network),
|
|
28
|
+
});
|
|
29
|
+
useWalletConnectorEvent.useWalletConnectorEvent(walletConnector || undefined, 'chainChange', ({ chain }) => setNetwork(chain));
|
|
30
|
+
/**
|
|
31
|
+
* Listen to disconnect event and update the network because ArgentX
|
|
32
|
+
* emits a disconnect event when the user switches network.
|
|
33
|
+
*/
|
|
34
|
+
useWalletConnectorEvent.useWalletConnectorEvent(walletConnector || undefined, 'disconnect', () => {
|
|
35
|
+
if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key) === 'argentx') {
|
|
36
|
+
walletConnector.getNetwork().then(setNetwork);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return { network };
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.useWalletConnectorNetwork = useWalletConnectorNetwork;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
/**
|
|
3
|
+
* Sync wallet connector network.
|
|
4
|
+
*
|
|
5
|
+
* @param walletConnector - The WalletConnector instance to be used.
|
|
6
|
+
*
|
|
7
|
+
* @returns {{ network: string | number | undefined }} An object containing the current network state.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Example of using the useWalletConnectorNetwork hook
|
|
11
|
+
* const { network } = useWalletConnectorNetwork(walletConnector);
|
|
12
|
+
*
|
|
13
|
+
* // You can then use the 'network' state in your component
|
|
14
|
+
* return <div>Current Network: {network}</div>;
|
|
15
|
+
*/
|
|
16
|
+
export declare const useWalletConnectorNetwork: (walletConnector: WalletConnector | null | undefined) => {
|
|
17
|
+
network: string | number | undefined;
|
|
18
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { usePromise } from '../usePromise/usePromise.js';
|
|
3
|
+
import '../../../events/dynamicEvents.js';
|
|
4
|
+
import { useWalletConnectorEvent } from '../events/useWalletConnectorEvent/useWalletConnectorEvent.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sync wallet connector network.
|
|
8
|
+
*
|
|
9
|
+
* @param walletConnector - The WalletConnector instance to be used.
|
|
10
|
+
*
|
|
11
|
+
* @returns {{ network: string | number | undefined }} An object containing the current network state.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Example of using the useWalletConnectorNetwork hook
|
|
15
|
+
* const { network } = useWalletConnectorNetwork(walletConnector);
|
|
16
|
+
*
|
|
17
|
+
* // You can then use the 'network' state in your component
|
|
18
|
+
* return <div>Current Network: {network}</div>;
|
|
19
|
+
*/
|
|
20
|
+
const useWalletConnectorNetwork = (walletConnector) => {
|
|
21
|
+
const [network, setNetwork] = useState();
|
|
22
|
+
usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), {
|
|
23
|
+
onResolve: (network) => setNetwork(network),
|
|
24
|
+
});
|
|
25
|
+
useWalletConnectorEvent(walletConnector || undefined, 'chainChange', ({ chain }) => setNetwork(chain));
|
|
26
|
+
/**
|
|
27
|
+
* Listen to disconnect event and update the network because ArgentX
|
|
28
|
+
* emits a disconnect event when the user switches network.
|
|
29
|
+
*/
|
|
30
|
+
useWalletConnectorEvent(walletConnector || undefined, 'disconnect', () => {
|
|
31
|
+
if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key) === 'argentx') {
|
|
32
|
+
walletConnector.getNetwork().then(setNetwork);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return { network };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { useWalletConnectorNetwork };
|
|
@@ -17,7 +17,6 @@ require('../../constants/colors.cjs');
|
|
|
17
17
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
18
|
require('viem');
|
|
19
19
|
require('../../../shared/consts/index.cjs');
|
|
20
|
-
var isSameWalletName = require('../../functions/isSameWalletName/isSameWalletName.cjs');
|
|
21
20
|
var useWalletsConnectionState = require('../useWalletsConnectionState/useWalletsConnectionState.cjs');
|
|
22
21
|
var reconnectSocialWallet = require('./reconnectSocialWallet.cjs');
|
|
23
22
|
var createLinkedWalletsFromWalletOptions = require('./utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.cjs');
|
|
@@ -96,7 +95,8 @@ const useWalletConnectors = ({ authMode, authToken, connectedWallets, walletConn
|
|
|
96
95
|
const accountIsNotConnectedInSecondaryWallet = connectedAccounts &&
|
|
97
96
|
!connectedAccounts.find((connectedAccount) => connectedAccount.toLowerCase() ===
|
|
98
97
|
newPrimaryWallet.address.toLowerCase());
|
|
99
|
-
return (
|
|
98
|
+
return (newPrimaryWallet.connector.key === primaryWallet.connector.key ||
|
|
99
|
+
accountIsNotConnectedInSecondaryWallet);
|
|
100
100
|
}, [multiWalletWidgetState]);
|
|
101
101
|
const checkIfShowQrCodeModal = React.useCallback((wallet) => !wallet.connector.isInstalledOnBrowser() &&
|
|
102
102
|
!wallet.connector.canConnectViaCustodialService, []);
|
|
@@ -13,7 +13,6 @@ import '../../constants/colors.js';
|
|
|
13
13
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
14
|
import 'viem';
|
|
15
15
|
import '../../../shared/consts/index.js';
|
|
16
|
-
import { isSameWalletName } from '../../functions/isSameWalletName/isSameWalletName.js';
|
|
17
16
|
import { useWalletsConnectionState } from '../useWalletsConnectionState/useWalletsConnectionState.js';
|
|
18
17
|
import { reconnectSocialWallet } from './reconnectSocialWallet.js';
|
|
19
18
|
import { createLinkedWalletsFromWalletOptions } from './utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.js';
|
|
@@ -92,7 +91,8 @@ const useWalletConnectors = ({ authMode, authToken, connectedWallets, walletConn
|
|
|
92
91
|
const accountIsNotConnectedInSecondaryWallet = connectedAccounts &&
|
|
93
92
|
!connectedAccounts.find((connectedAccount) => connectedAccount.toLowerCase() ===
|
|
94
93
|
newPrimaryWallet.address.toLowerCase());
|
|
95
|
-
return (
|
|
94
|
+
return (newPrimaryWallet.connector.key === primaryWallet.connector.key ||
|
|
95
|
+
accountIsNotConnectedInSecondaryWallet);
|
|
96
96
|
}, [multiWalletWidgetState]);
|
|
97
97
|
const checkIfShowQrCodeModal = useCallback((wallet) => !wallet.connector.isInstalledOnBrowser() &&
|
|
98
98
|
!wallet.connector.canConnectViaCustodialService, []);
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// remaining normalizeWalletName until QNTM-846 is complete due to us still passing the walletname to redcoast:
|
|
8
|
+
// https://linear.app/dynamic-labs/issue/QNTM-846/remove-usage-of-walletwalletconnectorwname-to-instead-use
|
|
9
|
+
const findWallet = (account, walletOptions) => walletOptions.find((wallet) => account.walletName &&
|
|
10
|
+
walletConnectorCore.normalizeWalletName(account.walletName) === wallet.key);
|
|
8
11
|
|
|
9
12
|
exports.findWallet = findWallet;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeWalletName } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// remaining normalizeWalletName until QNTM-846 is complete due to us still passing the walletname to redcoast:
|
|
4
|
+
// https://linear.app/dynamic-labs/issue/QNTM-846/remove-usage-of-walletwalletconnectorwname-to-instead-use
|
|
5
|
+
const findWallet = (account, walletOptions) => walletOptions.find((wallet) => account.walletName &&
|
|
6
|
+
normalizeWalletName(account.walletName) === wallet.key);
|
|
4
7
|
|
|
5
8
|
export { findWallet };
|
|
@@ -32,7 +32,7 @@ const BridgeNextWalletConnectionView = () => {
|
|
|
32
32
|
if (!chainInfo) {
|
|
33
33
|
throw new utils.DynamicError('No chain info found for chain', chain);
|
|
34
34
|
}
|
|
35
|
-
return (jsxRuntime.jsx(BridgeNextWalletToConnectLayout.BridgeNextWalletToConnectLayout, { chainName: chainInfo.blockchainName, chainIcon: jsxRuntime.jsx(ChainIcon, {}), onClickAction: () => setView('wallet-list'), onClickClose: () => setShowAuthFlow(false) }));
|
|
35
|
+
return (jsxRuntime.jsx(BridgeNextWalletToConnectLayout.BridgeNextWalletToConnectLayout, { chainName: chainInfo.blockchainName, chainIcon: jsxRuntime.jsx(ChainIcon, {}), onClickAction: () => setView('wallet-list'), onClickClose: () => setShowAuthFlow(false, { emitCancelAuth: true }) }));
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
exports.BridgeNextWalletConnectionView = BridgeNextWalletConnectionView;
|
|
@@ -28,7 +28,7 @@ const BridgeNextWalletConnectionView = () => {
|
|
|
28
28
|
if (!chainInfo) {
|
|
29
29
|
throw new DynamicError('No chain info found for chain', chain);
|
|
30
30
|
}
|
|
31
|
-
return (jsx(BridgeNextWalletToConnectLayout, { chainName: chainInfo.blockchainName, chainIcon: jsx(ChainIcon, {}), onClickAction: () => setView('wallet-list'), onClickClose: () => setShowAuthFlow(false) }));
|
|
31
|
+
return (jsx(BridgeNextWalletToConnectLayout, { chainName: chainInfo.blockchainName, chainIcon: jsx(ChainIcon, {}), onClickAction: () => setView('wallet-list'), onClickClose: () => setShowAuthFlow(false, { emitCancelAuth: true }) }));
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export { BridgeNextWalletConnectionView };
|
|
@@ -27,7 +27,7 @@ var Balance = require('../../widgets/DynamicWidget/components/Balance/Balance.cj
|
|
|
27
27
|
const BridgeSummaryView = () => {
|
|
28
28
|
const { primaryWallet, setShowAuthFlow, appName, bridgeChains = [], } = useInternalDynamicContext.useInternalDynamicContext();
|
|
29
29
|
const { t } = reactI18next.useTranslation();
|
|
30
|
-
const onClickClose = () => setShowAuthFlow(false);
|
|
30
|
+
const onClickClose = () => setShowAuthFlow(false, { emitCancelAuth: true });
|
|
31
31
|
const body = React.useMemo(() => {
|
|
32
32
|
const blockchainNames = bridgeChains.map(({ chain }) => { var _a; return (_a = walletConnectorCore.getChainInfo(chain)) === null || _a === void 0 ? void 0 : _a.blockchainName; });
|
|
33
33
|
const [firstBlockchainName, secondBlockchainName] = blockchainNames;
|
|
@@ -23,7 +23,7 @@ import { Balance } from '../../widgets/DynamicWidget/components/Balance/Balance.
|
|
|
23
23
|
const BridgeSummaryView = () => {
|
|
24
24
|
const { primaryWallet, setShowAuthFlow, appName, bridgeChains = [], } = useInternalDynamicContext();
|
|
25
25
|
const { t } = useTranslation();
|
|
26
|
-
const onClickClose = () => setShowAuthFlow(false);
|
|
26
|
+
const onClickClose = () => setShowAuthFlow(false, { emitCancelAuth: true });
|
|
27
27
|
const body = useMemo(() => {
|
|
28
28
|
const blockchainNames = bridgeChains.map(({ chain }) => { var _a; return (_a = getChainInfo(chain)) === null || _a === void 0 ? void 0 : _a.blockchainName; });
|
|
29
29
|
const [firstBlockchainName, secondBlockchainName] = blockchainNames;
|
|
@@ -47,7 +47,7 @@ const BridgeWelcomeView = () => {
|
|
|
47
47
|
return undefined;
|
|
48
48
|
})
|
|
49
49
|
.filter(isChainInfoDefined), [bridgeChains]);
|
|
50
|
-
return (jsxRuntime.jsx(BridgeWelcomeLayout.BridgeWelcomeLayout, { onClickClose: () => setShowAuthFlow(false), title: t('dyn_bridge.welcome_view.title', { appName }), copykey: 'dyn_bridge.welcome_view.title', body: body, chains: chains, actionButtonText: t('dyn_bridge.welcome_view.button'), onClickAction: () => setView('wallet-list') }));
|
|
50
|
+
return (jsxRuntime.jsx(BridgeWelcomeLayout.BridgeWelcomeLayout, { onClickClose: () => setShowAuthFlow(false, { emitCancelAuth: true }), title: t('dyn_bridge.welcome_view.title', { appName }), copykey: 'dyn_bridge.welcome_view.title', body: body, chains: chains, actionButtonText: t('dyn_bridge.welcome_view.button'), onClickAction: () => setView('wallet-list') }));
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
exports.BridgeWelcomeView = BridgeWelcomeView;
|
|
@@ -43,7 +43,7 @@ const BridgeWelcomeView = () => {
|
|
|
43
43
|
return undefined;
|
|
44
44
|
})
|
|
45
45
|
.filter(isChainInfoDefined), [bridgeChains]);
|
|
46
|
-
return (jsx(BridgeWelcomeLayout, { onClickClose: () => setShowAuthFlow(false), title: t('dyn_bridge.welcome_view.title', { appName }), copykey: 'dyn_bridge.welcome_view.title', body: body, chains: chains, actionButtonText: t('dyn_bridge.welcome_view.button'), onClickAction: () => setView('wallet-list') }));
|
|
46
|
+
return (jsx(BridgeWelcomeLayout, { onClickClose: () => setShowAuthFlow(false, { emitCancelAuth: true }), title: t('dyn_bridge.welcome_view.title', { appName }), copykey: 'dyn_bridge.welcome_view.title', body: body, chains: chains, actionButtonText: t('dyn_bridge.welcome_view.button'), onClickAction: () => setView('wallet-list') }));
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
export { BridgeWelcomeView };
|
|
@@ -13,7 +13,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useInte
|
|
|
13
13
|
require('@dynamic-labs/wallet-connector-core');
|
|
14
14
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
15
15
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
16
|
-
require('../../../context/ViewContext/ViewContext.cjs');
|
|
16
|
+
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
17
17
|
var decodeJwt = require('../../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
18
18
|
require('@dynamic-labs/iconic');
|
|
19
19
|
var close = require('../../../shared/assets/close.cjs');
|
|
@@ -78,17 +78,18 @@ var constants = require('../constants.cjs');
|
|
|
78
78
|
const EmbeddedRevealView = () => {
|
|
79
79
|
var _a, _b;
|
|
80
80
|
const { authToken, primaryWallet, user, setShowAuthFlow, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
81
|
+
const { view } = ViewContext.useViewContext();
|
|
81
82
|
const [acknowledgement1, setAcknowledgement1] = React.useState(false);
|
|
82
83
|
const iframeContainerRef = React.useRef(null);
|
|
83
84
|
const decodedJwt = decodeJwt.decodeJwt(authToken);
|
|
84
85
|
const walletProperties = (_b = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
85
86
|
const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
87
|
+
const exportPrivateKey = view === null || view === void 0 ? void 0 : view.includes('account');
|
|
86
88
|
React.useEffect(() => {
|
|
89
|
+
var _a;
|
|
87
90
|
const iframeContainerElement = iframeContainerRef.current;
|
|
88
|
-
if (!iframeContainerElement
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
if (iframeContainerElement.children.length > 0) {
|
|
91
|
+
if (!iframeContainerElement ||
|
|
92
|
+
((_a = iframeContainerElement === null || iframeContainerElement === void 0 ? void 0 : iframeContainerElement.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
95
|
turnkeyExport.initExport({
|
|
@@ -105,11 +106,8 @@ const EmbeddedRevealView = () => {
|
|
|
105
106
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
107
|
}, []);
|
|
107
108
|
const { mutate: handleExportWallet, isLoading, error, data, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
-
const iframeContainerElement = iframeContainerRef.current;
|
|
109
|
-
if (!iframeContainerElement) {
|
|
110
|
-
throw new utils.DynamicError('Missing iframe container');
|
|
111
|
-
}
|
|
112
109
|
return turnkeyExport.exportCredential({
|
|
110
|
+
address: exportPrivateKey ? primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address : undefined,
|
|
113
111
|
authToken,
|
|
114
112
|
environmentId,
|
|
115
113
|
userEmail: user === null || user === void 0 ? void 0 : user.email,
|
|
@@ -137,22 +135,26 @@ const EmbeddedRevealView = () => {
|
|
|
137
135
|
if (((_a = iframeContainerRef === null || iframeContainerRef === void 0 ? void 0 : iframeContainerRef.current) === null || _a === void 0 ? void 0 : _a.children) && data) {
|
|
138
136
|
// eslint-disable-next-line prefer-destructuring
|
|
139
137
|
const iframeElement = iframeContainerRef.current.children[0];
|
|
140
|
-
iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', isTurnkeyHDWallet
|
|
138
|
+
iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', !isTurnkeyHDWallet || exportPrivateKey
|
|
139
|
+
? 'height: 60px'
|
|
140
|
+
: 'height: 100px');
|
|
141
141
|
}
|
|
142
|
-
}, [iframeContainerRef, data, isTurnkeyHDWallet]);
|
|
143
|
-
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { onClick: () => setShowAuthFlow(false), type: 'button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
142
|
+
}, [iframeContainerRef, data, isTurnkeyHDWallet, exportPrivateKey]);
|
|
143
|
+
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { onClick: () => setShowAuthFlow(false, { emitCancelAuth: true }), type: 'button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
144
144
|
const hasInjectedCredential = !isLoading && data && !error;
|
|
145
|
-
const credentialTitle = isTurnkeyHDWallet
|
|
146
|
-
? t('dyn_embedded_reveal.
|
|
147
|
-
: t('dyn_embedded_reveal.
|
|
145
|
+
const credentialTitle = !isTurnkeyHDWallet || exportPrivateKey
|
|
146
|
+
? t('dyn_embedded_reveal.private_key_title')
|
|
147
|
+
: t('dyn_embedded_reveal.recovery_phrase_title');
|
|
148
148
|
const title = hasInjectedCredential
|
|
149
149
|
? credentialTitle
|
|
150
150
|
: t('dyn_embedded_reveal.agreement_title');
|
|
151
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsxRuntime.jsx("div", { className: 'embedded-reveal-view', children: jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body', children: [contentHeader, jsxRuntime.jsx("div", { id: constants.iframeContainerId, style: { display: data ? 'block' : 'none' }, ref: iframeContainerRef }), hasInjectedCredential ? (jsxRuntime.jsx(Button.Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', onClick: () => setShowAuthFlow(false), loading: isLoading, typographyProps: {
|
|
151
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsxRuntime.jsx("div", { className: 'embedded-reveal-view', children: jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body', children: [contentHeader, jsxRuntime.jsx("div", { id: constants.iframeContainerId, style: { display: data ? 'block' : 'none' }, ref: iframeContainerRef }), hasInjectedCredential ? (jsxRuntime.jsx(Button.Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', onClick: () => setShowAuthFlow(false), loading: isLoading, copykey: 'dyn_embedded_reveal.done_button_label', typographyProps: {
|
|
152
152
|
color: 'inherit',
|
|
153
|
-
}, children: t('dyn_embedded_reveal.done_button_label') })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__description', children: jsxRuntime.jsx(Badge.Badge, { text: t('dyn_embedded_reveal.badge_label'), className: 'embedded-reveal-view__body__badge' }) }), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card', children: [jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsxRuntime.jsx(walletV2.ReactComponent, {}) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, children: t('dyn_embedded_reveal.statement_1.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', children: t('dyn_embedded_reveal.statement_1.description') })] })] }), jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsxRuntime.jsx(eyeOffIcon.ReactComponent, {}) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, children: t('dyn_embedded_reveal.statement_2.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', weight: 'regular',
|
|
153
|
+
}, children: t('dyn_embedded_reveal.done_button_label') })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__description', children: jsxRuntime.jsx(Badge.Badge, { text: t('dyn_embedded_reveal.badge_label'), className: 'embedded-reveal-view__body__badge' }) }), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card', children: [jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsxRuntime.jsx(walletV2.ReactComponent, {}) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.statement_1.title', children: t('dyn_embedded_reveal.statement_1.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', copykey: 'dyn_embedded_reveal.statement_1.description', children: t('dyn_embedded_reveal.statement_1.description') })] })] }), jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsxRuntime.jsx(eyeOffIcon.ReactComponent, {}) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.statement_2.title', children: t('dyn_embedded_reveal.statement_2.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', copykey: 'dyn_embedded_reveal.statement_2.description', children: t('dyn_embedded_reveal.statement_2.description', {
|
|
154
|
+
credential_type: credentialTitle === null || credentialTitle === void 0 ? void 0 : credentialTitle.toLowerCase(),
|
|
155
|
+
}) })] })] })] }), jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__confirm_card', children: [jsxRuntime.jsxs("button", { className: 'embedded-reveal-view__body__card__acknowledgement', onClick: () => setAcknowledgement1(!acknowledgement1), children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Checkbox.Checkbox, { checked: acknowledgement1, onChange: () => setAcknowledgement1(!acknowledgement1), className: 'embedded-reveal-view__body__card__statement__checkbox', id: 'embedded-reveal-checkbox-1' }) }), jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.checkbox_label', children: t('dyn_embedded_reveal.checkbox_label') }) })] }), jsxRuntime.jsx(Button.Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', typographyProps: {
|
|
154
156
|
color: 'inherit',
|
|
155
|
-
}, onClick: () => handleExportWallet(), disabled: !acknowledgement1, loading: isLoading, dataTestId: 'embedded-reveal-button', children: t('dyn_embedded_reveal.reveal_button_label') })] })] }))] }) })] }));
|
|
157
|
+
}, onClick: () => handleExportWallet(), disabled: !acknowledgement1, loading: isLoading, dataTestId: 'embedded-reveal-button', copykey: 'dyn_embedded_reveal.reveal_button_label', children: t('dyn_embedded_reveal.reveal_button_label') })] })] }))] }) })] }));
|
|
156
158
|
};
|
|
157
159
|
|
|
158
160
|
exports.EmbeddedRevealView = EmbeddedRevealView;
|
|
@@ -9,7 +9,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useIn
|
|
|
9
9
|
import '@dynamic-labs/wallet-connector-core';
|
|
10
10
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
11
11
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
12
|
-
import '../../../context/ViewContext/ViewContext.js';
|
|
12
|
+
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
13
13
|
import { decodeJwt } from '../../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
14
14
|
import '@dynamic-labs/iconic';
|
|
15
15
|
import { ReactComponent as SvgClose } from '../../../shared/assets/close.js';
|
|
@@ -74,17 +74,18 @@ import { iframeContainerId, iframeElementId } from '../constants.js';
|
|
|
74
74
|
const EmbeddedRevealView = () => {
|
|
75
75
|
var _a, _b;
|
|
76
76
|
const { authToken, primaryWallet, user, setShowAuthFlow, environmentId } = useInternalDynamicContext();
|
|
77
|
+
const { view } = useViewContext();
|
|
77
78
|
const [acknowledgement1, setAcknowledgement1] = useState(false);
|
|
78
79
|
const iframeContainerRef = useRef(null);
|
|
79
80
|
const decodedJwt = decodeJwt(authToken);
|
|
80
81
|
const walletProperties = (_b = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
81
82
|
const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
83
|
+
const exportPrivateKey = view === null || view === void 0 ? void 0 : view.includes('account');
|
|
82
84
|
useEffect(() => {
|
|
85
|
+
var _a;
|
|
83
86
|
const iframeContainerElement = iframeContainerRef.current;
|
|
84
|
-
if (!iframeContainerElement
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
if (iframeContainerElement.children.length > 0) {
|
|
87
|
+
if (!iframeContainerElement ||
|
|
88
|
+
((_a = iframeContainerElement === null || iframeContainerElement === void 0 ? void 0 : iframeContainerElement.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
91
|
initExport({
|
|
@@ -101,11 +102,8 @@ const EmbeddedRevealView = () => {
|
|
|
101
102
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
102
103
|
}, []);
|
|
103
104
|
const { mutate: handleExportWallet, isLoading, error, data, } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
104
|
-
const iframeContainerElement = iframeContainerRef.current;
|
|
105
|
-
if (!iframeContainerElement) {
|
|
106
|
-
throw new DynamicError('Missing iframe container');
|
|
107
|
-
}
|
|
108
105
|
return exportCredential({
|
|
106
|
+
address: exportPrivateKey ? primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address : undefined,
|
|
109
107
|
authToken,
|
|
110
108
|
environmentId,
|
|
111
109
|
userEmail: user === null || user === void 0 ? void 0 : user.email,
|
|
@@ -133,22 +131,26 @@ const EmbeddedRevealView = () => {
|
|
|
133
131
|
if (((_a = iframeContainerRef === null || iframeContainerRef === void 0 ? void 0 : iframeContainerRef.current) === null || _a === void 0 ? void 0 : _a.children) && data) {
|
|
134
132
|
// eslint-disable-next-line prefer-destructuring
|
|
135
133
|
const iframeElement = iframeContainerRef.current.children[0];
|
|
136
|
-
iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', isTurnkeyHDWallet
|
|
134
|
+
iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', !isTurnkeyHDWallet || exportPrivateKey
|
|
135
|
+
? 'height: 60px'
|
|
136
|
+
: 'height: 100px');
|
|
137
137
|
}
|
|
138
|
-
}, [iframeContainerRef, data, isTurnkeyHDWallet]);
|
|
139
|
-
const closeButton = (jsx(IconButton, { onClick: () => setShowAuthFlow(false), type: 'button', children: jsx(SvgClose, {}) }));
|
|
138
|
+
}, [iframeContainerRef, data, isTurnkeyHDWallet, exportPrivateKey]);
|
|
139
|
+
const closeButton = (jsx(IconButton, { onClick: () => setShowAuthFlow(false, { emitCancelAuth: true }), type: 'button', children: jsx(SvgClose, {}) }));
|
|
140
140
|
const hasInjectedCredential = !isLoading && data && !error;
|
|
141
|
-
const credentialTitle = isTurnkeyHDWallet
|
|
142
|
-
? t('dyn_embedded_reveal.
|
|
143
|
-
: t('dyn_embedded_reveal.
|
|
141
|
+
const credentialTitle = !isTurnkeyHDWallet || exportPrivateKey
|
|
142
|
+
? t('dyn_embedded_reveal.private_key_title')
|
|
143
|
+
: t('dyn_embedded_reveal.recovery_phrase_title');
|
|
144
144
|
const title = hasInjectedCredential
|
|
145
145
|
? credentialTitle
|
|
146
146
|
: t('dyn_embedded_reveal.agreement_title');
|
|
147
|
-
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsx("div", { className: 'embedded-reveal-view', children: jsxs("div", { className: 'embedded-reveal-view__body', children: [contentHeader, jsx("div", { id: iframeContainerId, style: { display: data ? 'block' : 'none' }, ref: iframeContainerRef }), hasInjectedCredential ? (jsx(Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', onClick: () => setShowAuthFlow(false), loading: isLoading, typographyProps: {
|
|
147
|
+
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsx("div", { className: 'embedded-reveal-view', children: jsxs("div", { className: 'embedded-reveal-view__body', children: [contentHeader, jsx("div", { id: iframeContainerId, style: { display: data ? 'block' : 'none' }, ref: iframeContainerRef }), hasInjectedCredential ? (jsx(Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', onClick: () => setShowAuthFlow(false), loading: isLoading, copykey: 'dyn_embedded_reveal.done_button_label', typographyProps: {
|
|
148
148
|
color: 'inherit',
|
|
149
|
-
}, children: t('dyn_embedded_reveal.done_button_label') })) : (jsxs(Fragment, { children: [jsx("div", { className: 'embedded-reveal-view__body__description', children: jsx(Badge, { text: t('dyn_embedded_reveal.badge_label'), className: 'embedded-reveal-view__body__badge' }) }), errorText && jsx(ErrorContainer, { children: errorText }), jsxs("div", { className: 'embedded-reveal-view__body__card', children: [jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsx(SvgWalletV2, {}) }), jsxs("div", { children: [jsx(Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, children: t('dyn_embedded_reveal.statement_1.title') }), jsx(Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', children: t('dyn_embedded_reveal.statement_1.description') })] })] }), jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsx(SvgEyeOffIcon, {}) }), jsxs("div", { children: [jsx(Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, children: t('dyn_embedded_reveal.statement_2.title') }), jsx(Typography, { variant: 'body_small', color: 'secondary', weight: 'regular',
|
|
149
|
+
}, children: t('dyn_embedded_reveal.done_button_label') })) : (jsxs(Fragment, { children: [jsx("div", { className: 'embedded-reveal-view__body__description', children: jsx(Badge, { text: t('dyn_embedded_reveal.badge_label'), className: 'embedded-reveal-view__body__badge' }) }), errorText && jsx(ErrorContainer, { children: errorText }), jsxs("div", { className: 'embedded-reveal-view__body__card', children: [jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsx(SvgWalletV2, {}) }), jsxs("div", { children: [jsx(Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.statement_1.title', children: t('dyn_embedded_reveal.statement_1.title') }), jsx(Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', copykey: 'dyn_embedded_reveal.statement_1.description', children: t('dyn_embedded_reveal.statement_1.description') })] })] }), jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsx(SvgEyeOffIcon, {}) }), jsxs("div", { children: [jsx(Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.statement_2.title', children: t('dyn_embedded_reveal.statement_2.title') }), jsx(Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', copykey: 'dyn_embedded_reveal.statement_2.description', children: t('dyn_embedded_reveal.statement_2.description', {
|
|
150
|
+
credential_type: credentialTitle === null || credentialTitle === void 0 ? void 0 : credentialTitle.toLowerCase(),
|
|
151
|
+
}) })] })] })] }), jsxs("div", { className: 'embedded-reveal-view__body__confirm_card', children: [jsxs("button", { className: 'embedded-reveal-view__body__card__acknowledgement', onClick: () => setAcknowledgement1(!acknowledgement1), children: [jsx("div", { children: jsx(Checkbox, { checked: acknowledgement1, onChange: () => setAcknowledgement1(!acknowledgement1), className: 'embedded-reveal-view__body__card__statement__checkbox', id: 'embedded-reveal-checkbox-1' }) }), jsx("div", { children: jsx(Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.checkbox_label', children: t('dyn_embedded_reveal.checkbox_label') }) })] }), jsx(Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', typographyProps: {
|
|
150
152
|
color: 'inherit',
|
|
151
|
-
}, onClick: () => handleExportWallet(), disabled: !acknowledgement1, loading: isLoading, dataTestId: 'embedded-reveal-button', children: t('dyn_embedded_reveal.reveal_button_label') })] })] }))] }) })] }));
|
|
153
|
+
}, onClick: () => handleExportWallet(), disabled: !acknowledgement1, loading: isLoading, dataTestId: 'embedded-reveal-button', copykey: 'dyn_embedded_reveal.reveal_button_label', children: t('dyn_embedded_reveal.reveal_button_label') })] })] }))] }) })] }));
|
|
152
154
|
};
|
|
153
155
|
|
|
154
156
|
export { EmbeddedRevealView };
|