Add check if method is defined on the contract
This commit is contained in:
parent
d42b0fa2dd
commit
1488862b42
@ -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) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user