Skip to content

Commit

Permalink
Transform daoSnapshotENS to lower case
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrila committed Aug 15, 2024
1 parent 120a3fa commit fe42cf7
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { URL_DOCS_GOV_TYPES } from '../../../constants/url';
import { createAccountSubstring } from '../../../hooks/utils/useDisplayName';
import { useFractal } from '../../../providers/App/AppProvider';
import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider';
import { ICreationStepProps, VotingStrategyType, GovernanceType } from '../../../types';
import { GovernanceType, ICreationStepProps, VotingStrategyType } from '../../../types';
import { InputComponent, LabelComponent } from '../../ui/forms/InputComponent';
import LabelWrapper from '../../ui/forms/LabelWrapper';
import { RadioWithText } from '../../ui/forms/Radio/RadioWithText';
Expand Down Expand Up @@ -34,7 +34,7 @@ export function EstablishEssentials(props: ICreationStepProps) {
setFieldValue('essentials.daoName', daoName, false);
if (createAccountSubstring(daoAddress!) !== daoName) {
// Pre-fill the snapshot URL form field when editing
setFieldValue('essentials.snapshotENS', daoSnapshotENS || '', false);
setFieldValue('essentials.snapshotENS', daoSnapshotENS?.toLowerCase() || '', false);
}
}
}, [setFieldValue, mode, daoName, daoSnapshotENS, isEdit, daoAddress]);
Expand Down Expand Up @@ -70,7 +70,7 @@ export function EstablishEssentials(props: ICreationStepProps) {
helper={t('helperDAOName')}
isRequired
value={values.essentials.daoName}
id="searchEssentials-daoName"
id="essentials-daoName"
onChange={cEvent => setFieldValue('essentials.daoName', cEvent.target.value, true)}
onBlur={cEvent => setFieldValue('essentials.daoName', cEvent.target.value.trim(), true)}
disabled={daoNameDisabled}
Expand Down
6 changes: 4 additions & 2 deletions src/components/Proposals/ProposalInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Flex, Button, Link } from '@chakra-ui/react';
import { Box, Button, Flex, Link } from '@chakra-ui/react';
import { ArrowUpRight } from '@phosphor-icons/react';
import { useTranslation } from 'react-i18next';
import { Shield } from '../../assets/theme/custom/icons/Shield';
Expand Down Expand Up @@ -53,7 +53,9 @@ export function ProposalInfo({
/>
{isSnapshotProposal && (
<>
<SnapshotButton snapshotENS={`${daoSnapshotENS}/proposal/${proposal.proposalId}`} />
<SnapshotButton
snapshotENS={`${daoSnapshotENS?.toLowerCase()}/proposal/${proposal.proposalId}`}
/>
{(proposal as ExtendedSnapshotProposal).privacy === 'shutter' && (
<Button
as={Link}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button } from '@chakra-ui/react';
import { useState, useEffect, ChangeEventHandler } from 'react';
import { ChangeEventHandler, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { isHex, getAddress } from 'viem';
import { getAddress, isHex } from 'viem';
import { DAO_ROUTES } from '../../../../constants/routes';
import useSubmitProposal from '../../../../hooks/DAO/proposal/useSubmitProposal';
import { useCanUserCreateProposal } from '../../../../hooks/utils/useCanUserSubmitProposal';
Expand Down Expand Up @@ -38,7 +38,7 @@ export function MetadataContainer() {
}

if (daoSnapshotENS) {
setSnapshotENS(daoSnapshotENS);
setSnapshotENS(daoSnapshotENS.toLowerCase());
}
}, [daoName, daoSnapshotENS, daoAddress]);

Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/cards/DAOInfoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Flex, Text, Link, Center } from '@chakra-ui/react';
import { Box, Center, Flex, Link, Text } from '@chakra-ui/react';
import { Link as RouterLink } from 'react-router-dom';
import { DAO_ROUTES } from '../../../constants/routes';
import useDisplayName from '../../../hooks/utils/useDisplayName';
Expand Down Expand Up @@ -111,7 +111,7 @@ export function DAOInfoCard() {
<AddressCopier address={displayedAddress} />

{/* SNAPSHOT ICON LINK */}
{node.daoSnapshotENS && <SnapshotButton snapshotENS={node.daoSnapshotENS} />}
{node.daoSnapshotENS && <SnapshotButton snapshotENS={node.daoSnapshotENS.toLowerCase()} />}
</Flex>
</Box>
);
Expand Down
8 changes: 5 additions & 3 deletions src/components/ui/cards/DAONodeInfoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Flex, Text, FlexProps, Link, Center, VStack } from '@chakra-ui/react';
import { Center, Flex, FlexProps, Link, Text, VStack } from '@chakra-ui/react';
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 { FractalGuardContracts, FractalNode, FreezeGuard } from '../../../types';
import { SnapshotButton } from '../badges/Snapshot';
import { FavoriteIcon } from '../icons/FavoriteIcon';
import AddressCopier from '../links/AddressCopier';
Expand Down Expand Up @@ -104,7 +104,9 @@ export function DAONodeInfoCard({ node, freezeGuard, guardContracts, ...rest }:
/>

{/* SNAPSHOT ICON LINK */}
{node.daoSnapshotENS && <SnapshotButton snapshotENS={node.daoSnapshotENS} />}
{node.daoSnapshotENS && (
<SnapshotButton snapshotENS={node.daoSnapshotENS.toLowerCase()} />
)}
</Flex>

{/* DAO ADDRESS */}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/forms/ABISelector.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Select, Text } from '@chakra-ui/react';
import axios from 'axios';
import detectProxyTarget from 'evm-proxy-detection';
import { useMemo, useState, useEffect } from 'react';
import { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { isAddress } from 'viem';
import { useEnsAddress, usePublicClient } from 'wagmi';
Expand All @@ -28,7 +28,7 @@ export default function ABISelector({ target, onChange }: IABISelector) {
const [abi, setABI] = useState<ABIElement[]>([]);
const { etherscanAPIUrl } = useNetworkConfig();
const { t } = useTranslation('common');
const { data: ensAddress } = useEnsAddress({ name: target });
const { data: ensAddress } = useEnsAddress({ name: target?.toLowerCase() });
const client = usePublicClient();

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/DAO/loaders/snapshot/useSnapshotSpaceName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export default function useSnapshotSpaceName() {
node: { daoSnapshotENS },
} = useFractal();

return daoSnapshotENS;
return daoSnapshotENS?.toLowerCase();
}
2 changes: 1 addition & 1 deletion src/hooks/DAO/loaders/useFractalNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const useFractalNode = (
},
daoName: name as string,
daoAddress: getAddress(_daoAddress),
daoSnapshotENS: snapshotENS as string,
daoSnapshotENS: snapshotENS?.toLowerCase() as string,
proposalTemplatesHash: proposalTemplatesHash as string,
};
return currentNode;
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/DAO/loaders/useLoadDAONode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useLazyQuery } from '@apollo/client';
import { useCallback } from 'react';
import { isAddress, getAddress } from 'viem';
import { getAddress, isAddress } from 'viem';
import { DAO, DAOQueryDocument, DAOQueryQuery } from '../../../../.graphclient';
import { logError } from '../../../helpers/errorLogging';
import { useSafeAPI } from '../../../providers/App/hooks/useSafeAPI';
Expand Down Expand Up @@ -42,7 +42,7 @@ export const useLoadDAONode = () => {
},
daoName: name as string,
daoAddress: getAddress(_daoAddress),
daoSnapshotENS: snapshotENS as string,
daoSnapshotENS: snapshotENS?.toLowerCase() as string,
};
return currentNode;
}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/DAO/useGetDAOName.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useState } from 'react';
import { Address, PublicClient, getContract, parseAbi, getAddress } from 'viem';
import { Address, PublicClient, getAddress, getContract, parseAbi } from 'viem';
import { usePublicClient } from 'wagmi';
import { useFractal } from '../../providers/App/AppProvider';
import { FractalContracts } from '../../types';
Expand All @@ -22,7 +22,7 @@ const getDAOName = async ({
throw new Error('Public client not available');
}

const ensName = await publicClient.getEnsName({ address: address }).catch((error: Error) => {
const ensName = await publicClient.getEnsName({ address }).catch((error: Error) => {
if (error.name === 'ChainDoesNotSupportContract') {
// Sliently fail, this is fine.
// https://github.com/wevm/viem/discussions/781
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/utils/useAvatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigPro
const useAvatar = (name: string) => {
const { chain } = useNetworkConfig();
const { data: avatarURL } = useEnsAvatar({
name: name,
name: name?.toLowerCase(),
chainId: chain.id,
});

Expand Down
8 changes: 4 additions & 4 deletions src/models/DaoTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { zeroAddress } from 'viem';
import { GnosisSafeL2 } from '../assets/typechain-types/usul/@gnosis.pm/safe-contracts/contracts';
import { buildContractCall, encodeMultiSend } from '../helpers';
import {
BaseContracts,
SafeMultisigDAO,
SafeTransaction,
AzoriusContracts,
AzoriusERC20DAO,
AzoriusERC721DAO,
BaseContracts,
SafeMultisigDAO,
SafeTransaction,
VotingStrategyType,
} from '../types';
import { BaseTxBuilder } from './BaseTxBuilder';
Expand Down Expand Up @@ -228,7 +228,7 @@ export class DaoTxBuilder extends BaseTxBuilder {
return buildContractCall(
this.baseContracts.keyValuePairsContract,
'updateValues',
[['snapshotENS'], [this.daoData.snapshotENS]],
[['snapshotENS'], [this.daoData.snapshotENS.toLowerCase()]],
0,
false,
);
Expand Down

0 comments on commit fe42cf7

Please sign in to comment.