@@ -167,6 +174,25 @@ const VerifiedIconWithTooltip = () => {
)
}
+const VotedIconWithTooltip = () => {
+ return (
+
+
+
+
+
+
+
+
+ You have voted on this proposal.
+
+
+
+
+
+ )
+}
+
const ParsedAccountPubkeyRow = ({
mapping,
title,
@@ -187,7 +213,7 @@ const ParsedAccountPubkeyRow = ({
}
const getProposalStatus = (
- proposal: TransactionAccount | undefined,
+ proposal: TransactionAccount | ClientProposal | undefined,
multisig: MultisigAccount | undefined
): string => {
if (multisig && proposal) {
@@ -1054,6 +1080,8 @@ const Proposal = ({
)
}
+type ClientProposal = TransactionAccount & { verified: boolean; voted: boolean }
+
const Proposals = ({
publisherKeyToNameMapping,
multisigSignerKeyToNameMapping,
@@ -1062,11 +1090,13 @@ const Proposals = ({
multisigSignerKeyToNameMapping: Record
}) => {
const router = useRouter()
+ const { connected, publicKey: signerPublicKey } = useWallet()
const [currentProposal, setCurrentProposal] = useState()
const [currentProposalIndex, setCurrentProposalIndex] = useState()
const [allProposalsVerifiedArr, setAllProposalsVerifiedArr] = useState<
boolean[]
>([])
+ const [proposalsVotedArr, setProposalsVotedArr] = useState([])
const [currentProposalPubkey, setCurrentProposalPubkey] = useState()
const { cluster } = useContext(ClusterContext)
const { statusFilter } = useContext(StatusFilterContext)
@@ -1076,9 +1106,9 @@ const Proposals = ({
allProposalsIxsParsed,
isLoading: isMultisigLoading,
} = useMultisigContext()
- const [filteredProposals, setFilteredProposals] = useState<
- TransactionAccount[]
- >(priceFeedMultisigProposals)
+ const [filteredProposals, setFilteredProposals] = useState(
+ []
+ )
useEffect(() => {
if (!isMultisigLoading) {
@@ -1160,19 +1190,59 @@ const Proposals = ({
])
useEffect(() => {
+ const allClientProposals = priceFeedMultisigProposals.map(
+ (proposal, idx) => ({
+ ...proposal,
+ verified: allProposalsVerifiedArr[idx],
+ voted: proposalsVotedArr[idx],
+ })
+ )
// filter price feed multisig proposals by status
if (statusFilter === 'all') {
- setFilteredProposals(priceFeedMultisigProposals)
+ // pass priceFeedMultisigProposals and add verified and voted props
+ setFilteredProposals(allClientProposals)
} else {
setFilteredProposals(
- priceFeedMultisigProposals.filter(
+ allClientProposals.filter(
(proposal) =>
getProposalStatus(proposal, priceFeedMultisigAccount) ===
statusFilter
)
)
}
- }, [statusFilter, priceFeedMultisigAccount, priceFeedMultisigProposals])
+ }, [
+ statusFilter,
+ priceFeedMultisigAccount,
+ priceFeedMultisigProposals,
+ allProposalsVerifiedArr,
+ proposalsVotedArr,
+ ])
+
+ useEffect(() => {
+ if (priceFeedMultisigAccount && connected && signerPublicKey) {
+ const res: boolean[] = []
+ priceFeedMultisigProposals.map((proposal) => {
+ // check if proposal.approved, proposal.cancelled, proposal.rejected has wallet pubkey and return true if anyone of them has wallet pubkey
+ const isProposalVoted =
+ proposal.approved.some(
+ (p) => p.toBase58() === signerPublicKey.toBase58()
+ ) ||
+ proposal.cancelled.some(
+ (p) => p.toBase58() === signerPublicKey.toBase58()
+ ) ||
+ proposal.rejected.some(
+ (p) => p.toBase58() === signerPublicKey.toBase58()
+ )
+ res.push(isProposalVoted)
+ })
+ setProposalsVotedArr(res)
+ }
+ }, [
+ priceFeedMultisigAccount,
+ priceFeedMultisigProposals,
+ connected,
+ signerPublicKey,
+ ])
return (
@@ -1210,7 +1280,8 @@ const Proposals = ({
diff --git a/governance/xc_admin/packages/xc_admin_frontend/images/icons/voted.inline.svg b/governance/xc_admin/packages/xc_admin_frontend/images/icons/voted.inline.svg
new file mode 100644
index 00000000..780c62c1
--- /dev/null
+++ b/governance/xc_admin/packages/xc_admin_frontend/images/icons/voted.inline.svg
@@ -0,0 +1,23 @@
+