Add script for vetoing via console #122
32
scripts/veto-contribution.js
Normal file
32
scripts/veto-contribution.js
Normal 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));
|
||||||
|
|||||||
|
});
|
||||||
|
} catch(err) {
|
||||||
|
console.log('Failed to veto contribution');
|
||||||
|
callback(inspect(err));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user
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?
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
ah I see.
I guess we don't need it and also don't use it everywhere.