diff options
author | Dan J Miller <danjm.com@gmail.com> | 2019-05-15 02:14:07 +0800 |
---|---|---|
committer | Frankie <frankie.diamond@gmail.com> | 2019-05-15 02:14:07 +0800 |
commit | b81c4e5c98cdf3f5e6ebb05e57c2be993cdf5da0 (patch) | |
tree | f2deb9c7ebb567e02e6fed5f4510062e584f655e /app/scripts/controllers/transactions/index.js | |
parent | 3b01ba8741543d54bd2c3aad6a8ea0ef352e8924 (diff) | |
download | tangerine-wallet-browser-b81c4e5c98cdf3f5e6ebb05e57c2be993cdf5da0.tar tangerine-wallet-browser-b81c4e5c98cdf3f5e6ebb05e57c2be993cdf5da0.tar.gz tangerine-wallet-browser-b81c4e5c98cdf3f5e6ebb05e57c2be993cdf5da0.tar.bz2 tangerine-wallet-browser-b81c4e5c98cdf3f5e6ebb05e57c2be993cdf5da0.tar.lz tangerine-wallet-browser-b81c4e5c98cdf3f5e6ebb05e57c2be993cdf5da0.tar.xz tangerine-wallet-browser-b81c4e5c98cdf3f5e6ebb05e57c2be993cdf5da0.tar.zst tangerine-wallet-browser-b81c4e5c98cdf3f5e6ebb05e57c2be993cdf5da0.zip |
Set a default value for code in _determineTransactionCategory (#6604)
* Set a default value for code in _determineTransactionCategory
* Adds e2e tests that fail when token txs without gas param are not properly handled.
* Adds unit tests for _determineTransactionCategory
* Base error throwing and simple gas setting in estimateTxGas on transactionCategory
Diffstat (limited to 'app/scripts/controllers/transactions/index.js')
-rw-r--r-- | app/scripts/controllers/transactions/index.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index dc6a043e4..79dba7833 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -191,7 +191,7 @@ class TransactionController extends EventEmitter { } txUtils.validateTxParams(normalizedTxParams) // construct txMeta - const { transactionCategory, code } = await this._determineTransactionCategory(txParams) + const { transactionCategory, getCodeResponse } = await this._determineTransactionCategory(txParams) let txMeta = this.txStateManager.generateTxMeta({ txParams: normalizedTxParams, type: TRANSACTION_TYPE_STANDARD, @@ -204,7 +204,7 @@ class TransactionController extends EventEmitter { // check whether recipient account is blacklisted recipientBlacklistChecker.checkAccount(txMeta.metamaskNetworkId, normalizedTxParams.to) // add default tx params - txMeta = await this.addTxGasDefaults(txMeta, code) + txMeta = await this.addTxGasDefaults(txMeta, getCodeResponse) } catch (error) { log.warn(error) txMeta.loadingDefaults = false @@ -224,7 +224,7 @@ class TransactionController extends EventEmitter { @param txMeta {Object} - the txMeta object @returns {Promise<object>} resolves with txMeta */ - async addTxGasDefaults (txMeta, code) { + async addTxGasDefaults (txMeta, getCodeResponse) { const txParams = txMeta.txParams // ensure value txParams.value = txParams.value ? ethUtil.addHexPrefix(txParams.value) : '0x0' @@ -235,7 +235,7 @@ class TransactionController extends EventEmitter { } txParams.gasPrice = ethUtil.addHexPrefix(gasPrice.toString(16)) // set gasLimit - return await this.txGasUtil.analyzeGasUsage(txMeta, code) + return await this.txGasUtil.analyzeGasUsage(txMeta, getCodeResponse) } /** @@ -593,6 +593,7 @@ class TransactionController extends EventEmitter { try { code = await this.query.getCode(to) } catch (e) { + code = null log.warn(e) } // For an address with no code, geth will return '0x', and ganache-core v2.2.1 will return '0x0' @@ -601,7 +602,7 @@ class TransactionController extends EventEmitter { result = codeIsEmpty ? SEND_ETHER_ACTION_KEY : CONTRACT_INTERACTION_KEY } - return { transactionCategory: result, code } + return { transactionCategory: result, getCodeResponse: code } } /** |