Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:decentdao/fractal-interface into…
Browse files Browse the repository at this point in the history
… make-azorious-load-faster
  • Loading branch information
Da-Colon committed Mar 29, 2024
2 parents 69d9818 + 785eff5 commit 1d6386e
Show file tree
Hide file tree
Showing 52 changed files with 471 additions and 315 deletions.
6 changes: 5 additions & 1 deletion src/components/Activity/ActivityDescriptionGovernance.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box, Flex, Text } from '@chakra-ui/react';
import { useTranslation } from 'react-i18next';
import { useGetMetadata } from '../../hooks/DAO/proposal/useGetMetadata';
import useAvatar from '../../hooks/utils/useAvatar';
import useDisplayName from '../../hooks/utils/useDisplayName';
import {
Activity,
Expand Down Expand Up @@ -52,6 +53,8 @@ function ProposalAuthor({ activity }: { activity: Activity }) {
: multisigProposal.confirmations[0].owner;

const { displayName: author } = useDisplayName(proposer);
const avatarURL = useAvatar(author);

return (
<Flex
gap={2}
Expand All @@ -61,7 +64,8 @@ function ProposalAuthor({ activity }: { activity: Activity }) {
>
<Avatar
size="sm"
address={author}
address={proposer}
url={avatarURL}
/>
<Box>{author}</Box>
</Flex>
Expand Down
6 changes: 5 additions & 1 deletion src/components/DaoCreator/StepWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useNavigate } from 'react-router-dom';
import { BACKGROUND_SEMI_TRANSPARENT } from '../../constants/common';
import { BASE_ROUTES, DAO_ROUTES } from '../../constants/routes';
import { useFractal } from '../../providers/App/AppProvider';
import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider';
import PageHeader from '../ui/page/Header/PageHeader';
import { DAOCreateMode } from './formComponents/EstablishEssentials';

Expand All @@ -29,6 +30,7 @@ export function StepWrapper({
const {
node: { daoAddress },
} = useFractal();
const { addressPrefix } = useNetworkConfig();
const { t } = useTranslation(['daoCreate']);
const navigate = useNavigate();

Expand Down Expand Up @@ -64,7 +66,9 @@ export function StepWrapper({
isButtonDisabled={isFormSubmitting}
buttonClick={() =>
navigate(
!isSubDAO || !daoAddress ? BASE_ROUTES.landing : DAO_ROUTES.dao.relative(daoAddress),
!isSubDAO || !daoAddress
? BASE_ROUTES.landing
: DAO_ROUTES.dao.relative(addressPrefix, daoAddress),
)
}
/>
Expand Down
6 changes: 4 additions & 2 deletions src/components/ProposalTemplates/ProposalTemplateCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useRemoveProposalTemplate from '../../hooks/DAO/proposal/useRemoveProposa
import useSubmitProposal from '../../hooks/DAO/proposal/useSubmitProposal';
import { useCanUserCreateProposal } from '../../hooks/utils/useCanUserSubmitProposal';
import { useFractal } from '../../providers/App/AppProvider';
import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider';
import { ProposalTemplate } from '../../types/createProposalTemplate';
import ContentBox from '../ui/containers/ContentBox';
import { OptionMenu } from '../ui/menus/OptionMenu';
Expand All @@ -29,6 +30,7 @@ export default function ProposalTemplateCard({
const {
node: { safe, daoAddress },
} = useFractal();
const { addressPrefix } = useNetworkConfig();

const { prepareRemoveProposalTemplateProposal } = useRemoveProposalTemplate();
const { submitProposal } = useSubmitProposal();
Expand All @@ -46,9 +48,9 @@ export default function ProposalTemplateCard({
const successCallback = useCallback(() => {
if (daoAddress) {
// Redirecting to proposals page so that user will see Proposal for Proposal Template creation
navigate(DAO_ROUTES.proposals.relative(daoAddress));
navigate(DAO_ROUTES.proposals.relative(addressPrefix, daoAddress));
}
}, [navigate, daoAddress]);
}, [navigate, daoAddress, addressPrefix]);

const nonce = safe?.nonce;
const handleRemoveTemplate = useCallback(async () => {
Expand Down
6 changes: 4 additions & 2 deletions src/components/ProposalTemplates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Link } from 'react-router-dom';
import { DAO_ROUTES } from '../../constants/routes';
import { useCanUserCreateProposal } from '../../hooks/utils/useCanUserSubmitProposal';
import { useFractal } from '../../providers/App/AppProvider';
import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider';
import { EmptyBox } from '../ui/containers/EmptyBox';
import { InfoBoxLoader } from '../ui/loaders/InfoBoxLoader';
import ProposalTemplateCard from './ProposalTemplateCard';
Expand All @@ -14,6 +15,7 @@ export default function ProposalTemplates() {
node: { daoAddress },
governance: { proposalTemplates },
} = useFractal();
const { addressPrefix } = useNetworkConfig();
const { canUserCreateProposal } = useCanUserCreateProposal();

return (
Expand All @@ -36,8 +38,8 @@ export default function ProposalTemplates() {
))
) : (
<EmptyBox emptyText={t('emptyProposalTemplates')}>
{canUserCreateProposal && (
<Link to={DAO_ROUTES.proposalTemplateNew.relative(daoAddress)}>
{canUserCreateProposal && daoAddress && (
<Link to={DAO_ROUTES.proposalTemplateNew.relative(addressPrefix, daoAddress)}>
<Button
variant="text"
textStyle="text-xl-mono-bold"
Expand Down
8 changes: 7 additions & 1 deletion src/components/Proposals/ProposalCard/ProposalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { DAO_ROUTES } from '../../../constants/routes';
import { useFractal } from '../../../providers/App/AppProvider';
import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider';
import { ActivityEventType, FractalProposal, SnapshotProposal } from '../../../types';
import { DEFAULT_DATE_FORMAT } from '../../../utils';
import { ActivityDescription } from '../../Activity/ActivityDescription';
Expand All @@ -14,6 +15,7 @@ function ProposalCard({ proposal }: { proposal: FractalProposal }) {
const {
node: { daoAddress },
} = useFractal();
const { addressPrefix } = useNetworkConfig();
const { t } = useTranslation('common');

const eventDateLabel = t(
Expand All @@ -26,8 +28,12 @@ function ProposalCard({ proposal }: { proposal: FractalProposal }) {

const isSnapshotProposal = !!(proposal as SnapshotProposal).snapshotProposalId;

if (!daoAddress) {
return null;
}

return (
<Link to={DAO_ROUTES.proposal.relative(daoAddress, proposal.proposalId)}>
<Link to={DAO_ROUTES.proposal.relative(addressPrefix, daoAddress, proposal.proposalId)}>
<Box
minHeight="6.25rem"
bg="chocolate.900"
Expand Down
7 changes: 5 additions & 2 deletions src/components/Proposals/ProposalsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Link } from 'react-router-dom';
import { DAO_ROUTES } from '../../constants/routes';
import { useCanUserCreateProposal } from '../../hooks/utils/useCanUserSubmitProposal';
import { useFractal } from '../../providers/App/AppProvider';
import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider';
import { FractalProposal } from '../../types';
import { EmptyBox } from '../ui/containers/EmptyBox';
import { InfoBoxLoader } from '../ui/loaders/InfoBoxLoader';
Expand All @@ -14,6 +15,8 @@ export function ProposalsList({ proposals }: { proposals: FractalProposal[] }) {
node: { daoAddress },
} = useFractal();
const { canUserCreateProposal } = useCanUserCreateProposal();
const { addressPrefix } = useNetworkConfig();

const { t } = useTranslation('proposal');
return (
<Flex
Expand All @@ -33,8 +36,8 @@ export function ProposalsList({ proposals }: { proposals: FractalProposal[] }) {
))
) : (
<EmptyBox emptyText={t('emptyProposals')}>
{canUserCreateProposal && (
<Link to={DAO_ROUTES.proposalNew.relative(daoAddress)}>
{canUserCreateProposal && daoAddress && (
<Link to={DAO_ROUTES.proposalNew.relative(addressPrefix, daoAddress)}>
<Button
variant="text"
textStyle="text-xl-mono-bold"
Expand Down
4 changes: 3 additions & 1 deletion src/components/pages/AppHome/FeaturedDAOCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ interface DAOFeatureProps extends BoxProps {
iconSrc: string;
title: string;
desc: string;
network: string;
address: string;
}

export default function FeaturedDAOCard({
iconSrc,
title,
desc,
network,
address,
...rest
}: DAOFeatureProps) {
Expand Down Expand Up @@ -57,7 +59,7 @@ export default function FeaturedDAOCard({
_hover={{ color: 'gold.500-hover' }}
alignSelf="end"
textStyle="text-lg-mono-bold"
to={DAO_ROUTES.dao.relative(address)}
to={DAO_ROUTES.dao.relative(network, address)}
>
{t('featureLink')}
</Link>
Expand Down
3 changes: 2 additions & 1 deletion src/components/pages/DaoDashboard/Activities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useActivities } from './hooks/useActivities';

export function Activities() {
const {
guardContracts: { freezeVotingContractAddress },
guard,
governance: { type },
} = useFractal();
Expand All @@ -37,7 +38,7 @@ export function Activities() {
flexDirection="column"
gap="1rem"
>
{guard.freezeProposalVoteCount?.gt(0) && <ActivityFreeze />}
{freezeVotingContractAddress && guard.freezeProposalVoteCount?.gt(0) && <ActivityFreeze />}
{!type ? (
<InfoBoxLoader />
) : sortedActivities.length ? (
Expand Down
4 changes: 3 additions & 1 deletion src/components/pages/DaoDashboard/Info/ParentLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
import { Link as RouterLink } from 'react-router-dom';
import { DAO_ROUTES } from '../../../../constants/routes';
import { useFractal } from '../../../../providers/App/AppProvider';
import { useNetworkConfig } from '../../../../providers/NetworkConfig/NetworkConfigProvider';

/**
* Displays a link to the current DAO's parent, if it has one.
Expand All @@ -12,6 +13,7 @@ export function ParentLink() {
node: { nodeHierarchy },
action,
} = useFractal();
const { addressPrefix } = useNetworkConfig();
const { t } = useTranslation('breadcrumbs');

if (!nodeHierarchy.parentAddress) {
Expand All @@ -22,7 +24,7 @@ export function ParentLink() {
<Link
color="gold.500"
_hover={{ textDecoration: 'none', color: 'gold.500-hover' }}
to={DAO_ROUTES.dao.relative(nodeHierarchy.parentAddress)}
to={DAO_ROUTES.dao.relative(addressPrefix, nodeHierarchy.parentAddress)}
onClick={action.resetDAO}
marginBottom="1rem"
as={RouterLink}
Expand Down
6 changes: 4 additions & 2 deletions src/components/pages/DaoDashboard/Info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box, Flex, Text } from '@chakra-ui/react';
import { DAO_ROUTES } from '../../../../constants/routes';
import useDAOMetadata from '../../../../hooks/DAO/useDAOMetadata';
import { useFractal } from '../../../../providers/App/AppProvider';
import { useNetworkConfig } from '../../../../providers/NetworkConfig/NetworkConfigProvider';
import { InfoBox } from '../../../ui/containers/InfoBox';
import ExternalLink from '../../../ui/links/ExternalLink';
import { InfoDAO } from './InfoDAO';
Expand All @@ -14,6 +15,7 @@ export function Info() {
const {
node: { daoAddress },
} = useFractal();
const { addressPrefix } = useNetworkConfig();
const daoMetadata = useDAOMetadata();

// using this gap method instead of 'gap' to make width percentages more precise, since they
Expand Down Expand Up @@ -135,7 +137,7 @@ export function Info() {
pb={{ sm: PAD, md: NONE }}
pt={{ sm: PAD, lg: NONE }}
>
<InfoBox to={DAO_ROUTES.proposals.relative(daoAddress)}>
<InfoBox to={DAO_ROUTES.proposals.relative(addressPrefix, daoAddress || '')}>
<InfoProposals />
</InfoBox>
</Box>
Expand All @@ -144,7 +146,7 @@ export function Info() {
ps={{ base: NONE, md: PAD }}
pt={{ sm: PAD, lg: NONE }}
>
<InfoBox to={DAO_ROUTES.treasury.relative(daoAddress)}>
<InfoBox to={DAO_ROUTES.treasury.relative(addressPrefix, daoAddress || '')}>
<InfoTreasury />
</InfoBox>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/DaoHierarchy/DaoNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function DaoNode({
} else if (errorNode.error === 'errorFailedSearch') {
setNode({
daoName: null,
daoAddress: daoAddress,
daoAddress,
safe: null,
fractalModules: [],
nodeHierarchy: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/DaoHierarchy/useFetchNodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function useFetchNodes(address?: string) {
for await (const subDAO of nodes) {
try {
const safeInfo = await requestWithRetries(() => fetchDAOInfo(subDAO.address), 5, 5000);
if (safeInfo.guard) {
if (safeInfo && safeInfo.guard) {
if (safeInfo.guard === ethers.constants.AddressZero) {
subDAOs.push(safeInfo);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import useSubmitProposal from '../../../../../hooks/DAO/proposal/useSubmitPropos
import { useCanUserCreateProposal } from '../../../../../hooks/utils/useCanUserSubmitProposal';
import { createAccountSubstring } from '../../../../../hooks/utils/useDisplayName';
import { useFractal } from '../../../../../providers/App/AppProvider';
import { useNetworkConfig } from '../../../../../providers/NetworkConfig/NetworkConfigProvider';
import { ProposalExecuteData } from '../../../../../types';
import { couldBeENS } from '../../../../../utils/url';
import { InputComponent } from '../../../../ui/forms/InputComponent';
Expand All @@ -29,6 +30,7 @@ export default function MetadataContainer() {
user: { votingWeight },
},
} = useFractal();
const { addressPrefix } = useNetworkConfig();

useEffect(() => {
if (daoName && daoAddress && createAccountSubstring(daoAddress) !== daoName) {
Expand All @@ -52,7 +54,11 @@ export default function MetadataContainer() {

const userHasVotingWeight = votingWeight.gt(0);

const submitProposalSuccessCallback = () => navigate(DAO_ROUTES.proposals.relative(daoAddress));
const submitProposalSuccessCallback = () => {
if (daoAddress) {
navigate(DAO_ROUTES.proposals.relative(addressPrefix, daoAddress));
}
};

const handleEditDAOName = () => {
if (!baseContracts) {
Expand Down
6 changes: 4 additions & 2 deletions src/components/ui/cards/DAOInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Link as RouterLink } from 'react-router-dom';
import { DAO_ROUTES } from '../../../constants/routes';
import useDisplayName from '../../../hooks/utils/useDisplayName';
import { useFractal } from '../../../providers/App/AppProvider';
import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider';
import { FreezeGuard, FractalGuardContracts, FractalNode } from '../../../types';
import Snapshot from '../badges/Snapshot';
import FavoriteIcon from '../icons/FavoriteIcon';
Expand Down Expand Up @@ -42,6 +43,7 @@ export function DAOInfoCard({
action,
readOnly: { user },
} = useFractal();
const { addressPrefix } = useNetworkConfig();
// for non Fractal Safes
const { displayName } = useDisplayName(node?.daoAddress);

Expand Down Expand Up @@ -77,7 +79,7 @@ export function DAOInfoCard({
<Link
as={RouterLink}
pointerEvents={isCurrentDAO ? 'none' : undefined}
to={DAO_ROUTES.dao.relative(displayedAddress)}
to={DAO_ROUTES.dao.relative(addressPrefix, displayedAddress)}
_hover={{ textDecoration: 'none' }}
onClick={() => {
// if we're not on the current DAO, reset
Expand All @@ -104,7 +106,7 @@ export function DAOInfoCard({
/>
{childCount && childCount > 0 && (
<Link
to={DAO_ROUTES.hierarchy.relative(displayedAddress)}
to={DAO_ROUTES.hierarchy.relative(addressPrefix, displayedAddress)}
as={RouterLink}
>
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function Connected() {
} = useFractal();
const account = user.address;
const { displayName: accountDisplayName } = useDisplayName(account);
const avatarURL = useAvatar(account);
const avatarURL = useAvatar(accountDisplayName);

if (!account) {
return null;
Expand Down
Loading

0 comments on commit 1d6386e

Please sign in to comment.