@dynamic-labs/sdk-react-core 4.36.0 → 4.37.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 +15 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -0
- package/src/lib/client/extension/deprecated/mfa/verifyTotpMfaDevice/verifyTotpMfaDevice.d.ts +1 -1
- package/src/lib/client/extension/projectSettings/getProjectSettings/getProjectSettings.d.ts +2 -1
- package/src/lib/client/extension/projectSettings/useProjectSettings/useProjectSettings.d.ts +2 -1
- package/src/lib/client/extension/projectSettings/useRefetchProjectSettings/useRefetchProjectSettings.d.ts +2 -1
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +3 -1
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +3 -1
- package/src/lib/context/SocialRedirectContext/utils/getDynamicRedirectData/getDynamicRedirectData.d.ts +1 -0
- package/src/lib/context/SocialRedirectContext/utils/getDynamicRedirectDataFromUrl/getDynamicRedirectDataFromUrl.cjs +2 -1
- package/src/lib/context/SocialRedirectContext/utils/getDynamicRedirectDataFromUrl/getDynamicRedirectDataFromUrl.d.ts +1 -0
- package/src/lib/context/SocialRedirectContext/utils/getDynamicRedirectDataFromUrl/getDynamicRedirectDataFromUrl.js +2 -1
- package/src/lib/data/api/oauth/oauth.cjs +2 -1
- package/src/lib/data/api/oauth/oauth.d.ts +1 -1
- package/src/lib/data/api/oauth/oauth.js +2 -1
- package/src/lib/locale/en/translation.cjs +26 -3
- package/src/lib/locale/en/translation.d.ts +25 -2
- package/src/lib/locale/en/translation.js +26 -3
- package/src/lib/shared/assets/connect.cjs +57 -0
- package/src/lib/shared/assets/connect.js +33 -0
- package/src/lib/shared/assets/index.d.ts +1 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/authViewLayoutChecks.cjs +1 -0
- package/src/lib/utils/constants/authViewLayoutChecks.js +1 -0
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +3 -0
- package/src/lib/utils/constants/localStorage.d.ts +4 -0
- package/src/lib/utils/constants/localStorage.js +3 -1
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.cjs +47 -0
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.d.ts +26 -0
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.js +41 -0
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.cjs +5 -3
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.js +5 -3
- package/src/lib/utils/functions/socialStorage/socialStorage.d.ts +2 -0
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +5 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +4 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +5 -2
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +7 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +7 -0
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +59 -5
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.d.ts +12 -1
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +59 -5
- package/src/lib/views/WalletDelegation/WalletDelegationView/AgreementSection.cjs +28 -0
- package/src/lib/views/WalletDelegation/WalletDelegationView/AgreementSection.d.ts +9 -0
- package/src/lib/views/WalletDelegation/WalletDelegationView/AgreementSection.js +24 -0
- package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.cjs +144 -104
- package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.d.ts +7 -1
- package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.js +146 -106
- package/src/lib/views/viewToComponentMap.d.ts +3 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +2 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +4 -1
- 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/ConnectedAppsView/ConnectedAppsView.cjs +2 -6
- package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.js +2 -6
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +17 -1
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +17 -1
- package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.cjs +149 -0
- package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.d.ts +12 -0
- package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.js +144 -0
- package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/EmbeddedDelegatedSection/EmbeddedDelegatedSection.cjs +0 -34
- package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/EmbeddedDelegatedSection/EmbeddedDelegatedSection.d.ts +0 -2
- package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/EmbeddedDelegatedSection/EmbeddedDelegatedSection.js +0 -30
- package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/EmbeddedDelegatedSection/index.d.ts +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
|
+
import { StorageService } from '@dynamic-labs/utils';
|
|
4
5
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
5
6
|
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
6
7
|
import '@dynamic-labs/iconic';
|
|
@@ -9,7 +10,7 @@ import 'react/jsx-runtime';
|
|
|
9
10
|
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
10
11
|
import '../../../shared/logger.js';
|
|
11
12
|
import '@dynamic-labs/wallet-book';
|
|
12
|
-
import '
|
|
13
|
+
import { DELEGATION_STATE } from '../../constants/localStorage.js';
|
|
13
14
|
import '../../constants/colors.js';
|
|
14
15
|
import '../../constants/values.js';
|
|
15
16
|
import '@dynamic-labs/sdk-api-core';
|
|
@@ -25,13 +26,14 @@ import '@dynamic-labs-sdk/client/core';
|
|
|
25
26
|
import '../../../client/client.js';
|
|
26
27
|
import '@dynamic-labs-sdk/client';
|
|
27
28
|
import '../../../config/ApiEndpoint.js';
|
|
29
|
+
import { useProjectSettings } from '../../../client/extension/projectSettings/useProjectSettings/useProjectSettings.js';
|
|
28
30
|
import '../../../locale/locale.js';
|
|
29
31
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
30
32
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
31
33
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
32
34
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
33
35
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
34
|
-
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
36
|
+
import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
35
37
|
import '../../../store/state/authMode/authMode.js';
|
|
36
38
|
import '../../../context/VerificationContext/VerificationContext.js';
|
|
37
39
|
import 'react-dom';
|
|
@@ -100,9 +102,35 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
100
102
|
|
|
101
103
|
// Hook to trigger wallet delegation modal
|
|
102
104
|
const useWalletDelegation = () => {
|
|
105
|
+
var _a, _b, _c;
|
|
103
106
|
const { primaryWallet, user, setShowAuthFlow } = useInternalDynamicContext();
|
|
107
|
+
const { userWallets } = useInternalUserWallets();
|
|
104
108
|
const { pushView } = useViewContext();
|
|
105
|
-
const
|
|
109
|
+
const projectSettings = useProjectSettings();
|
|
110
|
+
const waasSettings = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.waas;
|
|
111
|
+
const delegatedAccessEnabled = (_a = waasSettings === null || waasSettings === void 0 ? void 0 : waasSettings.delegatedAccess) === null || _a === void 0 ? void 0 : _a.enabled;
|
|
112
|
+
const promptUsersOnSignIn = (_b = waasSettings === null || waasSettings === void 0 ? void 0 : waasSettings.delegatedAccess) === null || _b === void 0 ? void 0 : _b.promptUsersOnSignIn;
|
|
113
|
+
const requiresDelegation = (_c = waasSettings === null || waasSettings === void 0 ? void 0 : waasSettings.delegatedAccess) === null || _c === void 0 ? void 0 : _c.requiresDelegation;
|
|
114
|
+
const shouldPromptWalletDelegation = useCallback(() => {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
if (!delegatedAccessEnabled || !promptUsersOnSignIn) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
// If the prompt was dismissed, do not show again until logout
|
|
120
|
+
// Unified state first, then legacy dismissed flag
|
|
121
|
+
const state = StorageService.getItem(DELEGATION_STATE);
|
|
122
|
+
const dismissed = state === null || state === void 0 ? void 0 : state.dismissed;
|
|
123
|
+
if (dismissed) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const userId = (user === null || user === void 0 ? void 0 : user.userId) || 'anonymous';
|
|
127
|
+
const deniedForUser = new Set(((_a = state === null || state === void 0 ? void 0 : state.denied) === null || _a === void 0 ? void 0 : _a[userId]) || []);
|
|
128
|
+
const completedForUser = new Set(((_b = state === null || state === void 0 ? void 0 : state.completed) === null || _b === void 0 ? void 0 : _b[userId]) || []);
|
|
129
|
+
const waasWallets = userWallets.filter((wallet) => wallet.connector.key.startsWith('dynamicwaas'));
|
|
130
|
+
const hasUndeniedWaasWallet = waasWallets.some((wallet) => !deniedForUser.has(wallet.id) && !completedForUser.has(wallet.id));
|
|
131
|
+
return hasUndeniedWaasWallet;
|
|
132
|
+
}, [user === null || user === void 0 ? void 0 : user.userId, userWallets, delegatedAccessEnabled, promptUsersOnSignIn]);
|
|
133
|
+
const initDelegationProcess = useCallback((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
134
|
if (!primaryWallet) {
|
|
107
135
|
throw new Error('No primary wallet');
|
|
108
136
|
}
|
|
@@ -114,15 +142,41 @@ const useWalletDelegation = () => {
|
|
|
114
142
|
ignoreIfIsEmbeddedWidget: false,
|
|
115
143
|
performMultiWalletChecks: false,
|
|
116
144
|
});
|
|
117
|
-
// Push the wallet delegation view
|
|
118
|
-
pushView('wallet-delegation-view', {
|
|
145
|
+
// Push the wallet delegation view with optional wallets override
|
|
146
|
+
pushView('wallet-delegation-view', {
|
|
147
|
+
wallets: options === null || options === void 0 ? void 0 : options.wallets,
|
|
148
|
+
});
|
|
119
149
|
return new Promise((resolve, reject) => {
|
|
120
150
|
dynamicEvents.once('embeddedWalletDelegationCompleted', () => resolve());
|
|
121
151
|
dynamicEvents.once('embeddedWalletDelegationFailed', (error) => reject(error));
|
|
122
152
|
});
|
|
123
153
|
}), [primaryWallet, setShowAuthFlow, pushView, user]);
|
|
154
|
+
const getWalletsDelegatedStatus = useCallback(() => {
|
|
155
|
+
var _a, _b;
|
|
156
|
+
if (!primaryWallet) {
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
const state = StorageService.getItem(DELEGATION_STATE);
|
|
160
|
+
const userId = (user === null || user === void 0 ? void 0 : user.userId) || 'anonymous';
|
|
161
|
+
const completedForUser = new Set(((_a = state === null || state === void 0 ? void 0 : state.completed) === null || _a === void 0 ? void 0 : _a[userId]) || []);
|
|
162
|
+
const deniedForUser = new Set(((_b = state === null || state === void 0 ? void 0 : state.denied) === null || _b === void 0 ? void 0 : _b[userId]) || []);
|
|
163
|
+
return userWallets.map((wallet) => {
|
|
164
|
+
let status = 'pending';
|
|
165
|
+
if (completedForUser.has(wallet.id)) {
|
|
166
|
+
status = 'delegated';
|
|
167
|
+
}
|
|
168
|
+
else if (deniedForUser.has(wallet.id)) {
|
|
169
|
+
status = 'denied';
|
|
170
|
+
}
|
|
171
|
+
return Object.assign(Object.assign({}, wallet), { status });
|
|
172
|
+
});
|
|
173
|
+
}, [primaryWallet, user === null || user === void 0 ? void 0 : user.userId, userWallets]);
|
|
124
174
|
return {
|
|
175
|
+
delegatedAccessEnabled,
|
|
176
|
+
getWalletsDelegatedStatus,
|
|
125
177
|
initDelegationProcess,
|
|
178
|
+
requiresDelegation,
|
|
179
|
+
shouldPromptWalletDelegation,
|
|
126
180
|
};
|
|
127
181
|
};
|
|
128
182
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var Checkbox = require('../../../components/Checkbox/Checkbox.cjs');
|
|
8
|
+
var Typography = require('../../../components/Typography/Typography.cjs');
|
|
9
|
+
|
|
10
|
+
const AgreementSection = ({ checked, onToggle, text, className, }) => {
|
|
11
|
+
const handleKeyDown = (event) => {
|
|
12
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
onToggle();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const handleCheckboxClick = (event) => {
|
|
18
|
+
// Prevent the container onClick from firing twice
|
|
19
|
+
event.stopPropagation();
|
|
20
|
+
onToggle();
|
|
21
|
+
};
|
|
22
|
+
const containerClassName = className
|
|
23
|
+
? `embedded-delegated-view__agreement-section ${className}`
|
|
24
|
+
: 'embedded-delegated-view__agreement-section';
|
|
25
|
+
return (jsxRuntime.jsxs("div", { className: containerClassName, onClick: onToggle, role: 'checkbox', "aria-checked": checked, tabIndex: 0, onKeyDown: handleKeyDown, children: [jsxRuntime.jsx(Checkbox.Checkbox, { checked: checked, onChange: handleCheckboxClick, value: 'agreement' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', children: text })] }));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.AgreementSection = AgreementSection;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Checkbox } from '../../../components/Checkbox/Checkbox.js';
|
|
4
|
+
import { Typography } from '../../../components/Typography/Typography.js';
|
|
5
|
+
|
|
6
|
+
const AgreementSection = ({ checked, onToggle, text, className, }) => {
|
|
7
|
+
const handleKeyDown = (event) => {
|
|
8
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
onToggle();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const handleCheckboxClick = (event) => {
|
|
14
|
+
// Prevent the container onClick from firing twice
|
|
15
|
+
event.stopPropagation();
|
|
16
|
+
onToggle();
|
|
17
|
+
};
|
|
18
|
+
const containerClassName = className
|
|
19
|
+
? `embedded-delegated-view__agreement-section ${className}`
|
|
20
|
+
: 'embedded-delegated-view__agreement-section';
|
|
21
|
+
return (jsxs("div", { className: containerClassName, onClick: onToggle, role: 'checkbox', "aria-checked": checked, tabIndex: 0, onKeyDown: handleKeyDown, children: [jsx(Checkbox, { checked: checked, onChange: handleCheckboxClick, value: 'agreement' }), jsx(Typography, { variant: 'body_small', color: 'secondary', children: text })] }));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { AgreementSection };
|
|
@@ -14,119 +14,69 @@ var IconButton = require('../../../components/IconButton/IconButton.cjs');
|
|
|
14
14
|
var ModalHeader = require('../../../components/ModalHeader/ModalHeader.cjs');
|
|
15
15
|
var Typography = require('../../../components/Typography/Typography.cjs');
|
|
16
16
|
var TypographyButton = require('../../../components/TypographyButton/TypographyButton.cjs');
|
|
17
|
-
require('../../../context/DynamicContext/
|
|
18
|
-
require('../../../
|
|
19
|
-
require('
|
|
20
|
-
require('
|
|
17
|
+
var useDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useDynamicContext.cjs');
|
|
18
|
+
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
19
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
20
|
+
var getProperErrorMessage = require('../../../modals/SignMessageConfirmationModal/getProperErrorMessage.cjs');
|
|
21
|
+
var arrowLeft = require('../../../shared/assets/arrow-left.cjs');
|
|
21
22
|
var check = require('../../../shared/assets/check.cjs');
|
|
22
23
|
var close = require('../../../shared/assets/close.cjs');
|
|
23
24
|
var switchHorizontal = require('../../../shared/assets/switch-horizontal.cjs');
|
|
25
|
+
require('@dynamic-labs/iconic');
|
|
24
26
|
require('../../../context/ViewContext/ViewContext.cjs');
|
|
25
27
|
var logger = require('../../../shared/logger.cjs');
|
|
26
|
-
require('@dynamic-labs/wallet-book');
|
|
27
|
-
require('../../../utils/constants/colors.cjs');
|
|
28
|
-
require('../../../utils/constants/values.cjs');
|
|
29
|
-
require('@dynamic-labs/sdk-api-core');
|
|
30
|
-
require('../../../shared/consts/index.cjs');
|
|
31
|
-
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
32
|
-
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
33
|
-
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
34
|
-
require('@dynamic-labs/multi-wallet');
|
|
35
|
-
require('react-international-phone');
|
|
36
|
-
require('../../../store/state/nonce/nonce.cjs');
|
|
37
|
-
require('@dynamic-labs-sdk/client/core');
|
|
38
|
-
require('../../../client/client.cjs');
|
|
39
|
-
require('@dynamic-labs-sdk/client');
|
|
40
|
-
require('../../../config/ApiEndpoint.cjs');
|
|
41
|
-
require('../../../locale/locale.cjs');
|
|
42
|
-
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
43
|
-
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
44
|
-
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
45
|
-
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
46
|
-
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
47
|
-
var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
48
|
-
require('../../../store/state/authMode/authMode.cjs');
|
|
49
|
-
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
50
|
-
require('react-dom');
|
|
51
|
-
require('../../../utils/functions/compareChains/compareChains.cjs');
|
|
52
|
-
require('../../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
53
|
-
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
54
|
-
require('../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
55
28
|
var useMutation = require('../../../utils/hooks/useMutation/useMutation.cjs');
|
|
56
|
-
require('bs58');
|
|
57
|
-
require('@dynamic-labs/types');
|
|
58
|
-
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
59
|
-
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
60
|
-
require('../../../context/WalletContext/WalletContext.cjs');
|
|
61
|
-
require('../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
62
|
-
require('yup');
|
|
63
|
-
require('../../../context/MockContext/MockContext.cjs');
|
|
64
|
-
require('../../CollectUserDataView/useFields.cjs');
|
|
65
|
-
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
66
|
-
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
67
|
-
require('@dynamic-labs/rpc-providers');
|
|
68
|
-
require('../../../store/state/walletOptions/walletOptions.cjs');
|
|
69
|
-
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
70
|
-
require('../../../components/Alert/Alert.cjs');
|
|
71
|
-
var WalletIconWithNetwork = require('../../../widgets/DynamicWidget/components/WalletIconWithNetwork/WalletIconWithNetwork.cjs');
|
|
72
|
-
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
73
|
-
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
74
|
-
require('../../../components/Input/Input.cjs');
|
|
75
|
-
require('../../../components/IsBrowser/IsBrowser.cjs');
|
|
76
|
-
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
77
|
-
require('../../../components/OverlayCard/OverlayCard.cjs');
|
|
78
|
-
require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
79
|
-
require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
80
|
-
require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
81
|
-
require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
82
|
-
require('../../../components/Popper/Popper/Popper.cjs');
|
|
83
|
-
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
84
|
-
require('react-focus-lock');
|
|
85
|
-
require('qrcode');
|
|
86
|
-
require('formik');
|
|
87
|
-
require('../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
|
|
88
|
-
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
89
|
-
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
90
|
-
require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
91
|
-
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
92
|
-
require('@hcaptcha/react-hcaptcha');
|
|
93
|
-
var getProperErrorMessage = require('../../../modals/SignMessageConfirmationModal/getProperErrorMessage.cjs');
|
|
94
|
-
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
95
|
-
require('../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs');
|
|
96
|
-
require('../../ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
|
|
97
|
-
require('../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
98
|
-
require('../../../context/FooterAnimationContext/index.cjs');
|
|
99
|
-
require('../../MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
100
|
-
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
101
|
-
require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
102
|
-
var useDynamicWaas = require('../../../utils/hooks/useDynamicWaas/useDynamicWaas.cjs');
|
|
103
29
|
var settingsUtils = require('../../../store/utils/settingsUtils/settingsUtils.cjs');
|
|
104
|
-
require('../../../
|
|
105
|
-
require('../../../
|
|
106
|
-
require('../../../components/
|
|
107
|
-
require('../../../
|
|
108
|
-
require('
|
|
109
|
-
require('../../../
|
|
110
|
-
require('
|
|
111
|
-
require('
|
|
112
|
-
require('../../../store/state/tokenBalances.cjs');
|
|
113
|
-
require('../../../store/state/multichainBalances.cjs');
|
|
114
|
-
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
115
|
-
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
30
|
+
var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
31
|
+
var useDynamicWaas = require('../../../utils/hooks/useDynamicWaas/useDynamicWaas.cjs');
|
|
32
|
+
var WalletIconWithNetwork = require('../../../widgets/DynamicWidget/components/WalletIconWithNetwork/WalletIconWithNetwork.cjs');
|
|
33
|
+
var useWalletDelegation = require('../../../utils/hooks/useWalletDelegation/useWalletDelegation.cjs');
|
|
34
|
+
var localStorage = require('../../../utils/constants/localStorage.cjs');
|
|
35
|
+
require('../../../utils/constants/colors.cjs');
|
|
36
|
+
require('../../../utils/constants/values.cjs');
|
|
37
|
+
var AgreementSection = require('./AgreementSection.cjs');
|
|
116
38
|
|
|
117
|
-
const WalletDelegationView = () => {
|
|
118
|
-
const {
|
|
39
|
+
const WalletDelegationView = ({ wallets, }) => {
|
|
40
|
+
const { setShowAuthFlow, handleLogOut } = useInternalDynamicContext.useInternalDynamicContext();
|
|
41
|
+
const { user } = useDynamicContext.useDynamicContext();
|
|
119
42
|
const appName = settingsUtils.useAppName();
|
|
120
43
|
const { userWallets } = UserWalletsContext.useInternalUserWallets();
|
|
121
44
|
const { delegateKeyShares } = useDynamicWaas.useDynamicWaas();
|
|
45
|
+
const { requiresDelegation } = useWalletDelegation.useWalletDelegation();
|
|
122
46
|
const [selectedWallets, setSelectedWallets] = React.useState(new Set());
|
|
123
|
-
|
|
124
|
-
const
|
|
47
|
+
const [showEditView, setShowEditView] = React.useState(false);
|
|
48
|
+
const [agreementChecked, setAgreementChecked] = React.useState(false);
|
|
49
|
+
const [selectionInitialized, setSelectionInitialized] = React.useState(false);
|
|
50
|
+
// Get waas wallets that are not yet delegated or use provided wallets override
|
|
51
|
+
const waasWallets = React.useMemo(() => {
|
|
52
|
+
const items = wallets && wallets.length > 0
|
|
53
|
+
? wallets
|
|
54
|
+
: userWallets.filter((wallet) => wallet.connector.key.startsWith('dynamicwaas'));
|
|
55
|
+
const state = utils.StorageService.getItem(localStorage.DELEGATION_STATE) || { completed: {}, denied: {}, dismissed: false };
|
|
56
|
+
const userId = (user === null || user === void 0 ? void 0 : user.userId) || 'anonymous';
|
|
57
|
+
const deniedForUser = new Set(state.denied[userId] || []);
|
|
58
|
+
const completedForUser = new Set(state.completed[userId] || []);
|
|
59
|
+
return items.filter((wallet) => !deniedForUser.has(wallet.id) && !completedForUser.has(wallet.id));
|
|
60
|
+
}, [userWallets, wallets, user === null || user === void 0 ? void 0 : user.userId]);
|
|
61
|
+
// Auto-select wallets only on initial load
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
if (selectionInitialized)
|
|
64
|
+
return;
|
|
65
|
+
if (waasWallets.length === 1) {
|
|
66
|
+
setSelectedWallets(new Set([waasWallets[0].id]));
|
|
67
|
+
setSelectionInitialized(true);
|
|
68
|
+
}
|
|
69
|
+
else if (waasWallets.length > 1) {
|
|
70
|
+
setSelectedWallets(new Set(waasWallets.map((w) => w.id)));
|
|
71
|
+
setSelectionInitialized(true);
|
|
72
|
+
}
|
|
73
|
+
}, [waasWallets, selectionInitialized]);
|
|
125
74
|
const handleWalletToggle = (walletId, event) => {
|
|
126
75
|
// Prevent event propagation if called from checkbox
|
|
127
76
|
if (event) {
|
|
128
77
|
event.stopPropagation();
|
|
129
78
|
}
|
|
79
|
+
setSelectionInitialized(true);
|
|
130
80
|
setSelectedWallets((prev) => {
|
|
131
81
|
const newSet = new Set(prev);
|
|
132
82
|
if (newSet.has(walletId)) {
|
|
@@ -139,11 +89,22 @@ const WalletDelegationView = () => {
|
|
|
139
89
|
});
|
|
140
90
|
};
|
|
141
91
|
const handleSelectAll = () => {
|
|
92
|
+
setSelectionInitialized(true);
|
|
142
93
|
setSelectedWallets(new Set(waasWallets.map((wallet) => wallet.id)));
|
|
143
94
|
};
|
|
144
95
|
const handleDeselectAll = () => {
|
|
96
|
+
setSelectionInitialized(true);
|
|
145
97
|
setSelectedWallets(new Set());
|
|
146
98
|
};
|
|
99
|
+
const persistDeniedWallets = () => {
|
|
100
|
+
const state = utils.StorageService.getItem(localStorage.DELEGATION_STATE) || { completed: {}, denied: {}, dismissed: false };
|
|
101
|
+
const userId = (user === null || user === void 0 ? void 0 : user.userId) || 'anonymous';
|
|
102
|
+
const existingForUser = new Set(state.denied[userId] || []);
|
|
103
|
+
selectedWallets.forEach((walletId) => existingForUser.add(walletId));
|
|
104
|
+
state.denied[userId] = Array.from(existingForUser);
|
|
105
|
+
utils.StorageService.setItem(localStorage.DELEGATION_STATE, state);
|
|
106
|
+
// No legacy mirrors; unified state only
|
|
107
|
+
};
|
|
147
108
|
const { mutate: handleDelegateWallets, isLoading, error, data: isSuccess, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
148
109
|
if (selectedWallets.size === 0) {
|
|
149
110
|
throw new utils.DynamicError('No wallets selected for delegation');
|
|
@@ -166,6 +127,14 @@ const WalletDelegationView = () => {
|
|
|
166
127
|
}));
|
|
167
128
|
// Wait for all delegations to complete
|
|
168
129
|
yield Promise.all(delegationPromises);
|
|
130
|
+
// Persist completed delegations (unified state + legacy)
|
|
131
|
+
const state = utils.StorageService.getItem(localStorage.DELEGATION_STATE) || { completed: {}, denied: {}, dismissed: false };
|
|
132
|
+
const userId = (user === null || user === void 0 ? void 0 : user.userId) || 'anonymous';
|
|
133
|
+
const existingForUser = new Set(state.completed[userId] || []);
|
|
134
|
+
selectedWalletObjects.forEach((wallet) => existingForUser.add(wallet.id));
|
|
135
|
+
state.completed[userId] = Array.from(existingForUser);
|
|
136
|
+
utils.StorageService.setItem(localStorage.DELEGATION_STATE, state);
|
|
137
|
+
// No legacy mirrors; unified state only
|
|
169
138
|
// Emit overall success event
|
|
170
139
|
dynamicEvents.dynamicEvents.emit('embeddedWalletDelegationCompleted', selectedWalletObjects[0]);
|
|
171
140
|
return true;
|
|
@@ -207,13 +176,38 @@ const WalletDelegationView = () => {
|
|
|
207
176
|
// Error state content
|
|
208
177
|
const errorContent = (jsxRuntime.jsx("div", { className: 'embedded-delegated-view__body__description', children: jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__approval-section', children: [jsxRuntime.jsx("div", { className: 'embedded-delegated-view__error-icon', children: jsxRuntime.jsx(close.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'bold', color: 'primary', className: 'embedded-delegated-view__approval-title', children: t('dyn_wallet_delegation.something_went_wrong') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', className: 'embedded-delegated-view__approval-description', children: t('dyn_wallet_delegation.delegation_timeout_message') })] }) }));
|
|
209
178
|
// Initial state content
|
|
210
|
-
const initialContent = (jsxRuntime.jsx("div", { className: 'embedded-delegated-view__body__description', children: jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__approval-section', children: [jsxRuntime.jsx("div", { className: 'embedded-delegated-view__approval-icon', children: jsxRuntime.jsx(switchHorizontal.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'bold', color: 'primary', className: 'embedded-delegated-view__approval-title', copykey: 'dyn_wallet_delegation.approval_required', children:
|
|
179
|
+
const initialContent = (jsxRuntime.jsx("div", { className: 'embedded-delegated-view__body__description', children: jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__approval-section', children: [jsxRuntime.jsx("div", { className: 'embedded-delegated-view__approval-icon', children: jsxRuntime.jsx(switchHorizontal.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'bold', color: 'primary', className: 'embedded-delegated-view__approval-title', copykey: 'dyn_wallet_delegation.approval_required', children: requiresDelegation
|
|
180
|
+
? t('dyn_wallet_delegation.approval_required')
|
|
181
|
+
: t('dyn_wallet_delegation.approval_requested') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', className: 'embedded-delegated-view__approval-description', copykey: 'dyn_wallet_delegation.approval_description', children: t('dyn_wallet_delegation.approval_description', {
|
|
211
182
|
appName,
|
|
212
183
|
}) })] }) }));
|
|
213
|
-
|
|
184
|
+
// Single wallet view
|
|
185
|
+
const displaySingleWallet = () => {
|
|
186
|
+
const [wallet] = waasWallets;
|
|
187
|
+
if (!wallet)
|
|
188
|
+
return null;
|
|
189
|
+
return (jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-card-container', children: [jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-card', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'medium', color: 'primary', children: t('dyn_wallet_delegation.my_wallet') }), jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-address', children: [jsxRuntime.jsx("div", { className: 'embedded-delegated-view__wallet-address-dot' }), jsxRuntime.jsxs(Typography.Typography, { variant: 'body_small', color: 'secondary', children: [wallet.address.slice(0, 6), "...", wallet.address.slice(-4)] })] })] }), jsxRuntime.jsx(AgreementSection.AgreementSection, { checked: agreementChecked, onToggle: () => setAgreementChecked(!agreementChecked), text: t('dyn_wallet_delegation.agreement_text') })] }));
|
|
190
|
+
};
|
|
191
|
+
// Multi-wallet initial view
|
|
192
|
+
const displayMultiWalletSummary = () => (jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-card-container', children: [jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-card', children: [jsxRuntime.jsxs("div", { style: { alignItems: 'baseline', display: 'flex', gap: '4px' }, children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'medium', color: 'primary', children: t(selectedWallets.size === waasWallets.length
|
|
193
|
+
? 'dyn_wallet_delegation.all_wallets'
|
|
194
|
+
: 'dyn_wallet_delegation.selected_wallets') }), selectedWallets.size !== waasWallets.length && (jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'tertiary', children: selectedWallets.size.toString().padStart(2, '0') }))] }), jsxRuntime.jsx("button", { onClick: () => setShowEditView(true), className: 'embedded-delegated-view__edit-selections-button', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', children: t('dyn_wallet_delegation.edit_selections') }) })] }), jsxRuntime.jsx(AgreementSection.AgreementSection, { checked: agreementChecked, onToggle: () => setAgreementChecked(!agreementChecked), text: t('dyn_wallet_delegation.agreement_text') })] }));
|
|
195
|
+
// Edit view (full wallet selection)
|
|
196
|
+
const displayWaasWallets = () => (jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-selection', children: [jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-selection__header', children: [jsxRuntime.jsxs("div", { style: { display: 'flex', gap: '4px' }, children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', children: t('dyn_wallet_delegation.selected_wallets') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'tertiary', children: selectedWallets.size.toString().padStart(2, '0') })] }), jsxRuntime.jsx("button", { onClick: selectedWallets.size === waasWallets.length
|
|
214
197
|
? handleDeselectAll
|
|
215
|
-
: handleSelectAll, className: 'embedded-delegated-view__wallet-selection__deselect-all', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: '
|
|
216
|
-
|
|
198
|
+
: handleSelectAll, className: 'embedded-delegated-view__wallet-selection__deselect-all', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'tertiary', children: getSelectButtonText() }) })] }), jsxRuntime.jsx("div", { className: 'embedded-delegated-view__wallet-list', children: waasWallets === null || waasWallets === void 0 ? void 0 : waasWallets.map((wallet) => (jsxRuntime.jsx("div", { className: `embedded-delegated-view__wallet-item${selectedWallets.has(wallet.id)
|
|
199
|
+
? ' embedded-delegated-view__wallet-item--selected'
|
|
200
|
+
: ''}`, onClick: () => handleWalletToggle(wallet.id), children: jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-item__content', children: [jsxRuntime.jsx("div", { className: 'embedded-delegated-view__wallet-item__icon', children: jsxRuntime.jsx(WalletIconWithNetwork.WalletIconWithNetwork, { walletKey: wallet.key, Icon: null, iconUrl: wallet.connector.metadata.icon, chainName: wallet.chain, iconSize: 24, showNetwork: true }) }), jsxRuntime.jsx("div", { className: 'embedded-delegated-view__wallet-item__info', children: jsxRuntime.jsxs(Typography.Typography, { variant: 'body_small', weight: 'medium', children: [wallet.address.slice(0, 6), "...", wallet.address.slice(-4)] }) }), jsxRuntime.jsx("div", { className: 'embedded-delegated-view__wallet-item__checkbox', children: jsxRuntime.jsx(Checkbox.Checkbox, { checked: selectedWallets.has(wallet.id), onChange: (e) => e.stopPropagation(), value: wallet.id }) })] }) }, wallet.id))) })] }));
|
|
201
|
+
const navigationButton = showEditView ? (jsxRuntime.jsx(IconButton.IconButton, { onClick: () => {
|
|
202
|
+
setShowEditView(false);
|
|
203
|
+
// Reset agreement when coming back from edit view
|
|
204
|
+
setAgreementChecked(false);
|
|
205
|
+
}, type: 'button', children: jsxRuntime.jsx(arrowLeft.ReactComponent, {}) })) : (jsxRuntime.jsx(IconButton.IconButton, { onClick: () => {
|
|
206
|
+
// Mark prompt as dismissed until logout (unified state + legacy)
|
|
207
|
+
const state = utils.StorageService.getItem(localStorage.DELEGATION_STATE) || { completed: {}, denied: {}, dismissed: false };
|
|
208
|
+
state.dismissed = true;
|
|
209
|
+
utils.StorageService.setItem(localStorage.DELEGATION_STATE, state);
|
|
210
|
+
// No legacy mirror; unified state only
|
|
217
211
|
setShowAuthFlow(false);
|
|
218
212
|
}, type: 'button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
219
213
|
// Determine which content to show based on state
|
|
@@ -248,18 +242,64 @@ const WalletDelegationView = () => {
|
|
|
248
242
|
width: '100%',
|
|
249
243
|
}, className: 'embedded-delegated-view__body__button', expanded: true, children: t('dyn_wallet_delegation.try_again_button') }));
|
|
250
244
|
}
|
|
245
|
+
// If in edit view, show Done button
|
|
246
|
+
if (showEditView) {
|
|
247
|
+
return (jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonPadding: 'medium', buttonVariant: 'secondary', typographyProps: {
|
|
248
|
+
color: 'primary',
|
|
249
|
+
weight: 'medium',
|
|
250
|
+
}, onClick: () => {
|
|
251
|
+
setShowEditView(false);
|
|
252
|
+
setAgreementChecked(false);
|
|
253
|
+
}, dataTestId: 'embedded-delegation-done-button', copykey: 'dyn_wallet_delegation.done_button', style: {
|
|
254
|
+
backgroundColor: 'white',
|
|
255
|
+
border: '1px solid var(--dynamic-base-4)',
|
|
256
|
+
width: '100%',
|
|
257
|
+
}, className: 'embedded-delegated-view__body__button', expanded: true, children: t('dyn_wallet_delegation.done_button') }));
|
|
258
|
+
}
|
|
251
259
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', typographyProps: {
|
|
252
260
|
color: 'inherit',
|
|
253
|
-
}, onClick: () => handleDelegateWallets(), loading: isLoading, disabled: selectedWallets.size === 0, dataTestId: 'embedded-delegation-button', copykey: 'dyn_wallet_delegation.approve_button', style: { width: '100%' }, className: 'embedded-delegated-view__body__button', expanded: true, children: t('dyn_wallet_delegation.approve_button') }), !isLoading && (jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', typographyProps: {
|
|
261
|
+
}, onClick: () => handleDelegateWallets(), loading: isLoading, disabled: selectedWallets.size === 0 || !agreementChecked, dataTestId: 'embedded-delegation-button', copykey: 'dyn_wallet_delegation.approve_button', style: { width: '100%' }, className: 'embedded-delegated-view__body__button', expanded: true, children: t('dyn_wallet_delegation.approve_button') }), !isLoading && !requiresDelegation && (jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', typographyProps: {
|
|
262
|
+
color: 'primary',
|
|
263
|
+
weight: 'bold',
|
|
264
|
+
}, onClick: () => {
|
|
265
|
+
persistDeniedWallets();
|
|
266
|
+
setShowAuthFlow(false);
|
|
267
|
+
}, dataTestId: 'embedded-delegation-deny-button', copykey: 'dyn_wallet_delegation.deny_button', style: {
|
|
268
|
+
backgroundColor: 'white',
|
|
269
|
+
border: '1px solid var(--dynamic-base-4)',
|
|
270
|
+
width: '100%',
|
|
271
|
+
}, className: 'embedded-delegated-view__body__button embedded-delegated-view__body__deny-button', expanded: true, children: t('dyn_wallet_delegation.deny_button') })), !isLoading && requiresDelegation && (jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', typographyProps: {
|
|
254
272
|
color: 'primary',
|
|
255
273
|
weight: 'bold',
|
|
256
|
-
}, onClick: () =>
|
|
274
|
+
}, onClick: () => {
|
|
275
|
+
handleLogOut();
|
|
276
|
+
}, dataTestId: 'embedded-delegation-logout-button', copykey: 'dyn_wallet_delegation.logout_button', style: {
|
|
257
277
|
backgroundColor: 'white',
|
|
258
278
|
border: '1px solid var(--dynamic-base-4)',
|
|
259
279
|
width: '100%',
|
|
260
|
-
}, className: 'embedded-delegated-view__body__button embedded-delegated-
|
|
280
|
+
}, className: 'embedded-delegated-view__body__button embedded-delegated-view__body__logout-button', expanded: true, children: t('dyn_wallet_delegation.logout_button') }))] }));
|
|
261
281
|
};
|
|
262
|
-
|
|
282
|
+
// Header configuration
|
|
283
|
+
let headerLeading;
|
|
284
|
+
if (showEditView) {
|
|
285
|
+
headerLeading = navigationButton;
|
|
286
|
+
}
|
|
287
|
+
else if (!requiresDelegation) {
|
|
288
|
+
headerLeading = navigationButton;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
headerLeading = undefined;
|
|
292
|
+
}
|
|
293
|
+
const headerChildren = showEditView ? (jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'primary', children: t('dyn_wallet_delegation.edit_wallets_to_delegate') })) : undefined;
|
|
294
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: headerLeading, children: headerChildren }), jsxRuntime.jsx("div", { className: 'embedded-delegated-view', children: jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__body', children: [!showEditView && getContentHeader(), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), !isLoading && !isSuccess && !error && (jsxRuntime.jsx("div", { className: 'embedded-delegated-view__body__card', children: (() => {
|
|
295
|
+
if (showEditView)
|
|
296
|
+
return displayWaasWallets();
|
|
297
|
+
if (waasWallets.length === 1)
|
|
298
|
+
return displaySingleWallet();
|
|
299
|
+
if (waasWallets.length > 1)
|
|
300
|
+
return displayMultiWalletSummary();
|
|
301
|
+
return null;
|
|
302
|
+
})() })), jsxRuntime.jsx("div", { className: 'embedded-delegated-view__body__button_section', children: getButtons() })] }) })] }));
|
|
263
303
|
};
|
|
264
304
|
|
|
265
305
|
exports.WalletDelegationView = WalletDelegationView;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
|
|
2
|
+
import { Wallet } from '../../../shared';
|
|
3
|
+
type WalletDelegationViewProps = {
|
|
4
|
+
/** Optional list of wallets to display instead of default WAAS wallets */
|
|
5
|
+
wallets?: Wallet[];
|
|
6
|
+
};
|
|
7
|
+
export declare const WalletDelegationView: FC<WalletDelegationViewProps>;
|
|
8
|
+
export {};
|