@dynamic-labs/sdk-react-core 2.1.0-alpha.25 → 2.1.0-alpha.26
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 +13 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -5
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -5
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +0 -1
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +2 -2
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +2 -2
- package/src/lib/context/DynamicContext/validators/validators.d.ts +2 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +30 -14
- package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +3 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +30 -14
- package/src/lib/data/api/mfa/mfa.cjs +10 -5
- package/src/lib/data/api/mfa/mfa.d.ts +1 -1
- package/src/lib/data/api/mfa/mfa.js +10 -5
- package/src/lib/data/api/wallets/wallets.cjs +6 -3
- package/src/lib/data/api/wallets/wallets.d.ts +1 -1
- package/src/lib/data/api/wallets/wallets.js +6 -3
- package/src/lib/events/embeddedWallet.d.ts +2 -1
- package/src/lib/locale/en/translation.cjs +2 -2
- package/src/lib/locale/en/translation.d.ts +1 -1
- package/src/lib/locale/en/translation.js +2 -2
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +1 -1
- package/src/lib/shared/types/localStorage.d.ts +0 -13
- package/src/lib/store/actions/networkConfigurationsActions/index.d.ts +1 -0
- package/src/lib/store/actions/networkConfigurationsActions/networkConfigurationsActions.cjs +10 -0
- package/src/lib/store/actions/networkConfigurationsActions/networkConfigurationsActions.d.ts +7 -0
- package/src/lib/store/actions/networkConfigurationsActions/networkConfigurationsActions.js +6 -0
- package/src/lib/store/hooks/useNetworkConfigurations/index.d.ts +1 -0
- package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.cjs +139 -0
- package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.d.ts +12 -0
- package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.js +135 -0
- package/src/lib/store/index.d.ts +3 -1
- package/src/lib/store/store.cjs +1 -0
- package/src/lib/store/store.js +1 -0
- package/src/lib/store/types.d.ts +6 -1
- package/src/lib/store/utils/clearExpiredData/clearExpiredData.cjs +4 -1
- package/src/lib/store/utils/clearExpiredData/clearExpiredData.js +4 -1
- package/src/lib/utils/constants/localStorage.cjs +0 -2
- package/src/lib/utils/constants/localStorage.js +1 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +12 -15
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +12 -15
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +3 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +11 -10
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +11 -10
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +5 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +5 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +1 -1
- package/src/lib/utils/hooks/useInitEmbeddedWalletAuthMethod/useInitEmbeddedWalletAuthMethod.cjs +2 -6
- package/src/lib/utils/hooks/useInitEmbeddedWalletAuthMethod/useInitEmbeddedWalletAuthMethod.js +2 -6
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +1 -4
- package/src/lib/utils/hooks/useMfa/useMfa.js +1 -4
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +29 -21
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +29 -21
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +1 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +1 -1
- package/src/lib/utils/hooks/useSocialAuth/farcaster.cjs +13 -4
- package/src/lib/utils/hooks/useSocialAuth/farcaster.d.ts +2 -0
- package/src/lib/utils/hooks/useSocialAuth/farcaster.js +13 -4
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +4 -4
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +7 -6
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +5 -5
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +3 -5
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +3 -5
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +4 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +5 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +2 -2
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +2 -2
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.cjs +5 -4
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.js +5 -4
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +5 -6
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.d.ts +1 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +5 -6
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +8 -18
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.d.ts +4 -12
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +8 -18
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/index.d.ts +0 -1
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.cjs +0 -117
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.d.ts +0 -14
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.js +0 -113
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var store = require('../../store.cjs');
|
|
8
|
+
var useStoreWithSelector = require('../useStoreWithSelector/useStoreWithSelector.cjs');
|
|
9
|
+
require('react');
|
|
10
|
+
require('../../../events/dynamicEvents.cjs');
|
|
11
|
+
require('@dynamic-labs/utils');
|
|
12
|
+
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
13
|
+
require('@dynamic-labs/sdk-api-core');
|
|
14
|
+
require('../../../shared/logger.cjs');
|
|
15
|
+
require('@dynamic-labs/iconic');
|
|
16
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
17
|
+
require('react/jsx-runtime');
|
|
18
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
19
|
+
require('@dynamic-labs/wallet-book');
|
|
20
|
+
require('../../../utils/constants/colors.cjs');
|
|
21
|
+
require('../../../utils/constants/values.cjs');
|
|
22
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
23
|
+
require('../../../shared/consts/index.cjs');
|
|
24
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
25
|
+
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
26
|
+
require('@dynamic-labs/multi-wallet');
|
|
27
|
+
require('react-international-phone');
|
|
28
|
+
require('viem');
|
|
29
|
+
require('viem/chains');
|
|
30
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
31
|
+
require('../../../locale/locale.cjs');
|
|
32
|
+
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
33
|
+
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
34
|
+
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
35
|
+
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
36
|
+
require('react-dom');
|
|
37
|
+
require('../../../context/WalletContext/WalletContext.cjs');
|
|
38
|
+
var usePromise = require('../../../utils/hooks/usePromise/usePromise.cjs');
|
|
39
|
+
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
40
|
+
require('../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
41
|
+
require('@dynamic-labs/types');
|
|
42
|
+
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
43
|
+
require('yup');
|
|
44
|
+
require('../../../context/MockContext/MockContext.cjs');
|
|
45
|
+
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
46
|
+
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
47
|
+
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
48
|
+
var networkConfigurationsActions = require('../../actions/networkConfigurationsActions/networkConfigurationsActions.cjs');
|
|
49
|
+
require('@dynamic-labs/rpc-providers');
|
|
50
|
+
require('react-i18next');
|
|
51
|
+
require('../../../components/Alert/Alert.cjs');
|
|
52
|
+
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
53
|
+
require('../../../components/IconButton/IconButton.cjs');
|
|
54
|
+
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
55
|
+
require('../../../components/Input/Input.cjs');
|
|
56
|
+
require('../../../components/IsBrowser/IsBrowser.cjs');
|
|
57
|
+
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
58
|
+
require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
59
|
+
require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
60
|
+
require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
61
|
+
require('../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
62
|
+
require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
63
|
+
require('../../../components/Popper/Popper/Popper.cjs');
|
|
64
|
+
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
65
|
+
require('react-focus-lock');
|
|
66
|
+
require('qrcode');
|
|
67
|
+
require('formik');
|
|
68
|
+
require('../../../views/WalletList/WalletList.cjs');
|
|
69
|
+
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
70
|
+
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
71
|
+
require('@hcaptcha/react-hcaptcha');
|
|
72
|
+
require('../../../context/FooterAnimationContext/index.cjs');
|
|
73
|
+
require('../../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.cjs');
|
|
74
|
+
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
75
|
+
require('../../../context/MfaSettingsContext/MfaSettingsContext.cjs');
|
|
76
|
+
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
77
|
+
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
78
|
+
require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
79
|
+
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
80
|
+
require('../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
81
|
+
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
82
|
+
|
|
83
|
+
const createNetwork = (network, parser = (input) => input) => ({
|
|
84
|
+
blockExplorerUrls: network.blockExplorerUrls,
|
|
85
|
+
chainId: parser(network.chainId),
|
|
86
|
+
iconUrls: network.iconUrls,
|
|
87
|
+
lcdUrl: network.lcdUrl,
|
|
88
|
+
name: network.name,
|
|
89
|
+
nativeCurrency: network.nativeCurrency,
|
|
90
|
+
networkId: parser(network.networkId),
|
|
91
|
+
privateCustomerRpcUrls: network.privateCustomerRpcUrls,
|
|
92
|
+
rpcUrls: network.rpcUrls,
|
|
93
|
+
vanityName: network.vanityName,
|
|
94
|
+
});
|
|
95
|
+
const useNetworkConfigurations = ({ environmentId, projectSettings, evmNetworksOverrides, }) => {
|
|
96
|
+
const storedNetworks = useStoreWithSelector.useStoreWithSelector(store.getStore(), ({ networkConfigurations }) => networkConfigurations);
|
|
97
|
+
const { isLoading } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
var _a, _b, _c, _d;
|
|
99
|
+
if (!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks))
|
|
100
|
+
return Promise.resolve({});
|
|
101
|
+
const { networks } = projectSettings;
|
|
102
|
+
const evm = networks.find((configurations) => configurations.chainName === 'evm');
|
|
103
|
+
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
104
|
+
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
105
|
+
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
106
|
+
const cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
107
|
+
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
108
|
+
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
109
|
+
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
110
|
+
if (evmNetworksOverrides) {
|
|
111
|
+
if (Array.isArray(evmNetworksOverrides))
|
|
112
|
+
evmNetworks = evmNetworksOverrides;
|
|
113
|
+
else
|
|
114
|
+
evmNetworks = evmNetworksOverrides(evmNetworks !== null && evmNetworks !== void 0 ? evmNetworks : []);
|
|
115
|
+
}
|
|
116
|
+
return Promise.resolve({
|
|
117
|
+
cosmos: cosmosNetworks,
|
|
118
|
+
evm: evmNetworks,
|
|
119
|
+
solana: solanaNetworks,
|
|
120
|
+
starknet: starknetNetworks,
|
|
121
|
+
});
|
|
122
|
+
}), {
|
|
123
|
+
deps: [environmentId, projectSettings, evmNetworksOverrides],
|
|
124
|
+
enabled: Boolean(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks),
|
|
125
|
+
onResolve: (networkConfigurations) => {
|
|
126
|
+
const expiry = new Date().getTime() + 60000 * 5;
|
|
127
|
+
networkConfigurationsActions.setNetworkConfigurations({
|
|
128
|
+
expiresAt: expiry,
|
|
129
|
+
networkConfigurations,
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
isLoading,
|
|
135
|
+
networkConfigurations: storedNetworks === null || storedNetworks === void 0 ? void 0 : storedNetworks.networkConfigurations,
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
exports.useNetworkConfigurations = useNetworkConfigurations;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ProjectSettings } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { NetworkConfigurationMap } from '@dynamic-labs/types';
|
|
3
|
+
import { EvmNetworksOverrides } from '../../../context/DynamicContext/types';
|
|
4
|
+
export type UseNetworkConfigurationsProps = {
|
|
5
|
+
environmentId: string;
|
|
6
|
+
projectSettings?: ProjectSettings;
|
|
7
|
+
evmNetworksOverrides?: EvmNetworksOverrides;
|
|
8
|
+
};
|
|
9
|
+
export declare const useNetworkConfigurations: ({ environmentId, projectSettings, evmNetworksOverrides, }: UseNetworkConfigurationsProps) => {
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
networkConfigurations: NetworkConfigurationMap | undefined;
|
|
12
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { getStore } from '../../store.js';
|
|
4
|
+
import { useStoreWithSelector } from '../useStoreWithSelector/useStoreWithSelector.js';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '../../../events/dynamicEvents.js';
|
|
7
|
+
import '@dynamic-labs/utils';
|
|
8
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
9
|
+
import '@dynamic-labs/sdk-api-core';
|
|
10
|
+
import '../../../shared/logger.js';
|
|
11
|
+
import '@dynamic-labs/iconic';
|
|
12
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
13
|
+
import 'react/jsx-runtime';
|
|
14
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
15
|
+
import '@dynamic-labs/wallet-book';
|
|
16
|
+
import '../../../utils/constants/colors.js';
|
|
17
|
+
import '../../../utils/constants/values.js';
|
|
18
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
19
|
+
import '../../../shared/consts/index.js';
|
|
20
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
21
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
22
|
+
import '@dynamic-labs/multi-wallet';
|
|
23
|
+
import 'react-international-phone';
|
|
24
|
+
import 'viem';
|
|
25
|
+
import 'viem/chains';
|
|
26
|
+
import '../../../config/ApiEndpoint.js';
|
|
27
|
+
import '../../../locale/locale.js';
|
|
28
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
29
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
30
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
31
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
32
|
+
import 'react-dom';
|
|
33
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
34
|
+
import { usePromise } from '../../../utils/hooks/usePromise/usePromise.js';
|
|
35
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
36
|
+
import '../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
37
|
+
import '@dynamic-labs/types';
|
|
38
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
39
|
+
import 'yup';
|
|
40
|
+
import '../../../context/MockContext/MockContext.js';
|
|
41
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
42
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
43
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
44
|
+
import { setNetworkConfigurations } from '../../actions/networkConfigurationsActions/networkConfigurationsActions.js';
|
|
45
|
+
import '@dynamic-labs/rpc-providers';
|
|
46
|
+
import 'react-i18next';
|
|
47
|
+
import '../../../components/Alert/Alert.js';
|
|
48
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
49
|
+
import '../../../components/IconButton/IconButton.js';
|
|
50
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
51
|
+
import '../../../components/Input/Input.js';
|
|
52
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
53
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
54
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
55
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
56
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
57
|
+
import '../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
58
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
59
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
60
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
61
|
+
import 'react-focus-lock';
|
|
62
|
+
import 'qrcode';
|
|
63
|
+
import 'formik';
|
|
64
|
+
import '../../../views/WalletList/WalletList.js';
|
|
65
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
66
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
67
|
+
import '@hcaptcha/react-hcaptcha';
|
|
68
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
69
|
+
import '../../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.js';
|
|
70
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
71
|
+
import '../../../context/MfaSettingsContext/MfaSettingsContext.js';
|
|
72
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
73
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
74
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
75
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
76
|
+
import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
77
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
78
|
+
|
|
79
|
+
const createNetwork = (network, parser = (input) => input) => ({
|
|
80
|
+
blockExplorerUrls: network.blockExplorerUrls,
|
|
81
|
+
chainId: parser(network.chainId),
|
|
82
|
+
iconUrls: network.iconUrls,
|
|
83
|
+
lcdUrl: network.lcdUrl,
|
|
84
|
+
name: network.name,
|
|
85
|
+
nativeCurrency: network.nativeCurrency,
|
|
86
|
+
networkId: parser(network.networkId),
|
|
87
|
+
privateCustomerRpcUrls: network.privateCustomerRpcUrls,
|
|
88
|
+
rpcUrls: network.rpcUrls,
|
|
89
|
+
vanityName: network.vanityName,
|
|
90
|
+
});
|
|
91
|
+
const useNetworkConfigurations = ({ environmentId, projectSettings, evmNetworksOverrides, }) => {
|
|
92
|
+
const storedNetworks = useStoreWithSelector(getStore(), ({ networkConfigurations }) => networkConfigurations);
|
|
93
|
+
const { isLoading } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
var _a, _b, _c, _d;
|
|
95
|
+
if (!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks))
|
|
96
|
+
return Promise.resolve({});
|
|
97
|
+
const { networks } = projectSettings;
|
|
98
|
+
const evm = networks.find((configurations) => configurations.chainName === 'evm');
|
|
99
|
+
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
100
|
+
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
101
|
+
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
102
|
+
const cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
103
|
+
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
104
|
+
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
105
|
+
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
106
|
+
if (evmNetworksOverrides) {
|
|
107
|
+
if (Array.isArray(evmNetworksOverrides))
|
|
108
|
+
evmNetworks = evmNetworksOverrides;
|
|
109
|
+
else
|
|
110
|
+
evmNetworks = evmNetworksOverrides(evmNetworks !== null && evmNetworks !== void 0 ? evmNetworks : []);
|
|
111
|
+
}
|
|
112
|
+
return Promise.resolve({
|
|
113
|
+
cosmos: cosmosNetworks,
|
|
114
|
+
evm: evmNetworks,
|
|
115
|
+
solana: solanaNetworks,
|
|
116
|
+
starknet: starknetNetworks,
|
|
117
|
+
});
|
|
118
|
+
}), {
|
|
119
|
+
deps: [environmentId, projectSettings, evmNetworksOverrides],
|
|
120
|
+
enabled: Boolean(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks),
|
|
121
|
+
onResolve: (networkConfigurations) => {
|
|
122
|
+
const expiry = new Date().getTime() + 60000 * 5;
|
|
123
|
+
setNetworkConfigurations({
|
|
124
|
+
expiresAt: expiry,
|
|
125
|
+
networkConfigurations,
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
isLoading,
|
|
131
|
+
networkConfigurations: storedNetworks === null || storedNetworks === void 0 ? void 0 : storedNetworks.networkConfigurations,
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export { useNetworkConfigurations };
|
package/src/lib/store/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from './actions/networkConfigurationsActions';
|
|
1
2
|
export * from './actions/projectSettingsActions';
|
|
2
3
|
export * from './actions/storeActions';
|
|
3
4
|
export * from './actions/userActions';
|
|
4
|
-
export * from './hooks/
|
|
5
|
+
export * from './hooks/useNetworkConfigurations';
|
|
5
6
|
export * from './hooks/useProjectSettings';
|
|
7
|
+
export * from './hooks/useUser';
|
|
6
8
|
export { initializeStore } from './store';
|
package/src/lib/store/store.cjs
CHANGED
|
@@ -30,6 +30,7 @@ const initializeStore = ({ storageSuffix, environmentId, }) => {
|
|
|
30
30
|
});
|
|
31
31
|
store = clearExpiredData.clearExpiredData(syncLegacyStorage.syncLegacyStorage(persist(store$1.createStore(() => ({
|
|
32
32
|
environmentId,
|
|
33
|
+
networkConfigurations: undefined,
|
|
33
34
|
projectSettings: undefined,
|
|
34
35
|
user: undefined,
|
|
35
36
|
})))));
|
package/src/lib/store/store.js
CHANGED
|
@@ -26,6 +26,7 @@ const initializeStore = ({ storageSuffix, environmentId, }) => {
|
|
|
26
26
|
});
|
|
27
27
|
store = clearExpiredData(syncLegacyStorage(persist(createStore(() => ({
|
|
28
28
|
environmentId,
|
|
29
|
+
networkConfigurations: undefined,
|
|
29
30
|
projectSettings: undefined,
|
|
30
31
|
user: undefined,
|
|
31
32
|
})))));
|
package/src/lib/store/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProjectSettings } from '@dynamic-labs/sdk-api-core';
|
|
2
|
-
import { UserProfile } from '@dynamic-labs/types';
|
|
2
|
+
import { NetworkConfigurationMap, UserProfile } from '@dynamic-labs/types';
|
|
3
3
|
export type SdkStoreProps = {
|
|
4
4
|
environmentId: string;
|
|
5
5
|
storageSuffix?: string;
|
|
@@ -8,8 +8,13 @@ export type SdkStore = {
|
|
|
8
8
|
environmentId: string | undefined;
|
|
9
9
|
user: UserProfile | undefined;
|
|
10
10
|
projectSettings: StoredProjectSettings | undefined;
|
|
11
|
+
networkConfigurations: StoredNetworkConfigurations | undefined;
|
|
11
12
|
};
|
|
12
13
|
export type StoredProjectSettings = {
|
|
13
14
|
expiresAt: number;
|
|
14
15
|
settings: ProjectSettings;
|
|
15
16
|
};
|
|
17
|
+
export type StoredNetworkConfigurations = {
|
|
18
|
+
expiresAt: number;
|
|
19
|
+
networkConfigurations: NetworkConfigurationMap;
|
|
20
|
+
};
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
const clearExpiredData = (store) => {
|
|
7
|
-
const { projectSettings } = store.getState();
|
|
7
|
+
const { projectSettings, networkConfigurations } = store.getState();
|
|
8
8
|
if (projectSettings && projectSettings.expiresAt < Date.now()) {
|
|
9
9
|
store.setState({ projectSettings: undefined });
|
|
10
10
|
}
|
|
11
|
+
if (networkConfigurations && networkConfigurations.expiresAt < Date.now()) {
|
|
12
|
+
store.setState({ networkConfigurations: undefined });
|
|
13
|
+
}
|
|
11
14
|
return store;
|
|
12
15
|
};
|
|
13
16
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
const clearExpiredData = (store) => {
|
|
3
|
-
const { projectSettings } = store.getState();
|
|
3
|
+
const { projectSettings, networkConfigurations } = store.getState();
|
|
4
4
|
if (projectSettings && projectSettings.expiresAt < Date.now()) {
|
|
5
5
|
store.setState({ projectSettings: undefined });
|
|
6
6
|
}
|
|
7
|
+
if (networkConfigurations && networkConfigurations.expiresAt < Date.now()) {
|
|
8
|
+
store.setState({ networkConfigurations: undefined });
|
|
9
|
+
}
|
|
7
10
|
return store;
|
|
8
11
|
};
|
|
9
12
|
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
const AUTH_TOKEN = 'dynamic_authentication_token';
|
|
7
7
|
const AUTH_MIN_TOKEN = 'dynamic_min_authentication_token';
|
|
8
8
|
const LAST_USED_WALLET = 'dynamic_last_used_wallet';
|
|
9
|
-
const NETWORKS_STORAGE_KEY = 'dynamic_networks';
|
|
10
9
|
const NONCE_STORAGE_KEY = 'dynamic_nonce';
|
|
11
10
|
const PRIMARY_WALLET_ID = 'dynamic_primary_wallet_id';
|
|
12
11
|
const PROJECT_SETTINGS_STORAGE_KEY = 'dynamic_project_settings';
|
|
@@ -37,7 +36,6 @@ exports.DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS = DYNAMIC_CONTEXT_LAST_SESSION_SET
|
|
|
37
36
|
exports.EMBEDDED_WALLET_SECURE_BANNER = EMBEDDED_WALLET_SECURE_BANNER;
|
|
38
37
|
exports.EMBEDDED_WALLET_SESSION_SETTINGS = EMBEDDED_WALLET_SESSION_SETTINGS;
|
|
39
38
|
exports.LAST_USED_WALLET = LAST_USED_WALLET;
|
|
40
|
-
exports.NETWORKS_STORAGE_KEY = NETWORKS_STORAGE_KEY;
|
|
41
39
|
exports.NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY = NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY;
|
|
42
40
|
exports.NONCE_STORAGE_KEY = NONCE_STORAGE_KEY;
|
|
43
41
|
exports.PHANTOM_SIGNATURE_STATE = PHANTOM_SIGNATURE_STATE;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
const AUTH_TOKEN = 'dynamic_authentication_token';
|
|
3
3
|
const AUTH_MIN_TOKEN = 'dynamic_min_authentication_token';
|
|
4
4
|
const LAST_USED_WALLET = 'dynamic_last_used_wallet';
|
|
5
|
-
const NETWORKS_STORAGE_KEY = 'dynamic_networks';
|
|
6
5
|
const NONCE_STORAGE_KEY = 'dynamic_nonce';
|
|
7
6
|
const PRIMARY_WALLET_ID = 'dynamic_primary_wallet_id';
|
|
8
7
|
const PROJECT_SETTINGS_STORAGE_KEY = 'dynamic_project_settings';
|
|
@@ -23,4 +22,4 @@ const PHONE_INPUT_DEFAULT_COUNTRY = 'dynamic_phone_input_default_country';
|
|
|
23
22
|
const PHANTOM_SIGNATURE_STATE = 'phantom_verification_type';
|
|
24
23
|
const STORE_STORAGE_KEY = 'dynamic_store';
|
|
25
24
|
|
|
26
|
-
export { AUTH_MIN_TOKEN, AUTH_MODE, AUTH_TOKEN, BRIDGE_ONBOARDING_COMPLETED, CONNECTED_WALLETS_INFO, CONNECTED_WALLET_NAME_SERVICE, DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, EMBEDDED_WALLET_SECURE_BANNER, EMBEDDED_WALLET_SESSION_SETTINGS, LAST_USED_WALLET,
|
|
25
|
+
export { AUTH_MIN_TOKEN, AUTH_MODE, AUTH_TOKEN, BRIDGE_ONBOARDING_COMPLETED, CONNECTED_WALLETS_INFO, CONNECTED_WALLET_NAME_SERVICE, DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, EMBEDDED_WALLET_SECURE_BANNER, EMBEDDED_WALLET_SESSION_SETTINGS, LAST_USED_WALLET, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, NONCE_STORAGE_KEY, PHANTOM_SIGNATURE_STATE, PHONE_INPUT_DEFAULT_COUNTRY, PRIMARY_WALLET_ID, PROJECT_SETTINGS_STORAGE_KEY, STORE_STORAGE_KEY, WAGMI_LAST_SESSION_SETTINGS, WALLET_PICKER_SEARCH_KEY };
|
|
@@ -23,13 +23,13 @@ require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
|
23
23
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
24
|
var errors = require('../../constants/errors.cjs');
|
|
25
25
|
require('@dynamic-labs/multi-wallet');
|
|
26
|
+
var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
|
|
26
27
|
require('react-international-phone');
|
|
27
28
|
require('viem');
|
|
28
29
|
require('viem/chains');
|
|
29
30
|
require('../../../config/ApiEndpoint.cjs');
|
|
30
31
|
require('@dynamic-labs/store');
|
|
31
32
|
require('../../../locale/locale.cjs');
|
|
32
|
-
var updateJWTAndCreateUserProfile = require('../../functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.cjs');
|
|
33
33
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
34
34
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
35
35
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -87,7 +87,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
87
87
|
// This hook needs to be async that's why it's not using useMutation
|
|
88
88
|
const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
89
89
|
var _a, _b;
|
|
90
|
-
const { setPrimaryWalletId,
|
|
90
|
+
const { setPrimaryWalletId, user, setShowAuthFlow, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
91
91
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
92
92
|
const [error, setError] = React.useState();
|
|
93
93
|
const embeddedChainConfig = ((_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.chainConfigurations) || [];
|
|
@@ -102,7 +102,7 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
102
102
|
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
103
103
|
}
|
|
104
104
|
try {
|
|
105
|
-
const { embeddedWalletVerifiedCredential,
|
|
105
|
+
const { embeddedWalletVerifiedCredential, updatedUser, walletConnector, } = yield createEmbeddedWalletRequest.createEmbeddedWalletRequest({
|
|
106
106
|
chains: chains !== null && chains !== void 0 ? chains : embeddedChains,
|
|
107
107
|
environmentId,
|
|
108
108
|
user,
|
|
@@ -110,8 +110,7 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
110
110
|
webAuthnAttestation: options === null || options === void 0 ? void 0 : options.webAuthnAttestation,
|
|
111
111
|
withAuthenticator,
|
|
112
112
|
});
|
|
113
|
-
const
|
|
114
|
-
const turnkeyVerifiedCredentials = (_d = userFromResponse.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'));
|
|
113
|
+
const turnkeyVerifiedCredentials = (_d = updatedUser.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'));
|
|
115
114
|
/** It's not authenticated if it's a turnkey wallet that still hasn't created a passkey */
|
|
116
115
|
const authenticated = Boolean((_e = turnkeyVerifiedCredentials === null || turnkeyVerifiedCredentials === void 0 ? void 0 : turnkeyVerifiedCredentials.walletProperties) === null || _e === void 0 ? void 0 : _e.isAuthenticatorAttached);
|
|
117
116
|
const passkeyWallet = {
|
|
@@ -122,25 +121,24 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
122
121
|
connector: walletConnector,
|
|
123
122
|
id: embeddedWalletVerifiedCredential.id,
|
|
124
123
|
};
|
|
125
|
-
const smartWallet$1 = smartWallet.findSmartWallet(embeddedWalletVerifiedCredential,
|
|
126
|
-
if (smartWallet$1) {
|
|
124
|
+
const smartWallet$1 = smartWallet.findSmartWallet(embeddedWalletVerifiedCredential, updatedUser.verifiedCredentials);
|
|
125
|
+
if (!smartWallet$1) {
|
|
126
|
+
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
127
129
|
yield smartWallet.initializeSmartWallet({
|
|
128
130
|
account: smartWallet$1,
|
|
129
|
-
verifiedCredentials:
|
|
131
|
+
verifiedCredentials: updatedUser.verifiedCredentials,
|
|
130
132
|
walletConnectorOptions,
|
|
131
133
|
});
|
|
132
134
|
setPrimaryWalletId(smartWallet$1.id);
|
|
133
135
|
}
|
|
134
|
-
|
|
135
|
-
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
136
|
-
}
|
|
137
|
-
setUser(updateJWTAndCreateUserProfile.updateJWTAndCreateUserProfile(signersResponse.jwt, signersResponse.minifiedJwt));
|
|
136
|
+
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', passkeyWallet, turnkeyVerifiedCredentials, getAuthToken.getAuthToken(), updatedUser);
|
|
138
137
|
setShowAuthFlow(false, { performMultiWalletChecks: false });
|
|
139
|
-
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', passkeyWallet, turnkeyVerifiedCredentials, signersResponse.jwt);
|
|
140
138
|
}
|
|
141
139
|
catch (err) {
|
|
142
|
-
setError(err);
|
|
143
140
|
logger.logger.error('Failed to create embedded wallet', err);
|
|
141
|
+
setError(err);
|
|
144
142
|
dynamicEvents.dynamicEvents.emit('embeddedWalletFailed', err);
|
|
145
143
|
}
|
|
146
144
|
finally {
|
|
@@ -151,7 +149,6 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
151
149
|
primaryEmbeddedChain,
|
|
152
150
|
setPrimaryWalletId,
|
|
153
151
|
setShowAuthFlow,
|
|
154
|
-
setUser,
|
|
155
152
|
user,
|
|
156
153
|
]);
|
|
157
154
|
return {
|
|
@@ -19,13 +19,13 @@ import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
|
19
19
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
20
|
import { USER_NOT_LOGGED_IN } from '../../constants/errors.js';
|
|
21
21
|
import '@dynamic-labs/multi-wallet';
|
|
22
|
+
import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
22
23
|
import 'react-international-phone';
|
|
23
24
|
import 'viem';
|
|
24
25
|
import 'viem/chains';
|
|
25
26
|
import '../../../config/ApiEndpoint.js';
|
|
26
27
|
import '@dynamic-labs/store';
|
|
27
28
|
import '../../../locale/locale.js';
|
|
28
|
-
import { updateJWTAndCreateUserProfile } from '../../functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.js';
|
|
29
29
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
30
30
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
31
31
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -83,7 +83,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
83
83
|
// This hook needs to be async that's why it's not using useMutation
|
|
84
84
|
const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
85
85
|
var _a, _b;
|
|
86
|
-
const { setPrimaryWalletId,
|
|
86
|
+
const { setPrimaryWalletId, user, setShowAuthFlow, projectSettings } = useInternalDynamicContext();
|
|
87
87
|
const [isLoading, setIsLoading] = useState(false);
|
|
88
88
|
const [error, setError] = useState();
|
|
89
89
|
const embeddedChainConfig = ((_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.chainConfigurations) || [];
|
|
@@ -98,7 +98,7 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
98
98
|
throw new DynamicError(USER_NOT_LOGGED_IN);
|
|
99
99
|
}
|
|
100
100
|
try {
|
|
101
|
-
const { embeddedWalletVerifiedCredential,
|
|
101
|
+
const { embeddedWalletVerifiedCredential, updatedUser, walletConnector, } = yield createEmbeddedWalletRequest({
|
|
102
102
|
chains: chains !== null && chains !== void 0 ? chains : embeddedChains,
|
|
103
103
|
environmentId,
|
|
104
104
|
user,
|
|
@@ -106,8 +106,7 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
106
106
|
webAuthnAttestation: options === null || options === void 0 ? void 0 : options.webAuthnAttestation,
|
|
107
107
|
withAuthenticator,
|
|
108
108
|
});
|
|
109
|
-
const
|
|
110
|
-
const turnkeyVerifiedCredentials = (_d = userFromResponse.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'));
|
|
109
|
+
const turnkeyVerifiedCredentials = (_d = updatedUser.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'));
|
|
111
110
|
/** It's not authenticated if it's a turnkey wallet that still hasn't created a passkey */
|
|
112
111
|
const authenticated = Boolean((_e = turnkeyVerifiedCredentials === null || turnkeyVerifiedCredentials === void 0 ? void 0 : turnkeyVerifiedCredentials.walletProperties) === null || _e === void 0 ? void 0 : _e.isAuthenticatorAttached);
|
|
113
112
|
const passkeyWallet = {
|
|
@@ -118,25 +117,24 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
118
117
|
connector: walletConnector,
|
|
119
118
|
id: embeddedWalletVerifiedCredential.id,
|
|
120
119
|
};
|
|
121
|
-
const smartWallet = findSmartWallet(embeddedWalletVerifiedCredential,
|
|
122
|
-
if (smartWallet) {
|
|
120
|
+
const smartWallet = findSmartWallet(embeddedWalletVerifiedCredential, updatedUser.verifiedCredentials);
|
|
121
|
+
if (!smartWallet) {
|
|
122
|
+
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
123
125
|
yield initializeSmartWallet({
|
|
124
126
|
account: smartWallet,
|
|
125
|
-
verifiedCredentials:
|
|
127
|
+
verifiedCredentials: updatedUser.verifiedCredentials,
|
|
126
128
|
walletConnectorOptions,
|
|
127
129
|
});
|
|
128
130
|
setPrimaryWalletId(smartWallet.id);
|
|
129
131
|
}
|
|
130
|
-
|
|
131
|
-
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
132
|
-
}
|
|
133
|
-
setUser(updateJWTAndCreateUserProfile(signersResponse.jwt, signersResponse.minifiedJwt));
|
|
132
|
+
dynamicEvents.emit('embeddedWalletCreated', passkeyWallet, turnkeyVerifiedCredentials, getAuthToken(), updatedUser);
|
|
134
133
|
setShowAuthFlow(false, { performMultiWalletChecks: false });
|
|
135
|
-
dynamicEvents.emit('embeddedWalletCreated', passkeyWallet, turnkeyVerifiedCredentials, signersResponse.jwt);
|
|
136
134
|
}
|
|
137
135
|
catch (err) {
|
|
138
|
-
setError(err);
|
|
139
136
|
logger.error('Failed to create embedded wallet', err);
|
|
137
|
+
setError(err);
|
|
140
138
|
dynamicEvents.emit('embeddedWalletFailed', err);
|
|
141
139
|
}
|
|
142
140
|
finally {
|
|
@@ -147,7 +145,6 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
147
145
|
primaryEmbeddedChain,
|
|
148
146
|
setPrimaryWalletId,
|
|
149
147
|
setShowAuthFlow,
|
|
150
|
-
setUser,
|
|
151
148
|
user,
|
|
152
149
|
]);
|
|
153
150
|
return {
|
|
@@ -92,10 +92,10 @@ const useEmbeddedReveal = () => {
|
|
|
92
92
|
const turnkeyChecks = ({ user, recoveryPhrase, }) => {
|
|
93
93
|
var _a, _b;
|
|
94
94
|
if (!isTurnkeyEnabled.isTurnkeyEnabled(projectSettings)) {
|
|
95
|
-
throw new Error('
|
|
95
|
+
throw new Error('Dynamic embedded wallet is not enabled. Go to the dashboard and make sure to have both Dynamic Embedded wallet and at least one EVM network enabled. Also, check if EthereumWalletConnectors is in the DynamicContextProvider > settings > walletConnectors.');
|
|
96
96
|
}
|
|
97
97
|
if (!userHasEmbeddedWallet()) {
|
|
98
|
-
throw new Error('
|
|
98
|
+
throw new Error('Dynamic embedded wallet not found');
|
|
99
99
|
}
|
|
100
100
|
const walletProperties = (_b = (_a = user.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;
|
|
101
101
|
const turnkeyHDWalletId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
@@ -125,7 +125,7 @@ const useEmbeddedReveal = () => {
|
|
|
125
125
|
coinbaseMpcChecks();
|
|
126
126
|
}
|
|
127
127
|
if (!userHasEmbeddedWallet()) {
|
|
128
|
-
throw new Error('
|
|
128
|
+
throw new Error('Dynamic embedded wallet not found');
|
|
129
129
|
}
|
|
130
130
|
setShowAuthFlow(true, {
|
|
131
131
|
ignoreIfIsEmbeddedWidget: false,
|
|
@@ -88,10 +88,10 @@ const useEmbeddedReveal = () => {
|
|
|
88
88
|
const turnkeyChecks = ({ user, recoveryPhrase, }) => {
|
|
89
89
|
var _a, _b;
|
|
90
90
|
if (!isTurnkeyEnabled(projectSettings)) {
|
|
91
|
-
throw new Error('
|
|
91
|
+
throw new Error('Dynamic embedded wallet is not enabled. Go to the dashboard and make sure to have both Dynamic Embedded wallet and at least one EVM network enabled. Also, check if EthereumWalletConnectors is in the DynamicContextProvider > settings > walletConnectors.');
|
|
92
92
|
}
|
|
93
93
|
if (!userHasEmbeddedWallet()) {
|
|
94
|
-
throw new Error('
|
|
94
|
+
throw new Error('Dynamic embedded wallet not found');
|
|
95
95
|
}
|
|
96
96
|
const walletProperties = (_b = (_a = user.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;
|
|
97
97
|
const turnkeyHDWalletId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
@@ -121,7 +121,7 @@ const useEmbeddedReveal = () => {
|
|
|
121
121
|
coinbaseMpcChecks();
|
|
122
122
|
}
|
|
123
123
|
if (!userHasEmbeddedWallet()) {
|
|
124
|
-
throw new Error('
|
|
124
|
+
throw new Error('Dynamic embedded wallet not found');
|
|
125
125
|
}
|
|
126
126
|
setShowAuthFlow(true, {
|
|
127
127
|
ignoreIfIsEmbeddedWidget: false,
|