@dynamic-labs/sdk-react-core 4.91.0 → 4.91.2
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 +43 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -13
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +34 -6
- package/src/lib/components/SendBalanceForm/SendBalanceForm.d.ts +2 -1
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +35 -7
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +2 -2
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +2 -2
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.cjs +8 -7
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.d.ts +3 -1
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.js +8 -7
- package/src/lib/modals/SignMessageConfirmationModal/getProperErrorMessage.cjs +3 -0
- package/src/lib/modals/SignMessageConfirmationModal/getProperErrorMessage.js +3 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +21 -3
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +7 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +21 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +5 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.d.ts +1 -1
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +5 -3
- package/src/lib/utils/hooks/useSyncEmbeddedWalletFlow/useSyncEmbeddedWalletFlow.cjs +1 -1
- package/src/lib/utils/hooks/useSyncEmbeddedWalletFlow/useSyncEmbeddedWalletFlow.js +1 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +18 -11
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.d.ts +1 -0
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +18 -11
- package/src/lib/widgets/DynamicWidget/components/ActiveMidnightWalletBalance/ActiveMidnightWalletBalance.cjs +38 -11
- package/src/lib/widgets/DynamicWidget/components/ActiveMidnightWalletBalance/ActiveMidnightWalletBalance.js +38 -11
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.cjs +5 -2
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.js +5 -2
- package/src/lib/widgets/DynamicWidget/views/DepositView/DepositView.cjs +18 -2
- package/src/lib/widgets/DynamicWidget/views/DepositView/DepositView.js +18 -2
- package/src/lib/widgets/DynamicWidget/views/ExportAndRecoveryView/ExportAndRecoveryView.cjs +3 -1
- package/src/lib/widgets/DynamicWidget/views/ExportAndRecoveryView/ExportAndRecoveryView.js +3 -1
|
@@ -454,7 +454,24 @@ const useDynamicWaas = () => {
|
|
|
454
454
|
});
|
|
455
455
|
yield refresh();
|
|
456
456
|
});
|
|
457
|
-
const
|
|
457
|
+
const migrateFromFireblocks = (_h) => _tslib.__awaiter(void 0, [_h], void 0, function* ({ deviceId, jwt, password, storage, expectedAddresses, }) {
|
|
458
|
+
const [chainName] = enabledChainNames !== null && enabledChainNames !== void 0 ? enabledChainNames : [];
|
|
459
|
+
if (!chainName)
|
|
460
|
+
return undefined;
|
|
461
|
+
const walletConnector = getWaasWalletConnector(chainName);
|
|
462
|
+
if (!walletConnector)
|
|
463
|
+
return undefined;
|
|
464
|
+
const result = yield walletConnector.migrateFromFireblocks({
|
|
465
|
+
deviceId,
|
|
466
|
+
expectedAddresses,
|
|
467
|
+
jwt,
|
|
468
|
+
ncwStorage: storage,
|
|
469
|
+
walletPassword: password,
|
|
470
|
+
});
|
|
471
|
+
yield refresh();
|
|
472
|
+
return result;
|
|
473
|
+
});
|
|
474
|
+
const upgradeToDynamicWaas = React.useCallback((_j) => _tslib.__awaiter(void 0, [_j], void 0, function* ({ privateKey, wallet, password, }) {
|
|
458
475
|
isUpgrading.current = true;
|
|
459
476
|
if (!wallet) {
|
|
460
477
|
throw new utils.DynamicError('Wallet to upgrade was not provided');
|
|
@@ -534,14 +551,14 @@ const useDynamicWaas = () => {
|
|
|
534
551
|
values.VerifiedCredentialNameToChainEnum[cred.chain]);
|
|
535
552
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
|
|
536
553
|
const processSignOnWalletSettings = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
537
|
-
var
|
|
554
|
+
var _k;
|
|
538
555
|
if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials)) {
|
|
539
556
|
return;
|
|
540
557
|
}
|
|
541
558
|
const waasWallets = user.verifiedCredentials.filter((vc) => { var _a; return vc.walletName === 'dynamicwaas' && ((_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings); });
|
|
542
559
|
for (const wallet of waasWallets) {
|
|
543
560
|
try {
|
|
544
|
-
const settings = (
|
|
561
|
+
const settings = (_k = wallet.walletProperties) === null || _k === void 0 ? void 0 : _k.settings;
|
|
545
562
|
const { address, chain } = wallet;
|
|
546
563
|
if (!settings || !address || !chain) {
|
|
547
564
|
continue;
|
|
@@ -612,6 +629,7 @@ const useDynamicWaas = () => {
|
|
|
612
629
|
getWaasWalletsByCredentials,
|
|
613
630
|
importPrivateKey,
|
|
614
631
|
initializeWaas,
|
|
632
|
+
migrateFromFireblocks,
|
|
615
633
|
needsAutoCreateWalletChains,
|
|
616
634
|
needsSettingsProcessing,
|
|
617
635
|
processSignOnWalletSettings,
|
|
@@ -54,6 +54,13 @@ export declare const useDynamicWaas: () => {
|
|
|
54
54
|
initializeWaas: ({ forceClientRebuild, }?: {
|
|
55
55
|
forceClientRebuild?: boolean;
|
|
56
56
|
}) => Promise<void>;
|
|
57
|
+
migrateFromFireblocks: ({ deviceId, jwt, password, storage, expectedAddresses, }: {
|
|
58
|
+
deviceId: string;
|
|
59
|
+
jwt: string;
|
|
60
|
+
password: string;
|
|
61
|
+
storage: Record<string, string>;
|
|
62
|
+
expectedAddresses: Record<string, string>;
|
|
63
|
+
}) => Promise<import("@dynamic-labs-wallet/browser-wallet-client").MigrateFromFireblocksResponse | undefined>;
|
|
57
64
|
needsAutoCreateWalletChains: WalletCreationRequirement[];
|
|
58
65
|
needsSettingsProcessing: boolean;
|
|
59
66
|
processSignOnWalletSettings: () => Promise<void>;
|
|
@@ -450,7 +450,24 @@ const useDynamicWaas = () => {
|
|
|
450
450
|
});
|
|
451
451
|
yield refresh();
|
|
452
452
|
});
|
|
453
|
-
const
|
|
453
|
+
const migrateFromFireblocks = (_h) => __awaiter(void 0, [_h], void 0, function* ({ deviceId, jwt, password, storage, expectedAddresses, }) {
|
|
454
|
+
const [chainName] = enabledChainNames !== null && enabledChainNames !== void 0 ? enabledChainNames : [];
|
|
455
|
+
if (!chainName)
|
|
456
|
+
return undefined;
|
|
457
|
+
const walletConnector = getWaasWalletConnector(chainName);
|
|
458
|
+
if (!walletConnector)
|
|
459
|
+
return undefined;
|
|
460
|
+
const result = yield walletConnector.migrateFromFireblocks({
|
|
461
|
+
deviceId,
|
|
462
|
+
expectedAddresses,
|
|
463
|
+
jwt,
|
|
464
|
+
ncwStorage: storage,
|
|
465
|
+
walletPassword: password,
|
|
466
|
+
});
|
|
467
|
+
yield refresh();
|
|
468
|
+
return result;
|
|
469
|
+
});
|
|
470
|
+
const upgradeToDynamicWaas = useCallback((_j) => __awaiter(void 0, [_j], void 0, function* ({ privateKey, wallet, password, }) {
|
|
454
471
|
isUpgrading.current = true;
|
|
455
472
|
if (!wallet) {
|
|
456
473
|
throw new DynamicError('Wallet to upgrade was not provided');
|
|
@@ -530,14 +547,14 @@ const useDynamicWaas = () => {
|
|
|
530
547
|
VerifiedCredentialNameToChainEnum[cred.chain]);
|
|
531
548
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
|
|
532
549
|
const processSignOnWalletSettings = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
533
|
-
var
|
|
550
|
+
var _k;
|
|
534
551
|
if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials)) {
|
|
535
552
|
return;
|
|
536
553
|
}
|
|
537
554
|
const waasWallets = user.verifiedCredentials.filter((vc) => { var _a; return vc.walletName === 'dynamicwaas' && ((_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings); });
|
|
538
555
|
for (const wallet of waasWallets) {
|
|
539
556
|
try {
|
|
540
|
-
const settings = (
|
|
557
|
+
const settings = (_k = wallet.walletProperties) === null || _k === void 0 ? void 0 : _k.settings;
|
|
541
558
|
const { address, chain } = wallet;
|
|
542
559
|
if (!settings || !address || !chain) {
|
|
543
560
|
continue;
|
|
@@ -608,6 +625,7 @@ const useDynamicWaas = () => {
|
|
|
608
625
|
getWaasWalletsByCredentials,
|
|
609
626
|
importPrivateKey,
|
|
610
627
|
initializeWaas,
|
|
628
|
+
migrateFromFireblocks,
|
|
611
629
|
needsAutoCreateWalletChains,
|
|
612
630
|
needsSettingsProcessing,
|
|
613
631
|
processSignOnWalletSettings,
|
|
@@ -63,9 +63,10 @@ const useEmbeddedReveal = () => {
|
|
|
63
63
|
throw new Error('Wallet is non-HD and does not have a recovery phrase');
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
const initExportProcess = React.useCallback((...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* (recoveryPhrase = false, isPromptForExport = false) {
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const initExportProcess = React.useCallback((...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* (recoveryPhrase = false, isPromptForExport = false, walletId) {
|
|
67
|
+
const targetWalletId = walletId !== null && walletId !== void 0 ? walletId : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id;
|
|
68
|
+
if (!targetWalletId) {
|
|
69
|
+
throw new Error('No wallet available for export');
|
|
69
70
|
}
|
|
70
71
|
if (!user) {
|
|
71
72
|
throw new Error(errors.USER_NOT_LOGGED_IN);
|
|
@@ -83,6 +84,7 @@ const useEmbeddedReveal = () => {
|
|
|
83
84
|
pushView('embedded-reveal-view', {
|
|
84
85
|
exportPrivateKey: !recoveryPhrase,
|
|
85
86
|
isPromptForExport,
|
|
87
|
+
walletId: targetWalletId,
|
|
86
88
|
});
|
|
87
89
|
return new Promise((resolve, reject) => {
|
|
88
90
|
dynamicEvents.dynamicEvents.once('embeddedWalletRevealCompleted', (wallet) => resolve(wallet));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Wallet } from '../../../shared';
|
|
2
2
|
export declare const useEmbeddedReveal: () => {
|
|
3
|
-
readonly initExportProcess: (recoveryPhrase?: boolean, isPromptForExport?: boolean) => Promise<Wallet>;
|
|
3
|
+
readonly initExportProcess: (recoveryPhrase?: boolean, isPromptForExport?: boolean, walletId?: string) => Promise<Wallet>;
|
|
4
4
|
};
|
|
@@ -59,9 +59,10 @@ const useEmbeddedReveal = () => {
|
|
|
59
59
|
throw new Error('Wallet is non-HD and does not have a recovery phrase');
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
const initExportProcess = useCallback((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (recoveryPhrase = false, isPromptForExport = false) {
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const initExportProcess = useCallback((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (recoveryPhrase = false, isPromptForExport = false, walletId) {
|
|
63
|
+
const targetWalletId = walletId !== null && walletId !== void 0 ? walletId : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id;
|
|
64
|
+
if (!targetWalletId) {
|
|
65
|
+
throw new Error('No wallet available for export');
|
|
65
66
|
}
|
|
66
67
|
if (!user) {
|
|
67
68
|
throw new Error(USER_NOT_LOGGED_IN);
|
|
@@ -79,6 +80,7 @@ const useEmbeddedReveal = () => {
|
|
|
79
80
|
pushView('embedded-reveal-view', {
|
|
80
81
|
exportPrivateKey: !recoveryPhrase,
|
|
81
82
|
isPromptForExport,
|
|
83
|
+
walletId: targetWalletId,
|
|
82
84
|
});
|
|
83
85
|
return new Promise((resolve, reject) => {
|
|
84
86
|
dynamicEvents.once('embeddedWalletRevealCompleted', (wallet) => resolve(wallet));
|
|
@@ -95,7 +95,7 @@ const useSyncEmbeddedWalletFlow = () => {
|
|
|
95
95
|
primaryWallet) {
|
|
96
96
|
try {
|
|
97
97
|
setShowAuthFlow(true);
|
|
98
|
-
yield initExportProcess(true, true);
|
|
98
|
+
yield initExportProcess(true, true, primaryWallet.id);
|
|
99
99
|
}
|
|
100
100
|
catch (error) {
|
|
101
101
|
logger.logger.error('Error initializing embedded wallet export', error);
|
|
@@ -91,7 +91,7 @@ const useSyncEmbeddedWalletFlow = () => {
|
|
|
91
91
|
primaryWallet) {
|
|
92
92
|
try {
|
|
93
93
|
setShowAuthFlow(true);
|
|
94
|
-
yield initExportProcess(true, true);
|
|
94
|
+
yield initExportProcess(true, true, primaryWallet.id);
|
|
95
95
|
}
|
|
96
96
|
catch (error) {
|
|
97
97
|
logger.error('Error initializing embedded wallet export', error);
|
|
@@ -55,7 +55,7 @@ require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
|
55
55
|
require('../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
56
56
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
57
57
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
58
|
-
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
58
|
+
var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
59
59
|
require('../../../store/state/authMode/authMode.cjs');
|
|
60
60
|
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
61
61
|
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
@@ -66,7 +66,6 @@ require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
|
66
66
|
var useSmartWallets = require('../../../utils/hooks/useSmartWallets/useSmartWallets.cjs');
|
|
67
67
|
require('../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
68
68
|
var useMutation = require('../../../utils/hooks/useMutation/useMutation.cjs');
|
|
69
|
-
var useIsTurnkeyWallet = require('../../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
70
69
|
require('bs58');
|
|
71
70
|
require('@dynamic-labs/types');
|
|
72
71
|
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
@@ -136,32 +135,40 @@ var useSyncEmbeddedWalletFlow = require('../../../utils/hooks/useSyncEmbeddedWal
|
|
|
136
135
|
require('@dynamic-labs/store');
|
|
137
136
|
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
138
137
|
|
|
139
|
-
const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) => {
|
|
140
|
-
var _a, _b, _c;
|
|
138
|
+
const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, walletId, }) => {
|
|
139
|
+
var _a, _b, _c, _d, _e;
|
|
141
140
|
const { primaryWallet, user, setShowAuthFlow, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
141
|
+
const { userWallets } = UserWalletsContext.useInternalUserWallets();
|
|
142
142
|
const { handleAcknowledgeExportPrompt } = useSyncEmbeddedWalletFlow.useSyncEmbeddedWalletFlow();
|
|
143
|
-
const { isTurnkeyWallet } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
144
143
|
const isWaasWallet = Boolean(user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((vc) => { var _a; return (_a = vc.walletName) === null || _a === void 0 ? void 0 : _a.startsWith('dynamicwaas'); }));
|
|
145
144
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
146
145
|
const { pushView } = ViewContext.useViewContext();
|
|
147
146
|
const { getEOAWallet, isSmartWallet } = useSmartWallets.useSmartWallets();
|
|
148
147
|
const [isAcknowledged, setIsAcknowledged] = React.useState(false);
|
|
149
148
|
const [iframeContainerRef, setIframeContainerRef] = React.useState(null);
|
|
150
|
-
|
|
149
|
+
const walletFromId = walletId
|
|
150
|
+
? userWallets.find((w) => w.id === walletId)
|
|
151
|
+
: undefined;
|
|
152
|
+
if (walletId && !walletFromId) {
|
|
153
|
+
throw new utils.DynamicError('Wallet not found. Please try again.', errors.INVALID_WALLET_DATA);
|
|
154
|
+
}
|
|
155
|
+
const targetWallet = walletFromId !== null && walletFromId !== void 0 ? walletFromId : primaryWallet;
|
|
156
|
+
if (!targetWallet) {
|
|
151
157
|
throw new utils.DynamicError('No primary wallet found', errors.INVALID_WALLET_DATA);
|
|
152
158
|
}
|
|
153
159
|
let primaryTurnkeyWalletId;
|
|
154
160
|
try {
|
|
155
|
-
primaryTurnkeyWalletId = getTurnkeyWalletId.getTurnkeyWalletId(
|
|
161
|
+
primaryTurnkeyWalletId = getTurnkeyWalletId.getTurnkeyWalletId(targetWallet.id, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
156
162
|
}
|
|
157
163
|
catch (error) {
|
|
158
164
|
// waas wallet
|
|
159
165
|
}
|
|
160
166
|
const turnkeyCredential = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId);
|
|
161
167
|
const walletProperties = turnkeyCredential === null || turnkeyCredential === void 0 ? void 0 : turnkeyCredential.walletProperties;
|
|
162
|
-
const walletCredential = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find((cred) => cred.address ===
|
|
168
|
+
const walletCredential = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find((cred) => cred.address === targetWallet.address);
|
|
163
169
|
const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
164
|
-
const wallet = (_c = (
|
|
170
|
+
const wallet = (_c = (targetWallet && getEOAWallet(targetWallet))) !== null && _c !== void 0 ? _c : targetWallet;
|
|
171
|
+
const isTurnkeyWallet = Boolean((_e = (_d = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _d === void 0 ? void 0 : _d.key) === null || _e === void 0 ? void 0 : _e.startsWith('turnkey'));
|
|
165
172
|
// eslint-disable-next-line arrow-body-style
|
|
166
173
|
React.useEffect(() => {
|
|
167
174
|
return () => {
|
|
@@ -252,8 +259,8 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
252
259
|
}
|
|
253
260
|
return baseClass;
|
|
254
261
|
};
|
|
255
|
-
const isEip7702SmartWallet = Boolean(
|
|
256
|
-
const isErc4337SmartWallet = Boolean(
|
|
262
|
+
const isEip7702SmartWallet = Boolean(targetWallet === null || targetWallet === void 0 ? void 0 : targetWallet.id.endsWith('-zerodev'));
|
|
263
|
+
const isErc4337SmartWallet = Boolean(targetWallet && isSmartWallet(targetWallet)) &&
|
|
257
264
|
!isEip7702SmartWallet;
|
|
258
265
|
const shouldShowAaWarning = isErc4337SmartWallet && !isLoading && Boolean(data) && !error;
|
|
259
266
|
const aaWarning = shouldShowAaWarning && (jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__zerodev-warning', children: [jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__zerodev-warning__title-row', children: [jsxRuntime.jsx(info.ReactComponent, { className: 'embedded-reveal-view__zerodev-warning__icon' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', copykey: 'dyn_embedded_reveal.aa_warning.title', children: t('dyn_embedded_reveal.aa_warning.title') })] }), jsxRuntime.jsxs(Typography.Typography, { variant: 'body_normal', weight: 'regular', copykey: 'dyn_embedded_reveal.aa_warning.subtitle', children: [t('dyn_embedded_reveal.aa_warning.subtitle'), jsxRuntime.jsx("button", { onClick: () => {
|
|
@@ -51,7 +51,7 @@ import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
|
51
51
|
import '../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
52
52
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
53
53
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
54
|
-
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
54
|
+
import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
55
55
|
import '../../../store/state/authMode/authMode.js';
|
|
56
56
|
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
57
57
|
import '../../../context/VerificationContext/VerificationContext.js';
|
|
@@ -62,7 +62,6 @@ import '../../../context/ThemeContext/ThemeContext.js';
|
|
|
62
62
|
import { useSmartWallets } from '../../../utils/hooks/useSmartWallets/useSmartWallets.js';
|
|
63
63
|
import '../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
64
64
|
import { useMutation } from '../../../utils/hooks/useMutation/useMutation.js';
|
|
65
|
-
import { useIsTurnkeyWallet } from '../../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
66
65
|
import 'bs58';
|
|
67
66
|
import '@dynamic-labs/types';
|
|
68
67
|
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
@@ -132,32 +131,40 @@ import { useSyncEmbeddedWalletFlow } from '../../../utils/hooks/useSyncEmbeddedW
|
|
|
132
131
|
import '@dynamic-labs/store';
|
|
133
132
|
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
134
133
|
|
|
135
|
-
const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) => {
|
|
136
|
-
var _a, _b, _c;
|
|
134
|
+
const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, walletId, }) => {
|
|
135
|
+
var _a, _b, _c, _d, _e;
|
|
137
136
|
const { primaryWallet, user, setShowAuthFlow, environmentId } = useInternalDynamicContext();
|
|
137
|
+
const { userWallets } = useInternalUserWallets();
|
|
138
138
|
const { handleAcknowledgeExportPrompt } = useSyncEmbeddedWalletFlow();
|
|
139
|
-
const { isTurnkeyWallet } = useIsTurnkeyWallet();
|
|
140
139
|
const isWaasWallet = Boolean(user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((vc) => { var _a; return (_a = vc.walletName) === null || _a === void 0 ? void 0 : _a.startsWith('dynamicwaas'); }));
|
|
141
140
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
142
141
|
const { pushView } = useViewContext();
|
|
143
142
|
const { getEOAWallet, isSmartWallet } = useSmartWallets();
|
|
144
143
|
const [isAcknowledged, setIsAcknowledged] = useState(false);
|
|
145
144
|
const [iframeContainerRef, setIframeContainerRef] = useState(null);
|
|
146
|
-
|
|
145
|
+
const walletFromId = walletId
|
|
146
|
+
? userWallets.find((w) => w.id === walletId)
|
|
147
|
+
: undefined;
|
|
148
|
+
if (walletId && !walletFromId) {
|
|
149
|
+
throw new DynamicError('Wallet not found. Please try again.', INVALID_WALLET_DATA);
|
|
150
|
+
}
|
|
151
|
+
const targetWallet = walletFromId !== null && walletFromId !== void 0 ? walletFromId : primaryWallet;
|
|
152
|
+
if (!targetWallet) {
|
|
147
153
|
throw new DynamicError('No primary wallet found', INVALID_WALLET_DATA);
|
|
148
154
|
}
|
|
149
155
|
let primaryTurnkeyWalletId;
|
|
150
156
|
try {
|
|
151
|
-
primaryTurnkeyWalletId = getTurnkeyWalletId(
|
|
157
|
+
primaryTurnkeyWalletId = getTurnkeyWalletId(targetWallet.id, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
152
158
|
}
|
|
153
159
|
catch (error) {
|
|
154
160
|
// waas wallet
|
|
155
161
|
}
|
|
156
162
|
const turnkeyCredential = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId);
|
|
157
163
|
const walletProperties = turnkeyCredential === null || turnkeyCredential === void 0 ? void 0 : turnkeyCredential.walletProperties;
|
|
158
|
-
const walletCredential = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find((cred) => cred.address ===
|
|
164
|
+
const walletCredential = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find((cred) => cred.address === targetWallet.address);
|
|
159
165
|
const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
160
|
-
const wallet = (_c = (
|
|
166
|
+
const wallet = (_c = (targetWallet && getEOAWallet(targetWallet))) !== null && _c !== void 0 ? _c : targetWallet;
|
|
167
|
+
const isTurnkeyWallet = Boolean((_e = (_d = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _d === void 0 ? void 0 : _d.key) === null || _e === void 0 ? void 0 : _e.startsWith('turnkey'));
|
|
161
168
|
// eslint-disable-next-line arrow-body-style
|
|
162
169
|
useEffect(() => {
|
|
163
170
|
return () => {
|
|
@@ -248,8 +255,8 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
248
255
|
}
|
|
249
256
|
return baseClass;
|
|
250
257
|
};
|
|
251
|
-
const isEip7702SmartWallet = Boolean(
|
|
252
|
-
const isErc4337SmartWallet = Boolean(
|
|
258
|
+
const isEip7702SmartWallet = Boolean(targetWallet === null || targetWallet === void 0 ? void 0 : targetWallet.id.endsWith('-zerodev'));
|
|
259
|
+
const isErc4337SmartWallet = Boolean(targetWallet && isSmartWallet(targetWallet)) &&
|
|
253
260
|
!isEip7702SmartWallet;
|
|
254
261
|
const shouldShowAaWarning = isErc4337SmartWallet && !isLoading && Boolean(data) && !error;
|
|
255
262
|
const aaWarning = shouldShowAaWarning && (jsxs("div", { className: 'embedded-reveal-view__zerodev-warning', children: [jsxs("div", { className: 'embedded-reveal-view__zerodev-warning__title-row', children: [jsx(SvgInfo, { className: 'embedded-reveal-view__zerodev-warning__icon' }), jsx(Typography, { variant: 'body_normal', weight: 'bold', copykey: 'dyn_embedded_reveal.aa_warning.title', children: t('dyn_embedded_reveal.aa_warning.title') })] }), jsxs(Typography, { variant: 'body_normal', weight: 'regular', copykey: 'dyn_embedded_reveal.aa_warning.subtitle', children: [t('dyn_embedded_reveal.aa_warning.subtitle'), jsx("button", { onClick: () => {
|
|
@@ -16,7 +16,7 @@ require('@dynamic-labs/iconic');
|
|
|
16
16
|
var midnightShielded = require('../../../../shared/assets/midnight-shielded.cjs');
|
|
17
17
|
var midnightUnshielded = require('../../../../shared/assets/midnight-unshielded.cjs');
|
|
18
18
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
19
|
-
require('../../../../shared/logger.cjs');
|
|
19
|
+
var logger = require('../../../../shared/logger.cjs');
|
|
20
20
|
require('@dynamic-labs/wallet-book');
|
|
21
21
|
require('@dynamic-labs/utils');
|
|
22
22
|
require('../../../../utils/constants/colors.cjs');
|
|
@@ -80,24 +80,43 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
|
|
|
80
80
|
deps: [walletAddress, primaryWallet, dustPollTick],
|
|
81
81
|
enabled,
|
|
82
82
|
});
|
|
83
|
-
const { dustBalance,
|
|
83
|
+
const { dustBalance, shieldedTokenCount, unshieldedBalance, dustSyncing } = balances !== null && balances !== void 0 ? balances : {};
|
|
84
84
|
React.useEffect(() => {
|
|
85
85
|
if (!dustSyncing)
|
|
86
86
|
return undefined;
|
|
87
|
-
|
|
87
|
+
// Poll frequently while syncing so the gauge appears within a couple
|
|
88
|
+
// seconds of dust completing (sync now finishes in ~4s). The effect stops
|
|
89
|
+
// the moment `dustSyncing` flips false, so this adds no steady-state load.
|
|
90
|
+
const id = setInterval(() => setDustPollTick((tick) => tick + 1), 2500);
|
|
88
91
|
return () => clearInterval(id);
|
|
89
92
|
}, [dustSyncing]);
|
|
90
93
|
// `registerDust` is a WaaS-only connector method (external/injected Midnight
|
|
91
94
|
// wallets manage dust themselves). When the embedded wallet has no dust
|
|
92
95
|
// registered yet, we surface a "Register DUST" button instead of the gauge.
|
|
93
96
|
const isWaasWallet = Boolean(primaryWallet && walletConnectorCore.isDynamicWaasConnector(primaryWallet.connector));
|
|
97
|
+
// True once registered. balance/cap can't tell us this on load (cap reads 0
|
|
98
|
+
// on current wallet-client builds), so we track it after a register call to
|
|
99
|
+
// flip from the "Register DUST" prompt to the generating state.
|
|
100
|
+
const [dustRegistered, setDustRegistered] = React.useState(false);
|
|
101
|
+
// Returns the promise so <Button> shows its built-in spinner while the heavy
|
|
102
|
+
// registerDust call runs.
|
|
94
103
|
const handleRegisterDust = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
95
104
|
const connector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
96
105
|
if (!(connector === null || connector === void 0 ? void 0 : connector.registerDust))
|
|
97
106
|
return;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
try {
|
|
108
|
+
const result = yield connector.registerDust();
|
|
109
|
+
if ((result === null || result === void 0 ? void 0 : result.status) === 'registered' ||
|
|
110
|
+
(result === null || result === void 0 ? void 0 : result.status) === 'already_registered' ||
|
|
111
|
+
(result === null || result === void 0 ? void 0 : result.status) === 'already_has_dust') {
|
|
112
|
+
setDustRegistered(true);
|
|
113
|
+
}
|
|
114
|
+
setDustPollTick((tick) => tick + 1);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
// Leave the prompt up so the user can retry rather than failing silently.
|
|
118
|
+
logger.logger.error('Failed to register dust', err);
|
|
119
|
+
}
|
|
101
120
|
});
|
|
102
121
|
// Only show the full skeleton on the very first load; background dust polls
|
|
103
122
|
// keep `balances` populated so the view never flashes back to a skeleton.
|
|
@@ -113,7 +132,10 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
|
|
|
113
132
|
cap: truncateToDecimals(dustBalance.cap, 2),
|
|
114
133
|
}
|
|
115
134
|
: undefined;
|
|
116
|
-
|
|
135
|
+
// Unshielded shows the native NIGHT amount; shielded has no NIGHT, so it
|
|
136
|
+
// shows the count of token types held in the pool instead.
|
|
137
|
+
const tokenCount = shieldedTokenCount !== null && shieldedTokenCount !== void 0 ? shieldedTokenCount : 0;
|
|
138
|
+
const shieldedDisplay = `${tokenCount} ${tokenCount === 1 ? 'token' : 'tokens'}`;
|
|
117
139
|
// Dust section has three mutually exclusive states (syncing, generating with
|
|
118
140
|
// a balance, and the WaaS "register dust" prompt). Resolved via a helper to
|
|
119
141
|
// avoid nesting ternaries in the JSX below.
|
|
@@ -121,8 +143,11 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
|
|
|
121
143
|
if (dustSyncing) {
|
|
122
144
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'active-midnight-balance__dust', children: jsxRuntime.jsx("div", { className: 'active-midnight-balance__dust-header', children: jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsxRuntime.jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsxRuntime.jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsxRuntime.jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.midnight_dust_syncing', children: t('dyn_active_wallet_info.midnight_dust_syncing') })] }) }) }), jsxRuntime.jsx("div", { className: 'active-midnight-balance__divider' })] }));
|
|
123
145
|
}
|
|
124
|
-
|
|
125
|
-
|
|
146
|
+
// Generating gauge: shown with a dust balance, or once registered (balance
|
|
147
|
+
// still 0 during the grace period). Bar renders either way; count only
|
|
148
|
+
// shows with a real balance.
|
|
149
|
+
if (dustBalance || (isWaasWallet && dustRegistered)) {
|
|
150
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust', children: [jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust-header', children: [jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsxRuntime.jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsxRuntime.jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsxRuntime.jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.midnight_dust_generating', children: t('dyn_active_wallet_info.midnight_dust_generating') })] }), dustBalanceDisplay && (jsxRuntime.jsxs("span", { className: 'active-midnight-balance__dust-count', children: [dustBalanceDisplay.balance, "/", dustBalanceDisplay.cap] }))] }), jsxRuntime.jsx("div", { className: 'active-midnight-balance__dust-bar', children: DUST_SEGMENT_KEYS.map((segmentKey, i) => (jsxRuntime.jsx("div", { className: [
|
|
126
151
|
'active-midnight-balance__dust-segment',
|
|
127
152
|
i === 0 && 'active-midnight-balance__dust-segment--first',
|
|
128
153
|
i === DUST_SEGMENTS - 1 &&
|
|
@@ -134,13 +159,15 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
|
|
|
134
159
|
.join(' ') }, segmentKey))) })] }), jsxRuntime.jsx("div", { className: 'active-midnight-balance__divider' })] }));
|
|
135
160
|
}
|
|
136
161
|
if (isWaasWallet) {
|
|
137
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust', children: [jsxRuntime.jsx("div", { className: 'active-midnight-balance__dust-header', children: jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsxRuntime.jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsxRuntime.jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsxRuntime.jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.
|
|
162
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust', children: [jsxRuntime.jsx("div", { className: 'active-midnight-balance__dust-header', children: jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsxRuntime.jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsxRuntime.jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsxRuntime.jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.midnight_dust_not_registered', children: t('dyn_active_wallet_info.midnight_dust_not_registered') })] }) }), jsxRuntime.jsx(Button.Button, { buttonPadding: 'small', buttonVariant: 'secondary', buttonClassName: 'active-midnight-balance__register-dust-button', onClick: handleRegisterDust, "data-copykey": 'dyn_active_wallet_info.midnight_register_dust', children: t('dyn_active_wallet_info.midnight_register_dust') })] }), jsxRuntime.jsx("div", { className: 'active-midnight-balance__divider' })] }));
|
|
138
163
|
}
|
|
139
164
|
return null;
|
|
140
165
|
};
|
|
141
166
|
return (jsxRuntime.jsx("div", { className: 'active-midnight-balance', children: jsxRuntime.jsxs("div", { className: 'active-midnight-balance__card', children: [renderDustSection(), jsxRuntime.jsx("div", { className: 'active-midnight-balance__tab-bar', children: TABS.map(({ id, copykey }) => (jsxRuntime.jsx("button", { className: classNames.classNames('active-midnight-balance__tab', {
|
|
142
167
|
'active-midnight-balance__tab--active': activeTab === id,
|
|
143
|
-
}), "data-copykey": copykey, onClick: () => setActiveTab(id), children: t(copykey) }, id))) }), jsxRuntime.jsxs("div", { className: 'active-midnight-balance__pocket', children: [activeTab === 'shielded' ? (jsxRuntime.jsx(midnightShielded.ReactComponent, { className: 'active-midnight-balance__pocket-icon' })) : (jsxRuntime.jsx(midnightUnshielded.ReactComponent, { className: 'active-midnight-balance__pocket-icon' })), jsxRuntime.
|
|
168
|
+
}), "data-copykey": copykey, onClick: () => setActiveTab(id), children: t(copykey) }, id))) }), jsxRuntime.jsxs("div", { className: 'active-midnight-balance__pocket', children: [activeTab === 'shielded' ? (jsxRuntime.jsx(midnightShielded.ReactComponent, { className: 'active-midnight-balance__pocket-icon' })) : (jsxRuntime.jsx(midnightUnshielded.ReactComponent, { className: 'active-midnight-balance__pocket-icon' })), jsxRuntime.jsx("span", { className: 'active-midnight-balance__amount', children: activeTab === 'shielded'
|
|
169
|
+
? shieldedDisplay
|
|
170
|
+
: `${unshieldedBalance !== null && unshieldedBalance !== void 0 ? unshieldedBalance : '—'} NIGHT` })] })] }) }));
|
|
144
171
|
};
|
|
145
172
|
|
|
146
173
|
exports.ActiveMidnightWalletBalance = ActiveMidnightWalletBalance;
|
|
@@ -12,7 +12,7 @@ import '@dynamic-labs/iconic';
|
|
|
12
12
|
import { ReactComponent as SvgMidnightShielded } from '../../../../shared/assets/midnight-shielded.js';
|
|
13
13
|
import { ReactComponent as SvgMidnightUnshielded } from '../../../../shared/assets/midnight-unshielded.js';
|
|
14
14
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
15
|
-
import '../../../../shared/logger.js';
|
|
15
|
+
import { logger } from '../../../../shared/logger.js';
|
|
16
16
|
import '@dynamic-labs/wallet-book';
|
|
17
17
|
import '@dynamic-labs/utils';
|
|
18
18
|
import '../../../../utils/constants/colors.js';
|
|
@@ -76,24 +76,43 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
|
|
|
76
76
|
deps: [walletAddress, primaryWallet, dustPollTick],
|
|
77
77
|
enabled,
|
|
78
78
|
});
|
|
79
|
-
const { dustBalance,
|
|
79
|
+
const { dustBalance, shieldedTokenCount, unshieldedBalance, dustSyncing } = balances !== null && balances !== void 0 ? balances : {};
|
|
80
80
|
useEffect(() => {
|
|
81
81
|
if (!dustSyncing)
|
|
82
82
|
return undefined;
|
|
83
|
-
|
|
83
|
+
// Poll frequently while syncing so the gauge appears within a couple
|
|
84
|
+
// seconds of dust completing (sync now finishes in ~4s). The effect stops
|
|
85
|
+
// the moment `dustSyncing` flips false, so this adds no steady-state load.
|
|
86
|
+
const id = setInterval(() => setDustPollTick((tick) => tick + 1), 2500);
|
|
84
87
|
return () => clearInterval(id);
|
|
85
88
|
}, [dustSyncing]);
|
|
86
89
|
// `registerDust` is a WaaS-only connector method (external/injected Midnight
|
|
87
90
|
// wallets manage dust themselves). When the embedded wallet has no dust
|
|
88
91
|
// registered yet, we surface a "Register DUST" button instead of the gauge.
|
|
89
92
|
const isWaasWallet = Boolean(primaryWallet && isDynamicWaasConnector(primaryWallet.connector));
|
|
93
|
+
// True once registered. balance/cap can't tell us this on load (cap reads 0
|
|
94
|
+
// on current wallet-client builds), so we track it after a register call to
|
|
95
|
+
// flip from the "Register DUST" prompt to the generating state.
|
|
96
|
+
const [dustRegistered, setDustRegistered] = useState(false);
|
|
97
|
+
// Returns the promise so <Button> shows its built-in spinner while the heavy
|
|
98
|
+
// registerDust call runs.
|
|
90
99
|
const handleRegisterDust = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
100
|
const connector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
92
101
|
if (!(connector === null || connector === void 0 ? void 0 : connector.registerDust))
|
|
93
102
|
return;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
103
|
+
try {
|
|
104
|
+
const result = yield connector.registerDust();
|
|
105
|
+
if ((result === null || result === void 0 ? void 0 : result.status) === 'registered' ||
|
|
106
|
+
(result === null || result === void 0 ? void 0 : result.status) === 'already_registered' ||
|
|
107
|
+
(result === null || result === void 0 ? void 0 : result.status) === 'already_has_dust') {
|
|
108
|
+
setDustRegistered(true);
|
|
109
|
+
}
|
|
110
|
+
setDustPollTick((tick) => tick + 1);
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
// Leave the prompt up so the user can retry rather than failing silently.
|
|
114
|
+
logger.error('Failed to register dust', err);
|
|
115
|
+
}
|
|
97
116
|
});
|
|
98
117
|
// Only show the full skeleton on the very first load; background dust polls
|
|
99
118
|
// keep `balances` populated so the view never flashes back to a skeleton.
|
|
@@ -109,7 +128,10 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
|
|
|
109
128
|
cap: truncateToDecimals(dustBalance.cap, 2),
|
|
110
129
|
}
|
|
111
130
|
: undefined;
|
|
112
|
-
|
|
131
|
+
// Unshielded shows the native NIGHT amount; shielded has no NIGHT, so it
|
|
132
|
+
// shows the count of token types held in the pool instead.
|
|
133
|
+
const tokenCount = shieldedTokenCount !== null && shieldedTokenCount !== void 0 ? shieldedTokenCount : 0;
|
|
134
|
+
const shieldedDisplay = `${tokenCount} ${tokenCount === 1 ? 'token' : 'tokens'}`;
|
|
113
135
|
// Dust section has three mutually exclusive states (syncing, generating with
|
|
114
136
|
// a balance, and the WaaS "register dust" prompt). Resolved via a helper to
|
|
115
137
|
// avoid nesting ternaries in the JSX below.
|
|
@@ -117,8 +139,11 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
|
|
|
117
139
|
if (dustSyncing) {
|
|
118
140
|
return (jsxs(Fragment, { children: [jsx("div", { className: 'active-midnight-balance__dust', children: jsx("div", { className: 'active-midnight-balance__dust-header', children: jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.midnight_dust_syncing', children: t('dyn_active_wallet_info.midnight_dust_syncing') })] }) }) }), jsx("div", { className: 'active-midnight-balance__divider' })] }));
|
|
119
141
|
}
|
|
120
|
-
|
|
121
|
-
|
|
142
|
+
// Generating gauge: shown with a dust balance, or once registered (balance
|
|
143
|
+
// still 0 during the grace period). Bar renders either way; count only
|
|
144
|
+
// shows with a real balance.
|
|
145
|
+
if (dustBalance || (isWaasWallet && dustRegistered)) {
|
|
146
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: 'active-midnight-balance__dust', children: [jsxs("div", { className: 'active-midnight-balance__dust-header', children: [jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.midnight_dust_generating', children: t('dyn_active_wallet_info.midnight_dust_generating') })] }), dustBalanceDisplay && (jsxs("span", { className: 'active-midnight-balance__dust-count', children: [dustBalanceDisplay.balance, "/", dustBalanceDisplay.cap] }))] }), jsx("div", { className: 'active-midnight-balance__dust-bar', children: DUST_SEGMENT_KEYS.map((segmentKey, i) => (jsx("div", { className: [
|
|
122
147
|
'active-midnight-balance__dust-segment',
|
|
123
148
|
i === 0 && 'active-midnight-balance__dust-segment--first',
|
|
124
149
|
i === DUST_SEGMENTS - 1 &&
|
|
@@ -130,13 +155,15 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
|
|
|
130
155
|
.join(' ') }, segmentKey))) })] }), jsx("div", { className: 'active-midnight-balance__divider' })] }));
|
|
131
156
|
}
|
|
132
157
|
if (isWaasWallet) {
|
|
133
|
-
return (jsxs(Fragment, { children: [jsxs("div", { className: 'active-midnight-balance__dust', children: [jsx("div", { className: 'active-midnight-balance__dust-header', children: jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.
|
|
158
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: 'active-midnight-balance__dust', children: [jsx("div", { className: 'active-midnight-balance__dust-header', children: jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.midnight_dust_not_registered', children: t('dyn_active_wallet_info.midnight_dust_not_registered') })] }) }), jsx(Button, { buttonPadding: 'small', buttonVariant: 'secondary', buttonClassName: 'active-midnight-balance__register-dust-button', onClick: handleRegisterDust, "data-copykey": 'dyn_active_wallet_info.midnight_register_dust', children: t('dyn_active_wallet_info.midnight_register_dust') })] }), jsx("div", { className: 'active-midnight-balance__divider' })] }));
|
|
134
159
|
}
|
|
135
160
|
return null;
|
|
136
161
|
};
|
|
137
162
|
return (jsx("div", { className: 'active-midnight-balance', children: jsxs("div", { className: 'active-midnight-balance__card', children: [renderDustSection(), jsx("div", { className: 'active-midnight-balance__tab-bar', children: TABS.map(({ id, copykey }) => (jsx("button", { className: classNames('active-midnight-balance__tab', {
|
|
138
163
|
'active-midnight-balance__tab--active': activeTab === id,
|
|
139
|
-
}), "data-copykey": copykey, onClick: () => setActiveTab(id), children: t(copykey) }, id))) }), jsxs("div", { className: 'active-midnight-balance__pocket', children: [activeTab === 'shielded' ? (jsx(SvgMidnightShielded, { className: 'active-midnight-balance__pocket-icon' })) : (jsx(SvgMidnightUnshielded, { className: 'active-midnight-balance__pocket-icon' })),
|
|
164
|
+
}), "data-copykey": copykey, onClick: () => setActiveTab(id), children: t(copykey) }, id))) }), jsxs("div", { className: 'active-midnight-balance__pocket', children: [activeTab === 'shielded' ? (jsx(SvgMidnightShielded, { className: 'active-midnight-balance__pocket-icon' })) : (jsx(SvgMidnightUnshielded, { className: 'active-midnight-balance__pocket-icon' })), jsx("span", { className: 'active-midnight-balance__amount', children: activeTab === 'shielded'
|
|
165
|
+
? shieldedDisplay
|
|
166
|
+
: `${unshieldedBalance !== null && unshieldedBalance !== void 0 ? unshieldedBalance : '—'} NIGHT` })] })] }) }));
|
|
140
167
|
};
|
|
141
168
|
|
|
142
169
|
export { ActiveMidnightWalletBalance };
|
|
@@ -177,9 +177,10 @@ const EmbeddedWalletExportSection = () => {
|
|
|
177
177
|
}, [setShowAuthFlow, pushView]);
|
|
178
178
|
const handleExportClick = React.useCallback((recoveryPhrase) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
179
179
|
var _l;
|
|
180
|
+
const targetWalletId = wallet === null || wallet === void 0 ? void 0 : wallet.id;
|
|
180
181
|
logger.logger.info('Starting embedded wallet export process', {
|
|
181
182
|
userId: user === null || user === void 0 ? void 0 : user.userId,
|
|
182
|
-
walletId:
|
|
183
|
+
walletId: targetWalletId,
|
|
183
184
|
walletName: (_l = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _l === void 0 ? void 0 : _l.name,
|
|
184
185
|
});
|
|
185
186
|
const stepUpRequired = yield isStepUpRequired({
|
|
@@ -215,8 +216,10 @@ const EmbeddedWalletExportSection = () => {
|
|
|
215
216
|
});
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
|
-
return initExportProcess(recoveryPhrase);
|
|
219
|
+
return initExportProcess(recoveryPhrase, false, targetWalletId);
|
|
219
220
|
}), [
|
|
221
|
+
wallet,
|
|
222
|
+
user,
|
|
220
223
|
isStepUpRequired,
|
|
221
224
|
promptStepUpAuth,
|
|
222
225
|
isMfaRequiredForAction,
|