estimate with custom block time

This commit is contained in:
liangping 2022-11-25 18:54:07 +08:00
parent 072efbb5a6
commit c337a4519e
2 changed files with 28 additions and 3 deletions

View File

@ -34,6 +34,10 @@ export default class Proposal {
if (this.contents) {
this.title = this.contents.title
this.description = this.contents.description
this.type = element.content.type
if (element.content['@type']) {
this.type = element.content['@type']
}
}
this.metadata = element.metadata
return this
@ -50,6 +54,7 @@ export default class Proposal {
versionFixed(ver) {
if (compareVersions(ver, '0.46') >= 0) {
[this.contents] = this.element.messages
if (this.contents) this.type = this.contents['@type']
if (this.contents['@type'] === '/cosmos.gov.v1.MsgExecLegacyContent') {
this.title = this.contents.content.title
this.description = this.contents.content.description

View File

@ -68,7 +68,7 @@
{{ $t('voting_time') }}
</b-td><b-td>{{ formatDate(proposal.voting_start_time) }} - {{ formatDate(proposal.voting_end_time) }}</b-td>
</b-tr>
<b-tr>
<b-tr v-if="proposal.metadata">
<b-td>
Metadata
</b-td><b-td>{{ proposal.metadata }}</b-td>
@ -80,6 +80,21 @@
<b-td class="text-center">
{{ $t('upgrade_time') }} {{ upgradeTime }}
<flip-countdown :deadline="upgradeTime" />
<b-input-group prepend="Estimated by block time: ">
<b-form-select v-model="blocktime">
<b-form-select-option value="7">
7s
</b-form-select-option>
<b-form-select-option value="6">
6s
</b-form-select-option>
<b-form-select-option value="2">
2s
</b-form-select-option>
<b-form-select-option value="1">
1s
</b-form-select-option>
</b-form-select></b-input-group>
</b-td>
</b-tr>
</b-table-simple>
@ -263,7 +278,7 @@
<script>
import {
BCard, BCardBody, BCardFooter, BButton, BTable, BTableSimple, BTr, BTd, BCardTitle, BCardHeader,
BProgressBar, BProgress, BTooltip, BBadge,
BProgressBar, BProgress, BTooltip, BBadge, BFormSelect, BFormSelectOption, BInputGroup, BInputGroupPrepend,
} from 'bootstrap-vue'
import FlipCountdown from 'vue2-flip-countdown'
// import fetch from 'node-fetch'
@ -294,12 +309,17 @@ export default {
BProgress,
BTooltip,
BBadge,
BFormSelect,
BFormSelectOption,
BInputGroup,
BInputGroupPrepend,
ObjectFieldComponent,
FlipCountdown,
OperationModal,
},
data() {
return {
blocktime: 6,
tallyParam: null,
latest: {},
next: null,
@ -358,7 +378,7 @@ export default {
if (Number(this.proposal?.contents.plan.height || 0) > 0 && this.latest?.block) {
const blocks = Number(this.proposal.contents.plan.height) - Number(this.latest.block?.header?.height || 0)
if (blocks > 0) {
const endtime = dayjs().add(blocks * 6, 'second').format('YYYY-MM-DD HH:mm:ss')
const endtime = dayjs().add(blocks * this.blocktime, 'second').format('YYYY-MM-DD HH:mm:ss')
return endtime
}
}