@dynamic-labs/sdk-react-core 3.0.0-alpha.50 → 3.0.0-alpha.52

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +13 -12
  5. package/src/lib/components/Typography/Typography.cjs +1 -0
  6. package/src/lib/components/Typography/Typography.js +1 -0
  7. package/src/lib/components/Typography/Typography.types.d.ts +1 -1
  8. package/src/lib/components/TypographyButton/TypographyButton.cjs +2 -1
  9. package/src/lib/components/TypographyButton/TypographyButton.js +2 -1
  10. package/src/lib/context/DynamicContext/DynamicContext.cjs +5 -4
  11. package/src/lib/context/DynamicContext/DynamicContext.js +5 -4
  12. package/src/lib/context/DynamicContext/hooks/useSelectedWalletConnector/useSelectedWalletConnector.d.ts +1 -1
  13. package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +3 -2
  14. package/src/lib/context/ViewContext/types/index.d.ts +1 -1
  15. package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.cjs +1 -0
  16. package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.js +2 -1
  17. package/src/lib/locale/en/translation.cjs +24 -0
  18. package/src/lib/locale/en/translation.d.ts +24 -0
  19. package/src/lib/locale/en/translation.js +24 -0
  20. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +8 -1
  21. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +8 -1
  22. package/src/lib/shared/assets/blue-walletconnect.cjs +62 -0
  23. package/src/lib/shared/assets/blue-walletconnect.js +38 -0
  24. package/src/lib/shared/assets/index.d.ts +3 -0
  25. package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.cjs +19 -4
  26. package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.d.ts +4 -3
  27. package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.js +19 -4
  28. package/src/lib/styles/index.shadow.cjs +1 -1
  29. package/src/lib/styles/index.shadow.js +1 -1
  30. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +1 -0
  31. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +1 -0
  32. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +2 -2
  33. package/src/lib/views/GlobalWalletConfirmView/GlobalWalletConfirmView.cjs +105 -0
  34. package/src/lib/views/GlobalWalletConfirmView/GlobalWalletConfirmView.d.ts +12 -0
  35. package/src/lib/views/GlobalWalletConfirmView/GlobalWalletConfirmView.js +100 -0
  36. package/src/lib/views/GlobalWalletConfirmView/index.d.ts +1 -0
  37. package/src/lib/views/viewToComponentMap.cjs +2 -0
  38. package/src/lib/views/viewToComponentMap.d.ts +1 -0
  39. package/src/lib/views/viewToComponentMap.js +2 -0
  40. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.cjs +12 -5
  41. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.js +13 -6
  42. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/DynamicWidgetViews.cjs +2 -0
  43. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/DynamicWidgetViews.js +2 -0
  44. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +2 -0
  45. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +2 -0
  46. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.cjs +2 -0
  47. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +3 -1
  48. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.js +2 -1
  49. package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.cjs +230 -0
  50. package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.d.ts +3 -0
  51. package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.js +225 -0
@@ -0,0 +1,230 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../../../_virtual/_tslib.cjs');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+ var React = require('react');
9
+ var reactI18next = require('react-i18next');
10
+ require('@dynamic-labs/sdk-api-core');
11
+ require('../../../../shared/logger.cjs');
12
+ require('@dynamic-labs/iconic');
13
+ require('@dynamic-labs/wallet-connector-core');
14
+ var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
15
+ var arrowLeft = require('../../../../shared/assets/arrow-left.cjs');
16
+ var copy = require('../../../../shared/assets/copy.cjs');
17
+ var blueWalletconnect = require('../../../../shared/assets/blue-walletconnect.cjs');
18
+ require('@dynamic-labs/wallet-book');
19
+ require('../../../../utils/constants/colors.cjs');
20
+ require('../../../../utils/constants/values.cjs');
21
+ require('../../../../shared/utils/classes/storage/localStorage.cjs');
22
+ require('../../../../shared/utils/classes/storage/sessionStorage.cjs');
23
+ require('@dynamic-labs/utils');
24
+ require('../../../../shared/consts/index.cjs');
25
+ var IconButton = require('../../../../components/IconButton/IconButton.cjs');
26
+ var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
27
+ require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
28
+ require('../../../../components/Alert/Alert.cjs');
29
+ require('../../../../events/dynamicEvents.cjs');
30
+ var useDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useDynamicContext.cjs');
31
+ var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.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('../../../../config/ApiEndpoint.cjs');
37
+ require('@dynamic-labs/store');
38
+ require('../../../../locale/locale.cjs');
39
+ require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
40
+ require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
41
+ require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
42
+ require('../../../../context/VerificationContext/VerificationContext.cjs');
43
+ require('react-dom');
44
+ require('../../../../context/WalletContext/WalletContext.cjs');
45
+ require('../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
46
+ require('../../../../context/ThemeContext/ThemeContext.cjs');
47
+ require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
48
+ require('@dynamic-labs/types');
49
+ require('../../../../context/LoadingContext/LoadingContext.cjs');
50
+ require('yup');
51
+ require('../../../../context/MockContext/MockContext.cjs');
52
+ require('../../../../views/CollectUserDataView/useFields.cjs');
53
+ require('../../../../context/FieldsStateContext/FieldsStateContext.cjs');
54
+ require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
55
+ require('@dynamic-labs/rpc-providers');
56
+ var Typography = require('../../../../components/Typography/Typography.cjs');
57
+ require('../../../../context/FooterAnimationContext/index.cjs');
58
+ require('../../../../components/ShadowDOM/ShadowDOM.cjs');
59
+ require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
60
+ require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
61
+ require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
62
+ require('../../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
63
+ require('../../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
64
+ require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
65
+ require('../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
66
+ require('react-focus-lock');
67
+ require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
68
+ require('formik');
69
+ require('../../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
70
+ var Input = require('../../../../components/Input/Input.cjs');
71
+ require('@dynamic-labs/ethereum-core');
72
+ require('../../../../context/PasskeyContext/PasskeyContext.cjs');
73
+ require('../ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
74
+ require('../../../../../polyfills.cjs');
75
+ require('../../../../context/DynamicContext/DynamicContext.cjs');
76
+ require('../../../../context/ErrorBoundary/ErrorBoundaryBase.cjs');
77
+ require('../../../../context/ErrorBoundary/ErrorBoundaryContext.cjs');
78
+ require('../../../DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.cjs');
79
+ require('../../components/DynamicWidgetCard/DynamicWidgetCard.cjs');
80
+ require('../../../../components/IsBrowser/IsBrowser.cjs');
81
+ require('../../../../context/WidgetRegistry/WidgetRegistryContextProvider.cjs');
82
+ require('../../../../context/FundingContext/FundingContext.cjs');
83
+ require('../../../../components/Popper/Popper/Popper.cjs');
84
+ require('../../../../components/Popper/PopperContext/PopperContext.cjs');
85
+ require('../../../../views/WalletList/WalletList.cjs');
86
+ require('../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
87
+ require('@hcaptcha/react-hcaptcha');
88
+ require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
89
+ require('../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
90
+ require('../../../../context/SendBalanceContext/SendBalanceContext.cjs');
91
+ require('../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
92
+ require('../../../../context/ConnectWithOtpContext/constants.cjs');
93
+ require('../../../../context/ReinitializeContext/ReinitializeContextProvider.cjs');
94
+ var InlineSubmitButton = require('../../../../components/InlineSubmitButton/InlineSubmitButton.cjs');
95
+ require('../../../../components/InlineWidget/InlineWidget.cjs');
96
+ require('qrcode');
97
+
98
+ const GlobalWalletView = () => {
99
+ const { t } = reactI18next.useTranslation();
100
+ const { setDynamicWidgetView, goToInitialDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
101
+ const { setView } = ViewContext.useViewContext();
102
+ const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
103
+ const { primaryWallet } = useDynamicContext.useDynamicContext();
104
+ const [walletConnectUri, setWalletConnectUri] = React.useState('');
105
+ const [bannerMessage, setBannerMessage] = React.useState(null);
106
+ const [isHovered, setIsHovered] = React.useState(false);
107
+ const [isFocused, setIsFocused] = React.useState(false);
108
+ const { globalWallet } = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
109
+ if (!globalWallet)
110
+ throw new Error('Global Wallet not found');
111
+ React.useEffect(() => {
112
+ let timeoutId;
113
+ if (bannerMessage) {
114
+ timeoutId = setTimeout(() => {
115
+ setBannerMessage(null);
116
+ }, 3000);
117
+ }
118
+ return () => {
119
+ if (timeoutId) {
120
+ clearTimeout(timeoutId);
121
+ }
122
+ };
123
+ }, [bannerMessage]);
124
+ const onClickBack = () => {
125
+ goToInitialDynamicWidgetView();
126
+ };
127
+ const onConnectClick = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
128
+ if (!walletConnectUri.startsWith('wc:')) {
129
+ setBannerMessage({
130
+ message: t('global_wallet.banner.bad_input'),
131
+ type: 'error',
132
+ });
133
+ return;
134
+ }
135
+ try {
136
+ yield globalWallet.pairWithWC(walletConnectUri);
137
+ // wait 0.5 second to receive the pairing request event
138
+ yield new Promise((resolve) => setTimeout(resolve, 500));
139
+ const pendingPairing = globalWallet.getPendingPairing();
140
+ if (!pendingPairing)
141
+ throw new Error('No pending pairing');
142
+ const { name, url, icons } = pendingPairing.params
143
+ .proposer.metadata;
144
+ setView('global-wallet-confirm', {
145
+ onCancel: onCancelPairing,
146
+ onConfirm: onConfirmPairing,
147
+ pairingInfo: { icons, name, url },
148
+ });
149
+ setShowAuthFlow(true, {
150
+ ignoreIfIsEmbeddedWidget: false,
151
+ performMultiWalletChecks: false,
152
+ });
153
+ }
154
+ catch (error) {
155
+ if (String(error).includes('expired')) {
156
+ setBannerMessage({
157
+ message: t('global_wallet.banner.expired', {
158
+ name: 'this app',
159
+ }),
160
+ type: 'error',
161
+ });
162
+ }
163
+ else if (String(error).includes('exists')) {
164
+ setBannerMessage({
165
+ message: t('global_wallet.banner.already_connected', {
166
+ name: 'this app',
167
+ }),
168
+ type: 'success',
169
+ });
170
+ }
171
+ else {
172
+ setBannerMessage({
173
+ message: t('global_wallet.banner.warning', { name: 'the app' }),
174
+ type: 'error',
175
+ });
176
+ }
177
+ }
178
+ });
179
+ const onConfirmPairing = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
180
+ var _a;
181
+ const pendingConnection = (_a = globalWallet.getPendingPairing()) !== null && _a !== void 0 ? _a : {};
182
+ const { name } = pendingConnection.params.proposer.metadata;
183
+ try {
184
+ yield globalWallet.confirmPairing(true);
185
+ setDynamicWidgetView('global-wallet');
186
+ setShowAuthFlow(false, {
187
+ ignoreIfIsEmbeddedWidget: false,
188
+ performMultiWalletChecks: false,
189
+ });
190
+ setBannerMessage({
191
+ message: t('global_wallet.banner.success', {
192
+ name: name !== null && name !== void 0 ? name : 'the dApp',
193
+ }),
194
+ type: 'success',
195
+ });
196
+ }
197
+ catch (error) {
198
+ setBannerMessage({
199
+ message: t('global_wallet.banner.warning', {
200
+ name: name !== null && name !== void 0 ? name : 'the dApp',
201
+ }),
202
+ type: 'error',
203
+ });
204
+ }
205
+ });
206
+ const onCancelPairing = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
207
+ setDynamicWidgetView('global-wallet');
208
+ setShowAuthFlow(false, {
209
+ ignoreIfIsEmbeddedWidget: false,
210
+ performMultiWalletChecks: false,
211
+ });
212
+ });
213
+ const handleSubmit = (e) => {
214
+ e.preventDefault();
215
+ onConnectClick();
216
+ };
217
+ const handleKeyDown = (e) => {
218
+ if (e.key === 'Enter') {
219
+ handleSubmit(e);
220
+ }
221
+ };
222
+ const InlineWalletConnectTypography = () => (jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'regular', color: 'secondary', children: jsxRuntime.jsxs("span", { className: 'inline-logo-text', children: ["3. Open WalletConnect ", jsxRuntime.jsx(blueWalletconnect.ReactComponent, { className: 'inline-logo' }), ' ', "from the list"] }) }));
223
+ const InlineCopyTextTypography = () => (jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'regular', color: 'secondary', children: jsxRuntime.jsxs("span", { className: 'inline-logo-text', children: ["4. Locate and click ", jsxRuntime.jsx(copy.ReactComponent, { className: 'inline-logo' }), " to copy the URI code"] }) }));
224
+ return (jsxRuntime.jsxs("div", { className: 'connect-dapps-view', children: [jsxRuntime.jsxs("div", { className: 'header', children: [jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: onClickBack, "data-testid": 'back-button', children: jsxRuntime.jsx(arrowLeft.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'title', weight: 'medium', color: 'primary', as: 'h1', children: "Connect to apps" })] }), jsxRuntime.jsxs("div", { className: 'wallet-connect-card', children: [jsxRuntime.jsx("div", { className: 'input-group', children: jsxRuntime.jsx(Input.Input, { id: 'walletconnect-uri', label: 'WalletConnect URI', placeholder: 'wc:...', value: walletConnectUri, onChange: (e) => setWalletConnectUri(e.target.value), variant: 'dense', onKeyDown: handleKeyDown, suffix:
225
+ // eslint-disable-next-line react/jsx-wrap-multilines
226
+ jsxRuntime.jsx("div", { className: 'input-suffix', onClick: handleSubmit, role: 'button', tabIndex: 0, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), children: jsxRuntime.jsx(InlineSubmitButton.InlineSubmitButton, { disabled: false, highlighted: Boolean(walletConnectUri), isFocused: isFocused, isHovered: isHovered, emailSubmitButtonInsideInput: true }) }) }) }), bannerMessage && (jsxRuntime.jsx("div", { className: `banner ${bannerMessage.type}`, children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'regular', color: 'primary', children: bannerMessage.message }) }))] }), jsxRuntime.jsx("div", { className: 'info-card', children: jsxRuntime.jsxs("div", { className: 'wrapper', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'bold', color: 'primary', as: 'h2', children: t('global_wallet.help.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'regular', color: 'secondary', children: t('global_wallet.help.step.1') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'regular', color: 'secondary', children: t('global_wallet.help.step.2') }), jsxRuntime.jsx(InlineWalletConnectTypography, {}), jsxRuntime.jsx(InlineCopyTextTypography, {})] }) })] }));
227
+ };
228
+
229
+ exports.GlobalWalletView = GlobalWalletView;
230
+ exports["default"] = GlobalWalletView;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const GlobalWalletView: React.FC;
3
+ export default GlobalWalletView;
@@ -0,0 +1,225 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../../../_virtual/_tslib.js';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { useState, useEffect } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import '@dynamic-labs/sdk-api-core';
7
+ import '../../../../shared/logger.js';
8
+ import '@dynamic-labs/iconic';
9
+ import '@dynamic-labs/wallet-connector-core';
10
+ import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
11
+ import { ReactComponent as SvgArrowLeft } from '../../../../shared/assets/arrow-left.js';
12
+ import { ReactComponent as SvgCopy } from '../../../../shared/assets/copy.js';
13
+ import { ReactComponent as SvgBlueWalletconnect } from '../../../../shared/assets/blue-walletconnect.js';
14
+ import '@dynamic-labs/wallet-book';
15
+ import '../../../../utils/constants/colors.js';
16
+ import '../../../../utils/constants/values.js';
17
+ import '../../../../shared/utils/classes/storage/localStorage.js';
18
+ import '../../../../shared/utils/classes/storage/sessionStorage.js';
19
+ import '@dynamic-labs/utils';
20
+ import '../../../../shared/consts/index.js';
21
+ import { IconButton } from '../../../../components/IconButton/IconButton.js';
22
+ import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
23
+ import '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
24
+ import '../../../../components/Alert/Alert.js';
25
+ import '../../../../events/dynamicEvents.js';
26
+ import { useDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useDynamicContext.js';
27
+ import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
28
+ import '../../../../context/CaptchaContext/CaptchaContext.js';
29
+ import '../../../../context/ErrorContext/ErrorContext.js';
30
+ import '@dynamic-labs/multi-wallet';
31
+ import 'react-international-phone';
32
+ import '../../../../config/ApiEndpoint.js';
33
+ import '@dynamic-labs/store';
34
+ import '../../../../locale/locale.js';
35
+ import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
36
+ import '../../../../context/AccountExistsContext/AccountExistsContext.js';
37
+ import '../../../../context/UserWalletsContext/UserWalletsContext.js';
38
+ import '../../../../context/VerificationContext/VerificationContext.js';
39
+ import 'react-dom';
40
+ import '../../../../context/WalletContext/WalletContext.js';
41
+ import '../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
42
+ import '../../../../context/ThemeContext/ThemeContext.js';
43
+ import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
44
+ import '@dynamic-labs/types';
45
+ import '../../../../context/LoadingContext/LoadingContext.js';
46
+ import 'yup';
47
+ import '../../../../context/MockContext/MockContext.js';
48
+ import '../../../../views/CollectUserDataView/useFields.js';
49
+ import '../../../../context/FieldsStateContext/FieldsStateContext.js';
50
+ import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
51
+ import '@dynamic-labs/rpc-providers';
52
+ import { Typography } from '../../../../components/Typography/Typography.js';
53
+ import '../../../../context/FooterAnimationContext/index.js';
54
+ import '../../../../components/ShadowDOM/ShadowDOM.js';
55
+ import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
56
+ import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
57
+ import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
58
+ import '../../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
59
+ import '../../../../context/SocialRedirectContext/SocialRedirectContext.js';
60
+ import '../../../../context/WalletGroupContext/WalletGroupContext.js';
61
+ import '../../components/DynamicWidgetHeader/DynamicWidgetHeader.js';
62
+ import 'react-focus-lock';
63
+ import '../../../../components/MenuList/Dropdown/Dropdown.js';
64
+ import 'formik';
65
+ import '../../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
66
+ import { Input } from '../../../../components/Input/Input.js';
67
+ import '@dynamic-labs/ethereum-core';
68
+ import '../../../../context/PasskeyContext/PasskeyContext.js';
69
+ import '../ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
70
+ import '../../../../../polyfills.js';
71
+ import '../../../../context/DynamicContext/DynamicContext.js';
72
+ import '../../../../context/ErrorBoundary/ErrorBoundaryBase.js';
73
+ import '../../../../context/ErrorBoundary/ErrorBoundaryContext.js';
74
+ import '../../../DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js';
75
+ import '../../components/DynamicWidgetCard/DynamicWidgetCard.js';
76
+ import '../../../../components/IsBrowser/IsBrowser.js';
77
+ import '../../../../context/WidgetRegistry/WidgetRegistryContextProvider.js';
78
+ import '../../../../context/FundingContext/FundingContext.js';
79
+ import '../../../../components/Popper/Popper/Popper.js';
80
+ import '../../../../components/Popper/PopperContext/PopperContext.js';
81
+ import '../../../../views/WalletList/WalletList.js';
82
+ import '../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
83
+ import '@hcaptcha/react-hcaptcha';
84
+ import '../../../../context/IpConfigurationContext/IpConfigurationContext.js';
85
+ import '../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
86
+ import '../../../../context/SendBalanceContext/SendBalanceContext.js';
87
+ import '../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
88
+ import '../../../../context/ConnectWithOtpContext/constants.js';
89
+ import '../../../../context/ReinitializeContext/ReinitializeContextProvider.js';
90
+ import { InlineSubmitButton } from '../../../../components/InlineSubmitButton/InlineSubmitButton.js';
91
+ import '../../../../components/InlineWidget/InlineWidget.js';
92
+ import 'qrcode';
93
+
94
+ const GlobalWalletView = () => {
95
+ const { t } = useTranslation();
96
+ const { setDynamicWidgetView, goToInitialDynamicWidgetView } = useWidgetContext();
97
+ const { setView } = useViewContext();
98
+ const { setShowAuthFlow } = useInternalDynamicContext();
99
+ const { primaryWallet } = useDynamicContext();
100
+ const [walletConnectUri, setWalletConnectUri] = useState('');
101
+ const [bannerMessage, setBannerMessage] = useState(null);
102
+ const [isHovered, setIsHovered] = useState(false);
103
+ const [isFocused, setIsFocused] = useState(false);
104
+ const { globalWallet } = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
105
+ if (!globalWallet)
106
+ throw new Error('Global Wallet not found');
107
+ useEffect(() => {
108
+ let timeoutId;
109
+ if (bannerMessage) {
110
+ timeoutId = setTimeout(() => {
111
+ setBannerMessage(null);
112
+ }, 3000);
113
+ }
114
+ return () => {
115
+ if (timeoutId) {
116
+ clearTimeout(timeoutId);
117
+ }
118
+ };
119
+ }, [bannerMessage]);
120
+ const onClickBack = () => {
121
+ goToInitialDynamicWidgetView();
122
+ };
123
+ const onConnectClick = () => __awaiter(void 0, void 0, void 0, function* () {
124
+ if (!walletConnectUri.startsWith('wc:')) {
125
+ setBannerMessage({
126
+ message: t('global_wallet.banner.bad_input'),
127
+ type: 'error',
128
+ });
129
+ return;
130
+ }
131
+ try {
132
+ yield globalWallet.pairWithWC(walletConnectUri);
133
+ // wait 0.5 second to receive the pairing request event
134
+ yield new Promise((resolve) => setTimeout(resolve, 500));
135
+ const pendingPairing = globalWallet.getPendingPairing();
136
+ if (!pendingPairing)
137
+ throw new Error('No pending pairing');
138
+ const { name, url, icons } = pendingPairing.params
139
+ .proposer.metadata;
140
+ setView('global-wallet-confirm', {
141
+ onCancel: onCancelPairing,
142
+ onConfirm: onConfirmPairing,
143
+ pairingInfo: { icons, name, url },
144
+ });
145
+ setShowAuthFlow(true, {
146
+ ignoreIfIsEmbeddedWidget: false,
147
+ performMultiWalletChecks: false,
148
+ });
149
+ }
150
+ catch (error) {
151
+ if (String(error).includes('expired')) {
152
+ setBannerMessage({
153
+ message: t('global_wallet.banner.expired', {
154
+ name: 'this app',
155
+ }),
156
+ type: 'error',
157
+ });
158
+ }
159
+ else if (String(error).includes('exists')) {
160
+ setBannerMessage({
161
+ message: t('global_wallet.banner.already_connected', {
162
+ name: 'this app',
163
+ }),
164
+ type: 'success',
165
+ });
166
+ }
167
+ else {
168
+ setBannerMessage({
169
+ message: t('global_wallet.banner.warning', { name: 'the app' }),
170
+ type: 'error',
171
+ });
172
+ }
173
+ }
174
+ });
175
+ const onConfirmPairing = () => __awaiter(void 0, void 0, void 0, function* () {
176
+ var _a;
177
+ const pendingConnection = (_a = globalWallet.getPendingPairing()) !== null && _a !== void 0 ? _a : {};
178
+ const { name } = pendingConnection.params.proposer.metadata;
179
+ try {
180
+ yield globalWallet.confirmPairing(true);
181
+ setDynamicWidgetView('global-wallet');
182
+ setShowAuthFlow(false, {
183
+ ignoreIfIsEmbeddedWidget: false,
184
+ performMultiWalletChecks: false,
185
+ });
186
+ setBannerMessage({
187
+ message: t('global_wallet.banner.success', {
188
+ name: name !== null && name !== void 0 ? name : 'the dApp',
189
+ }),
190
+ type: 'success',
191
+ });
192
+ }
193
+ catch (error) {
194
+ setBannerMessage({
195
+ message: t('global_wallet.banner.warning', {
196
+ name: name !== null && name !== void 0 ? name : 'the dApp',
197
+ }),
198
+ type: 'error',
199
+ });
200
+ }
201
+ });
202
+ const onCancelPairing = () => __awaiter(void 0, void 0, void 0, function* () {
203
+ setDynamicWidgetView('global-wallet');
204
+ setShowAuthFlow(false, {
205
+ ignoreIfIsEmbeddedWidget: false,
206
+ performMultiWalletChecks: false,
207
+ });
208
+ });
209
+ const handleSubmit = (e) => {
210
+ e.preventDefault();
211
+ onConnectClick();
212
+ };
213
+ const handleKeyDown = (e) => {
214
+ if (e.key === 'Enter') {
215
+ handleSubmit(e);
216
+ }
217
+ };
218
+ const InlineWalletConnectTypography = () => (jsx(Typography, { variant: 'body_small', weight: 'regular', color: 'secondary', children: jsxs("span", { className: 'inline-logo-text', children: ["3. Open WalletConnect ", jsx(SvgBlueWalletconnect, { className: 'inline-logo' }), ' ', "from the list"] }) }));
219
+ const InlineCopyTextTypography = () => (jsx(Typography, { variant: 'body_small', weight: 'regular', color: 'secondary', children: jsxs("span", { className: 'inline-logo-text', children: ["4. Locate and click ", jsx(SvgCopy, { className: 'inline-logo' }), " to copy the URI code"] }) }));
220
+ return (jsxs("div", { className: 'connect-dapps-view', children: [jsxs("div", { className: 'header', children: [jsx(IconButton, { type: 'button', onClick: onClickBack, "data-testid": 'back-button', children: jsx(SvgArrowLeft, {}) }), jsx(Typography, { variant: 'title', weight: 'medium', color: 'primary', as: 'h1', children: "Connect to apps" })] }), jsxs("div", { className: 'wallet-connect-card', children: [jsx("div", { className: 'input-group', children: jsx(Input, { id: 'walletconnect-uri', label: 'WalletConnect URI', placeholder: 'wc:...', value: walletConnectUri, onChange: (e) => setWalletConnectUri(e.target.value), variant: 'dense', onKeyDown: handleKeyDown, suffix:
221
+ // eslint-disable-next-line react/jsx-wrap-multilines
222
+ jsx("div", { className: 'input-suffix', onClick: handleSubmit, role: 'button', tabIndex: 0, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), children: jsx(InlineSubmitButton, { disabled: false, highlighted: Boolean(walletConnectUri), isFocused: isFocused, isHovered: isHovered, emailSubmitButtonInsideInput: true }) }) }) }), bannerMessage && (jsx("div", { className: `banner ${bannerMessage.type}`, children: jsx(Typography, { variant: 'body_small', weight: 'regular', color: 'primary', children: bannerMessage.message }) }))] }), jsx("div", { className: 'info-card', children: jsxs("div", { className: 'wrapper', children: [jsx(Typography, { variant: 'body_small', weight: 'bold', color: 'primary', as: 'h2', children: t('global_wallet.help.title') }), jsx(Typography, { variant: 'body_small', weight: 'regular', color: 'secondary', children: t('global_wallet.help.step.1') }), jsx(Typography, { variant: 'body_small', weight: 'regular', color: 'secondary', children: t('global_wallet.help.step.2') }), jsx(InlineWalletConnectTypography, {}), jsx(InlineCopyTextTypography, {})] }) })] }));
223
+ };
224
+
225
+ export { GlobalWalletView, GlobalWalletView as default };