Add script for vetoing via console #122

Merged
raucao merged 1 commits from feature/veto_script into master 2019-05-01 18:05:38 +00:00

View File

@ -0,0 +1,32 @@
const promptly = require('promptly');
const { inspect } = require('util');
const initKredits = require('./helpers/init_kredits.js');
module.exports = async function(callback) {
let kredits;
try { kredits = await initKredits(web3);
} catch(e) { callback(e); return; }
console.log(`Using Contributions at: ${kredits.Contribution.contract.address}\n`);
let contributionId = await promptly.prompt('Contribution ID: ');
console.log(`Recording a veto for contribution #${contributionId}`);
try {
kredits.Contribution.functions.veto(contributionId, { gasLimit: 300000 })
.then(result => {
console.log("\n\nResult:");
console.log(result);
callback();
})
.catch(error => {
console.log('Failed to veto contribution');
callback(inspect(error));
bumi commented 2019-04-28 19:58:18 +00:00 (Migrated from github.com)
Review

why do we have that inspect here - which we do not have in the other scripts? this turns that error into a string.
Because I've never looked into that callback function details? what does it exactly do? is it better to pass in a string than an error object?

why do we have that inspect here - which we do not have in the other scripts? this turns that error into a string. Because I've never looked into that callback function details? what does it exactly do? is it better to pass in a string than an error object?
raucao commented 2019-04-28 20:19:26 +00:00 (Migrated from github.com)
Review

This is copied straight from another script I added the first error handling to, and where it's still present:

https://github.com/67P/kredits-contracts/blob/master/scripts/add-contribution.js#L56

This is copied straight from another script I added the first error handling to, and where it's still present: https://github.com/67P/kredits-contracts/blob/master/scripts/add-contribution.js#L56
bumi commented 2019-05-01 18:05:16 +00:00 (Migrated from github.com)
Review

ah I see.
I guess we don't need it and also don't use it everywhere.

ah I see. I guess we don't need it and also don't use it everywhere.
});
} catch(err) {
console.log('Failed to veto contribution');
callback(inspect(err));
}
}