@dynamic-labs/sdk-react-core 3.0.3 → 3.1.1
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 +28 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/components/QRCode/QRCode.cjs +2 -2
- package/src/lib/components/QRCode/QRCode.js +2 -2
- package/src/lib/components/WalletInformationCard/WalletInformationCard.cjs +1 -1
- package/src/lib/components/WalletInformationCard/WalletInformationCard.js +1 -1
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/data/api/transactions/blockaid.cjs +23 -0
- package/src/lib/data/api/transactions/blockaid.js +19 -0
- package/src/lib/locale/en/translation.cjs +35 -1
- package/src/lib/locale/en/translation.d.ts +34 -0
- package/src/lib/locale/en/translation.js +35 -1
- package/src/lib/shared/assets/caution-triangle.cjs +54 -0
- package/src/lib/shared/assets/caution-triangle.js +30 -0
- package/src/lib/shared/assets/exclamation-circle.cjs +54 -0
- package/src/lib/shared/assets/exclamation-circle.js +30 -0
- package/src/lib/shared/assets/exclamation.cjs +52 -0
- package/src/lib/shared/assets/exclamation.js +28 -0
- package/src/lib/shared/assets/index.d.ts +5 -0
- package/src/lib/shared/assets/warning-orange.cjs +54 -0
- package/src/lib/shared/assets/warning-orange.js +30 -0
- package/src/lib/shared/assets/warning-red.cjs +54 -0
- package/src/lib/shared/assets/warning-red.js +30 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/helpers/showPendingConnectView.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/helpers/showPendingConnectView.js +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +1 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.cjs +8 -1
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.js +8 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +148 -114
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +151 -117
- package/src/lib/views/GlobalWalletMaliciousView/GlobalWalletMaliciousView.cjs +139 -0
- package/src/lib/views/GlobalWalletMaliciousView/GlobalWalletMaliciousView.d.ts +11 -0
- package/src/lib/views/GlobalWalletMaliciousView/GlobalWalletMaliciousView.js +134 -0
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +1 -1
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +1 -1
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.cjs +3 -3
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.d.ts +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.js +3 -3
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.cjs +31 -8
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.js +31 -8
|
@@ -122,7 +122,7 @@ const MfaChooseDeviceView = ({ isInitialSetup = true, }) => {
|
|
|
122
122
|
? t('dyn_mfa.choose_device_view.title')
|
|
123
123
|
: t('dyn_mfa.choose_device_view.choose_another_method') }) }) }), jsxs("div", { className: 'mfa-choose-device-view__body', "data-testid": 'mfa-choose-device-view', children: [jsx(SvgSecureAccount, {}), jsx(Typography, { className: 'mfa-choose-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: isInitialSetup
|
|
124
124
|
? t('dyn_mfa.choose_device_view.select_options')
|
|
125
|
-
: t('dyn_mfa.choose_device_view.choose_another_method_description') }), mfaOptions.map((option) => (jsxs(Button, { buttonClassName: 'mfa-choose-device-view__button', expanded: true, onClick: () => handleClick(option), children: [jsxs("div", { className: 'mfa-choose-device-view__button__header', children: [jsx(Typography, { copykey: option.labelKey, children: t(option.labelKey) }), jsx(SvgChevronLeft, { className: 'mfa-choose-device-view__icon--rotate' })] }), jsx(Typography, { className: 'mfa-choose-device-view__button__description', color: 'secondary', copykey: option.descriptionKey, children: t(option.descriptionKey) })] }, option.type))), jsx(TextButton, { className: 'mfa-choose-device-view__logout', onClick: handleLogOut, copykey: 'dyn_mfa.choose_device_view.logout', children: t('dyn_mfa.choose_device_view.logout') })] })] }));
|
|
125
|
+
: t('dyn_mfa.choose_device_view.choose_another_method_description') }), mfaOptions.map((option) => (jsxs(Button, { buttonClassName: 'mfa-choose-device-view__button', expanded: true, onClick: () => handleClick(option), children: [jsxs("div", { className: 'mfa-choose-device-view__button__header', children: [jsx(Typography, { copykey: option.labelKey, color: 'primary', children: t(option.labelKey) }), jsx(SvgChevronLeft, { className: 'mfa-choose-device-view__icon--rotate' })] }), jsx(Typography, { className: 'mfa-choose-device-view__button__description', color: 'secondary', copykey: option.descriptionKey, children: t(option.descriptionKey) })] }, option.type))), jsx(TextButton, { className: 'mfa-choose-device-view__logout', onClick: handleLogOut, copykey: 'dyn_mfa.choose_device_view.logout', children: t('dyn_mfa.choose_device_view.logout') })] })] }));
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
export { MfaChooseDeviceView };
|
|
@@ -132,6 +132,7 @@ var MfaSecureDeviceHelpView = require('./MfaSecureDeviceHelpView/MfaSecureDevice
|
|
|
132
132
|
var SandboxMaximumThresholdReached = require('./SandboxMaximumThresholdReached/SandboxMaximumThresholdReached.cjs');
|
|
133
133
|
var GlobalWalletConfirmView = require('./GlobalWalletConfirmView/GlobalWalletConfirmView.cjs');
|
|
134
134
|
var GlobalWalletInfoView = require('./GlobalWalletInfoView/GlobalWalletInfoView.cjs');
|
|
135
|
+
var GlobalWalletMaliciousView = require('./GlobalWalletMaliciousView/GlobalWalletMaliciousView.cjs');
|
|
135
136
|
require('../context/SendBalanceContext/SendBalanceContext.cjs');
|
|
136
137
|
require('../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
137
138
|
require('../context/ConnectWithOtpContext/constants.cjs');
|
|
@@ -161,6 +162,7 @@ const viewToComponentMap = {
|
|
|
161
162
|
'gate-blocked-wallet': NoAccess.NoAccess,
|
|
162
163
|
'global-wallet-confirm': GlobalWalletConfirmView.GlobalWalletConfirmView,
|
|
163
164
|
'global-wallet-info': GlobalWalletInfoView.GlobalWalletInfoView,
|
|
165
|
+
'global-wallet-malicious': GlobalWalletMaliciousView.GlobalWalletMaliciousView,
|
|
164
166
|
'login-with-email-or-wallet': LoginView.LoginView,
|
|
165
167
|
'login-with-email-or-wallet-full-wallet-list': WalletList.WalletList,
|
|
166
168
|
'login-with-email-verification': EmailVerification.EmailVerification,
|
|
@@ -21,6 +21,7 @@ export declare const viewToComponentMap: {
|
|
|
21
21
|
'gate-blocked-wallet': () => JSX.Element;
|
|
22
22
|
'global-wallet-confirm': import("react").FC<import("./GlobalWalletConfirmView").GlobalWalletConfirmViewProps>;
|
|
23
23
|
'global-wallet-info': () => JSX.Element;
|
|
24
|
+
'global-wallet-malicious': import("react").FC<import("./GlobalWalletMaliciousView/GlobalWalletMaliciousView").GlobalWalletMaliciousViewProps>;
|
|
24
25
|
'login-with-email-or-wallet': () => JSX.Element;
|
|
25
26
|
'login-with-email-or-wallet-full-wallet-list': ({ isWalletConnectList, }: import("./WalletList").WalletListProps) => JSX.Element;
|
|
26
27
|
'login-with-email-verification': import("react").FC<import("./EmailVerification/EmailVerification").EmailVerificationProps>;
|
|
@@ -128,6 +128,7 @@ import { MfaSecureDeviceHelper } from './MfaSecureDeviceHelpView/MfaSecureDevice
|
|
|
128
128
|
import { SandboxMaximumThresholdReached } from './SandboxMaximumThresholdReached/SandboxMaximumThresholdReached.js';
|
|
129
129
|
import { GlobalWalletConfirmView } from './GlobalWalletConfirmView/GlobalWalletConfirmView.js';
|
|
130
130
|
import { GlobalWalletInfoView } from './GlobalWalletInfoView/GlobalWalletInfoView.js';
|
|
131
|
+
import { GlobalWalletMaliciousView } from './GlobalWalletMaliciousView/GlobalWalletMaliciousView.js';
|
|
131
132
|
import '../context/SendBalanceContext/SendBalanceContext.js';
|
|
132
133
|
import '../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
133
134
|
import '../context/ConnectWithOtpContext/constants.js';
|
|
@@ -157,6 +158,7 @@ const viewToComponentMap = {
|
|
|
157
158
|
'gate-blocked-wallet': NoAccess,
|
|
158
159
|
'global-wallet-confirm': GlobalWalletConfirmView,
|
|
159
160
|
'global-wallet-info': GlobalWalletInfoView,
|
|
161
|
+
'global-wallet-malicious': GlobalWalletMaliciousView,
|
|
160
162
|
'login-with-email-or-wallet': LoginView,
|
|
161
163
|
'login-with-email-or-wallet-full-wallet-list': WalletList,
|
|
162
164
|
'login-with-email-verification': EmailVerification,
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var reactI18next = require('react-i18next');
|
|
9
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
9
10
|
require('../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
10
11
|
require('../../components/Alert/Alert.cjs');
|
|
11
12
|
require('../../events/dynamicEvents.cjs');
|
|
@@ -16,7 +17,6 @@ require('@dynamic-labs/sdk-api-core');
|
|
|
16
17
|
require('../../shared/logger.cjs');
|
|
17
18
|
var getChainIcon = require('../../shared/utils/functions/chain/getChainIcon.cjs');
|
|
18
19
|
require('@dynamic-labs/wallet-connector-core');
|
|
19
|
-
require('@dynamic-labs/wallet-book');
|
|
20
20
|
var shortenWalletAddress = require('../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
|
|
21
21
|
require('../../utils/constants/colors.cjs');
|
|
22
22
|
require('../../utils/constants/values.cjs');
|
|
@@ -96,7 +96,7 @@ var InlineWidgetButton = require('../../components/InlineWidget/components/Inlin
|
|
|
96
96
|
var InlineWidget = require('../../components/InlineWidget/InlineWidget.cjs');
|
|
97
97
|
require('qrcode');
|
|
98
98
|
|
|
99
|
-
const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
|
|
99
|
+
const DynamicBridgeWidget = ({ className, variant = 'modal', iconVariant = 'chain', }) => {
|
|
100
100
|
const { showAuthFlow, setShowBridgeWidget, bridgeChains, setShowAuthFlow, connectedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
101
101
|
const { widgetRef, inlineControlsRef } = DynamicBridgeWidgetContext.useDynamicBridgeWidgetContext();
|
|
102
102
|
const { t } = reactI18next.useTranslation();
|
|
@@ -114,7 +114,7 @@ const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
|
|
|
114
114
|
const ChainIcon = getChainIcon.getChainIcon(chain);
|
|
115
115
|
const connectedChainWallets = connectedWallets.filter(({ chain: connectedChain }) => connectedChain === chain);
|
|
116
116
|
if (connectedChainWallets.length > 0) {
|
|
117
|
-
return connectedChainWallets.map((wallet) => (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, { icon: jsxRuntime.jsx(ChainIcon, {}), onClick: () => setShowBridgeWidget(true), children: shortenWalletAddress.shortenWalletAddress(wallet.address
|
|
117
|
+
return connectedChainWallets.map((wallet) => (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, { icon: iconVariant === 'wallet' ? (jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: wallet.connector.key })) : (jsxRuntime.jsx(ChainIcon, {})), onClick: () => setShowBridgeWidget(true), children: shortenWalletAddress.shortenWalletAddress(wallet.address) }, wallet.id)));
|
|
118
118
|
}
|
|
119
119
|
return (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, { icon: jsxRuntime.jsx(ChainIcon, {}), onClick: () => setShowAuthFlow(true), copykey: 'dyn_bridge.widget.connect', children: t('dyn_bridge.widget.connect') }, chain));
|
|
120
120
|
}) }), jsxRuntime.jsx(DynamicBridgeUserProfile.DynamicBridgeUserProfile, { variant: variant })] }));
|
|
@@ -3,5 +3,6 @@ export type DynamicBridgeWidgetVariant = 'modal' | 'dropdown';
|
|
|
3
3
|
export type DynamicBridgeWidgetProps = {
|
|
4
4
|
className?: string;
|
|
5
5
|
variant?: DynamicBridgeWidgetVariant;
|
|
6
|
+
iconVariant?: 'wallet' | 'chain';
|
|
6
7
|
};
|
|
7
8
|
export declare const DynamicBridgeWidget: FC<DynamicBridgeWidgetProps>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { WalletIcon } from '@dynamic-labs/wallet-book';
|
|
5
6
|
import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
6
7
|
import '../../components/Alert/Alert.js';
|
|
7
8
|
import '../../events/dynamicEvents.js';
|
|
@@ -12,7 +13,6 @@ import '@dynamic-labs/sdk-api-core';
|
|
|
12
13
|
import '../../shared/logger.js';
|
|
13
14
|
import { getChainIcon } from '../../shared/utils/functions/chain/getChainIcon.js';
|
|
14
15
|
import '@dynamic-labs/wallet-connector-core';
|
|
15
|
-
import '@dynamic-labs/wallet-book';
|
|
16
16
|
import { shortenWalletAddress } from '../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
|
|
17
17
|
import '../../utils/constants/colors.js';
|
|
18
18
|
import '../../utils/constants/values.js';
|
|
@@ -92,7 +92,7 @@ import { InlineWidgetButton } from '../../components/InlineWidget/components/Inl
|
|
|
92
92
|
import { InlineWidget } from '../../components/InlineWidget/InlineWidget.js';
|
|
93
93
|
import 'qrcode';
|
|
94
94
|
|
|
95
|
-
const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
|
|
95
|
+
const DynamicBridgeWidget = ({ className, variant = 'modal', iconVariant = 'chain', }) => {
|
|
96
96
|
const { showAuthFlow, setShowBridgeWidget, bridgeChains, setShowAuthFlow, connectedWallets, } = useInternalDynamicContext();
|
|
97
97
|
const { widgetRef, inlineControlsRef } = useDynamicBridgeWidgetContext();
|
|
98
98
|
const { t } = useTranslation();
|
|
@@ -110,7 +110,7 @@ const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
|
|
|
110
110
|
const ChainIcon = getChainIcon(chain);
|
|
111
111
|
const connectedChainWallets = connectedWallets.filter(({ chain: connectedChain }) => connectedChain === chain);
|
|
112
112
|
if (connectedChainWallets.length > 0) {
|
|
113
|
-
return connectedChainWallets.map((wallet) => (jsx(InlineWidgetButton, { icon: jsx(ChainIcon, {}), onClick: () => setShowBridgeWidget(true), children: shortenWalletAddress(wallet.address
|
|
113
|
+
return connectedChainWallets.map((wallet) => (jsx(InlineWidgetButton, { icon: iconVariant === 'wallet' ? (jsx(WalletIcon, { walletKey: wallet.connector.key })) : (jsx(ChainIcon, {})), onClick: () => setShowBridgeWidget(true), children: shortenWalletAddress(wallet.address) }, wallet.id)));
|
|
114
114
|
}
|
|
115
115
|
return (jsx(InlineWidgetButton, { icon: jsx(ChainIcon, {}), onClick: () => setShowAuthFlow(true), copykey: 'dyn_bridge.widget.connect', children: t('dyn_bridge.widget.connect') }, chain));
|
|
116
116
|
}) }), jsx(DynamicBridgeUserProfile, { variant: variant })] }));
|
|
@@ -75,6 +75,7 @@ var Input = require('../../../../components/Input/Input.cjs');
|
|
|
75
75
|
require('../../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
76
76
|
require('../../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
77
77
|
require('../ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
78
|
+
var blockaid = require('../../../../data/api/transactions/blockaid.cjs');
|
|
78
79
|
var GlobalWalletScanner = require('./scanner/GlobalWalletScanner.cjs');
|
|
79
80
|
require('../../../../../polyfills.cjs');
|
|
80
81
|
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
@@ -107,6 +108,7 @@ const GlobalWalletView = () => {
|
|
|
107
108
|
const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
108
109
|
const { primaryWallet } = useDynamicContext.useDynamicContext();
|
|
109
110
|
const [walletConnectUri, setWalletConnectUri] = React.useState('');
|
|
111
|
+
const { environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
110
112
|
const [bannerMessage, setBannerMessage] = React.useState(null);
|
|
111
113
|
const [isScanned, setIsScanned] = React.useState(false);
|
|
112
114
|
const { globalWallet } =
|
|
@@ -123,11 +125,7 @@ const GlobalWalletView = () => {
|
|
|
123
125
|
goToInitialDynamicWidgetView();
|
|
124
126
|
}, timeout);
|
|
125
127
|
}, [goToInitialDynamicWidgetView]);
|
|
126
|
-
const
|
|
127
|
-
const pendingPairing = globalWallet.getPendingPairing();
|
|
128
|
-
if (!pendingPairing)
|
|
129
|
-
throw new Error('No pending pairing');
|
|
130
|
-
const { name, url, icons } = pendingPairing.params.proposer.metadata;
|
|
128
|
+
const handleConfirmView = (pairingInfo) => {
|
|
131
129
|
setView('global-wallet-confirm', {
|
|
132
130
|
onCancel: () => {
|
|
133
131
|
setDynamicWidgetView('global-wallet');
|
|
@@ -138,6 +136,7 @@ const GlobalWalletView = () => {
|
|
|
138
136
|
setWalletConnectUri('');
|
|
139
137
|
},
|
|
140
138
|
onConfirm: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
+
var _a, _b;
|
|
141
140
|
try {
|
|
142
141
|
yield globalWallet.confirmPairing(true);
|
|
143
142
|
setDynamicWidgetView('global-wallet');
|
|
@@ -146,22 +145,46 @@ const GlobalWalletView = () => {
|
|
|
146
145
|
performMultiWalletChecks: false,
|
|
147
146
|
});
|
|
148
147
|
showBanner(t('global_wallet.banner.success', {
|
|
149
|
-
name: name !== null &&
|
|
148
|
+
name: (_a = pairingInfo.name) !== null && _a !== void 0 ? _a : t('global_wallet.the_dapp'),
|
|
150
149
|
}), 'success');
|
|
151
150
|
}
|
|
152
151
|
catch (error) {
|
|
153
152
|
showBanner(t('global_wallet.banner.warning', {
|
|
154
|
-
name: name !== null &&
|
|
153
|
+
name: (_b = pairingInfo.name) !== null && _b !== void 0 ? _b : t('global_wallet.the_dapp'),
|
|
155
154
|
}), 'error');
|
|
156
155
|
}
|
|
157
156
|
}),
|
|
158
|
-
pairingInfo
|
|
157
|
+
pairingInfo,
|
|
159
158
|
});
|
|
160
159
|
setShowAuthFlow(true, {
|
|
161
160
|
ignoreIfIsEmbeddedWidget: false,
|
|
162
161
|
performMultiWalletChecks: false,
|
|
163
162
|
});
|
|
164
163
|
};
|
|
164
|
+
const popupConfirmView = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
165
|
+
const pendingPairing = globalWallet.getPendingPairing();
|
|
166
|
+
if (!pendingPairing)
|
|
167
|
+
throw new Error('No pending pairing');
|
|
168
|
+
const { name, url, icons } = pendingPairing.params.proposer.metadata;
|
|
169
|
+
const pairingInfo = { icons, name, url };
|
|
170
|
+
const isDefinitelyMalicious = yield blockaid.isMaliciousUrl({ environmentId, url });
|
|
171
|
+
if (isDefinitelyMalicious || isDefinitelyMalicious === undefined) {
|
|
172
|
+
setView('global-wallet-malicious', {
|
|
173
|
+
maliciousSiteInfo: {
|
|
174
|
+
isDefinitelyMalicious: isDefinitelyMalicious !== null && isDefinitelyMalicious !== void 0 ? isDefinitelyMalicious : false,
|
|
175
|
+
proceedFlow: () => handleConfirmView(pairingInfo),
|
|
176
|
+
url,
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
setShowAuthFlow(true, {
|
|
180
|
+
ignoreIfIsEmbeddedWidget: false,
|
|
181
|
+
performMultiWalletChecks: false,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
handleConfirmView(pairingInfo);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
165
188
|
const handlePairing = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
166
189
|
if (!walletConnectUri.startsWith('wc:')) {
|
|
167
190
|
showBanner(t('global_wallet.banner.bad_input'), 'error');
|
|
@@ -71,6 +71,7 @@ import { Input } from '../../../../components/Input/Input.js';
|
|
|
71
71
|
import '../../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
72
72
|
import '../../../../context/PasskeyContext/PasskeyContext.js';
|
|
73
73
|
import '../ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
74
|
+
import { isMaliciousUrl } from '../../../../data/api/transactions/blockaid.js';
|
|
74
75
|
import { GlobalWalletScanner } from './scanner/GlobalWalletScanner.js';
|
|
75
76
|
import '../../../../../polyfills.js';
|
|
76
77
|
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
@@ -103,6 +104,7 @@ const GlobalWalletView = () => {
|
|
|
103
104
|
const { setShowAuthFlow } = useInternalDynamicContext();
|
|
104
105
|
const { primaryWallet } = useDynamicContext();
|
|
105
106
|
const [walletConnectUri, setWalletConnectUri] = useState('');
|
|
107
|
+
const { environmentId } = useInternalDynamicContext();
|
|
106
108
|
const [bannerMessage, setBannerMessage] = useState(null);
|
|
107
109
|
const [isScanned, setIsScanned] = useState(false);
|
|
108
110
|
const { globalWallet } =
|
|
@@ -119,11 +121,7 @@ const GlobalWalletView = () => {
|
|
|
119
121
|
goToInitialDynamicWidgetView();
|
|
120
122
|
}, timeout);
|
|
121
123
|
}, [goToInitialDynamicWidgetView]);
|
|
122
|
-
const
|
|
123
|
-
const pendingPairing = globalWallet.getPendingPairing();
|
|
124
|
-
if (!pendingPairing)
|
|
125
|
-
throw new Error('No pending pairing');
|
|
126
|
-
const { name, url, icons } = pendingPairing.params.proposer.metadata;
|
|
124
|
+
const handleConfirmView = (pairingInfo) => {
|
|
127
125
|
setView('global-wallet-confirm', {
|
|
128
126
|
onCancel: () => {
|
|
129
127
|
setDynamicWidgetView('global-wallet');
|
|
@@ -134,6 +132,7 @@ const GlobalWalletView = () => {
|
|
|
134
132
|
setWalletConnectUri('');
|
|
135
133
|
},
|
|
136
134
|
onConfirm: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
+
var _a, _b;
|
|
137
136
|
try {
|
|
138
137
|
yield globalWallet.confirmPairing(true);
|
|
139
138
|
setDynamicWidgetView('global-wallet');
|
|
@@ -142,22 +141,46 @@ const GlobalWalletView = () => {
|
|
|
142
141
|
performMultiWalletChecks: false,
|
|
143
142
|
});
|
|
144
143
|
showBanner(t('global_wallet.banner.success', {
|
|
145
|
-
name: name !== null &&
|
|
144
|
+
name: (_a = pairingInfo.name) !== null && _a !== void 0 ? _a : t('global_wallet.the_dapp'),
|
|
146
145
|
}), 'success');
|
|
147
146
|
}
|
|
148
147
|
catch (error) {
|
|
149
148
|
showBanner(t('global_wallet.banner.warning', {
|
|
150
|
-
name: name !== null &&
|
|
149
|
+
name: (_b = pairingInfo.name) !== null && _b !== void 0 ? _b : t('global_wallet.the_dapp'),
|
|
151
150
|
}), 'error');
|
|
152
151
|
}
|
|
153
152
|
}),
|
|
154
|
-
pairingInfo
|
|
153
|
+
pairingInfo,
|
|
155
154
|
});
|
|
156
155
|
setShowAuthFlow(true, {
|
|
157
156
|
ignoreIfIsEmbeddedWidget: false,
|
|
158
157
|
performMultiWalletChecks: false,
|
|
159
158
|
});
|
|
160
159
|
};
|
|
160
|
+
const popupConfirmView = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
+
const pendingPairing = globalWallet.getPendingPairing();
|
|
162
|
+
if (!pendingPairing)
|
|
163
|
+
throw new Error('No pending pairing');
|
|
164
|
+
const { name, url, icons } = pendingPairing.params.proposer.metadata;
|
|
165
|
+
const pairingInfo = { icons, name, url };
|
|
166
|
+
const isDefinitelyMalicious = yield isMaliciousUrl({ environmentId, url });
|
|
167
|
+
if (isDefinitelyMalicious || isDefinitelyMalicious === undefined) {
|
|
168
|
+
setView('global-wallet-malicious', {
|
|
169
|
+
maliciousSiteInfo: {
|
|
170
|
+
isDefinitelyMalicious: isDefinitelyMalicious !== null && isDefinitelyMalicious !== void 0 ? isDefinitelyMalicious : false,
|
|
171
|
+
proceedFlow: () => handleConfirmView(pairingInfo),
|
|
172
|
+
url,
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
setShowAuthFlow(true, {
|
|
176
|
+
ignoreIfIsEmbeddedWidget: false,
|
|
177
|
+
performMultiWalletChecks: false,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
handleConfirmView(pairingInfo);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
161
184
|
const handlePairing = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
162
185
|
if (!walletConnectUri.startsWith('wc:')) {
|
|
163
186
|
showBanner(t('global_wallet.banner.bad_input'), 'error');
|