Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@ n stable
peerstat analyze block height of all peers
delegatestat analyze delegates status
ipstat analyze peer ip info

~~propose [options] propose a proposal~~
registergateway [options] register a gateway
activateproposal [options] activate a proposal
initgateway [options] initiate a gateway
updatemember [options] update a member of a gateway
revokegateway [options] revoke a gateway
registermember [options] register a member for a gateway
upvoteproposal [options] vote for a proposal


Options:

-h, --help output usage information
Expand Down
134 changes: 130 additions & 4 deletions plugins/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ function sendMoney(options) {
secret: options.secret,
secondSecret: options.secondSecret,
args: [
'XAS',
options.amount,
Number(options.amount),
options.to
]
});
Expand All @@ -216,7 +215,6 @@ function setName(options) {
options.secret,
options.secondSecret
);
console.log(JSON.stringify(trs))
getApi().broadcastTransaction(trs, function (err, result) {
console.log(err || result.transactionId)
});
Expand Down Expand Up @@ -360,6 +358,74 @@ function transaction(options) {
});
}

/* function propose(options) {
var trs = aschJS.proposal.propose({
title: options.title,
desc: options.desc,
endHeight: options.endHeight
},options.secret, options.secondSecret)
getApi().broadcastTransaction(trs, function (err, result) {
console.log(err || result.transactionId)
});
} */

function registergateway(options) {
var trs = aschJS.proposal.registergateway({
title: options.title,
desc: options.desc,
endHeight: Number(options.endHeight),
name: options.name,
symbol: options.symbol,
currencyDesc: options.currencyDesc,
precision: options.precision || 8,
minimumMembers: options.minimumMembers || 3,
updateInterval: options.updateInterval || 8640
},options.secret, options.secondSecret)
getApi().broadcastTransaction(trs, function (err, result) {
console.log(err || result.transactionId)
});
}activateproposal

function activateproposal(options) {
var trs = aschJS.proposal.activate({
tid: options.tid
},options.secret, options.secondSecret)
getApi().broadcastTransaction(trs, function (err, result) {
console.log(err || result.transactionId)
});
}

function upvoteproposal(options) {
var trs = aschJS.proposal.upvote({
tid: options.tid
},options.secret, options.secondSecret)
getApi().broadcastTransaction(trs, function (err, result) {
console.log(err || result.transactionId)
});
}

function initgateway(options) {
var trs = aschJS.proposal.initgateway({
name: options.name,
members: JSON.parse('[' + options.members.split(',').map(function(word){
return '"' + word.trim() + '"';
}).join(',')
+']')
},options.secret, options.secondSecret)
getApi().broadcastTransaction(trs, function (err, result) {
console.log(err || result.transactionId)
});
}

function registermember(options) {
var trs = aschJS.gateway.registerMember({
gateway: options.gateway
},options.secret, options.secondSecret)
getApi().broadcastTransaction(trs, function (err, result) {
console.log(err || result.transactionId)
});
}

function lock(options) {
var trs = aschJS.transaction.createLock(options.height, options.secret, options.secondSecret)
getApi().broadcastTransaction(trs, function (err, result) {
Expand Down Expand Up @@ -728,4 +794,64 @@ module.exports = function(program) {
.option("-m, --message <message>", "")
.option("-f, --fee <fee>", "transaction fee")
.action(transaction);
}

/* Only proposals with a type (topic) set can be done
program
.command("propose")
.description("propose a proposal")
.option("-e, --secret <secret>", "")
.option("-t, --title <title>", "Title of the proposal (10-100 chars)")
.option("-d, --desc <description>", "Description of the proposal")
.option("-h, --endHeight <height>", "Proposal end date")
.action(propose);
*/

program
.command("registergateway")
.description("register a gateway")
.option("-e, --secret <secret>", "")
.option("-s, --secondSecret <secret>", "")
.option("-t, --title <title>", "Title of the Gateway (10-100 chars)")
.option("-d, --desc <description>", "Description of the Gateway")
.option("-h, --endHeight <height>", "Proposal end date")
.option("-n, --name <name>", "Name of the currency (3-16 uppercase and lowercase chars)")
.option("-s, --symbol <symbol>", "Howto call the issued currency")
.option("-c, --currencyDesc <Description>", "description of the currency")
.option("-p, --precision <precision>", "precision of the currency")
.option("-m, --minimumMembers <minimumMembers>", "The minimum number of members of the gateway, the range of this value should be an integer between 3-33")
.option("-u, --updateInterval <updateInterval>", "update frequency, this value Should be greater than or equal to 8640")
.action(registergateway);

program
.command("activateproposal")
.description("activate a proposal")
.option("-e, --secret <secret>", "")
.option("-s, --secondSecret <secret>", "")
.option("-t, --tid <tid>", "The tid of the proposal")
.action(activateproposal);

program
.command("initgateway")
.description("register a gateway")
.option("-e, --secret <secret>", "")
.option("-s, --secondSecret <secret>", "")
.option("-n, --name <name>", "Name of the currency / gateway (3-16 uppercase and lowercase chars)")
.option("-m, --members <addressMember1, addressMember2, addressMember3, ...>", "csv list of the member addresses")
.action(initgateway);

program
.command("registermember")
.description("register a member for a gateway")
.option("-e, --secret <secret>", "")
.option("-s, --secondSecret <secret>", "")
.option("-g, --gateway <gateway>", "the name of the gateway")
.action(registermember);

program
.command("upvoteproposal")
.description("activate a proposal")
.option("-e, --secret <secret>", "")
.option("-s, --secondSecret <secret>", "")
.option("-t, --tid <tid>", "The tid of the proposal")
.action(upvoteproposal);
}