fix decimal

This commit is contained in:
Pham Tu 2024-01-17 18:47:35 +07:00
parent 7f4acfabe6
commit e382913c19
No known key found for this signature in database
GPG Key ID: 7460FD99133ADA1C
2 changed files with 4 additions and 5 deletions

View File

@ -51,10 +51,6 @@ const typeMap = Object.fromEntries(
Object.entries(MsgType).map(([k, v]) => ['/' + v, k])
);
Object.assign(typeMap, {
'/cosmos.params.v1beta1.ParameterChangeProposal': 'ParameterChangeProposal',
});
const findType = (obj: any, type: string): any => {
if (typeof obj !== 'object') return;
const msg = obj[type];
@ -66,9 +62,10 @@ const findType = (obj: any, type: string): any => {
};
export const decodeProto = (msg: { typeUrl: string; value: Uint8Array }) => {
const type = typeMap[msg.typeUrl];
const type = typeMap[msg.typeUrl] ?? msg.typeUrl.split('.').pop();
if (type) {
const obj = findType(injProto, type);
if (obj) {
const res = obj.decode(msg.value);
if (res.msgs) {

View File

@ -53,6 +53,8 @@ store.fetchProposal(props.proposal_id).then((res) => {
proposalDetail.content!
) as ParameterChangeProposal;
Object.assign(proposalDetail.content!, changeProposal);
// @ts-ignore
delete proposalDetail.content.value;
// when status under the voting, final_tally_result are no data, should request fetchTally
if (proposalDetail.status === ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD) {
// 'PROPOSAL_STATUS_VOTING_PERIOD') {