From a1c9f6e7ca1e91e6e1aa2f4add7ee14193ef70ad Mon Sep 17 00:00:00 2001 From: donne <503124742@qq.com> Date: Tue, 5 Apr 2022 11:07:09 +0800 Subject: [PATCH 1/3] fix selectedChain --- src/libs/fetch.js | 5 +++-- src/views/WalletAccounts.vue | 10 +++++++--- .../OperationModal/TransactionResult.vue | 6 +++++- src/views/components/OperationModal/index.vue | 16 ++++++++++++++-- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/libs/fetch.js b/src/libs/fetch.js index 83457768..8ea2bfa2 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -75,8 +75,9 @@ export default class ChainFetch { return this.get('/cosmos/slashing/v1beta1/signing_infos?pagination.limit=500', config) } - async getTxs(hash) { - const ver = this.getSelectedConfig() ? this.config.sdk_version : '0.41' + async getTxs(hash, config = null) { + const conf = config || this.getSelectedConfig() + const ver = conf.sdk_version || '0.41' // /cosmos/tx/v1beta1/txs/{hash} if (ver && compareVersions(ver, '0.40') < 1) { return this.get(`/txs/${hash}`).then(data => WrapStdTx.create(data, ver)) diff --git a/src/views/WalletAccounts.vue b/src/views/WalletAccounts.vue index 8bd37b63..0d1735fb 100644 --- a/src/views/WalletAccounts.vue +++ b/src/views/WalletAccounts.vue @@ -154,14 +154,14 @@ Transfer IBC Transfer @@ -268,6 +268,7 @@ @@ -334,6 +335,7 @@ export default { ibcDenom: {}, quotes: {}, operationModalType: '', + selectedChainName: '', options: { maintainAspectRatio: false, legend: { @@ -532,9 +534,11 @@ export default { this.currency2 = c this.currency = getUserCurrencySign() }, - transfer(type, addr) { + transfer(type, addr, chain) { + console.log(chain) this.operationModalType = type this.selectedAddress = addr + this.selectedChainName = chain }, completeAdd() { this.init() diff --git a/src/views/components/OperationModal/TransactionResult.vue b/src/views/components/OperationModal/TransactionResult.vue index 12c2fa27..6b8b88b9 100644 --- a/src/views/components/OperationModal/TransactionResult.vue +++ b/src/views/components/OperationModal/TransactionResult.vue @@ -100,6 +100,10 @@ export default { type: String, default: null, }, + selectedChain: { + type: Object, + default: null, + }, }, data() { return { @@ -133,7 +137,7 @@ export default { trace() { if (this.hash) { this.error = null - this.$http.getTxs(this.hash).then(res => { + this.$http.getTxs(this.hash, this.selectedChain).then(res => { if (res.code === 0) { this.succeed = true clearInterval(this.timer) diff --git a/src/views/components/OperationModal/index.vue b/src/views/components/OperationModal/index.vue index 356308da..3f2e6303 100644 --- a/src/views/components/OperationModal/index.vue +++ b/src/views/components/OperationModal/index.vue @@ -140,6 +140,7 @@ @@ -236,13 +237,16 @@ export default { type: String, default: null, }, + selectedChainName: { + type: String, + default: null, + }, }, data() { return { modalTitle: '', historyName: '', selectedValidator: null, - selectedChain: null, token: '', chainId: '', balance: [], @@ -301,6 +305,14 @@ export default { const selectedAddress = this.accounts.address.find(x => x.chain === chain) return selectedAddress?.addr }, + selectedChain() { + let config = null + const allChains = localStorage.getItem('chains') + if (allChains) { + config = JSON.parse(allChains)[this.selectedChainName] + } + return config + }, }, methods: { initialize() { @@ -318,7 +330,7 @@ export default { this.accountNumber = account.accountNumber this.sequence = account.sequence }) - this.$http.getBankBalances(this.selectedAddress).then(res => { + this.$http.getBankBalances(this.selectedAddress, this.selectedChain).then(res => { if (res && res.length > 0) { this.balance = res.reverse() const token = this.balance.find(i => !i.denom.startsWith('ibc')) From 893e6ed8534a76965de2f7e192f7134b1d162c8f Mon Sep 17 00:00:00 2001 From: donne <503124742@qq.com> Date: Tue, 5 Apr 2022 11:21:38 +0800 Subject: [PATCH 2/3] fix --- src/views/WalletAccounts.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/WalletAccounts.vue b/src/views/WalletAccounts.vue index 8132c640..67339a9b 100644 --- a/src/views/WalletAccounts.vue +++ b/src/views/WalletAccounts.vue @@ -488,7 +488,6 @@ export default { this.currency = getUserCurrencySign() }, transfer(type, addr, chain) { - console.log(chain) this.operationModalType = type this.selectedAddress = addr this.selectedChainName = chain From c91b1f72d777e0fbf804c7f99d91052c568eb46d Mon Sep 17 00:00:00 2001 From: donne <503124742@qq.com> Date: Tue, 5 Apr 2022 11:27:21 +0800 Subject: [PATCH 3/3] fix --- src/views/components/OperationModal/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/components/OperationModal/index.vue b/src/views/components/OperationModal/index.vue index ec9f2194..3e4bf2ba 100644 --- a/src/views/components/OperationModal/index.vue +++ b/src/views/components/OperationModal/index.vue @@ -308,7 +308,7 @@ export default { selectedChain() { let config = null const allChains = localStorage.getItem('chains') - if (allChains) { + if (allChains && this.selectedChainName) { config = JSON.parse(allChains)[this.selectedChainName] } return config