@dynamic-labs/sdk-react-core 4.20.4 → 4.20.5
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 +14 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/functions.d.ts +1 -0
- package/src/index.cjs +5 -2
- package/src/index.d.ts +3 -1
- package/src/index.js +3 -2
- package/src/lib/Main.cjs +2 -2
- package/src/lib/Main.js +3 -3
- package/src/lib/components/ModalCard/ModalCard.cjs +3 -1
- package/src/lib/components/ModalCard/ModalCard.d.ts +2 -0
- package/src/lib/components/ModalCard/ModalCard.js +3 -1
- package/src/lib/components/UserWalletsList/UserWalletsList.cjs +2 -2
- package/src/lib/components/UserWalletsList/UserWalletsList.js +3 -3
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -0
- package/src/lib/context/UserWalletsContext/UserWalletsContext.cjs +2 -2
- package/src/lib/context/UserWalletsContext/UserWalletsContext.d.ts +1 -1
- package/src/lib/context/UserWalletsContext/UserWalletsContext.js +2 -2
- package/src/lib/data/api/api.cjs +5 -0
- package/src/lib/data/api/api.js +5 -0
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.cjs +1 -0
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.js +1 -0
- package/src/lib/locale/en/translation.cjs +15 -0
- package/src/lib/locale/en/translation.d.ts +15 -0
- package/src/lib/locale/en/translation.js +15 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/sessionStorage.cjs +12 -0
- package/src/lib/utils/constants/sessionStorage.d.ts +2 -0
- package/src/lib/utils/constants/sessionStorage.js +7 -0
- package/src/lib/utils/functions/clientSessionKeys/constants.cjs +8 -0
- package/src/lib/utils/functions/clientSessionKeys/constants.d.ts +1 -0
- package/src/lib/utils/functions/clientSessionKeys/constants.js +4 -0
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.cjs +67 -0
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.d.ts +17 -0
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.js +58 -0
- package/src/lib/utils/functions/clientSessionKeys/index.d.ts +1 -0
- package/src/lib/utils/functions/clientSessionKeys/types.d.ts +5 -0
- package/src/lib/utils/functions/index.d.ts +2 -0
- package/src/lib/utils/functions/keyService/index.d.ts +1 -0
- package/src/lib/utils/{hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/utils.cjs → functions/keyService/keyService.cjs} +13 -1
- package/src/lib/utils/{hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/utils.d.ts → functions/keyService/keyService.d.ts} +1 -0
- package/src/lib/utils/{hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/utils.js → functions/keyService/keyService.js} +13 -2
- package/src/lib/utils/functions/usingV3Wallets/index.d.ts +1 -0
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useClientSessionKeys/index.d.ts +1 -0
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +63 -0
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.d.ts +5 -0
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +59 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +4 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +4 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.cjs +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.d.ts +1 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.js +2 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +51 -36
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +1 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +52 -37
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +6 -17
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +1 -12
- package/src/lib/utils/hooks/useFundWithWallet/useChooseLinkedWallet/useChooseLinkedWallet.cjs +1 -1
- package/src/lib/utils/hooks/useFundWithWallet/useChooseLinkedWallet/useChooseLinkedWallet.js +2 -2
- package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.cjs +1 -1
- package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.js +2 -2
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.cjs +1 -1
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.js +1 -1
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +3 -1
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +3 -1
- package/src/lib/utils/hooks/useSwitchWallet/useSwitchWallet.cjs +1 -1
- package/src/lib/utils/hooks/useSwitchWallet/useSwitchWallet.js +2 -2
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +0 -5
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +0 -5
- package/src/lib/utils/hooks/useWalletConnectors/utils/smartWallet/smartWallet.cjs +4 -1
- package/src/lib/utils/hooks/useWalletConnectors/utils/smartWallet/smartWallet.js +4 -1
- package/src/lib/utils/hooks/useWalletList/useWalletList.cjs +1 -1
- package/src/lib/utils/hooks/useWalletList/useWalletList.js +2 -2
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSimpleSignIn/WalletSimpleSignIn.cjs +1 -1
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSimpleSignIn/WalletSimpleSignIn.js +2 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +2 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +13 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +2 -0
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/views/ConfirmExchangeTransferView/ConfirmExchangeTransferView.cjs +134 -0
- package/src/lib/widgets/DynamicWidget/views/ConfirmExchangeTransferView/ConfirmExchangeTransferView.d.ts +18 -0
- package/src/lib/widgets/DynamicWidget/views/ConfirmExchangeTransferView/ConfirmExchangeTransferView.js +130 -0
- package/src/lib/widgets/DynamicWidget/views/ConfirmExchangeTransferView/index.d.ts +1 -0
|
@@ -7,19 +7,23 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
9
9
|
var utils = require('@dynamic-labs/utils');
|
|
10
|
-
|
|
11
|
-
require('
|
|
12
|
-
require('@dynamic-labs/multi-wallet');
|
|
10
|
+
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
11
|
+
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
13
12
|
require('../../../shared/logger.cjs');
|
|
14
|
-
require('../../constants/colors.cjs');
|
|
15
|
-
var getMinAuthToken = require('../../functions/getMinAuthToken/getMinAuthToken.cjs');
|
|
16
|
-
require('react-international-phone');
|
|
17
13
|
require('@dynamic-labs/iconic');
|
|
18
14
|
require('@dynamic-labs/wallet-connector-core');
|
|
19
15
|
require('react/jsx-runtime');
|
|
20
16
|
require('../../../context/ViewContext/ViewContext.cjs');
|
|
21
17
|
require('@dynamic-labs/wallet-book');
|
|
18
|
+
require('../../constants/colors.cjs');
|
|
19
|
+
require('../../constants/values.cjs');
|
|
22
20
|
require('../../../shared/consts/index.cjs');
|
|
21
|
+
require('../../../events/dynamicEvents.cjs');
|
|
22
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
|
+
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
|
+
require('@dynamic-labs/multi-wallet');
|
|
25
|
+
var getMinAuthToken = require('../../functions/getMinAuthToken/getMinAuthToken.cjs');
|
|
26
|
+
require('react-international-phone');
|
|
23
27
|
require('../../../store/state/nonce/nonce.cjs');
|
|
24
28
|
var isCookieEnabled = require('../../functions/isCookieEnabled/isCookieEnabled.cjs');
|
|
25
29
|
var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
@@ -27,32 +31,26 @@ var updatePrimaryWalletId = require('../../functions/updatePrimaryWalletId/updat
|
|
|
27
31
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
28
32
|
var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
29
33
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
30
|
-
var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
|
|
31
|
-
var compareChains = require('../../functions/compareChains/compareChains.cjs');
|
|
32
|
-
var user = require('../../../store/state/user/user.cjs');
|
|
33
|
-
var walletOptions = require('../../../store/state/walletOptions/walletOptions.cjs');
|
|
34
|
-
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
35
|
-
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
36
|
-
require('../../../events/dynamicEvents.cjs');
|
|
37
|
-
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
38
|
-
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
39
34
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
40
35
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
36
|
+
var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
41
37
|
require('../../../config/ApiEndpoint.cjs');
|
|
38
|
+
var user = require('../../../store/state/user/user.cjs');
|
|
42
39
|
require('../../../locale/locale.cjs');
|
|
43
40
|
require('../../../store/state/authMode/authMode.cjs');
|
|
44
41
|
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
45
42
|
require('react-dom');
|
|
46
43
|
var smartWallet = require('../useWalletConnectors/utils/smartWallet/smartWallet.cjs');
|
|
47
44
|
require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
48
|
-
var useEmbeddedWalletSessionKeys = require('../useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs');
|
|
49
45
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
46
|
+
var compareChains = require('../../functions/compareChains/compareChains.cjs');
|
|
50
47
|
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
51
48
|
require('bs58');
|
|
52
49
|
require('@dynamic-labs/types');
|
|
53
50
|
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
54
51
|
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
55
52
|
require('../../../context/WalletContext/WalletContext.cjs');
|
|
53
|
+
var getNewVerifiedCredentialsFromDiff = require('../../functions/getNewVerifiedCredentialsFromDiff/getNewVerifiedCredentialsFromDiff.cjs');
|
|
56
54
|
require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
57
55
|
require('yup');
|
|
58
56
|
require('../../../context/MockContext/MockContext.cjs');
|
|
@@ -60,6 +58,7 @@ require('../../../views/CollectUserDataView/useFields.cjs');
|
|
|
60
58
|
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
61
59
|
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
62
60
|
require('@dynamic-labs/rpc-providers');
|
|
61
|
+
var walletOptions = require('../../../store/state/walletOptions/walletOptions.cjs');
|
|
63
62
|
require('react-i18next');
|
|
64
63
|
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
65
64
|
require('../../../components/Alert/Alert.cjs');
|
|
@@ -100,6 +99,8 @@ require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
|
100
99
|
require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
101
100
|
require('../../../../index.cjs');
|
|
102
101
|
var apiUrl = require('../../constants/waas/apiUrl.cjs');
|
|
102
|
+
var useClientSessionKeys = require('../useClientSessionKeys/useClientSessionKeys.cjs');
|
|
103
|
+
var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
|
|
103
104
|
var constants = require('./constants.cjs');
|
|
104
105
|
require('../../../store/state/tokenBalances.cjs');
|
|
105
106
|
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
@@ -119,13 +120,13 @@ const useDynamicWaas = () => {
|
|
|
119
120
|
var _a, _b, _c;
|
|
120
121
|
const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
121
122
|
const { user: user$1 } = user.useUser();
|
|
123
|
+
const { addedWalletsIds, userWallets } = UserWalletsContext.useInternalUserWallets();
|
|
122
124
|
const apiBaseUrl = dynamicContextProps.useApiBaseUrl();
|
|
123
125
|
const projectSettings$1 = projectSettings.useProjectSettings();
|
|
124
126
|
const environmentId = dynamicContextProps.useEnvironmentId();
|
|
125
127
|
const walletConnectorOptions = walletOptions.useWalletConnectorOptions();
|
|
126
128
|
const refresh = useRefreshUser.useRefreshUser();
|
|
127
129
|
const relayUrl = (_b = (_a = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk) === null || _a === void 0 ? void 0 : _a.waas) === null || _b === void 0 ? void 0 : _b.relayUrl;
|
|
128
|
-
const userWallets = UserWalletsContext.useUserWallets();
|
|
129
130
|
const embeddedWalletSettings = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk.embeddedWallets;
|
|
130
131
|
const enabledChains = (_c = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _c === void 0 ? void 0 : _c.filter((c) => c.enabled);
|
|
131
132
|
const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
|
|
@@ -135,9 +136,7 @@ const useDynamicWaas = () => {
|
|
|
135
136
|
const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
|
|
136
137
|
const dynamicWaasIsEnabled = defaultWalletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V3;
|
|
137
138
|
const authToken = getMinAuthToken.getMinAuthToken();
|
|
138
|
-
const { getSignedSessionId } =
|
|
139
|
-
environmentId,
|
|
140
|
-
});
|
|
139
|
+
const { getSignedSessionId } = useClientSessionKeys.useClientSessionKeys();
|
|
141
140
|
const isCookieAuthEnabled = projectSettings$1 && isCookieEnabled.isCookieEnabled(projectSettings$1);
|
|
142
141
|
const getWalletConnector = React.useCallback((chainName) => {
|
|
143
142
|
var _a;
|
|
@@ -174,30 +173,44 @@ const useDynamicWaas = () => {
|
|
|
174
173
|
if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
|
|
175
174
|
throw new utils.DynamicError(constants.NO_ENABLED_CHAINS_ERROR);
|
|
176
175
|
}
|
|
177
|
-
const invalidChains = chainNames
|
|
176
|
+
const invalidChains = chainNames.filter((chain) => !enabledChainNames.includes(chain));
|
|
178
177
|
if (invalidChains && invalidChains.length) {
|
|
179
178
|
throw new utils.DynamicError(`${constants.INVALID_CHAINS_ERROR}: ${invalidChains.join(', ')}`);
|
|
180
179
|
}
|
|
181
|
-
const
|
|
180
|
+
const currentVerifiedCredentials = (user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials) || [];
|
|
181
|
+
const results = yield Promise.allSettled(chainNames.map((chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
182
182
|
const walletConnector = getWalletConnector(chain);
|
|
183
183
|
if (!walletConnector)
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
return Object.assign(Object.assign({},
|
|
184
|
+
throw new Error('No connector');
|
|
185
|
+
const account = yield walletConnector.createWalletAccount();
|
|
186
|
+
return Object.assign(Object.assign({}, account), { chainName: chain });
|
|
187
187
|
})));
|
|
188
|
+
const failedChains = chainNames.filter((_, i) => results[i].status === 'rejected');
|
|
189
|
+
if (failedChains.length > 0) {
|
|
190
|
+
refresh();
|
|
191
|
+
throw new utils.DynamicError(`${constants.WALLET_CREATION_FAILED_ERROR}: ${failedChains.join(', ')}`);
|
|
192
|
+
}
|
|
193
|
+
const createdWalletAccounts = results.map((r) => r.status === 'fulfilled' ? r.value : undefined);
|
|
188
194
|
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));
|
|
189
195
|
const refreshedUser = yield refresh();
|
|
190
|
-
if (refreshedUser
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
if (refreshedUser) {
|
|
197
|
+
// Add new wallet IDs to trigger walletAdded events
|
|
198
|
+
const newWalletIds = getNewVerifiedCredentialsFromDiff.getNewVerifiedCredentialsFromDiff(currentVerifiedCredentials, refreshedUser.verifiedCredentials)
|
|
199
|
+
.filter(({ format }) => format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Blockchain)
|
|
200
|
+
.map(({ id }) => id);
|
|
201
|
+
addedWalletsIds.current = addedWalletsIds.current.concat(newWalletIds);
|
|
202
|
+
if (primaryWalletAccount) {
|
|
203
|
+
const createdPrimaryWallet = refreshedUser.verifiedCredentials.find((wallet) => {
|
|
204
|
+
var _a, _b, _c;
|
|
205
|
+
return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes(dynamicWaasKey)) &&
|
|
206
|
+
((_b = wallet.address) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
|
|
207
|
+
((_c = primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
|
|
208
|
+
});
|
|
209
|
+
if (createdPrimaryWallet) {
|
|
210
|
+
const smartWalletAccount = smartWallet.findSmartWallet(createdPrimaryWallet, refreshedUser.verifiedCredentials);
|
|
211
|
+
const walletIdToUse = (smartWalletAccount === null || smartWalletAccount === void 0 ? void 0 : smartWalletAccount.id) || createdPrimaryWallet.id;
|
|
212
|
+
updatePrimaryWalletId.updatePrimaryWalletId(walletIdToUse);
|
|
213
|
+
}
|
|
201
214
|
}
|
|
202
215
|
}
|
|
203
216
|
setShowAuthFlow(false, { performMultiWalletChecks: false }); // close email otp pin modal
|
|
@@ -208,6 +221,8 @@ const useDynamicWaas = () => {
|
|
|
208
221
|
enabledChainNames,
|
|
209
222
|
refresh,
|
|
210
223
|
setShowAuthFlow,
|
|
224
|
+
user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials,
|
|
225
|
+
addedWalletsIds,
|
|
211
226
|
]);
|
|
212
227
|
const needsAutoCreateWalletChains = React.useMemo(() => {
|
|
213
228
|
const hasDynamicWaasWalletForChain = (chain) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
1
|
import { ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, getSignedSessionId, }: {
|
|
4
4
|
walletConnector: IDynamicWaasConnector;
|
|
5
5
|
environmentId: string;
|
|
@@ -3,19 +3,23 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { useCallback, useMemo } from 'react';
|
|
4
4
|
import { EmbeddedWalletVersionEnum, JwtVerifiedCredentialFormatEnum, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
|
-
import
|
|
7
|
-
import '
|
|
8
|
-
import '@dynamic-labs/multi-wallet';
|
|
6
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
7
|
+
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
9
8
|
import '../../../shared/logger.js';
|
|
10
|
-
import '../../constants/colors.js';
|
|
11
|
-
import { getMinAuthToken } from '../../functions/getMinAuthToken/getMinAuthToken.js';
|
|
12
|
-
import 'react-international-phone';
|
|
13
9
|
import '@dynamic-labs/iconic';
|
|
14
10
|
import '@dynamic-labs/wallet-connector-core';
|
|
15
11
|
import 'react/jsx-runtime';
|
|
16
12
|
import '../../../context/ViewContext/ViewContext.js';
|
|
17
13
|
import '@dynamic-labs/wallet-book';
|
|
14
|
+
import '../../constants/colors.js';
|
|
15
|
+
import '../../constants/values.js';
|
|
18
16
|
import '../../../shared/consts/index.js';
|
|
17
|
+
import '../../../events/dynamicEvents.js';
|
|
18
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
|
+
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import { getMinAuthToken } from '../../functions/getMinAuthToken/getMinAuthToken.js';
|
|
22
|
+
import 'react-international-phone';
|
|
19
23
|
import '../../../store/state/nonce/nonce.js';
|
|
20
24
|
import { isCookieEnabled } from '../../functions/isCookieEnabled/isCookieEnabled.js';
|
|
21
25
|
import { useProjectSettings } from '../../../store/state/projectSettings/projectSettings.js';
|
|
@@ -23,32 +27,26 @@ import { updatePrimaryWalletId } from '../../functions/updatePrimaryWalletId/upd
|
|
|
23
27
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
24
28
|
import { useApiBaseUrl, useEnvironmentId } from '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
25
29
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
26
|
-
import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
|
|
27
|
-
import { compareChains } from '../../functions/compareChains/compareChains.js';
|
|
28
|
-
import { useUser } from '../../../store/state/user/user.js';
|
|
29
|
-
import { useWalletConnectorOptions } from '../../../store/state/walletOptions/walletOptions.js';
|
|
30
|
-
import '../../../context/DynamicContext/DynamicContext.js';
|
|
31
|
-
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
32
|
-
import '../../../events/dynamicEvents.js';
|
|
33
|
-
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
34
|
-
import '../../../context/ErrorContext/ErrorContext.js';
|
|
35
30
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
36
31
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
32
|
+
import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
37
33
|
import '../../../config/ApiEndpoint.js';
|
|
34
|
+
import { useUser } from '../../../store/state/user/user.js';
|
|
38
35
|
import '../../../locale/locale.js';
|
|
39
36
|
import '../../../store/state/authMode/authMode.js';
|
|
40
37
|
import '../../../context/VerificationContext/VerificationContext.js';
|
|
41
38
|
import 'react-dom';
|
|
42
39
|
import { findSmartWallet } from '../useWalletConnectors/utils/smartWallet/smartWallet.js';
|
|
43
40
|
import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
44
|
-
import { useEmbeddedWalletSessionKeys } from '../useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js';
|
|
45
41
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
42
|
+
import { compareChains } from '../../functions/compareChains/compareChains.js';
|
|
46
43
|
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
47
44
|
import 'bs58';
|
|
48
45
|
import '@dynamic-labs/types';
|
|
49
46
|
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
50
47
|
import '../../../context/LoadingContext/LoadingContext.js';
|
|
51
48
|
import '../../../context/WalletContext/WalletContext.js';
|
|
49
|
+
import { getNewVerifiedCredentialsFromDiff } from '../../functions/getNewVerifiedCredentialsFromDiff/getNewVerifiedCredentialsFromDiff.js';
|
|
52
50
|
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
53
51
|
import 'yup';
|
|
54
52
|
import '../../../context/MockContext/MockContext.js';
|
|
@@ -56,6 +54,7 @@ import '../../../views/CollectUserDataView/useFields.js';
|
|
|
56
54
|
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
57
55
|
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
58
56
|
import '@dynamic-labs/rpc-providers';
|
|
57
|
+
import { useWalletConnectorOptions } from '../../../store/state/walletOptions/walletOptions.js';
|
|
59
58
|
import 'react-i18next';
|
|
60
59
|
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
61
60
|
import '../../../components/Alert/Alert.js';
|
|
@@ -96,7 +95,9 @@ import '../../../context/OnrampContext/OnrampContext.js';
|
|
|
96
95
|
import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
97
96
|
import '../../../../index.js';
|
|
98
97
|
import { DEFAULT_WAAS_API_URL } from '../../constants/waas/apiUrl.js';
|
|
99
|
-
import {
|
|
98
|
+
import { useClientSessionKeys } from '../useClientSessionKeys/useClientSessionKeys.js';
|
|
99
|
+
import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
|
|
100
|
+
import { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, NO_ENABLED_CHAINS_ERROR, INVALID_CHAINS_ERROR, WALLET_CREATION_FAILED_ERROR } from './constants.js';
|
|
100
101
|
import '../../../store/state/tokenBalances.js';
|
|
101
102
|
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
102
103
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
@@ -115,13 +116,13 @@ const useDynamicWaas = () => {
|
|
|
115
116
|
var _a, _b, _c;
|
|
116
117
|
const { setShowAuthFlow } = useInternalDynamicContext();
|
|
117
118
|
const { user } = useUser();
|
|
119
|
+
const { addedWalletsIds, userWallets } = useInternalUserWallets();
|
|
118
120
|
const apiBaseUrl = useApiBaseUrl();
|
|
119
121
|
const projectSettings = useProjectSettings();
|
|
120
122
|
const environmentId = useEnvironmentId();
|
|
121
123
|
const walletConnectorOptions = useWalletConnectorOptions();
|
|
122
124
|
const refresh = useRefreshUser();
|
|
123
125
|
const relayUrl = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.waas) === null || _b === void 0 ? void 0 : _b.relayUrl;
|
|
124
|
-
const userWallets = useUserWallets();
|
|
125
126
|
const embeddedWalletSettings = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets;
|
|
126
127
|
const enabledChains = (_c = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _c === void 0 ? void 0 : _c.filter((c) => c.enabled);
|
|
127
128
|
const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
|
|
@@ -131,9 +132,7 @@ const useDynamicWaas = () => {
|
|
|
131
132
|
const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
|
|
132
133
|
const dynamicWaasIsEnabled = defaultWalletVersion === EmbeddedWalletVersionEnum.V3;
|
|
133
134
|
const authToken = getMinAuthToken();
|
|
134
|
-
const { getSignedSessionId } =
|
|
135
|
-
environmentId,
|
|
136
|
-
});
|
|
135
|
+
const { getSignedSessionId } = useClientSessionKeys();
|
|
137
136
|
const isCookieAuthEnabled = projectSettings && isCookieEnabled(projectSettings);
|
|
138
137
|
const getWalletConnector = useCallback((chainName) => {
|
|
139
138
|
var _a;
|
|
@@ -170,30 +169,44 @@ const useDynamicWaas = () => {
|
|
|
170
169
|
if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
|
|
171
170
|
throw new DynamicError(NO_ENABLED_CHAINS_ERROR);
|
|
172
171
|
}
|
|
173
|
-
const invalidChains = chainNames
|
|
172
|
+
const invalidChains = chainNames.filter((chain) => !enabledChainNames.includes(chain));
|
|
174
173
|
if (invalidChains && invalidChains.length) {
|
|
175
174
|
throw new DynamicError(`${INVALID_CHAINS_ERROR}: ${invalidChains.join(', ')}`);
|
|
176
175
|
}
|
|
177
|
-
const
|
|
176
|
+
const currentVerifiedCredentials = (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || [];
|
|
177
|
+
const results = yield Promise.allSettled(chainNames.map((chain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
178
178
|
const walletConnector = getWalletConnector(chain);
|
|
179
179
|
if (!walletConnector)
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
return Object.assign(Object.assign({},
|
|
180
|
+
throw new Error('No connector');
|
|
181
|
+
const account = yield walletConnector.createWalletAccount();
|
|
182
|
+
return Object.assign(Object.assign({}, account), { chainName: chain });
|
|
183
183
|
})));
|
|
184
|
+
const failedChains = chainNames.filter((_, i) => results[i].status === 'rejected');
|
|
185
|
+
if (failedChains.length > 0) {
|
|
186
|
+
refresh();
|
|
187
|
+
throw new DynamicError(`${WALLET_CREATION_FAILED_ERROR}: ${failedChains.join(', ')}`);
|
|
188
|
+
}
|
|
189
|
+
const createdWalletAccounts = results.map((r) => r.status === 'fulfilled' ? r.value : undefined);
|
|
184
190
|
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));
|
|
185
191
|
const refreshedUser = yield refresh();
|
|
186
|
-
if (refreshedUser
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
if (refreshedUser) {
|
|
193
|
+
// Add new wallet IDs to trigger walletAdded events
|
|
194
|
+
const newWalletIds = getNewVerifiedCredentialsFromDiff(currentVerifiedCredentials, refreshedUser.verifiedCredentials)
|
|
195
|
+
.filter(({ format }) => format === JwtVerifiedCredentialFormatEnum.Blockchain)
|
|
196
|
+
.map(({ id }) => id);
|
|
197
|
+
addedWalletsIds.current = addedWalletsIds.current.concat(newWalletIds);
|
|
198
|
+
if (primaryWalletAccount) {
|
|
199
|
+
const createdPrimaryWallet = refreshedUser.verifiedCredentials.find((wallet) => {
|
|
200
|
+
var _a, _b, _c;
|
|
201
|
+
return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes(dynamicWaasKey)) &&
|
|
202
|
+
((_b = wallet.address) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
|
|
203
|
+
((_c = primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
|
|
204
|
+
});
|
|
205
|
+
if (createdPrimaryWallet) {
|
|
206
|
+
const smartWalletAccount = findSmartWallet(createdPrimaryWallet, refreshedUser.verifiedCredentials);
|
|
207
|
+
const walletIdToUse = (smartWalletAccount === null || smartWalletAccount === void 0 ? void 0 : smartWalletAccount.id) || createdPrimaryWallet.id;
|
|
208
|
+
updatePrimaryWalletId(walletIdToUse);
|
|
209
|
+
}
|
|
197
210
|
}
|
|
198
211
|
}
|
|
199
212
|
setShowAuthFlow(false, { performMultiWalletChecks: false }); // close email otp pin modal
|
|
@@ -204,6 +217,8 @@ const useDynamicWaas = () => {
|
|
|
204
217
|
enabledChainNames,
|
|
205
218
|
refresh,
|
|
206
219
|
setShowAuthFlow,
|
|
220
|
+
user === null || user === void 0 ? void 0 : user.verifiedCredentials,
|
|
221
|
+
addedWalletsIds,
|
|
207
222
|
]);
|
|
208
223
|
const needsAutoCreateWalletChains = useMemo(() => {
|
|
209
224
|
const hasDynamicWaasWalletForChain = (chain) => {
|
|
@@ -8,7 +8,7 @@ var React = require('react');
|
|
|
8
8
|
var utils = require('@dynamic-labs/utils');
|
|
9
9
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
10
10
|
var localStorage = require('../../constants/localStorage.cjs');
|
|
11
|
-
var
|
|
11
|
+
var keyService = require('../../functions/keyService/keyService.cjs');
|
|
12
12
|
require('@dynamic-labs/sdk-api-core');
|
|
13
13
|
require('../../../config/ApiEndpoint.cjs');
|
|
14
14
|
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
@@ -85,7 +85,7 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
|
85
85
|
publicKey = nextPublicKey;
|
|
86
86
|
privateKey = nextPrivateKey;
|
|
87
87
|
privateKeyJwk = nextPrivateKeyJwk;
|
|
88
|
-
prevSessionKeySignature = yield
|
|
88
|
+
prevSessionKeySignature = yield keyService.p256Sign(decodedSessionKeys.privateKeyJwk, user$1.sessionId);
|
|
89
89
|
utils.tracing.logEvent('session-key', 'Loaded prevSessionKeySignature', utils.tracing.formatObject({ nextPublicKey, prevSessionKeySignature }));
|
|
90
90
|
}
|
|
91
91
|
let resp;
|
|
@@ -116,16 +116,16 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
|
116
116
|
expirationDate,
|
|
117
117
|
publicKey,
|
|
118
118
|
}));
|
|
119
|
-
utils.StorageService.setItem(localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS, toEncodedFormat(publicKey, privateKey, privateKeyJwk, true, expirationDate), localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS);
|
|
119
|
+
utils.StorageService.setItem(localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS, keyService.toEncodedFormat(publicKey, privateKey, privateKeyJwk, true, expirationDate), localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS);
|
|
120
120
|
return { expirationDate, privateKey, publicKey };
|
|
121
121
|
});
|
|
122
122
|
const generateSessionKey = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
-
const { private: privateKey, public: publicKey, privateJwk, } = yield
|
|
123
|
+
const { private: privateKey, public: publicKey, privateJwk, } = yield keyService.p256Keygen();
|
|
124
124
|
// convert to base64 and store the session keys in session storage
|
|
125
125
|
utils.tracing.logEvent('session-key', 'Generated new session key', utils.tracing.formatObject({
|
|
126
126
|
publicKey,
|
|
127
127
|
}));
|
|
128
|
-
utils.StorageService.setItem(localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS, toEncodedFormat(publicKey, privateKey, privateJwk, false), localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS);
|
|
128
|
+
utils.StorageService.setItem(localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS, keyService.toEncodedFormat(publicKey, privateKey, privateJwk, false), localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS);
|
|
129
129
|
return { privateKey, privateKeyJwk: privateJwk, publicKey };
|
|
130
130
|
});
|
|
131
131
|
const getSessionPublicKey = () => {
|
|
@@ -146,17 +146,6 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
|
146
146
|
// the user is undefined at this point in the auth flow and we cant check the users wallet version
|
|
147
147
|
// so we just return true for now
|
|
148
148
|
const shouldRegisterSessionKeysOnSignin = () => true;
|
|
149
|
-
const toEncodedFormat = (publicKey, privateKey, privateKeyJwk, registered, expirationDate) => {
|
|
150
|
-
const sessionKeys = {
|
|
151
|
-
expirationDate,
|
|
152
|
-
privateKey,
|
|
153
|
-
privateKeyJwk,
|
|
154
|
-
publicKey,
|
|
155
|
-
registered,
|
|
156
|
-
};
|
|
157
|
-
const sessionKeysString = JSON.stringify(sessionKeys);
|
|
158
|
-
return Buffer.from(sessionKeysString).toString('base64');
|
|
159
|
-
};
|
|
160
149
|
const getSignedSessionId = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
161
150
|
const sessionId = user$1 === null || user$1 === void 0 ? void 0 : user$1.sessionId;
|
|
162
151
|
if (!sessionId) {
|
|
@@ -169,7 +158,7 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
|
169
158
|
if (!(decodedSessionKeys === null || decodedSessionKeys === void 0 ? void 0 : decodedSessionKeys.privateKeyJwk)) {
|
|
170
159
|
throw new Error('Private key JWK not found');
|
|
171
160
|
}
|
|
172
|
-
const signedSessionId = yield
|
|
161
|
+
const signedSessionId = yield keyService.p256Sign(decodedSessionKeys.privateKeyJwk, sessionId);
|
|
173
162
|
return signedSessionId;
|
|
174
163
|
});
|
|
175
164
|
const removeSessionKey = React.useCallback(() => {
|
|
@@ -4,7 +4,7 @@ import { useCallback } from 'react';
|
|
|
4
4
|
import { tracing, StorageService, InvalidEmbeddedWalletSessionKeyError } from '@dynamic-labs/utils';
|
|
5
5
|
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
6
6
|
import { SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS } from '../../constants/localStorage.js';
|
|
7
|
-
import { p256Sign, p256Keygen } from '
|
|
7
|
+
import { p256Sign, toEncodedFormat, p256Keygen } from '../../functions/keyService/keyService.js';
|
|
8
8
|
import '@dynamic-labs/sdk-api-core';
|
|
9
9
|
import '../../../config/ApiEndpoint.js';
|
|
10
10
|
import '../../../store/state/projectSettings/projectSettings.js';
|
|
@@ -142,17 +142,6 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
|
142
142
|
// the user is undefined at this point in the auth flow and we cant check the users wallet version
|
|
143
143
|
// so we just return true for now
|
|
144
144
|
const shouldRegisterSessionKeysOnSignin = () => true;
|
|
145
|
-
const toEncodedFormat = (publicKey, privateKey, privateKeyJwk, registered, expirationDate) => {
|
|
146
|
-
const sessionKeys = {
|
|
147
|
-
expirationDate,
|
|
148
|
-
privateKey,
|
|
149
|
-
privateKeyJwk,
|
|
150
|
-
publicKey,
|
|
151
|
-
registered,
|
|
152
|
-
};
|
|
153
|
-
const sessionKeysString = JSON.stringify(sessionKeys);
|
|
154
|
-
return Buffer.from(sessionKeysString).toString('base64');
|
|
155
|
-
};
|
|
156
145
|
const getSignedSessionId = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
157
146
|
const sessionId = user === null || user === void 0 ? void 0 : user.sessionId;
|
|
158
147
|
if (!sessionId) {
|
package/src/lib/utils/hooks/useFundWithWallet/useChooseLinkedWallet/useChooseLinkedWallet.cjs
CHANGED
|
@@ -102,7 +102,7 @@ var useInternalDynamicContext = require('../../../../context/DynamicContext/useD
|
|
|
102
102
|
const useChooseLinkedWallet = () => {
|
|
103
103
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
104
104
|
const { setShowDynamicUserProfile } = useInternalDynamicContext.useInternalDynamicContext();
|
|
105
|
-
const userWallets = UserWalletsContext.
|
|
105
|
+
const { userWallets } = UserWalletsContext.useInternalUserWallets();
|
|
106
106
|
const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
107
107
|
const filteredWallets = React.useMemo(() => userWallets.filter((wallet) => wallet.id !== (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id) &&
|
|
108
108
|
wallet.chain === (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain)), [userWallets, primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain, primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id]);
|
package/src/lib/utils/hooks/useFundWithWallet/useChooseLinkedWallet/useChooseLinkedWallet.js
CHANGED
|
@@ -29,7 +29,7 @@ import '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
|
29
29
|
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
30
30
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
31
31
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
32
|
-
import {
|
|
32
|
+
import { useInternalUserWallets } from '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
33
33
|
import '../../../../events/dynamicEvents.js';
|
|
34
34
|
import '../../../../store/state/authMode/authMode.js';
|
|
35
35
|
import '../../../../context/VerificationContext/VerificationContext.js';
|
|
@@ -98,7 +98,7 @@ import { useInternalDynamicContext } from '../../../../context/DynamicContext/us
|
|
|
98
98
|
const useChooseLinkedWallet = () => {
|
|
99
99
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
100
100
|
const { setShowDynamicUserProfile } = useInternalDynamicContext();
|
|
101
|
-
const userWallets =
|
|
101
|
+
const { userWallets } = useInternalUserWallets();
|
|
102
102
|
const { primaryWallet } = useInternalDynamicContext();
|
|
103
103
|
const filteredWallets = useMemo(() => userWallets.filter((wallet) => wallet.id !== (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id) &&
|
|
104
104
|
wallet.chain === (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain)), [userWallets, primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain, primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id]);
|
|
@@ -107,7 +107,7 @@ var useInternalDynamicContext = require('../../../../context/DynamicContext/useD
|
|
|
107
107
|
const useConnectWalletForFunding = () => {
|
|
108
108
|
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
109
109
|
const { clearStackAndPush } = ViewContext.useViewContext();
|
|
110
|
-
const userWallets = UserWalletsContext.
|
|
110
|
+
const { userWallets } = UserWalletsContext.useInternalUserWallets();
|
|
111
111
|
const initiatedByWidgetRef = React.useRef(false);
|
|
112
112
|
const { walletOptions: walletOptions$1 } = useWalletOptions.useWalletOptions();
|
|
113
113
|
const internalConnectionPromiseRef = React.useRef(null);
|
|
@@ -29,7 +29,7 @@ import '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
|
29
29
|
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
30
30
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
31
31
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
32
|
-
import {
|
|
32
|
+
import { useInternalUserWallets } from '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
33
33
|
import { dynamicEvents } from '../../../../events/dynamicEvents.js';
|
|
34
34
|
import '../../../../store/state/authMode/authMode.js';
|
|
35
35
|
import '../../../../context/VerificationContext/VerificationContext.js';
|
|
@@ -103,7 +103,7 @@ import { useInternalDynamicContext } from '../../../../context/DynamicContext/us
|
|
|
103
103
|
const useConnectWalletForFunding = () => {
|
|
104
104
|
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext();
|
|
105
105
|
const { clearStackAndPush } = useViewContext();
|
|
106
|
-
const userWallets =
|
|
106
|
+
const { userWallets } = useInternalUserWallets();
|
|
107
107
|
const initiatedByWidgetRef = useRef(false);
|
|
108
108
|
const { walletOptions } = useWalletOptions();
|
|
109
109
|
const internalConnectionPromiseRef = useRef(null);
|
|
@@ -32,6 +32,7 @@ require('../../../locale/locale.cjs');
|
|
|
32
32
|
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
33
33
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
34
34
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
35
|
+
var usingV3Wallets = require('../../functions/usingV3Wallets/usingV3Wallets.cjs');
|
|
35
36
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
36
37
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
37
38
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -42,7 +43,6 @@ require('../../functions/compareChains/compareChains.cjs');
|
|
|
42
43
|
require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
43
44
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
44
45
|
var useSmartWallets = require('../useSmartWallets/useSmartWallets.cjs');
|
|
45
|
-
var usingV3Wallets = require('../../functions/usingV3Wallets/usingV3Wallets.cjs');
|
|
46
46
|
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
47
47
|
require('bs58');
|
|
48
48
|
require('@dynamic-labs/types');
|
|
@@ -28,6 +28,7 @@ import '../../../locale/locale.js';
|
|
|
28
28
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
29
29
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
30
30
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
31
|
+
import { usingV3Wallets } from '../../functions/usingV3Wallets/usingV3Wallets.js';
|
|
31
32
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
32
33
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
33
34
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -38,7 +39,6 @@ import '../../functions/compareChains/compareChains.js';
|
|
|
38
39
|
import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
39
40
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
40
41
|
import { useSmartWallets } from '../useSmartWallets/useSmartWallets.js';
|
|
41
|
-
import { usingV3Wallets } from '../../functions/usingV3Wallets/usingV3Wallets.js';
|
|
42
42
|
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
43
43
|
import 'bs58';
|
|
44
44
|
import '@dynamic-labs/types';
|
|
@@ -99,11 +99,13 @@ var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
|
|
|
99
99
|
var apiUrl = require('../../constants/waas/apiUrl.cjs');
|
|
100
100
|
require('../../../store/state/tokenBalances.cjs');
|
|
101
101
|
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
102
|
+
var useClientSessionKeys = require('../useClientSessionKeys/useClientSessionKeys.cjs');
|
|
102
103
|
|
|
103
104
|
const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSettings) => {
|
|
104
105
|
const apiBaseUrl = dynamicContextProps.useApiBaseUrl();
|
|
105
106
|
const authToken = getMinAuthToken.getMinAuthToken();
|
|
106
|
-
const { registerEmbeddedWalletSessionKey, removeSessionKey
|
|
107
|
+
const { registerEmbeddedWalletSessionKey, removeSessionKey } = useEmbeddedWalletSessionKeys.useEmbeddedWalletSessionKeys({ environmentId, projectSettings });
|
|
108
|
+
const { getSignedSessionId } = useClientSessionKeys.useClientSessionKeys();
|
|
107
109
|
if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
108
110
|
return;
|
|
109
111
|
walletOptions.forEach((walletOption) => {
|
|
@@ -95,11 +95,13 @@ import { configWaasWalletConnector } from '../useDynamicWaas/useDynamicWaas.js';
|
|
|
95
95
|
import { DEFAULT_WAAS_API_URL } from '../../constants/waas/apiUrl.js';
|
|
96
96
|
import '../../../store/state/tokenBalances.js';
|
|
97
97
|
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
98
|
+
import { useClientSessionKeys } from '../useClientSessionKeys/useClientSessionKeys.js';
|
|
98
99
|
|
|
99
100
|
const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSettings) => {
|
|
100
101
|
const apiBaseUrl = useApiBaseUrl();
|
|
101
102
|
const authToken = getMinAuthToken();
|
|
102
|
-
const { registerEmbeddedWalletSessionKey, removeSessionKey
|
|
103
|
+
const { registerEmbeddedWalletSessionKey, removeSessionKey } = useEmbeddedWalletSessionKeys({ environmentId, projectSettings });
|
|
104
|
+
const { getSignedSessionId } = useClientSessionKeys();
|
|
103
105
|
if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
104
106
|
return;
|
|
105
107
|
walletOptions.forEach((walletOption) => {
|
|
@@ -126,7 +126,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
126
126
|
const useSwitchWallet = () => {
|
|
127
127
|
const { setPrimaryWallet, user, primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
128
128
|
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
129
|
-
const userWallets = UserWalletsContext.
|
|
129
|
+
const { userWallets } = UserWalletsContext.useInternalUserWallets();
|
|
130
130
|
return React.useCallback((walletId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
131
131
|
var _a, _b, _c;
|
|
132
132
|
const wallet = userWallets.find((wallet) => wallet.id === walletId);
|