fix selectedChain

This commit is contained in:
donne 2022-04-05 11:07:09 +08:00
parent c8f3dcdaaf
commit a1c9f6e7ca
4 changed files with 29 additions and 8 deletions

View File

@ -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))

View File

@ -154,14 +154,14 @@
<b-dropdown-item
v-if="balances[acc.addr]"
v-b-modal.operation-modal
@click="transfer('Transfer',acc.addr)"
@click="transfer('Transfer',acc.addr,acc.chain)"
>
<feather-icon icon="SendIcon" /> Transfer
</b-dropdown-item>
<b-dropdown-item
v-if="balances[acc.addr]"
v-b-modal.operation-modal
@click="transfer('IBCTransfer',acc.addr)"
@click="transfer('IBCTransfer',acc.addr,acc.chain)"
>
<feather-icon icon="SendIcon" /> IBC Transfer
</b-dropdown-item>
@ -268,6 +268,7 @@
<operation-modal
:type="operationModalType"
:address="selectedAddress"
:selected-chain-name="selectedChainName"
/>
</div>
</template>
@ -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()

View File

@ -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)

View File

@ -140,6 +140,7 @@
<TransactionResult
v-else
:hash="txHash"
:selected-chain="selectedChain"
/>
</b-overlay>
</b-modal>
@ -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'))