@dynamic-labs/sdk-react-core 4.8.2 → 4.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -0
- package/src/lib/components/ShadowDOM/utils.cjs +1 -0
- package/src/lib/components/ShadowDOM/utils.js +1 -0
- package/src/lib/components/SyncAuthFlow/SyncAuthFlow.cjs +2 -0
- package/src/lib/components/SyncAuthFlow/SyncAuthFlow.js +2 -0
- package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.cjs +1 -1
- package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.js +2 -2
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +0 -4
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +0 -4
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +2 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +2 -0
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +1 -0
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +1 -0
- package/src/lib/locale/en/translation.cjs +2 -1
- package/src/lib/locale/en/translation.d.ts +2 -1
- package/src/lib/locale/en/translation.js +2 -1
- package/src/lib/shared/utils/functions/getInitialUrl/getInitialUrl.cjs +1 -0
- package/src/lib/shared/utils/functions/getInitialUrl/getInitialUrl.js +1 -0
- package/src/lib/store/state/dynamicContextProps/dynamicContextProps.cjs +2 -0
- package/src/lib/store/state/dynamicContextProps/dynamicContextProps.d.ts +2 -0
- package/src/lib/store/state/dynamicContextProps/dynamicContextProps.js +2 -1
- package/src/lib/utils/functions/coinbaseOnramp/formatCoinbaseOnrampUrl.cjs +2 -2
- package/src/lib/utils/functions/coinbaseOnramp/formatCoinbaseOnrampUrl.js +2 -2
- package/src/lib/utils/functions/generateMessages/index.cjs +3 -2
- package/src/lib/utils/functions/generateMessages/index.js +4 -3
- package/src/lib/utils/functions/getAppOrigin/getAppOrigin.cjs +1 -0
- package/src/lib/utils/functions/getAppOrigin/getAppOrigin.js +1 -0
- package/src/lib/utils/functions/isProgrammableNetworkSwitchSupported/isProgrammableNetworkSwitchSupported.cjs +1 -0
- package/src/lib/utils/functions/isProgrammableNetworkSwitchSupported/isProgrammableNetworkSwitchSupported.js +1 -0
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.cjs +10 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.d.ts +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.js +5 -0
- package/src/lib/utils/hooks/useDynamicWaas/index.d.ts +1 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +220 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +21 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +215 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +9 -5
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +10 -6
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +14 -1
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +15 -2
- package/src/lib/utils/hooks/useSyncDynamicWaas/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +145 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.d.ts +1 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +141 -0
- package/src/lib/views/UserDeleteAccountView/UserDeleteAccountView.cjs +6 -3
- package/src/lib/views/UserDeleteAccountView/UserDeleteAccountView.js +6 -3
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +1 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
9
|
+
var utils = require('@dynamic-labs/utils');
|
|
10
|
+
require('../../constants/values.cjs');
|
|
11
|
+
require('@dynamic-labs/multi-wallet');
|
|
12
|
+
var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
|
|
13
|
+
require('../../../shared/logger.cjs');
|
|
14
|
+
require('../../constants/colors.cjs');
|
|
15
|
+
require('react-international-phone');
|
|
16
|
+
require('@dynamic-labs/iconic');
|
|
17
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
18
|
+
require('react/jsx-runtime');
|
|
19
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
20
|
+
require('@dynamic-labs/wallet-book');
|
|
21
|
+
require('../../../shared/consts/index.cjs');
|
|
22
|
+
require('../../../store/state/nonce/nonce.cjs');
|
|
23
|
+
var isCookieEnabled = require('../../functions/isCookieEnabled/isCookieEnabled.cjs');
|
|
24
|
+
var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
25
|
+
var updatePrimaryWalletId = require('../../functions/updatePrimaryWalletId/updatePrimaryWalletId.cjs');
|
|
26
|
+
var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
|
|
27
|
+
var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
28
|
+
var user = require('../../../store/state/user/user.cjs');
|
|
29
|
+
var walletOptions = require('../../../store/state/walletOptions/walletOptions.cjs');
|
|
30
|
+
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
31
|
+
require('../../../events/dynamicEvents.cjs');
|
|
32
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
33
|
+
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
34
|
+
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
35
|
+
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
36
|
+
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
37
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
38
|
+
require('../../../locale/locale.cjs');
|
|
39
|
+
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
40
|
+
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
41
|
+
require('react-dom');
|
|
42
|
+
require('../../functions/compareChains/compareChains.cjs');
|
|
43
|
+
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
44
|
+
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
45
|
+
require('bs58');
|
|
46
|
+
require('@dynamic-labs/types');
|
|
47
|
+
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
48
|
+
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
49
|
+
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
50
|
+
require('../../../context/WalletContext/WalletContext.cjs');
|
|
51
|
+
require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
52
|
+
require('yup');
|
|
53
|
+
require('../../../context/MockContext/MockContext.cjs');
|
|
54
|
+
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
55
|
+
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
56
|
+
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
57
|
+
require('@dynamic-labs/rpc-providers');
|
|
58
|
+
require('../../../store/state/loadingAndLifecycle.cjs');
|
|
59
|
+
require('react-i18next');
|
|
60
|
+
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
61
|
+
require('../../../components/Alert/Alert.cjs');
|
|
62
|
+
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
63
|
+
require('../../../components/IconButton/IconButton.cjs');
|
|
64
|
+
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
65
|
+
require('../../../components/Input/Input.cjs');
|
|
66
|
+
require('../../../components/IsBrowser/IsBrowser.cjs');
|
|
67
|
+
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
68
|
+
require('../../../components/OverlayCard/OverlayCard.cjs');
|
|
69
|
+
require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
70
|
+
require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
71
|
+
require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
72
|
+
require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
73
|
+
require('../../../components/Popper/Popper/Popper.cjs');
|
|
74
|
+
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
75
|
+
require('react-focus-lock');
|
|
76
|
+
require('qrcode');
|
|
77
|
+
require('formik');
|
|
78
|
+
require('../useSubdomainCheck/useSubdomainCheck.cjs');
|
|
79
|
+
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
80
|
+
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
81
|
+
require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
82
|
+
require('../../../context/ConnectWithOtpContext/constants.cjs');
|
|
83
|
+
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
84
|
+
require('@hcaptcha/react-hcaptcha');
|
|
85
|
+
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
86
|
+
require('../../../context/FooterAnimationContext/index.cjs');
|
|
87
|
+
require('../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
88
|
+
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
89
|
+
require('../../../store/state/sendBalances.cjs');
|
|
90
|
+
require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
91
|
+
require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
92
|
+
require('../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
93
|
+
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
94
|
+
require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
95
|
+
require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
96
|
+
require('../../../../index.cjs');
|
|
97
|
+
var constants = require('./constants.cjs');
|
|
98
|
+
require('../../../store/state/tokenBalances.cjs');
|
|
99
|
+
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
100
|
+
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
101
|
+
|
|
102
|
+
const dynamicWaasKey = 'dynamicwaas';
|
|
103
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, }) => {
|
|
104
|
+
walletConnector.setEnvironmentId(environmentId);
|
|
105
|
+
walletConnector.setBaseApiUrl(apiBaseUrl === null || apiBaseUrl === void 0 ? void 0 : apiBaseUrl.replace('/api/v0', ''));
|
|
106
|
+
walletConnector.setGetAuthTokenFunction(() => authToken !== null && authToken !== void 0 ? authToken : '');
|
|
107
|
+
return walletConnector;
|
|
108
|
+
};
|
|
109
|
+
const useDynamicWaas = () => {
|
|
110
|
+
var _a;
|
|
111
|
+
const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
112
|
+
const { user: user$1 } = user.useUser();
|
|
113
|
+
const apiBaseUrl = dynamicContextProps.useApiBaseUrl();
|
|
114
|
+
const projectSettings$1 = projectSettings.useProjectSettings();
|
|
115
|
+
const environmentId = dynamicContextProps.useEnvironmentId();
|
|
116
|
+
const walletConnectorOptions = walletOptions.useWalletConnectorOptions();
|
|
117
|
+
const refresh = useRefreshUser.useRefreshUser();
|
|
118
|
+
const embeddedWalletSettings = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk.embeddedWallets;
|
|
119
|
+
const enabledChains = (_a = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _a === void 0 ? void 0 : _a.filter((c) => c.enabled);
|
|
120
|
+
const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
|
|
121
|
+
const enabledChainNames = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.map((chain) => chain.name);
|
|
122
|
+
const automaticEmbeddedWalletCreationEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreation;
|
|
123
|
+
const automaticEmbeddedWalletCreationForExternalEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreationForExternal;
|
|
124
|
+
const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
|
|
125
|
+
const dynamicWaasIsEnabled = defaultWalletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V3;
|
|
126
|
+
const authToken = getAuthToken.getAuthToken();
|
|
127
|
+
const isCookieAuthEnabled = projectSettings$1 && isCookieEnabled.isCookieEnabled(projectSettings$1);
|
|
128
|
+
const getWalletConnector = React.useCallback((chainName) => {
|
|
129
|
+
var _a;
|
|
130
|
+
if (!isCookieAuthEnabled && !authToken) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
if (!walletConnectorOptions.length || !environmentId || !apiBaseUrl)
|
|
134
|
+
return undefined;
|
|
135
|
+
const connectorKey = chainName === 'EVM' ? dynamicWaasKey : `${dynamicWaasKey}-svm`;
|
|
136
|
+
const walletConnector = (_a = walletConnectorOptions.find((option) => option.key.includes(connectorKey))) === null || _a === void 0 ? void 0 : _a.walletConnector;
|
|
137
|
+
if (!walletConnector) {
|
|
138
|
+
throw new utils.DynamicError(constants.DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR);
|
|
139
|
+
}
|
|
140
|
+
const configuredWalletConnector = configWaasWalletConnector({
|
|
141
|
+
apiBaseUrl,
|
|
142
|
+
authToken,
|
|
143
|
+
environmentId,
|
|
144
|
+
walletConnector,
|
|
145
|
+
});
|
|
146
|
+
return configuredWalletConnector;
|
|
147
|
+
}, [
|
|
148
|
+
walletConnectorOptions,
|
|
149
|
+
environmentId,
|
|
150
|
+
authToken,
|
|
151
|
+
apiBaseUrl,
|
|
152
|
+
isCookieAuthEnabled,
|
|
153
|
+
]);
|
|
154
|
+
const createWalletAccount = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
|
|
156
|
+
throw new utils.DynamicError(constants.NO_ENABLED_CHAINS_ERROR);
|
|
157
|
+
}
|
|
158
|
+
const createdWalletAccounts = yield Promise.all(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.map((chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
159
|
+
const walletConnector = getWalletConnector(chain);
|
|
160
|
+
if (!walletConnector)
|
|
161
|
+
return undefined;
|
|
162
|
+
const createdWalletAccount = yield walletConnector.createWalletAccount();
|
|
163
|
+
return Object.assign(Object.assign({}, createdWalletAccount), { chainName: chain });
|
|
164
|
+
})));
|
|
165
|
+
const primaryWalletAccount = createdWalletAccounts === null || createdWalletAccounts === void 0 ? void 0 : createdWalletAccounts.find((wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.chainName) === (primaryChain === null || primaryChain === void 0 ? void 0 : primaryChain.name));
|
|
166
|
+
const refreshedUser = yield refresh();
|
|
167
|
+
const createdPrimaryWallet = refreshedUser === null || refreshedUser === void 0 ? void 0 : refreshedUser.verifiedCredentials.find((wallet) => {
|
|
168
|
+
var _a, _b, _c;
|
|
169
|
+
return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes(dynamicWaasKey)) &&
|
|
170
|
+
((_b = wallet.address) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
|
|
171
|
+
((_c = primaryWalletAccount === null || primaryWalletAccount === void 0 ? void 0 : primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
|
|
172
|
+
});
|
|
173
|
+
if (createdPrimaryWallet) {
|
|
174
|
+
updatePrimaryWalletId.updatePrimaryWalletId(createdPrimaryWallet.id);
|
|
175
|
+
}
|
|
176
|
+
setShowAuthFlow(false, { performMultiWalletChecks: false }); // close email otp pin modal
|
|
177
|
+
return createdWalletAccounts;
|
|
178
|
+
}), [getWalletConnector, primaryChain, enabledChainNames, refresh]);
|
|
179
|
+
const shouldAutoCreateDynamicWaasWallet = React.useMemo(() => {
|
|
180
|
+
const hasDynamicWaasWallet = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((wallet) => { var _a; return (_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes('dynamicwaas'); });
|
|
181
|
+
if (!user$1 ||
|
|
182
|
+
hasDynamicWaasWallet || // already has a dynamic waas wallet
|
|
183
|
+
!dynamicWaasIsEnabled || // dynamic waas is not enabled
|
|
184
|
+
!automaticEmbeddedWalletCreationEnabled // automatic embedded wallet creation is not enabled
|
|
185
|
+
)
|
|
186
|
+
return false;
|
|
187
|
+
const hasExternalWallet = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((vc) => vc.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Blockchain &&
|
|
188
|
+
vc.walletProvider !== sdkApiCore.WalletProviderEnum.EmbeddedWallet);
|
|
189
|
+
const shouldCreateDynamicWaasWallet = hasExternalWallet
|
|
190
|
+
? automaticEmbeddedWalletCreationForExternalEnabled
|
|
191
|
+
: true;
|
|
192
|
+
return shouldCreateDynamicWaasWallet;
|
|
193
|
+
}, [
|
|
194
|
+
user$1,
|
|
195
|
+
dynamicWaasIsEnabled,
|
|
196
|
+
automaticEmbeddedWalletCreationEnabled,
|
|
197
|
+
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
198
|
+
walletConnectorOptions,
|
|
199
|
+
]);
|
|
200
|
+
const importPrivateKey = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ chainName, privateKey, }) {
|
|
201
|
+
const walletConnector = getWalletConnector(chainName);
|
|
202
|
+
if (!walletConnector)
|
|
203
|
+
return;
|
|
204
|
+
yield walletConnector.importPrivateKey({
|
|
205
|
+
chainName,
|
|
206
|
+
privateKey,
|
|
207
|
+
});
|
|
208
|
+
yield refresh();
|
|
209
|
+
});
|
|
210
|
+
return {
|
|
211
|
+
createWalletAccount,
|
|
212
|
+
dynamicWaasIsEnabled,
|
|
213
|
+
getWalletConnector,
|
|
214
|
+
importPrivateKey,
|
|
215
|
+
shouldAutoCreateDynamicWaasWallet,
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
exports.configWaasWalletConnector = configWaasWalletConnector;
|
|
220
|
+
exports.useDynamicWaas = useDynamicWaas;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, authToken, }: {
|
|
3
|
+
walletConnector: IDynamicWaasConnector;
|
|
4
|
+
environmentId: string;
|
|
5
|
+
apiBaseUrl: string;
|
|
6
|
+
authToken: string | undefined;
|
|
7
|
+
}) => IDynamicWaasConnector;
|
|
8
|
+
export declare const useDynamicWaas: () => {
|
|
9
|
+
createWalletAccount: () => Promise<({
|
|
10
|
+
chainName: string;
|
|
11
|
+
accountAddress: string;
|
|
12
|
+
publicKeyHex: string;
|
|
13
|
+
} | undefined)[]>;
|
|
14
|
+
dynamicWaasIsEnabled: boolean;
|
|
15
|
+
getWalletConnector: (chainName: string) => IDynamicWaasConnector | undefined;
|
|
16
|
+
importPrivateKey: ({ chainName, privateKey, }: {
|
|
17
|
+
chainName: string;
|
|
18
|
+
privateKey: string;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
shouldAutoCreateDynamicWaasWallet: boolean | undefined;
|
|
21
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useCallback, useMemo } from 'react';
|
|
4
|
+
import { EmbeddedWalletVersionEnum, JwtVerifiedCredentialFormatEnum, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
|
+
import '../../constants/values.js';
|
|
7
|
+
import '@dynamic-labs/multi-wallet';
|
|
8
|
+
import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
9
|
+
import '../../../shared/logger.js';
|
|
10
|
+
import '../../constants/colors.js';
|
|
11
|
+
import 'react-international-phone';
|
|
12
|
+
import '@dynamic-labs/iconic';
|
|
13
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
14
|
+
import 'react/jsx-runtime';
|
|
15
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
16
|
+
import '@dynamic-labs/wallet-book';
|
|
17
|
+
import '../../../shared/consts/index.js';
|
|
18
|
+
import '../../../store/state/nonce/nonce.js';
|
|
19
|
+
import { isCookieEnabled } from '../../functions/isCookieEnabled/isCookieEnabled.js';
|
|
20
|
+
import { useProjectSettings } from '../../../store/state/projectSettings/projectSettings.js';
|
|
21
|
+
import { updatePrimaryWalletId } from '../../functions/updatePrimaryWalletId/updatePrimaryWalletId.js';
|
|
22
|
+
import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
|
|
23
|
+
import { useApiBaseUrl, useEnvironmentId } from '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
24
|
+
import { useUser } from '../../../store/state/user/user.js';
|
|
25
|
+
import { useWalletConnectorOptions } from '../../../store/state/walletOptions/walletOptions.js';
|
|
26
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
27
|
+
import '../../../events/dynamicEvents.js';
|
|
28
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
29
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
30
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
31
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
32
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
33
|
+
import '../../../config/ApiEndpoint.js';
|
|
34
|
+
import '../../../locale/locale.js';
|
|
35
|
+
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
36
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
37
|
+
import 'react-dom';
|
|
38
|
+
import '../../functions/compareChains/compareChains.js';
|
|
39
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
40
|
+
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
41
|
+
import 'bs58';
|
|
42
|
+
import '@dynamic-labs/types';
|
|
43
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
44
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
45
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
46
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
47
|
+
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
48
|
+
import 'yup';
|
|
49
|
+
import '../../../context/MockContext/MockContext.js';
|
|
50
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
51
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
52
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
53
|
+
import '@dynamic-labs/rpc-providers';
|
|
54
|
+
import '../../../store/state/loadingAndLifecycle.js';
|
|
55
|
+
import 'react-i18next';
|
|
56
|
+
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
57
|
+
import '../../../components/Alert/Alert.js';
|
|
58
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
59
|
+
import '../../../components/IconButton/IconButton.js';
|
|
60
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
61
|
+
import '../../../components/Input/Input.js';
|
|
62
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
63
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
64
|
+
import '../../../components/OverlayCard/OverlayCard.js';
|
|
65
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
66
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
67
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
68
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
69
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
70
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
71
|
+
import 'react-focus-lock';
|
|
72
|
+
import 'qrcode';
|
|
73
|
+
import 'formik';
|
|
74
|
+
import '../useSubdomainCheck/useSubdomainCheck.js';
|
|
75
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
76
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
77
|
+
import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
78
|
+
import '../../../context/ConnectWithOtpContext/constants.js';
|
|
79
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
80
|
+
import '@hcaptcha/react-hcaptcha';
|
|
81
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
82
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
83
|
+
import '../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
84
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
85
|
+
import '../../../store/state/sendBalances.js';
|
|
86
|
+
import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
87
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
88
|
+
import '../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
89
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
90
|
+
import '../../../context/OnrampContext/OnrampContext.js';
|
|
91
|
+
import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
92
|
+
import '../../../../index.js';
|
|
93
|
+
import { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, NO_ENABLED_CHAINS_ERROR } from './constants.js';
|
|
94
|
+
import '../../../store/state/tokenBalances.js';
|
|
95
|
+
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
96
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
97
|
+
|
|
98
|
+
const dynamicWaasKey = 'dynamicwaas';
|
|
99
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, }) => {
|
|
100
|
+
walletConnector.setEnvironmentId(environmentId);
|
|
101
|
+
walletConnector.setBaseApiUrl(apiBaseUrl === null || apiBaseUrl === void 0 ? void 0 : apiBaseUrl.replace('/api/v0', ''));
|
|
102
|
+
walletConnector.setGetAuthTokenFunction(() => authToken !== null && authToken !== void 0 ? authToken : '');
|
|
103
|
+
return walletConnector;
|
|
104
|
+
};
|
|
105
|
+
const useDynamicWaas = () => {
|
|
106
|
+
var _a;
|
|
107
|
+
const { setShowAuthFlow } = useInternalDynamicContext();
|
|
108
|
+
const { user } = useUser();
|
|
109
|
+
const apiBaseUrl = useApiBaseUrl();
|
|
110
|
+
const projectSettings = useProjectSettings();
|
|
111
|
+
const environmentId = useEnvironmentId();
|
|
112
|
+
const walletConnectorOptions = useWalletConnectorOptions();
|
|
113
|
+
const refresh = useRefreshUser();
|
|
114
|
+
const embeddedWalletSettings = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets;
|
|
115
|
+
const enabledChains = (_a = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _a === void 0 ? void 0 : _a.filter((c) => c.enabled);
|
|
116
|
+
const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
|
|
117
|
+
const enabledChainNames = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.map((chain) => chain.name);
|
|
118
|
+
const automaticEmbeddedWalletCreationEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreation;
|
|
119
|
+
const automaticEmbeddedWalletCreationForExternalEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreationForExternal;
|
|
120
|
+
const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
|
|
121
|
+
const dynamicWaasIsEnabled = defaultWalletVersion === EmbeddedWalletVersionEnum.V3;
|
|
122
|
+
const authToken = getAuthToken();
|
|
123
|
+
const isCookieAuthEnabled = projectSettings && isCookieEnabled(projectSettings);
|
|
124
|
+
const getWalletConnector = useCallback((chainName) => {
|
|
125
|
+
var _a;
|
|
126
|
+
if (!isCookieAuthEnabled && !authToken) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
if (!walletConnectorOptions.length || !environmentId || !apiBaseUrl)
|
|
130
|
+
return undefined;
|
|
131
|
+
const connectorKey = chainName === 'EVM' ? dynamicWaasKey : `${dynamicWaasKey}-svm`;
|
|
132
|
+
const walletConnector = (_a = walletConnectorOptions.find((option) => option.key.includes(connectorKey))) === null || _a === void 0 ? void 0 : _a.walletConnector;
|
|
133
|
+
if (!walletConnector) {
|
|
134
|
+
throw new DynamicError(DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR);
|
|
135
|
+
}
|
|
136
|
+
const configuredWalletConnector = configWaasWalletConnector({
|
|
137
|
+
apiBaseUrl,
|
|
138
|
+
authToken,
|
|
139
|
+
environmentId,
|
|
140
|
+
walletConnector,
|
|
141
|
+
});
|
|
142
|
+
return configuredWalletConnector;
|
|
143
|
+
}, [
|
|
144
|
+
walletConnectorOptions,
|
|
145
|
+
environmentId,
|
|
146
|
+
authToken,
|
|
147
|
+
apiBaseUrl,
|
|
148
|
+
isCookieAuthEnabled,
|
|
149
|
+
]);
|
|
150
|
+
const createWalletAccount = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
+
if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
|
|
152
|
+
throw new DynamicError(NO_ENABLED_CHAINS_ERROR);
|
|
153
|
+
}
|
|
154
|
+
const createdWalletAccounts = yield Promise.all(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.map((chain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
const walletConnector = getWalletConnector(chain);
|
|
156
|
+
if (!walletConnector)
|
|
157
|
+
return undefined;
|
|
158
|
+
const createdWalletAccount = yield walletConnector.createWalletAccount();
|
|
159
|
+
return Object.assign(Object.assign({}, createdWalletAccount), { chainName: chain });
|
|
160
|
+
})));
|
|
161
|
+
const primaryWalletAccount = createdWalletAccounts === null || createdWalletAccounts === void 0 ? void 0 : createdWalletAccounts.find((wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.chainName) === (primaryChain === null || primaryChain === void 0 ? void 0 : primaryChain.name));
|
|
162
|
+
const refreshedUser = yield refresh();
|
|
163
|
+
const createdPrimaryWallet = refreshedUser === null || refreshedUser === void 0 ? void 0 : refreshedUser.verifiedCredentials.find((wallet) => {
|
|
164
|
+
var _a, _b, _c;
|
|
165
|
+
return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes(dynamicWaasKey)) &&
|
|
166
|
+
((_b = wallet.address) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
|
|
167
|
+
((_c = primaryWalletAccount === null || primaryWalletAccount === void 0 ? void 0 : primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
|
|
168
|
+
});
|
|
169
|
+
if (createdPrimaryWallet) {
|
|
170
|
+
updatePrimaryWalletId(createdPrimaryWallet.id);
|
|
171
|
+
}
|
|
172
|
+
setShowAuthFlow(false, { performMultiWalletChecks: false }); // close email otp pin modal
|
|
173
|
+
return createdWalletAccounts;
|
|
174
|
+
}), [getWalletConnector, primaryChain, enabledChainNames, refresh]);
|
|
175
|
+
const shouldAutoCreateDynamicWaasWallet = useMemo(() => {
|
|
176
|
+
const hasDynamicWaasWallet = user === null || user === void 0 ? void 0 : user.verifiedCredentials.some((wallet) => { var _a; return (_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes('dynamicwaas'); });
|
|
177
|
+
if (!user ||
|
|
178
|
+
hasDynamicWaasWallet || // already has a dynamic waas wallet
|
|
179
|
+
!dynamicWaasIsEnabled || // dynamic waas is not enabled
|
|
180
|
+
!automaticEmbeddedWalletCreationEnabled // automatic embedded wallet creation is not enabled
|
|
181
|
+
)
|
|
182
|
+
return false;
|
|
183
|
+
const hasExternalWallet = user === null || user === void 0 ? void 0 : user.verifiedCredentials.some((vc) => vc.format === JwtVerifiedCredentialFormatEnum.Blockchain &&
|
|
184
|
+
vc.walletProvider !== WalletProviderEnum.EmbeddedWallet);
|
|
185
|
+
const shouldCreateDynamicWaasWallet = hasExternalWallet
|
|
186
|
+
? automaticEmbeddedWalletCreationForExternalEnabled
|
|
187
|
+
: true;
|
|
188
|
+
return shouldCreateDynamicWaasWallet;
|
|
189
|
+
}, [
|
|
190
|
+
user,
|
|
191
|
+
dynamicWaasIsEnabled,
|
|
192
|
+
automaticEmbeddedWalletCreationEnabled,
|
|
193
|
+
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
194
|
+
walletConnectorOptions,
|
|
195
|
+
]);
|
|
196
|
+
const importPrivateKey = (_b) => __awaiter(void 0, [_b], void 0, function* ({ chainName, privateKey, }) {
|
|
197
|
+
const walletConnector = getWalletConnector(chainName);
|
|
198
|
+
if (!walletConnector)
|
|
199
|
+
return;
|
|
200
|
+
yield walletConnector.importPrivateKey({
|
|
201
|
+
chainName,
|
|
202
|
+
privateKey,
|
|
203
|
+
});
|
|
204
|
+
yield refresh();
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
createWalletAccount,
|
|
208
|
+
dynamicWaasIsEnabled,
|
|
209
|
+
getWalletConnector,
|
|
210
|
+
importPrivateKey,
|
|
211
|
+
shouldAutoCreateDynamicWaasWallet,
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export { configWaasWalletConnector, useDynamicWaas };
|
|
@@ -160,19 +160,23 @@ const useEmbeddedWallet = () => {
|
|
|
160
160
|
});
|
|
161
161
|
const shouldPromptForKeyExport = React.useCallback(() => { var _a; return Boolean((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.promptForKeyExport); }, [projectSettings]);
|
|
162
162
|
const shouldAutoCreateEmbeddedWallet = React.useCallback((verifiedUser) => {
|
|
163
|
-
var _a, _b, _c, _d, _e;
|
|
163
|
+
var _a, _b, _c, _d, _e, _f;
|
|
164
164
|
const hasEmbeddedWalletProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
|
|
165
|
+
const defaultWalletVersion = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.defaultWalletVersion;
|
|
165
166
|
const hasPrimaryWallet = primaryWalletId.getPrimaryWalletId();
|
|
167
|
+
if (defaultWalletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V3) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
166
170
|
if (!hasEmbeddedWalletProviderEnabled || hasPrimaryWallet) {
|
|
167
171
|
return false;
|
|
168
172
|
}
|
|
169
173
|
// Turnkey specific rules
|
|
170
174
|
if (verifiedUser) {
|
|
171
175
|
const primaryEmbeddedChain = findPrimaryEmbeddedChain.findPrimaryEmbeddedChain(projectSettings);
|
|
172
|
-
const embeddedWalletVerifiedCredentialId = (
|
|
176
|
+
const embeddedWalletVerifiedCredentialId = (_b = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(verifiedUser, [
|
|
173
177
|
primaryEmbeddedChain,
|
|
174
|
-
])) === null ||
|
|
175
|
-
const AAWalletCredentialId = (
|
|
178
|
+
])) === null || _b === void 0 ? void 0 : _b.id;
|
|
179
|
+
const AAWalletCredentialId = (_d = (_c = verifiedUser.verifiedCredentials) === null || _c === void 0 ? void 0 : _c.find((vc) => vc.walletProvider === sdkApiCore.WalletProviderEnum.SmartContractWallet)) === null || _d === void 0 ? void 0 : _d.id;
|
|
176
180
|
const targetPrimaryWalletId = AAWalletCredentialId
|
|
177
181
|
? AAWalletCredentialId
|
|
178
182
|
: embeddedWalletVerifiedCredentialId;
|
|
@@ -182,7 +186,7 @@ const useEmbeddedWallet = () => {
|
|
|
182
186
|
}
|
|
183
187
|
}
|
|
184
188
|
if (isTurnkeyEnabled.isTurnkeyEnabled(projectSettings) &&
|
|
185
|
-
!((
|
|
189
|
+
!((_f = (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _e === void 0 ? void 0 : _e.embeddedWallets) === null || _f === void 0 ? void 0 : _f.automaticEmbeddedWalletCreation)) {
|
|
186
190
|
return false;
|
|
187
191
|
}
|
|
188
192
|
return true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
|
-
import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { EmbeddedWalletVersionEnum, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
6
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
7
7
|
import '../../../shared/logger.js';
|
|
@@ -156,19 +156,23 @@ const useEmbeddedWallet = () => {
|
|
|
156
156
|
});
|
|
157
157
|
const shouldPromptForKeyExport = useCallback(() => { var _a; return Boolean((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.promptForKeyExport); }, [projectSettings]);
|
|
158
158
|
const shouldAutoCreateEmbeddedWallet = useCallback((verifiedUser) => {
|
|
159
|
-
var _a, _b, _c, _d, _e;
|
|
159
|
+
var _a, _b, _c, _d, _e, _f;
|
|
160
160
|
const hasEmbeddedWalletProviderEnabled = isTurnkeyEnabled(projectSettings);
|
|
161
|
+
const defaultWalletVersion = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.defaultWalletVersion;
|
|
161
162
|
const hasPrimaryWallet = getPrimaryWalletId();
|
|
163
|
+
if (defaultWalletVersion === EmbeddedWalletVersionEnum.V3) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
162
166
|
if (!hasEmbeddedWalletProviderEnabled || hasPrimaryWallet) {
|
|
163
167
|
return false;
|
|
164
168
|
}
|
|
165
169
|
// Turnkey specific rules
|
|
166
170
|
if (verifiedUser) {
|
|
167
171
|
const primaryEmbeddedChain = findPrimaryEmbeddedChain(projectSettings);
|
|
168
|
-
const embeddedWalletVerifiedCredentialId = (
|
|
172
|
+
const embeddedWalletVerifiedCredentialId = (_b = findEmbeddedWalletFromVerifiedCredentials(verifiedUser, [
|
|
169
173
|
primaryEmbeddedChain,
|
|
170
|
-
])) === null ||
|
|
171
|
-
const AAWalletCredentialId = (
|
|
174
|
+
])) === null || _b === void 0 ? void 0 : _b.id;
|
|
175
|
+
const AAWalletCredentialId = (_d = (_c = verifiedUser.verifiedCredentials) === null || _c === void 0 ? void 0 : _c.find((vc) => vc.walletProvider === WalletProviderEnum.SmartContractWallet)) === null || _d === void 0 ? void 0 : _d.id;
|
|
172
176
|
const targetPrimaryWalletId = AAWalletCredentialId
|
|
173
177
|
? AAWalletCredentialId
|
|
174
178
|
: embeddedWalletVerifiedCredentialId;
|
|
@@ -178,7 +182,7 @@ const useEmbeddedWallet = () => {
|
|
|
178
182
|
}
|
|
179
183
|
}
|
|
180
184
|
if (isTurnkeyEnabled(projectSettings) &&
|
|
181
|
-
!((
|
|
185
|
+
!((_f = (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _e === void 0 ? void 0 : _e.embeddedWallets) === null || _f === void 0 ? void 0 : _f.automaticEmbeddedWalletCreation)) {
|
|
182
186
|
return false;
|
|
183
187
|
}
|
|
184
188
|
return true;
|
|
@@ -21,13 +21,14 @@ require('../../../shared/consts/index.cjs');
|
|
|
21
21
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
22
22
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
23
23
|
require('@dynamic-labs/multi-wallet');
|
|
24
|
+
var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
|
|
24
25
|
require('react-international-phone');
|
|
25
26
|
require('../../../store/state/nonce/nonce.cjs');
|
|
26
27
|
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
27
28
|
require('../../../config/ApiEndpoint.cjs');
|
|
28
29
|
require('../../../store/state/user/user.cjs');
|
|
29
30
|
require('../../../locale/locale.cjs');
|
|
30
|
-
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
31
|
+
var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
31
32
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
32
33
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
33
34
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
@@ -91,10 +92,14 @@ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCa
|
|
|
91
92
|
require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
92
93
|
require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
93
94
|
require('../../../../index.cjs');
|
|
95
|
+
var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
|
|
94
96
|
require('../../../store/state/tokenBalances.cjs');
|
|
95
97
|
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
96
98
|
|
|
99
|
+
const DEFAULT_API_BASE_URL = 'https://app.dynamicauth.com/api/v0';
|
|
97
100
|
const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSettings) => {
|
|
101
|
+
const apiBaseUrl = dynamicContextProps.useApiBaseUrl();
|
|
102
|
+
const authToken = getAuthToken.getAuthToken();
|
|
98
103
|
const { registerEmbeddedWalletSessionKey, removeSessionKey } = useEmbeddedWalletSessionKeys.useEmbeddedWalletSessionKeys({ environmentId, projectSettings });
|
|
99
104
|
if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
100
105
|
return;
|
|
@@ -104,6 +109,14 @@ const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSett
|
|
|
104
109
|
(_a = walletOption.walletConnector) === null || _a === void 0 ? void 0 : _a.setSessionKeyFetcher(registerEmbeddedWalletSessionKey);
|
|
105
110
|
(_b = walletOption.walletConnector) === null || _b === void 0 ? void 0 : _b.setSessionKeyRemoveFunction(() => removeSessionKey());
|
|
106
111
|
}
|
|
112
|
+
else if (walletConnectorCore.isDynamicWaasConnector(walletOption.walletConnector)) {
|
|
113
|
+
useDynamicWaas.configWaasWalletConnector({
|
|
114
|
+
apiBaseUrl: apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : DEFAULT_API_BASE_URL,
|
|
115
|
+
authToken,
|
|
116
|
+
environmentId,
|
|
117
|
+
walletConnector: walletOption.walletConnector,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
107
120
|
});
|
|
108
121
|
};
|
|
109
122
|
|