From 5d46bf23a7e3447eedbfbcfb49f937abc35d4366 Mon Sep 17 00:00:00 2001 From: Pavan Soratur Date: Thu, 17 Aug 2023 00:37:18 -0700 Subject: [PATCH 1/2] chore: adds proposal detail page --- .../ProposalDetail/ProposalDetail.tsx | 333 +++++++++++++++- .../ProposalsTable/ProposalsTable.tsx | 27 +- apps/stats-dapp/src/gql/proposals.graphql | 1 + .../src/pages/ProposalDetailDrawer.tsx | 2 +- apps/stats-dapp/src/pages/Proposals.tsx | 3 + .../src/provider/hooks/useProposals.ts | 7 + apps/stats-dapp/src/routes/index.tsx | 4 +- apps/stats-dapp/src/utils/getProposalsData.ts | 377 +++++++++--------- apps/stats-dapp/src/utils/index.ts | 2 +- 9 files changed, 544 insertions(+), 212 deletions(-) diff --git a/apps/stats-dapp/src/containers/ProposalDetail/ProposalDetail.tsx b/apps/stats-dapp/src/containers/ProposalDetail/ProposalDetail.tsx index 9c516300ab..050f0e15f1 100644 --- a/apps/stats-dapp/src/containers/ProposalDetail/ProposalDetail.tsx +++ b/apps/stats-dapp/src/containers/ProposalDetail/ProposalDetail.tsx @@ -1,7 +1,336 @@ +import { + Button, + Chip, + DrawerCloseButton, +} from '@webb-tools/webb-ui-components/components'; +import { useBatchedProposal } from '../../provider/hooks/useProposals'; +import { FC, useCallback, useEffect, useMemo, useState } from 'react'; +import { getProposalsData } from '../../utils/getProposalsData'; +import { + ArrowLeft, + ArrowRight, + Close, + Expand, + ChainIcon, + ProposalVariant, +} from '@webb-tools/icons'; +import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'; +import { ProposalBatchStatus, ProposalType } from '../../generated/graphql'; +import { Typography } from '@webb-tools/webb-ui-components'; +import ProposalBadge from '@webb-tools/icons/ProposalBadge/ProposalBadge'; +import { StatusChip } from '../ProposalsTable'; +import { mapChainNameToLogo } from '../../utils'; + export const ProposalDetail = () => { + const { pathname } = useLocation(); + const navigate = useNavigate(); + const { proposalBatchId = '' } = useParams<{ proposalBatchId: string }>(); + + const batchedProposal = useBatchedProposal(proposalBatchId); + + const isPage = useMemo(() => { + return !pathname.includes('drawer'); + }, [pathname]); + + const proposalsWithCount = useMemo(() => { + if (batchedProposal.val) { + return batchedProposal.val.proposals.reduce< + { + type: string; + count: number; + }[] + >((acc, item) => { + const found = acc.find( + (e: { type: string; count: number }) => e.type === item.type + ); + if (found) { + found.count++; + } else { + acc.push({ type: item.type, count: 1 }); + } + return acc; + }, []); + } + + return []; + }, [batchedProposal]); + + const [proposalIds, setProposalIds] = useState([]); + + useEffect(() => { + const proposalIds = localStorage.getItem('proposalIds'); + if (proposalIds) { + setProposalIds(JSON.parse(proposalIds)); + } + }, [proposalBatchId]); + + const nextProposalBatchId = + proposalIds[proposalIds.indexOf(proposalBatchId) + 1]; + + const previousProposalBatchId = + proposalIds[proposalIds.indexOf(proposalBatchId) - 1]; + + const handleNextProposalBatch = useCallback(() => { + if (nextProposalBatchId) { + navigate(`/proposals${isPage ? '' : '/drawer'}/${nextProposalBatchId}`); + } + }, [isPage, navigate, nextProposalBatchId]); + + const handlePrevProposalBatch = useCallback(() => { + if (previousProposalBatchId) { + navigate( + `/proposals${isPage ? '' : '/drawer'}/${previousProposalBatchId}` + ); + } + }, [isPage, navigate, previousProposalBatchId]); + + const proposals = useMemo(() => { + if (batchedProposal.val) { + const proposalsArr = batchedProposal.val.proposals.map((proposal) => { + return { + ...proposal, + decodedData: getProposalsData( + proposal.type as ProposalType, + proposal.data + ), + }; + }); + + return proposalsArr; + } + + return []; + }, [batchedProposal]); + + const [proposalToShow, setProposalToShow] = useState(0); + + const handleNextProposal = () => { + if (proposalToShow < proposals.length - 1) { + setProposalToShow((prevIndex) => prevIndex + 1); + } + }; + + const handlePreviousProposal = () => { + if (proposalToShow > 0) { + setProposalToShow((prevIndex) => prevIndex - 1); + } + }; + + const currentProposal = useMemo(() => { + return proposals[proposalToShow]; + }, [proposalToShow, proposals]); + return ( -
- Proposal Detail +
+ {/* General Container */} +
+
+
+ + {isPage ? ( +
+ +
+ ) : ( + + )} + + + {batchedProposal.val?.status && ( + + )} + + + Proposal Details + +
+ +
+ + + + + {!isPage && ( + + + + )} +
+
+ +
+ + Proposals: + + + {proposalsWithCount.map((proposal, idx) => { + return ( +
+ + + {proposal.type} + + ({proposal.count}) +
+ ); + })} +
+ +
+
+ + Block Height: + + + + {batchedProposal.val?.height} + +
+ +
+ + Batch ID: + + + {batchedProposal.val?.id} +
+ +
+ + Chain: + + + + + + {mapChainNameToLogo(batchedProposal.val?.chain as string)} + +
+
+
+ + {/* Proposal Details Container */} +
+
+
+ + Proposal Details + + +
+ + Proposal: + + +
+ + + + {currentProposal ? currentProposal.type : ''} + +
+
+ +
+
+ + Type: {currentProposal ? currentProposal.type : ''} + +
+ +
+ +
+ + {`Proposal(s) ${proposalToShow + 1} out of ${ + proposals.length + }`} + + +
+ + + +
+
+
+
+
+
+
+ ); +}; + +const ProposalDecodedData: FC<{ data: Record }> = ({ data }) => { + const knowProposal = useMemo(() => { + const keys = Object.keys(data); + return keys.length === 1 && keys[0] === 'data'; + }, [data]); + + return ( +
+ {JSON.stringify(knowProposal ? data.data : data, null, 2)}
); }; diff --git a/apps/stats-dapp/src/containers/ProposalsTable/ProposalsTable.tsx b/apps/stats-dapp/src/containers/ProposalsTable/ProposalsTable.tsx index e9edbcf7dc..5c4a05a2ea 100644 --- a/apps/stats-dapp/src/containers/ProposalsTable/ProposalsTable.tsx +++ b/apps/stats-dapp/src/containers/ProposalsTable/ProposalsTable.tsx @@ -21,6 +21,7 @@ import { Table, Divider, ProposalsBadgeGroup, + Button, } from '@webb-tools/webb-ui-components/components'; import { fuzzyFilter } from '@webb-tools/webb-ui-components/components/Filter/utils'; import { ChainIcon, Spinner } from '@webb-tools/icons'; @@ -79,14 +80,19 @@ const columns: ColumnDef[] = [ }, }), - // columnHelper.accessor('id', { - // header: '', - // cell: (props) => ( - // - // ), - // }), + columnHelper.accessor('id', { + header: '', + cell: (props) => { + const isDisabled = + props.row.original.proposals.length === 0 ? true : false; + + return ( + + ); + }, + }), ]; export const ProposalsTable = () => { @@ -156,6 +162,9 @@ export const ProposalsTable = () => { const data = useMemo(() => { if (batchedProposals.val) { + const proposalIds = batchedProposals.val.items.map((item) => item.id); + localStorage.setItem('proposalIds', JSON.stringify(proposalIds)); + return batchedProposals.val.items; } @@ -302,6 +311,6 @@ interface StatusChipProps { status: ProposalBatchStatus; } -const StatusChip: React.FC = ({ status }) => { +export const StatusChip: React.FC = ({ status }) => { return {status}; }; diff --git a/apps/stats-dapp/src/gql/proposals.graphql b/apps/stats-dapp/src/gql/proposals.graphql index 538100a43e..8e58ced08a 100644 --- a/apps/stats-dapp/src/gql/proposals.graphql +++ b/apps/stats-dapp/src/gql/proposals.graphql @@ -28,5 +28,6 @@ query ProposalBatch($batchId: String!) { proposals chain status + timeline } } diff --git a/apps/stats-dapp/src/pages/ProposalDetailDrawer.tsx b/apps/stats-dapp/src/pages/ProposalDetailDrawer.tsx index 7f5ba0f8f0..86e851d46c 100644 --- a/apps/stats-dapp/src/pages/ProposalDetailDrawer.tsx +++ b/apps/stats-dapp/src/pages/ProposalDetailDrawer.tsx @@ -3,8 +3,8 @@ import { DrawerContent, } from '@webb-tools/webb-ui-components/components'; import { useNavigate } from 'react-router-dom'; - import { ProposalDetail } from '../containers'; +import { useEffect } from 'react'; const ProposalDetailDrawer = () => { const nagivate = useNavigate(); diff --git a/apps/stats-dapp/src/pages/Proposals.tsx b/apps/stats-dapp/src/pages/Proposals.tsx index 7ab96d2342..2c84e93780 100644 --- a/apps/stats-dapp/src/pages/Proposals.tsx +++ b/apps/stats-dapp/src/pages/Proposals.tsx @@ -2,6 +2,7 @@ import { Card, Stats, TitleWithInfo } from '@webb-tools/webb-ui-components'; import { ProposalsTable } from '../containers'; import { useMemo } from 'react'; import { useStatsContext } from '../provider'; +import { Outlet } from 'react-router-dom'; const Proposals = () => { const { @@ -40,6 +41,8 @@ const Proposals = () => { + +
); }; diff --git a/apps/stats-dapp/src/provider/hooks/useProposals.ts b/apps/stats-dapp/src/provider/hooks/useProposals.ts index 58b963f1e1..c107b2bf00 100644 --- a/apps/stats-dapp/src/provider/hooks/useProposals.ts +++ b/apps/stats-dapp/src/provider/hooks/useProposals.ts @@ -6,6 +6,11 @@ import { ProposalBatchesOrderBy, } from '../../generated/graphql'; +export type ProposalTimeline = { + status: string; + timestamp: string; +} + export type Proposal = { data: string; type: string; @@ -17,6 +22,7 @@ export type ProposalBatch = { height: number; proposals: Proposal[]; chain: string; + timeline: ProposalTimeline[]; }; export type BatchedProposalsQuery = PageInfoQuery & { @@ -143,6 +149,7 @@ export const useBatchedProposal = ( }; }), chain: batch?.chain, + timeline: batch?.timeline, }; setBatchedProposal({ diff --git a/apps/stats-dapp/src/routes/index.tsx b/apps/stats-dapp/src/routes/index.tsx index 80d6aa56d3..5b91230e98 100644 --- a/apps/stats-dapp/src/routes/index.tsx +++ b/apps/stats-dapp/src/routes/index.tsx @@ -106,7 +106,7 @@ export const routes: RouterConfigData[] = [ ), - path: 'proposals/:proposalId', + path: 'proposals/:proposalBatchId', }, { element: ( @@ -116,7 +116,7 @@ export const routes: RouterConfigData[] = [ ), children: [ { - path: 'drawer/:proposalId', + path: 'drawer/:proposalBatchId', element: ( diff --git a/apps/stats-dapp/src/utils/getProposalsData.ts b/apps/stats-dapp/src/utils/getProposalsData.ts index 01fb86bd24..c5bc0827c6 100644 --- a/apps/stats-dapp/src/utils/getProposalsData.ts +++ b/apps/stats-dapp/src/utils/getProposalsData.ts @@ -1,200 +1,183 @@ -// import { ProposalType } from '../generated/graphql'; +import { ProposalType } from '../generated/graphql'; +import { + AnchorCreateProposal, + AnchorUpdateProposal, + EVMProposal, + FeeRecipientUpdateProposal, + MaxDepositLimitProposal, + MinWithdrawalLimitProposal, + RefreshVoteProposal, + RescueTokensProposal, + ResourceIdUpdateProposal, + SetTreasuryHandlerProposal, + SetVerifierProposal, + TokenAddProposal, + TokenRemoveProposal, + WrappingFeeUpdateProposal, +} from '@webb-tools/sdk-core'; +import { hexToU8a, u8aToHex } from '@polkadot/util'; -// import { -// AnchorCreateProposal, -// AnchorUpdateProposal, -// EVMProposal, -// FeeRecipientUpdateProposal, -// MaxDepositLimitProposal, -// MinWithdrawalLimitProposal, -// ProposerSetUpdateProposal, -// RefreshVoteProposal, -// RescueTokensProposal, -// ResourceIdUpdateProposal, -// SetTreasuryHandlerProposal, -// SetVerifierProposal, -// TokenAddProposal, -// TokenRemoveProposal, -// WrappingFeeUpdateProposal, -// } from '@webb-tools/sdk-core'; +export function getProposalsData( + propType: ProposalType, + data: string +): Record> { + if (!data) return { data: '' }; -// import { hexToU8a, u8aToHex } from '@polkadot/util'; -// export function getProposalsData( -// propType: ProposalType, -// data: string -// ): Record> { -// if (!data) return { data: '' }; + const bytes = hexToU8a(data); -// const bytes = hexToU8a(data); -// switch (propType) { -// case ProposalType.AnchorCreateProposal: { -// const decoded = AnchorCreateProposal.fromBytes(bytes); -// return { -// encodedCall: decoded.encodedCall, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } - -// case ProposalType.AnchorUpdateProposal: { -// const decoded = AnchorUpdateProposal.fromBytes(bytes); -// return { -// merkleRoot: decoded.merkleRoot, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } -// case ProposalType.EvmProposal: { -// const decoded = EVMProposal.fromBytes(bytes); -// return { -// merkleRoot: String(decoded.nonce), -// chainId: String(decoded.chainId), -// tx: { ...decoded.tx }, -// }; -// } - -// case ProposalType.FeeRecipientUpdateProposal: { -// const decoded = FeeRecipientUpdateProposal.fromBytes(bytes); -// return { -// newFeeRecipient: decoded.newFeeRecipient, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } -// case ProposalType.MaxDepositLimitUpdateProposal: { -// const decoded = MaxDepositLimitProposal.fromBytes(bytes); -// return { -// maxDepositLimitBytes: decoded.maxDepositLimitBytes, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } -// case ProposalType.MinWithdrawalLimitUpdateProposal: { -// const decoded = MinWithdrawalLimitProposal.fromBytes(bytes); -// return { -// minWithdrawalLimitBytes: decoded.minWithdrawalLimitBytes, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } - -// case ProposalType.ProposerSetUpdateProposal: { -// const decoded = ProposerSetUpdateProposal.fromBytes(bytes); -// return { -// numberOfProposers: String(decoded.numberOfProposers), -// averageSessionLength: String(decoded.averageSessionLength), -// nonce: String(decoded.nonce), -// merkleRoot: decoded.merkleRoot, -// }; -// } - -// case ProposalType.RefreshVote: { -// const decoded = RefreshVoteProposal.fromBytes(bytes); -// return { -// nonce: String(decoded.nonce), -// publicKey: String(decoded.publicKey), -// }; -// } - -// case ProposalType.RescueTokensProposal: { -// const decoded = RescueTokensProposal.fromBytes(bytes); -// return { -// toAddress: decoded.toAddress, -// tokenAddress: decoded.tokenAddress, -// amount: decoded.amount, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } - -// case ProposalType.ResourceIdUpdateProposal: { -// const decoded = ResourceIdUpdateProposal.fromBytes(bytes); -// return { -// handlerAddress: decoded.handlerAddress, -// newResourceId: decoded.newResourceId, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } -// case ProposalType.SetTreasuryHandlerProposal: { -// const decoded = SetTreasuryHandlerProposal.fromBytes(bytes); -// return { -// newTreasuryHandler: decoded.newTreasuryHandler, -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// }; -// } - -// case ProposalType.SetVerifierProposal: { -// const decoded = SetVerifierProposal.fromBytes(bytes); -// return { -// newVerifier: decoded.newVerifier, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } -// case ProposalType.TokenAddProposal: { -// const decoded = TokenAddProposal.fromBytes(bytes); -// return { -// newTokenAddress: decoded.newTokenAddress, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } -// case ProposalType.TokenRemoveProposal: { -// const decoded = TokenRemoveProposal.fromBytes(bytes); -// return { -// removeTokenAddress: decoded.removeTokenAddress, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } -// case ProposalType.Unknown: -// break; -// case ProposalType.WrappingFeeUpdateProposal: { -// const decoded = WrappingFeeUpdateProposal.fromBytes(bytes); -// return { -// newFee: decoded.newFee, -// functionSignature: u8aToHex(decoded.header.functionSignature), -// nonce: String(decoded.header.nonce), -// chainType: String(decoded.header.resourceId.chainType), -// chainId: String(decoded.header.resourceId.chainId), -// targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), -// }; -// } -// } -// return { data }; -// } + switch (propType) { + case ProposalType.AnchorCreate: { + const decoded = AnchorCreateProposal.fromBytes(bytes); + return { + encodedCall: decoded.encodedCall, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + case ProposalType.AnchorUpdate: { + const decoded = AnchorUpdateProposal.fromBytes(bytes); + return { + merkleRoot: decoded.merkleRoot, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + case ProposalType.Evm: { + const decoded = EVMProposal.fromBytes(bytes); + return { + merkleRoot: String(decoded.nonce), + chainId: String(decoded.chainId), + tx: { ...decoded.tx }, + }; + } + case ProposalType.FeeRecipientUpdate: { + const decoded = FeeRecipientUpdateProposal.fromBytes(bytes); + return { + newFeeRecipient: decoded.newFeeRecipient, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + case ProposalType.MaxDepositLimitUpdate: { + const decoded = MaxDepositLimitProposal.fromBytes(bytes); + return { + maxDepositLimitBytes: decoded.maxDepositLimitBytes, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + case ProposalType.MinWithdrawalLimitUpdate: { + const decoded = MinWithdrawalLimitProposal.fromBytes(bytes); + return { + minWithdrawalLimitBytes: decoded.minWithdrawalLimitBytes, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + case ProposalType.Refresh: { + const decoded = RefreshVoteProposal.fromBytes(bytes); + return { + nonce: String(decoded.nonce), + publicKey: String(decoded.publicKey), + }; + } + case ProposalType.RescueTokens: { + const decoded = RescueTokensProposal.fromBytes(bytes); + return { + toAddress: decoded.toAddress, + tokenAddress: decoded.tokenAddress, + amount: decoded.amount, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + case ProposalType.ResourceIdUpdate: { + const decoded = ResourceIdUpdateProposal.fromBytes(bytes); + return { + handlerAddress: decoded.handlerAddress, + newResourceId: decoded.newResourceId, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + case ProposalType.SetTreasuryHandler: { + const decoded = SetTreasuryHandlerProposal.fromBytes(bytes); + return { + newTreasuryHandler: decoded.newTreasuryHandler, + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + }; + } + case ProposalType.SetVerifier: { + const decoded = SetVerifierProposal.fromBytes(bytes); + return { + newVerifier: decoded.newVerifier, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + case ProposalType.TokenAdd: { + const decoded = TokenAddProposal.fromBytes(bytes); + return { + newTokenAddress: decoded.newTokenAddress, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + case ProposalType.TokenRemove: { + const decoded = TokenRemoveProposal.fromBytes(bytes); + return { + removeTokenAddress: decoded.removeTokenAddress, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + case ProposalType.WrappingFeeUpdate: { + const decoded = WrappingFeeUpdateProposal.fromBytes(bytes); + return { + newFee: decoded.newFee, + functionSignature: u8aToHex(decoded.header.functionSignature), + nonce: String(decoded.header.nonce), + chainType: String(decoded.header.resourceId.chainType), + chainId: String(decoded.header.resourceId.chainId), + targetSystem: u8aToHex(decoded.header.resourceId.targetSystem), + }; + } + default: { + return { data }; + } + } +} diff --git a/apps/stats-dapp/src/utils/index.ts b/apps/stats-dapp/src/utils/index.ts index 129ebca471..4ef6643db9 100644 --- a/apps/stats-dapp/src/utils/index.ts +++ b/apps/stats-dapp/src/utils/index.ts @@ -1,5 +1,5 @@ export * from './getChipColorByKeyType'; export * from './getChipColorByProposalType'; -// export * from './getProposalsData'; +export * from './getProposalsData'; export * from './ChainNameToLogo'; export * from './networkSelector'; From 9e044109dc30023e27338a242dd8267686ed07e2 Mon Sep 17 00:00:00 2001 From: Pavan Soratur Date: Thu, 17 Aug 2023 00:44:43 -0700 Subject: [PATCH 2/2] chore: code format --- apps/stats-dapp/src/provider/hooks/useProposals.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/stats-dapp/src/provider/hooks/useProposals.ts b/apps/stats-dapp/src/provider/hooks/useProposals.ts index c107b2bf00..cc86ed4447 100644 --- a/apps/stats-dapp/src/provider/hooks/useProposals.ts +++ b/apps/stats-dapp/src/provider/hooks/useProposals.ts @@ -9,7 +9,7 @@ import { export type ProposalTimeline = { status: string; timestamp: string; -} +}; export type Proposal = { data: string;