diff --git a/components/ProposalStateBadge.tsx b/components/ProposalStateBadge.tsx index 69f7d4a829..c310e677cf 100644 --- a/components/ProposalStateBadge.tsx +++ b/components/ProposalStateBadge.tsx @@ -1,4 +1,8 @@ -import { Proposal, ProposalState } from '@solana/spl-governance' +import { + Proposal, + ProposalState, + getNativeTreasuryAddress, +} from '@solana/spl-governance' import classNames from 'classnames' import assertUnreachable from '@utils/typescript/assertUnreachable' @@ -8,6 +12,8 @@ import { useUserCouncilTokenOwnerRecord, } from '@hooks/queries/tokenOwnerRecord' import { useGovernanceByPubkeyQuery } from '@hooks/queries/governance' +import { useSelectedProposalTransactions } from '@hooks/queries/proposalTransaction' +import { useAsync } from 'react-async-hook' export const hasInstructions = (proposal: Proposal) => { if (proposal.instructionsCount) { @@ -172,6 +178,25 @@ export default function ProposalStateBadge(props: Props) { const coolOff = isInCoolOffTime(props.proposal, governance?.account) + const { data: allTransactions } = useSelectedProposalTransactions() + const treasuryAddress = useAsync( + async () => + governance !== undefined + ? getNativeTreasuryAddress(governance.owner, governance.pubkey) + : undefined, + [governance] + ) + const walletsPassedToInstructions = allTransactions?.flatMap((tx) => + tx.account.instructions.flatMap((ins) => + ins.accounts.map((acc) => acc.pubkey) + ) + ) + const possibleWrongGovernance = + allTransactions?.length && + !walletsPassedToInstructions?.find( + (x) => treasuryAddress.result && x.equals(treasuryAddress.result) + ) + const otherState = { isCreator, isSignatory, @@ -181,23 +206,45 @@ export default function ProposalStateBadge(props: Props) { } return ( -