From 21ff37aac182966a4e573e03355a2085049e31ba Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 28 Oct 2023 08:21:02 +0800 Subject: [PATCH] load origin value for param change proposal --- src/libs/api.ts | 1 + src/libs/client.ts | 4 ++++ src/libs/registry.ts | 2 ++ src/modules/[chain]/gov/[proposal_id].vue | 16 ++++++++++++++++ src/types/gov.ts | 2 ++ 5 files changed, 25 insertions(+) diff --git a/src/libs/api.ts b/src/libs/api.ts index 376b841b..bd951765 100644 --- a/src/libs/api.ts +++ b/src/libs/api.ts @@ -10,6 +10,7 @@ export const DEFAULT: RequestRegistry = { url: '/cosmos/auth/v1beta1/accounts/{address}', adapter, }, + params: { url: '/cosmos/params/v1beta1/params?subspace={subspace}&key={key}', adapter }, bank_params: { url: '/cosmos/bank/v1beta1/params', adapter }, bank_balances_address: { url: '/cosmos/bank/v1beta1/balances/{address}', diff --git a/src/libs/client.ts b/src/libs/client.ts index 38fc39b8..24ef7544 100644 --- a/src/libs/client.ts +++ b/src/libs/client.ts @@ -133,6 +133,10 @@ export class CosmosRestClient extends BaseRestClient { return this.request(this.registry.slashing_signing_info, {}, query); } // Gov + async getParams(subspace: string, key: string) { + console.log(this.registry.params, subspace, key) + return this.request(this.registry.params, {subspace, key}); + } async getGovParamsVoting() { return this.request(this.registry.gov_params_voting, {}); } diff --git a/src/libs/registry.ts b/src/libs/registry.ts index ce423071..1378ad27 100644 --- a/src/libs/registry.ts +++ b/src/libs/registry.ts @@ -124,6 +124,8 @@ export interface RequestRegistry extends AbstractRegistry { base_tendermint_validatorsets_latest: Request; base_tendermint_validatorsets_height: Request; + params: Request<{param: any}>; + tx_txs: Request; tx_txs_block: Request; tx_hash: Request<{ tx: Tx; tx_response: TxResponse }>; diff --git a/src/modules/[chain]/gov/[proposal_id].vue b/src/modules/[chain]/gov/[proposal_id].vue index 1eaf5cd7..c8371869 100644 --- a/src/modules/[chain]/gov/[proposal_id].vue +++ b/src/modules/[chain]/gov/[proposal_id].vue @@ -4,6 +4,7 @@ import MdEditor from 'md-editor-v3'; import ObjectElement from '@/components/dynamic/ObjectElement.vue'; import { useBaseStore, + useBlockchain, useFormatter, useGovStore, useStakingStore, @@ -28,6 +29,7 @@ const format = useFormatter(); const store = useGovStore(); const dialog = useTxDialog(); const stakingStore = useStakingStore(); +const chainStore = useBlockchain(); store.fetchProposal(props.proposal_id).then((res) => { const proposalDetail = reactive(res.proposal); @@ -38,6 +40,20 @@ store.fetchProposal(props.proposal_id).then((res) => { }); } proposal.value = proposalDetail; + // load origin params if the proposal is param change + if(proposalDetail.content?.changes) { + proposalDetail.content?.changes.forEach((item) => { + chainStore.rpc.getParams(item.subspace, item.key).then((res) => { + if(proposal.value.content && res.param) { + if(proposal.value.content.origin){ + proposal.value.content.origin.push(res.param); + } else { + proposal.value.content.origin = [res.param]; + }; + } + }) + }) + } }); const color = computed(() => { diff --git a/src/types/gov.ts b/src/types/gov.ts index 02c9d6ef..af84e43a 100644 --- a/src/types/gov.ts +++ b/src/types/gov.ts @@ -28,6 +28,8 @@ export interface GovProposal { '@type': string; title?: string; description?: string; + origin?: any[] + changes?: any[]; plan?: { height?: string | number; time?: string | number;