done save IBCDenoms to store

This commit is contained in:
donne1226
2022-04-05 23:31:06 +08:00
parent ccc4811fa5
commit 01408d2607
10 changed files with 52 additions and 62 deletions
+4 -10
View File
@@ -97,8 +97,6 @@
import {
BCard, BCardHeader, BCardTitle, BCardBody, BMediaBody, BMedia, BMediaAside, BAvatar, BButton,
} from 'bootstrap-vue'
import { sha256 } from '@cosmjs/crypto'
import { toHex } from '@cosmjs/encoding'
import { formatToken, numberWithCommas } from '@/libs/utils'
import OperationModal from '@/views/components/OperationModal/index.vue'
@@ -131,16 +129,12 @@ export default {
},
data() {
return {
denoms: {},
}
},
created() {
this.$http.getAllIBCDenoms().then(x => {
x.denom_traces.forEach(trace => {
const hash = toHex(sha256(new TextEncoder().encode(`${trace.path}/${trace.base_denom}`)))
this.$set(this.denoms, `ibc/${hash.toUpperCase()}`, trace.base_denom)
})
})
computed: {
denoms() {
return this.$store.state.chains.denoms
},
},
methods: {
formatNumber(value) {
+5 -9
View File
@@ -15,8 +15,6 @@
</template>
<script>
import { sha256 } from '@cosmjs/crypto'
import { toHex } from '@cosmjs/encoding'
import { BTable, BCardTitle, BCard } from 'bootstrap-vue'
import { formatTokenAmount, formatTokenDenom } from '@/libs/utils'
@@ -30,7 +28,6 @@ export default {
return {
islive: true,
assets: [],
denoms: {},
cfield: [
{
key: 'denom',
@@ -44,13 +41,12 @@ export default {
],
}
},
computed: {
denoms() {
return this.$store.state.chains.denoms
},
},
created() {
this.$http.getAllIBCDenoms().then(x => {
x.denom_traces.forEach(trace => {
const hash = toHex(sha256(new TextEncoder().encode(`${trace.path}/${trace.base_denom}`)))
this.$set(this.denoms, `ibc/${hash.toUpperCase()}`, trace)
})
})
this.$http.getBankTotals().then(res => {
const toshow = res.sort()
this.assets = toshow.reverse().map(x => {
+3 -9
View File
@@ -402,8 +402,6 @@ import {
formatToken, formatTokenAmount, formatTokenDenom, getStakingValidatorOperator, percent, tokenFormatter, toDay,
toDuration, abbrMessage, abbrAddress, getUserCurrency, getUserCurrencySign, numberWithCommas,
} from '@/libs/utils'
import { sha256 } from '@cosmjs/crypto'
import { toHex } from '@cosmjs/encoding'
import OperationModal from '@/views/components/OperationModal/index.vue'
import ObjectFieldComponent from './ObjectFieldComponent.vue'
import ChartComponentDoughnut from './ChartComponentDoughnut.vue'
@@ -448,7 +446,6 @@ export default {
address,
account: null,
assets: [],
denoms: {},
reward: [],
delegations: [],
redelegations: [],
@@ -600,14 +597,11 @@ export default {
}
return table
},
denoms() {
return this.$store.state.chains.denoms
},
},
created() {
this.$http.getAllIBCDenoms().then(x => {
x.denom_traces.forEach(trace => {
const hash = toHex(sha256(new TextEncoder().encode(`${trace.path}/${trace.base_denom}`)))
this.$set(this.denoms, `ibc/${hash.toUpperCase()}`, trace.base_denom)
})
})
this.$http.getAuthAccount(this.address).then(acc => {
this.account = acc
})
@@ -155,8 +155,6 @@ export default {
token: '',
amount: null,
selectedChain: '',
IBCDenom: {},
required,
password,
email,
@@ -201,6 +199,9 @@ export default {
},
}]
},
IBCDenom() {
return this.$store.state.chains.denoms
},
},
mounted() {
this.$emit('update', {
@@ -143,8 +143,6 @@ import {
import vSelect from 'vue-select'
import { coin } from '@cosmjs/amino'
import dayjs from 'dayjs'
import { toHex } from '@cosmjs/encoding'
import { sha256 } from '@cosmjs/crypto'
export default {
name: 'TransforDialogue',
@@ -177,8 +175,6 @@ export default {
token: '',
amount: null,
recipient: null,
IBCDenom: {},
paths: {},
destination: {},
channels: [],
@@ -228,6 +224,12 @@ export default {
selectedChain() {
return this.$store.state.chains.selected
},
IBCDenom() {
return this.$store.state.chains.denoms
},
paths() {
return this.$store.state.chains.ibcPaths
},
},
mounted() {
this.$emit('update', {
@@ -244,23 +246,6 @@ export default {
this.token = ''
this.targetChainId = ''
if (this.address) {
this.$http.getAllIBCDenoms(this.selectedChain).then(x => {
x.denom_traces.forEach(trace => {
const hash = toHex(sha256(new TextEncoder().encode(`${trace.path}/${trace.base_denom}`)))
const ibcDenom = `ibc/${hash.toUpperCase()}`
// add base_denom to cache
this.$set(this.IBCDenom, ibcDenom, trace.base_denom)
// store channel/part for ibc denoms
const path = trace.path.split('/')
if (path.length >= 2) {
this.paths[ibcDenom] = {
channel_id: path[path.length - 1],
port_id: path[path.length - 2],
}
}
})
})
this.$http.getIBCChannels(this.selectedChain, null).then(ret => {
const chans = ret.channels.filter(x => x.state === 'STATE_OPEN').map(x => ({ channel_id: x.channel_id, port_id: x.port_id }))
this.$set(this, 'channels', chans)
@@ -139,8 +139,6 @@ export default {
token: '',
amount: null,
recipient: '',
IBCDenom: {},
required,
password,
email,
@@ -175,6 +173,9 @@ export default {
balanceOptions() {
return this.setupBalance()
},
IBCDenom() {
return this.$store.state.chains.denoms
},
},
mounted() {
this.$emit('update', {