From 7cbdd583bc564a9ab410208d9849a51d67f0672d Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Mon, 25 Nov 2024 09:51:04 -0800 Subject: [PATCH] fixed DAOs with cross-chain SubDAOs not loading all members --- .../formulas/contract/daoCore/members.ts | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/formulas/formulas/contract/daoCore/members.ts b/src/formulas/formulas/contract/daoCore/members.ts index 66e9e7c..e360db5 100644 --- a/src/formulas/formulas/contract/daoCore/members.ts +++ b/src/formulas/formulas/contract/daoCore/members.ts @@ -1,5 +1,6 @@ import { ContractFormula } from '@/types' +import { info } from '../common' import { listMembers as listCw4Members, totalWeight as totalCw4Weight, @@ -12,7 +13,7 @@ import { topStakers as topOnftStakers } from '../voting/daoVotingOnftStaked' import { allVotersWithVotingPower as sgCommunityAllVoters } from '../voting/daoVotingSgCommunityNft' import { topStakers as topTokenStakers } from '../voting/daoVotingTokenStaked' import { config, votingModule } from './base' -import { getUniqueSubDaosInTree } from './utils' +import { DAO_CORE_CONTRACT_NAMES, getUniqueSubDaosInTree } from './utils' export type DaoMember = { address: string @@ -99,11 +100,34 @@ export const allMembers: ContractFormula< > = {} for (const dao of daos) { + // Get info. + const daoInfo = await info + .compute({ + ...env, + contractAddress: dao, + }) + .catch(() => null) + + // If invalid DAO, skip. + if ( + !daoInfo || + !DAO_CORE_CONTRACT_NAMES.some((name) => daoInfo.contract.includes(name)) + ) { + continue + } + // Get config. - const daoConfig = await config.compute({ - ...env, - contractAddress: dao, - }) + const daoConfig = await config + .compute({ + ...env, + contractAddress: dao, + }) + .catch(() => null) + + // If can't load DAO config, skip. + if (!daoConfig) { + continue + } // Get members. const members = await listMembers.compute({