Skip to content

Commit

Permalink
added vote transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
fix committed May 30, 2017
1 parent 7fc553f commit 89eeef7
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var arkticker = {};
var currencies = ["USD","AUD", "BRL", "CAD", "CHF", "CNY", "EUR", "GBP", "HKD", "IDR", "INR", "JPY", "KRW", "MXN", "RUB"]

var networks = {
testnet: {
devnet: {
nethash: "4befbd4cd1f2f10cbe69ac0b494b5ce070595ed23ee7abd386867c4edcdaf3bd",
peers: [
"5.39.9.245:4000",
Expand Down Expand Up @@ -504,6 +504,66 @@ vorpal
});
});

vorpal
.command('account vote <name>', 'Vote for delegate <name>. Remove previous vote if needed. Leave empty to clear vote')
.action(function(args, callback) {
var self = this;
async.waterfall([
function(seriesCb){
self.prompt({
type: 'password',
name: 'passphrase',
message: 'passphrase: ',
}, function(result){
if (result.passphrase) {
return seriesCb(null, result.passphrase);
}
else{
return seriesCb("Aborted.");
}
});
},
function(passphrase, seriesCb){
var delegate = args.name;
var transaction = require("arkjs").delegates.createVote(passphrase);
self.prompt({
type: 'confirm',
name: 'continue',
default: false,
message: 'Sending '+arkamount/100000000+'ARK '+(currency?'('+currency+args.amount+')':'')+' to '+args.recipient+' now',
}, function(result){
if (result.continue) {
return seriesCb(null, transaction);
}
else {
return seriesCb("Aborted.")
}
});
},
function(transaction, seriesCb){
postTransaction(transaction, function(err, response, body){
if(err){
seriesCb("Failed to send transaction: " + err);
}
else if(body.success){
seriesCb(null, transaction);
}
else {
seriesCb("Failed to send transaction: " + body.error);
}
});
}
], function(err, transaction){
if(err){
self.log(colors.red(err));
}
else{
self.log(colors.green("Transaction sent successfully with id "+transaction.id));
}
return callback();
});
});

vorpal
.command('account send <amount> <recipient>', 'Send <amount> ark to <recipient>. <amount> format examples: 10, USD10.4, EUR100')
.action(function(args, callback) {
Expand Down

0 comments on commit 89eeef7

Please sign in to comment.