-
Notifications
You must be signed in to change notification settings - Fork 6
updating transactions #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ayinot
wants to merge
2
commits into
gallactic:master
Choose a base branch
from
ayinot:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ typings/ | |
| .next | ||
|
|
||
| package-lock.json | ||
| .DS_Store | ||
|
|
||
|
|
||
| # Snak project folders | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,106 +1,59 @@ | ||
| 'use strict' | ||
|
|
||
| "use strict"; | ||
| var Keys = require('../keys'); | ||
| var keys = new Keys; | ||
|
|
||
| const SEND_TX_TYPE = 0x1 | ||
| const BOND_TX_TYPE = 0x3; | ||
| const UNBOND_TX_TYPE = 0x4; | ||
| const PERMISSION_TX_TYPE = 0x5; | ||
|
|
||
| module.exports = class Transaction { | ||
|
|
||
| constructor(intergallactic) { | ||
| this.igc = intergallactic; | ||
| } | ||
|
|
||
| send(address, amount, priv_key) { | ||
| const account = keys.getAccountInfo(priv_key) | ||
|
|
||
| const myTx = { | ||
| from: [{ | ||
| address: account.acAddress, | ||
| amount: amount | ||
| }], | ||
| to: [{ | ||
| address: address, | ||
| amount: amount | ||
| }] | ||
| }; | ||
|
|
||
| return this.signAndBroadcast(myTx, priv_key, SEND_TX_TYPE) | ||
| } | ||
|
|
||
| permission(address,perm_value,priv_key) { | ||
| const account = keys.getAccountInfo(priv_key) | ||
| const myTx = { | ||
| from: { | ||
| address: account.acAddress, | ||
| amount: 0 | ||
| }, | ||
| to: { | ||
| address: address, | ||
| amount: 0 | ||
| }, | ||
| permissions: perm_value, | ||
| set: true | ||
| } | ||
|
|
||
| return this.signAndBroadcast(myTx, priv_key,PERMISSION_TX_TYPE) | ||
| } | ||
|
|
||
| transact() { | ||
| let myTx = this.buildTxn(fromAddress, toAddress, amount) | ||
| } | ||
|
|
||
| bond(pubKey,amount,fee,priv_key) { | ||
| const account = keys.getAccountInfo(priv_key) | ||
| const vaAccount = keys.getInfoByPublicKey(pubKey) | ||
|
|
||
| const myTx = { | ||
| from: { | ||
| address: account.acAddress, | ||
| amount: amount | ||
| }, | ||
| to: { | ||
| address: vaAccount.vaAddress, | ||
| amount: amount | ||
| }, | ||
| publicKey: pubKey, | ||
| gasLimit: fee | ||
| }; | ||
|
|
||
| return this.signAndBroadcast(myTx, priv_key, BOND_TX_TYPE) | ||
| } | ||
|
|
||
| unbond(address,amount,fee,priv_key) { | ||
| const account = keys.getAccountInfo(priv_key) | ||
|
|
||
| const myTx = { | ||
| from: { | ||
| address: account.vaAddress, | ||
| amount: amount | ||
| }, | ||
| to: { | ||
| address: address, | ||
| amount: amount | ||
| }, | ||
| gasLimit: fee | ||
| }; | ||
|
|
||
| return this.signAndBroadcast(myTx, priv_key, UNBOND_TX_TYPE) | ||
| } | ||
|
|
||
| randomTransact() { | ||
| //TODO | ||
| } | ||
|
|
||
| signAndBroadcast(txnObject, priv_key, txnType) { | ||
|
|
||
| const newTxn = new this.igc.Transaction(txnObject, { type: txnType }); | ||
|
|
||
| return newTxn.signNBroadcast(priv_key).then(data => { | ||
| return (data); | ||
| }) | ||
| } | ||
| } | ||
| constructor(intergallactic) { | ||
| this.igc = intergallactic; | ||
| } | ||
|
|
||
| send(address, amount, priv_key) { | ||
| const myTx = { | ||
| to: address, | ||
| amount: amount | ||
| }; | ||
| const newTxn = new this.igc.Transaction(myTx); | ||
| return newTxn.send(priv_key); | ||
| } | ||
|
|
||
| permission(address, perm_value, priv_key) { | ||
| const myTx = { | ||
| to: address, | ||
| amount: 0, | ||
| permissions:perm_value, | ||
| set: true | ||
| }; | ||
| const newTxn = new this.igc.Transaction(myTx); | ||
| return newTxn.permission(priv_key); | ||
| } | ||
|
|
||
| bond(pubKey, amount, priv_key) { | ||
| const vaAccount = keys.getInfoByPublicKey(pubKey) | ||
| const myTx = { | ||
| to: vaAccount.vaAddress, | ||
| amount: amount, | ||
| publicKey: pubKey | ||
| }; | ||
| const newTxn = new this.igc.Transaction(myTx); | ||
| return newTxn.bond(priv_key); | ||
| } | ||
|
|
||
| unbond(address, amount, priv_key) { | ||
| const myTx = { | ||
| to: address, | ||
| amount: amount | ||
| }; | ||
| const newTxn = new this.igc.Transaction(myTx); | ||
| return newTxn.send(priv_key); | ||
| } | ||
|
|
||
| call(to, gaslimit, amount, data) { | ||
| const myTx = { | ||
| to: to, | ||
| gasLimit: gaslimit, | ||
| amount: amount, | ||
| data: data | ||
| }; | ||
| const newTxn = new this.igc.Transaction(myTx); | ||
| return newTxn.call(priv_key); | ||
| } | ||
| }; |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove fee from these txs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @ToniyaSundaram removed it, because currently intergallactic don't support fee feature yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@b00f Yes it is in accordance with intergallactic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fee = OutAmount - InAMount.I think gnet should handle it. not intergallactic.