Add check if method is defined on the contract

This commit is contained in:
bumi 2018-04-04 22:42:16 +02:00
parent d42b0fa2dd
commit 1488862b42

View File

@ -16,6 +16,10 @@ module.exports = function(callback) {
console.log(`Using ${contractName} at ${contractAddress}`); console.log(`Using ${contractName} at ${contractAddress}`);
let contract = await artifacts.require(`./${contractName}`).at(contractAddress); let contract = await artifacts.require(`./${contractName}`).at(contractAddress);
if(!contract[method]) {
callback(new Error(`Method ${method} is not defined on ${contractName}`));
return;
}
console.log(`Calling ${method} with ${JSON.stringify(args)}`); console.log(`Calling ${method} with ${JSON.stringify(args)}`);
contract[method](...args).then((result) => { contract[method](...args).then((result) => {