Skip to content

Commit

Permalink
fix(@embark/deployment): fix undefined in nb arguments in deploy
Browse files Browse the repository at this point in the history
This is caused by web3 using the method name to show which method
doesn't have the right number of arguments, but the constructor does
not have a name
  • Loading branch information
jrainville committed Feb 12, 2020
1 parent d6d6a16 commit 7021466
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/plugins/ethereum-blockchain-client/src/index.js
Expand Up @@ -59,6 +59,16 @@ class EthereumBlockchainClient {
const web3 = await this.web3;
const [account] = await web3.eth.getAccounts();
const contractObj = new web3.eth.Contract(contract.abiDefinition, contract.address);
contractObj._jsonInterface.find(obj => {
if (obj.type === 'constructor') {
if (!obj.name) {
// Add constructor as the name of the method, because if there is an error, it prints `undefined` otherwise
obj.name = 'constructor';
}
return true;
}
return false;
});
const code = contract.code.substring(0, 2) === '0x' ? contract.code : "0x" + contract.code;
const contractObject = contractObj.deploy({arguments: (contract.args || []), data: code});
if (contract.gas === 'auto' || !contract.gas) {
Expand Down

0 comments on commit 7021466

Please sign in to comment.