2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { compose } from 'redux';
|
|
|
|
import { withRouter } from 'react-router-dom';
|
2023-06-07 08:43:28 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
import { showCustodianDeepLink } from '@metamask-institutional/extension';
|
|
|
|
import { mmiActionsFactory } from '../../store/institutional/institution-background';
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2021-02-04 19:15:23 +01:00
|
|
|
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck';
|
2019-07-03 22:33:44 +02:00
|
|
|
|
2019-09-27 06:30:36 +02:00
|
|
|
import {
|
|
|
|
updateCustomNonce,
|
|
|
|
cancelTx,
|
|
|
|
cancelTxs,
|
|
|
|
updateAndApproveTx,
|
|
|
|
showModal,
|
|
|
|
getNextNonce,
|
2019-11-01 18:54:00 +01:00
|
|
|
tryReverseResolveAddress,
|
2021-05-03 19:51:09 +02:00
|
|
|
setDefaultHomeActiveTabName,
|
2023-02-09 18:45:52 +01:00
|
|
|
addToAddressBook,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../store/actions';
|
2022-09-16 21:05:21 +02:00
|
|
|
import { isBalanceSufficient } from '../send/send.utils';
|
2022-03-07 19:54:36 +01:00
|
|
|
import { shortenAddress, valuesFor } from '../../helpers/utils/util';
|
2020-05-02 21:41:17 +02:00
|
|
|
import {
|
|
|
|
getAdvancedInlineGasShown,
|
|
|
|
getCustomNonceValue,
|
|
|
|
getIsMainnet,
|
|
|
|
getKnownMethodData,
|
|
|
|
getMetaMaskAccounts,
|
|
|
|
getUseNonceField,
|
|
|
|
transactionFeeSelector,
|
2021-04-28 20:02:01 +02:00
|
|
|
getNoGasPriceFetched,
|
|
|
|
getIsEthGasPriceFetched,
|
2021-06-24 01:28:49 +02:00
|
|
|
getShouldShowFiat,
|
2021-08-03 00:52:18 +02:00
|
|
|
checkNetworkAndAccountSupports1559,
|
2021-08-06 03:07:04 +02:00
|
|
|
getPreferences,
|
2021-10-21 21:17:03 +02:00
|
|
|
doesAddressRequireLedgerHidConnection,
|
2021-09-09 22:56:27 +02:00
|
|
|
getTokenList,
|
2021-11-11 17:46:45 +01:00
|
|
|
getIsMultiLayerFeeNetwork,
|
2022-03-25 15:02:08 +01:00
|
|
|
getIsBuyableChain,
|
2022-06-13 18:18:33 +02:00
|
|
|
getEnsResolutionByAddress,
|
2022-10-28 10:37:33 +02:00
|
|
|
getUnapprovedTransaction,
|
|
|
|
getFullTxData,
|
2023-01-17 16:23:04 +01:00
|
|
|
getUseCurrencyRateCheck,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../selectors';
|
|
|
|
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
2021-08-17 22:08:13 +02:00
|
|
|
import {
|
2021-10-21 21:17:03 +02:00
|
|
|
isAddressLedger,
|
2022-03-25 18:11:04 +01:00
|
|
|
updateGasFees,
|
2021-08-06 01:59:58 +02:00
|
|
|
getIsGasEstimatesLoading,
|
2021-09-15 23:54:51 +02:00
|
|
|
getNativeCurrency,
|
2023-02-09 18:45:52 +01:00
|
|
|
getSendToAccounts,
|
2023-05-02 14:36:24 +02:00
|
|
|
getProviderConfig,
|
2021-08-06 01:59:58 +02:00
|
|
|
} from '../../ducks/metamask/metamask';
|
2023-06-07 08:43:28 +02:00
|
|
|
import {
|
|
|
|
addHexPrefix,
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
getEnvironmentType,
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
} from '../../../app/scripts/lib/util';
|
2021-10-21 21:17:03 +02:00
|
|
|
|
|
|
|
import {
|
2022-03-17 19:35:40 +01:00
|
|
|
parseStandardTokenTransactionData,
|
2021-10-21 21:17:03 +02:00
|
|
|
transactionMatchesNetwork,
|
|
|
|
txParamsAreDappSuggested,
|
|
|
|
} from '../../../shared/modules/transaction.utils';
|
2023-05-18 19:19:40 +02:00
|
|
|
import {
|
|
|
|
isEmptyHexString,
|
|
|
|
toChecksumHexAddress,
|
|
|
|
} from '../../../shared/modules/hexstring-utils';
|
2021-10-21 21:17:03 +02:00
|
|
|
|
2021-08-06 01:59:58 +02:00
|
|
|
import { getGasLoadingAnimationIsShowing } from '../../ducks/app/app';
|
2021-10-06 20:29:57 +02:00
|
|
|
import { isLegacyTransaction } from '../../helpers/utils/transactions.util';
|
2021-11-06 01:59:23 +01:00
|
|
|
import { CUSTOM_GAS_ESTIMATE } from '../../../shared/constants/gas';
|
2023-06-07 08:43:28 +02:00
|
|
|
|
2023-05-16 17:44:08 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
import { getAccountType } from '../../selectors/selectors';
|
2023-06-07 08:43:28 +02:00
|
|
|
import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../shared/constants/app';
|
|
|
|
import { getIsNoteToTraderSupported } from '../../selectors/institutional/selectors';
|
2023-07-13 10:42:08 +02:00
|
|
|
import { showCustodyConfirmLink } from '../../store/institutional/institution-actions';
|
2023-05-16 17:44:08 +02:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
2022-11-04 17:14:43 +01:00
|
|
|
import {
|
2023-01-18 15:47:29 +01:00
|
|
|
TransactionStatus,
|
|
|
|
TransactionType,
|
2022-11-04 17:14:43 +01:00
|
|
|
} from '../../../shared/constants/transaction';
|
2022-03-17 19:35:40 +01:00
|
|
|
import { getTokenAddressParam } from '../../helpers/utils/token-util';
|
2022-09-16 21:05:21 +02:00
|
|
|
import { calcGasTotal } from '../../../shared/lib/transactions-controller-utils';
|
2021-02-04 19:15:23 +01:00
|
|
|
import ConfirmTransactionBase from './confirm-transaction-base.component';
|
2018-07-20 23:18:50 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
let customNonceValue = '';
|
2020-11-03 00:41:28 +01:00
|
|
|
const customNonceMerge = (txData) =>
|
|
|
|
customNonceValue
|
|
|
|
? {
|
|
|
|
...txData,
|
|
|
|
customNonceValue,
|
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
: txData;
|
2019-09-27 06:30:36 +02:00
|
|
|
|
2023-02-09 18:45:52 +01:00
|
|
|
function addressIsNew(toAccounts, newAddress) {
|
|
|
|
const newAddressNormalized = newAddress.toLowerCase();
|
|
|
|
const foundMatching = toAccounts.some(
|
|
|
|
({ address }) => address.toLowerCase() === newAddressNormalized,
|
|
|
|
);
|
|
|
|
return !foundMatching;
|
|
|
|
}
|
|
|
|
|
2019-06-18 14:17:14 +02:00
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
toAddress: propsToAddress,
|
|
|
|
customTxParamsData,
|
|
|
|
match: { params = {} },
|
2021-02-04 19:15:23 +01:00
|
|
|
} = ownProps;
|
|
|
|
const { id: paramsTransactionId } = params;
|
|
|
|
const isMainnet = getIsMainnet(state);
|
2021-08-06 01:59:58 +02:00
|
|
|
|
2023-06-07 08:43:28 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
const envType = getEnvironmentType();
|
|
|
|
const isNotification = envType === ENVIRONMENT_TYPE_NOTIFICATION;
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
|
2021-08-06 01:59:58 +02:00
|
|
|
const isGasEstimatesLoading = getIsGasEstimatesLoading(state);
|
|
|
|
const gasLoadingAnimationIsShowing = getGasLoadingAnimationIsShowing(state);
|
2022-03-25 15:02:08 +01:00
|
|
|
const isBuyableChain = getIsBuyableChain(state);
|
2021-02-04 19:15:23 +01:00
|
|
|
const { confirmTransaction, metamask } = state;
|
2019-07-03 22:33:44 +02:00
|
|
|
const {
|
|
|
|
conversionRate,
|
|
|
|
identities,
|
2019-08-08 20:45:30 +02:00
|
|
|
addressBook,
|
NetworkController: Split `network` into `networkId` and `networkStatus` (#17556)
The `network` store of the network controller crams two types of data
into one place. It roughly tracks whether we have enough information to
make requests to the network and whether the network is capable of
receiving requests, but it also stores the ID of the network (as
obtained via `net_version`).
Generally we shouldn't be using the network ID for anything, as it has
been completely replaced by chain ID, which all custom RPC endpoints
have been required to support for over a year now. However, as the
network ID is used in various places within the extension codebase,
removing it entirely would be a non-trivial effort. So, minimally, this
commit splits `network` into two stores: `networkId` and
`networkStatus`. But it also expands the concept of network status.
Previously, the network was in one of two states: "loading" and
"not-loading". But now it can be in one of four states:
- `available`: The network is able to receive and respond to requests.
- `unavailable`: The network is not able to receive and respond to
requests for unknown reasons.
- `blocked`: The network is actively blocking requests based on the
user's geolocation. (This is specific to Infura.)
- `unknown`: We don't know whether the network can receive and respond
to requests, either because we haven't checked or we tried to check
and were unsuccessful.
This commit also changes how the network status is determined —
specifically, how many requests are used to determine that status, when
they occur, and whether they are awaited. Previously, the network
controller would make 2 to 3 requests during the course of running
`lookupNetwork`.
* First, if it was an Infura network, it would make a request for
`eth_blockNumber` to determine whether Infura was blocking requests or
not, then emit an appropriate event. This operation was not awaited.
* Then, regardless of the network, it would fetch the network ID via
`net_version`. This operation was awaited.
* Finally, regardless of the network, it would fetch the latest block
via `eth_getBlockByNumber`, then use the result to determine whether
the network supported EIP-1559. This operation was awaited.
Now:
* One fewer request is made, specifically `eth_blockNumber`, as we don't
need to make an extra request to determine whether Infura is blocking
requests; we can reuse `eth_getBlockByNumber`;
* All requests are awaited, which makes `lookupNetwork` run fully
in-band instead of partially out-of-band; and
* Both requests for `net_version` and `eth_getBlockByNumber` are
performed in parallel to make `lookupNetwork` run slightly faster.
2023-03-31 00:49:12 +02:00
|
|
|
networkId,
|
2019-07-03 22:33:44 +02:00
|
|
|
unapprovedTxs,
|
2019-09-27 06:30:36 +02:00
|
|
|
nextNonce,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = metamask;
|
2023-05-02 14:36:24 +02:00
|
|
|
const { chainId } = getProviderConfig(state);
|
2021-02-04 19:15:23 +01:00
|
|
|
const { tokenData, txData, tokenProps, nonce } = confirmTransaction;
|
2021-06-29 18:02:00 +02:00
|
|
|
const { txParams = {}, id: transactionId, type } = txData;
|
2022-10-28 10:37:33 +02:00
|
|
|
const txId = transactionId || Number(paramsTransactionId);
|
|
|
|
const transaction = getUnapprovedTransaction(state, txId);
|
2019-02-06 01:24:28 +01:00
|
|
|
const {
|
|
|
|
from: fromAddress,
|
|
|
|
to: txParamsToAddress,
|
|
|
|
gasPrice,
|
|
|
|
gas: gasLimit,
|
|
|
|
value: amount,
|
2019-06-18 14:17:14 +02:00
|
|
|
data,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = (transaction && transaction.txParams) || txParams;
|
|
|
|
const accounts = getMetaMaskAccounts(state);
|
2018-09-13 10:47:05 +02:00
|
|
|
|
2022-03-17 19:35:40 +01:00
|
|
|
const transactionData = parseStandardTokenTransactionData(data);
|
|
|
|
const tokenToAddress = getTokenAddressParam(transactionData);
|
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const { balance } = accounts[fromAddress];
|
|
|
|
const { name: fromName } = identities[fromAddress];
|
2023-05-18 19:19:40 +02:00
|
|
|
|
|
|
|
const isSendingAmount =
|
|
|
|
type === TransactionType.simpleSend || !isEmptyHexString(amount);
|
|
|
|
|
|
|
|
const toAddress = isSendingAmount
|
|
|
|
? txParamsToAddress
|
|
|
|
: propsToAddress || tokenToAddress || txParamsToAddress;
|
2020-08-13 22:00:09 +02:00
|
|
|
|
2023-02-09 18:45:52 +01:00
|
|
|
const toAccounts = getSendToAccounts(state);
|
|
|
|
|
2021-09-09 22:56:27 +02:00
|
|
|
const tokenList = getTokenList(state);
|
2022-08-10 03:26:25 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const toName =
|
|
|
|
identities[toAddress]?.name ||
|
2022-08-10 03:26:25 +02:00
|
|
|
tokenList[toAddress?.toLowerCase()]?.name ||
|
2021-05-17 23:19:39 +02:00
|
|
|
shortenAddress(toChecksumHexAddress(toAddress));
|
2018-07-20 23:18:50 +02:00
|
|
|
|
2021-05-17 23:19:39 +02:00
|
|
|
const checksummedAddress = toChecksumHexAddress(toAddress);
|
2021-12-01 18:22:08 +01:00
|
|
|
const addressBookObject =
|
|
|
|
addressBook &&
|
|
|
|
addressBook[chainId] &&
|
|
|
|
addressBook[chainId][checksummedAddress];
|
2022-06-13 18:18:33 +02:00
|
|
|
const toEns = getEnsResolutionByAddress(state, checksummedAddress);
|
2021-02-04 19:15:23 +01:00
|
|
|
const toNickname = addressBookObject ? addressBookObject.name : '';
|
|
|
|
const transactionStatus = transaction ? transaction.status : '';
|
2021-10-06 20:29:57 +02:00
|
|
|
const supportsEIP1559 =
|
|
|
|
checkNetworkAndAccountSupports1559(state) && !isLegacyTransaction(txParams);
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2019-07-03 22:33:44 +02:00
|
|
|
const {
|
|
|
|
hexTransactionAmount,
|
2021-07-31 02:45:18 +02:00
|
|
|
hexMaximumTransactionFee,
|
2019-07-03 22:33:44 +02:00
|
|
|
hexTransactionTotal,
|
2021-08-06 21:31:30 +02:00
|
|
|
gasEstimationObject,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = transactionFeeSelector(state, transaction);
|
2019-07-03 22:33:44 +02:00
|
|
|
|
2020-01-10 15:34:02 +01:00
|
|
|
const currentNetworkUnapprovedTxs = Object.keys(unapprovedTxs)
|
2021-03-01 16:15:42 +01:00
|
|
|
.filter((key) =>
|
NetworkController: Split `network` into `networkId` and `networkStatus` (#17556)
The `network` store of the network controller crams two types of data
into one place. It roughly tracks whether we have enough information to
make requests to the network and whether the network is capable of
receiving requests, but it also stores the ID of the network (as
obtained via `net_version`).
Generally we shouldn't be using the network ID for anything, as it has
been completely replaced by chain ID, which all custom RPC endpoints
have been required to support for over a year now. However, as the
network ID is used in various places within the extension codebase,
removing it entirely would be a non-trivial effort. So, minimally, this
commit splits `network` into two stores: `networkId` and
`networkStatus`. But it also expands the concept of network status.
Previously, the network was in one of two states: "loading" and
"not-loading". But now it can be in one of four states:
- `available`: The network is able to receive and respond to requests.
- `unavailable`: The network is not able to receive and respond to
requests for unknown reasons.
- `blocked`: The network is actively blocking requests based on the
user's geolocation. (This is specific to Infura.)
- `unknown`: We don't know whether the network can receive and respond
to requests, either because we haven't checked or we tried to check
and were unsuccessful.
This commit also changes how the network status is determined —
specifically, how many requests are used to determine that status, when
they occur, and whether they are awaited. Previously, the network
controller would make 2 to 3 requests during the course of running
`lookupNetwork`.
* First, if it was an Infura network, it would make a request for
`eth_blockNumber` to determine whether Infura was blocking requests or
not, then emit an appropriate event. This operation was not awaited.
* Then, regardless of the network, it would fetch the network ID via
`net_version`. This operation was awaited.
* Finally, regardless of the network, it would fetch the latest block
via `eth_getBlockByNumber`, then use the result to determine whether
the network supported EIP-1559. This operation was awaited.
Now:
* One fewer request is made, specifically `eth_blockNumber`, as we don't
need to make an extra request to determine whether Infura is blocking
requests; we can reuse `eth_getBlockByNumber`;
* All requests are awaited, which makes `lookupNetwork` run fully
in-band instead of partially out-of-band; and
* Both requests for `net_version` and `eth_getBlockByNumber` are
performed in parallel to make `lookupNetwork` run slightly faster.
2023-03-31 00:49:12 +02:00
|
|
|
transactionMatchesNetwork(unapprovedTxs[key], chainId, networkId),
|
2021-03-01 16:15:42 +01:00
|
|
|
)
|
2021-02-04 19:15:23 +01:00
|
|
|
.reduce((acc, key) => ({ ...acc, [key]: unapprovedTxs[key] }), {});
|
|
|
|
const unapprovedTxCount = valuesFor(currentNetworkUnapprovedTxs).length;
|
2018-09-20 02:48:28 +02:00
|
|
|
|
2019-02-06 01:24:28 +01:00
|
|
|
const insufficientBalance = !isBalanceSufficient({
|
|
|
|
amount,
|
|
|
|
gasTotal: calcGasTotal(gasLimit, gasPrice),
|
|
|
|
balance,
|
|
|
|
conversionRate,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-02-06 01:24:28 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const methodData = getKnownMethodData(state, data) || {};
|
2019-06-18 14:17:14 +02:00
|
|
|
|
2022-11-04 17:14:43 +01:00
|
|
|
const fullTxData = getFullTxData(
|
|
|
|
state,
|
|
|
|
txId,
|
2023-01-18 15:47:29 +01:00
|
|
|
TransactionStatus.unapproved,
|
2022-11-04 17:14:43 +01:00
|
|
|
customTxParamsData,
|
|
|
|
);
|
2022-01-10 17:23:53 +01:00
|
|
|
|
2021-04-17 00:00:18 +02:00
|
|
|
customNonceValue = getCustomNonceValue(state);
|
2021-04-28 20:02:01 +02:00
|
|
|
const isEthGasPrice = getIsEthGasPriceFetched(state);
|
2021-10-06 20:29:57 +02:00
|
|
|
const noGasPrice = !supportsEIP1559 && getNoGasPriceFetched(state);
|
2021-08-06 03:07:04 +02:00
|
|
|
const { useNativeCurrencyAsPrimaryCurrency } = getPreferences(state);
|
2021-08-17 22:08:13 +02:00
|
|
|
const gasFeeIsCustom =
|
2021-11-06 01:59:23 +01:00
|
|
|
fullTxData.userFeeLevel === CUSTOM_GAS_ESTIMATE ||
|
2021-08-17 22:08:13 +02:00
|
|
|
txParamsAreDappSuggested(fullTxData);
|
2021-10-21 21:17:03 +02:00
|
|
|
const fromAddressIsLedger = isAddressLedger(state, fromAddress);
|
2021-09-15 23:54:51 +02:00
|
|
|
const nativeCurrency = getNativeCurrency(state);
|
2023-06-07 08:43:28 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
const accountType = getAccountType(state, fromAddress);
|
|
|
|
const fromChecksumHexAddress = toChecksumHexAddress(fromAddress);
|
|
|
|
const isNoteToTraderSupported = getIsNoteToTraderSupported(
|
|
|
|
state,
|
|
|
|
fromChecksumHexAddress,
|
|
|
|
);
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2021-08-06 21:31:30 +02:00
|
|
|
|
2022-07-31 20:26:40 +02:00
|
|
|
const hardwareWalletRequiresConnection =
|
|
|
|
doesAddressRequireLedgerHidConnection(state, fromAddress);
|
2021-10-21 21:17:03 +02:00
|
|
|
|
2021-11-11 17:46:45 +01:00
|
|
|
const isMultiLayerFeeNetwork = getIsMultiLayerFeeNetwork(state);
|
|
|
|
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
balance,
|
|
|
|
fromAddress,
|
|
|
|
fromName,
|
2023-02-09 18:45:52 +01:00
|
|
|
toAccounts,
|
2018-06-23 08:52:45 +02:00
|
|
|
toAddress,
|
2019-11-01 18:54:00 +01:00
|
|
|
toEns,
|
2018-06-23 08:52:45 +02:00
|
|
|
toName,
|
2019-08-08 20:45:30 +02:00
|
|
|
toNickname,
|
2018-10-17 01:03:29 +02:00
|
|
|
hexTransactionAmount,
|
2021-07-31 02:45:18 +02:00
|
|
|
hexMaximumTransactionFee,
|
2018-10-17 01:03:29 +02:00
|
|
|
hexTransactionTotal,
|
2019-11-05 16:13:48 +01:00
|
|
|
txData: fullTxData,
|
2018-06-23 08:52:45 +02:00
|
|
|
tokenData,
|
2018-06-28 20:23:31 +02:00
|
|
|
methodData,
|
2018-06-23 08:52:45 +02:00
|
|
|
tokenProps,
|
|
|
|
conversionRate,
|
|
|
|
transactionStatus,
|
|
|
|
nonce,
|
2018-09-20 02:48:28 +02:00
|
|
|
unapprovedTxs,
|
|
|
|
unapprovedTxCount,
|
2018-09-13 10:47:05 +02:00
|
|
|
customGas: {
|
2019-07-03 22:33:44 +02:00
|
|
|
gasLimit,
|
|
|
|
gasPrice,
|
2018-09-13 10:47:05 +02:00
|
|
|
},
|
2019-02-06 01:24:28 +01:00
|
|
|
advancedInlineGasShown: getAdvancedInlineGasShown(state),
|
2019-09-27 06:30:36 +02:00
|
|
|
useNonceField: getUseNonceField(state),
|
2021-04-17 00:00:18 +02:00
|
|
|
customNonceValue,
|
2019-02-06 01:24:28 +01:00
|
|
|
insufficientBalance,
|
2021-06-24 01:28:49 +02:00
|
|
|
hideFiatConversion: !getShouldShowFiat(state),
|
2021-03-10 21:16:44 +01:00
|
|
|
type,
|
2019-09-27 06:30:36 +02:00
|
|
|
nextNonce,
|
2020-06-01 19:54:32 +02:00
|
|
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
2020-08-19 16:03:15 +02:00
|
|
|
isMainnet,
|
2021-04-28 20:02:01 +02:00
|
|
|
isEthGasPrice,
|
|
|
|
noGasPrice,
|
2021-10-06 20:29:57 +02:00
|
|
|
supportsEIP1559,
|
2021-08-06 01:59:58 +02:00
|
|
|
gasIsLoading: isGasEstimatesLoading || gasLoadingAnimationIsShowing,
|
2021-08-06 03:07:04 +02:00
|
|
|
useNativeCurrencyAsPrimaryCurrency,
|
2021-08-06 21:31:30 +02:00
|
|
|
maxFeePerGas: gasEstimationObject.maxFeePerGas,
|
|
|
|
maxPriorityFeePerGas: gasEstimationObject.maxPriorityFeePerGas,
|
2021-08-07 00:18:53 +02:00
|
|
|
baseFeePerGas: gasEstimationObject.baseFeePerGas,
|
2021-08-17 00:45:55 +02:00
|
|
|
gasFeeIsCustom,
|
2021-10-21 21:17:03 +02:00
|
|
|
showLedgerSteps: fromAddressIsLedger,
|
2021-09-15 23:54:51 +02:00
|
|
|
nativeCurrency,
|
2021-10-21 21:17:03 +02:00
|
|
|
hardwareWalletRequiresConnection,
|
2021-11-11 17:46:45 +01:00
|
|
|
isMultiLayerFeeNetwork,
|
2021-12-01 18:22:08 +01:00
|
|
|
chainId,
|
2022-03-25 15:02:08 +01:00
|
|
|
isBuyableChain,
|
2023-01-17 16:23:04 +01:00
|
|
|
useCurrencyRateCheck: getUseCurrencyRateCheck(state),
|
2023-05-16 17:44:08 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
accountType,
|
|
|
|
isNoteToTraderSupported,
|
2023-06-07 08:43:28 +02:00
|
|
|
isNotification,
|
2023-05-16 17:44:08 +02:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
export const mapDispatchToProps = (dispatch) => {
|
2023-06-07 08:43:28 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
const mmiActions = mmiActionsFactory();
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
2019-11-01 18:54:00 +01:00
|
|
|
tryReverseResolveAddress: (address) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
return dispatch(tryReverseResolveAddress(address));
|
2019-11-01 18:54:00 +01:00
|
|
|
},
|
2020-02-15 21:34:12 +01:00
|
|
|
updateCustomNonce: (value) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
customNonceValue = value;
|
|
|
|
dispatch(updateCustomNonce(value));
|
2019-09-27 06:30:36 +02:00
|
|
|
},
|
2018-06-23 08:52:45 +02:00
|
|
|
clearConfirmTransaction: () => dispatch(clearConfirmTransaction()),
|
2018-09-17 19:34:29 +02:00
|
|
|
showTransactionConfirmedModal: ({ onSubmit }) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
return dispatch(showModal({ name: 'TRANSACTION_CONFIRMED', onSubmit }));
|
2018-06-23 08:52:45 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
showRejectTransactionsConfirmationModal: ({
|
|
|
|
onSubmit,
|
|
|
|
unapprovedTxCount,
|
|
|
|
}) => {
|
|
|
|
return dispatch(
|
|
|
|
showModal({ name: 'REJECT_TRANSACTIONS', onSubmit, unapprovedTxCount }),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-09-24 07:07:19 +02:00
|
|
|
},
|
2018-06-23 08:52:45 +02:00
|
|
|
cancelTransaction: ({ id }) => dispatch(cancelTx({ id })),
|
2018-09-20 02:48:28 +02:00
|
|
|
cancelAllTransactions: (txList) => dispatch(cancelTxs(txList)),
|
2020-11-03 00:41:28 +01:00
|
|
|
sendTransaction: (txData) =>
|
|
|
|
dispatch(updateAndApproveTx(customNonceMerge(txData))),
|
2019-09-27 06:30:36 +02:00
|
|
|
getNextNonce: () => dispatch(getNextNonce()),
|
2021-05-03 19:51:09 +02:00
|
|
|
setDefaultHomeActiveTabName: (tabName) =>
|
|
|
|
dispatch(setDefaultHomeActiveTabName(tabName)),
|
2021-07-08 22:23:00 +02:00
|
|
|
updateTransactionGasFees: (gasFees) => {
|
2022-03-25 18:11:04 +01:00
|
|
|
dispatch(updateGasFees({ ...gasFees, expectHexWei: true }));
|
2021-07-08 22:23:00 +02:00
|
|
|
},
|
2023-02-09 18:45:52 +01:00
|
|
|
addToAddressBookIfNew: (newAddress, toAccounts, nickname = '') => {
|
|
|
|
const hexPrefixedAddress = addHexPrefix(newAddress);
|
|
|
|
if (addressIsNew(toAccounts, hexPrefixedAddress)) {
|
|
|
|
dispatch(addToAddressBook(hexPrefixedAddress, nickname));
|
|
|
|
}
|
|
|
|
},
|
2023-06-07 08:43:28 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
getCustodianConfirmDeepLink: (id) =>
|
|
|
|
dispatch(mmiActions.getCustodianConfirmDeepLink(id)),
|
|
|
|
showTransactionsFailedModal: (errorMessage, closeNotification) =>
|
|
|
|
dispatch(
|
|
|
|
showModal({
|
|
|
|
name: 'TRANSACTION_FAILED',
|
|
|
|
errorMessage,
|
|
|
|
closeNotification,
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
showCustodianDeepLink: ({
|
|
|
|
txId,
|
|
|
|
fromAddress,
|
|
|
|
closeNotification,
|
|
|
|
onDeepLinkFetched,
|
|
|
|
onDeepLinkShown,
|
|
|
|
}) =>
|
|
|
|
showCustodianDeepLink({
|
|
|
|
dispatch,
|
|
|
|
mmiActions,
|
|
|
|
txId,
|
|
|
|
fromAddress,
|
|
|
|
closeNotification,
|
|
|
|
onDeepLinkFetched,
|
|
|
|
onDeepLinkShown,
|
2023-07-13 10:42:08 +02:00
|
|
|
showCustodyConfirmLink,
|
2023-06-07 08:43:28 +02:00
|
|
|
}),
|
|
|
|
setWaitForConfirmDeepLinkDialog: (wait) =>
|
|
|
|
dispatch(mmiActions.setWaitForConfirmDeepLinkDialog(wait)),
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2018-07-06 20:58:41 +02:00
|
|
|
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
2021-08-02 16:07:15 +02:00
|
|
|
const { txData, unapprovedTxs } = stateProps;
|
2021-04-28 20:02:01 +02:00
|
|
|
|
2018-07-06 20:58:41 +02:00
|
|
|
const {
|
2018-09-20 02:48:28 +02:00
|
|
|
cancelAllTransactions: dispatchCancelAllTransactions,
|
2021-07-08 22:23:00 +02:00
|
|
|
updateTransactionGasFees: dispatchUpdateTransactionGasFees,
|
2018-07-06 20:58:41 +02:00
|
|
|
...otherDispatchProps
|
2021-02-04 19:15:23 +01:00
|
|
|
} = dispatchProps;
|
2018-07-06 20:58:41 +02:00
|
|
|
|
2023-06-08 11:01:06 +02:00
|
|
|
let isMainBetaFlask = ownProps.isMainBetaFlask || false;
|
2023-06-07 08:43:28 +02:00
|
|
|
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
|
2023-06-08 11:01:06 +02:00
|
|
|
if (ownProps.isMainBetaFlask === undefined) {
|
|
|
|
isMainBetaFlask = true;
|
|
|
|
}
|
2023-06-07 08:43:28 +02:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
|
2018-07-06 20:58:41 +02:00
|
|
|
return {
|
|
|
|
...stateProps,
|
|
|
|
...otherDispatchProps,
|
|
|
|
...ownProps,
|
2020-11-03 00:41:28 +01:00
|
|
|
cancelAllTransactions: () =>
|
|
|
|
dispatchCancelAllTransactions(valuesFor(unapprovedTxs)),
|
2019-07-03 22:33:44 +02:00
|
|
|
updateGasAndCalculate: ({ gasLimit, gasPrice }) => {
|
2021-07-08 22:23:00 +02:00
|
|
|
dispatchUpdateTransactionGasFees({
|
|
|
|
gasLimit,
|
|
|
|
gasPrice,
|
|
|
|
transaction: txData,
|
|
|
|
});
|
2019-07-03 22:33:44 +02:00
|
|
|
},
|
2023-06-07 08:43:28 +02:00
|
|
|
isMainBetaFlask,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2018-07-06 20:58:41 +02:00
|
|
|
|
2018-06-23 08:52:45 +02:00
|
|
|
export default compose(
|
|
|
|
withRouter,
|
2020-07-14 17:20:41 +02:00
|
|
|
connect(mapStateToProps, mapDispatchToProps, mergeProps),
|
2021-02-04 19:15:23 +01:00
|
|
|
)(ConfirmTransactionBase);
|