From 37382136b5f42de0960388d9e4321d302e8d19b4 Mon Sep 17 00:00:00 2001 From: soulBit Date: Wed, 11 Oct 2023 13:53:52 +0100 Subject: [PATCH] Bitocracy Page (#543) * feat: initial Bitocracy content and stubs * feat: add Bitocracy menu option for SOV-2917 * chore: add changeset * fix: missing lazy load for Bitocracy page * SOV-2922: voting proposals page (#552) * SOV-2922: voting proposals page * Create proud-rivers-give.md * chore: added changes from comments * chore: remove condition for past proposals * chore: added tooltip + added view button * chore: update proposal link + new proposal btn * SOV-3008: Proposal voting status (progress) (#565) * feat: add bar component with threshold option * SOV-3008: bitocracy voting result component * SOV-3226: Fix bitocracy alerts button (#610) * Fix bitocracy alerts button * Move EmailNotificationSettingsDialog to shared state * Create shiny-years-leave.md * SOV-3012: Bitocracy alerts (#580) * SOV-3012: Bitocracy alerts * Create fifty-baboons-fry.md * chore: cherry-pick from https://github.com/DistributedCollective/sovryn-dapp/pull/535/files * Fix invalid localization key * fix: duplicated deps --------- Co-authored-by: tiltom Co-authored-by: Victor Creed * SOV-3013: Voting - Next Steps modal (#564) * feat: Voting - Next Steps modal * Create two-ligers-relax.md * fix: resolve PR issue * fix: next step modal showing * fix: show next step dialog when tx dialog is closed * SOV-3010: Individual Proposal page (#583) * SOV-2922: voting proposals page (#552) * SOV-2922: voting proposals page * Create proud-rivers-give.md * chore: added changes from comments * chore: remove condition for past proposals * chore: added tooltip + added view button * chore: update proposal link + new proposal btn * feat: ProposalPage added * Create pink-buckets-rhyme.md * feat: update proposal page * feat: vote query * feat: resolve PR comments * feat: update cast vote in proposal * update proposal query * fix: mobile view * update gql * fix: proposal result issue * fix: show loading on proposal page * fix: cast vote error message * SOV-3009: voting actions (#597) * SOV-3009: voting actions * Create yellow-tips-sip.md * chore: fixes from comments * chore: update proposal status * chore: update proposal status * chore: update from comments * fix: proposal execution --------- Co-authored-by: Victor Creed * fix: execution eta * SOV-3196: add voting tooltips to Voting proposals page (#603) * SOV-3196: add voting tooltips to Voting proposals page * Create angry-mails-enjoy.md * chore: force deployment * chore: force deployment --------- Co-authored-by: Victor Creed <69458664+creed-victor@users.noreply.github.com> * SOV-3211-3207: Bitocracy proposal issues (#614) * fix: bitocracy proposal title * Create many-fishes-hang.md * fix: define title limit * fix: update proposal title * SOV-3195: add voting power section (#600) * SOV-3195: add voting power section * chore: add a tooltip for VP * chore: refactoring * Create giant-ducks-laugh.md * chore: updates from comments * fix: proposal status hook * chore: remove hrefExternal in view proposal button --------- Co-authored-by: Victor Creed * SOV-3225: Proposal row click (#625) * Fix individual proposal opening * Fix review remarks * Change title tooltip trigger to hover * Create fresh-goats-begin.md * SOV-3011: Voting - Proposal CSV export (#627) * SOV-3011: add CSV export * chore: update text in proposal CSV file * SOV-3239: Support/Reject button in Cast your vote (#616) * feat: support reject proposal * Create olive-olives-obey.md * fix: refetch when voting is done * fix: casting issue * fix: hide when loading * fix: resolve PR comments * fix: casting vote issue * chore: increase gas limit --------- Co-authored-by: Victor Creed <69458664+creed-victor@users.noreply.github.com> --------- Co-authored-by: Pietro Maximoff <74987028+pietro-maximoff@users.noreply.github.com> Co-authored-by: Victor Creed Co-authored-by: Victor Creed <69458664+creed-victor@users.noreply.github.com> Co-authored-by: tiltom * SOV-3319: Fix proposal type (#630) * Fix proposal type condition * Adjust exacutable details and proposal actions * Create brave-experts-cover.md * SOV-3312: Fix small bugs (#631) * Fix small bugs * Create small-fishes-work.md * Change layout of executable details * SOV-3288: Show the current state of voting (#632) * Show the current state of voting * Create thin-geckos-fail.md * Fix the copy * Fix review remarks * SOV-3327: Fix status labels (#636) * Fix status labels * Create moody-fans-attack.md * SOV-3334: Fix cast vote mobile (#639) * Fix cast section mobile view * Create happy-carrots-fold.md * Bump up proposal vote gas limit --------- Co-authored-by: Pietro Maximoff <74987028+pietro-maximoff@users.noreply.github.com> Co-authored-by: Victor Creed <69458664+creed-victor@users.noreply.github.com> Co-authored-by: tiltom Co-authored-by: tiltom Co-authored-by: Victor Creed Co-authored-by: Peiman <25097709+Rickk137@users.noreply.github.com> --- .changeset/angry-mails-enjoy.md | 5 + .changeset/brave-experts-cover.md | 5 + .changeset/fifty-baboons-fry.md | 5 + .changeset/fresh-goats-begin.md | 5 + .changeset/giant-ducks-laugh.md | 5 + .changeset/happy-carrots-fold.md | 5 + .changeset/many-fishes-hang.md | 5 + .changeset/moody-fans-attack.md | 5 + .changeset/nervous-swans-lick.md | 5 + .changeset/olive-olives-obey.md | 6 + .changeset/pink-buckets-rhyme.md | 6 + .changeset/pink-monkeys-wash.md | 5 + .changeset/proud-rivers-give.md | 5 + .changeset/shiny-years-leave.md | 5 + .changeset/silver-mayflies-sell.md | 5 + .changeset/small-fishes-work.md | 5 + .changeset/thin-geckos-fail.md | 5 + .changeset/two-ligers-relax.md | 5 + .changeset/yellow-tips-sip.md | 6 + apps/frontend/package.json | 4 + .../ConnectWalletButton.tsx | 20 +- .../EmailNotificationSettingsDialog.types.ts | 7 + .../components/Subscriptions.tsx | 11 + .../EmailNotificationSettingsContext.tsx | 7 + .../hooks/useHandleSubscriptions.ts | 13 + .../3_organisms/Header/Header.constants.tsx | 4 + .../ProposalVotingPower.tsx | 53 ++ .../ProposalVotingPower.utils.tsx | 34 + .../ProposalVotingResults.tsx | 165 ++++ .../SharedStateProvider.tsx | 27 + .../BitocracyPage/BitocracyPage.constants.tsx | 1 + .../5_pages/BitocracyPage/BitocracyPage.tsx | 82 ++ .../BitocracyPage/BitocracyPage.types.ts | 16 + .../BitocracyPage/BitocracyPage.utils.tsx | 46 ++ .../ProposalCardsMobile.tsx | 80 ++ .../ProposalStatus/ProposalStatus.tsx | 57 ++ .../ProposalTitle/ProposalTitle.tsx | 31 + .../components/ProposalType/ProposalType.tsx | 39 + .../ProposalViewButton/ProposalViewButton.tsx | 27 + .../Proposals/Proposals.constants.tsx | 70 ++ .../components/Proposals/Proposals.tsx | 103 +++ .../components/Proposals/Proposals.utils.tsx | 17 + .../BitocracyPage/hooks/useGetProposals.ts | 23 + .../hooks/useIsExecutableProposal.ts | 25 + .../BitocracyPage/hooks/useProposalStatus.ts | 44 + .../app/5_pages/ProposalPage/ProposalPage.tsx | 164 ++++ .../ProposalPage/ProposalPage.types.ts | 4 + .../ProposalPage/ProposalPage.utils.ts | 49 ++ .../components/CastVote/CastVote.tsx | 235 ++++++ .../ExecutableDetails/ExecutableDetails.tsx | 147 ++++ .../ProposalAction/ProposalAction.tsx | 87 ++ .../ProposalAction/ProposalAction.types.ts | 5 + .../ProposalAction/hooks/useHandleProposal.ts | 62 ++ .../components/ProposalInfo/ProposalInfo.tsx | 55 ++ .../components/VoteTimer/VoteTimer.tsx | 89 ++ .../ProposalPage/hooks/useGetProposalById.ts | 23 + .../ProposalPage/hooks/useGetUserVote.ts | 26 + .../app/5_pages/ProposalPage/hooks/useVote.ts | 75 ++ .../AddStakeRenderer/AddStakeRenderer.tsx | 17 +- .../NextStepDialog/NextStepDialog.tsx | 108 +++ .../images/ProposalStatuses/icon-active.svg | 11 + .../images/ProposalStatuses/icon-executed.svg | 11 + .../images/ProposalStatuses/icon-pending.svg | 14 + .../images/ProposalStatuses/icon-rejected.svg | 11 + .../images/ProposalStatuses/icon-succeed.svg | 5 + apps/frontend/src/constants/gasLimits.ts | 3 + .../frontend/src/locales/en/translations.json | 128 ++- apps/frontend/src/router.tsx | 14 + apps/frontend/src/store/rxjs/shared-state.ts | 26 + .../src/utils/graphql/rsk/generated.tsx | 404 +++++++++ .../rsk/operations/getProposal.graphql | 57 ++ .../rsk/operations/getProposals.graphql | 55 ++ .../graphql/rsk/operations/getVote.graphql | 16 + packages/contracts/src/abis/governor.json | 777 ++++++++++++++++++ .../contracts/src/contracts/protocol/rsk.ts | 8 + .../src/contracts/protocol/rskTestnet.ts | 8 + packages/ui/src/1_atoms/Bar/Bar.module.css | 20 + packages/ui/src/1_atoms/Bar/Bar.stories.tsx | 34 + packages/ui/src/1_atoms/Bar/Bar.tsx | 39 + packages/ui/src/1_atoms/index.tsx | 1 + yarn.lock | 749 ++++++++++++++++- 81 files changed, 4616 insertions(+), 25 deletions(-) create mode 100644 .changeset/angry-mails-enjoy.md create mode 100644 .changeset/brave-experts-cover.md create mode 100644 .changeset/fifty-baboons-fry.md create mode 100644 .changeset/fresh-goats-begin.md create mode 100644 .changeset/giant-ducks-laugh.md create mode 100644 .changeset/happy-carrots-fold.md create mode 100644 .changeset/many-fishes-hang.md create mode 100644 .changeset/moody-fans-attack.md create mode 100644 .changeset/nervous-swans-lick.md create mode 100644 .changeset/olive-olives-obey.md create mode 100644 .changeset/pink-buckets-rhyme.md create mode 100644 .changeset/pink-monkeys-wash.md create mode 100644 .changeset/proud-rivers-give.md create mode 100644 .changeset/shiny-years-leave.md create mode 100644 .changeset/silver-mayflies-sell.md create mode 100644 .changeset/small-fishes-work.md create mode 100644 .changeset/thin-geckos-fail.md create mode 100644 .changeset/two-ligers-relax.md create mode 100644 .changeset/yellow-tips-sip.md create mode 100644 apps/frontend/src/app/3_organisms/ProposalVotingPower/ProposalVotingPower.tsx create mode 100644 apps/frontend/src/app/3_organisms/ProposalVotingPower/ProposalVotingPower.utils.tsx create mode 100644 apps/frontend/src/app/3_organisms/ProposalVotingResults/ProposalVotingResults.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.constants.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.types.ts create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.utils.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/components/ProposalCardsMobile/ProposalCardsMobile.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/components/ProposalStatus/ProposalStatus.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/components/ProposalTitle/ProposalTitle.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/components/ProposalType/ProposalType.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/components/ProposalViewButton/ProposalViewButton.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/components/Proposals/Proposals.constants.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/components/Proposals/Proposals.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/components/Proposals/Proposals.utils.tsx create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/hooks/useGetProposals.ts create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/hooks/useIsExecutableProposal.ts create mode 100644 apps/frontend/src/app/5_pages/BitocracyPage/hooks/useProposalStatus.ts create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/ProposalPage.tsx create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/ProposalPage.types.ts create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/ProposalPage.utils.ts create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/components/CastVote/CastVote.tsx create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/components/ExecutableDetails/ExecutableDetails.tsx create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/components/ProposalAction/ProposalAction.tsx create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/components/ProposalAction/ProposalAction.types.ts create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/components/ProposalAction/hooks/useHandleProposal.ts create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/components/ProposalInfo/ProposalInfo.tsx create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/components/VoteTimer/VoteTimer.tsx create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/hooks/useGetProposalById.ts create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/hooks/useGetUserVote.ts create mode 100644 apps/frontend/src/app/5_pages/ProposalPage/hooks/useVote.ts create mode 100644 apps/frontend/src/app/5_pages/StakePage/components/NextStepDialog/NextStepDialog.tsx create mode 100644 apps/frontend/src/assets/images/ProposalStatuses/icon-active.svg create mode 100644 apps/frontend/src/assets/images/ProposalStatuses/icon-executed.svg create mode 100644 apps/frontend/src/assets/images/ProposalStatuses/icon-pending.svg create mode 100644 apps/frontend/src/assets/images/ProposalStatuses/icon-rejected.svg create mode 100644 apps/frontend/src/assets/images/ProposalStatuses/icon-succeed.svg create mode 100644 apps/frontend/src/utils/graphql/rsk/operations/getProposal.graphql create mode 100644 apps/frontend/src/utils/graphql/rsk/operations/getProposals.graphql create mode 100644 apps/frontend/src/utils/graphql/rsk/operations/getVote.graphql create mode 100644 packages/contracts/src/abis/governor.json create mode 100644 packages/ui/src/1_atoms/Bar/Bar.module.css create mode 100644 packages/ui/src/1_atoms/Bar/Bar.stories.tsx create mode 100644 packages/ui/src/1_atoms/Bar/Bar.tsx diff --git a/.changeset/angry-mails-enjoy.md b/.changeset/angry-mails-enjoy.md new file mode 100644 index 000000000..2e34c5206 --- /dev/null +++ b/.changeset/angry-mails-enjoy.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3196: add voting tooltips to Voting proposals page diff --git a/.changeset/brave-experts-cover.md b/.changeset/brave-experts-cover.md new file mode 100644 index 000000000..9138b9811 --- /dev/null +++ b/.changeset/brave-experts-cover.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3319: Fix proposal type diff --git a/.changeset/fifty-baboons-fry.md b/.changeset/fifty-baboons-fry.md new file mode 100644 index 000000000..a46c02c59 --- /dev/null +++ b/.changeset/fifty-baboons-fry.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3012: Bitocracy alerts diff --git a/.changeset/fresh-goats-begin.md b/.changeset/fresh-goats-begin.md new file mode 100644 index 000000000..14d7d0375 --- /dev/null +++ b/.changeset/fresh-goats-begin.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3225: Open proposal on row click diff --git a/.changeset/giant-ducks-laugh.md b/.changeset/giant-ducks-laugh.md new file mode 100644 index 000000000..ed61f4e54 --- /dev/null +++ b/.changeset/giant-ducks-laugh.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3195: add voting power section diff --git a/.changeset/happy-carrots-fold.md b/.changeset/happy-carrots-fold.md new file mode 100644 index 000000000..9481d044e --- /dev/null +++ b/.changeset/happy-carrots-fold.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3334: Fix cast vote mobile diff --git a/.changeset/many-fishes-hang.md b/.changeset/many-fishes-hang.md new file mode 100644 index 000000000..e4bcbcdd2 --- /dev/null +++ b/.changeset/many-fishes-hang.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +fix: Bitocracy proposal issues diff --git a/.changeset/moody-fans-attack.md b/.changeset/moody-fans-attack.md new file mode 100644 index 000000000..b8a7a825e --- /dev/null +++ b/.changeset/moody-fans-attack.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3327: Fix status labels diff --git a/.changeset/nervous-swans-lick.md b/.changeset/nervous-swans-lick.md new file mode 100644 index 000000000..48772e832 --- /dev/null +++ b/.changeset/nervous-swans-lick.md @@ -0,0 +1,5 @@ +--- +'frontend': patch +--- + +Bitocracy page diff --git a/.changeset/olive-olives-obey.md b/.changeset/olive-olives-obey.md new file mode 100644 index 000000000..4b0a1d92c --- /dev/null +++ b/.changeset/olive-olives-obey.md @@ -0,0 +1,6 @@ +--- +"frontend": patch +"@sovryn/contracts": patch +--- + +SOV-3239: Support/Reject button in Cast your vote diff --git a/.changeset/pink-buckets-rhyme.md b/.changeset/pink-buckets-rhyme.md new file mode 100644 index 000000000..d761c62b8 --- /dev/null +++ b/.changeset/pink-buckets-rhyme.md @@ -0,0 +1,6 @@ +--- +"frontend": patch +"@sovryn/ui": patch +--- + +SOV-3010: Individual Proposal page diff --git a/.changeset/pink-monkeys-wash.md b/.changeset/pink-monkeys-wash.md new file mode 100644 index 000000000..bb2ac7362 --- /dev/null +++ b/.changeset/pink-monkeys-wash.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3011: Export CSV diff --git a/.changeset/proud-rivers-give.md b/.changeset/proud-rivers-give.md new file mode 100644 index 000000000..9ef61b67d --- /dev/null +++ b/.changeset/proud-rivers-give.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-2922: voting proposals page diff --git a/.changeset/shiny-years-leave.md b/.changeset/shiny-years-leave.md new file mode 100644 index 000000000..3748c2bbf --- /dev/null +++ b/.changeset/shiny-years-leave.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3226: Fix bitocracy alerts button diff --git a/.changeset/silver-mayflies-sell.md b/.changeset/silver-mayflies-sell.md new file mode 100644 index 000000000..24a162c6e --- /dev/null +++ b/.changeset/silver-mayflies-sell.md @@ -0,0 +1,5 @@ +--- +'@sovryn/ui': patch +--- + +SOV-3008: add bar component with threshold option diff --git a/.changeset/small-fishes-work.md b/.changeset/small-fishes-work.md new file mode 100644 index 000000000..911c988f1 --- /dev/null +++ b/.changeset/small-fishes-work.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3312: Fix small bugs diff --git a/.changeset/thin-geckos-fail.md b/.changeset/thin-geckos-fail.md new file mode 100644 index 000000000..583ec7e24 --- /dev/null +++ b/.changeset/thin-geckos-fail.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3288: Show the current state of voting diff --git a/.changeset/two-ligers-relax.md b/.changeset/two-ligers-relax.md new file mode 100644 index 000000000..8b2fa76d3 --- /dev/null +++ b/.changeset/two-ligers-relax.md @@ -0,0 +1,5 @@ +--- +"frontend": patch +--- + +SOV-3013: Voting - Next Steps modal diff --git a/.changeset/yellow-tips-sip.md b/.changeset/yellow-tips-sip.md new file mode 100644 index 000000000..60b8e9da2 --- /dev/null +++ b/.changeset/yellow-tips-sip.md @@ -0,0 +1,6 @@ +--- +"frontend": patch +"@sovryn/contracts": patch +--- + +SOV-3009: voting actions diff --git a/apps/frontend/package.json b/apps/frontend/package.json index 1e5fd4b43..c45b90c31 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -45,10 +45,14 @@ "react-dom": "18.2.0", "react-helmet-async": "1.3.0", "react-i18next": "12.0.0", + "react-markdown": "8.0.7", "react-router-dom": "6.4.2", "react-scripts": "5.0.1", + "react-timer-hook": "3.0.7", "reactjs-localstorage": "1.0.1", + "remark-gfm": "3.0.1", "rxjs": "7.5.6", + "sanitize-html": "2.11.0", "socket.io-client": "4.5.4", "utf8": "^3.0.0" }, diff --git a/apps/frontend/src/app/2_molecules/ConnectWalletButton/ConnectWalletButton.tsx b/apps/frontend/src/app/2_molecules/ConnectWalletButton/ConnectWalletButton.tsx index 09f6c4505..ab21a7670 100644 --- a/apps/frontend/src/app/2_molecules/ConnectWalletButton/ConnectWalletButton.tsx +++ b/apps/frontend/src/app/2_molecules/ConnectWalletButton/ConnectWalletButton.tsx @@ -1,4 +1,4 @@ -import React, { FC, PropsWithChildren, useCallback, useState } from 'react'; +import React, { FC, PropsWithChildren, useCallback } from 'react'; import { t } from 'i18next'; import { nanoid } from 'nanoid'; @@ -12,9 +12,9 @@ import { WalletIdentity, } from '@sovryn/ui'; -import { EmailNotificationSettingsDialog } from '../../3_organisms/EmailNotificationSettingsDialog/EmailNotificationSettingsDialog'; import { useNotificationContext } from '../../../contexts/NotificationContext'; import { translations } from '../../../locales/i18n'; +import { sharedState } from '../../../store/rxjs/shared-state'; export type ConnectWalletButtonProps = { onConnect: () => void; @@ -35,7 +35,6 @@ export const ConnectWalletButton: FC< className, dataAttribute, }) => { - const [open, setOpen] = useState(false); const { addNotification } = useNotificationContext(); const onCopyAddress = useCallback(() => { @@ -48,6 +47,11 @@ export const ConnectWalletButton: FC< }); }, [addNotification]); + const handleSettingsClick = useCallback( + () => sharedState.actions.openEmailNotificationSettingsDialog(), + [], + ); + if (!address) { return (