diff --git a/README.md b/README.md index 83f98ab..1181a89 100644 --- a/README.md +++ b/README.md @@ -5,21 +5,25 @@ The easiest way to delegate on Polkadot ## Delegation made simple + - 2 click flow to delegate, even with complex setup - See your current governance locks -- Delegatees can link to their page direction +- Delegates can link to their page direction ### Why + Elections are only meaningful if the participation turnout is high. This applies to politics around the world, and to Polkadot. To increase turnout (1-3% currently) we need more participation, which leads to more decentralization -Delegation is a way to give power to delegatees, that can vote on your behalf. +Delegation is a way to give power to delegates, that can vote on your behalf. ## Development + Requirements, [node](https://nodejs.org/en/download/package-manager/current) and [pnpm](https://pnpm.io/installation). <-- install them by clicking on the links To run the project + - clone this repo `git clone https://github.com/delegit-xyz/dashboard.git && cd dashboard` - install dependencies diff --git a/src/App.tsx b/src/App.tsx index 8661ccb..7400c66 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,7 +12,7 @@ import { ReDotProvider, ReDotChainProvider } from '@reactive-dot/react' import { Suspense } from 'react' import { AccountContextProvider } from './contexts/AccountsContext' import { LocksContextProvider } from './contexts/LocksContext' -import { DelegateeContextProvider } from '@/contexts/DelegateesContext' +import { DelegateContextProvider } from '@/contexts/DelegatesContext' import { NetworkContextProvider } from './contexts/NetworkContext' const App = () => { @@ -27,7 +27,7 @@ const App = () => { - + @@ -41,7 +41,7 @@ const App = () => { - + diff --git a/src/components/DelegateeCard.tsx b/src/components/DelegateeCard.tsx index e37bf7c..2500de2 100644 --- a/src/components/DelegateeCard.tsx +++ b/src/components/DelegateeCard.tsx @@ -12,12 +12,12 @@ import { ellipsisFn } from '@polkadot-ui/utils' import { useNavigate } from 'react-router-dom' import copy from 'copy-to-clipboard' import { useEffect, useState } from 'react' -import { Delegatee } from '@/contexts/DelegateesContext' +import { Delegate } from '@/contexts/DelegatesContext' interface Props { - delegatee: Delegatee + delegate: Delegate } -export const DelegateeCard = ({ delegatee: d }: Props) => { +export const DelegateCard = ({ delegate: d }: Props) => { const [copied, setCopied] = useState(false) const navigate = useNavigate() diff --git a/src/contexts/DelegateesContext.tsx b/src/contexts/DelegateesContext.tsx index d0cf528..324f3dc 100644 --- a/src/contexts/DelegateesContext.tsx +++ b/src/contexts/DelegateesContext.tsx @@ -4,11 +4,11 @@ import { useNetwork } from './NetworkContext' import { DelegeeListKusama, DelegeeListPolkadot } from '@/lib/constants' // import { dotApi } from '@/clients' -type DelegateesContextProps = { +type DelegatesContextProps = { children: React.ReactNode | React.ReactNode[] } -export type Delegatee = { +export type Delegate = { address: string name: string image: string @@ -17,18 +17,16 @@ export type Delegatee = { isOrganization: boolean } -export interface IDelegateesContext { - delegatees: Delegatee[] - getDelegateeByAddress: (address: string) => Delegatee | undefined +export interface IDelegatesContext { + delegates: Delegate[] + getDelegateByAddress: (address: string) => Delegate | undefined } -const DelegateesContext = createContext( - undefined, -) +const DelegatesContext = createContext(undefined) -const DelegateeContextProvider = ({ children }: DelegateesContextProps) => { +const DelegateContextProvider = ({ children }: DelegatesContextProps) => { const { network } = useNetwork() - const [delegatees, setDelegatees] = useState([]) + const [delegates, setDelegates] = useState([]) useEffect(() => { const fetchOpenPRs = async () => { @@ -37,42 +35,42 @@ const DelegateeContextProvider = ({ children }: DelegateesContextProps) => { network === 'polkadot' ? DelegeeListPolkadot : DelegeeListKusama, )! ).json() - setDelegatees(response) + setDelegates(response) } fetchOpenPRs() }, [network]) - const getDelegateeByAddress = (address: string) => - delegatees.find((d) => d.address === address) + const getDelegateByAddress = (address: string) => + delegates.find((d) => d.address === address) // Votes thingy - pause for now // useEffect(() => { - // const a = async (delegatees: any[]) => { - // const result: Promise[] = delegatees.map((d) => { + // const a = async (delegates: any[]) => { + // const result: Promise[] = delegates.map((d) => { // return dotApi.query.ConvictionVoting.VotingFor.getEntries(d.address) // }) // await Promise.all(result).then((res) => { // console.log(res) // }) // } - // a(delegatees) - // }, [delegatees]) + // a(delegates) + // }, [delegates]) return ( - + {children} - + ) } -const useDelegatees = () => { - const context = useContext(DelegateesContext) +const useDelegates = () => { + const context = useContext(DelegatesContext) if (context === undefined) { throw new Error( - 'useDelegatees must be used within a DelegateesContextProvider', + 'useDelegates must be used within a DelegatesContextProvider', ) } return context } -export { DelegateeContextProvider, useDelegatees } +export { DelegateContextProvider, useDelegates } diff --git a/src/pages/Delegate/index.tsx b/src/pages/Delegate/index.tsx index 78844db..b9f2d18 100644 --- a/src/pages/Delegate/index.tsx +++ b/src/pages/Delegate/index.tsx @@ -1,6 +1,6 @@ import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' -import { useDelegatees } from '@/contexts/DelegateesContext' +import { useDelegates } from '@/contexts/DelegatesContext' import { useNetwork } from '@/contexts/NetworkContext' import { getLockTimes } from '@/lib/locks' import { VotingConviction } from '@polkadot-api/descriptors' @@ -34,9 +34,9 @@ export const Delegate = () => { const { api, assetInfo } = useNetwork() const { address } = useParams() - const { getDelegateeByAddress } = useDelegatees() - const [delegatee, setDelegatee] = useState( - address && getDelegateeByAddress(address), + const { getDelegateByAddress } = useDelegates() + const [delegate, setDelegate] = useState( + address && getDelegateByAddress(address), ) const [amount, setAmount] = useState(0n) const [amountVisible, setAmountVisible] = useState('0') @@ -75,12 +75,12 @@ export const Delegate = () => { }, [convictionNo, convictionList]) useEffect(() => { - if (!address || delegatee) return - const res = getDelegateeByAddress(address) - setDelegatee(res) - }, [address, delegatee, getDelegateeByAddress]) + if (!address || delegate) return + const res = getDelegateByAddress(address) + setDelegate(res) + }, [address, delegate, getDelegateByAddress]) - if (!delegatee || !api) return
No delegatee found
+ if (!delegate || !api) return
No delegate found
const onChangeAmount = ( e: React.ChangeEvent, @@ -103,7 +103,7 @@ export const Delegate = () => { const tx = getDelegateTx({ from: selectedAccount?.address, - target: delegatee.address, + target: delegate.address, conviction: conviction, amount, tracks: allTracks || [], @@ -139,7 +139,7 @@ export const Delegate = () => { /> )}

- Delegate to {delegatee.name} + Delegate to {delegate.name}

diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index db34ebd..3fe15de 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -1,18 +1,18 @@ import { LocksCard } from '@/components/LocksCard' -import { useDelegatees } from '@/contexts/DelegateesContext' -import { DelegateeCard } from '@/components/DelegateeCard' +import { useDelegates } from '@/contexts/DelegatesContext' +import { DelegateCard } from '@/components/DelegateCard' export const Home = () => { - const { delegatees } = useDelegatees() + const { delegates } = useDelegates() return (

- Delegatees + Delegates

- {delegatees?.map((d) => )} + {delegates?.map((d) => )}
)