From fd4d5d9fe1b3e5c807368dfa5c876851c2cf576f Mon Sep 17 00:00:00 2001 From: Kirill Klimenko Date: Thu, 18 Jan 2024 12:18:56 +0100 Subject: [PATCH 1/6] Filter out choices that don't have weight selected during casting vote and during displaying --- .../SnapshotProposalDetails/SnapshotProposalVoteItem.tsx | 9 ++++++--- .../SnapshotProposalDetails/SnapshotProposalVotes.tsx | 2 +- src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts | 2 +- src/hooks/DAO/proposal/useCastVote.ts | 4 +++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVoteItem.tsx b/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVoteItem.tsx index 17560334ec..24b81128c8 100644 --- a/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVoteItem.tsx +++ b/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVoteItem.tsx @@ -40,11 +40,14 @@ export default function SnapshotProposalVoteItem({ proposal, vote }: ISnapshotPr gap={1} flexWrap="wrap" > - {Object.keys(vote.choice as SnapshotWeightedVotingChoice).map((choice: any) => { + {Object.keys(vote.choice as SnapshotWeightedVotingChoice).map((choiceIdx: any) => { + if (!(vote.choice as SnapshotWeightedVotingChoice)[choiceIdx]) { + return null; + } return ( - + - {proposal.choices[(choice as any as number) - 1]} + {proposal.choices[(choiceIdx as number) - 1]} ); diff --git a/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVotes.tsx b/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVotes.tsx index bb63523b6a..003e659167 100644 --- a/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVotes.tsx +++ b/src/components/Proposals/SnapshotProposalDetails/SnapshotProposalVotes.tsx @@ -63,7 +63,7 @@ export default function SnapshotProposalVotes({ proposal }: ISnapshotProposalVot {proposal.privacy === 'shutter' && proposal.state !== FractalProposalState.CLOSED ? `? ${strategySymbol}` - : `${votesBreakdownChoiceTotal} ${strategySymbol}`} + : `${votesBreakdownChoiceTotal.toFixed(2)} ${strategySymbol}`} ); diff --git a/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts b/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts index f42d265327..f1d7f86a01 100644 --- a/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts +++ b/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts @@ -80,7 +80,7 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u const votesQueryResult = await client .query({ query: gql`query SnapshotProposalVotes { - votes(where: {proposal: "${snapshotProposal.snapshotProposalId}"}, first: 100) { + votes(where: {proposal: "${snapshotProposal.snapshotProposalId}"}, first: 500) { id voter vp diff --git a/src/hooks/DAO/proposal/useCastVote.ts b/src/hooks/DAO/proposal/useCastVote.ts index 8ea9724cba..2e6b93e77a 100644 --- a/src/hooks/DAO/proposal/useCastVote.ts +++ b/src/hooks/DAO/proposal/useCastVote.ts @@ -143,7 +143,9 @@ const useCastVote = ({ const mappedSnapshotWeightedChoice: { [choiceKey: number]: number } = {}; if (extendedSnapshotProposal.type === 'weighted') { snapshotWeightedChoice.forEach((value, choiceIndex) => { - mappedSnapshotWeightedChoice[choiceIndex + 1] = value; + if (value > 0) { + mappedSnapshotWeightedChoice[choiceIndex + 1] = value; + } }); } const choice = From c1e70dd892bfe6c142aac18d87255573ee768d58 Mon Sep 17 00:00:00 2001 From: Kirill Klimenko Date: Thu, 18 Jan 2024 12:45:11 +0100 Subject: [PATCH 2/6] Holy cow! Flashing issue completely fixed --- app/daos/[daoAddress]/layout.tsx | 6 +++--- src/hooks/DAO/loaders/useFractalNode.ts | 8 +++++++- src/hooks/DAO/useDAOController.ts | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/daos/[daoAddress]/layout.tsx b/app/daos/[daoAddress]/layout.tsx index afe5b2799d..af39d70eb4 100644 --- a/app/daos/[daoAddress]/layout.tsx +++ b/app/daos/[daoAddress]/layout.tsx @@ -72,7 +72,7 @@ export default function DaoPageLayout({ params: { daoAddress?: string }; }) { const { node } = useFractal(); - const { nodeLoading, reloadingDAO } = useDAOController({ daoAddress }); + const { nodeLoading, reloadingDAO, errorLoading } = useDAOController({ daoAddress }); const daoMetadata = useDAOMetadata(); const { chain } = useNetwork(); const activeTheme = useMemo(() => { @@ -106,7 +106,7 @@ export default function DaoPageLayout({ display = childrenDisplay; } else if (!chain) { // if we're disconnected - if (nodeLoading || reloadingDAO || validSafe) { + if (nodeLoading || reloadingDAO || validSafe || !errorLoading) { display = children; } else { display = ; @@ -116,7 +116,7 @@ export default function DaoPageLayout({ const invalidChain = !supportedChains.map(c => c.chainId).includes(chain.id); if (invalidChain) { display = ; - } else if (nodeLoading || reloadingDAO || validSafe) { + } else if (nodeLoading || reloadingDAO || validSafe || !errorLoading) { display = children; } else { display = ; diff --git a/src/hooks/DAO/loaders/useFractalNode.ts b/src/hooks/DAO/loaders/useFractalNode.ts index b9383cca7d..5bd8cd4b9c 100644 --- a/src/hooks/DAO/loaders/useFractalNode.ts +++ b/src/hooks/DAO/loaders/useFractalNode.ts @@ -20,6 +20,7 @@ export const useFractalNode = ({ daoAddress }: { daoAddress?: string }) => { // tracks the current valid Safe address and chain id; helps prevent unnecessary calls const currentValidSafe = useRef(); const [nodeLoading, setNodeLoading] = useState(true); + const [errorLoading, setErrorLoading] = useState(false); const { action } = useFractal(); const safeAPI = useSafeAPI(); @@ -87,12 +88,14 @@ export const useFractalNode = ({ daoAddress }: { daoAddress?: string }) => { const setDAO = useCallback( async (_chainId: number, _daoAddress: string) => { setNodeLoading(true); + setErrorLoading(false); if (utils.isAddress(_daoAddress) && safeAPI) { try { const safeInfo = await requestWithRetries(fetchSafeInfo, 5); if (!safeInfo) { currentValidSafe.current = undefined; action.resetDAO(); + setErrorLoading(true); } else { currentValidSafe.current = _chainId + _daoAddress; action.dispatch({ @@ -103,16 +106,19 @@ export const useFractalNode = ({ daoAddress }: { daoAddress?: string }) => { type: NodeAction.SET_SAFE_INFO, payload: safeInfo, }); + setErrorLoading(false); } } catch (e) { // network error currentValidSafe.current = undefined; action.resetDAO(); + setErrorLoading(true); } } else { // invalid address currentValidSafe.current = undefined; action.resetDAO(); + setErrorLoading(true); } setNodeLoading(false); }, @@ -128,5 +134,5 @@ export const useFractalNode = ({ daoAddress }: { daoAddress?: string }) => { } }, [daoAddress, setDAO, currentValidSafe, chainId]); - return nodeLoading; + return { nodeLoading, errorLoading }; }; diff --git a/src/hooks/DAO/useDAOController.ts b/src/hooks/DAO/useDAOController.ts index a91af59f21..7735b6937a 100644 --- a/src/hooks/DAO/useDAOController.ts +++ b/src/hooks/DAO/useDAOController.ts @@ -30,7 +30,7 @@ export default function useDAOController({ daoAddress }: { daoAddress?: string } } }, [daoAddress, currentDAOAddress, action]); - const nodeLoading = useFractalNode({ daoAddress: currentDAOAddress }); + const { nodeLoading, errorLoading } = useFractalNode({ daoAddress: currentDAOAddress }); useGovernanceContracts(); useFractalGuardContracts({}); useFractalFreeze({ parentSafeAddress: parentAddress }); @@ -38,5 +38,5 @@ export default function useDAOController({ daoAddress }: { daoAddress?: string } useFractalTreasury(); useERC20Claim(); useSnapshotProposals(); - return { nodeLoading, reloadingDAO }; + return { nodeLoading, reloadingDAO, errorLoading }; } From f488fcd4dd7780bc2b57a977916cc2dae622fe83 Mon Sep 17 00:00:00 2001 From: Kirill Klimenko Date: Thu, 18 Jan 2024 13:14:05 +0100 Subject: [PATCH 3/6] Disable navigation through SearchDisplay if found safe is currently viewed safe --- .../ui/menus/DAOSearch/SearchDisplay.tsx | 23 +++++++++++++------ src/i18n/locales/en/common.json | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/components/ui/menus/DAOSearch/SearchDisplay.tsx b/src/components/ui/menus/DAOSearch/SearchDisplay.tsx index 0d758cc1a9..e96189f8f9 100644 --- a/src/components/ui/menus/DAOSearch/SearchDisplay.tsx +++ b/src/components/ui/menus/DAOSearch/SearchDisplay.tsx @@ -1,5 +1,6 @@ import { Box, Flex, Text, Button } from '@chakra-ui/react'; import { useRouter } from 'next/navigation'; +import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { DAO_ROUTES } from '../../../../constants/routes'; import useDisplayName from '../../../../hooks/utils/useDisplayName'; @@ -28,8 +29,11 @@ export function SearchDisplay({ closeDrawer, }: ISearchDisplay) { const { t } = useTranslation(['common', 'dashboard']); - const { action } = useFractal(); + const { action, node } = useFractal(); const { push } = useRouter(); + const isCurrentSafe = useMemo(() => { + return !!node && !!node.daoAddress && node.daoAddress === address; + }, [node, address]); if (loading && address) { return ( @@ -49,12 +53,14 @@ export function SearchDisplay({ { - onClickView(); - if (closeDrawer) closeDrawer(); - action.resetDAO(); - push(DAO_ROUTES.dao.relative(address)); + if (!isCurrentSafe) { + onClickView(); + if (closeDrawer) closeDrawer(); + action.resetDAO(); + push(DAO_ROUTES.dao.relative(address)); + } }} - cursor="default" + cursor={isCurrentSafe ? 'not-allowed' : 'default'} justifyContent="space-between" > - {t('labelDAOFound')} + {t(isCurrentSafe ? 'labelCurrentDAO' : 'labelDAOFound')} @@ -74,6 +80,9 @@ export function SearchDisplay({ diff --git a/src/i18n/locales/en/common.json b/src/i18n/locales/en/common.json index d59cf73c70..f8c3645e61 100644 --- a/src/i18n/locales/en/common.json +++ b/src/i18n/locales/en/common.json @@ -37,6 +37,7 @@ "home": "Home", "labelViewDAO": "View Safe", "labelDAOFound": "Safe found", + "labelCurrentDAO": "This is Safe you are currently viewing", "labelEtherscan": "View on Etherscan", "errorInvalidENSAddress": "Invalid ENS name or address", "errorInvalidENSName": "Invalid ENS name", From 1887c2a0f80a8e3cc884e4127e61f4c7bc8ee1ff Mon Sep 17 00:00:00 2001 From: Kirill Klimenko Date: Thu, 18 Jan 2024 13:14:59 +0100 Subject: [PATCH 4/6] Do not display View Safe button in SearchDisplay if found safe is current safe --- .../ui/menus/DAOSearch/SearchDisplay.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/ui/menus/DAOSearch/SearchDisplay.tsx b/src/components/ui/menus/DAOSearch/SearchDisplay.tsx index e96189f8f9..cce35469b1 100644 --- a/src/components/ui/menus/DAOSearch/SearchDisplay.tsx +++ b/src/components/ui/menus/DAOSearch/SearchDisplay.tsx @@ -77,15 +77,14 @@ export function SearchDisplay({ - + {!isCurrentSafe && ( + + )} ); } From 45159f4998c9c7fc7cce2990ff3e2c7678f37935 Mon Sep 17 00:00:00 2001 From: Kirill Klimenko Date: Thu, 18 Jan 2024 14:22:29 +0100 Subject: [PATCH 5/6] Update metadata for ethlizards, add featured ethlizards section on HomePage, add logic to not show it on prod --- app/page.tsx | 25 +++++++++++++++++++++++++ src/i18n/locales/en/home.json | 2 ++ src/metadata/lizzardsDAO/index.ts | 13 +++++++------ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index f07e82b9e1..7ba6206c08 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -14,6 +14,7 @@ import ExternalLink from '../src/components/ui/links/ExternalLink'; import ClientOnly from '../src/components/ui/utils/ClientOnly'; import { BASE_ROUTES } from '../src/constants/routes'; import { URL_DOCS } from '../src/constants/url'; +import ethLizardsLogo from '../src/metadata/lizzardsDAO/assets/logo.png'; import { useFractal } from '../src/providers/App/AppProvider'; import { disconnectedChain } from '../src/providers/NetworkConfig/NetworkConfigProvider'; @@ -59,6 +60,12 @@ const FEATURED_DAOS = new Map([ descKey: 'awakeDesc', address: '0x36C19472D4CA942710cA9aF01a03cED4dBc6eC0a', }, + { + iconSrc: ethLizardsLogo.src, + titleKey: 'ethlizardsTitle', + descKey: 'ethlizardsDesc', + address: '0x167bE4073f52aD2Aa0D6d6FeddF0F1f79a82B98e', + }, ], ], [ @@ -76,6 +83,12 @@ const FEATURED_DAOS = new Map([ descKey: 'awakeDesc', address: '0xdD6CeFA62239272f1eDf755ba6471eacb7DF2Fa5', }, + { + iconSrc: ethLizardsLogo.src, + titleKey: 'ethlizardsTitle', + descKey: 'ethlizardsDesc', + address: '0x167bE4073f52aD2Aa0D6d6FeddF0F1f79a82B98e', // TODO: Change to mainnet address once it will be there + }, ], ], [ @@ -93,6 +106,12 @@ const FEATURED_DAOS = new Map([ descKey: 'awakeDesc', address: '0xdD6CeFA62239272f1eDf755ba6471eacb7DF2Fa5', // TODO: Change to Sepolia Address once it will be there }, + { + iconSrc: ethLizardsLogo.src, + titleKey: 'ethlizardsTitle', + descKey: 'ethlizardsDesc', + address: '0x167bE4073f52aD2Aa0D6d6FeddF0F1f79a82B98e', // TODO: Change to Sepolia address once it will be there + }, ], ], ]); @@ -216,6 +235,12 @@ export default function HomePage() { paddingBottom="1.5rem" > {features.map((feature, index) => { + if ( + typeof location !== 'undefined' && + location.pathname === 'app.fractalframework.xyz' + ) { + return null; + } return ( ", "readyCTA": "Ready to start?", "createButton": "+ Start from Scratch", diff --git a/src/metadata/lizzardsDAO/index.ts b/src/metadata/lizzardsDAO/index.ts index db2a286bb4..8f50d2767e 100644 --- a/src/metadata/lizzardsDAO/index.ts +++ b/src/metadata/lizzardsDAO/index.ts @@ -25,13 +25,14 @@ const LIZZARDS_DAO_METADATA: DAOMetadata = { sections: [ { title: 'Description', - content: ' for this proposal or just click on the link to learn more about the proposal', + content: + 'Ethlizards brings together an exceptional mix of avid gamers, visionary builders, and savvy investors, establishing itself as a highly esteemed partner in the GameFi ecosystem.', background: undefined, - link: { - position: 'start', - text: 'Vote here', - url: '/proposals/0xe10c44fceb1b43f74c42bd6efc9316e9ce14109ac8a166e5266fc78499cb4fea', - }, + // link: { + // position: 'start', + // text: 'Vote here', + // url: '/proposals/0xe10c44fceb1b43f74c42bd6efc9316e9ce14109ac8a166e5266fc78499cb4fea', + // }, }, { title: 'Elemental Lizards coming soon', From 6e98bad97d73120f11375c709292ed0bc7957c2e Mon Sep 17 00:00:00 2001 From: Kirill Klimenko Date: Thu, 18 Jan 2024 14:31:40 +0100 Subject: [PATCH 6/6] Inject Hotjar script for ethlizards testing --- app/daos/[daoAddress]/layout.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/daos/[daoAddress]/layout.tsx b/app/daos/[daoAddress]/layout.tsx index af39d70eb4..beb30c3182 100644 --- a/app/daos/[daoAddress]/layout.tsx +++ b/app/daos/[daoAddress]/layout.tsx @@ -3,6 +3,7 @@ import { Button, Center, Text, VStack, ChakraProvider, extendTheme } from '@chakra-ui/react'; import { theme } from '@decent-org/fractal-ui'; import { useRouter } from 'next/navigation'; +import Script from 'next/script'; import { ReactNode, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useNetwork } from 'wagmi'; @@ -126,6 +127,21 @@ export default function DaoPageLayout({ return ( {node?.daoName ? `${node.daoName} | ${APP_NAME}` : APP_NAME} + {node && node.daoAddress === '0x167bE4073f52aD2Aa0D6d6FeddF0F1f79a82B98e' && ( + + )} {display} );