From 88c85c744a654e16c2e59b392faadc220d820791 Mon Sep 17 00:00:00 2001 From: Kammradt Date: Sun, 24 Nov 2024 15:54:56 -0300 Subject: [PATCH 1/5] chore: adds simple badge --- config/kusama.yml.sample | 6 ++++++ src/pages/explore/PayoutsPage/components/PayoutsList.tsx | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config/kusama.yml.sample b/config/kusama.yml.sample index f388b69..45e6289 100644 --- a/config/kusama.yml.sample +++ b/config/kusama.yml.sample @@ -99,6 +99,12 @@ import-storage: - rank: 1 strikes: 0 index: 1 + - + - + - 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y # Charlie + - rank: 2 + strikes: 0 + index: 2 ChallengeRoundCount: 6 RoundCount: 6 MemberCount: 2 diff --git a/src/pages/explore/PayoutsPage/components/PayoutsList.tsx b/src/pages/explore/PayoutsPage/components/PayoutsList.tsx index 5fe5712..e62a5c7 100644 --- a/src/pages/explore/PayoutsPage/components/PayoutsList.tsx +++ b/src/pages/explore/PayoutsPage/components/PayoutsList.tsx @@ -59,9 +59,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() @@ -136,6 +138,8 @@ const PayoutsList = ({ api, members }: PayoutsListProps): JSX.Element => { Paid before V2 )} + + {isMember(member) && You} ))} From e2dd76c788e3ea6583dcb253c9234a43872ebb4a Mon Sep 17 00:00:00 2001 From: Kammradt Date: Thu, 5 Dec 2024 12:59:02 -0300 Subject: [PATCH 2/5] chore: adds button --- .../components/CandidatesList.tsx | 1 - .../PayoutsPage/components/PayoutsList.tsx | 49 ++++++++++++++++--- 2 files changed, 41 insertions(+), 9 deletions(-) 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 e62a5c7..1d79114 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,14 @@ const TimeRemaining = ({ block, latestBlock, api }: { block: number; latestBlock if (blocksLeft <= 0) return ( - - Matured - + <> + + Matured + + + ) return ( @@ -82,6 +97,21 @@ const PayoutsList = ({ api, members, activeAccount }: PayoutsListProps): JSX.Ele 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) + } + + members[members.length - 1] = { + ...members[members.length - 1], + hasPayouts: true + } + return ( <> @@ -124,9 +154,12 @@ const PayoutsList = ({ api, members, activeAccount }: PayoutsListProps): JSX.Ele )} {member.hasPayouts && ( - <> - - + )} {member.extendedPayouts.pending == 0 && member.extendedPayouts.paid > 0 && ( From dd465acc16a4cf3d01460d36b36706ca57308572 Mon Sep 17 00:00:00 2001 From: Kammradt Date: Thu, 5 Dec 2024 15:58:16 -0300 Subject: [PATCH 3/5] chore: adds button --- src/pages/explore/PayoutsPage/helper.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/pages/explore/PayoutsPage/helper.ts 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) +} From 865aa4b4a8cdab7052903d36e00dbc266ff0ce07 Mon Sep 17 00:00:00 2001 From: Kammradt Date: Tue, 21 Jan 2025 16:08:42 -0300 Subject: [PATCH 4/5] chore: change order of links --- src/pages/explore/components/NavigationBar.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 From 774644658f1c41adc99d7b771ef65e1ffc0ddfa6 Mon Sep 17 00:00:00 2001 From: Lauro Gripa Date: Tue, 21 Jan 2025 20:04:11 -0300 Subject: [PATCH 5/5] Add a matured payout to chopsticks storage --- config/kusama.yml.sample | 18 +++++++++++------- .../PayoutsPage/components/PayoutsList.tsx | 12 ++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/config/kusama.yml.sample b/config/kusama.yml.sample index 45e6289..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: @@ -99,15 +100,18 @@ import-storage: - rank: 1 strikes: 0 index: 1 - - - - - - 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y # Charlie - - rank: 2 - strikes: 0 - index: 2 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/PayoutsPage/components/PayoutsList.tsx b/src/pages/explore/PayoutsPage/components/PayoutsList.tsx index 1d79114..5daf338 100644 --- a/src/pages/explore/PayoutsPage/components/PayoutsList.tsx +++ b/src/pages/explore/PayoutsPage/components/PayoutsList.tsx @@ -61,6 +61,7 @@ const TimeRemaining = ({ block, latestBlock, api, onClainPayout }: TimeRemaining Matured + {/* @TODO: Only show claim button if it's the current address */} @@ -107,11 +108,6 @@ const PayoutsList = ({ api, members, activeAccount }: PayoutsListProps): JSX.Ele payout(tx, api, activeAccount, notReallySure) } - members[members.length - 1] = { - ...members[members.length - 1], - hasPayouts: true - } - return ( <> @@ -172,7 +168,11 @@ const PayoutsList = ({ api, members, activeAccount }: PayoutsListProps): JSX.Ele )} - {isMember(member) && You} + {isMember(member) && ( + + You + + )} ))}