From 29069b3b49213a0df94cd2fefb6cebb492027a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 23 Feb 2024 11:35:24 +0100 Subject: [PATCH 01/82] fix get drep voting power --- .../frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts index aade95029..48729a672 100644 --- a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts @@ -5,14 +5,14 @@ import { useCardano } from "@context"; import { getDRepVotingPower } from "@services"; export const useGetDRepVotingPowerQuery = () => { - const { dRepID } = useCardano(); + const { dRepID, dRep } = useCardano(); const { data, isLoading } = useQuery({ queryKey: QUERY_KEYS.useGetDRepVotingPowerKey, queryFn: async () => { return await getDRepVotingPower({ dRepID }); }, - enabled: !!dRepID, + enabled: !!dRepID && dRep?.isRegistered, }); return { dRepVotingPower: data, isDRepVotingPowerLoading: isLoading }; From 2e3a764fa9af99a4c8e45fd98cd69e8dd8962205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 23 Feb 2024 12:46:10 +0100 Subject: [PATCH 02/82] add keys --- .../frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts index 48729a672..5df7a3af1 100644 --- a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts @@ -8,7 +8,7 @@ export const useGetDRepVotingPowerQuery = () => { const { dRepID, dRep } = useCardano(); const { data, isLoading } = useQuery({ - queryKey: QUERY_KEYS.useGetDRepVotingPowerKey, + queryKey: [QUERY_KEYS.useGetDRepVotingPowerKey, dRepID, dRep?.isRegistered], queryFn: async () => { return await getDRepVotingPower({ dRepID }); }, From 7ac847f9e5fa38b074d56f1c78753751f0220e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 23 Feb 2024 14:09:31 +0100 Subject: [PATCH 03/82] [#280] Fix get drep voting power request --- CHANGELOG.md | 1 + .../frontend/src/hooks/mutations/useDRepRegisterMutation.ts | 6 +++++- .../frontend/src/hooks/mutations/useDRepRetireMutation.ts | 6 +++++- .../src/hooks/queries/useGetDRepVotingPowerQuery.ts | 2 +- govtool/frontend/src/models/api.ts | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e9e33261..90954bacd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ changes. - Fixed vote calculation problems related to NoConfidence DRep [Issue 59](https://github.com/IntersectMBO/govtool/issues/59) - Fixed ada-holder/get-current-delegation error when delegated to NoConfidence or AlwaysAbstain dreps. [Issue 82](https://github.com/IntersectMBO/govtool/issues/82) - Fixed deployment scripts to address [Issue 171](https://github.com/IntersectMBO/govtool/issues/171). +- Fixed get drep voting power incorrectly executed endpoint [Issue 280](https://github.com/IntersectMBO/govtool/issues/280) ### Changed - Update Cardano-Serialization-Lib to 12.0.0-alpha.16 [Issue 156](https://github.com/IntersectMBO/govtool/issues/156) diff --git a/govtool/frontend/src/hooks/mutations/useDRepRegisterMutation.ts b/govtool/frontend/src/hooks/mutations/useDRepRegisterMutation.ts index 76b79287d..d757d09b2 100644 --- a/govtool/frontend/src/hooks/mutations/useDRepRegisterMutation.ts +++ b/govtool/frontend/src/hooks/mutations/useDRepRegisterMutation.ts @@ -7,7 +7,11 @@ export const useDRepRegisterMutation = () => { const { mutateAsync, isLoading } = useMutation(postDRepRegister, { onSuccess: () => { - setDRep({ deposit: 100, isRegistered: true, wasRegistered: false }); + setDRep({ + deposit: 100, + isRegistered: true, + wasRegistered: false, + }); }, }); diff --git a/govtool/frontend/src/hooks/mutations/useDRepRetireMutation.ts b/govtool/frontend/src/hooks/mutations/useDRepRetireMutation.ts index b3697c714..8bf8973e1 100644 --- a/govtool/frontend/src/hooks/mutations/useDRepRetireMutation.ts +++ b/govtool/frontend/src/hooks/mutations/useDRepRetireMutation.ts @@ -8,7 +8,11 @@ export const useDRepRetireMutation = () => { const { mutateAsync } = useMutation(postDRepRetire, { onSuccess: () => { - setDRep({ deposit: 100, wasRegistered: true, isRegistered: false }); + setDRep({ + deposit: 100, + wasRegistered: true, + isRegistered: false, + }); addSuccessAlert("DRep retired."); }, }); diff --git a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts index 5df7a3af1..836946aa9 100644 --- a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts @@ -12,7 +12,7 @@ export const useGetDRepVotingPowerQuery = () => { queryFn: async () => { return await getDRepVotingPower({ dRepID }); }, - enabled: !!dRepID && dRep?.isRegistered, + enabled: !!dRepID && !!dRep?.isRegistered, }); return { dRepVotingPower: data, isDRepVotingPowerLoading: isLoading }; diff --git a/govtool/frontend/src/models/api.ts b/govtool/frontend/src/models/api.ts index 03fec9e2b..5281e2a9e 100644 --- a/govtool/frontend/src/models/api.ts +++ b/govtool/frontend/src/models/api.ts @@ -1,7 +1,7 @@ export interface DRepInfo { isRegistered: boolean; wasRegistered: boolean; - deposit: number; + deposit: number | null; } export interface DRepData { From 965c021c3f8a102f2e7c928a66c2435e536dc3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 23 Feb 2024 11:35:24 +0100 Subject: [PATCH 04/82] fix get drep voting power --- .../frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts index aade95029..48729a672 100644 --- a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts @@ -5,14 +5,14 @@ import { useCardano } from "@context"; import { getDRepVotingPower } from "@services"; export const useGetDRepVotingPowerQuery = () => { - const { dRepID } = useCardano(); + const { dRepID, dRep } = useCardano(); const { data, isLoading } = useQuery({ queryKey: QUERY_KEYS.useGetDRepVotingPowerKey, queryFn: async () => { return await getDRepVotingPower({ dRepID }); }, - enabled: !!dRepID, + enabled: !!dRepID && dRep?.isRegistered, }); return { dRepVotingPower: data, isDRepVotingPowerLoading: isLoading }; From 602c0835fb102fb8218423d1a6927db3c6d2acac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Fri, 23 Feb 2024 12:46:10 +0100 Subject: [PATCH 05/82] add keys --- .../frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts index 48729a672..5df7a3af1 100644 --- a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts @@ -8,7 +8,7 @@ export const useGetDRepVotingPowerQuery = () => { const { dRepID, dRep } = useCardano(); const { data, isLoading } = useQuery({ - queryKey: QUERY_KEYS.useGetDRepVotingPowerKey, + queryKey: [QUERY_KEYS.useGetDRepVotingPowerKey, dRepID, dRep?.isRegistered], queryFn: async () => { return await getDRepVotingPower({ dRepID }); }, From e18baa1b111a618bb2cc1f4c2d24ebb726eff4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 23 Feb 2024 14:09:31 +0100 Subject: [PATCH 06/82] [#280] Fix get drep voting power request --- CHANGELOG.md | 1 + .../frontend/src/hooks/mutations/useDRepRegisterMutation.ts | 6 +++++- .../frontend/src/hooks/mutations/useDRepRetireMutation.ts | 6 +++++- .../src/hooks/queries/useGetDRepVotingPowerQuery.ts | 2 +- govtool/frontend/src/models/api.ts | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e9e33261..90954bacd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ changes. - Fixed vote calculation problems related to NoConfidence DRep [Issue 59](https://github.com/IntersectMBO/govtool/issues/59) - Fixed ada-holder/get-current-delegation error when delegated to NoConfidence or AlwaysAbstain dreps. [Issue 82](https://github.com/IntersectMBO/govtool/issues/82) - Fixed deployment scripts to address [Issue 171](https://github.com/IntersectMBO/govtool/issues/171). +- Fixed get drep voting power incorrectly executed endpoint [Issue 280](https://github.com/IntersectMBO/govtool/issues/280) ### Changed - Update Cardano-Serialization-Lib to 12.0.0-alpha.16 [Issue 156](https://github.com/IntersectMBO/govtool/issues/156) diff --git a/govtool/frontend/src/hooks/mutations/useDRepRegisterMutation.ts b/govtool/frontend/src/hooks/mutations/useDRepRegisterMutation.ts index 76b79287d..d757d09b2 100644 --- a/govtool/frontend/src/hooks/mutations/useDRepRegisterMutation.ts +++ b/govtool/frontend/src/hooks/mutations/useDRepRegisterMutation.ts @@ -7,7 +7,11 @@ export const useDRepRegisterMutation = () => { const { mutateAsync, isLoading } = useMutation(postDRepRegister, { onSuccess: () => { - setDRep({ deposit: 100, isRegistered: true, wasRegistered: false }); + setDRep({ + deposit: 100, + isRegistered: true, + wasRegistered: false, + }); }, }); diff --git a/govtool/frontend/src/hooks/mutations/useDRepRetireMutation.ts b/govtool/frontend/src/hooks/mutations/useDRepRetireMutation.ts index b3697c714..8bf8973e1 100644 --- a/govtool/frontend/src/hooks/mutations/useDRepRetireMutation.ts +++ b/govtool/frontend/src/hooks/mutations/useDRepRetireMutation.ts @@ -8,7 +8,11 @@ export const useDRepRetireMutation = () => { const { mutateAsync } = useMutation(postDRepRetire, { onSuccess: () => { - setDRep({ deposit: 100, wasRegistered: true, isRegistered: false }); + setDRep({ + deposit: 100, + wasRegistered: true, + isRegistered: false, + }); addSuccessAlert("DRep retired."); }, }); diff --git a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts index 5df7a3af1..836946aa9 100644 --- a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts @@ -12,7 +12,7 @@ export const useGetDRepVotingPowerQuery = () => { queryFn: async () => { return await getDRepVotingPower({ dRepID }); }, - enabled: !!dRepID && dRep?.isRegistered, + enabled: !!dRepID && !!dRep?.isRegistered, }); return { dRepVotingPower: data, isDRepVotingPowerLoading: isLoading }; diff --git a/govtool/frontend/src/models/api.ts b/govtool/frontend/src/models/api.ts index 03fec9e2b..5281e2a9e 100644 --- a/govtool/frontend/src/models/api.ts +++ b/govtool/frontend/src/models/api.ts @@ -1,7 +1,7 @@ export interface DRepInfo { isRegistered: boolean; wasRegistered: boolean; - deposit: number; + deposit: number | null; } export interface DRepData { From 3d96d83232f946be940b18eca443b9d75c345162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Mon, 26 Feb 2024 15:20:54 +0100 Subject: [PATCH 07/82] [#265] make button disabled when tries to connect --- CHANGELOG.md | 1 + .../src/components/molecules/WalletOption.tsx | 81 ++++++++++++------- govtool/frontend/src/context/wallet.tsx | 7 ++ 3 files changed, 61 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90954bacd..b80f9c5f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ changes. - i18next library added to FE [Issue 80](https://github.com/IntersectMBO/govtool/issues/80) ### Fixed +- Fix make button disble when wallet tries connect [Issue 265](https://github.com/IntersectMBO/govtool/issues/265) - Fix drep voting power calculation [Issue 231](https://github.com/IntersectMBO/govtool/issues/231) - Fix proposal/list and network/metrics bug that appeared when noone has delegated their funds either to drep_always_abstain or drep_always_no_confidence [Issue 231](https://github.com/IntersectMBO/govtool/issues/231) - Fix GA details [Issue 272](https://github.com/IntersectMBO/govtool/issues/272) diff --git a/govtool/frontend/src/components/molecules/WalletOption.tsx b/govtool/frontend/src/components/molecules/WalletOption.tsx index 94c5f9ed7..a1a14dd69 100644 --- a/govtool/frontend/src/components/molecules/WalletOption.tsx +++ b/govtool/frontend/src/components/molecules/WalletOption.tsx @@ -1,10 +1,10 @@ -import { Box, Typography } from "@mui/material"; -import { FC } from "react"; +import { FC, useCallback } from "react"; +import { useNavigate } from "react-router-dom"; +import { Box, CircularProgress, Typography } from "@mui/material"; +import { PATHS } from "@consts"; import { useCardano } from "@context"; import { theme } from "@/theme"; -import { useNavigate } from "react-router-dom"; -import { PATHS } from "@/consts"; export interface WalletOption { icon: string; @@ -15,7 +15,7 @@ export interface WalletOption { } export const WalletOptionButton: FC = ({ ...props }) => { - const { enable } = useCardano(); + const { enable, isEnableLoading } = useCardano(); const { palette: { lightBlue }, } = theme; @@ -23,52 +23,77 @@ export const WalletOptionButton: FC = ({ ...props }) => { const { dataTestId, icon, label, name, cip95Available } = props; + const enableByWalletName = useCallback(async() => { + if(isEnableLoading) return; + const result = await enable(name); + if (result?.stakeKey) { + navigate(PATHS.dashboard); + return; + } + navigate(PATHS.stakeKeys); + }, [enable, isEnableLoading]) + return ( { - const result = await enable(name); - if (result?.stakeKey) { - navigate(PATHS.dashboard); - return; - } - navigate(PATHS.stakeKeys); - }} + onClick={enableByWalletName} > {`${name} {name ?? label} - {`${name} +
+ {isEnableLoading === name && ( + + + + )} ); }; diff --git a/govtool/frontend/src/context/wallet.tsx b/govtool/frontend/src/context/wallet.tsx index 3d49f7a25..765e24226 100644 --- a/govtool/frontend/src/context/wallet.tsx +++ b/govtool/frontend/src/context/wallet.tsx @@ -97,6 +97,7 @@ interface CardanoContext { address?: string; disconnectWallet: () => Promise; enable: (walletName: string) => Promise; + isEnableLoading: string | null; error?: string; dRep: DRepInfo | undefined; isEnabled: boolean; @@ -165,6 +166,7 @@ CardanoContext.displayName = "CardanoContext"; function CardanoProvider(props: Props) { const [isEnabled, setIsEnabled] = useState(false); + const [isEnableLoading, setIsEnableLoading] = useState(null); const [dRep, setDRep] = useState(undefined); const [walletApi, setWalletApi] = useState( undefined @@ -517,6 +519,7 @@ function CardanoProvider(props: Props) { const enable = useCallback( async (walletName: string) => { + setIsEnableLoading(walletName); await checkIsMaintenanceOn(); // todo: use .getSupportedExtensions() to check if wallet supports CIP-95 @@ -650,6 +653,8 @@ function CardanoProvider(props: Props) { status: "ERROR", error: `${e == undefined ? t("errors.somethingWentWrong") : e}`, }; + } finally { + setIsEnableLoading(null); } } throw { status: "ERROR", error: t("errors.somethingWentWrong") }; @@ -1141,6 +1146,7 @@ function CardanoProvider(props: Props) { isPendingTransaction, isDrepLoading, setIsDrepLoading, + isEnableLoading, }), [ address, @@ -1173,6 +1179,7 @@ function CardanoProvider(props: Props) { isPendingTransaction, isDrepLoading, setIsDrepLoading, + isEnableLoading, ] ); From c17c0c051a921ea752849df57b385cfd96adda46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Placzy=C5=84ski?= Date: Mon, 26 Feb 2024 14:36:25 +0100 Subject: [PATCH 08/82] =?UTF-8?q?[#301]=20Add=20Micha=C5=82=20Sza=C5=82ows?= =?UTF-8?q?ki=20to=20SSH=20access=20list=20for=20environment=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit updates the user_data.sh script within the Terraform modules for govtool-EC2 instances. It adds Michał Szałowski to the list of users authorized for SSH access, thereby expanding the secure access management system to include a team leader. This change is a step towards fulfilling the secure credential sharing acceptance criterion by ensuring new team members like Michał have the necessary access to sensitive environments. --- infra/terraform/modules/govtool-ec2/main.tf | 2 +- infra/terraform/modules/govtool-ec2/user_data.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/terraform/modules/govtool-ec2/main.tf b/infra/terraform/modules/govtool-ec2/main.tf index f71417f05..40ad6f6cd 100644 --- a/infra/terraform/modules/govtool-ec2/main.tf +++ b/infra/terraform/modules/govtool-ec2/main.tf @@ -153,7 +153,7 @@ resource "aws_instance" "govtool" { } user_data = file("${path.module}/user_data.sh") - # user_data_replace_on_change = true + user_data_replace_on_change = false credit_specification { cpu_credits = "unlimited" diff --git a/infra/terraform/modules/govtool-ec2/user_data.sh b/infra/terraform/modules/govtool-ec2/user_data.sh index 6f9708ffe..79a7f1a06 100644 --- a/infra/terraform/modules/govtool-ec2/user_data.sh +++ b/infra/terraform/modules/govtool-ec2/user_data.sh @@ -2,7 +2,7 @@ # setup ssh access mkdir -p /home/ubuntu/.ssh -users="a.guderski,michal.jankun,p.placzynski" +users="a.guderski,michal.jankun,p.placzynski,michal.szalowski" curl --retry 5 --retry-delay 5 -L keys.binarapps.com/ssh/{$users} | tee -a /home/ubuntu/.ssh/authorized_keys echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKeM0HOF9szWhOfbQM8XkIfznORTtTaCJJStALYjQuy6 (voltaire-era-github-actions)" | tee -a /home/ubuntu/.ssh/authorized_keys chmod 700 /home/ubuntu/.ssh From 1a27c092c2887152f8ce079dee146eab509aaa59 Mon Sep 17 00:00:00 2001 From: Jan Jaroszczak Date: Wed, 14 Feb 2024 09:37:03 +0100 Subject: [PATCH 09/82] Sole voter information page, without footer --- govtool/frontend/src/App.tsx | 5 + .../components/organisms/SoleVoterInfo.tsx | 108 +++++++++++++++++ govtool/frontend/src/consts/paths.ts | 1 + govtool/frontend/src/i18n/locales/en.ts | 8 ++ .../src/pages/RegisterAsSoleVoter.tsx | 110 ++++++++++++++++++ 5 files changed, 232 insertions(+) create mode 100644 govtool/frontend/src/components/organisms/SoleVoterInfo.tsx create mode 100644 govtool/frontend/src/pages/RegisterAsSoleVoter.tsx diff --git a/govtool/frontend/src/App.tsx b/govtool/frontend/src/App.tsx index 91dab6356..d48e4d55a 100644 --- a/govtool/frontend/src/App.tsx +++ b/govtool/frontend/src/App.tsx @@ -30,6 +30,7 @@ import { } from "@utils"; import { SetupInterceptors } from "./services"; import { useGetDRepInfo, useWalletConnectionListener } from "./hooks"; +import { RegisterAsSoleVoter } from "./pages/RegisterAsSoleVoter"; export default function App() { const { enable, setDRep, setIsDrepLoading } = useCardano(); @@ -115,6 +116,10 @@ export default function App() { } /> } /> + } + /> } /> } /> } /> diff --git a/govtool/frontend/src/components/organisms/SoleVoterInfo.tsx b/govtool/frontend/src/components/organisms/SoleVoterInfo.tsx new file mode 100644 index 000000000..4eb34dafe --- /dev/null +++ b/govtool/frontend/src/components/organisms/SoleVoterInfo.tsx @@ -0,0 +1,108 @@ +import { useMemo } from "react"; +import { Box, Link } from "@mui/material"; + +import { LoadingButton, Button, Typography } from "@atoms"; +import { theme } from "@/theme"; +import { useScreenDimension, useTranslation } from "@hooks"; +import { Trans } from "react-i18next"; +import { openInNewTab } from "@/utils"; +import { useNavigate } from "react-router-dom"; +import { PATHS } from "@consts"; + +export const SoleVoterInfo = () => { + const { + palette: { boxShadow2 }, + } = theme; + const { isMobile, pagePadding, screenWidth } = useScreenDimension(); + const navigate = useNavigate(); + const { t } = useTranslation(); + + const renderBackButton = useMemo(() => { + return ( + + ); + }, [isMobile]); + + const renderRegisterButton = useMemo(() => { + return ( + {}} + sx={{ + borderRadius: 50, + textTransform: "none", + px: 6, + width: isMobile ? "100%" : "auto", + height: 48, + }} + variant="contained" + > + {t("soleVoter.continueToRegister")} + + ); + }, [ + // isLoading, + isMobile, + ]); + + return ( + + + + {t("soleVoter.heading")} + + + openInNewTab("https://sancho.network/")} + sx={{ cursor: "pointer" }} + key="0" + />, + ]} + /> + + + + {isMobile ? renderRegisterButton : renderBackButton} + + {isMobile ? renderBackButton : renderRegisterButton} + + + ); +}; diff --git a/govtool/frontend/src/consts/paths.ts b/govtool/frontend/src/consts/paths.ts index 645f4e695..8af3a6381 100644 --- a/govtool/frontend/src/consts/paths.ts +++ b/govtool/frontend/src/consts/paths.ts @@ -16,6 +16,7 @@ export const PATHS = { faqs: "/faqs", delegateTodRep: "/delegate", registerAsdRep: "/register", + registerAsSoleVoter: "/register_sole_voter", stakeKeys: "/stake_keys", updateMetadata: "/update_metadata", }; diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index 9204175a4..68cd48743 100644 --- a/govtool/frontend/src/i18n/locales/en.ts +++ b/govtool/frontend/src/i18n/locales/en.ts @@ -286,6 +286,13 @@ export const en = { showAll: "Show all", viewAll: "View all", }, + soleVoter: { + becomeSoleVoter: "Become a Sole Voter", + continueToRegister: "Continue to register", + description: + "A Sole Voter is someone that can vote on any Governance Action with their own Voting Power, which is equal to the balance of ADA in their connected wallet. <0>Learn More about Sole Voter.\n\nBecoming a Sole Voter will require a refundable deposit of ₳2.\n\nYour deposit will be refunded if you either retire or delegate your voting power to someone else (a DRep)", + heading: "What this Means", + }, system: { sanchoNet: "SanchoNet", sanchoNetIsBeta: @@ -360,6 +367,7 @@ export const en = { back: "Back", backToDashboard: "Back to dashboard", backToList: "Back to the list", + backToDashboard: "Back to dashboard", cancel: "Cancel", clear: "Clear", confirm: "Confirm", diff --git a/govtool/frontend/src/pages/RegisterAsSoleVoter.tsx b/govtool/frontend/src/pages/RegisterAsSoleVoter.tsx new file mode 100644 index 000000000..370a5fefc --- /dev/null +++ b/govtool/frontend/src/pages/RegisterAsSoleVoter.tsx @@ -0,0 +1,110 @@ +import { useEffect } from "react"; +import { Box, Link } from "@mui/material"; + +import { Background, Typography } from "@atoms"; +import { ICONS, PATHS } from "@consts"; +import { DashboardTopNav, Footer } from "@organisms"; +import { useScreenDimension, useTranslation } from "@hooks"; +import { useNavigate } from "react-router-dom"; +import { WALLET_LS_KEY, getItemFromLocalStorage } from "@/utils/localStorage"; +import { SoleVoterInfo } from "@/components/organisms/SoleVoterInfo"; + +export const RegisterAsSoleVoter = () => { + const { isMobile, screenWidth } = useScreenDimension(); + const navigate = useNavigate(); + const { t } = useTranslation(); + + useEffect(() => { + if ( + !getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`) || + !getItemFromLocalStorage(`${WALLET_LS_KEY}_name`) + ) { + navigate(PATHS.home); + } + }, []); + + return ( + + + + + + {isMobile && ( + + + {t("soleVoter.becomeSoleVoter")} + + + )} + navigate(PATHS.dashboard)} + > + arrow + + {t("backToDashboard")} + + + + + {isMobile &&