From 360df5f6efb280c40bf47244c3e47a8a319ffc69 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Sun, 28 Oct 2018 17:10:38 +0100 Subject: [PATCH] Display better error message --- embark-ui/src/components/ContractOverview.js | 4 ++-- lib/modules/contracts_manager/index.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/embark-ui/src/components/ContractOverview.js b/embark-ui/src/components/ContractOverview.js index adbe8bb1..f02b27fb 100644 --- a/embark-ui/src/components/ContractOverview.js +++ b/embark-ui/src/components/ContractOverview.js @@ -161,8 +161,8 @@ class ContractFunction extends Component { {this.props.contractFunctions.map(contractFunction => ( - {contractFunction.inputs.length > 0 &&

Inputs: {contractFunction.inputs.join(', ')}

} - Result: {contractFunction.result} + {contractFunction.inputs.length > 0 &&

Input(s): {contractFunction.inputs.join(', ')}

} + Result: {JSON.stringify(contractFunction.result)}
))}
diff --git a/lib/modules/contracts_manager/index.js b/lib/modules/contracts_manager/index.js index 689473d8..5e75543e 100644 --- a/lib/modules/contracts_manager/index.js +++ b/lib/modules/contracts_manager/index.js @@ -116,7 +116,7 @@ class ContractsManager { self.events.request("blockchain:contract:create", {abi: contract.abiDefinition, address: contract.deployedAddress}, async (contractObj) => { try { const gas = await contractObj.methods[req.body.method].apply(this, req.body.inputs).estimateGas(); - contractObj.methods[req.body.method].apply(this, req.body.inputs)[funcCall]({from: account, gasPrice: req.body.gasPrice, gas}, (error, result) => { + contractObj.methods[req.body.method].apply(this, req.body.inputs)[funcCall]({from: account, gasPrice: req.body.gasPrice, gas: Math.floor(gas)}, (error, result) => { if (error) { return res.send({result: error.message}); } @@ -124,6 +124,9 @@ class ContractsManager { res.send({result}); }); } catch (e) { + if (funcCall === 'call' && e.message === 'Returned error: gas required exceeds allowance or always failing transaction') { + return res.send({result: 'Failing call, this could be because of invalid inputs or function guards that may have been triggered, or an unknown error.'}); + } res.send({result: e.message}); } });