Skip to content

Commit

Permalink
Merge pull request #241 from MickWang/master
Browse files Browse the repository at this point in the history
update for ledger connector
  • Loading branch information
MickWang authored Jul 8, 2020
2 parents 2fc42dc + d2a44f8 commit 189b388
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/common/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ Within their 50% share each consensus node will receive their share according to
submit: 'Submit',
updateSuccess: 'Update node info succeed',
updateFailed: 'Update node info failed',
ledgerWalletNotSupportForNow: 'Nodes registered with ledger currently do not support updating node-related information '
ledgerWalletNotSupportForNow: 'Nodes registered with ledger currently do not support updating node-related information. Please email to: '
},
exchange: {
exchange: 'Exchange',
Expand Down
2 changes: 1 addition & 1 deletion src/common/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ export default {
submit: '提交',
updateSuccess: '更新成功',
updateFailed: '更新失败',
ledgerWalletNotSupportForNow: '使用Ledger注册的节点,暂时不支持更新节点相关信息'
ledgerWalletNotSupportForNow: '使用Ledger注册的节点,暂时不支持更新节点相关信息.请发送邮件至:'
},
exchange: {
exchange: 'Exchange',
Expand Down
18 changes: 13 additions & 5 deletions src/renderer/components/Common/SignSendTx.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,20 @@ export default {
},
mounted(){
if(!this.wallet.key) {//common wallet
this.$store.dispatch('getLedgerStatus')
},
watch: {
visible(newV, oldV) {
if(newV) {
if(!this.wallet.key) {//common wallet
this.$store.dispatch('getLedgerStatus')
}
} else {
this.$store.dispatch('stopGetLedgerStatus')
}
}
},
beforeDestroy() {
clearInterval(this.intervalId);
this.$store.dispatch('stopGetLedgerStatus')
},
data(){
Expand Down Expand Up @@ -102,9 +110,11 @@ export default {
const signature = pri.sign(tx)
this.$store.dispatch("hideLoadingModals");
this.$emit('afterSign', signature) // 返回签名message结果
this.walletPassword = ''
} else {
TransactionBuilder.signTransaction(tx, pri);
this.sendTx(tx);
this.walletPassword = ''
}
} else {
Expand All @@ -122,7 +132,6 @@ export default {
},
err => {
this.sending = false;
this.ledgerStatus = "";
this.$store.dispatch("hideLoadingModals");
this.$message.error(this.$t('ledgerWallet.signFailed'))
}
Expand All @@ -143,7 +152,6 @@ export default {
},
err => {
this.sending = false;
this.ledgerStatus = "";
this.$store.dispatch("hideLoadingModals");
this.$message.error(this.$t('ledgerWallet.signFailed'))
}
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/Node/NodeApply/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export default {
return;
}
this.current += 1;
this.$store.dispatch('stopGetLedgerStatus') // 防止过多ledger请求
},
cancel() {
this.current -= 1;
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/components/Node/NodeStake/NodeInfo.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<template>
<div>
<div v-if="!stakeWallet.key" class="ledger-not-support">
{{$t('nodeInfo.ledgerWalletNotSupportForNow')}}
<p>{{$t('nodeInfo.ledgerWalletNotSupportForNow')}}
<a href=mailto:contact@ont.io>[email protected]</a>
</p>

</div>
<div class="container" v-if="stakeWallet.key">
<div class="info-container">
Expand Down
12 changes: 8 additions & 4 deletions src/renderer/store/modules/LedgerConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function getDevice(commit, state) {
}

function getLedgerPublicKey(commit, state) {
// 这里如果去掉,再SelectWallet组件里,切换类型后不再重新获取ledger地址,会产生bug。
// if (state.publicKey) {
// return;
// }
Expand Down Expand Up @@ -89,17 +88,22 @@ const mutations = {
}
}

const LEDGER_CONNECTOR_INTERVAL = 'ledger_connector_intervalId'

const actions = {
getLedgerStatus({dispatch,commit,state}, interval) {
let time = interval || 3000;
let time = interval || 5000;
getDevice(commit, state)
const intervalId = setInterval(() => {
getDevice(commit, state)
}, time)
commit('UPDATE_LEDGER_CONNECTOR_INTERVALID', {intervalId: intervalId})
localStorage.setItem(LEDGER_CONNECTOR_INTERVAL, intervalId)
},
stopGetLedgerStatus({commit, state}) {
clearInterval(state.intervalId)
const intervalId = localStorage.getItem(LEDGER_CONNECTOR_INTERVAL) || ''
clearInterval(intervalId)
localStorage.removeItem(LEDGER_CONNECTOR_INTERVAL)
commit('UPDATE_LEDGER_PUBLICKEY', {publicKey: ''})
}
}

Expand Down

0 comments on commit 189b388

Please sign in to comment.