mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 21:00:13 +01:00
748801f417
* Adds 4byte registry fallback to getMethodData() (#6435) * Adds fetchWithCache to guard against unnecessary API calls * Add custom fetch wrapper with abort on timeout * Use opts and cacheRefreshTime in fetch-with-cache util * Use custom fetch wrapper with timeout for fetch-with-cache * Improve contract method data fetching (#6623) * Remove async call from getTransactionActionKey() * Stop blocking confirm screen rendering on method data loading, and base screen route on transactionCategory * Remove use of withMethodData, fix use of knownMethodData, in relation to transaction-list-item.component * Load data contract method data progressively, making it non-blocking; requires simplifying conf-tx-base lifecycle logic. * Allow editing of gas price while loading on the confirm screen. * Fix transactionAction component and its unit tests. * Fix confirm transaction components for cases of route transitions within metamask. * Only call toString on id if truthy in getNavigateTxData() * Fix knownMethodData retrieval and data fetching from fourbyte
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
import { connect } from 'react-redux'
|
|
import ConfirmTransactionSwitch from './confirm-transaction-switch.component'
|
|
import {
|
|
TOKEN_METHOD_TRANSFER,
|
|
TOKEN_METHOD_APPROVE,
|
|
TOKEN_METHOD_TRANSFER_FROM,
|
|
SEND_ETHER_ACTION_KEY,
|
|
} from '../../helpers/constants/transactions'
|
|
import { unconfirmedTransactionsListSelector } from '../../selectors/confirm-transaction'
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
const { metamask: { unapprovedTxs } } = state
|
|
const { match: { params = {}, url } } = ownProps
|
|
const urlId = url && url.match(/\d+/) && url.match(/\d+/)[0]
|
|
const { id: paramsId } = params
|
|
const transactionId = paramsId || urlId
|
|
|
|
const unconfirmedTransactions = unconfirmedTransactionsListSelector(state)
|
|
const totalUnconfirmed = unconfirmedTransactions.length
|
|
const transaction = totalUnconfirmed
|
|
? unapprovedTxs[transactionId] || unconfirmedTransactions[totalUnconfirmed - 1]
|
|
: {}
|
|
|
|
return {
|
|
txData: transaction,
|
|
isEtherTransaction: transaction && transaction.transactionCategory === SEND_ETHER_ACTION_KEY,
|
|
isTokenMethod: [TOKEN_METHOD_APPROVE, TOKEN_METHOD_TRANSFER, TOKEN_METHOD_TRANSFER_FROM].includes(transaction && transaction.transactionCategory && transaction.transactionCategory.toLowerCase()),
|
|
}
|
|
}
|
|
|
|
export default connect(mapStateToProps)(ConfirmTransactionSwitch)
|