Skip to content

Commit

Permalink
Finish removing "snapshotURL" from the app everywhere except the edges
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgall committed Apr 17, 2024
1 parent d4af814 commit fe68ae2
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
11 changes: 3 additions & 8 deletions src/components/DaoCreator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,10 @@ function DaoCreator({
const choosenGovernance = values.essentials.governance;
const freezeGuard = isSubDAO ? values.freeze : undefined;

const valuesEssentialsWithSnapshotURL = {
...values.essentials,
snapshotURL: values.essentials.snapshotENS,
};

switch (choosenGovernance) {
case GovernanceType.MULTISIG: {
const data = await prepareMultisigFormData({
...valuesEssentialsWithSnapshotURL,
...values.essentials,
...values.multisig,
freezeGuard,
});
Expand All @@ -49,7 +44,7 @@ function DaoCreator({
}
case GovernanceType.AZORIUS_ERC20: {
const data = await prepareAzoriusERC20FormData({
...valuesEssentialsWithSnapshotURL,
...values.essentials,
...values.azorius,
...values.erc20Token,
freezeGuard,
Expand All @@ -61,7 +56,7 @@ function DaoCreator({
}
case GovernanceType.AZORIUS_ERC721: {
const data = await prepareAzoriusERC721FormData({
...valuesEssentialsWithSnapshotURL,
...values.essentials,
...values.azorius,
...values.erc721Token,
freezeGuard,
Expand Down
53 changes: 34 additions & 19 deletions src/hooks/DAO/loaders/governance/useAzoriusProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import { VotedEvent as ERC20VotedEvent } from '@fractal-framework/fractal-contracts/dist/typechain-types/contracts/azorius/LinearERC20Voting';
import { VotedEvent as ERC721VotedEvent } from '@fractal-framework/fractal-contracts/dist/typechain-types/contracts/azorius/LinearERC721Voting';
import { useCallback, useEffect, useMemo, useRef } from 'react';
import { logError } from '../../../../helpers/errorLogging';
import { useFractal } from '../../../../providers/App/AppProvider';
import { useEthersProvider } from '../../../../providers/Ethers/hooks/useEthersProvider';
import { CreateProposalMetadata, VotingStrategyType, DecodedTransaction } from '../../../../types';
Expand Down Expand Up @@ -140,25 +141,39 @@ export const useAzoriusProposals = () => {
for (const proposalCreatedEvent of proposalCreatedEvents) {
let proposalData;
if (proposalCreatedEvent.args.metadata) {
const metadataEvent: CreateProposalMetadata = JSON.parse(
proposalCreatedEvent.args.metadata,
);
const decodedTransactions = await decodeTransactions(
_decode,
proposalCreatedEvent.args.transactions.map(t => ({ ...t, value: t.value.toBigInt() })),
);
proposalData = {
metaData: {
title: metadataEvent.title,
description: metadataEvent.description,
documentationUrl: metadataEvent.documentationUrl,
},
transactions: proposalCreatedEvent.args.transactions.map(t => ({
...t,
value: t.value.toBigInt(),
})),
decodedTransactions,
};
try {
const metadataEvent: CreateProposalMetadata = JSON.parse(
proposalCreatedEvent.args.metadata,
);

const decodedTransactions = await decodeTransactions(
_decode,
proposalCreatedEvent.args.transactions.map(t => ({
...t,
value: t.value.toBigInt(),
})),
);
proposalData = {
metaData: {
title: metadataEvent.title,
description: metadataEvent.description,
documentationUrl: metadataEvent.documentationUrl,
},
transactions: proposalCreatedEvent.args.transactions.map(t => ({
...t,
value: t.value.toBigInt(),
})),
decodedTransactions,
};
} catch {
logError(
'Unable to parse proposal metadata or transactions.',
'metadata:',
proposalCreatedEvent.args.metadata,
'transactions:',
proposalCreatedEvent.args.transactions,
);
}
}

const proposal = await mapProposalCreatedEventToProposal(
Expand Down
2 changes: 1 addition & 1 deletion src/models/DaoTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class DaoTxBuilder extends BaseTxBuilder {
return buildContractCall(
this.baseContracts.keyValuePairsContract,
'updateValues',
[['snapshotURL'], [this.daoData.snapshotURL]],
[['snapshotURL'], [this.daoData.snapshotENS]],
0,
false,
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/daos/[daoAddress]/edit/governance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function ModifyGovernancePage() {
deployAzorius(
daoData as AzoriusERC20DAO | AzoriusERC721DAO,
!daoName || createAccountSubstring(daoAddress!) === daoName,
!daoSnapshotENS && !!daoData.snapshotURL,
!daoSnapshotENS && !!daoData.snapshotENS,
);
};

Expand Down
14 changes: 2 additions & 12 deletions src/types/createDAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ export type DAOEssentials = {
snapshotENS: string;
};

/**
* `DAOEssentialsEdge` is a transitionary type that is used in place of the in-app-only `DAOEssentials` type.
* `DAOEssentialsEdge` has a `snapshotURL` field in place of a `snapshotENS` field.
*
* A recent update necessitated the renaming of references to `snapshotURL` to `snapshotENS`,
* but as the contracts and subgraph already use `snapshotURL`, this type is used to maintain compatibility
* of the app with the contracts and subgraph of the outside world.
*/
type DAOEssentialsEdge = Omit<DAOEssentials, 'snapshotENS'> & { snapshotURL: string };

export type DAOGovernorERC20Token<T = bigint> = {
tokenCreationType: TokenCreationType;
tokenImportAddress?: string;
Expand Down Expand Up @@ -100,7 +90,7 @@ export interface SubDAO<T = bigint>
DAOFreezeGuardConfig<T> {}

export interface AzoriusGovernanceDAO<T = bigint>
extends DAOEssentialsEdge,
extends DAOEssentials,
DAOGovernorModuleConfig<T> {}

export interface AzoriusERC20DAO<T = bigint>
Expand All @@ -114,7 +104,7 @@ export interface AzoriusERC721DAO<T = bigint>
extends AzoriusGovernanceDAO<T>,
DAOGovernorERC721Token<T> {}

export interface SafeMultisigDAO extends DAOEssentialsEdge, SafeConfiguration {}
export interface SafeMultisigDAO extends DAOEssentials, SafeConfiguration {}

export type DAOTrigger = (
daoData: SafeMultisigDAO | AzoriusERC20DAO | AzoriusERC721DAO | SubDAO,
Expand Down

0 comments on commit fe68ae2

Please sign in to comment.