Skip to content

Commit

Permalink
Bitocracy Page (#543)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Victor Creed <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

---------

Co-authored-by: Pietro Maximoff <[email protected]>
Co-authored-by: Victor Creed <[email protected]>
Co-authored-by: Victor Creed <[email protected]>
Co-authored-by: tiltom <[email protected]>

* 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 <[email protected]>
Co-authored-by: Victor Creed <[email protected]>
Co-authored-by: tiltom <[email protected]>
Co-authored-by: tiltom <[email protected]>
Co-authored-by: Victor Creed <[email protected]>
Co-authored-by: Peiman <[email protected]>
  • Loading branch information
7 people authored Oct 11, 2023
1 parent 8c3d97e commit 3738213
Show file tree
Hide file tree
Showing 81 changed files with 4,616 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-mails-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3196: add voting tooltips to Voting proposals page
5 changes: 5 additions & 0 deletions .changeset/brave-experts-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3319: Fix proposal type
5 changes: 5 additions & 0 deletions .changeset/fifty-baboons-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3012: Bitocracy alerts
5 changes: 5 additions & 0 deletions .changeset/fresh-goats-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3225: Open proposal on row click
5 changes: 5 additions & 0 deletions .changeset/giant-ducks-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3195: add voting power section
5 changes: 5 additions & 0 deletions .changeset/happy-carrots-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3334: Fix cast vote mobile
5 changes: 5 additions & 0 deletions .changeset/many-fishes-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

fix: Bitocracy proposal issues
5 changes: 5 additions & 0 deletions .changeset/moody-fans-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3327: Fix status labels
5 changes: 5 additions & 0 deletions .changeset/nervous-swans-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'frontend': patch
---

Bitocracy page
6 changes: 6 additions & 0 deletions .changeset/olive-olives-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"frontend": patch
"@sovryn/contracts": patch
---

SOV-3239: Support/Reject button in Cast your vote
6 changes: 6 additions & 0 deletions .changeset/pink-buckets-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"frontend": patch
"@sovryn/ui": patch
---

SOV-3010: Individual Proposal page
5 changes: 5 additions & 0 deletions .changeset/pink-monkeys-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3011: Export CSV
5 changes: 5 additions & 0 deletions .changeset/proud-rivers-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-2922: voting proposals page
5 changes: 5 additions & 0 deletions .changeset/shiny-years-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3226: Fix bitocracy alerts button
5 changes: 5 additions & 0 deletions .changeset/silver-mayflies-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sovryn/ui': patch
---

SOV-3008: add bar component with threshold option
5 changes: 5 additions & 0 deletions .changeset/small-fishes-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3312: Fix small bugs
5 changes: 5 additions & 0 deletions .changeset/thin-geckos-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3288: Show the current state of voting
5 changes: 5 additions & 0 deletions .changeset/two-ligers-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3013: Voting - Next Steps modal
6 changes: 6 additions & 0 deletions .changeset/yellow-tips-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"frontend": patch
"@sovryn/contracts": patch
---

SOV-3009: voting actions
4 changes: 4 additions & 0 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -35,7 +35,6 @@ export const ConnectWalletButton: FC<
className,
dataAttribute,
}) => {
const [open, setOpen] = useState(false);
const { addNotification } = useNotificationContext();

const onCopyAddress = useCallback(() => {
Expand All @@ -48,6 +47,11 @@ export const ConnectWalletButton: FC<
});
}, [addNotification]);

const handleSettingsClick = useCallback(
() => sharedState.actions.openEmailNotificationSettingsDialog(),
[],
);

if (!address) {
return (
<Button
Expand Down Expand Up @@ -83,9 +87,9 @@ export const ConnectWalletButton: FC<
/>
</Link>
<MenuItem
text={t(translations.connectWalletButton.settings)}
onClick={() => setOpen(true)}
dataAttribute={`${dataAttribute}-menu-settings`}
text={t(translations.connectWalletButton.notifications)}
onClick={handleSettingsClick}
dataAttribute={`${dataAttribute}-menu-notifications`}
/>
</Menu>
}
Expand All @@ -94,10 +98,6 @@ export const ConnectWalletButton: FC<
disconnect: t(translations.connectWalletButton.disconnect),
}}
/>
<EmailNotificationSettingsDialog
isOpen={open}
onClose={() => setOpen(false)}
/>
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ export enum NotificationMessageType {
LoanMarginCall = 'LoanMarginCall',
LoanLiquidation = 'LoanLiquidation',
LoanMarginCallUndercollateralized = 'LoanMarginCallUndercollateralized',
BitocracyVote = 'BitocracyVote',
}

export enum AlertGroup {
MarginCalls = 'MarginCalls',
Liquidations = 'Liquidations',
StabilityPool = 'StabilityPool',
System = 'System',
BitocracyVote = 'BitocracyVote',
}

export const AlertGroupToNotificationsMapping: Record<
Expand All @@ -57,6 +59,7 @@ export const AlertGroupToNotificationsMapping: Record<
NotificationMessageType.ZeroLowTcr,
NotificationMessageType.ZeroRecovery,
],
BitocracyVote: [NotificationMessageType.BitocracyVote],
};

export type Notification = {
Expand Down Expand Up @@ -121,4 +124,8 @@ export const defaultSubscriptionsArray: Notification[] = [
notification: NotificationMessageType.LoanLiquidation,
isSubscribed: false,
},
{
notification: NotificationMessageType.BitocracyVote,
isSubscribed: false,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ export const Subscriptions: FC<SubscriptionsProps> = ({
liquidationsToggle,
stabilityPoolToggle,
systemToggle,
bitocracyToggle,
} = useEmailNotificationSettingsContext();

const {
marginCallsToggleHandler,
liquidationsToggleHandler,
stabilityPoolToggleHandler,
systemToggleHandler,
bitocracyToggleHandler,
} = useHandleSubscriptions();

const items: ToggleItem[] = useMemo(
Expand All @@ -64,6 +66,13 @@ export const Subscriptions: FC<SubscriptionsProps> = ({
dataAttributeSuffix: 'stability',
className: 'mb-7',
},
{
checked: bitocracyToggle,
onChange: bitocracyToggleHandler,
label: t(baseTranslationPath.bitocracyToggle),
dataAttributeSuffix: 'bitocracy',
className: 'mb-7',
},
{
checked: systemToggle,
onChange: systemToggleHandler,
Expand All @@ -80,6 +89,8 @@ export const Subscriptions: FC<SubscriptionsProps> = ({
stabilityPoolToggleHandler,
systemToggle,
systemToggleHandler,
bitocracyToggle,
bitocracyToggleHandler,
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type EmailNotificationSettingsContextValue = {
setStabilityPoolToggle: React.Dispatch<React.SetStateAction<boolean>>;
systemToggle: boolean;
setSystemToggle: React.Dispatch<React.SetStateAction<boolean>>;
bitocracyToggle: boolean;
setBitocracyToggle: React.Dispatch<React.SetStateAction<boolean>>;
haveSubscriptionsBeenUpdated: boolean;
};

Expand All @@ -42,6 +44,8 @@ const defaultContextValue: EmailNotificationSettingsContextValue = {
setStabilityPoolToggle: noop,
systemToggle: false,
setSystemToggle: noop,
bitocracyToggle: false,
setBitocracyToggle: noop,
haveSubscriptionsBeenUpdated: false,
};

Expand Down Expand Up @@ -69,6 +73,7 @@ export const EmailNotificationSettingsContextProvider: React.FC<
const [liquidationsToggle, setLiquidationsToggle] = useState(false);
const [stabilityPoolToggle, setStabilityPoolToggle] = useState(false);
const [systemToggle, setSystemToggle] = useState(false);
const [bitocracyToggle, setBitocracyToggle] = useState(false);

const resetSubscriptions = useCallback(() => {
setSubscriptions(defaultContextValue.subscriptions);
Expand Down Expand Up @@ -117,6 +122,8 @@ export const EmailNotificationSettingsContextProvider: React.FC<
setStabilityPoolToggle,
systemToggle,
setSystemToggle,
bitocracyToggle,
setBitocracyToggle,
haveSubscriptionsBeenUpdated,
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const useHandleSubscriptions = () => {
setStabilityPoolToggle,
setSystemToggle,
setServerSubscriptionsState,
setBitocracyToggle,
} = useEmailNotificationSettingsContext();

const resetSubscriptions = useCallback(() => {
Expand All @@ -28,12 +29,14 @@ export const useHandleSubscriptions = () => {
setLiquidationsToggle(false);
setStabilityPoolToggle(false);
setSystemToggle(false);
setBitocracyToggle(false);
}, [
resetSubscriptionsState,
setMarginCallsToggle,
setLiquidationsToggle,
setStabilityPoolToggle,
setSystemToggle,
setBitocracyToggle,
]);

const withDefaultSubscriptions = useCallback(
Expand Down Expand Up @@ -75,6 +78,9 @@ export const useHandleSubscriptions = () => {
setSystemToggle(
isSubscribedToGroup(AlertGroup.System, parsedSubscriptions),
);
setBitocracyToggle(
isSubscribedToGroup(AlertGroup.BitocracyVote, parsedSubscriptions),
);
},
[
withDefaultSubscriptions,
Expand All @@ -84,6 +90,7 @@ export const useHandleSubscriptions = () => {
setLiquidationsToggle,
setStabilityPoolToggle,
setSystemToggle,
setBitocracyToggle,
],
);

Expand Down Expand Up @@ -145,12 +152,18 @@ export const useHandleSubscriptions = () => {
setSystemToggle(prevValue => !prevValue);
}, [updateSubscriptions, setSystemToggle]);

const bitocracyToggleHandler = useCallback(() => {
updateSubscriptions(AlertGroup.BitocracyVote);
setBitocracyToggle(prevValue => !prevValue);
}, [updateSubscriptions, setBitocracyToggle]);

return {
resetSubscriptions,
parseSubscriptionsResponse,
marginCallsToggleHandler,
liquidationsToggleHandler,
stabilityPoolToggleHandler,
systemToggleHandler,
bitocracyToggleHandler,
};
};
4 changes: 4 additions & 0 deletions apps/frontend/src/app/3_organisms/Header/Header.constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ export const menuItemsMapping: MenuItem[] = [
text: t(translations.header.nav.convert),
url: '/convert',
},
{
text: t(translations.header.nav.bitocracy),
url: '/bitocracy',
},
];
Loading

0 comments on commit 3738213

Please sign in to comment.