2020-08-18 21:18:25 +02:00
|
|
|
import { addHexPrefix } from 'ethereumjs-util'
|
2018-06-23 08:52:45 +02:00
|
|
|
import {
|
|
|
|
conversionRateSelector,
|
|
|
|
currentCurrencySelector,
|
|
|
|
unconfirmedTransactionsHashSelector,
|
2018-10-26 10:26:43 +02:00
|
|
|
getNativeCurrency,
|
2020-05-02 21:41:17 +02:00
|
|
|
} from '../../selectors'
|
2018-06-23 08:52:45 +02:00
|
|
|
|
|
|
|
import {
|
2018-07-31 07:03:20 +02:00
|
|
|
getValueFromWeiHex,
|
2018-06-23 08:52:45 +02:00
|
|
|
getTransactionFee,
|
|
|
|
getHexGasTotal,
|
|
|
|
addFiat,
|
|
|
|
addEth,
|
|
|
|
increaseLastGasPrice,
|
|
|
|
hexGreaterThan,
|
2019-03-22 00:03:30 +01:00
|
|
|
} from '../../helpers/utils/confirm-tx.util'
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
import { getTokenData, sumHexes } from '../../helpers/utils/transactions.util'
|
2018-10-17 01:03:29 +02:00
|
|
|
|
2019-03-22 00:03:30 +01:00
|
|
|
import { conversionUtil } from '../../helpers/utils/conversion-util'
|
2018-06-23 08:52:45 +02:00
|
|
|
|
|
|
|
// Actions
|
2020-02-15 21:34:12 +01:00
|
|
|
const createActionType = (action) => `metamask/confirm-transaction/${action}`
|
2018-06-23 08:52:45 +02:00
|
|
|
|
|
|
|
const UPDATE_TX_DATA = createActionType('UPDATE_TX_DATA')
|
|
|
|
const CLEAR_TX_DATA = createActionType('CLEAR_TX_DATA')
|
|
|
|
const UPDATE_TOKEN_DATA = createActionType('UPDATE_TOKEN_DATA')
|
|
|
|
const CLEAR_TOKEN_DATA = createActionType('CLEAR_TOKEN_DATA')
|
2018-06-28 20:23:31 +02:00
|
|
|
const UPDATE_METHOD_DATA = createActionType('UPDATE_METHOD_DATA')
|
|
|
|
const CLEAR_METHOD_DATA = createActionType('CLEAR_METHOD_DATA')
|
2018-06-23 08:52:45 +02:00
|
|
|
const CLEAR_CONFIRM_TRANSACTION = createActionType('CLEAR_CONFIRM_TRANSACTION')
|
2020-11-03 00:41:28 +01:00
|
|
|
const UPDATE_TRANSACTION_AMOUNTS = createActionType(
|
|
|
|
'UPDATE_TRANSACTION_AMOUNTS',
|
|
|
|
)
|
2018-06-23 08:52:45 +02:00
|
|
|
const UPDATE_TRANSACTION_FEES = createActionType('UPDATE_TRANSACTION_FEES')
|
|
|
|
const UPDATE_TRANSACTION_TOTALS = createActionType('UPDATE_TRANSACTION_TOTALS')
|
|
|
|
const UPDATE_TOKEN_PROPS = createActionType('UPDATE_TOKEN_PROPS')
|
|
|
|
const UPDATE_NONCE = createActionType('UPDATE_NONCE')
|
2018-08-17 23:34:14 +02:00
|
|
|
const UPDATE_TO_SMART_CONTRACT = createActionType('UPDATE_TO_SMART_CONTRACT')
|
|
|
|
const FETCH_DATA_START = createActionType('FETCH_DATA_START')
|
|
|
|
const FETCH_DATA_END = createActionType('FETCH_DATA_END')
|
2018-06-23 08:52:45 +02:00
|
|
|
|
|
|
|
// Initial state
|
|
|
|
const initState = {
|
|
|
|
txData: {},
|
|
|
|
tokenData: {},
|
2018-06-28 20:23:31 +02:00
|
|
|
methodData: {},
|
2018-06-23 08:52:45 +02:00
|
|
|
tokenProps: {
|
|
|
|
tokenDecimals: '',
|
|
|
|
tokenSymbol: '',
|
|
|
|
},
|
|
|
|
fiatTransactionAmount: '',
|
|
|
|
fiatTransactionFee: '',
|
|
|
|
fiatTransactionTotal: '',
|
|
|
|
ethTransactionAmount: '',
|
|
|
|
ethTransactionFee: '',
|
|
|
|
ethTransactionTotal: '',
|
2018-10-17 01:03:29 +02:00
|
|
|
hexTransactionAmount: '',
|
|
|
|
hexTransactionFee: '',
|
|
|
|
hexTransactionTotal: '',
|
2018-06-23 08:52:45 +02:00
|
|
|
nonce: '',
|
2018-08-17 23:34:14 +02:00
|
|
|
toSmartContract: false,
|
|
|
|
fetchingData: false,
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reducer
|
2020-11-03 00:41:28 +01:00
|
|
|
export default function reducer(state = initState, action = {}) {
|
2018-06-23 08:52:45 +02:00
|
|
|
switch (action.type) {
|
|
|
|
case UPDATE_TX_DATA:
|
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-06-23 08:52:45 +02:00
|
|
|
txData: {
|
|
|
|
...action.payload,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
case CLEAR_TX_DATA:
|
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-06-23 08:52:45 +02:00
|
|
|
txData: {},
|
|
|
|
}
|
|
|
|
case UPDATE_TOKEN_DATA:
|
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-06-23 08:52:45 +02:00
|
|
|
tokenData: {
|
|
|
|
...action.payload,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
case CLEAR_TOKEN_DATA:
|
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-06-23 08:52:45 +02:00
|
|
|
tokenData: {},
|
|
|
|
}
|
2018-06-28 20:23:31 +02:00
|
|
|
case UPDATE_METHOD_DATA:
|
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-06-28 20:23:31 +02:00
|
|
|
methodData: {
|
|
|
|
...action.payload,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
case CLEAR_METHOD_DATA:
|
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-06-28 20:23:31 +02:00
|
|
|
methodData: {},
|
|
|
|
}
|
2020-08-12 18:41:27 +02:00
|
|
|
case UPDATE_TRANSACTION_AMOUNTS: {
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
fiatTransactionAmount,
|
|
|
|
ethTransactionAmount,
|
|
|
|
hexTransactionAmount,
|
|
|
|
} = action.payload
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2020-11-03 00:41:28 +01:00
|
|
|
fiatTransactionAmount:
|
|
|
|
fiatTransactionAmount || state.fiatTransactionAmount,
|
|
|
|
ethTransactionAmount:
|
|
|
|
ethTransactionAmount || state.ethTransactionAmount,
|
|
|
|
hexTransactionAmount:
|
|
|
|
hexTransactionAmount || state.hexTransactionAmount,
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
2020-08-12 18:41:27 +02:00
|
|
|
}
|
|
|
|
case UPDATE_TRANSACTION_FEES: {
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
fiatTransactionFee,
|
|
|
|
ethTransactionFee,
|
|
|
|
hexTransactionFee,
|
|
|
|
} = action.payload
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
|
|
|
fiatTransactionFee: fiatTransactionFee || state.fiatTransactionFee,
|
|
|
|
ethTransactionFee: ethTransactionFee || state.ethTransactionFee,
|
|
|
|
hexTransactionFee: hexTransactionFee || state.hexTransactionFee,
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
2020-08-12 18:41:27 +02:00
|
|
|
}
|
|
|
|
case UPDATE_TRANSACTION_TOTALS: {
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
fiatTransactionTotal,
|
|
|
|
ethTransactionTotal,
|
|
|
|
hexTransactionTotal,
|
|
|
|
} = action.payload
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2020-11-03 00:41:28 +01:00
|
|
|
fiatTransactionTotal:
|
|
|
|
fiatTransactionTotal || state.fiatTransactionTotal,
|
2020-02-06 17:38:14 +01:00
|
|
|
ethTransactionTotal: ethTransactionTotal || state.ethTransactionTotal,
|
|
|
|
hexTransactionTotal: hexTransactionTotal || state.hexTransactionTotal,
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
2020-08-12 18:41:27 +02:00
|
|
|
}
|
|
|
|
case UPDATE_TOKEN_PROPS: {
|
2018-06-23 08:52:45 +02:00
|
|
|
const { tokenSymbol = '', tokenDecimals = '' } = action.payload
|
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-06-23 08:52:45 +02:00
|
|
|
tokenProps: {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state.tokenProps,
|
2018-06-23 08:52:45 +02:00
|
|
|
tokenSymbol,
|
|
|
|
tokenDecimals,
|
|
|
|
},
|
|
|
|
}
|
2020-08-12 18:41:27 +02:00
|
|
|
}
|
2018-06-23 08:52:45 +02:00
|
|
|
case UPDATE_NONCE:
|
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-06-23 08:52:45 +02:00
|
|
|
nonce: action.payload,
|
|
|
|
}
|
2018-08-17 23:34:14 +02:00
|
|
|
case UPDATE_TO_SMART_CONTRACT:
|
2018-06-28 20:23:31 +02:00
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-08-17 23:34:14 +02:00
|
|
|
toSmartContract: action.payload,
|
2018-06-28 20:23:31 +02:00
|
|
|
}
|
2018-08-17 23:34:14 +02:00
|
|
|
case FETCH_DATA_START:
|
2018-06-28 20:23:31 +02:00
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-08-17 23:34:14 +02:00
|
|
|
fetchingData: true,
|
|
|
|
}
|
|
|
|
case FETCH_DATA_END:
|
|
|
|
return {
|
2020-02-06 17:38:14 +01:00
|
|
|
...state,
|
2018-08-17 23:34:14 +02:00
|
|
|
fetchingData: false,
|
2018-06-28 20:23:31 +02:00
|
|
|
}
|
2018-06-23 08:52:45 +02:00
|
|
|
case CLEAR_CONFIRM_TRANSACTION:
|
|
|
|
return initState
|
|
|
|
default:
|
2020-02-06 17:38:14 +01:00
|
|
|
return state
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Action Creators
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateTxData(txData) {
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
type: UPDATE_TX_DATA,
|
|
|
|
payload: txData,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function clearTxData() {
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
type: CLEAR_TX_DATA,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateTokenData(tokenData) {
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
type: UPDATE_TOKEN_DATA,
|
|
|
|
payload: tokenData,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function clearTokenData() {
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
type: CLEAR_TOKEN_DATA,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateMethodData(methodData) {
|
2018-06-28 20:23:31 +02:00
|
|
|
return {
|
|
|
|
type: UPDATE_METHOD_DATA,
|
|
|
|
payload: methodData,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function clearMethodData() {
|
2018-06-28 20:23:31 +02:00
|
|
|
return {
|
|
|
|
type: CLEAR_METHOD_DATA,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateTransactionAmounts(amounts) {
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
type: UPDATE_TRANSACTION_AMOUNTS,
|
|
|
|
payload: amounts,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateTransactionFees(fees) {
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
type: UPDATE_TRANSACTION_FEES,
|
|
|
|
payload: fees,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateTransactionTotals(totals) {
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
type: UPDATE_TRANSACTION_TOTALS,
|
|
|
|
payload: totals,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateTokenProps(tokenProps) {
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
type: UPDATE_TOKEN_PROPS,
|
|
|
|
payload: tokenProps,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateNonce(nonce) {
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
type: UPDATE_NONCE,
|
|
|
|
payload: nonce,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateToSmartContract(toSmartContract) {
|
2018-08-17 23:34:14 +02:00
|
|
|
return {
|
|
|
|
type: UPDATE_TO_SMART_CONTRACT,
|
|
|
|
payload: toSmartContract,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setFetchingData(isFetching) {
|
2018-06-28 20:23:31 +02:00
|
|
|
return {
|
2018-08-17 23:34:14 +02:00
|
|
|
type: isFetching ? FETCH_DATA_START : FETCH_DATA_END,
|
2018-06-28 20:23:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateGasAndCalculate({ gasLimit, gasPrice }) {
|
2018-06-23 08:52:45 +02:00
|
|
|
return (dispatch, getState) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
confirmTransaction: { txData },
|
|
|
|
} = getState()
|
2018-06-23 08:52:45 +02:00
|
|
|
const newTxData = {
|
|
|
|
...txData,
|
|
|
|
txParams: {
|
|
|
|
...txData.txParams,
|
2020-08-15 13:58:11 +02:00
|
|
|
gas: addHexPrefix(gasLimit),
|
|
|
|
gasPrice: addHexPrefix(gasPrice),
|
2018-06-23 08:52:45 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(updateTxDataAndCalculate(newTxData))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function increaseFromLastGasPrice(txData) {
|
2018-06-23 08:52:45 +02:00
|
|
|
const { lastGasPrice, txParams: { gasPrice: previousGasPrice } = {} } = txData
|
|
|
|
|
|
|
|
// Set the minimum to a 10% increase from the lastGasPrice.
|
|
|
|
const minimumGasPrice = increaseLastGasPrice(lastGasPrice)
|
|
|
|
const gasPriceBelowMinimum = hexGreaterThan(minimumGasPrice, previousGasPrice)
|
2020-11-03 00:41:28 +01:00
|
|
|
const gasPrice =
|
|
|
|
!previousGasPrice || gasPriceBelowMinimum
|
|
|
|
? minimumGasPrice
|
|
|
|
: previousGasPrice
|
2018-06-23 08:52:45 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
...txData,
|
|
|
|
txParams: {
|
|
|
|
...txData.txParams,
|
|
|
|
gasPrice,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function updateTxDataAndCalculate(txData) {
|
2018-06-23 08:52:45 +02:00
|
|
|
return (dispatch, getState) => {
|
|
|
|
const state = getState()
|
|
|
|
const currentCurrency = currentCurrencySelector(state)
|
|
|
|
const conversionRate = conversionRateSelector(state)
|
2018-10-26 10:26:43 +02:00
|
|
|
const nativeCurrency = getNativeCurrency(state)
|
2018-06-23 08:52:45 +02:00
|
|
|
|
|
|
|
dispatch(updateTxData(txData))
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
txParams: { value = '0x0', gas: gasLimit = '0x0', gasPrice = '0x0' } = {},
|
|
|
|
} = txData
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2018-07-31 07:03:20 +02:00
|
|
|
const fiatTransactionAmount = getValueFromWeiHex({
|
2020-11-03 00:41:28 +01:00
|
|
|
value,
|
|
|
|
fromCurrency: nativeCurrency,
|
|
|
|
toCurrency: currentCurrency,
|
|
|
|
conversionRate,
|
|
|
|
numberOfDecimals: 2,
|
2018-06-23 08:52:45 +02:00
|
|
|
})
|
2018-07-31 07:03:20 +02:00
|
|
|
const ethTransactionAmount = getValueFromWeiHex({
|
2020-11-03 00:41:28 +01:00
|
|
|
value,
|
|
|
|
fromCurrency: nativeCurrency,
|
|
|
|
toCurrency: nativeCurrency,
|
|
|
|
conversionRate,
|
|
|
|
numberOfDecimals: 6,
|
2018-06-23 08:52:45 +02:00
|
|
|
})
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
dispatch(
|
|
|
|
updateTransactionAmounts({
|
|
|
|
fiatTransactionAmount,
|
|
|
|
ethTransactionAmount,
|
|
|
|
hexTransactionAmount: value,
|
|
|
|
}),
|
|
|
|
)
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2018-10-17 01:03:29 +02:00
|
|
|
const hexTransactionFee = getHexGasTotal({ gasLimit, gasPrice })
|
2018-06-23 08:52:45 +02:00
|
|
|
|
|
|
|
const fiatTransactionFee = getTransactionFee({
|
2018-10-17 01:03:29 +02:00
|
|
|
value: hexTransactionFee,
|
2018-10-26 10:26:43 +02:00
|
|
|
fromCurrency: nativeCurrency,
|
2018-06-23 08:52:45 +02:00
|
|
|
toCurrency: currentCurrency,
|
|
|
|
numberOfDecimals: 2,
|
|
|
|
conversionRate,
|
|
|
|
})
|
|
|
|
const ethTransactionFee = getTransactionFee({
|
2018-10-17 01:03:29 +02:00
|
|
|
value: hexTransactionFee,
|
2018-10-26 10:26:43 +02:00
|
|
|
fromCurrency: nativeCurrency,
|
|
|
|
toCurrency: nativeCurrency,
|
2018-06-23 08:52:45 +02:00
|
|
|
numberOfDecimals: 6,
|
|
|
|
conversionRate,
|
|
|
|
})
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
dispatch(
|
|
|
|
updateTransactionFees({
|
|
|
|
fiatTransactionFee,
|
|
|
|
ethTransactionFee,
|
|
|
|
hexTransactionFee,
|
|
|
|
}),
|
|
|
|
)
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const fiatTransactionTotal = addFiat(
|
|
|
|
fiatTransactionFee,
|
|
|
|
fiatTransactionAmount,
|
|
|
|
)
|
2018-06-23 08:52:45 +02:00
|
|
|
const ethTransactionTotal = addEth(ethTransactionFee, ethTransactionAmount)
|
2018-10-17 01:03:29 +02:00
|
|
|
const hexTransactionTotal = sumHexes(value, hexTransactionFee)
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
dispatch(
|
|
|
|
updateTransactionTotals({
|
|
|
|
fiatTransactionTotal,
|
|
|
|
ethTransactionTotal,
|
|
|
|
hexTransactionTotal,
|
|
|
|
}),
|
|
|
|
)
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function setTransactionToConfirm(transactionId) {
|
2019-06-18 14:17:14 +02:00
|
|
|
return (dispatch, getState) => {
|
2018-06-23 08:52:45 +02:00
|
|
|
const state = getState()
|
2020-11-03 00:41:28 +01:00
|
|
|
const unconfirmedTransactionsHash = unconfirmedTransactionsHashSelector(
|
|
|
|
state,
|
|
|
|
)
|
2018-06-23 08:52:45 +02:00
|
|
|
const transaction = unconfirmedTransactionsHash[transactionId]
|
|
|
|
|
|
|
|
if (!transaction) {
|
|
|
|
console.error(`Transaction with id ${transactionId} not found`)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-06-25 21:06:57 +02:00
|
|
|
if (transaction.txParams) {
|
|
|
|
const { lastGasPrice } = transaction
|
2020-11-03 00:41:28 +01:00
|
|
|
const txData = lastGasPrice
|
|
|
|
? increaseFromLastGasPrice(transaction)
|
|
|
|
: transaction
|
2018-06-25 21:06:57 +02:00
|
|
|
dispatch(updateTxDataAndCalculate(txData))
|
|
|
|
|
|
|
|
const { txParams } = transaction
|
|
|
|
|
|
|
|
if (txParams.data) {
|
2019-06-18 14:17:14 +02:00
|
|
|
const { data } = txParams
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2018-06-25 21:06:57 +02:00
|
|
|
const tokenData = getTokenData(data)
|
|
|
|
dispatch(updateTokenData(tokenData))
|
|
|
|
}
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2018-06-25 21:06:57 +02:00
|
|
|
if (txParams.nonce) {
|
|
|
|
const nonce = conversionUtil(txParams.nonce, {
|
|
|
|
fromNumericBase: 'hex',
|
|
|
|
toNumericBase: 'dec',
|
|
|
|
})
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2018-06-25 21:06:57 +02:00
|
|
|
dispatch(updateNonce(nonce))
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dispatch(updateTxData(transaction))
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function clearConfirmTransaction() {
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
|
|
|
type: CLEAR_CONFIRM_TRANSACTION,
|
|
|
|
}
|
|
|
|
}
|