Stop throwing an error when adding gas defaults for a simple send, that has data, to an address without a response code (#15424)

* Stop throwing an error when adding gas defaults for a simple send, that has data, to an address without a response code

* Lint fix

* fixup lint

Co-authored-by: brad-decker <bhdecker84@gmail.com>
feature/default_network_editable
Dan J Miller 2 years ago committed by GitHub
parent ddadc79f60
commit 7e01dbca96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      app/scripts/controllers/transactions/index.js

@ -17,7 +17,6 @@ import {
addHexPrefix,
getChainType,
} from '../../lib/util';
import { TRANSACTION_NO_CONTRACT_ERROR_KEY } from '../../../../ui/helpers/constants/error-keys';
import { calcGasTotal } from '../../../../ui/pages/send/send.utils';
import { getSwapsTokensReceivedFromTxMeta } from '../../../../ui/pages/swaps/swaps.util';
import {
@ -1000,10 +999,9 @@ export default class TransactionController extends EventEmitter {
* Gets default gas limit, or debug information about why gas estimate failed.
*
* @param {object} txMeta - The txMeta object
* @param {string} getCodeResponse - The transaction category code response, used for debugging purposes
* @returns {Promise<object>} Object containing the default gas limit, or the simulation failure object
*/
async _getDefaultGasLimit(txMeta, getCodeResponse) {
async _getDefaultGasLimit(txMeta) {
const chainId = this._getCurrentChainId();
const customNetworkGasBuffer = CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP[chainId];
const chainType = getChainType(chainId);
@ -1013,21 +1011,9 @@ export default class TransactionController extends EventEmitter {
} else if (
txMeta.txParams.to &&
txMeta.type === TRANSACTION_TYPES.SIMPLE_SEND &&
chainType !== 'custom'
chainType !== 'custom' &&
!txMeta.txParams.data
) {
// if there's data in the params, but there's no contract code, it's not a valid transaction
if (txMeta.txParams.data) {
const err = new Error(
'TxGasUtil - Trying to call a function on a non-contract address',
);
// set error key so ui can display localized error message
err.errorKey = TRANSACTION_NO_CONTRACT_ERROR_KEY;
// set the response on the error so that we can see in logs what the actual response was
err.getCodeResponse = getCodeResponse;
throw err;
}
// This is a standard ether simple send, gas requirement is exactly 21k
return { gasLimit: GAS_LIMITS.SIMPLE };
}

Loading…
Cancel
Save