OSDN Git Service

update cross transfer details page.
authorZhiting Lin <zlin035@uottawa.ca>
Thu, 12 Sep 2019 05:45:48 +0000 (13:45 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Thu, 12 Sep 2019 05:45:48 +0000 (13:45 +0800)
src/assets/language/cn.js
src/assets/language/en.js
src/models/bytom.js
src/views/assetList.vue
src/views/home.vue
src/views/sendTransaction/crossChainTransaction.vue
src/views/transferDetail.vue
src/views/vote/vote.vue

index 212250c..da2ebf3 100644 (file)
@@ -55,7 +55,8 @@ const cn = {
     amountHint:'跨链交易预计24小时内完成',
     toVapor:'转入\nVapor链',
     toBytom:'转出至\nBytom链',
-    asset:'选择资产'
+    asset:'选择资产',
+    direction:'跨链方向'
   },
   listVote:{
     title:'节点投票',
@@ -70,6 +71,7 @@ const cn = {
     bpPubkey:'节点公钥',
     vote:'投票',
     votes:'票数',
+    voteVotes:'投票票数',
     voteAccount:'投票账户',
     vetoAccount:'取消投票账户'
   },
index 1d12d9d..7b3ec0b 100644 (file)
@@ -55,7 +55,8 @@ const en = {
     amountHint:'Cross Chain Transaction will be completed in 24 hrs.',
     toVapor:'Transfer to \n Vapor Chain',
     toBytom:'Transfer to \n Bytom Chain',
-    asset:'Select Asset'
+    asset:'Select Asset',
+    direction:'Cross Direction'
   },
   listVote:{
     title:'Block Producer Voting',
@@ -70,6 +71,7 @@ const en = {
     bpPubkey:'BP Public Key',
     vote:'Vote',
     votes:'Votes',
+    voteVotes:'Votes',
     voteAccount:'Vote Account',
     vetoAccount:'Veto Account'
   },
index fee8297..a1ef96b 100644 (file)
@@ -1,9 +1,10 @@
 import Bytom from 'bytom-js-sdk'
 
 var networks = {
-  testnetvapor: 'http://52.82.55.145:3000/api/v1/vapor/',
-  testnet: 'http://52.82.55.145:3000/api/v1/btm/',
-  solonet: 'http://app.bycoin.io:3060/api/v1/btm/',
+  solonetvapor: 'http://52.82.55.145:3000/api/v1/vapor/',
+  solonet: 'http://52.82.55.145:3000/api/v1/btm/',
+  testnetvapor: 'http://app.bycoin.io:3020/api/v1/vapor/',
+  testnet: 'http://app.bycoin.io:3020/api/v1/btm/',
   mainnet: 'https://api.bycoin.im:8000/api/v1/btm/',
   mainnetvapor: 'https://api.bycoin.im:8000/api/v1/vapor/'
 }
index 1db2416..061620b 100644 (file)
 
 <script>
 import address from "@/utils/address";
+import query from "@/models/query";
 import transaction from "@/models/transaction";
 import { BTM } from "@/utils/constants";
 import { mapActions, mapGetters, mapState } from 'vuex'
@@ -203,7 +204,8 @@ export default {
     computed: {
         ...mapState([
           'bytom',
-          'currentAsset'
+          'currentAsset',
+          'listVote'
         ]),
         ...mapGetters([
           'currentAccount',
@@ -270,20 +272,25 @@ export default {
               .filter(b => b.asset === assetID);
 
             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'
               const inAmount = _.sumBy((transaction.inputs.filter(i => i.type ==='veto')), 'amount')
               const outAmount = _.sumBy((transaction.outputs.filter(i => i.type ==='vote')), 'amount')
+              transaction.pubkey = filterInput.vote
               transaction.vAmount =  Num.formatNue(inAmount-outAmount,8)
-            }else if(_.find(transaction.outputs, function(o) { return o.type =='vote'; })){
+            }else if(filterOutput){
               const outAmount = _.sumBy((transaction.outputs.filter(i => i.type ==='vote')), 'amount')
+              transaction.pubkey = filterOutput.vote
               transaction.vAmount =  Num.formatNue(outAmount,8)
               transaction.type = 'vote'
             }else if(_.find(transaction.outputs, function(o) { return o.type =='crosschain_output'; })){
               transaction.type = 'crossChain'
+              transaction.cDirection ='Vapor -> Bytom'
             }else if(_.find(transaction.inputs, function(o) { return o.type =='crosschain_input'; })){
               transaction.type = 'crossChain'
+              transaction.cDirection ='Bytom -> Vapor'
             }
 
             if(balanceObject.length ===1 ){
@@ -315,12 +322,24 @@ export default {
         },
       ...mapActions([
         Actions.UPDATE_STORED_BYTOM,
+        Actions.SET_LIST_VOTE
       ])
     },
     mounted() {
         this.refreshTransactions( this.start, this.limit).then(transactions => {
           this.transactions = transactions
         });
+        if(this.listVote.length == 0){
+          query.chainStatus().then(resp => {
+            if(resp){
+              const votes =  resp.consensus_nodes.map( (item, index) => {
+                item.rank = index+1;
+                return item
+              });
+              this[Actions.SET_LIST_VOTE](votes)
+            }
+          })
+        }
     },
   };
 </script>
index 13f18ec..8a3ff85 100644 (file)
@@ -403,6 +403,9 @@ export default {
         },
         netTypeToggle: function (event) {
             const newNetType = event.target.value  ==='bytom'? '' :event.target.value;
+
+            console.log(newNetType)
+          console.log(this.netType)
             if( newNetType !== this.netType){
               const bytom = this.bytom.clone();
 
index 560efb5..9f786f7 100644 (file)
@@ -245,7 +245,7 @@ export default {
             const balanceObject = balances.filter(b => b.asset === BTM)[0]
             balance = balanceObject.balance
 
-            let vote, lock
+            let vote = 0, lock = 0
 
             const votes = this.currentAccount.votes
 
index b02a470..5b32f0f 100644 (file)
                           <p>{{transaction.fee}}</p>
                         </td>
                       </tr>
+                      <tr v-if="transaction.type =='vote'">
+                        <td colspan="2"><div class="divider"></div></td>
+                      </tr>
+                      <tr  v-if="transaction.type =='vote'">
+                        <td class="label">
+                          {{ $t('listVote.bpName') }}
+                        </td>
+                        <td class="value">
+                          <p>{{transaction.vName}}</p>
+                        </td>
+                      </tr>
+                      <tr  v-if="transaction.type =='vote'">
+                        <td class="label">
+                          {{ $t('listVote.voteVotes') }}
+                        </td>
+                        <td class="value">
+                          <p>{{transaction.vAmount}}</p>
+                        </td>
+                      </tr>
+                      <tr v-if="transaction.type =='crossChain'">
+                        <td colspan="2"><div class="divider"></div></td>
+                      </tr>
+                      <tr  v-if="transaction.type =='crossChain'">
+                        <td class="label">
+                          {{ $t('crossChain.direction') }}
+                        </td>
+                        <td class="value">
+                          <p>{{transaction.cDirection}}</p>
+                        </td>
+                      </tr>
                       <tr>
                         <td colspan="2"><div class="divider"></div></td>
                       </tr>
         }
       },
       ...mapState([
-        'currentAsset'
+        'currentAsset',
+        'listVote'
       ]),
       ...mapGetters([
         'currentAccount',
     mounted() {
         let params = this.$route.params;
 
-        this.transaction = params.transaction;
+        let transaction = params.transaction;
         if(this.netType === 'vapor'){
           this.selfAddress = this.currentAccount.vpAddress;
         }else{
           this.selfAddress = this.currentAccount.address;
         }
         console.log(params.transaction)
+        if(transaction.type =='vote' || transaction.type =='veto'){
+          const node =_.find(this.listVote, {pub_key: transaction.pubkey})
+          transaction.vName = node.name
+        }
+        this.transaction = transaction
     }
 };
 </script>
index e65b456..f3e4adb 100644 (file)
@@ -135,7 +135,7 @@ export default {
           const balanceObject = balances.filter(b => b.asset === BTM)[0]
           balance = balanceObject.balance
 
-          let vote, lock
+          let vote = 0, lock = 0
           const votes = this.currentAccount.votes
           if(votes && votes.length >0 ){
             vote = _.sumBy(votes,'total')