return retPromise;
};
-transaction.buildVote = function(guid, vote, amount, confirmations, memo) {
+transaction.buildVote = function(address, vote, amount, confirmations, memo) {
let retPromise = new Promise((resolve, reject) => {
bytom.transaction
- .buildVote(guid, vote, Number(amount), confirmations, memo)
+ .buildVote(address, vote, amount.toString(), confirmations, memo)
.then(res => {
resolve(res);
})
return retPromise;
};
-transaction.buildVeto = function(guid, vote, amount, confirmations, memo) {
+transaction.buildVeto = function(address, vote, amount, confirmations, memo) {
let retPromise = new Promise((resolve, reject) => {
bytom.transaction
- .buildVeto(guid, vote, Number(amount), confirmations, memo)
+ .buildVeto(address, vote, amount.toString(), confirmations, memo)
.then(res => {
resolve(res);
})
const balanceObject = transaction.balances
.filter(b => b.asset.assetId === assetID);
- const filterInput = transaction.types.includes('veto')
- const filterOutput = transaction.types.includes('vote')
+ const filterInput = _.find(transaction.inputs, function(o) { return o.type =='veto'; })
+ const filterOutput = _.find(transaction.outputs, function(o) { return o.type =='vote'; })
if(filterInput){
transaction.type = 'veto'
}else{
transaction.cDirection ='Bytom -> Vapor'
}
- }else if(transaction.types.includes('in_crosschain')){
+ }else if(transaction.types.includes('in_crosschain')){
transaction.type = 'crossChain'
if(this.netType === 'vapor'){
transaction.cDirection ='Bytom -> Vapor'
<div class="tx-header"
v-bind:class="classObject">
<p class="value">{{transaction.direct}}{{transaction.val}}</p>
- <small class="header-text" v-if="transaction.status_fail">
+ <small class="header-text" v-if="!transaction.status">
{{ $t('transactionDetail.fail') }}
</small>
<small class="header-text" v-else-if="transaction.hasOwnProperty('blockTimestamp')">
<p>{{transaction.fee}}</p>
</td>
</tr>
- <tr v-if="transaction.type =='vote'">
+ <tr v-if="transaction.type =='vote' || transaction.type =='veto' ">
<td colspan="2"><div class="divider"></div></td>
</tr>
- <tr v-if="transaction.type =='vote'">
+ <tr v-if="transaction.type =='vote' || transaction.type =='veto'">
<td class="label">
{{ $t('listVote.bpName') }}
</td>
}
console.log(params.transaction)
if(transaction.type =='vote' || transaction.type =='veto'){
- const node =_.find(this.listVote, {pub_key: transaction.pubkey})
+ const node =_.find(this.listVote, {pubKey: transaction.pubkey})
transaction.vName = node.name
}
this.transaction = transaction
{{vote.name}}
</div>
</div>
- <div class="vote-number">{{$t('listVote.votes')}} {{formatNue(vote.vote_num)}} ({{formatFraction(vote.vote_num, totalVote)}})</div>
+ <div class="vote-number">{{$t('listVote.votes')}} {{formatNue(vote.voteNum)}} ({{formatFraction(vote.voteNum, totalVote)}})</div>
</td>
<td class="text-align-right">
<button class="btn btn-vote" @click="openVote(vote)">
mounted() {
query.chainStatus().then(resp => {
if(resp){
- this.totalVote = resp.total_vote_num;
- const votes = resp.consensus_nodes.map( (item, index) => {
+ this.totalVote = resp.totalVoteNum;
+ const votes = resp.consensusNodes.map( (item, index) => {
item.rank = index+1;
return item
});
const vote = this.selectVote.pubKey
this.transaction.to = vote
- transaction.buildVeto(this.currentAccount.guid, vote, Num.convertToNue(this.transaction.amount,8), this.transaction.confirmations).then(result => {
+ transaction.buildVeto(this.currentAccount.vpAddress, vote, this.transaction.amount, this.transaction.confirmations).then(result => {
loader.hide();
if(!this.transaction.fee){
- this.transaction.fee = Number( _.sumBy(result, 'fee'));
+ this.transaction.fee = Number( _.sumBy(result, 'tx.fee'));
}
this.$router.push({ name: 'vote-confirm', params: { account: this.currentAccount, transaction: this.transaction, assetAlias: 'BTM',rawData: result} })
}).catch(error => {
let balance,
balances = this.currentAccount.vpBalances
if(balances && balances.length >0 ){
- const balanceObject = balances.filter(b => b.asset === BTM)[0]
- balance = balanceObject.balance
-
- let vote = 0, lock = 0
- const votes = this.currentAccount.votes
- if(votes && votes.length >0 ){
- vote = _.sumBy(votes,'total')
- lock = _.sumBy(votes,'locked')
- }
-
- balance = (balance-vote-lock)/Math.pow(10,balanceObject.decimals)
+ const balanceObject = balances.filter(b => b.asset.assetId === BTM)[0]
+ balance = balanceObject.availableBalance
}
return `${this.$t("vote.amountPlaceHolder")}${(balance != null && balance != 0) ? balance : '0.00'}`
onCancel: this.onCancel
});
- const vote = this.selectVote.pub_key
+ const vote = this.selectVote.pubKey
this.transaction.to = vote
- transaction.buildVote(this.currentAccount.guid, vote, Num.convertToNue(this.transaction.amount,8), this.transaction.confirmations).then(result => {
+ transaction.buildVote(this.currentAccount.vpAddress, vote, this.transaction.amount, this.transaction.confirmations).then(result => {
loader.hide();
if(!this.transaction.fee){
- this.transaction.fee = Number( _.sumBy(result, 'fee') );
+ this.transaction.fee = Number( _.sumBy(result, 'tx.fee') );
}
this.$router.push({ name: 'vote-confirm', params: { account: this.currentAccount, transaction: this.transaction,assetAlias: 'BTM', rawData: result} })
}).catch(error => {
onCancel: this.onCancel
});
- Promise.all(this.rawData.map( (rawdata) => transaction.transfer(this.account.guid, rawdata, this.password)))
+ Promise.all(this.rawData.map( (rawdata) => transaction.transfer(this.account.guid, rawdata, this.password, this.account.vpAddress)))
.then(ret => {
loader.hide();
if(this.$route.params.type == 'popup'){
{{transaction.vName}}
</div>
<div class="addr color-grey">
- <div v-if="transaction.hasOwnProperty('block_timestamp')">
- {{transaction.submission_timestamp | moment}}
+ <div v-if="transaction.hasOwnProperty('blockTimestamp')">
+ {{transaction.submissionTimestamp | moment}}
</div>
<div v-else>
{{ $t('main.unconfirmed') }}
},
refreshTransactions: function (start, limit) {
return new Promise((resolve, reject) => {
- transaction.list(this.currentAccount.guid, BTM, start, limit, tx_types).then(transactions => {
+ transaction.list(this.currentAccount.vpAddress, BTM, start, limit, tx_types).then(transactions => {
if (transactions == null) {
return;
}
transactions.forEach(transaction => {
const balanceObject = transaction.balances
- .filter(b => b.asset === assetID);
-
- const filterInput = _.find(transaction.inputs, function(o) { return o.type =='veto'; })
+ .filter(b => b.asset.assetId === assetID);
+ const filterInput = transaction.types.includes('veto')
const allVotes = this.listVote;
if(filterInput){
const inAmount = _.sumBy((transaction.inputs.filter(i => i.type ==='veto')), 'amount')
const outAmount = _.sumBy((transaction.outputs.filter(i => i.type ==='vote')), 'amount')
transaction.vAmount = Num.formatNue(inAmount-outAmount,8)
- transaction.vName = (_.find(allVotes, {pub_key: pubkey})).name
- }else if(_.find(transaction.outputs, function(o) { return o.type =='vote'; })){
+ transaction.vName = (_.find(allVotes, {pubKey: pubkey})).name
+ }else if(transaction.types.includes('vote')){
const pubkey = (transaction.outputs.filter(i => i.type ==='vote'))[0].vote
const outAmount = _.sumBy((transaction.outputs.filter(i => i.type ==='vote')), 'amount')
transaction.vAmount = Num.formatNue(outAmount,8)
- transaction.vName = (_.find(allVotes, {pub_key: pubkey})).name
+ transaction.vName = (_.find(allVotes, {pubKey: pubkey})).name
transaction.type = 'vote'
}