diff --git a/package-lock.json b/package-lock.json index c290ccf200..1227202c32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "name": "fractal-interface", "hasInstallScript": true, "dependencies": { + "@adraffy/ens-normalize": "^1.10.1", "@apollo/client": "^3.7.10", "@chakra-ui/react": "^2.8.2", "@decent-org/fractal-ui": "^0.1.25", @@ -95,9 +96,9 @@ "dev": true }, "node_modules/@adraffy/ens-normalize": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz", - "integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==" + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz", + "integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==" }, "node_modules/@ampproject/remapping": { "version": "2.2.0", @@ -10175,6 +10176,11 @@ "viem": "^1.0.0" } }, + "node_modules/@safe-global/safe-apps-sdk/node_modules/@adraffy/ens-normalize": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz", + "integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==" + }, "node_modules/@safe-global/safe-apps-sdk/node_modules/@scure/bip32": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.2.tgz", @@ -22783,6 +22789,11 @@ } } }, + "node_modules/mipd/node_modules/@adraffy/ens-normalize": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz", + "integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==" + }, "node_modules/mipd/node_modules/@scure/bip32": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.2.tgz", @@ -28740,6 +28751,11 @@ } } }, + "node_modules/viem/node_modules/@adraffy/ens-normalize": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz", + "integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==" + }, "node_modules/viem/node_modules/@scure/bip32": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.2.tgz", diff --git a/package.json b/package.json index 6006e15e64..9175d797b3 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "fractal-interface", "private": true, "dependencies": { + "@adraffy/ens-normalize": "^1.10.1", "@apollo/client": "^3.7.10", "@chakra-ui/react": "^2.8.2", "@decent-org/fractal-ui": "^0.1.25", diff --git a/src/components/DaoCreator/constants.ts b/src/components/DaoCreator/constants.ts index 196ad440ed..d29a0f36a7 100644 --- a/src/components/DaoCreator/constants.ts +++ b/src/components/DaoCreator/constants.ts @@ -13,7 +13,7 @@ export const initialState: CreatorFormState = { essentials: { daoName: '', governance: GovernanceType.MULTISIG, - snapshotURL: '', + snapshotENS: '', }, erc20Token: { tokenCreationType: TokenCreationType.NEW, diff --git a/src/components/DaoCreator/formComponents/EstablishEssentials.tsx b/src/components/DaoCreator/formComponents/EstablishEssentials.tsx index 89de33253d..0349479ea5 100644 --- a/src/components/DaoCreator/formComponents/EstablishEssentials.tsx +++ b/src/components/DaoCreator/formComponents/EstablishEssentials.tsx @@ -1,6 +1,7 @@ +import { ens_normalize } from '@adraffy/ens-normalize'; import { Box, Divider, Input, RadioGroup } from '@chakra-ui/react'; import { LabelWrapper } from '@decent-org/fractal-ui'; -import { useEffect } from 'react'; +import { useEffect, useState } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { BACKGROUND_SEMI_TRANSPARENT } from '../../../constants/common'; import { URL_DOCS_GOV_TYPES } from '../../../constants/url'; @@ -29,8 +30,10 @@ export function EstablishEssentials(props: ICreationStepProps) { const { t } = useTranslation(['daoCreate', 'common']); const { values, setFieldValue, isSubmitting, transactionPending, isSubDAO, errors, mode } = props; + const [isSnapshotSpaceValid, setSnapshotSpaceValid] = useState(true); + const { - node: { daoName, daoSnapshotURL, daoAddress }, + node: { daoName, daoSnapshotENS, daoAddress }, } = useFractal(); const isEdit = mode === DAOCreateMode.EDIT; @@ -38,14 +41,18 @@ export function EstablishEssentials(props: ICreationStepProps) { useEffect(() => { if (isEdit) { setFieldValue('essentials.daoName', daoName, false); - if (createAccountSubstring(daoAddress!) !== daoName) - setFieldValue('essentials.snapshotURL', daoSnapshotURL || '', false); + if (createAccountSubstring(daoAddress!) !== daoName) { + // Pre-fill the snapshot URL form field when editing + setFieldValue('essentials.snapshotENS', daoSnapshotENS || '', false); + } } - }, [setFieldValue, mode, daoName, daoSnapshotURL, isEdit, daoAddress]); + }, [setFieldValue, mode, daoName, daoSnapshotENS, isEdit, daoAddress]); const daoNameDisabled = isEdit && !!daoName && !!daoAddress && createAccountSubstring(daoAddress) !== daoName; - const snapshotURLDisabled = isEdit && !!daoSnapshotURL; + + // If in governance edit mode and snapshot URL is already set, disable the field + const snapshotENSDisabled = isEdit && !!daoSnapshotENS; const handleGovernanceChange = (value: string) => { if (value === GovernanceType.AZORIUS_ERC20) { @@ -57,6 +64,24 @@ export function EstablishEssentials(props: ICreationStepProps) { setFieldValue('essentials.governance', value); }; + const handleSnapshotSpaceChange = (value: string) => { + setFieldValue('essentials.snapshotENS', value, true); + + // If there's no input in the snapshot URL field, we don't need to check if it's valid + if (!value) { + setSnapshotSpaceValid(true); + return; + } + + try { + ens_normalize(value); + setSnapshotSpaceValid(true); + } catch (error) { + console.log(error); + setSnapshotSpaceValid(false); + } + }; + const { createOptions } = useNetworkConfig(); return ( @@ -160,14 +185,13 @@ export function EstablishEssentials(props: ICreationStepProps) { helper={t('snapshotHelper')} isRequired={false} > - + setFieldValue('essentials.snapshotURL', cEvent.target.value, true)} - isDisabled={snapshotURLDisabled} - data-testid="essentials-snapshotURL" + value={values.essentials.snapshotENS} + onChange={cEvent => handleSnapshotSpaceChange(cEvent.target.value)} + isDisabled={snapshotENSDisabled} + data-testid="essentials-snapshotENS" placeholder="example.eth" - maxLength={30} /> @@ -179,6 +203,7 @@ export function EstablishEssentials(props: ICreationStepProps) { { const choosenGovernance = values.essentials.governance; const freezeGuard = isSubDAO ? values.freeze : undefined; + switch (choosenGovernance) { case GovernanceType.MULTISIG: { const data = await prepareMultisigFormData({ diff --git a/src/components/Proposals/ProposalInfo.tsx b/src/components/Proposals/ProposalInfo.tsx index c72d393241..4241c6eb4e 100644 --- a/src/components/Proposals/ProposalInfo.tsx +++ b/src/components/Proposals/ProposalInfo.tsx @@ -20,7 +20,7 @@ export function ProposalInfo({ const metaData = useGetMetadata(proposal); const { t } = useTranslation('proposal'); const { - node: { daoSnapshotURL }, + node: { daoSnapshotENS }, } = useFractal(); const { isSnapshotProposal } = useSnapshotProposal(proposal); @@ -36,7 +36,7 @@ export function ProposalInfo({ {isSnapshotProposal && ( <> {(proposal as ExtendedSnapshotProposal).privacy === 'shutter' && ( diff --git a/src/components/Proposals/index.tsx b/src/components/Proposals/index.tsx index f324ce185e..d1c53e3f38 100644 --- a/src/components/Proposals/index.tsx +++ b/src/components/Proposals/index.tsx @@ -42,7 +42,7 @@ const FILTERS_SNAPSHOT = [FractalProposalState.CLOSED, FractalProposalState.PEND export default function Proposals() { const { - node: { daoSnapshotURL }, + node: { daoSnapshotENS }, governance: { type }, guardContracts, } = useFractal(); @@ -72,12 +72,12 @@ export default function Proposals() { } break; } - if (daoSnapshotURL) { + if (daoSnapshotENS) { options = [...options, ...FILTERS_SNAPSHOT]; } setAllOptions(options); setFilters(options); - }, [daoSnapshotURL, guardContracts.freezeGuardContractAddress, type]); + }, [daoSnapshotENS, guardContracts.freezeGuardContractAddress, type]); const toggleFilter = (filter: FractalProposalState) => { setFilters(prevState => { diff --git a/src/components/pages/DaoSettings/components/Metadata/index.tsx b/src/components/pages/DaoSettings/components/Metadata/index.tsx index e1b754b371..831fc68078 100644 --- a/src/components/pages/DaoSettings/components/Metadata/index.tsx +++ b/src/components/pages/DaoSettings/components/Metadata/index.tsx @@ -1,3 +1,4 @@ +import { ens_normalize } from '@adraffy/ens-normalize'; import { Flex, Text, Button, Divider } from '@chakra-ui/react'; import { useState, useEffect, ChangeEventHandler } from 'react'; import { useTranslation } from 'react-i18next'; @@ -10,13 +11,12 @@ import { createAccountSubstring } from '../../../../../hooks/utils/useDisplayNam 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'; export default function MetadataContainer() { const [name, setName] = useState(''); - const [snapshotURL, setSnapshotURL] = useState(''); - const [snapshotURLValid, setSnapshotURLValid] = useState(); + const [snapshotENS, setSnapshotENS] = useState(''); + const [snapshotENSValid, setSnapshotENSValid] = useState(); const { t } = useTranslation(['settings', 'proposalMetadata']); const navigate = useNavigate(); @@ -24,7 +24,7 @@ export default function MetadataContainer() { const { canUserCreateProposal } = useCanUserCreateProposal(); const { baseContracts, - node: { daoName, daoSnapshotURL, daoAddress, safe }, + node: { daoName, daoSnapshotENS, daoAddress, safe }, readOnly: { user: { votingWeight }, }, @@ -36,19 +36,19 @@ export default function MetadataContainer() { setName(daoName); } - if (daoSnapshotURL) { - setSnapshotURL(daoSnapshotURL); + if (daoSnapshotENS) { + setSnapshotENS(daoSnapshotENS); } - }, [daoName, daoSnapshotURL, daoAddress]); + }, [daoName, daoSnapshotENS, daoAddress]); - const handleSnapshotURLChange: ChangeEventHandler = e => { - if (couldBeENS(e.target.value)) { - setSnapshotURLValid(true); - } else { - setSnapshotURLValid(false); + const handleSnapshotENSChange: ChangeEventHandler = e => { + setSnapshotENS(e.target.value); + try { + ens_normalize(e.target.value); + setSnapshotENSValid(true); + } catch (error) { + setSnapshotENSValid(false); } - - setSnapshotURL(e.target.value); }; const userHasVotingWeight = votingWeight > 0n; @@ -87,7 +87,7 @@ export default function MetadataContainer() { }); }; - const handleEditDAOSnapshotURL = () => { + const handleEditDAOSnapshotENS = () => { if (!baseContracts) { return; } @@ -102,8 +102,8 @@ export default function MetadataContainer() { values: [0n], calldatas: [ keyValuePairsContract.asProvider.interface.encodeFunctionData('updateValues', [ - ['snapshotURL'], - [snapshotURL], + ['snapshotENS'], + [snapshotENS], ]), ], }; @@ -182,9 +182,9 @@ export default function MetadataContainer() { {canUserCreateProposal && ( @@ -192,11 +192,11 @@ export default function MetadataContainer() { )} - {node.daoSnapshotURL && } + {node.daoSnapshotENS && } ); diff --git a/src/hooks/DAO/loaders/snapshot/index.ts b/src/hooks/DAO/loaders/snapshot/index.ts index 4c6c14b179..1740bb2e90 100644 --- a/src/hooks/DAO/loaders/snapshot/index.ts +++ b/src/hooks/DAO/loaders/snapshot/index.ts @@ -11,9 +11,9 @@ const defaultOptions: DefaultOptions = { }, }; -export const createClient = (uri: string) => +export const createSnapshotGraphQlClient = () => new ApolloClient({ - uri: `https://${uri.includes('testnet') ? 'testnet.' : ''}hub.snapshot.org/graphql`, + uri: 'https://hub.snapshot.org/graphql', cache: new InMemoryCache(), defaultOptions, }); diff --git a/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts b/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts index 24ea78a238..726524207e 100644 --- a/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts +++ b/src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts @@ -11,23 +11,18 @@ import { SnapshotWeightedVotingChoice, } from '../../../../types'; import useSnapshotSpaceName from './useSnapshotSpaceName'; -import { createClient } from './'; +import { createSnapshotGraphQlClient } from './'; export default function useSnapshotProposal(proposal: FractalProposal | null | undefined) { const [extendedSnapshotProposal, setExtendedSnapshotProposal] = useState(); const { - node: { daoSnapshotURL }, readOnly: { user: { address }, }, } = useFractal(); const daoSnapshotSpaceName = useSnapshotSpaceName(); - const client = useMemo(() => { - if (daoSnapshotURL) { - return createClient(daoSnapshotURL); - } - }, [daoSnapshotURL]); + const snaphshotGraphQlClient = useMemo(() => createSnapshotGraphQlClient(), []); const snapshotProposal = proposal as SnapshotProposal; const isSnapshotProposal = useMemo( @@ -36,8 +31,8 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u ); const loadProposal = useCallback(async () => { - if (snapshotProposal?.snapshotProposalId && client) { - const proposalQueryResult = await client + if (snapshotProposal?.snapshotProposalId && snaphshotGraphQlClient) { + const proposalQueryResult = await snaphshotGraphQlClient .query({ query: gql` query ExtendedSnapshotProposal { @@ -77,7 +72,7 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u }, ); - const votesQueryResult = await client + const votesQueryResult = await snaphshotGraphQlClient .query({ query: gql`query SnapshotProposalVotes { votes(where: {proposal: "${snapshotProposal.snapshotProposalId}"}, first: 500) { @@ -199,7 +194,12 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u votes: votesQueryResult, } as ExtendedSnapshotProposal); } - }, [snapshotProposal?.snapshotProposalId, proposal, snapshotProposal?.state, client]); + }, [ + snapshotProposal?.snapshotProposalId, + proposal, + snapshotProposal?.state, + snaphshotGraphQlClient, + ]); const loadVotingWeight = useCallback(async () => { const emptyVotingWeight = { @@ -207,8 +207,8 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u votingWeightByStrategy: [0], votingState: '', }; - if (snapshotProposal?.snapshotProposalId && client) { - const queryResult = await client + if (snapshotProposal?.snapshotProposalId && snaphshotGraphQlClient) { + const queryResult = await snaphshotGraphQlClient .query({ query: gql` query UserVotingWeight { @@ -239,7 +239,7 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u } return emptyVotingWeight; - }, [address, snapshotProposal?.snapshotProposalId, client, daoSnapshotSpaceName]); + }, [address, snapshotProposal?.snapshotProposalId, snaphshotGraphQlClient, daoSnapshotSpaceName]); return { loadVotingWeight, diff --git a/src/hooks/DAO/loaders/snapshot/useSnapshotProposals.ts b/src/hooks/DAO/loaders/snapshot/useSnapshotProposals.ts index 3156b53459..7bf8d495e9 100644 --- a/src/hooks/DAO/loaders/snapshot/useSnapshotProposals.ts +++ b/src/hooks/DAO/loaders/snapshot/useSnapshotProposals.ts @@ -5,24 +5,17 @@ import { FractalGovernanceAction } from '../../../../providers/App/governance/ac import { ActivityEventType, FractalProposalState } from '../../../../types'; import { SnapshotProposal } from '../../../../types/daoProposal'; import useSnapshotSpaceName from './useSnapshotSpaceName'; -import { createClient } from './'; +import { createSnapshotGraphQlClient } from './'; export const useSnapshotProposals = () => { - const { - node: { daoSnapshotURL }, - action, - } = useFractal(); + const { action } = useFractal(); const daoSnapshotSpaceName = useSnapshotSpaceName(); - const currentSnapshotURL = useRef(); - const client = useMemo(() => { - if (daoSnapshotURL) { - return createClient(daoSnapshotURL); - } - }, [daoSnapshotURL]); + const currentSnapshotENS = useRef(); + const snaphshotGraphQlClient = useMemo(() => createSnapshotGraphQlClient(), []); const loadSnapshotProposals = useCallback(async () => { - if (client) { - client + if (snaphshotGraphQlClient) { + snaphshotGraphQlClient .query({ query: gql` query Proposals { @@ -80,11 +73,11 @@ export const useSnapshotProposals = () => { }); }); } - }, [action, daoSnapshotSpaceName, client]); + }, [action, daoSnapshotSpaceName, snaphshotGraphQlClient]); useEffect(() => { - if (!daoSnapshotSpaceName || daoSnapshotSpaceName === currentSnapshotURL.current) return; - currentSnapshotURL.current = daoSnapshotSpaceName; + if (!daoSnapshotSpaceName || daoSnapshotSpaceName === currentSnapshotENS.current) return; + currentSnapshotENS.current = daoSnapshotSpaceName; loadSnapshotProposals(); }, [daoSnapshotSpaceName, loadSnapshotProposals]); }; diff --git a/src/hooks/DAO/loaders/snapshot/useSnapshotSpaceName.ts b/src/hooks/DAO/loaders/snapshot/useSnapshotSpaceName.ts index 478930a086..d47fa442ef 100644 --- a/src/hooks/DAO/loaders/snapshot/useSnapshotSpaceName.ts +++ b/src/hooks/DAO/loaders/snapshot/useSnapshotSpaceName.ts @@ -2,8 +2,8 @@ import { useFractal } from '../../../../providers/App/AppProvider'; export default function useSnapshotSpaceName() { const { - node: { daoSnapshotURL }, + node: { daoSnapshotENS }, } = useFractal(); - return daoSnapshotURL?.split('/').pop(); + return daoSnapshotENS; } diff --git a/src/hooks/DAO/loaders/useFractalNode.ts b/src/hooks/DAO/loaders/useFractalNode.ts index 0777b30e5e..a8efbc61e7 100644 --- a/src/hooks/DAO/loaders/useFractalNode.ts +++ b/src/hooks/DAO/loaders/useFractalNode.ts @@ -40,7 +40,13 @@ export const useFractalNode = ( const { daos } = result.data; const dao = daos[0]; if (dao) { - const { parentAddress, name, hierarchy, snapshotURL, proposalTemplatesHash } = dao; + const { + parentAddress, + name, + hierarchy, + snapshotURL: snapshotENS, + proposalTemplatesHash, + } = dao; const currentNode: Node = { nodeHierarchy: { @@ -49,7 +55,7 @@ export const useFractalNode = ( }, daoName: name as string, daoAddress: utils.getAddress(_daoAddress as string), - daoSnapshotURL: snapshotURL as string, + daoSnapshotENS: snapshotENS as string, proposalTemplatesHash: proposalTemplatesHash as string, }; return currentNode; diff --git a/src/hooks/DAO/loaders/useLoadDAONode.ts b/src/hooks/DAO/loaders/useLoadDAONode.ts index 1d10e4a348..e346c2a7bd 100644 --- a/src/hooks/DAO/loaders/useLoadDAONode.ts +++ b/src/hooks/DAO/loaders/useLoadDAONode.ts @@ -30,7 +30,7 @@ export const useLoadDAONode = () => { const { daos } = result.data; const dao = daos[0]; if (dao) { - const { parentAddress, name, hierarchy, snapshotURL } = dao; + const { parentAddress, name, hierarchy, snapshotURL: snapshotENS } = dao; const currentNode: Node = { nodeHierarchy: { @@ -39,7 +39,7 @@ export const useLoadDAONode = () => { }, daoName: name as string, daoAddress: utils.getAddress(_daoAddress as string), - daoSnapshotURL: snapshotURL as string, + daoSnapshotENS: snapshotENS as string, }; return currentNode; } diff --git a/src/hooks/DAO/proposal/useCastVote.ts b/src/hooks/DAO/proposal/useCastVote.ts index f0550e5836..9a75f048b2 100644 --- a/src/hooks/DAO/proposal/useCastVote.ts +++ b/src/hooks/DAO/proposal/useCastVote.ts @@ -34,7 +34,7 @@ const useCastVote = ({ const { governanceContracts: { ozLinearVotingContractAddress, erc721LinearVotingContractAddress }, governance, - node: { daoSnapshotURL }, + node: { daoSnapshotENS }, readOnly: { user: { address }, }, @@ -43,15 +43,11 @@ const useCastVote = ({ const daoSnapshotSpaceName = useSnapshotSpaceName(); const signer = useEthersSigner(); const client = useMemo(() => { - if (daoSnapshotURL) { - const isTestnetSnapshotURL = daoSnapshotURL.includes('testnet'); - const hub = isTestnetSnapshotURL - ? 'https://testnet.seq.snapshot.org' // This is not covered in Snapshot docs, but that's where they're sending request on testnet - : 'https://hub.snapshot.org'; - return new snapshot.Client712(hub); + if (daoSnapshotENS) { + return new snapshot.Client712('https://hub.snapshot.org'); } return undefined; - }, [daoSnapshotURL]); + }, [daoSnapshotENS]); const azoriusGovernance = useMemo(() => governance as AzoriusGovernance, [governance]); const { type } = azoriusGovernance; diff --git a/src/hooks/schemas/DAOCreate/useDAOCreateSchema.ts b/src/hooks/schemas/DAOCreate/useDAOCreateSchema.ts index 934da55988..c2b83b0888 100644 --- a/src/hooks/schemas/DAOCreate/useDAOCreateSchema.ts +++ b/src/hooks/schemas/DAOCreate/useDAOCreateSchema.ts @@ -34,7 +34,7 @@ export const useDAOCreateSchema = ({ isSubDAO }: { isSubDAO?: boolean }) => { essentials: Yup.object().shape({ daoName: Yup.string().required(), governance: Yup.string().required(), - snapshotURL: Yup.string(), + snapshotENS: Yup.string(), }), multisig: Yup.object().when('essentials', { is: ({ governance }: DAOEssentials) => governance === GovernanceType.MULTISIG, diff --git a/src/models/DaoTxBuilder.ts b/src/models/DaoTxBuilder.ts index ce6afa7069..723b78b094 100644 --- a/src/models/DaoTxBuilder.ts +++ b/src/models/DaoTxBuilder.ts @@ -85,7 +85,7 @@ export class DaoTxBuilder extends BaseTxBuilder { } if (shouldSetSnapshot) { - this.internalTxs = this.internalTxs.concat(this.buildUpdateDAOSnapshotURLTx()); + this.internalTxs = this.internalTxs.concat(this.buildUpdateDAOSnapshotENSTx()); } this.internalTxs = this.internalTxs.concat( @@ -159,7 +159,7 @@ export class DaoTxBuilder extends BaseTxBuilder { const multisigTxBuilder = this.txBuilderFactory.createMultiSigTxBuilder(); this.internalTxs.push(this.buildUpdateDAONameTx()); - this.internalTxs.push(this.buildUpdateDAOSnapshotURLTx()); + this.internalTxs.push(this.buildUpdateDAOSnapshotENSTx()); // subDAO case, add freeze guard if (this.parentAddress) { @@ -227,11 +227,11 @@ export class DaoTxBuilder extends BaseTxBuilder { ); } - private buildUpdateDAOSnapshotURLTx(): SafeTransaction { + private buildUpdateDAOSnapshotENSTx(): SafeTransaction { return buildContractCall( this.baseContracts.keyValuePairsContract, 'updateValues', - [['snapshotURL'], [this.daoData.snapshotURL]], + [['snapshotURL'], [this.daoData.snapshotENS]], 0, false, ); diff --git a/src/pages/daos/[daoAddress]/edit/governance/index.tsx b/src/pages/daos/[daoAddress]/edit/governance/index.tsx index 174fc56ae1..81d45f7550 100644 --- a/src/pages/daos/[daoAddress]/edit/governance/index.tsx +++ b/src/pages/daos/[daoAddress]/edit/governance/index.tsx @@ -21,7 +21,7 @@ import { export default function ModifyGovernancePage() { const { - node: { daoAddress, safe, daoName, daoSnapshotURL }, + node: { daoAddress, safe, daoName, daoSnapshotENS }, governance: { type }, readOnly: { user }, } = useFractal(); @@ -36,7 +36,7 @@ export default function ModifyGovernancePage() { deployAzorius( daoData as AzoriusERC20DAO | AzoriusERC721DAO, !daoName || createAccountSubstring(daoAddress!) === daoName, - !daoSnapshotURL && !!daoData.snapshotURL, + !daoSnapshotENS && !!daoData.snapshotENS, ); }; diff --git a/src/types/createDAO.ts b/src/types/createDAO.ts index 21cbf986b7..9d68f47b75 100644 --- a/src/types/createDAO.ts +++ b/src/types/createDAO.ts @@ -38,7 +38,7 @@ export interface CreatorFormState { export type DAOEssentials = { daoName: string; governance: GovernanceType; - snapshotURL: string; + snapshotENS: string; }; export type DAOGovernorERC20Token = { diff --git a/src/types/fractal.ts b/src/types/fractal.ts index 8c0bc7b3b6..9a984807b6 100644 --- a/src/types/fractal.ts +++ b/src/types/fractal.ts @@ -132,13 +132,13 @@ export enum FractalProposalState { /** * The proposal is pending, meaning it has been created, but voting has not yet begun. This state * has nothing to do with Fractal, and is used for Snapshot proposals only, which appear if the - * DAO's snapshotURL is set. + * DAO's snapshotENS is set. */ PENDING = 'statePending', /** * The proposal is closed, and no longer able to be signed. This state has nothing to do with Fractal, - * and is used for Snapshot proposals only, which appear if the DAO's snapshotURL is set. + * and is used for Snapshot proposals only, which appear if the DAO's snapshotENS is set. */ CLOSED = 'stateClosed', } @@ -238,7 +238,7 @@ export interface FractalNode { nodeHierarchy: NodeHierarchy; isModulesLoaded?: boolean; isHierarchyLoaded?: boolean; - daoSnapshotURL?: string; + daoSnapshotENS?: string; proposalTemplatesHash?: string; }