fix(@embark/deployment): fix undefined in nb arguments in deploy

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
This commit is contained in:
Jonathan Rainville 2020-02-12 14:07:47 -05:00
parent b4b4848913
commit 0016581225
1 changed files with 10 additions and 0 deletions

View File

@ -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) {