Skip to content

Commit

Permalink
Remove test code (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjurco authored Dec 9, 2024
1 parent 538e190 commit af15281
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 238 deletions.
41 changes: 2 additions & 39 deletions src/chain-data/context.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { createContext, useState, useMemo, useContext, ReactNode } from 'react';
import { initialSettableChainData, initialChainData, SettableChainData, Proposal } from './state';
import { initialSettableChainData, initialChainData, SettableChainData } from './state';
import { useAccount, useNetwork } from 'wagmi';
import { getDaoAddresses, updateNetworkName } from '../contracts';
import { useEthersProvider, useEthersSigner } from './adapters';
import { BigNumber, ethers } from 'ethers';
import testProposals from '../pages/proposals/test-proposals.json';
import { ethers } from 'ethers';

export const ChainDataContext = createContext(initialSettableChainData);

Expand Down Expand Up @@ -49,41 +48,6 @@ const ChainDataContextProvider = (props: { children: ReactNode }) => {

export default ChainDataContextProvider;

const convertBigNumbersAndDates = (obj: any): any => {
if (Array.isArray(obj)) {
return obj.map(convertBigNumbersAndDates);
} else if (obj && typeof obj === 'object') {
return Object.keys(obj).reduce((acc, key) => {
const value = obj[key];
if (value && value.type === 'BigNumber' && value.hex) {
acc[key] = BigNumber.from(value.hex);
} else if (key === 'deadline' || key === 'startDate') {
acc[key] = new Date(value);
} else {
acc[key] = convertBigNumbersAndDates(value);
}
return acc;
}, {} as any);
}
return obj;
};

const convertToProposals = (
data: any
): { primary: { [key: string]: Proposal }; secondary: { [key: string]: Proposal } } => {
const convertSection = (section: { [key: string]: any }) => {
return Object.keys(section).reduce((acc, key) => {
acc[key] = convertBigNumbersAndDates(section[key]);
return acc;
}, {} as { [key: string]: Proposal });
};

return {
primary: convertSection(data.primary),
secondary: convertSection(data.secondary),
};
};

export const useChainData = () => {
const data = useContext(ChainDataContext);
const { provider, signer } = useContext(ProviderSignerContext) || {};
Expand All @@ -95,7 +59,6 @@ export const useChainData = () => {
const networkName = updateNetworkName(chain?.network || '');
return {
...data,
// proposals: convertToProposals(testProposals),
isConnected: true,
provider,
signer,
Expand Down
32 changes: 1 addition & 31 deletions src/pages/proposals/proposals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ import {
votingPowerThresholdSelector,
} from '../../logic/proposals/selectors';
import Delegation from './delegation';
import { Proposal, useChainData } from '../../chain-data';
import { useChainData } from '../../chain-data';
import { useLoadDashboardData } from '../../logic/dashboard';
import { formatApi3, handleTransactionError, images, round } from '../../utils';
import testProposals from './test-proposals.json';
import { BigNumber } from 'ethers';
import styles from './proposals.module.scss';

const Proposals = () => {
Expand All @@ -45,34 +43,6 @@ const Proposals = () => {
useActiveProposals();
useTreasuryAndDelegation();

/** START: TESTING DATA FOR PROPOSAL LIST */

// const convertBigNumbersAndDates = (obj: any): any => {
// if (Array.isArray(obj)) {
// return obj.map(convertBigNumbersAndDates);
// } else if (obj && typeof obj === 'object') {
// return Object.keys(obj).reduce((acc, key) => {
// const value = obj[key];
// if (value && value.type === 'BigNumber' && value.hex) {
// acc[key] = BigNumber.from(value.hex);
// } else if (key === 'deadline' || key === 'startDate') {
// acc[key] = new Date(value);
// } else {
// acc[key] = convertBigNumbersAndDates(value);
// }
// return acc;
// }, {} as any);
// }
// return obj;
// };

// const convertToProposals = (data: any[]): Proposal[] => {
// return data.map((item) => convertBigNumbersAndDates(item));
// };
// const sortedProposals = convertToProposals(testProposals);

/** END: TESTING DATA FOR PROPOSAL LIST */

const sortedProposals = openProposalsSelector(proposals);
const createNewProposal = canCreateNewProposalSelector(delegation, dashboardState, isGenesisEpoch);
const votingThresholdPercent = votingPowerThresholdSelector(delegation);
Expand Down
168 changes: 0 additions & 168 deletions src/pages/proposals/test-proposals.json

This file was deleted.

0 comments on commit af15281

Please sign in to comment.