From 31e5cad1e34c1b07079c430bb1903f7914021111 Mon Sep 17 00:00:00 2001 From: kumavis Date: Sun, 21 Oct 2018 01:01:21 -0400 Subject: tx-gas-util - set error message when invalidating tx based on tx data but no contract code --- app/scripts/controllers/transactions/tx-gas-utils.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'app/scripts/controllers') diff --git a/app/scripts/controllers/transactions/tx-gas-utils.js b/app/scripts/controllers/transactions/tx-gas-utils.js index 436900715..def67c2c3 100644 --- a/app/scripts/controllers/transactions/tx-gas-utils.js +++ b/app/scripts/controllers/transactions/tx-gas-utils.js @@ -62,20 +62,21 @@ class TxGasUtil { const recipient = txParams.to const hasRecipient = Boolean(recipient) - // see if we can set the gas based on the recipient + // see if we can set the gas based on the recipient if (hasRecipient) { const code = await this.query.getCode(recipient) // For an address with no code, geth will return '0x', and ganache-core v2.2.1 will return '0x0' const codeIsEmpty = !code || code === '0x' || code === '0x0' - + if (codeIsEmpty) { // if there's data in the params, but there's no contract code, it's not a valid transaction if (txParams.data) { - const err = new Error() + 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 throw err } - + // This is a standard ether simple send, gas requirement is exactly 21k txParams.gas = SIMPLE_GAS_COST // prevents buffer addition -- cgit v1.2.3