From b645a1bbc70e8de2bd004e3a73840ead310ece28 Mon Sep 17 00:00:00 2001 From: Matej Lubej Date: Thu, 28 Mar 2024 07:56:41 +0100 Subject: [PATCH 1/2] Upcoming vote --- README.md | 4 - frontend/src/components/Layout/index.tsx | 8 +- frontend/src/components/MascotCard/index.tsx | 3 + .../pages/UpcomingVotePage/index.module.css | 81 +++++++++++++++++++ frontend/src/pages/UpcomingVotePage/index.tsx | 52 ++++++++++++ frontend/src/providers/AppStateContext.ts | 1 + frontend/src/providers/AppStateProvider.tsx | 13 ++- frontend/src/providers/Web3Provider.tsx | 8 +- frontend/src/utils/errors.ts | 6 ++ 9 files changed, 166 insertions(+), 10 deletions(-) create mode 100644 frontend/src/pages/UpcomingVotePage/index.module.css create mode 100644 frontend/src/pages/UpcomingVotePage/index.tsx diff --git a/README.md b/README.md index 3b45f66..fc6854b 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,6 @@ different aspect of the Oasis Network as follows: - Desert Owl represents _Knowledge_ - Fennec Fox stands for _Privacy_ -The voting process is open to all Sapphire wallets holding a minimum of 100 ROSE tokens. The vote commences on _March -20, 2024, at 4:00:00 PM GMT+1_ and concludes on _March 27, 2024, at 4:00:00 PM GMT+1_. At the closure of the vote, the -results will be promptly available and no further voting will be permitted. -

(back to top)

diff --git a/frontend/src/components/Layout/index.tsx b/frontend/src/components/Layout/index.tsx index 4f85c85..391ba9c 100644 --- a/frontend/src/components/Layout/index.tsx +++ b/frontend/src/components/Layout/index.tsx @@ -9,10 +9,11 @@ import { Button } from '../Button' import { StringUtils } from '../../utils/string.utils' import { useInView } from 'react-intersection-observer' import { LayoutBase } from '../LayoutBase' +import { UpcomingVotePage } from '../../pages/UpcomingVotePage' export const Layout: FC = () => { const { - state: { isInitialLoading, appError, isMobileScreen }, + state: { isInitialLoading, appError, isMobileScreen, isUpcomingVote }, clearAppError, } = useAppState() @@ -32,7 +33,7 @@ export const Layout: FC = () => { )} > - + {!isInitialLoading && !isUpcomingVote && }

Oasis Mascot

@@ -53,7 +54,8 @@ export const Layout: FC = () => { {isInitialLoading && ( Fetching poll...} /> )} - {!isInitialLoading && !appError && } + {!isInitialLoading && !appError && !isUpcomingVote && } + {!isInitialLoading && !appError && isUpcomingVote && }
diff --git a/frontend/src/components/MascotCard/index.tsx b/frontend/src/components/MascotCard/index.tsx index 9284318..02f44b2 100644 --- a/frontend/src/components/MascotCard/index.tsx +++ b/frontend/src/components/MascotCard/index.tsx @@ -13,6 +13,7 @@ interface Props { actions?: ReactElement selected?: boolean orientation?: MascotCardOrientation + className?: string } const orientationMap: Record = { @@ -27,6 +28,7 @@ export const MascotCard: FC = ({ actions, selected, orientation = 'vertical', + className, }) => { const { state: { isDesktopScreen }, @@ -36,6 +38,7 @@ export const MascotCard: FC = ({
{ + const { + state: { isMobileScreen, isDesktopScreen }, + } = useAppState() + + const headerText = ( + <> + Read more about the campaign  + + on our website + + . + + ) + + return ( + <> + {isMobileScreen &&

{headerText}

} + + {isDesktopScreen &&

{headerText}

} +
+ {POLL_CHOICES.map(({ name, description, imagePath }) => ( + } + className={classes.mascotCard} + /> + ))} +
+

+ Thank you for your vote! We’re running a second ballot in April. Please stay tuned as we announce + the new voting period. +

+
+ + ) +} diff --git a/frontend/src/providers/AppStateContext.ts b/frontend/src/providers/AppStateContext.ts index f73663d..558744f 100644 --- a/frontend/src/providers/AppStateContext.ts +++ b/frontend/src/providers/AppStateContext.ts @@ -9,6 +9,7 @@ export interface AppStateProviderState { appError: string isDesktopScreen: boolean isMobileScreen: boolean + isUpcomingVote: boolean } export interface AppStateProviderContext { diff --git a/frontend/src/providers/AppStateProvider.tsx b/frontend/src/providers/AppStateProvider.tsx index 71e1c7c..b1cea8d 100644 --- a/frontend/src/providers/AppStateProvider.tsx +++ b/frontend/src/providers/AppStateProvider.tsx @@ -6,7 +6,7 @@ import { StorageKeys } from '../constants/storage-keys' import { MascotChoices } from '../types' import { NumberUtils } from '../utils/number.utils' import { useMediaQuery } from 'react-responsive' -import { toErrorString } from '../utils/errors' +import { UpcomingPollError, toErrorString } from '../utils/errors' const localStorageStore = storage() @@ -18,6 +18,7 @@ const appStateProviderInitialState: AppStateProviderState = { appError: '', isMobileScreen: false, isDesktopScreen: false, + isUpcomingVote: false, } export const AppStateContextProvider: FC = ({ children }) => { @@ -81,7 +82,15 @@ export const AppStateContextProvider: FC = ({ children }) => } init().catch(ex => { - setAppError(toErrorString(ex as Error)) + if (ex instanceof UpcomingPollError) { + setState(prevState => ({ + ...prevState, + isInitialLoading: false, + isUpcomingVote: true, + })) + } else { + setAppError(toErrorString(ex as Error)) + } }) // eslint-disable-next-line react-hooks/exhaustive-deps }, [isVoidSignerConnected]) diff --git a/frontend/src/providers/Web3Provider.tsx b/frontend/src/providers/Web3Provider.tsx index 26bba6b..0d5af8b 100644 --- a/frontend/src/providers/Web3Provider.tsx +++ b/frontend/src/providers/Web3Provider.tsx @@ -12,11 +12,12 @@ import { handleKnownContractCallExceptionErrors, handleKnownErrors, handleKnownEthersErrors, + UpcomingPollError, UnknownNetworkError, } from '../utils/errors' import { Web3Context, Web3ProviderContext, Web3ProviderState } from './Web3Context' import { useEIP1193 } from '../hooks/useEIP1193' -import { BigNumberish, BrowserProvider, JsonRpcProvider, toBeHex } from 'ethers' +import { BigNumberish, BrowserProvider, JsonRpcProvider, toBeHex, ZeroAddress } from 'ethers' import { PollManager__factory } from '@oasisprotocol/dapp-voting-backend/src/contracts' const EMPTY_IN_DATA = new Uint8Array([]) @@ -208,6 +209,11 @@ export const Web3ContextProvider: FC = ({ children }) => { throw new Error('[pollManagerWithoutSigner] not initialized!') } + // TODO: Special case for zero address proposalId + if (VITE_PROPOSAL_ID === ZeroAddress) { + throw new UpcomingPollError() + } + return await pollManagerVoidSigner.PROPOSALS(toBeHex(VITE_PROPOSAL_ID)).catch(handleKnownErrors) } diff --git a/frontend/src/utils/errors.ts b/frontend/src/utils/errors.ts index b6c2a3b..8db019b 100644 --- a/frontend/src/utils/errors.ts +++ b/frontend/src/utils/errors.ts @@ -8,6 +8,12 @@ export class UnknownNetworkError extends Error { } } +export class UpcomingPollError extends Error { + constructor(message = '') { + super(message) + } +} + export interface EIP1193Error extends Error { code: number } From a1ddc5dd9a667e1d498e40137a776ade8f05a63d Mon Sep 17 00:00:00 2001 From: Matej Lubej Date: Thu, 28 Mar 2024 11:49:16 +0100 Subject: [PATCH 2/2] Set contracts to ZeroAddress - set start time to 0 --- frontend/.env.production | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/.env.production b/frontend/.env.production index 7b0c191..6a9fc9f 100644 --- a/frontend/.env.production +++ b/frontend/.env.production @@ -1,12 +1,12 @@ VITE_NETWORK=23294 VITE_WEB3_GATEWAY=https://sapphire.oasis.io -VITE_PROPOSAL_START_TIME=1710946800 +VITE_PROPOSAL_START_TIME=0 -VITE_CONTRACT_ACL_ALLOWALL= -VITE_CONTRACT_ACL_NATIVEBALANCE= -VITE_CONTRACT_POLLMANAGER= -VITE_CONTRACT_POLLMANAGER_ACL= -VITE_PROPOSAL_ID= +VITE_CONTRACT_ACL_ALLOWALL=0x0000000000000000000000000000000000000000 +VITE_CONTRACT_ACL_NATIVEBALANCE=0x0000000000000000000000000000000000000000 +VITE_CONTRACT_POLLMANAGER=0x0000000000000000000000000000000000000000 +VITE_CONTRACT_POLLMANAGER_ACL=0x0000000000000000000000000000000000000000 +VITE_PROPOSAL_ID=0x0000000000000000000000000000000000000000 VITE_REACT_APP_BUILD_VERSION=$REACT_APP_BUILD_SHA VITE_REACT_APP_BUILD_DATETIME=$REACT_APP_BUILD_DATETIME \ No newline at end of file