Skip to content

Commit

Permalink
made daos/memberOf resilient to fake DAOs
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Oct 30, 2024
1 parent 915cfe1 commit 06790e0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/formulas/formulas/account/daos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,18 @@ export const memberOf: AccountFormula<
)

const daos = Array.from(new Set([...daoAddresses, ...cw4DaoAddresses]))
const daoStates = await Promise.all(
daos.map((daoAddress) =>
Promise.all([
info.compute({ ...env, contractAddress: daoAddress }),
config.compute({ ...env, contractAddress: daoAddress }),
votingModule.compute({ ...env, contractAddress: daoAddress }),
proposalCount.compute({ ...env, contractAddress: daoAddress }),
])
const daoStates = (
await Promise.allSettled(
daos.map((daoAddress) =>
Promise.all([
info.compute({ ...env, contractAddress: daoAddress }),
config.compute({ ...env, contractAddress: daoAddress }),
votingModule.compute({ ...env, contractAddress: daoAddress }),
proposalCount.compute({ ...env, contractAddress: daoAddress }),
])
)
)
)
).flatMap((r) => (r.status === 'fulfilled' ? [r.value] : []))

return daoStates.flatMap(
([info, config, votingModule, proposalCount], index) =>
Expand Down

0 comments on commit 06790e0

Please sign in to comment.