Skip to content

Commit c85c3bc

Browse files
authored
Merge pull request #1089 from embark-framework/bug_fix/deploy-error
Fix using an object as arguments
2 parents b63525e + 6b61c8a commit c85c3bc

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/lib/constants.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
"testnet": 3,
4242
"ropsten": 3,
4343
"rinkeby": 4
44-
}
44+
},
45+
"gasAllowanceError": "Returned error: gas required exceeds allowance or always failing transaction",
46+
"gasAllowanceErrorMessage": "Failing call, this could be because of invalid inputs or function guards that may have been triggered, or an unknown error."
4547
},
4648
"storage": {
4749
"init": "init",
@@ -62,4 +64,4 @@
6264
"explicit": "explicit"
6365
},
6466
"embarkResourceOrigin": "http://embark"
65-
}
67+
}

src/lib/modules/contracts_manager/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ class ContractsManager {
124124
res.send({result});
125125
});
126126
} catch (e) {
127-
if (funcCall === 'call' && e.message === 'Returned error: gas required exceeds allowance or always failing transaction') {
128-
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.'});
127+
if (funcCall === 'call' && e.message === constants.blockchain.gasAllowanceError) {
128+
return res.send({result: constants.blockchain.gasAllowanceErrorMessage});
129129
}
130130
res.send({result: e.message});
131131
}
@@ -421,8 +421,7 @@ class ContractsManager {
421421
if (Array.isArray(contract.args)) {
422422
ref = contract.args;
423423
} else {
424-
let keys = Object.keys(contract.args);
425-
ref = keys.map((k) => contract.args[k]).filter((x) => !x);
424+
ref = Object.values(contract.args);
426425
}
427426

428427
for (let j = 0; j < ref.length; j++) {

src/lib/modules/deployment/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ let async = require('async');
22

33
const ContractDeployer = require('./contract_deployer.js');
44
const cloneDeep = require('clone-deep');
5+
const constants = require('../../constants');
56

67
class DeployManager {
78
constructor(embark, options) {
@@ -66,6 +67,9 @@ class DeployManager {
6667
if (err) {
6768
contract.error = err.message || err;
6869
self.logger.error(`[${contract.className}]: ${err.message || err}`);
70+
if (contract.error === constants.blockchain.gasAllowanceError) {
71+
self.logger.error(constants.blockchain.gasAllowanceErrorMessage);
72+
}
6973
errors.push(err);
7074
}
7175
callback();

0 commit comments

Comments
 (0)