forked from AschPlatform/asch-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(proposal): Finshed proposal and gateway features, closes Asch…
- Loading branch information
Showing
4 changed files
with
145 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,125 @@ | ||
var crypto = require("./crypto.js") | ||
var transaction = require('./transaction.js') | ||
|
||
/*function propose(options, secret, secondSecret) { | ||
var keys = crypto.getKeys(secret); | ||
function registerGateway(options, secret, secondSecret) { | ||
// construct content | ||
let content = { | ||
name : options.gatewayName, | ||
desc : options.gatewayDesc, | ||
minimumMembers: options.minimumMembers || 3, | ||
updateInterval: options.updateInterval || 8640, | ||
currency: { | ||
symbol : options.currencySymbol, | ||
desc: options.currencyDesc, | ||
precision : options.currencyPrecision | ||
} | ||
} | ||
|
||
return transaction.createTransactionEx({ | ||
type: 300, | ||
fee: 10 * 1e8, | ||
secret: secret, | ||
secondSecret, secondSecret, | ||
args: [options.title, options.desc, null, null, options.endHeight] | ||
type: 300, | ||
fee: 10 * 1e8, | ||
secret: secret, | ||
secondSecret: secondSecret, | ||
args: [ | ||
options.proposalTitle || 'title for gateway_register', | ||
options.proposalDesc, 'gateway_register', | ||
content, | ||
options.proposalEndHeight | ||
] | ||
}) | ||
}*/ | ||
} | ||
|
||
function registergateway(options, secret, secondSecret) { | ||
|
||
let keys = crypto.getKeys(secret); | ||
let currency = { | ||
symbol : options.symbol, | ||
desc: options.currencyDesc, | ||
precision : options.precision | ||
} | ||
// construct this content | ||
function initGateway(options, secret, secondSecret) { | ||
// construct content | ||
let content = { | ||
name : options.name, | ||
desc : options.desc, | ||
minimumMembers: options.minimumMembers, | ||
updateInterval: options.updateInterval, | ||
currency: currency | ||
gateway : options.gatewayName, | ||
members: options.gatewayMembers | ||
} | ||
|
||
return transaction.createTransactionEx({ | ||
type: 300, | ||
fee: 10 * 1e8, | ||
secret: secret, | ||
secondSecret, secondSecret, | ||
args: [options.title, options.desc, 'gateway_register', content, options.endHeight] | ||
secondSecret: secondSecret, | ||
args: [ | ||
options.proposalTitle || 'title for gateway_init', | ||
options.proposalDesc || 'desc for gateway_init', | ||
'gateway_init', | ||
content, | ||
options.proposalEndHeight | ||
] | ||
}) | ||
} | ||
|
||
function initgateway(options, secret, secondSecret) { | ||
|
||
let keys = crypto.getKeys(secret); | ||
// construct this content | ||
function updateGatewayMember(options, secret, secondSecret) { | ||
// construct content | ||
let content = { | ||
gateway : options.name, | ||
members: options.members | ||
gateway: options.gatewayName, | ||
from: options.fromAddress, | ||
to: options.toAddress | ||
} | ||
|
||
return transaction.createTransactionEx({ | ||
type: 300, | ||
fee: 10 * 1e8, | ||
secret: secret, | ||
secondSecret, secondSecret, | ||
args: ['xxxxxxxxxx', '', 'gateway_init', content, 500000] | ||
secondSecret: secondSecret, | ||
args: [ | ||
options.proposalTitle || 'title for gateway_update_member', | ||
options.proposalDesc || 'desc for gateway_update_member', | ||
'gateway_update_member', | ||
content, | ||
options.proposalEndHeight | ||
] | ||
}) | ||
} | ||
|
||
function activate(options, secret, secondSecret) { | ||
function revokeGateway(options, secret, secondSecret) { | ||
// construct content | ||
let content = { | ||
gateway: options.gatewayName | ||
} | ||
|
||
return transaction.createTransactionEx({ | ||
type: 300, | ||
fee: 10 * 1e8, | ||
secret: secret, | ||
secondSecret: secondSecret, | ||
args: [ | ||
options.proposalTitle || 'title for gateway_revoke', | ||
options.proposalDesc || 'desc for gateway_revoke', | ||
'gateway_revoke', | ||
content, | ||
options.proposalEndHeight | ||
] | ||
}) | ||
} | ||
|
||
let keys = crypto.getKeys(secret); | ||
function activateProposal(tid, secret, secondSecret) { | ||
return transaction.createTransactionEx({ | ||
type: 302, | ||
fee: 0 * 1e8, | ||
secret: secret, | ||
secondSecret, secondSecret, | ||
args: [options.tid] | ||
secondSecret: secondSecret, | ||
args: [tid] | ||
}) | ||
} | ||
|
||
function upvote(options, secret, secondSecret) { | ||
|
||
let keys = crypto.getKeys(secret); | ||
function upvoteProposal(tid, secret, secondSecret) { | ||
return transaction.createTransactionEx({ | ||
type: 301, | ||
fee: 1e7, // 0.1 * 1e8 | ||
secret: secret, | ||
secondSecret, secondSecret, | ||
args: [options.tid] | ||
secondSecret: secondSecret, | ||
args: [tid] | ||
}) | ||
} | ||
|
||
module.exports = { | ||
//propose: propose | ||
registergateway: registergateway, | ||
initgateway: initgateway, | ||
activate: activate, | ||
upvote: upvote | ||
registerGateway: registerGateway, | ||
initGateway: initGateway, | ||
updateGatewayMember: updateGatewayMember, | ||
revokeGateway: revokeGateway, | ||
activateProposal: activateProposal, | ||
upvoteProposal: upvoteProposal | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters