Skip to content

Commit

Permalink
fix: Correct prop loading (See hicommonwealth#9221)
Browse files Browse the repository at this point in the history
  • Loading branch information
clockworkgr committed Dec 10, 2024
1 parent 352a311 commit d2945a5
Showing 1 changed file with 35 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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) =>
Expand All @@ -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(
Expand Down Expand Up @@ -95,17 +102,33 @@ export const getActiveProposals = async (
cosmosChain: Cosmos,
): Promise<CosmosProposal[]> => {
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(
Expand Down

0 comments on commit d2945a5

Please sign in to comment.