diff --git a/config/kusama.yml.sample b/config/kusama.yml.sample index f388b69..190274f 100644 --- a/config/kusama.yml.sample +++ b/config/kusama.yml.sample @@ -58,6 +58,7 @@ import-storage: - Bids - Candidates - Members + - Payouts Bids: - who: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice kind: @@ -102,6 +103,15 @@ import-storage: ChallengeRoundCount: 6 RoundCount: 6 MemberCount: 2 - Head: 5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw + Head: 5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw # Eve + Payouts: + - + - + - 5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL # Ferdie + - paid: 0 + payouts: + - + - 20000000 + - 15000000000000 ParasDisputes: $removePrefix: ['disputes'] # those can makes block building super slow diff --git a/src/pages/explore/CandidatesPage/components/CandidatesList.tsx b/src/pages/explore/CandidatesPage/components/CandidatesList.tsx index 7c75595..53c4391 100644 --- a/src/pages/explore/CandidatesPage/components/CandidatesList.tsx +++ b/src/pages/explore/CandidatesPage/components/CandidatesList.tsx @@ -12,7 +12,6 @@ import { useAccount } from '../../../../account/AccountContext' import { AccountIdentity } from '../../../../components/AccountIdentity' import { DataHeaderRow, DataRow } from '../../../../components/base' import { FormatBalance } from '../../../../components/FormatBalance' -// import { truncate } from '../../../../helpers/truncate' import { Identicon } from '../../components/Identicon' import { toastByStatus } from '../../helpers' diff --git a/src/pages/explore/PayoutsPage/components/PayoutsList.tsx b/src/pages/explore/PayoutsPage/components/PayoutsList.tsx index 5fe5712..5daf338 100644 --- a/src/pages/explore/PayoutsPage/components/PayoutsList.tsx +++ b/src/pages/explore/PayoutsPage/components/PayoutsList.tsx @@ -1,19 +1,22 @@ import type { ApiPromise } from '@polkadot/api' import { WalletAccount } from '@talismn/connect-wallets' import { useState, useEffect } from 'react' -import { Badge, Col } from 'react-bootstrap' +import { Badge, Button, Col } from 'react-bootstrap' import styled from 'styled-components' import { DataHeaderRow, DataRow } from '../../../../components/base' import { FormatBalance } from '../../../../components/FormatBalance' import { useBlockTime } from '../../../../hooks/useBlockTime' import { Identicon } from '../../components/Identicon' +import { payout } from '../helper' const StyledDataRow = styled(DataRow)` background-color: ${(props) => (props.$isDefender ? props.theme.colors.black : '')}; border: ${(props) => (props.$isDefender ? `2px solid ${props.theme.colors.secondary}` : '')}; + &:hover { cursor: pointer; } + @media (max-width: 992px) { padding-block: 12px; margin-inline: 2px; @@ -27,7 +30,14 @@ type PayoutsListProps = { handleUpdate: () => void } -const TimeRemaining = ({ block, latestBlock, api }: { block: number; latestBlock: number | null; api: ApiPromise }) => { +type TimeRemainingProps = { + api: ApiPromise + block: number + latestBlock: number | null + onClainPayout: () => void +} + +const TimeRemaining = ({ block, latestBlock, api, onClainPayout }: TimeRemainingProps) => { if (!latestBlock) return ( @@ -47,9 +57,15 @@ const TimeRemaining = ({ block, latestBlock, api }: { block: number; latestBlock if (blocksLeft <= 0) return ( - - Matured - + <> + + Matured + + {/* @TODO: Only show claim button if it's the current address */} + + ) return ( @@ -59,9 +75,11 @@ const TimeRemaining = ({ block, latestBlock, api }: { block: number; latestBlock ) } -const PayoutsList = ({ api, members }: PayoutsListProps): JSX.Element => { +const PayoutsList = ({ api, members, activeAccount }: PayoutsListProps): JSX.Element => { const [latestBlock, setLatestBlock] = useState(null) + const isMember = (member: ExtendedSocietyMember) => activeAccount?.address === member.accountId.toHuman() + useEffect(() => { const fetchLatestBlock = async () => { const header = await api.rpc.chain.getHeader() @@ -80,6 +98,16 @@ const PayoutsList = ({ api, members }: PayoutsListProps): JSX.Element => { if (members.length === 0) return <>No members + const onClainPayout = () => { + const tx = api.tx.society.payout() + + const notReallySure = () => { + console.log('oiii ??????') + } + + payout(tx, api, activeAccount, notReallySure) + } + return ( <> @@ -122,9 +150,12 @@ const PayoutsList = ({ api, members }: PayoutsListProps): JSX.Element => { )} {member.hasPayouts && ( - <> - - + )} {member.extendedPayouts.pending == 0 && member.extendedPayouts.paid > 0 && ( @@ -136,6 +167,12 @@ const PayoutsList = ({ api, members }: PayoutsListProps): JSX.Element => { Paid before V2 )} + + {isMember(member) && ( + + You + + )} ))} diff --git a/src/pages/explore/PayoutsPage/helper.ts b/src/pages/explore/PayoutsPage/helper.ts new file mode 100644 index 0000000..2649c2e --- /dev/null +++ b/src/pages/explore/PayoutsPage/helper.ts @@ -0,0 +1,17 @@ +import { ApiPromise } from '@polkadot/api' +import { SubmittableExtrinsic } from '@polkadot/api/types' +import { WalletAccount } from '@talismn/connect-wallets' +import { doTx } from '../../../helpers/extrinsics' + +const waitingText = 'Request sent. Waiting for response...' + +export const payout = async ( + tx: SubmittableExtrinsic<'promise', any>, + api: ApiPromise, + activeAccount: WalletAccount | undefined, + onStatusChange: any +) => { + const finalizedText = 'Payout submitted successfully.' + + await doTx(api, tx, finalizedText, waitingText, activeAccount, onStatusChange) +} diff --git a/src/pages/explore/components/NavigationBar.tsx b/src/pages/explore/components/NavigationBar.tsx index af2d018..65132e6 100644 --- a/src/pages/explore/components/NavigationBar.tsx +++ b/src/pages/explore/components/NavigationBar.tsx @@ -52,13 +52,13 @@ const NavigationBar = ({ totals }: { totals: Totals }) => { - - Journey + + Payouts - - Payouts + + Journey