Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Erialos 2022-10-08 11:39:11 -06:00
commit b88cce7b5a
4 changed files with 36 additions and 24 deletions

View File

@ -23,10 +23,6 @@ export default class Proposal {
this.id = element.proposal_id || element.id this.id = element.proposal_id || element.id
this.status = element.status this.status = element.status
this.type = element.content.type
if (element.content['@type']) {
this.type = element.content['@type']
}
this.tally = new ProposalTally().init(element.final_tally_result, total) this.tally = new ProposalTally().init(element.final_tally_result, total)
this.submit_time = element.submit_time this.submit_time = element.submit_time
this.voting_end_time = element.voting_end_time this.voting_end_time = element.voting_end_time
@ -37,6 +33,10 @@ export default class Proposal {
if (this.contents) { if (this.contents) {
this.title = this.contents.title this.title = this.contents.title
this.description = this.contents.description this.description = this.contents.description
this.type = element.content.type
if (element.content['@type']) {
this.type = element.content['@type']
}
} }
return this return this
} }

View File

@ -1,6 +1,16 @@
<template> <template>
<div> <div>
<b-card title="Block Id"> <b-card>
<b-card-title class="d-flex justify-content-between">
<span>#{{ height }}</span>
<span><b-button
size="sm"
@click="goblock(height-1)"
> &lt; </b-button> <b-button
size="sm"
@click="goblock(Number(height)+1)"
> > </b-button></span>
</b-card-title>
<object-field-component :tablefield="block.block_id" /> <object-field-component :tablefield="block.block_id" />
</b-card> </b-card>
@ -42,7 +52,9 @@
</template> </template>
<script> <script>
import { BCard, BTable } from 'bootstrap-vue' import {
BCard, BTable, BCardTitle, BButton,
} from 'bootstrap-vue'
import { fromBase64 } from '@cosmjs/encoding' import { fromBase64 } from '@cosmjs/encoding'
import { decodeTxRaw } from '@cosmjs/proto-signing' import { decodeTxRaw } from '@cosmjs/proto-signing'
import Tx from '@/libs/data/tx' import Tx from '@/libs/data/tx'
@ -52,8 +64,10 @@ import ArrayFieldComponent from './components/ArrayFieldComponent.vue'
export default { export default {
components: { components: {
BButton,
BCard, BCard,
BTable, BTable,
BCardTitle,
ObjectFieldComponent, ObjectFieldComponent,
ArrayFieldComponent, ArrayFieldComponent,
}, },
@ -68,6 +82,7 @@ export default {
return { return {
block: { block: { header: {}, data: {}, evidence: {} } }, block: { block: { header: {}, data: {}, evidence: {} } },
txs: null, txs: null,
height: 0,
fields: [ fields: [
{ key: 'hash' }, { key: 'hash' },
{ key: 'fee', formatter: v => tokenFormatter(v) }, { key: 'fee', formatter: v => tokenFormatter(v) },
@ -82,6 +97,7 @@ export default {
}, },
methods: { methods: {
initData(height) { initData(height) {
this.height = height
this.$http.getBlockByHeight(height).then(res => { this.$http.getBlockByHeight(height).then(res => {
this.block = res this.block = res
const { txs } = res.block.data const { txs } = res.block.data
@ -101,6 +117,9 @@ export default {
if (array.length > 0) this.txs = array if (array.length > 0) this.txs = array
}) })
}, },
goblock(height) {
this.$router.push({ name: 'block', params: { height } })
},
}, },
} }
</script> </script>

View File

@ -49,14 +49,7 @@
> >
<tbody> <tbody>
<b-tr> <b-tr>
<b-td <b-td style="text-transform: capitalize; vertical-align: top; width:200px">
style="text-transform: capitalize; vertical-align: top; width:200px"
>
{{ $t('proposal_id') }}
</b-td><b-td>{{ proposal.id }}</b-td>
</b-tr>
<b-tr>
<b-td>
{{ $t('proposal_proposer') }} {{ $t('proposal_proposer') }}
</b-td><b-td><router-link :to="`../account/${proposer.proposer}`"> </b-td><b-td><router-link :to="`../account/${proposer.proposer}`">
{{ formatAddress(proposer.proposer) }} {{ formatAddress(proposer.proposer) }}

View File

@ -15,7 +15,7 @@
<b-td <b-td
style="text-transform: capitalize; vertical-align: top;" style="text-transform: capitalize; vertical-align: top;"
> >
{{ name }} {{ formatTitle(name) }}
</b-td> </b-td>
<b-td v-if="isTokenField(value)"> <b-td v-if="isTokenField(value)">
{{ formatTokens( value ) }} {{ formatTokens( value ) }}
@ -37,13 +37,12 @@
<b-tabs <b-tabs
v-if="value" v-if="value"
small small
class="overflow-hidden"
> >
<b-tab <b-tab
v-for="key in Object.keys(value)" v-for="key in Object.keys(value)"
:key="key" :key="key"
:title="key" :title="formatTitle(key)"
class="p-0 overflow-hidden" class="p-0 text-capitalize"
title-item-class="bg-light-primary" title-item-class="bg-light-primary"
> >
<array-field-component <array-field-component
@ -60,7 +59,7 @@
/> />
<div <div
v-else v-else
style="max-width: 800px; overflow: auto;" style="max-width: 800px; max-height: 300px; overflow: auto;"
>{{ value[key] }}</div> >{{ value[key] }}</div>
</b-tab> </b-tab>
</b-tabs> </b-tabs>
@ -71,7 +70,7 @@
</VueMarkdown> </VueMarkdown>
<div <div
v-else v-else
style="max-width: 800px; word-wrap:normal" style="max-width: 800px; max-height: 300px; overflow: auto;"
>{{ value }}</div> >{{ value }}</div>
</b-td> </b-td>
</b-tr> </b-tr>
@ -135,6 +134,7 @@ export default {
// } // }
return value return value
}, },
formatTitle: v => v.replaceAll('_', ' '),
isObjectText(v) { isObjectText(v) {
return String(v).startsWith('{') && String(v).endsWith('}') return String(v).startsWith('{') && String(v).endsWith('}')
}, },
@ -146,16 +146,16 @@ export default {
return Array.from(value) return Array.from(value)
}, },
isTokenField(value) { isTokenField(value) {
return isToken(value) return value ? isToken(value) : false
}, },
isHex(value) { isHex(value) {
return isHexAddress(value) return value ? isHexAddress(value) : false
}, },
formatHexAddress(v) { formatHexAddress(v) {
return getStakingValidatorByHex(this.$http.config.chain_name, v) return getStakingValidatorByHex(this.$http.config.chain_name, v)
}, },
isArrayText(value) { isArrayText(value) {
return isStringArray(value) return value ? isStringArray(value) : false
}, },
formatTokens(value) { formatTokens(value) {
return tokenFormatter(value) return tokenFormatter(value)
@ -165,7 +165,7 @@ export default {
if (percentage.test(value)) { if (percentage.test(value)) {
return `${percent(value)}%` return `${percent(value)}%`
} }
return value.replace(/(?:\\[rn])+/g, '\n') return value ? value.replace(/(?:\\[rn])+/g, '\n') : '-'
}, },
}, },
} }