refactor version compatible support

This commit is contained in:
liangping
2024-09-01 15:04:33 +08:00
parent 00cb9e5f42
commit 0960ad6596
10 changed files with 113 additions and 27 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
import { BaseRestClient } from '@/libs/client';
import { adapter, type AbstractRegistry, type Request } from '@/libs/registry';
import { adapter, type AbstractRegistry, type Request } from '@/libs/api/registry';
import { defineStore } from 'pinia';
import type {
CodeInfo,
+8 -3
View File
@@ -32,7 +32,7 @@ const stakingStore = useStakingStore();
const chainStore = useBlockchain();
store.fetchProposal(props.proposal_id).then((res) => {
const proposalDetail = reactive(res.proposal);
let proposalDetail = reactive(res.proposal);
// when status under the voting, final_tally_result are no data, should request fetchTally
if (res.proposal?.status === 'PROPOSAL_STATUS_VOTING_PERIOD') {
store.fetchTally(props.proposal_id).then((tallRes) => {
@@ -55,7 +55,7 @@ store.fetchProposal(props.proposal_id).then((res) => {
})
}
const msgType = proposalDetail.content['@type'] || '';
const msgType = proposalDetail.content?.['@type'] || '';
if(msgType.endsWith('MsgUpdateParams')) {
if(msgType.indexOf('staking') > -1) {
chainStore.rpc.getStakingParams().then((res) => {
@@ -214,7 +214,12 @@ function pageload(p: number) {
}
function metaItem(metadata: string|undefined): { title: string; summary: string } {
return metadata ? JSON.parse(metadata) : {}
if (!metadata) {
return { title: '', summary: '' }
} else if (metadata.startsWith('{') && metadata.endsWith('}')) {
return JSON.parse(metadata)
}
return { title: metadata, summary: '' }
}
</script>