|
|
@ -15,6 +15,7 @@ import { |
|
|
|
bnToHex, |
|
|
|
bnToHex, |
|
|
|
BnMultiplyByFraction, |
|
|
|
BnMultiplyByFraction, |
|
|
|
addHexPrefix, |
|
|
|
addHexPrefix, |
|
|
|
|
|
|
|
getChainType, |
|
|
|
} from '../../lib/util'; |
|
|
|
} from '../../lib/util'; |
|
|
|
import { TRANSACTION_NO_CONTRACT_ERROR_KEY } from '../../../../ui/helpers/constants/error-keys'; |
|
|
|
import { TRANSACTION_NO_CONTRACT_ERROR_KEY } from '../../../../ui/helpers/constants/error-keys'; |
|
|
|
import { getSwapsTokensReceivedFromTxMeta } from '../../../../ui/pages/swaps/swaps.util'; |
|
|
|
import { getSwapsTokensReceivedFromTxMeta } from '../../../../ui/pages/swaps/swaps.util'; |
|
|
@ -24,6 +25,7 @@ import { |
|
|
|
} from '../../../../shared/constants/transaction'; |
|
|
|
} from '../../../../shared/constants/transaction'; |
|
|
|
import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller'; |
|
|
|
import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller'; |
|
|
|
import { GAS_LIMITS } from '../../../../shared/constants/gas'; |
|
|
|
import { GAS_LIMITS } from '../../../../shared/constants/gas'; |
|
|
|
|
|
|
|
import { CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP } from '../../../../shared/constants/network'; |
|
|
|
import { isEIP1559Transaction } from '../../../../shared/modules/transaction.utils'; |
|
|
|
import { isEIP1559Transaction } from '../../../../shared/modules/transaction.utils'; |
|
|
|
import TransactionStateManager from './tx-state-manager'; |
|
|
|
import TransactionStateManager from './tx-state-manager'; |
|
|
|
import TxGasUtil from './tx-gas-utils'; |
|
|
|
import TxGasUtil from './tx-gas-utils'; |
|
|
@ -356,11 +358,16 @@ export default class TransactionController extends EventEmitter { |
|
|
|
* @returns {Promise<Object>} Object containing the default gas limit, or the simulation failure object |
|
|
|
* @returns {Promise<Object>} Object containing the default gas limit, or the simulation failure object |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
async _getDefaultGasLimit(txMeta, getCodeResponse) { |
|
|
|
async _getDefaultGasLimit(txMeta, getCodeResponse) { |
|
|
|
|
|
|
|
const chainId = this._getCurrentChainId(); |
|
|
|
|
|
|
|
const customNetworkGasBuffer = CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP[chainId]; |
|
|
|
|
|
|
|
const chainType = getChainType(chainId); |
|
|
|
|
|
|
|
|
|
|
|
if (txMeta.txParams.gas) { |
|
|
|
if (txMeta.txParams.gas) { |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} else if ( |
|
|
|
} else if ( |
|
|
|
txMeta.txParams.to && |
|
|
|
txMeta.txParams.to && |
|
|
|
txMeta.type === TRANSACTION_TYPES.SENT_ETHER |
|
|
|
txMeta.type === TRANSACTION_TYPES.SENT_ETHER && |
|
|
|
|
|
|
|
chainType !== 'custom' |
|
|
|
) { |
|
|
|
) { |
|
|
|
// if there's data in the params, but there's no contract code, it's not a valid transaction
|
|
|
|
// if there's data in the params, but there's no contract code, it's not a valid transaction
|
|
|
|
if (txMeta.txParams.data) { |
|
|
|
if (txMeta.txParams.data) { |
|
|
@ -389,6 +396,7 @@ export default class TransactionController extends EventEmitter { |
|
|
|
const gasLimit = this.txGasUtil.addGasBuffer( |
|
|
|
const gasLimit = this.txGasUtil.addGasBuffer( |
|
|
|
addHexPrefix(estimatedGasHex), |
|
|
|
addHexPrefix(estimatedGasHex), |
|
|
|
blockGasLimit, |
|
|
|
blockGasLimit, |
|
|
|
|
|
|
|
customNetworkGasBuffer, |
|
|
|
); |
|
|
|
); |
|
|
|
return { gasLimit, simulationFails }; |
|
|
|
return { gasLimit, simulationFails }; |
|
|
|
} |
|
|
|
} |
|
|
|