@dynamic-labs/sdk-react-core 0.18.100-viem.0 → 0.18.100-viem.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -1
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +9 -9
- package/src/index.cjs +2 -0
- package/src/index.js +1 -0
- package/src/lib/Main.cjs +5 -0
- package/src/lib/Main.js +5 -0
- package/src/lib/components/Button/Button.cjs +10 -7
- package/src/lib/components/Button/Button.js +10 -7
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
- package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
- package/src/lib/components/ListTile/ListTile.cjs +1 -1
- package/src/lib/components/ListTile/ListTile.js +1 -1
- package/src/lib/components/ListTile/ListTile.types.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +5 -3
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +5 -3
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +2 -2
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +2 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +7 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +8 -3
- package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.cjs +13 -3
- package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.js +13 -3
- package/src/lib/context/DynamicContext/types/index.d.ts +2 -2
- package/src/lib/context/SendBalanceContext/SendBalanceContext.types.d.ts +2 -2
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/data/api.cjs +16 -0
- package/src/lib/data/api.d.ts +1 -0
- package/src/lib/data/api.js +18 -3
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +10 -2
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +10 -2
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.d.ts +2 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +10 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +10 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +6 -3
- package/src/lib/shared/assets/double-arrow-right.cjs +53 -0
- package/src/lib/shared/assets/double-arrow-right.js +29 -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/errors.cjs +7 -0
- package/src/lib/utils/constants/errors.d.ts +1 -0
- package/src/lib/utils/constants/errors.js +3 -0
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +2 -0
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +2 -1
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.cjs +10 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.js +6 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +2 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +11 -9
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -1
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +11 -9
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -2
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs +2 -7
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.js +2 -7
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/index.d.ts +1 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +16 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +2 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +12 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +22 -4
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +22 -4
- package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +31 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +27 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +56 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +52 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -0
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +1 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +2 -2
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +5 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +2 -2
- package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -2
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +9 -3
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +9 -3
- package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +4 -0
- package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +13 -4
- package/src/lib/views/EmailUpdate/EmailUpdate.js +13 -4
- package/src/lib/views/EmailVerification/EmailVerification.cjs +12 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +14 -3
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +3 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +3 -2
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +4 -1
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +4 -1
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -1
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +111 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.d.ts +2 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +107 -0
- package/src/lib/views/MergeUserAccountsView/index.d.ts +1 -0
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +1 -0
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +1 -0
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +1 -0
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +1 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +14 -35
- package/src/lib/views/SendBalanceView/SendBalanceView.d.ts +2 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.js +15 -36
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +73 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +69 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/index.d.ts +1 -0
- package/src/lib/views/SendBalanceView/components/index.d.ts +1 -0
- package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -2
- package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -2
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +31 -8
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.d.ts +4 -3
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +32 -9
- package/src/lib/views/TransactionConfirmationView/hooks/index.d.ts +2 -1
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/index.d.ts +1 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.cjs +69 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.js +65 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/index.d.ts +1 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.cjs +14 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.d.ts +6 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.js +10 -0
- package/src/lib/views/WalletList/WalletList.cjs +4 -1
- package/src/lib/views/WalletList/WalletList.js +4 -1
- package/src/lib/views/WalletLockedView/WalletLockedView.cjs +20 -4
- package/src/lib/views/WalletLockedView/WalletLockedView.js +20 -4
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +0 -104
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +0 -17
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +0 -100
|
@@ -22,7 +22,10 @@ const LoginWithEmailWalletList = ({ walletsList, numberOfWallets, }) => {
|
|
|
22
22
|
const { setView } = useViewContext();
|
|
23
23
|
const { projectSettings } = useInternalDynamicContext();
|
|
24
24
|
const isUsingMultiWallet = Boolean(LocalStorage.getFromLS(AUTH_USER));
|
|
25
|
-
return !projectSettings ? (jsx(Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxs("div", { className: 'login-with-email-wallet-list__container', children: [walletsList.map((wallet) =>
|
|
25
|
+
return !projectSettings ? (jsx(Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxs("div", { className: 'login-with-email-wallet-list__container', children: [walletsList.map((wallet) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return (jsx(WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
|
|
28
|
+
}), jsx(ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] }));
|
|
26
29
|
};
|
|
27
30
|
|
|
28
31
|
export { LoginWithEmailWalletList, NUMBER_OF_WALLETS };
|
|
@@ -78,7 +78,7 @@ const SocialSignIn = () => {
|
|
|
78
78
|
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { onClick: closeCard, type: 'button', id: 'close-button', disabled: isLoading, "data-testid": 'close-button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
79
79
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'social-sign-in', style: {
|
|
80
80
|
'--number-of-social-grid-items': numberOfSocialGridItems,
|
|
81
|
-
}, children: [socialProvidersToDisplayInline.map((provider) => (jsxRuntime.jsxs(IconListTile.IconListTile, { dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile', children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxRuntime.jsxs(Typography.Typography, { variant: 'button_primary', children: ["Connect with ", capitalize.capitalize(provider)] }))] }, provider))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, { dataTestId: 'show-more-options', onClick: () => setShowCard(true), children: jsxRuntime.jsx(Icon.Icon, { color: 'text-primary', children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) }) }, 'show-more-options'))] }), jsxRuntime.jsx(OverlayCard.OverlayCard, { isOpen: showCard, onClickOverlay: closeCard, children: jsxRuntime.jsxs("div", { className: 'social-sign-in--card', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span', children: "Choose a social account" }) }), jsxRuntime.jsx("div", { className: 'social-sign-in--card--body', children: socialProviders.map((provider) => (jsxRuntime.jsx(IconListTile.IconListTile, { dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--card--tile', children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }, provider))) })] }) })] }));
|
|
81
|
+
}, children: [socialProvidersToDisplayInline.map((provider) => (jsxRuntime.jsxs(IconListTile.IconListTile, { dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--tile', children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxRuntime.jsxs(Typography.Typography, { variant: 'button_primary', children: ["Connect with ", capitalize.capitalize(provider)] }))] }, provider))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, { dataTestId: 'show-more-options', onClick: () => setShowCard(true), children: jsxRuntime.jsx(Icon.Icon, { color: 'text-primary', children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) }) }, 'show-more-options'))] }), jsxRuntime.jsx(OverlayCard.OverlayCard, { isOpen: showCard, onClickOverlay: closeCard, children: jsxRuntime.jsxs("div", { className: 'social-sign-in--card', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span', children: "Choose a social account" }) }), jsxRuntime.jsx("div", { className: 'social-sign-in--card--body', children: socialProviders.map((provider) => (jsxRuntime.jsx(IconListTile.IconListTile, { dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--card--tile', children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }, provider))) })] }) })] }));
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
exports.SocialSignIn = SocialSignIn;
|
|
@@ -74,7 +74,7 @@ const SocialSignIn = () => {
|
|
|
74
74
|
const closeButton = (jsx(IconButton, { onClick: closeCard, type: 'button', id: 'close-button', disabled: isLoading, "data-testid": 'close-button', children: jsx(SvgClose, {}) }));
|
|
75
75
|
return (jsxs(Fragment, { children: [jsxs("div", { className: 'social-sign-in', style: {
|
|
76
76
|
'--number-of-social-grid-items': numberOfSocialGridItems,
|
|
77
|
-
}, children: [socialProvidersToDisplayInline.map((provider) => (jsxs(IconListTile, { dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile', children: [jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxs(Typography, { variant: 'button_primary', children: ["Connect with ", capitalize(provider)] }))] }, provider))), showCardButton && (jsx(IconListTile, { dataTestId: 'show-more-options', onClick: () => setShowCard(true), children: jsx(Icon, { color: 'text-primary', children: jsx(SvgDotsHorizontal, {}) }) }, 'show-more-options'))] }), jsx(OverlayCard, { isOpen: showCard, onClickOverlay: closeCard, children: jsxs("div", { className: 'social-sign-in--card', children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span', children: "Choose a social account" }) }), jsx("div", { className: 'social-sign-in--card--body', children: socialProviders.map((provider) => (jsx(IconListTile, { dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--card--tile', children: jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }, provider))) })] }) })] }));
|
|
77
|
+
}, children: [socialProvidersToDisplayInline.map((provider) => (jsxs(IconListTile, { dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--tile', children: [jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxs(Typography, { variant: 'button_primary', children: ["Connect with ", capitalize(provider)] }))] }, provider))), showCardButton && (jsx(IconListTile, { dataTestId: 'show-more-options', onClick: () => setShowCard(true), children: jsx(Icon, { color: 'text-primary', children: jsx(SvgDotsHorizontal, {}) }) }, 'show-more-options'))] }), jsx(OverlayCard, { isOpen: showCard, onClickOverlay: closeCard, children: jsxs("div", { className: 'social-sign-in--card', children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span', children: "Choose a social account" }) }), jsx("div", { className: 'social-sign-in--card--body', children: socialProviders.map((provider) => (jsx(IconListTile, { dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--card--tile', children: jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }, provider))) })] }) })] }));
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
export { SocialSignIn };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
9
|
+
var iconic = require('@dynamic-labs/iconic');
|
|
10
|
+
require('react');
|
|
11
|
+
var Typography = require('../../components/Typography/Typography.cjs');
|
|
12
|
+
var decodeJwt = require('../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
13
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
14
|
+
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
var doubleArrowRight = require('../../shared/assets/double-arrow-right.cjs');
|
|
16
|
+
require('../../shared/logger.cjs');
|
|
17
|
+
var shortenWalletAddress = require('../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
|
|
18
|
+
require('../../utils/constants/colors.cjs');
|
|
19
|
+
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
20
|
+
require('viem');
|
|
21
|
+
require('../../shared/consts/index.cjs');
|
|
22
|
+
var useInternalDynamicContext = require('../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
23
|
+
var index = require('../../utils/functions/storeAuthToken/index.cjs');
|
|
24
|
+
require('@dynamic-labs/multi-wallet');
|
|
25
|
+
var createUserProfile = require('../../utils/functions/createUserProfile/createUserProfile.cjs');
|
|
26
|
+
require('@dynamic-labs/sdk-api');
|
|
27
|
+
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
28
|
+
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
29
|
+
var Icon = require('../../components/Icon/Icon.cjs');
|
|
30
|
+
require('react-dom');
|
|
31
|
+
require('react-focus-lock');
|
|
32
|
+
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
33
|
+
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
34
|
+
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
35
|
+
var api = require('../../data/api.cjs');
|
|
36
|
+
require('@dynamic-labs/rpc-providers');
|
|
37
|
+
require('../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
38
|
+
var ErrorContext = require('../../context/ErrorContext/ErrorContext.cjs');
|
|
39
|
+
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
40
|
+
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
41
|
+
require('../../components/IconButton/IconButton.cjs');
|
|
42
|
+
var Button = require('../../components/Button/Button.cjs');
|
|
43
|
+
require('../../components/Alert/Alert.cjs');
|
|
44
|
+
require('../../context/MockContext/MockContext.cjs');
|
|
45
|
+
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
46
|
+
require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
47
|
+
var shortenEmail = require('../../shared/utils/functions/shortenEmail/shortenEmail.cjs');
|
|
48
|
+
require('../../components/Popper/Popper/Popper.cjs');
|
|
49
|
+
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
50
|
+
require('formik');
|
|
51
|
+
require('yup');
|
|
52
|
+
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
53
|
+
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
54
|
+
var EmailVerificationContext = require('../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
55
|
+
|
|
56
|
+
const MergeUserAccountsView = () => {
|
|
57
|
+
const { environmentId, setUser, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, primaryWallet, user, authToken, onboardingOnlyJwt, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
58
|
+
const { setError } = ErrorContext.useErrorContext();
|
|
59
|
+
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
60
|
+
const { email } = EmailVerificationContext.useEmailVerificationContext();
|
|
61
|
+
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
62
|
+
// If user tries to merge during KYC step, authToken is undefined and onboardingOnlyJwt is defined
|
|
63
|
+
const jwtToken = authToken || onboardingOnlyJwt;
|
|
64
|
+
const handleMergeUserAccounts = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
if (!jwtToken) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const newJwt = yield api.mergeUserAccounts(jwtToken, environmentId);
|
|
70
|
+
if (newJwt) {
|
|
71
|
+
index.storeAuthToken(newJwt);
|
|
72
|
+
const decodedJwt = decodeJwt.decodeJwt(newJwt);
|
|
73
|
+
if (decodedJwt === undefined) {
|
|
74
|
+
throw new utils.DynamicError('Invalid token!');
|
|
75
|
+
}
|
|
76
|
+
const newUser = createUserProfile.createUserProfile(decodedJwt);
|
|
77
|
+
setOnboardingOnlyJwt(undefined);
|
|
78
|
+
setUser(newUser);
|
|
79
|
+
setShowAuthFlow(false);
|
|
80
|
+
setCallback('authSuccess');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
throw new utils.DynamicError('Something went wrong, please try again.');
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
setError('Something went wrong, please try again.');
|
|
87
|
+
if (user) {
|
|
88
|
+
setShowAuthFlow(false);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
goToInitialView();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const handleUseDifferentEmail = () => {
|
|
95
|
+
setError(undefined);
|
|
96
|
+
if (user) {
|
|
97
|
+
setShowAuthFlow(false);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
setView('collect-user-data');
|
|
101
|
+
};
|
|
102
|
+
return (jsxRuntime.jsxs("div", { className: 'merge-user-accounts__container', children: [jsxRuntime.jsxs("div", { className: 'merge-user-accounts__accounts', children: [jsxRuntime.jsxs("div", { className: 'merge-user-accounts__accounts__item', children: [jsxRuntime.jsx(walletBook.WalletIcon, { walletName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.name, className: 'merge-user-accounts__accounts__item__icon' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text', children: shortenWalletAddress.shortenWalletAddress(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address, 3, 3) })] }), jsxRuntime.jsx("div", { className: 'merge-user-accounts__accounts__divider', children: jsxRuntime.jsx(Icon.Icon, { color: 'text-secondary', size: 'small', children: jsxRuntime.jsx(doubleArrowRight.ReactComponent, {}) }) }), jsxRuntime.jsxs("div", { className: 'merge-user-accounts__accounts__item', children: [jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'merge-user-accounts__accounts__item__icon' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text', children: shortenEmail.shortenEmail(email, {
|
|
103
|
+
breakpoint: 4,
|
|
104
|
+
cutEnd: 1,
|
|
105
|
+
cutStart: 2,
|
|
106
|
+
}) })] })] }), jsxRuntime.jsx(Typography.Typography, { weight: 'regular', variant: 'title', className: 'merge-user-accounts__text merge-user-accounts__text__header', children: "Would you like to link this wallet to this existing account?" }), jsxRuntime.jsxs(Typography.Typography, { weight: 'medium', variant: 'body_normal', className: 'merge-user-accounts__text merge-user-accounts__text__body', children: ["An account already exists that uses", ' ', jsxRuntime.jsx("span", { className: 'merge-user-accounts__text--bold', children: shortenEmail.shortenEmail(email, {
|
|
107
|
+
breakpoint: 14,
|
|
108
|
+
}) }), ' ', "email."] }), jsxRuntime.jsxs("div", { className: 'merge-user-accounts__buttons', children: [jsxRuntime.jsx(Button.Button, { className: 'merge-user-accounts__buttons__button', onClick: handleMergeUserAccounts, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'default', children: "Yes, link to existing account" }), jsxRuntime.jsx(Button.Button, { className: 'merge-user-accounts__buttons__button', onClick: handleUseDifferentEmail, buttonVariant: 'secondary', buttonPadding: 'large', buttonRounded: 'default', children: "No, I'll use a different email" })] })] }));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
exports.MergeUserAccountsView = MergeUserAccountsView;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
4
|
+
import { WalletIcon } from '@dynamic-labs/wallet-book';
|
|
5
|
+
import { UserProfileIcon } from '@dynamic-labs/iconic';
|
|
6
|
+
import 'react';
|
|
7
|
+
import { Typography } from '../../components/Typography/Typography.js';
|
|
8
|
+
import { decodeJwt } from '../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
9
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import { ReactComponent as SvgDoubleArrowRight } from '../../shared/assets/double-arrow-right.js';
|
|
12
|
+
import '../../shared/logger.js';
|
|
13
|
+
import { shortenWalletAddress } from '../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
|
|
14
|
+
import '../../utils/constants/colors.js';
|
|
15
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
16
|
+
import 'viem';
|
|
17
|
+
import '../../shared/consts/index.js';
|
|
18
|
+
import { useInternalDynamicContext } from '../../context/DynamicContext/useInternalDynamicContext.js';
|
|
19
|
+
import { storeAuthToken } from '../../utils/functions/storeAuthToken/index.js';
|
|
20
|
+
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import { createUserProfile } from '../../utils/functions/createUserProfile/createUserProfile.js';
|
|
22
|
+
import '@dynamic-labs/sdk-api';
|
|
23
|
+
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
24
|
+
import '../../context/ThemeContext/ThemeContext.js';
|
|
25
|
+
import { Icon } from '../../components/Icon/Icon.js';
|
|
26
|
+
import 'react-dom';
|
|
27
|
+
import 'react-focus-lock';
|
|
28
|
+
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
29
|
+
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
30
|
+
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
31
|
+
import { mergeUserAccounts } from '../../data/api.js';
|
|
32
|
+
import '@dynamic-labs/rpc-providers';
|
|
33
|
+
import '../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
34
|
+
import { useErrorContext } from '../../context/ErrorContext/ErrorContext.js';
|
|
35
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
36
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
37
|
+
import '../../components/IconButton/IconButton.js';
|
|
38
|
+
import { Button } from '../../components/Button/Button.js';
|
|
39
|
+
import '../../components/Alert/Alert.js';
|
|
40
|
+
import '../../context/MockContext/MockContext.js';
|
|
41
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
42
|
+
import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
43
|
+
import { shortenEmail } from '../../shared/utils/functions/shortenEmail/shortenEmail.js';
|
|
44
|
+
import '../../components/Popper/Popper/Popper.js';
|
|
45
|
+
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
46
|
+
import 'formik';
|
|
47
|
+
import 'yup';
|
|
48
|
+
import '../../components/InlineWidget/InlineWidget.js';
|
|
49
|
+
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
50
|
+
import { useEmailVerificationContext } from '../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
51
|
+
|
|
52
|
+
const MergeUserAccountsView = () => {
|
|
53
|
+
const { environmentId, setUser, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, primaryWallet, user, authToken, onboardingOnlyJwt, } = useInternalDynamicContext();
|
|
54
|
+
const { setError } = useErrorContext();
|
|
55
|
+
const { setView, goToInitialView } = useViewContext();
|
|
56
|
+
const { email } = useEmailVerificationContext();
|
|
57
|
+
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
58
|
+
// If user tries to merge during KYC step, authToken is undefined and onboardingOnlyJwt is defined
|
|
59
|
+
const jwtToken = authToken || onboardingOnlyJwt;
|
|
60
|
+
const handleMergeUserAccounts = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
if (!jwtToken) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const newJwt = yield mergeUserAccounts(jwtToken, environmentId);
|
|
66
|
+
if (newJwt) {
|
|
67
|
+
storeAuthToken(newJwt);
|
|
68
|
+
const decodedJwt = decodeJwt(newJwt);
|
|
69
|
+
if (decodedJwt === undefined) {
|
|
70
|
+
throw new DynamicError('Invalid token!');
|
|
71
|
+
}
|
|
72
|
+
const newUser = createUserProfile(decodedJwt);
|
|
73
|
+
setOnboardingOnlyJwt(undefined);
|
|
74
|
+
setUser(newUser);
|
|
75
|
+
setShowAuthFlow(false);
|
|
76
|
+
setCallback('authSuccess');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
throw new DynamicError('Something went wrong, please try again.');
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
setError('Something went wrong, please try again.');
|
|
83
|
+
if (user) {
|
|
84
|
+
setShowAuthFlow(false);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
goToInitialView();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const handleUseDifferentEmail = () => {
|
|
91
|
+
setError(undefined);
|
|
92
|
+
if (user) {
|
|
93
|
+
setShowAuthFlow(false);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
setView('collect-user-data');
|
|
97
|
+
};
|
|
98
|
+
return (jsxs("div", { className: 'merge-user-accounts__container', children: [jsxs("div", { className: 'merge-user-accounts__accounts', children: [jsxs("div", { className: 'merge-user-accounts__accounts__item', children: [jsx(WalletIcon, { walletName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.name, className: 'merge-user-accounts__accounts__item__icon' }), jsx(Typography, { variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text', children: shortenWalletAddress(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address, 3, 3) })] }), jsx("div", { className: 'merge-user-accounts__accounts__divider', children: jsx(Icon, { color: 'text-secondary', size: 'small', children: jsx(SvgDoubleArrowRight, {}) }) }), jsxs("div", { className: 'merge-user-accounts__accounts__item', children: [jsx(UserProfileIcon, { className: 'merge-user-accounts__accounts__item__icon' }), jsx(Typography, { variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text', children: shortenEmail(email, {
|
|
99
|
+
breakpoint: 4,
|
|
100
|
+
cutEnd: 1,
|
|
101
|
+
cutStart: 2,
|
|
102
|
+
}) })] })] }), jsx(Typography, { weight: 'regular', variant: 'title', className: 'merge-user-accounts__text merge-user-accounts__text__header', children: "Would you like to link this wallet to this existing account?" }), jsxs(Typography, { weight: 'medium', variant: 'body_normal', className: 'merge-user-accounts__text merge-user-accounts__text__body', children: ["An account already exists that uses", ' ', jsx("span", { className: 'merge-user-accounts__text--bold', children: shortenEmail(email, {
|
|
103
|
+
breakpoint: 14,
|
|
104
|
+
}) }), ' ', "email."] }), jsxs("div", { className: 'merge-user-accounts__buttons', children: [jsx(Button, { className: 'merge-user-accounts__buttons__button', onClick: handleMergeUserAccounts, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'default', children: "Yes, link to existing account" }), jsx(Button, { className: 'merge-user-accounts__buttons__button', onClick: handleUseDifferentEmail, buttonVariant: 'secondary', buttonPadding: 'large', buttonRounded: 'default', children: "No, I'll use a different email" })] })] }));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { MergeUserAccountsView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MergeUserAccountsView } from './MergeUserAccountsView';
|
|
@@ -57,6 +57,7 @@ const NetworkNotSupported = () => {
|
|
|
57
57
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
58
58
|
const { data: walletConnectorNetwork } = usePromise.usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
|
|
59
59
|
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
60
|
+
shouldCallCallback: false,
|
|
60
61
|
shouldUpdateWallets: !isFullyConnected,
|
|
61
62
|
});
|
|
62
63
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
|
|
@@ -53,6 +53,7 @@ const NetworkNotSupported = () => {
|
|
|
53
53
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
54
54
|
const { data: walletConnectorNetwork } = usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
|
|
55
55
|
const finishConnectAndSign = useConnectAndSign({
|
|
56
|
+
shouldCallCallback: false,
|
|
56
57
|
shouldUpdateWallets: !isFullyConnected,
|
|
57
58
|
});
|
|
58
59
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = useState(false);
|
|
@@ -60,6 +60,7 @@ const NetworkNotSupportedSwitchManual = () => {
|
|
|
60
60
|
deps: [walletConnector, connectedWallets],
|
|
61
61
|
});
|
|
62
62
|
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
63
|
+
shouldCallCallback: false,
|
|
63
64
|
shouldUpdateWallets: !isFullyConnected,
|
|
64
65
|
});
|
|
65
66
|
// Finishes auth flow when wallet switches to proper network
|
|
@@ -56,6 +56,7 @@ const NetworkNotSupportedSwitchManual = () => {
|
|
|
56
56
|
deps: [walletConnector, connectedWallets],
|
|
57
57
|
});
|
|
58
58
|
const finishConnectAndSign = useConnectAndSign({
|
|
59
|
+
shouldCallCallback: false,
|
|
59
60
|
shouldUpdateWallets: !isFullyConnected,
|
|
60
61
|
});
|
|
61
62
|
// Finishes auth flow when wallet switches to proper network
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
6
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
6
|
var React = require('react');
|
|
8
7
|
var viem = require('viem');
|
|
@@ -10,7 +9,7 @@ var utils = require('@dynamic-labs/utils');
|
|
|
10
9
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
11
10
|
require('@dynamic-labs/sdk-api');
|
|
12
11
|
require('../../config/ApiEndpoint.cjs');
|
|
13
|
-
|
|
12
|
+
require('../../shared/logger.cjs');
|
|
14
13
|
var getChainIcon = require('../../shared/utils/functions/chain/getChainIcon.cjs');
|
|
15
14
|
require('@dynamic-labs/wallet-book');
|
|
16
15
|
var shortenWalletAddress = require('../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
|
|
@@ -42,9 +41,9 @@ require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
|
42
41
|
var SendBalancePageLayout = require('../../components/SendBalancePageLayout/SendBalancePageLayout.cjs');
|
|
43
42
|
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
44
43
|
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
45
|
-
var TransactionConfirmationView = require('../TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
46
|
-
var TransactionStatusLayout = require('../../components/TransactionStatusLayout/TransactionStatusLayout.cjs');
|
|
47
44
|
var useFetchCurrency = require('../../widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs');
|
|
45
|
+
var TransactionStatusLayout = require('../../components/TransactionStatusLayout/TransactionStatusLayout.cjs');
|
|
46
|
+
var TransactionStage = require('./components/TransactionStage/TransactionStage.cjs');
|
|
48
47
|
require('../../context/MockContext/MockContext.cjs');
|
|
49
48
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
50
49
|
var usePromise = require('../../utils/hooks/usePromise/usePromise.cjs');
|
|
@@ -52,19 +51,19 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
|
52
51
|
|
|
53
52
|
const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBack, onClickClose, onError, onSuccess, onDone, displayPoweredByDynamicFooter = false, }) => {
|
|
54
53
|
const [stage, setStage] = React.useState('form');
|
|
55
|
-
const { primaryWallet,
|
|
54
|
+
const { primaryWallet, network } = useInternalDynamicContext.useInternalDynamicContext();
|
|
56
55
|
const [value, setValue] = React.useState(initialValue !== null && initialValue !== void 0 ? initialValue : null);
|
|
57
56
|
const [recipientAddress, setRecipientAddress] = React.useState(initialRecipientAddress);
|
|
58
57
|
const transactionRef = React.useRef(null);
|
|
59
58
|
if (!primaryWallet) {
|
|
60
59
|
throw new utils.DynamicError('Primary wallet is not available, send balance cannot be displayed');
|
|
61
60
|
}
|
|
62
|
-
const
|
|
63
|
-
const { data:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
const walletConnector = primaryWallet.connector;
|
|
62
|
+
const { data: balance } = usePromise.usePromise(() => walletConnector.getBalance(), {
|
|
63
|
+
deps: [walletConnector],
|
|
64
|
+
});
|
|
65
|
+
const { data: provider } = usePromise.usePromise(() => primaryWallet.connector.getRpcProvider());
|
|
66
|
+
const evmNetworks = (walletConnector && walletConnector.evmNetworks) || [];
|
|
68
67
|
const evmNetwork = evmNetworks.find((evmNetwork) => evmNetwork.chainId === network);
|
|
69
68
|
const networkIcon = evmNetwork && (jsxRuntime.jsx("img", { src: evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.iconUrls[0], alt: `${evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name} icon` }));
|
|
70
69
|
const networkName = (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.vanityName) || (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name);
|
|
@@ -76,7 +75,7 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
76
75
|
amount: value === null ? '' : formatBigNumber.formatBigNumber(value),
|
|
77
76
|
recipient: recipientAddress,
|
|
78
77
|
}, balance: balance, onClickBack: onClickBack, chain: primaryWallet.chain, networkName: networkName, networkIcon: networkIcon, currencySymbol: currencySymbol, isLoading: false, walletAddress: shortenWalletAddress.shortenWalletAddress(primaryWallet.address, 3, 3), walletName: primaryWallet.connector.name, onClickClose: onClickClose, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSubmit: (data) => {
|
|
79
|
-
setValue(viem.parseEther(data.amount));
|
|
78
|
+
setValue(viem.parseEther(data.amount, 'wei'));
|
|
80
79
|
setRecipientAddress(data.recipient);
|
|
81
80
|
setStage('confirmation');
|
|
82
81
|
} }));
|
|
@@ -85,36 +84,16 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
85
84
|
return null;
|
|
86
85
|
}
|
|
87
86
|
const transaction = {
|
|
88
|
-
chain: undefined,
|
|
89
87
|
from: primaryWallet.address,
|
|
90
88
|
to: recipientAddress,
|
|
89
|
+
type: 'eip2930',
|
|
91
90
|
value,
|
|
92
91
|
};
|
|
93
|
-
return (jsxRuntime.jsx(
|
|
92
|
+
return (jsxRuntime.jsx(TransactionStage.TransactionStage, { walletConnector: walletConnector, provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (transaction) => {
|
|
94
93
|
transactionRef.current = transaction;
|
|
95
94
|
setStage('success');
|
|
96
95
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionRef.current);
|
|
97
|
-
}
|
|
98
|
-
walletUiUtils.disabledConfirmationOnce();
|
|
99
|
-
const sentTransaction = yield provider.sendTransaction(Object.assign(Object.assign({ account: transaction.from }, transaction), { chain: utils.getChain(yield provider.getChainId()) }));
|
|
100
|
-
if (!publicClient) {
|
|
101
|
-
throw new utils.DynamicError('Public client is not available, send balance cannot be displayed');
|
|
102
|
-
}
|
|
103
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
104
|
-
for (let i = 0; i < 120; i++) {
|
|
105
|
-
try {
|
|
106
|
-
const tx = yield publicClient.getTransactionReceipt({
|
|
107
|
-
hash: sentTransaction,
|
|
108
|
-
});
|
|
109
|
-
return tx;
|
|
110
|
-
}
|
|
111
|
-
catch (_a) {
|
|
112
|
-
logger.logger.debug(`Transaction not found for hash: ${sentTransaction} Retrying...`);
|
|
113
|
-
yield sleep(1000);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
throw new Error(`Unable to find transaction for hash ${sentTransaction}`);
|
|
117
|
-
}) }));
|
|
96
|
+
} }));
|
|
118
97
|
};
|
|
119
98
|
const buildSuccessState = () => {
|
|
120
99
|
var _a;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC, MouseEventHandler } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Address } from 'viem';
|
|
3
3
|
export type SendBalanceViewProps = {
|
|
4
4
|
displayPoweredByDynamicFooter?: boolean;
|
|
5
5
|
initialRecipientAddress?: string;
|
|
@@ -8,6 +8,6 @@ export type SendBalanceViewProps = {
|
|
|
8
8
|
onClickClose?: MouseEventHandler<HTMLButtonElement>;
|
|
9
9
|
onDone?: () => void;
|
|
10
10
|
onError?: (error: unknown) => void;
|
|
11
|
-
onSuccess?: (transaction:
|
|
11
|
+
onSuccess?: (transaction: Address) => void;
|
|
12
12
|
};
|
|
13
13
|
export declare const SendBalanceView: FC<SendBalanceViewProps>;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
1
|
import { jsx } from 'react/jsx-runtime';
|
|
3
2
|
import { useState, useRef } from 'react';
|
|
4
3
|
import { parseEther } from 'viem';
|
|
5
|
-
import { DynamicError
|
|
4
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
5
|
import { getChainInfo } from '@dynamic-labs/wallet-connector-core';
|
|
7
6
|
import '@dynamic-labs/sdk-api';
|
|
8
7
|
import '../../config/ApiEndpoint.js';
|
|
9
|
-
import
|
|
8
|
+
import '../../shared/logger.js';
|
|
10
9
|
import { getChainIcon } from '../../shared/utils/functions/chain/getChainIcon.js';
|
|
11
10
|
import '@dynamic-labs/wallet-book';
|
|
12
11
|
import { shortenWalletAddress } from '../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
|
|
@@ -38,9 +37,9 @@ import '../../components/Popper/PopperContext/PopperContext.js';
|
|
|
38
37
|
import { SendBalancePageLayout } from '../../components/SendBalancePageLayout/SendBalancePageLayout.js';
|
|
39
38
|
import '../../components/InlineWidget/InlineWidget.js';
|
|
40
39
|
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
41
|
-
import { TransactionConfirmationView } from '../TransactionConfirmationView/TransactionConfirmationView.js';
|
|
42
|
-
import { TransactionStatusLayout } from '../../components/TransactionStatusLayout/TransactionStatusLayout.js';
|
|
43
40
|
import { useFetchCurrency } from '../../widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js';
|
|
41
|
+
import { TransactionStatusLayout } from '../../components/TransactionStatusLayout/TransactionStatusLayout.js';
|
|
42
|
+
import { TransactionStage } from './components/TransactionStage/TransactionStage.js';
|
|
44
43
|
import '../../context/MockContext/MockContext.js';
|
|
45
44
|
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
46
45
|
import { usePromise } from '../../utils/hooks/usePromise/usePromise.js';
|
|
@@ -48,19 +47,19 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
|
48
47
|
|
|
49
48
|
const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBack, onClickClose, onError, onSuccess, onDone, displayPoweredByDynamicFooter = false, }) => {
|
|
50
49
|
const [stage, setStage] = useState('form');
|
|
51
|
-
const { primaryWallet,
|
|
50
|
+
const { primaryWallet, network } = useInternalDynamicContext();
|
|
52
51
|
const [value, setValue] = useState(initialValue !== null && initialValue !== void 0 ? initialValue : null);
|
|
53
52
|
const [recipientAddress, setRecipientAddress] = useState(initialRecipientAddress);
|
|
54
53
|
const transactionRef = useRef(null);
|
|
55
54
|
if (!primaryWallet) {
|
|
56
55
|
throw new DynamicError('Primary wallet is not available, send balance cannot be displayed');
|
|
57
56
|
}
|
|
58
|
-
const
|
|
59
|
-
const { data:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
const walletConnector = primaryWallet.connector;
|
|
58
|
+
const { data: balance } = usePromise(() => walletConnector.getBalance(), {
|
|
59
|
+
deps: [walletConnector],
|
|
60
|
+
});
|
|
61
|
+
const { data: provider } = usePromise(() => primaryWallet.connector.getRpcProvider());
|
|
62
|
+
const evmNetworks = (walletConnector && walletConnector.evmNetworks) || [];
|
|
64
63
|
const evmNetwork = evmNetworks.find((evmNetwork) => evmNetwork.chainId === network);
|
|
65
64
|
const networkIcon = evmNetwork && (jsx("img", { src: evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.iconUrls[0], alt: `${evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name} icon` }));
|
|
66
65
|
const networkName = (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.vanityName) || (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name);
|
|
@@ -72,7 +71,7 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
72
71
|
amount: value === null ? '' : formatBigNumber(value),
|
|
73
72
|
recipient: recipientAddress,
|
|
74
73
|
}, balance: balance, onClickBack: onClickBack, chain: primaryWallet.chain, networkName: networkName, networkIcon: networkIcon, currencySymbol: currencySymbol, isLoading: false, walletAddress: shortenWalletAddress(primaryWallet.address, 3, 3), walletName: primaryWallet.connector.name, onClickClose: onClickClose, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSubmit: (data) => {
|
|
75
|
-
setValue(parseEther(data.amount));
|
|
74
|
+
setValue(parseEther(data.amount, 'wei'));
|
|
76
75
|
setRecipientAddress(data.recipient);
|
|
77
76
|
setStage('confirmation');
|
|
78
77
|
} }));
|
|
@@ -81,36 +80,16 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
81
80
|
return null;
|
|
82
81
|
}
|
|
83
82
|
const transaction = {
|
|
84
|
-
chain: undefined,
|
|
85
83
|
from: primaryWallet.address,
|
|
86
84
|
to: recipientAddress,
|
|
85
|
+
type: 'eip2930',
|
|
87
86
|
value,
|
|
88
87
|
};
|
|
89
|
-
return (jsx(
|
|
88
|
+
return (jsx(TransactionStage, { walletConnector: walletConnector, provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (transaction) => {
|
|
90
89
|
transactionRef.current = transaction;
|
|
91
90
|
setStage('success');
|
|
92
91
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionRef.current);
|
|
93
|
-
}
|
|
94
|
-
walletUiUtils.disabledConfirmationOnce();
|
|
95
|
-
const sentTransaction = yield provider.sendTransaction(Object.assign(Object.assign({ account: transaction.from }, transaction), { chain: getChain(yield provider.getChainId()) }));
|
|
96
|
-
if (!publicClient) {
|
|
97
|
-
throw new DynamicError('Public client is not available, send balance cannot be displayed');
|
|
98
|
-
}
|
|
99
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
100
|
-
for (let i = 0; i < 120; i++) {
|
|
101
|
-
try {
|
|
102
|
-
const tx = yield publicClient.getTransactionReceipt({
|
|
103
|
-
hash: sentTransaction,
|
|
104
|
-
});
|
|
105
|
-
return tx;
|
|
106
|
-
}
|
|
107
|
-
catch (_a) {
|
|
108
|
-
logger.debug(`Transaction not found for hash: ${sentTransaction} Retrying...`);
|
|
109
|
-
yield sleep(1000);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
throw new Error(`Unable to find transaction for hash ${sentTransaction}`);
|
|
113
|
-
}) }));
|
|
92
|
+
} }));
|
|
114
93
|
};
|
|
115
94
|
const buildSuccessState = () => {
|
|
116
95
|
var _a;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
require('react');
|
|
8
|
+
require('@dynamic-labs/utils');
|
|
9
|
+
require('@dynamic-labs/sdk-api');
|
|
10
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
11
|
+
require('../../../../shared/logger.cjs');
|
|
12
|
+
require('@dynamic-labs/iconic');
|
|
13
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
14
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
require('@dynamic-labs/wallet-book');
|
|
16
|
+
require('../../../../utils/constants/colors.cjs');
|
|
17
|
+
require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
|
+
require('viem');
|
|
19
|
+
require('../../../../shared/consts/index.cjs');
|
|
20
|
+
require('@dynamic-labs/multi-wallet');
|
|
21
|
+
var isMagicConnector = require('../../../../utils/functions/isMagicConnector/isMagicConnector.cjs');
|
|
22
|
+
require('@dynamic-labs/rpc-providers');
|
|
23
|
+
require('../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
24
|
+
var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
25
|
+
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
26
|
+
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
27
|
+
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
28
|
+
require('react-dom');
|
|
29
|
+
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
30
|
+
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
31
|
+
require('react-focus-lock');
|
|
32
|
+
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
33
|
+
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
34
|
+
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
35
|
+
require('../../../../components/IconButton/IconButton.cjs');
|
|
36
|
+
require('../../../../components/Alert/Alert.cjs');
|
|
37
|
+
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
38
|
+
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
39
|
+
require('formik');
|
|
40
|
+
require('yup');
|
|
41
|
+
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
42
|
+
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
43
|
+
var TransactionConfirmationView = require('../../../TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
44
|
+
require('../../../../context/MockContext/MockContext.cjs');
|
|
45
|
+
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
46
|
+
require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
47
|
+
var useTransactionWithGasPrice = require('../../../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs');
|
|
48
|
+
|
|
49
|
+
const TransactionStage = (_a) => {
|
|
50
|
+
var { transaction, provider, walletConnector } = _a, rest = _tslib.__rest(_a, ["transaction", "provider", "walletConnector"]);
|
|
51
|
+
const { walletUiUtils } = useInternalDynamicContext.useInternalDynamicContext();
|
|
52
|
+
const transactionWithGasPrice = useTransactionWithGasPrice.useTransactionWithGasPrice({
|
|
53
|
+
enabled: isMagicConnector.isMagicConnector(walletConnector),
|
|
54
|
+
increasePercentage: 5,
|
|
55
|
+
provider,
|
|
56
|
+
transaction,
|
|
57
|
+
});
|
|
58
|
+
return (jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
walletUiUtils.disabledConfirmationOnce();
|
|
60
|
+
const signer = yield walletConnector.getSigner();
|
|
61
|
+
const sentTransaction = yield signer.sendTransaction({
|
|
62
|
+
account: transactionWithGasPrice.from,
|
|
63
|
+
chain: null,
|
|
64
|
+
gasPrice: transactionWithGasPrice.gasPrice,
|
|
65
|
+
to: transactionWithGasPrice.to,
|
|
66
|
+
type: 'eip2930',
|
|
67
|
+
value: transactionWithGasPrice.value,
|
|
68
|
+
});
|
|
69
|
+
return sentTransaction;
|
|
70
|
+
}) }, rest)));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.TransactionStage = TransactionStage;
|