Document helper scripts to interact with the contracts

This commit is contained in:
2018-04-04 21:56:54 +02:00
parent bdd99d58cf
commit 7d52161014
5 changed files with 52 additions and 15 deletions

View File

@@ -30,19 +30,18 @@ module.exports = function(callback) {
let ipfsHash = process.argv[5] || 'QmQyZJT9uikzDYTZLhhyVZ5ReZVCoMucYzyvDokDJsijhj';
let contributorMultihash = getBytes32FromMultiash(ipfsHash);
let isCore = true;
operator.addContributor(contributorToAddAddress, contributorMultihash.digest, contributorMultihash.hashFunction, contributorMultihash.size, isCore).then((result) => {
console.log('Contributor added, tx: ', result.tx);
});
let contributorResult = await operator.addContributor(contributorToAddAddress, contributorMultihash.digest, contributorMultihash.hashFunction, contributorMultihash.size, isCore);
console.log('Contributor added, tx: ', contributorResult.tx);
var contributorId = await contributors.getContributorIdByAddress(contributorToAddAddress);
let contributorId = await contributors.getContributorIdByAddress(contributorToAddAddress);
let proposalMultihash = getBytes32FromMultiash('QmQNA1hhVyL1Vm6HiRxXe9xmc6LUMBDyiNMVgsjThtyevs');
operator.addProposal(contributorId, 23, proposalMultihash.digest, proposalMultihash.hashFunction, proposalMultihash.size).then((result) => {
console.log('Proposal added, tx: ', result.tx);
});
let proposalResult = await operator.addProposal(contributorId, 23, proposalMultihash.digest, proposalMultihash.hashFunction, proposalMultihash.size);
console.log('Proposal added, tx: ', proposalResult.tx);
var proposalId = await operator.proposalsCount();
operator.vote(proposalId.toNumber()-1).then((result) => {
console.log('Voted for proposal', proposalId, result.tx);
})
let proposalId = await operator.proposalsCount();
let votingResult = operator.vote(proposalId.toNumber()-1);
console.log('Voted for proposal', proposalId.toString(), votingResult.tx);
callback();
});
}

View File

@@ -32,9 +32,9 @@ module.exports = function(callback) {
let contributorId = await contributors.getContributorIdByAddress(recipientAddress);
operator.addProposal(contributorId.toNumber(), 23, multihash.digest, multihash.hashFunction, multihash.size).then((result) => {
console.log('Proposal added, tx: ', result.tx);
});
let result = await operator.addProposal(contributorId.toNumber(), 23, multihash.digest, multihash.hashFunction, multihash.size);
console.log('Proposal added, tx: ', result.tx);
callback();
});
}

View File

@@ -29,4 +29,6 @@ module.exports = function(callback) {
seeds.ipfsContent.forEach((content) => {
ipfs.add(new ipfs.Buffer(JSON.stringify(content))).then((result) => { console.log(`[IPFS] added ${result[0].hash}`) });
});
callback();
}

View File

@@ -1,5 +1,5 @@
module.exports = function(cb) {
module.exports = function(callback) {
let recipient = process.argv[4];
if (!recipient) {
console.log('Please provide a recipient address');
@@ -8,4 +8,6 @@ module.exports = function(cb) {
let amount = parseInt(process.argv[5]) || 1;
console.log(recipient);
web3.eth.sendTransaction({to: recipient, value: web3.toWei(amount), from: web3.eth.accounts[0]}, console.log);
callback();
}