@dynamic-labs/sdk-react-core 0.18.0-beta.32 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +9 -9
- package/src/lib/components/Button/Button.cjs +10 -7
- package/src/lib/components/Button/Button.js +10 -7
- package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
- 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/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +10 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +10 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +2 -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 +3 -1
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +3 -2
- 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 +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +1 -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 +61 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +57 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +47 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +43 -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/CollectUserDataView/UserDataFields/index.cjs +4 -0
- package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +5 -2
- package/src/lib/views/EmailUpdate/EmailUpdate.js +5 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +6 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +7 -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/MergeUserAccountsView/MergeUserAccountsView.cjs +4 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +4 -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 +11 -16
- package/src/lib/views/SendBalanceView/SendBalanceView.js +11 -16
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +66 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +62 -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 +22 -4
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +22 -4
- 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/{useTransactionData/useTransactionData.cjs → useTransactionGas/useTransactionGas.cjs} +17 -42
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
- package/src/lib/views/TransactionConfirmationView/hooks/{useTransactionData/useTransactionData.js → useTransactionGas/useTransactionGas.js} +18 -43
- 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 +7 -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/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +0 -18
|
@@ -1,4 +1,3 @@
|
|
|
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 { utils } from 'ethers';
|
|
@@ -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,18 +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
|
-
|
|
57
|
+
const walletConnector = primaryWallet.connector;
|
|
58
|
+
const { data: balance } = usePromise(() => walletConnector.getBalance(), {
|
|
59
|
+
deps: [walletConnector],
|
|
60
|
+
});
|
|
61
|
+
const { data: provider } = usePromise(() => walletConnector.getWeb3Provider(), { deps: [walletConnector] });
|
|
62
|
+
const evmNetworks = (walletConnector && walletConnector.evmNetworks) || [];
|
|
63
63
|
const evmNetwork = evmNetworks.find((evmNetwork) => evmNetwork.chainId === network);
|
|
64
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` }));
|
|
65
65
|
const networkName = (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.vanityName) || (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name);
|
|
@@ -84,16 +84,11 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
84
84
|
to: recipientAddress,
|
|
85
85
|
value,
|
|
86
86
|
};
|
|
87
|
-
return (jsx(
|
|
87
|
+
return (jsx(TransactionStage, { walletConnector: walletConnector, provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (transaction) => {
|
|
88
88
|
transactionRef.current = transaction;
|
|
89
89
|
setStage('success');
|
|
90
90
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionRef.current);
|
|
91
|
-
}
|
|
92
|
-
walletUiUtils.disabledConfirmationOnce();
|
|
93
|
-
const signer = provider.getSigner();
|
|
94
|
-
const sentTransaction = yield signer.sendTransaction(transaction);
|
|
95
|
-
return sentTransaction;
|
|
96
|
-
}) }));
|
|
91
|
+
} }));
|
|
97
92
|
};
|
|
98
93
|
const buildSuccessState = () => {
|
|
99
94
|
var _a;
|
|
@@ -0,0 +1,66 @@
|
|
|
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('ethers');
|
|
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 = provider.getSigner();
|
|
61
|
+
const sentTransaction = yield signer.sendTransaction(transactionWithGasPrice);
|
|
62
|
+
return sentTransaction;
|
|
63
|
+
}) }, rest)));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
exports.TransactionStage = TransactionStage;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { TransactionConfirmationViewProps } from '../../../TransactionConfirmationView';
|
|
4
|
+
type TransactionStageProps = Omit<TransactionConfirmationViewProps, 'mutation'> & {
|
|
5
|
+
walletConnector: WalletConnector;
|
|
6
|
+
};
|
|
7
|
+
export declare const TransactionStage: FC<TransactionStageProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { __rest, __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@dynamic-labs/utils';
|
|
5
|
+
import '@dynamic-labs/sdk-api';
|
|
6
|
+
import '../../../../config/ApiEndpoint.js';
|
|
7
|
+
import '../../../../shared/logger.js';
|
|
8
|
+
import '@dynamic-labs/iconic';
|
|
9
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import '@dynamic-labs/wallet-book';
|
|
12
|
+
import '../../../../utils/constants/colors.js';
|
|
13
|
+
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import 'ethers';
|
|
15
|
+
import '../../../../shared/consts/index.js';
|
|
16
|
+
import '@dynamic-labs/multi-wallet';
|
|
17
|
+
import { isMagicConnector } from '../../../../utils/functions/isMagicConnector/isMagicConnector.js';
|
|
18
|
+
import '@dynamic-labs/rpc-providers';
|
|
19
|
+
import '../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
20
|
+
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
21
|
+
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
22
|
+
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
23
|
+
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
24
|
+
import 'react-dom';
|
|
25
|
+
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
26
|
+
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
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 '../../../../components/IconButton/IconButton.js';
|
|
32
|
+
import '../../../../components/Alert/Alert.js';
|
|
33
|
+
import '../../../../components/Popper/Popper/Popper.js';
|
|
34
|
+
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
35
|
+
import 'formik';
|
|
36
|
+
import 'yup';
|
|
37
|
+
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
38
|
+
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
39
|
+
import { TransactionConfirmationView } from '../../../TransactionConfirmationView/TransactionConfirmationView.js';
|
|
40
|
+
import '../../../../context/MockContext/MockContext.js';
|
|
41
|
+
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
42
|
+
import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
43
|
+
import { useTransactionWithGasPrice } from '../../../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js';
|
|
44
|
+
|
|
45
|
+
const TransactionStage = (_a) => {
|
|
46
|
+
var { transaction, provider, walletConnector } = _a, rest = __rest(_a, ["transaction", "provider", "walletConnector"]);
|
|
47
|
+
const { walletUiUtils } = useInternalDynamicContext();
|
|
48
|
+
const transactionWithGasPrice = useTransactionWithGasPrice({
|
|
49
|
+
enabled: isMagicConnector(walletConnector),
|
|
50
|
+
increasePercentage: 5,
|
|
51
|
+
provider,
|
|
52
|
+
transaction,
|
|
53
|
+
});
|
|
54
|
+
return (jsx(TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
walletUiUtils.disabledConfirmationOnce();
|
|
56
|
+
const signer = provider.getSigner();
|
|
57
|
+
const sentTransaction = yield signer.sendTransaction(transactionWithGasPrice);
|
|
58
|
+
return sentTransaction;
|
|
59
|
+
}) }, rest)));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { TransactionStage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TransactionStage } from './TransactionStage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TransactionStage';
|
|
@@ -47,14 +47,13 @@ require('../../components/InlineWidget/InlineWidget.cjs');
|
|
|
47
47
|
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
48
48
|
var SocialRedirectContext = require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
49
49
|
|
|
50
|
-
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
51
50
|
const SocialRedirectView = () => {
|
|
52
51
|
const { socialProvider, socialWalletConnector } = SocialRedirectContext.useSocialRedirectContext();
|
|
53
52
|
const getSocialIcon = useGetSocialIcon.useGetSocialIcon();
|
|
54
53
|
if (!socialWalletConnector || !socialProvider) {
|
|
55
54
|
return null;
|
|
56
55
|
}
|
|
57
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('social-redirect-view__container') }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsxRuntime.
|
|
56
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('social-redirect-view__container') }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames.classNames('social-redirect-view__title') }, { children: "Logging you in" }))] })));
|
|
58
57
|
};
|
|
59
58
|
|
|
60
59
|
exports.SocialRedirectView = SocialRedirectView;
|
|
@@ -43,14 +43,13 @@ import '../../components/InlineWidget/InlineWidget.js';
|
|
|
43
43
|
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
44
44
|
import { useSocialRedirectContext } from '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
45
45
|
|
|
46
|
-
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
47
46
|
const SocialRedirectView = () => {
|
|
48
47
|
const { socialProvider, socialWalletConnector } = useSocialRedirectContext();
|
|
49
48
|
const getSocialIcon = useGetSocialIcon();
|
|
50
49
|
if (!socialWalletConnector || !socialProvider) {
|
|
51
50
|
return null;
|
|
52
51
|
}
|
|
53
|
-
return (jsxs("div", Object.assign({ className: classNames('social-redirect-view__container') }, { children: [jsx(IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }),
|
|
52
|
+
return (jsxs("div", Object.assign({ className: classNames('social-redirect-view__container') }, { children: [jsx(IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsx(Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames('social-redirect-view__title') }, { children: "Logging you in" }))] })));
|
|
54
53
|
};
|
|
55
54
|
|
|
56
55
|
export { SocialRedirectView };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
7
|
var React = require('react');
|
|
7
8
|
var ethers = require('ethers');
|
|
@@ -46,7 +47,8 @@ require('yup');
|
|
|
46
47
|
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
47
48
|
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
48
49
|
var useFetchCurrency = require('../../widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs');
|
|
49
|
-
var
|
|
50
|
+
var useTransactionGas = require('./hooks/useTransactionGas/useTransactionGas.cjs');
|
|
51
|
+
var useTransactionTotal = require('./hooks/useTransactionTotal/useTransactionTotal.cjs');
|
|
50
52
|
var transactionErrorMessage = require('./helpers/transactionErrorMessage.cjs');
|
|
51
53
|
require('../../context/MockContext/MockContext.cjs');
|
|
52
54
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
@@ -68,10 +70,24 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
|
|
|
68
70
|
onFailure: (error) => onError === null || onError === void 0 ? void 0 : onError(error),
|
|
69
71
|
onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx),
|
|
70
72
|
});
|
|
71
|
-
const { isLoading:
|
|
73
|
+
const { isLoading: isGasPriceLoading, gasTotalPrice, isGasEstimated, } = useTransactionGas.useTransactionGas({
|
|
72
74
|
provider,
|
|
73
75
|
transaction,
|
|
74
76
|
});
|
|
77
|
+
const { data: transactionToAddress, isLoading: isTransactionToAddressLoading, } = usePromise.usePromise(() => transaction.to);
|
|
78
|
+
const { data: transactionFromAddress, isLoading: isTransactionFromAddressLoading, } = usePromise.usePromise(() => transaction.from);
|
|
79
|
+
const { data: transactionValue, isLoading: isTransactionValueLoading } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
const val = yield transaction.value;
|
|
81
|
+
return val ? ethers.ethers.BigNumber.from(val) : undefined;
|
|
82
|
+
}));
|
|
83
|
+
const total = useTransactionTotal.useTransactionTotal({
|
|
84
|
+
gasTotalPrice,
|
|
85
|
+
transactionValue,
|
|
86
|
+
});
|
|
87
|
+
const isTransactionLoading = isTransactionValueLoading ||
|
|
88
|
+
isGasPriceLoading ||
|
|
89
|
+
isTransactionToAddressLoading ||
|
|
90
|
+
isTransactionFromAddressLoading;
|
|
75
91
|
const ChainIconComponent = getChainIcon.getChainIcon(primaryWallet.chain);
|
|
76
92
|
const chainIcon = (jsxRuntime.jsx(Icon.Icon, Object.assign({ size: 'small' }, { children: jsxRuntime.jsx(ChainIconComponent, {}) })));
|
|
77
93
|
const errorMessage = transactionError && transactionErrorMessage.transactionErrorMessage(transactionError);
|
|
@@ -92,8 +108,10 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
|
|
|
92
108
|
const amountLeft = formatBigNumber.formatBigNumber(missingFunds, 5);
|
|
93
109
|
return `Insufficient funds due to gas price increase from estimate. Please add ${amountLeft} ${currencySymbol} to continue.`;
|
|
94
110
|
}, [currencySymbol, hasInsufficientFunds, missingFunds]);
|
|
95
|
-
return (jsxRuntime.jsxs(TransactionConfirmationPageLayout.TransactionConfirmationPageLayout, Object.assign({ onClickBack: onClickBack, onClickClose: onClickClose, title: title, appOrigin: appOrigin, appName: appName, appLogoUrl: appLogoUrl, isLoading: isLoading, onClickSend: () => send(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton:
|
|
96
|
-
shortenWalletAddress.shortenWalletAddress(transactionToAddress, 4, 4) })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Amount', isLoading:
|
|
111
|
+
return (jsxRuntime.jsxs(TransactionConfirmationPageLayout.TransactionConfirmationPageLayout, Object.assign({ onClickBack: onClickBack, onClickClose: onClickClose, title: title, appOrigin: appOrigin, appName: appName, appLogoUrl: appLogoUrl, isLoading: isLoading, onClickSend: () => send(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton: isTransactionLoading || hasInsufficientFunds, error: errorMessage, warningMessage: warningMessage }, { children: [jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress }, { children: shortenWalletAddress.shortenWalletAddress(transactionFromAddress, 4, 4) })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress }, { children: transactionToAddress &&
|
|
112
|
+
shortenWalletAddress.shortenWalletAddress(transactionToAddress, 4, 4) })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Amount', isLoading: isTransactionValueLoading, isEmpty: !transactionValue, title: transactionValue && formatBigNumber.formatBigNumber(transactionValue), suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount' }, { children: transactionValue ? formatBigNumber.formatBigNumber(transactionValue, 10) : 0 })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: isGasEstimated ? 'Gas (estimate)' : 'Gas', isEmpty: !gasTotalPrice, isLoading: isGasPriceLoading, title: gasTotalPrice && formatBigNumber.formatBigNumber(gasTotalPrice), suffix: gasTotalPrice && currencySymbol, icon: gasTotalPrice && chainIcon, dataTestId: isGasEstimated
|
|
113
|
+
? 'transaction-estimated-gas-fee'
|
|
114
|
+
: 'transaction-gas-fee' }, { children: gasTotalPrice ? formatBigNumber.formatBigNumber(gasTotalPrice, 10) : 'N/A' })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Total', isEmpty: !total, title: total && formatBigNumber.formatBigNumber(total), suffix: total && currencySymbol, icon: total && chainIcon, dataTestId: 'transaction-total' }, { children: total ? formatBigNumber.formatBigNumber(total, 10) : 'N/A' }))] })));
|
|
97
115
|
};
|
|
98
116
|
|
|
99
117
|
exports.TransactionConfirmationView = TransactionConfirmationView;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
1
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
3
|
import { useMemo } from 'react';
|
|
3
4
|
import { ethers } from 'ethers';
|
|
@@ -42,7 +43,8 @@ import 'yup';
|
|
|
42
43
|
import '../../components/InlineWidget/InlineWidget.js';
|
|
43
44
|
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
44
45
|
import { useFetchCurrency } from '../../widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js';
|
|
45
|
-
import {
|
|
46
|
+
import { useTransactionGas } from './hooks/useTransactionGas/useTransactionGas.js';
|
|
47
|
+
import { useTransactionTotal } from './hooks/useTransactionTotal/useTransactionTotal.js';
|
|
46
48
|
import { transactionErrorMessage } from './helpers/transactionErrorMessage.js';
|
|
47
49
|
import '../../context/MockContext/MockContext.js';
|
|
48
50
|
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
@@ -64,10 +66,24 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
|
|
|
64
66
|
onFailure: (error) => onError === null || onError === void 0 ? void 0 : onError(error),
|
|
65
67
|
onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx),
|
|
66
68
|
});
|
|
67
|
-
const { isLoading:
|
|
69
|
+
const { isLoading: isGasPriceLoading, gasTotalPrice, isGasEstimated, } = useTransactionGas({
|
|
68
70
|
provider,
|
|
69
71
|
transaction,
|
|
70
72
|
});
|
|
73
|
+
const { data: transactionToAddress, isLoading: isTransactionToAddressLoading, } = usePromise(() => transaction.to);
|
|
74
|
+
const { data: transactionFromAddress, isLoading: isTransactionFromAddressLoading, } = usePromise(() => transaction.from);
|
|
75
|
+
const { data: transactionValue, isLoading: isTransactionValueLoading } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
const val = yield transaction.value;
|
|
77
|
+
return val ? ethers.BigNumber.from(val) : undefined;
|
|
78
|
+
}));
|
|
79
|
+
const total = useTransactionTotal({
|
|
80
|
+
gasTotalPrice,
|
|
81
|
+
transactionValue,
|
|
82
|
+
});
|
|
83
|
+
const isTransactionLoading = isTransactionValueLoading ||
|
|
84
|
+
isGasPriceLoading ||
|
|
85
|
+
isTransactionToAddressLoading ||
|
|
86
|
+
isTransactionFromAddressLoading;
|
|
71
87
|
const ChainIconComponent = getChainIcon(primaryWallet.chain);
|
|
72
88
|
const chainIcon = (jsx(Icon, Object.assign({ size: 'small' }, { children: jsx(ChainIconComponent, {}) })));
|
|
73
89
|
const errorMessage = transactionError && transactionErrorMessage(transactionError);
|
|
@@ -88,8 +104,10 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
|
|
|
88
104
|
const amountLeft = formatBigNumber(missingFunds, 5);
|
|
89
105
|
return `Insufficient funds due to gas price increase from estimate. Please add ${amountLeft} ${currencySymbol} to continue.`;
|
|
90
106
|
}, [currencySymbol, hasInsufficientFunds, missingFunds]);
|
|
91
|
-
return (jsxs(TransactionConfirmationPageLayout, Object.assign({ onClickBack: onClickBack, onClickClose: onClickClose, title: title, appOrigin: appOrigin, appName: appName, appLogoUrl: appLogoUrl, isLoading: isLoading, onClickSend: () => send(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton:
|
|
92
|
-
shortenWalletAddress(transactionToAddress, 4, 4) })), jsx(TransactionRow, Object.assign({ label: 'Amount', isLoading:
|
|
107
|
+
return (jsxs(TransactionConfirmationPageLayout, Object.assign({ onClickBack: onClickBack, onClickClose: onClickClose, title: title, appOrigin: appOrigin, appName: appName, appLogoUrl: appLogoUrl, isLoading: isLoading, onClickSend: () => send(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton: isTransactionLoading || hasInsufficientFunds, error: errorMessage, warningMessage: warningMessage }, { children: [jsx(TransactionRow, Object.assign({ label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress }, { children: shortenWalletAddress(transactionFromAddress, 4, 4) })), jsx(TransactionRow, Object.assign({ label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress }, { children: transactionToAddress &&
|
|
108
|
+
shortenWalletAddress(transactionToAddress, 4, 4) })), jsx(TransactionRow, Object.assign({ label: 'Amount', isLoading: isTransactionValueLoading, isEmpty: !transactionValue, title: transactionValue && formatBigNumber(transactionValue), suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount' }, { children: transactionValue ? formatBigNumber(transactionValue, 10) : 0 })), jsx(TransactionRow, Object.assign({ label: isGasEstimated ? 'Gas (estimate)' : 'Gas', isEmpty: !gasTotalPrice, isLoading: isGasPriceLoading, title: gasTotalPrice && formatBigNumber(gasTotalPrice), suffix: gasTotalPrice && currencySymbol, icon: gasTotalPrice && chainIcon, dataTestId: isGasEstimated
|
|
109
|
+
? 'transaction-estimated-gas-fee'
|
|
110
|
+
: 'transaction-gas-fee' }, { children: gasTotalPrice ? formatBigNumber(gasTotalPrice, 10) : 'N/A' })), jsx(TransactionRow, Object.assign({ label: 'Total', isEmpty: !total, title: total && formatBigNumber(total), suffix: total && currencySymbol, icon: total && chainIcon, dataTestId: 'transaction-total' }, { children: total ? formatBigNumber(total, 10) : 'N/A' }))] })));
|
|
93
111
|
};
|
|
94
112
|
|
|
95
113
|
export { TransactionConfirmationView };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './useTransactionGas';
|
|
2
|
+
export * from './useTransactionTotal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTransactionGas } from './useTransactionGas';
|
|
@@ -43,54 +43,29 @@ require('../../../../context/MockContext/MockContext.cjs');
|
|
|
43
43
|
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
44
44
|
var usePromise = require('../../../../utils/hooks/usePromise/usePromise.cjs');
|
|
45
45
|
require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
46
|
+
var useTransactionEstimatedGas = require('../../../../utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs');
|
|
46
47
|
|
|
47
|
-
const
|
|
48
|
-
const { data:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const transactionWithNoOrigin = _tslib.__rest(transaction, ["from"]);
|
|
58
|
-
return provider.estimateGas(transactionWithNoOrigin);
|
|
48
|
+
const useTransactionGas = ({ provider, transaction, }) => {
|
|
49
|
+
const { data: estimatedGas, isLoading: isEstimatedGasLoading } = useTransactionEstimatedGas.useTransactionEstimatedGas(provider, transaction);
|
|
50
|
+
const { data: gasPrice, isLoading: isLoadingGasPrice } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
if (transaction.gasPrice) {
|
|
52
|
+
const gasPrice = yield transaction.gasPrice;
|
|
53
|
+
return gasPrice ? ethers.ethers.BigNumber.from(gasPrice) : undefined;
|
|
54
|
+
}
|
|
55
|
+
return provider.getGasPrice();
|
|
56
|
+
}), {
|
|
57
|
+
deps: [transaction.gasPrice],
|
|
59
58
|
});
|
|
60
|
-
const
|
|
61
|
-
const isGasPriceLoading = isEstimatedGasLoading || isFeeDataLoading;
|
|
62
|
-
const gasEstimate = React.useMemo(() => gasPrice && estimatedGas
|
|
59
|
+
const gasTotalPrice = React.useMemo(() => gasPrice && estimatedGas
|
|
63
60
|
? ethers.ethers.BigNumber.from(gasPrice).mul(estimatedGas)
|
|
64
61
|
: undefined, [gasPrice, estimatedGas]);
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const total = React.useMemo(() => {
|
|
68
|
-
if (gasEstimate !== undefined && transactionValue !== undefined) {
|
|
69
|
-
return gasEstimate.add(transactionValue);
|
|
70
|
-
}
|
|
71
|
-
return transactionValue || gasEstimate;
|
|
72
|
-
}, [gasEstimate, transactionValue]);
|
|
73
|
-
const isLoading = React.useMemo(() => isEffectiveValueLoading ||
|
|
74
|
-
isGasPriceLoading ||
|
|
75
|
-
isTransactionToAddressLoading ||
|
|
76
|
-
isTransactionFromAddressLoading, [
|
|
77
|
-
isEffectiveValueLoading,
|
|
78
|
-
isGasPriceLoading,
|
|
79
|
-
isTransactionToAddressLoading,
|
|
80
|
-
isTransactionFromAddressLoading,
|
|
81
|
-
]);
|
|
62
|
+
const isLoading = isEstimatedGasLoading || isLoadingGasPrice;
|
|
63
|
+
const isGasEstimated = Boolean(estimatedGas) && !transaction.gasPrice;
|
|
82
64
|
return {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
isGasPriceLoading,
|
|
65
|
+
gasTotalPrice,
|
|
66
|
+
isGasEstimated,
|
|
86
67
|
isLoading,
|
|
87
|
-
isTransactionFromAddressLoading,
|
|
88
|
-
isTransactionToAddressLoading,
|
|
89
|
-
total,
|
|
90
|
-
transactionFromAddress,
|
|
91
|
-
transactionToAddress,
|
|
92
|
-
transactionValue,
|
|
93
68
|
};
|
|
94
69
|
};
|
|
95
70
|
|
|
96
|
-
exports.
|
|
71
|
+
exports.useTransactionGas = useTransactionGas;
|
package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
type UseTransactionGasProps = {
|
|
3
|
+
provider: ethers.providers.Web3Provider;
|
|
4
|
+
transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>;
|
|
5
|
+
};
|
|
6
|
+
export declare const useTransactionGas: ({ provider, transaction, }: UseTransactionGasProps) => {
|
|
7
|
+
gasTotalPrice: ethers.BigNumber | undefined;
|
|
8
|
+
isGasEstimated: boolean;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __awaiter
|
|
1
|
+
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
4
|
import '@dynamic-labs/utils';
|
|
@@ -39,54 +39,29 @@ import '../../../../context/MockContext/MockContext.js';
|
|
|
39
39
|
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
40
40
|
import { usePromise } from '../../../../utils/hooks/usePromise/usePromise.js';
|
|
41
41
|
import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
42
|
+
import { useTransactionEstimatedGas } from '../../../../utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js';
|
|
42
43
|
|
|
43
|
-
const
|
|
44
|
-
const { data:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const transactionWithNoOrigin = __rest(transaction, ["from"]);
|
|
54
|
-
return provider.estimateGas(transactionWithNoOrigin);
|
|
44
|
+
const useTransactionGas = ({ provider, transaction, }) => {
|
|
45
|
+
const { data: estimatedGas, isLoading: isEstimatedGasLoading } = useTransactionEstimatedGas(provider, transaction);
|
|
46
|
+
const { data: gasPrice, isLoading: isLoadingGasPrice } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
if (transaction.gasPrice) {
|
|
48
|
+
const gasPrice = yield transaction.gasPrice;
|
|
49
|
+
return gasPrice ? ethers.BigNumber.from(gasPrice) : undefined;
|
|
50
|
+
}
|
|
51
|
+
return provider.getGasPrice();
|
|
52
|
+
}), {
|
|
53
|
+
deps: [transaction.gasPrice],
|
|
55
54
|
});
|
|
56
|
-
const
|
|
57
|
-
const isGasPriceLoading = isEstimatedGasLoading || isFeeDataLoading;
|
|
58
|
-
const gasEstimate = useMemo(() => gasPrice && estimatedGas
|
|
55
|
+
const gasTotalPrice = useMemo(() => gasPrice && estimatedGas
|
|
59
56
|
? ethers.BigNumber.from(gasPrice).mul(estimatedGas)
|
|
60
57
|
: undefined, [gasPrice, estimatedGas]);
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const total = useMemo(() => {
|
|
64
|
-
if (gasEstimate !== undefined && transactionValue !== undefined) {
|
|
65
|
-
return gasEstimate.add(transactionValue);
|
|
66
|
-
}
|
|
67
|
-
return transactionValue || gasEstimate;
|
|
68
|
-
}, [gasEstimate, transactionValue]);
|
|
69
|
-
const isLoading = useMemo(() => isEffectiveValueLoading ||
|
|
70
|
-
isGasPriceLoading ||
|
|
71
|
-
isTransactionToAddressLoading ||
|
|
72
|
-
isTransactionFromAddressLoading, [
|
|
73
|
-
isEffectiveValueLoading,
|
|
74
|
-
isGasPriceLoading,
|
|
75
|
-
isTransactionToAddressLoading,
|
|
76
|
-
isTransactionFromAddressLoading,
|
|
77
|
-
]);
|
|
58
|
+
const isLoading = isEstimatedGasLoading || isLoadingGasPrice;
|
|
59
|
+
const isGasEstimated = Boolean(estimatedGas) && !transaction.gasPrice;
|
|
78
60
|
return {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
isGasPriceLoading,
|
|
61
|
+
gasTotalPrice,
|
|
62
|
+
isGasEstimated,
|
|
82
63
|
isLoading,
|
|
83
|
-
isTransactionFromAddressLoading,
|
|
84
|
-
isTransactionToAddressLoading,
|
|
85
|
-
total,
|
|
86
|
-
transactionFromAddress,
|
|
87
|
-
transactionToAddress,
|
|
88
|
-
transactionValue,
|
|
89
64
|
};
|
|
90
65
|
};
|
|
91
66
|
|
|
92
|
-
export {
|
|
67
|
+
export { useTransactionGas };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTransactionTotal } from './useTransactionTotal';
|
package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
const useTransactionTotal = ({ transactionValue, gasTotalPrice, }) => React.useMemo(() => {
|
|
8
|
+
if (gasTotalPrice !== undefined && transactionValue !== undefined) {
|
|
9
|
+
return gasTotalPrice.add(transactionValue);
|
|
10
|
+
}
|
|
11
|
+
return transactionValue || gasTotalPrice;
|
|
12
|
+
}, [gasTotalPrice, transactionValue]);
|
|
13
|
+
|
|
14
|
+
exports.useTransactionTotal = useTransactionTotal;
|
package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
type UseTransactionTotalProps = {
|
|
3
|
+
transactionValue?: ethers.BigNumber;
|
|
4
|
+
gasTotalPrice?: ethers.BigNumber;
|
|
5
|
+
};
|
|
6
|
+
export declare const useTransactionTotal: ({ transactionValue, gasTotalPrice, }: UseTransactionTotalProps) => ethers.BigNumber | undefined;
|
|
7
|
+
export {};
|
package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
const useTransactionTotal = ({ transactionValue, gasTotalPrice, }) => useMemo(() => {
|
|
4
|
+
if (gasTotalPrice !== undefined && transactionValue !== undefined) {
|
|
5
|
+
return gasTotalPrice.add(transactionValue);
|
|
6
|
+
}
|
|
7
|
+
return transactionValue || gasTotalPrice;
|
|
8
|
+
}, [gasTotalPrice, transactionValue]);
|
|
9
|
+
|
|
10
|
+
export { useTransactionTotal };
|
|
@@ -78,7 +78,10 @@ const WalletList = ({ isWalletConnectList = false, }) => {
|
|
|
78
78
|
};
|
|
79
79
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", Object.assign({ className: 'wallet-list__container' }, { children: [error && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: error }), !projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { className: 'wallet-list__search-skeleton' })) : (isSearchEnabled && (jsxRuntime.jsx(Search.Search, { label: `Search through ${numberOfWallets} wallets...`, value: filterValue, onChange: ({ target: { value } }) => handleFilterValueChange(value), onClickClear: () => handleFilterValueChange('') }))), jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('wallet-list__scroll-container', {
|
|
80
80
|
'wallet-list__scroll-container--full-height': isSearchEnabled,
|
|
81
|
-
}), "data-testid": 'wallet-list-scroll-container', ref: walletListScrollRef, onScroll: handleScroll }, { children: [!projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: 10, className: 'wallet-list__tile-skeleton' })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [wallets.length === 0 && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: "Oops, no login methods have been configured." })), wallets.length && walletsList.length === 0 ? (jsxRuntime.jsx(SearchNotFoundMessage.SearchNotFoundMessage, { title: 'No wallet found.', subtitle: 'Try searching for a different wallet', image: jsxRuntime.jsx(noWalletFound.ReactComponent, {}) })) : (walletsList.map((wallet) =>
|
|
81
|
+
}), "data-testid": 'wallet-list-scroll-container', ref: walletListScrollRef, onScroll: handleScroll }, { children: [!projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: 10, className: 'wallet-list__tile-skeleton' })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [wallets.length === 0 && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: "Oops, no login methods have been configured." })), wallets.length && walletsList.length === 0 ? (jsxRuntime.jsx(SearchNotFoundMessage.SearchNotFoundMessage, { title: 'No wallet found.', subtitle: 'Try searching for a different wallet', image: jsxRuntime.jsx(noWalletFound.ReactComponent, {}) })) : (walletsList.map((wallet) => {
|
|
82
|
+
var _a;
|
|
83
|
+
return (jsxRuntime.jsx(WalletListItem.WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet, onResetSearchValue: () => handleFilterValueChange('') }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
|
|
84
|
+
}))] })), isSearchEnabled && !filterValue && projectSettings && (jsxRuntime.jsx(SearchNotFoundMessage.SearchNotFoundMessage, {}))] }))] })), noDefaultFooter && (jsxRuntime.jsx("div", { className: classNames.classNames('wallet-list__tiny-footer', {
|
|
82
85
|
'wallet-list__tiny-footer--hidden': footerIsVisible,
|
|
83
86
|
}), "data-testid": 'wallet-list-tiny-footer' }))] }));
|
|
84
87
|
};
|