From d2945a572c6258c14c31fbbc43d2d8269f93cf5b Mon Sep 17 00:00:00 2001 From: "Alex M. - Clockwork" Date: Tue, 10 Dec 2024 14:25:07 +0200 Subject: [PATCH] fix: Correct prop loading (See #9221) --- .../controllers/chain/cosmos/gov/utils.ts | 47 ++++++++++++++----- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/packages/commonwealth/client/scripts/controllers/chain/cosmos/gov/utils.ts b/packages/commonwealth/client/scripts/controllers/chain/cosmos/gov/utils.ts index c3bc5c49342..1887351dac3 100644 --- a/packages/commonwealth/client/scripts/controllers/chain/cosmos/gov/utils.ts +++ b/packages/commonwealth/client/scripts/controllers/chain/cosmos/gov/utils.ts @@ -1,8 +1,12 @@ import { CosmosGovernanceVersion } from '@hicommonwealth/shared'; +import { AtomOneLCD, LCD } from 'shared/chain/types/cosmos'; import Cosmos from '../adapter'; import CosmosGovernanceV1AtomOne from './atomone/governance-v1'; import { CosmosProposalV1AtomOne } from './atomone/proposal-v1'; -import { getCompletedProposalsV1AtomOne } from './atomone/utils-v1'; +import { + getActiveProposalsV1AtomOne, + getCompletedProposalsV1AtomOne, +} from './atomone/utils-v1'; import CosmosGovernanceGovgen from './govgen/governance-v1beta1'; import { CosmosProposalGovgen } from './govgen/proposal-v1beta1'; import { @@ -28,19 +32,22 @@ export const getCompletedProposals = async ( const { chain, accounts, governance, meta } = cosmosChain; console.log(cosmosChain); const isAtomone = - meta.ChainNode?.cosmos_gov_version === CosmosGovernanceVersion.v1atomone; + meta.ChainNode?.cosmosGovernanceVersion === + CosmosGovernanceVersion.v1atomone; const isGovgen = - meta.ChainNode?.cosmos_gov_version === + meta.ChainNode?.cosmosGovernanceVersion === CosmosGovernanceVersion.v1beta1govgen; const isV1 = - meta.ChainNode?.cosmos_gov_version === CosmosGovernanceVersion.v1; + meta.ChainNode?.cosmosGovernanceVersion === CosmosGovernanceVersion.v1; const betaAttemptFailed = - meta.ChainNode?.cosmos_gov_version === + meta.ChainNode?.cosmosGovernanceVersion === CosmosGovernanceVersion.v1beta1Failed; let cosmosProposals = []; if (isAtomone) { - const v1proposals = await getCompletedProposalsV1AtomOne(chain.api); + const v1proposals = await getCompletedProposalsV1AtomOne( + chain.lcd as AtomOneLCD, + ); // @ts-expect-error StrictNullChecks cosmosProposals = v1proposals.map( (p) => @@ -64,7 +71,7 @@ export const getCompletedProposals = async ( ), ); } else if (!isGovgen && (isV1 || betaAttemptFailed)) { - const v1Proposals = await getCompletedProposalsV1(chain.lcd); + const v1Proposals = await getCompletedProposalsV1(chain.lcd as LCD); // @ts-expect-error StrictNullChecks cosmosProposals = v1Proposals.map( @@ -95,17 +102,33 @@ export const getActiveProposals = async ( cosmosChain: Cosmos, ): Promise => { const { chain, accounts, governance, meta } = cosmosChain; + const isAtomone = + meta.ChainNode?.cosmosGovernanceVersion === + CosmosGovernanceVersion.v1atomone; const isGovgen = - meta.ChainNode?.cosmos_gov_version === + meta.ChainNode?.cosmosGovernanceVersion === CosmosGovernanceVersion.v1beta1govgen; const isV1 = - meta.ChainNode?.cosmos_gov_version === CosmosGovernanceVersion.v1; + meta.ChainNode?.cosmosGovernanceVersion === CosmosGovernanceVersion.v1; const betaAttemptFailed = - meta.ChainNode?.cosmos_gov_version === + meta.ChainNode?.cosmosGovernanceVersion === CosmosGovernanceVersion.v1beta1Failed; let cosmosProposals = []; - - if (isGovgen) { + if (isAtomone) { + const v1Proposals = await getActiveProposalsV1AtomOne( + chain.lcd as AtomOneLCD, + ); + // @ts-expect-error StrictNullChecks + cosmosProposals = v1Proposals.map( + (p) => + new CosmosProposalV1AtomOne( + chain, + accounts, + governance as CosmosGovernanceV1AtomOne, + p, + ), + ); + } else if (isGovgen) { const v1Beta1Proposals = await getActiveProposalsGovgen(chain.api); // @ts-expect-error StrictNullChecks cosmosProposals = v1Beta1Proposals.map(