@dynamic-labs/sdk-react-core 4.59.1 → 4.60.0
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 +23 -0
- package/package.cjs +2 -1
- package/package.js +2 -1
- package/package.json +13 -12
- package/src/index.cjs +4 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
- package/src/lib/components/FormFieldLabel/FormFieldLabel.cjs +5 -1
- package/src/lib/components/FormFieldLabel/FormFieldLabel.d.ts +2 -1
- package/src/lib/components/FormFieldLabel/FormFieldLabel.js +5 -1
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +4 -2
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +4 -2
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/events/embeddedWallet.d.ts +15 -3
- package/src/lib/shared/assets/index.d.ts +1 -1
- package/src/lib/shared/assets/setup-password-terms-illustration.cjs +83 -0
- package/src/lib/shared/assets/setup-password-terms-illustration.js +59 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/index.d.ts +4 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +48 -6
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +8 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +49 -7
- package/src/lib/utils/hooks/useGetPasswordForSigning/index.d.ts +2 -0
- package/src/lib/utils/hooks/useGetPasswordForSigning/useGetPasswordForSigning.cjs +16 -0
- package/src/lib/utils/hooks/useGetPasswordForSigning/useGetPasswordForSigning.d.ts +5 -0
- package/src/lib/utils/hooks/useGetPasswordForSigning/useGetPasswordForSigning.js +12 -0
- package/src/lib/utils/hooks/usePromptWalletUnlock/index.d.ts +2 -0
- package/src/lib/utils/hooks/usePromptWalletUnlock/usePromptWalletUnlock.cjs +144 -0
- package/src/lib/utils/hooks/usePromptWalletUnlock/usePromptWalletUnlock.d.ts +5 -0
- package/src/lib/utils/hooks/usePromptWalletUnlock/usePromptWalletUnlock.js +140 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +14 -14
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +14 -14
- package/src/lib/utils/hooks/useSetupPassword/useSetupPassword.cjs +13 -100
- package/src/lib/utils/hooks/useSetupPassword/useSetupPassword.js +13 -100
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +10 -3
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +10 -3
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +2 -1
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +3 -2
- package/src/lib/utils/hooks/useWalletUnlock/index.d.ts +2 -0
- package/src/lib/utils/hooks/useWalletUnlock/useWalletUnlock.d.ts +15 -0
- package/src/lib/views/NoAccess/NoAccess.cjs +1 -1
- package/src/lib/views/NoAccess/NoAccess.js +1 -1
- package/src/lib/views/{SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.cjs → UnlockWalletView/UnlockWalletView.cjs} +18 -13
- package/src/lib/views/UnlockWalletView/UnlockWalletView.d.ts +6 -0
- package/src/lib/views/{SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.js → UnlockWalletView/UnlockWalletView.js} +18 -13
- package/src/lib/views/UnlockWalletView/index.d.ts +2 -0
- package/src/lib/views/index.d.ts +3 -3
- package/src/lib/views/viewToComponentMap.cjs +3 -3
- package/src/lib/views/viewToComponentMap.d.ts +1 -1
- package/src/lib/views/viewToComponentMap.js +3 -3
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +43 -43
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +43 -43
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +33 -19
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +33 -19
- package/src/lib/widgets/DynamicWidget/views/EnterPasswordView/EnterPasswordView.cjs +61 -0
- package/src/lib/widgets/DynamicWidget/views/EnterPasswordView/EnterPasswordView.d.ts +9 -0
- package/src/lib/widgets/DynamicWidget/views/EnterPasswordView/EnterPasswordView.js +57 -0
- package/src/lib/widgets/DynamicWidget/views/EnterPasswordView/index.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordTermsView/SetupPasswordTermsView.cjs +2 -3
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordTermsView/SetupPasswordTermsView.js +2 -3
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.cjs +13 -6
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.js +13 -6
- package/src/lib/widgets/DynamicWidget/views/index.d.ts +1 -0
- package/src/lib/shared/assets/warning-circle-orange.cjs +0 -57
- package/src/lib/shared/assets/warning-circle-orange.js +0 -33
- package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.d.ts +0 -2
- package/src/lib/views/SetupPasswordForWalletCreationView/index.d.ts +0 -1
|
@@ -100,3 +100,7 @@ export { CloudBackupProvider, isWalletBackedUp, useBackupWallets, useWalletBacku
|
|
|
100
100
|
export type { WalletBackupStatus, WalletOperationState, WalletToBackup, WalletWithBackupStatus, } from './useWalletBackup';
|
|
101
101
|
export { useRefreshAuth } from './useRefreshAuth';
|
|
102
102
|
export { useSetupPassword, PASSWORD_SETUP_CANCELLED_ERROR, } from './useSetupPassword';
|
|
103
|
+
export { useWalletUnlock } from './useWalletUnlock';
|
|
104
|
+
export type { UseWalletUnlockReturn, WalletUnlockState, } from './useWalletUnlock';
|
|
105
|
+
export { usePromptWalletUnlock } from './usePromptWalletUnlock';
|
|
106
|
+
export { useGetPasswordForSigning } from './useGetPasswordForSigning';
|
|
@@ -105,6 +105,7 @@ var useRefreshAuth = require('../useRefreshAuth/useRefreshAuth.cjs');
|
|
|
105
105
|
var apiUrl = require('../../constants/waas/apiUrl.cjs');
|
|
106
106
|
var useClientSessionKeys = require('../useClientSessionKeys/useClientSessionKeys.cjs');
|
|
107
107
|
var useGetMfaToken = require('../useGetMfaToken/useGetMfaToken.cjs');
|
|
108
|
+
var useGetPasswordForSigning = require('../useGetPasswordForSigning/useGetPasswordForSigning.cjs');
|
|
108
109
|
var constants = require('./constants.cjs');
|
|
109
110
|
var normalizeWalletRequirements = require('./normalizeWalletRequirements.cjs');
|
|
110
111
|
require('../../../store/state/sendBalances.cjs');
|
|
@@ -122,7 +123,7 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
122
123
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
123
124
|
|
|
124
125
|
const dynamicWaasKey = 'dynamicwaas';
|
|
125
|
-
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, svmGasSponsorshipEnabled = false, }) => {
|
|
126
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, getPasswordForSigning, svmGasSponsorshipEnabled = false, }) => {
|
|
126
127
|
var _a;
|
|
127
128
|
walletConnector.setEnvironmentId(environmentId);
|
|
128
129
|
walletConnector.setBaseApiUrl((_a = (apiBaseUrl || apiUrl.DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
|
|
@@ -138,6 +139,10 @@ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl,
|
|
|
138
139
|
walletConnector.setRelayUrl(relayUrl);
|
|
139
140
|
walletConnector.setGetMfaTokenFunction(getMfaToken);
|
|
140
141
|
walletConnector.setBaseClientKeysharesRelayApiUrl(baseClientKeysharesRelayApiUrl);
|
|
142
|
+
// Set password provider for locked wallets
|
|
143
|
+
if (getPasswordForSigning) {
|
|
144
|
+
walletConnector.setGetPasswordForSigningFunction(getPasswordForSigning);
|
|
145
|
+
}
|
|
141
146
|
// Sync SVM gas sponsorship setting for SOL connectors
|
|
142
147
|
const isSolConnector = walletConnector.connectedChain === 'SOL';
|
|
143
148
|
const supportsSponsorshipSetting = 'setSvmGasSponsorshipEnabled' in walletConnector;
|
|
@@ -170,8 +175,10 @@ const useDynamicWaas = () => {
|
|
|
170
175
|
const authToken = getMinAuthToken.getMinAuthToken();
|
|
171
176
|
const { getSignedSessionId } = useClientSessionKeys.useClientSessionKeys();
|
|
172
177
|
const getMfaToken = useGetMfaToken.useGetMfaToken();
|
|
178
|
+
const getPasswordForSigning = useGetPasswordForSigning.useGetPasswordForSigning();
|
|
173
179
|
const isCookieAuthEnabled = projectSettings && isCookieEnabled.isCookieEnabled();
|
|
174
180
|
const isUpgrading = React.useRef(false);
|
|
181
|
+
const [recoveredWallets, setRecoveredWallets] = React.useState(() => new Set());
|
|
175
182
|
const getWaasWalletConnector = React.useCallback((chainName) => {
|
|
176
183
|
var _a;
|
|
177
184
|
if (!isCookieAuthEnabled && !authToken) {
|
|
@@ -190,6 +197,7 @@ const useDynamicWaas = () => {
|
|
|
190
197
|
baseClientKeysharesRelayApiUrl,
|
|
191
198
|
environmentId,
|
|
192
199
|
getMfaToken,
|
|
200
|
+
getPasswordForSigning,
|
|
193
201
|
getSignedSessionId,
|
|
194
202
|
relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
|
|
195
203
|
svmGasSponsorshipEnabled,
|
|
@@ -203,6 +211,7 @@ const useDynamicWaas = () => {
|
|
|
203
211
|
environmentId,
|
|
204
212
|
apiBaseUrl,
|
|
205
213
|
getMfaToken,
|
|
214
|
+
getPasswordForSigning,
|
|
206
215
|
getSignedSessionId,
|
|
207
216
|
relayUrl,
|
|
208
217
|
baseClientKeysharesRelayApiUrl,
|
|
@@ -232,14 +241,23 @@ const useDynamicWaas = () => {
|
|
|
232
241
|
return;
|
|
233
242
|
try {
|
|
234
243
|
const initializationStart = new Date().getTime();
|
|
235
|
-
|
|
244
|
+
const userWaasWallets = user.verifiedCredentials.filter((vc) => vc.walletName === dynamicWaasKey && vc.address && vc.chain);
|
|
245
|
+
const chainsWithWallets = [
|
|
246
|
+
...new Set(userWaasWallets.map((vc) => { var _a; return values.VerifiedCredentialNameToChainEnum[(_a = vc.chain) !== null && _a !== void 0 ? _a : '']; })),
|
|
247
|
+
].filter(Boolean);
|
|
248
|
+
// Combine enabled chains with chains that have wallets
|
|
249
|
+
// This ensures we initialize clients for enabled chains AND recover wallets from any other chains
|
|
250
|
+
const allChainsToProcess = [
|
|
251
|
+
...new Set([...(enabledChainNames || []), ...chainsWithWallets]),
|
|
252
|
+
];
|
|
253
|
+
yield Promise.all(allChainsToProcess.map((chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
236
254
|
const walletConnector = getWaasWalletConnector(chain);
|
|
237
255
|
if (!walletConnector)
|
|
238
256
|
return;
|
|
239
257
|
// Filter for waas wallets on this chain
|
|
240
258
|
const waasWallets = user.verifiedCredentials.filter((credential) => {
|
|
241
259
|
var _a;
|
|
242
|
-
return credential.walletName ===
|
|
260
|
+
return credential.walletName === dynamicWaasKey &&
|
|
243
261
|
credential.address &&
|
|
244
262
|
values.VerifiedCredentialNameToChainEnum[(_a = credential.chain) !== null && _a !== void 0 ? _a : ''] ===
|
|
245
263
|
walletConnector.connectedChain;
|
|
@@ -292,6 +310,13 @@ const useDynamicWaas = () => {
|
|
|
292
310
|
time: totalElapsedTime,
|
|
293
311
|
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
294
312
|
});
|
|
313
|
+
// Track successfully recovered wallet
|
|
314
|
+
setRecoveredWallets((prev) => {
|
|
315
|
+
var _a;
|
|
316
|
+
const next = new Set(prev);
|
|
317
|
+
next.add((_a = wallet.address) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
318
|
+
return next;
|
|
319
|
+
});
|
|
295
320
|
}
|
|
296
321
|
catch (error) {
|
|
297
322
|
walletConnectorCore.logger.warn('[useDynamicWaas] Error restoring wallet keyshare', {
|
|
@@ -627,20 +652,37 @@ const useDynamicWaas = () => {
|
|
|
627
652
|
}
|
|
628
653
|
yield refresh();
|
|
629
654
|
}), [user, getWaasWalletConnector, refresh]);
|
|
630
|
-
|
|
655
|
+
// Get wallets that need settings processing
|
|
656
|
+
const walletsNeedingSettings = React.useMemo(() => {
|
|
631
657
|
if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials) || !dynamicWaasIsEnabled) {
|
|
632
|
-
return
|
|
658
|
+
return [];
|
|
633
659
|
}
|
|
634
|
-
return user.verifiedCredentials.
|
|
660
|
+
return user.verifiedCredentials.filter((vc) => {
|
|
635
661
|
var _a;
|
|
636
662
|
return vc.walletName === 'dynamicwaas' &&
|
|
663
|
+
vc.address &&
|
|
637
664
|
((_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings) &&
|
|
638
665
|
(vc.walletProperties.settings.shouldRefreshOnNextSignOn ||
|
|
639
666
|
vc.walletProperties.settings.reshareOnNextSignOn ||
|
|
640
667
|
vc.walletProperties.settings.revokeOnNextSignOn);
|
|
641
668
|
});
|
|
642
669
|
}, [user, dynamicWaasIsEnabled]);
|
|
670
|
+
// Derived from walletsNeedingSettings for backward compatibility
|
|
671
|
+
const needsSettingsProcessing = walletsNeedingSettings.length > 0;
|
|
672
|
+
// Check if all wallets needing settings have been recovered
|
|
673
|
+
const areWalletsReadyForSettings = React.useCallback(() => {
|
|
674
|
+
if (walletsNeedingSettings.length === 0) {
|
|
675
|
+
return false;
|
|
676
|
+
}
|
|
677
|
+
return walletsNeedingSettings.every((wallet) => { var _a; return recoveredWallets.has((_a = wallet.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
|
|
678
|
+
}, [walletsNeedingSettings, recoveredWallets]);
|
|
679
|
+
// Clear recovered wallets tracking (call on logout)
|
|
680
|
+
const clearRecoveredWallets = React.useCallback(() => {
|
|
681
|
+
setRecoveredWallets(new Set());
|
|
682
|
+
}, []);
|
|
643
683
|
return {
|
|
684
|
+
areWalletsReadyForSettings,
|
|
685
|
+
clearRecoveredWallets,
|
|
644
686
|
createWalletAccount,
|
|
645
687
|
dynamicWaasIsEnabled,
|
|
646
688
|
getWaasWalletConnector,
|
|
@@ -12,7 +12,11 @@ export type WalletCreationRequirement = {
|
|
|
12
12
|
network?: string;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type GetPasswordForSigningFn = (props: {
|
|
16
|
+
accountAddress: string;
|
|
17
|
+
chainName: string;
|
|
18
|
+
}) => Promise<string | undefined>;
|
|
19
|
+
export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode, getSignedSessionId, getMfaToken, getPasswordForSigning, svmGasSponsorshipEnabled, }: {
|
|
16
20
|
walletConnector: IDynamicWaasConnector;
|
|
17
21
|
environmentId: string;
|
|
18
22
|
apiBaseUrl: string;
|
|
@@ -23,9 +27,12 @@ export declare const configWaasWalletConnector: ({ walletConnector, environmentI
|
|
|
23
27
|
getMfaToken: (props?: {
|
|
24
28
|
mfaAction?: MFAAction;
|
|
25
29
|
}) => Promise<string | undefined>;
|
|
30
|
+
getPasswordForSigning?: GetPasswordForSigningFn;
|
|
26
31
|
svmGasSponsorshipEnabled?: boolean;
|
|
27
32
|
}) => IDynamicWaasConnector;
|
|
28
33
|
export declare const useDynamicWaas: () => {
|
|
34
|
+
areWalletsReadyForSettings: () => boolean;
|
|
35
|
+
clearRecoveredWallets: () => void;
|
|
29
36
|
createWalletAccount: (requirementsOrChainNames: WalletCreationRequirement[] | ChainEnum[], password?: string, bitcoinConfig?: {
|
|
30
37
|
addressType?: string;
|
|
31
38
|
network?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { useRef, useCallback, useMemo } from 'react';
|
|
3
|
+
import { useRef, useState, useCallback, useMemo } from 'react';
|
|
4
4
|
import { EmbeddedWalletVersionEnum, JwtVerifiedCredentialFormatEnum, WalletProviderEnum, ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
6
|
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
@@ -101,6 +101,7 @@ import { useRefreshAuth } from '../useRefreshAuth/useRefreshAuth.js';
|
|
|
101
101
|
import { DEFAULT_WAAS_API_URL } from '../../constants/waas/apiUrl.js';
|
|
102
102
|
import { useClientSessionKeys } from '../useClientSessionKeys/useClientSessionKeys.js';
|
|
103
103
|
import { useGetMfaToken } from '../useGetMfaToken/useGetMfaToken.js';
|
|
104
|
+
import { useGetPasswordForSigning } from '../useGetPasswordForSigning/useGetPasswordForSigning.js';
|
|
104
105
|
import { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, NO_ENABLED_CHAINS_ERROR, INVALID_CHAINS_ERROR, WALLET_CREATION_FAILED_ERROR } from './constants.js';
|
|
105
106
|
import { normalizeWalletRequirements } from './normalizeWalletRequirements.js';
|
|
106
107
|
import '../../../store/state/sendBalances.js';
|
|
@@ -118,7 +119,7 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
118
119
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
119
120
|
|
|
120
121
|
const dynamicWaasKey = 'dynamicwaas';
|
|
121
|
-
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, svmGasSponsorshipEnabled = false, }) => {
|
|
122
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, getPasswordForSigning, svmGasSponsorshipEnabled = false, }) => {
|
|
122
123
|
var _a;
|
|
123
124
|
walletConnector.setEnvironmentId(environmentId);
|
|
124
125
|
walletConnector.setBaseApiUrl((_a = (apiBaseUrl || DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
|
|
@@ -134,6 +135,10 @@ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl,
|
|
|
134
135
|
walletConnector.setRelayUrl(relayUrl);
|
|
135
136
|
walletConnector.setGetMfaTokenFunction(getMfaToken);
|
|
136
137
|
walletConnector.setBaseClientKeysharesRelayApiUrl(baseClientKeysharesRelayApiUrl);
|
|
138
|
+
// Set password provider for locked wallets
|
|
139
|
+
if (getPasswordForSigning) {
|
|
140
|
+
walletConnector.setGetPasswordForSigningFunction(getPasswordForSigning);
|
|
141
|
+
}
|
|
137
142
|
// Sync SVM gas sponsorship setting for SOL connectors
|
|
138
143
|
const isSolConnector = walletConnector.connectedChain === 'SOL';
|
|
139
144
|
const supportsSponsorshipSetting = 'setSvmGasSponsorshipEnabled' in walletConnector;
|
|
@@ -166,8 +171,10 @@ const useDynamicWaas = () => {
|
|
|
166
171
|
const authToken = getMinAuthToken();
|
|
167
172
|
const { getSignedSessionId } = useClientSessionKeys();
|
|
168
173
|
const getMfaToken = useGetMfaToken();
|
|
174
|
+
const getPasswordForSigning = useGetPasswordForSigning();
|
|
169
175
|
const isCookieAuthEnabled = projectSettings && isCookieEnabled();
|
|
170
176
|
const isUpgrading = useRef(false);
|
|
177
|
+
const [recoveredWallets, setRecoveredWallets] = useState(() => new Set());
|
|
171
178
|
const getWaasWalletConnector = useCallback((chainName) => {
|
|
172
179
|
var _a;
|
|
173
180
|
if (!isCookieAuthEnabled && !authToken) {
|
|
@@ -186,6 +193,7 @@ const useDynamicWaas = () => {
|
|
|
186
193
|
baseClientKeysharesRelayApiUrl,
|
|
187
194
|
environmentId,
|
|
188
195
|
getMfaToken,
|
|
196
|
+
getPasswordForSigning,
|
|
189
197
|
getSignedSessionId,
|
|
190
198
|
relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
|
|
191
199
|
svmGasSponsorshipEnabled,
|
|
@@ -199,6 +207,7 @@ const useDynamicWaas = () => {
|
|
|
199
207
|
environmentId,
|
|
200
208
|
apiBaseUrl,
|
|
201
209
|
getMfaToken,
|
|
210
|
+
getPasswordForSigning,
|
|
202
211
|
getSignedSessionId,
|
|
203
212
|
relayUrl,
|
|
204
213
|
baseClientKeysharesRelayApiUrl,
|
|
@@ -228,14 +237,23 @@ const useDynamicWaas = () => {
|
|
|
228
237
|
return;
|
|
229
238
|
try {
|
|
230
239
|
const initializationStart = new Date().getTime();
|
|
231
|
-
|
|
240
|
+
const userWaasWallets = user.verifiedCredentials.filter((vc) => vc.walletName === dynamicWaasKey && vc.address && vc.chain);
|
|
241
|
+
const chainsWithWallets = [
|
|
242
|
+
...new Set(userWaasWallets.map((vc) => { var _a; return VerifiedCredentialNameToChainEnum[(_a = vc.chain) !== null && _a !== void 0 ? _a : '']; })),
|
|
243
|
+
].filter(Boolean);
|
|
244
|
+
// Combine enabled chains with chains that have wallets
|
|
245
|
+
// This ensures we initialize clients for enabled chains AND recover wallets from any other chains
|
|
246
|
+
const allChainsToProcess = [
|
|
247
|
+
...new Set([...(enabledChainNames || []), ...chainsWithWallets]),
|
|
248
|
+
];
|
|
249
|
+
yield Promise.all(allChainsToProcess.map((chain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
232
250
|
const walletConnector = getWaasWalletConnector(chain);
|
|
233
251
|
if (!walletConnector)
|
|
234
252
|
return;
|
|
235
253
|
// Filter for waas wallets on this chain
|
|
236
254
|
const waasWallets = user.verifiedCredentials.filter((credential) => {
|
|
237
255
|
var _a;
|
|
238
|
-
return credential.walletName ===
|
|
256
|
+
return credential.walletName === dynamicWaasKey &&
|
|
239
257
|
credential.address &&
|
|
240
258
|
VerifiedCredentialNameToChainEnum[(_a = credential.chain) !== null && _a !== void 0 ? _a : ''] ===
|
|
241
259
|
walletConnector.connectedChain;
|
|
@@ -288,6 +306,13 @@ const useDynamicWaas = () => {
|
|
|
288
306
|
time: totalElapsedTime,
|
|
289
307
|
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
290
308
|
});
|
|
309
|
+
// Track successfully recovered wallet
|
|
310
|
+
setRecoveredWallets((prev) => {
|
|
311
|
+
var _a;
|
|
312
|
+
const next = new Set(prev);
|
|
313
|
+
next.add((_a = wallet.address) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
314
|
+
return next;
|
|
315
|
+
});
|
|
291
316
|
}
|
|
292
317
|
catch (error) {
|
|
293
318
|
logger.warn('[useDynamicWaas] Error restoring wallet keyshare', {
|
|
@@ -623,20 +648,37 @@ const useDynamicWaas = () => {
|
|
|
623
648
|
}
|
|
624
649
|
yield refresh();
|
|
625
650
|
}), [user, getWaasWalletConnector, refresh]);
|
|
626
|
-
|
|
651
|
+
// Get wallets that need settings processing
|
|
652
|
+
const walletsNeedingSettings = useMemo(() => {
|
|
627
653
|
if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials) || !dynamicWaasIsEnabled) {
|
|
628
|
-
return
|
|
654
|
+
return [];
|
|
629
655
|
}
|
|
630
|
-
return user.verifiedCredentials.
|
|
656
|
+
return user.verifiedCredentials.filter((vc) => {
|
|
631
657
|
var _a;
|
|
632
658
|
return vc.walletName === 'dynamicwaas' &&
|
|
659
|
+
vc.address &&
|
|
633
660
|
((_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings) &&
|
|
634
661
|
(vc.walletProperties.settings.shouldRefreshOnNextSignOn ||
|
|
635
662
|
vc.walletProperties.settings.reshareOnNextSignOn ||
|
|
636
663
|
vc.walletProperties.settings.revokeOnNextSignOn);
|
|
637
664
|
});
|
|
638
665
|
}, [user, dynamicWaasIsEnabled]);
|
|
666
|
+
// Derived from walletsNeedingSettings for backward compatibility
|
|
667
|
+
const needsSettingsProcessing = walletsNeedingSettings.length > 0;
|
|
668
|
+
// Check if all wallets needing settings have been recovered
|
|
669
|
+
const areWalletsReadyForSettings = useCallback(() => {
|
|
670
|
+
if (walletsNeedingSettings.length === 0) {
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
return walletsNeedingSettings.every((wallet) => { var _a; return recoveredWallets.has((_a = wallet.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
|
|
674
|
+
}, [walletsNeedingSettings, recoveredWallets]);
|
|
675
|
+
// Clear recovered wallets tracking (call on logout)
|
|
676
|
+
const clearRecoveredWallets = useCallback(() => {
|
|
677
|
+
setRecoveredWallets(new Set());
|
|
678
|
+
}, []);
|
|
639
679
|
return {
|
|
680
|
+
areWalletsReadyForSettings,
|
|
681
|
+
clearRecoveredWallets,
|
|
640
682
|
createWalletAccount,
|
|
641
683
|
dynamicWaasIsEnabled,
|
|
642
684
|
getWaasWalletConnector,
|
|
@@ -0,0 +1,16 @@
|
|
|
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 usePromptWalletUnlock = require('../usePromptWalletUnlock/usePromptWalletUnlock.cjs');
|
|
9
|
+
|
|
10
|
+
const useGetPasswordForSigning = () => {
|
|
11
|
+
const promptWalletUnlock = usePromptWalletUnlock.usePromptWalletUnlock();
|
|
12
|
+
const getPasswordForSigning = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ accountAddress, chainName, }) { return promptWalletUnlock({ accountAddress, chainName }); }), [promptWalletUnlock]);
|
|
13
|
+
return getPasswordForSigning;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.useGetPasswordForSigning = useGetPasswordForSigning;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { usePromptWalletUnlock } from '../usePromptWalletUnlock/usePromptWalletUnlock.js';
|
|
5
|
+
|
|
6
|
+
const useGetPasswordForSigning = () => {
|
|
7
|
+
const promptWalletUnlock = usePromptWalletUnlock();
|
|
8
|
+
const getPasswordForSigning = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ accountAddress, chainName, }) { return promptWalletUnlock({ accountAddress, chainName }); }), [promptWalletUnlock]);
|
|
9
|
+
return getPasswordForSigning;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { useGetPasswordForSigning };
|
|
@@ -0,0 +1,144 @@
|
|
|
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 utils = require('@dynamic-labs/utils');
|
|
9
|
+
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
10
|
+
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
11
|
+
require('@dynamic-labs/iconic');
|
|
12
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
13
|
+
require('react/jsx-runtime');
|
|
14
|
+
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
require('../../../shared/logger.cjs');
|
|
16
|
+
require('@dynamic-labs/wallet-book');
|
|
17
|
+
require('../../constants/colors.cjs');
|
|
18
|
+
require('../../constants/values.cjs');
|
|
19
|
+
require('@dynamic-labs/sdk-api-core');
|
|
20
|
+
require('../../../shared/consts/index.cjs');
|
|
21
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
22
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
|
+
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
|
+
require('@dynamic-labs/multi-wallet');
|
|
25
|
+
require('react-international-phone');
|
|
26
|
+
require('../../../store/state/nonce/nonce.cjs');
|
|
27
|
+
require('@dynamic-labs-sdk/client/core');
|
|
28
|
+
require('../../../client/client.cjs');
|
|
29
|
+
require('@dynamic-labs-sdk/client');
|
|
30
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
31
|
+
require('@dynamic-labs/locale');
|
|
32
|
+
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
33
|
+
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
34
|
+
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
35
|
+
require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
36
|
+
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
37
|
+
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
38
|
+
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
39
|
+
require('../../../store/state/authMode/authMode.cjs');
|
|
40
|
+
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
41
|
+
require('react-dom');
|
|
42
|
+
require('../../functions/compareChains/compareChains.cjs');
|
|
43
|
+
require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
44
|
+
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
45
|
+
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
46
|
+
require('bs58');
|
|
47
|
+
require('@dynamic-labs/types');
|
|
48
|
+
require('../../../context/SocialRedirectContext/SocialRedirectContext.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/walletOptions/walletOptions.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('../useWalletBackup/useWalletBackup.cjs');
|
|
81
|
+
require('../useWalletBackup/types.cjs');
|
|
82
|
+
require('../useWalletBackup/cloudProviders.cjs');
|
|
83
|
+
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
84
|
+
require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
85
|
+
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
86
|
+
require('@hcaptcha/react-hcaptcha');
|
|
87
|
+
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
88
|
+
require('../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs');
|
|
89
|
+
require('../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
|
|
90
|
+
require('../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
91
|
+
require('../../../context/FooterAnimationContext/index.cjs');
|
|
92
|
+
require('../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
93
|
+
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
94
|
+
require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
95
|
+
require('../../../store/state/sendBalances.cjs');
|
|
96
|
+
require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
97
|
+
require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
98
|
+
require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
99
|
+
require('../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
100
|
+
require('../../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs');
|
|
101
|
+
require('../../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.cjs');
|
|
102
|
+
require('../../../../index.cjs');
|
|
103
|
+
require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
104
|
+
require('../../../store/state/tokenBalances.cjs');
|
|
105
|
+
require('../../../store/state/multichainBalances.cjs');
|
|
106
|
+
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
107
|
+
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
108
|
+
|
|
109
|
+
const usePromptWalletUnlock = () => {
|
|
110
|
+
const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
111
|
+
const { pushView } = ViewContext.useViewContext();
|
|
112
|
+
const promptWalletUnlock = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ accountAddress, chainName, }) {
|
|
113
|
+
const deferred = new utils.DeferredPromise();
|
|
114
|
+
setShowAuthFlow(true, { ignoreIfIsEmbeddedWidget: false });
|
|
115
|
+
pushView('unlock-wallet', { accountAddress, chainName });
|
|
116
|
+
const passwordProvidedHandler = (payload) => {
|
|
117
|
+
if (payload.accountAddress === accountAddress &&
|
|
118
|
+
payload.chainName === chainName) {
|
|
119
|
+
deferred.resolve(payload.password);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
dynamicEvents.dynamicEvents.on('walletUnlockPasswordProvided', passwordProvidedHandler);
|
|
123
|
+
const cancelledHandler = (payload) => {
|
|
124
|
+
if (payload.accountAddress === accountAddress &&
|
|
125
|
+
payload.chainName === chainName) {
|
|
126
|
+
deferred.resolve(undefined);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
dynamicEvents.dynamicEvents.on('walletUnlockCancelled', cancelledHandler);
|
|
130
|
+
const authFlowCloseHandler = () => {
|
|
131
|
+
deferred.resolve(undefined);
|
|
132
|
+
};
|
|
133
|
+
dynamicEvents.dynamicEvents.on('authFlowClose', authFlowCloseHandler);
|
|
134
|
+
deferred.promise.finally(() => {
|
|
135
|
+
dynamicEvents.dynamicEvents.off('walletUnlockPasswordProvided', passwordProvidedHandler);
|
|
136
|
+
dynamicEvents.dynamicEvents.off('walletUnlockCancelled', cancelledHandler);
|
|
137
|
+
dynamicEvents.dynamicEvents.off('authFlowClose', authFlowCloseHandler);
|
|
138
|
+
});
|
|
139
|
+
return deferred.promise;
|
|
140
|
+
}), [setShowAuthFlow, pushView]);
|
|
141
|
+
return promptWalletUnlock;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
exports.usePromptWalletUnlock = usePromptWalletUnlock;
|