Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/ethers-provider-and-signer
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrila committed Mar 4, 2024
2 parents e1c896b + 2cd70e5 commit a9d4ae7
Show file tree
Hide file tree
Showing 21 changed files with 391 additions and 338 deletions.
2 changes: 0 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ NEXT_PUBLIC_ALCHEMY_SEPOLIA_API_KEY=""
NEXT_PUBLIC_ALCHEMY_TESTING_API_KEY=""
# ABI selector (*)
NEXT_PUBLIC_ETHERSCAN_API_KEY=""
# wallet providers (*)
NEXT_PUBLIC_INFURA_API_KEY=""
# IPFS pinning (*)
NEXT_PUBLIC_INFURA_IPFS_API_KEY=""
# IPFS pinning (*)
Expand Down
12 changes: 1 addition & 11 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
'use client';

import '@fontsource/ibm-plex-mono';
import '@fontsource/ibm-plex-sans';
import 'i18next';
import { ReactNode, useEffect } from 'react';
import 'react-toastify/dist/ReactToastify.min.css';
import { ReactNode } from 'react';
import { APP_NAME } from '../src/constants/common';
import { initErrorLogging } from '../src/helpers/errorLogging';
import Providers from '../src/providers/Providers';

export default function RootLayout({ children }: { children: ReactNode }) {
useEffect(() => {
initErrorLogging();
}, []);

return (
<html>
<head>
Expand Down
38 changes: 13 additions & 25 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ const FEATURED_DAOS = new Map<number, Feature[]>([
[
mainnet.id,
[
{
iconSrc: '/images/shutter-icon-only-logo.svg',
titleKey: 'shutterTitle',
descKey: 'shutterDesc',
address: '0x36bD3044ab68f600f6d3e081056F34f2a58432c4',
},
{
iconSrc: '/images/icon-decent.svg',
titleKey: 'decentTitle',
Expand All @@ -60,34 +66,16 @@ const FEATURED_DAOS = new Map<number, Feature[]>([
descKey: 'awakeDesc',
address: '0xdD6CeFA62239272f1eDf755ba6471eacb7DF2Fa5',
},
{
iconSrc: ethLizardsLogo.src,
titleKey: 'ethlizardsTitle',
descKey: 'ethlizardsDesc',
address: '0x167bE4073f52aD2Aa0D6d6FeddF0F1f79a82B98e', // TODO: Change to mainnet address once it will be there
},
],
],
[
sepolia.id,
[
{
iconSrc: '/images/icon-decent.svg',
titleKey: 'decentTitle',
descKey: 'decentDesc',
address: '0xD26c85D435F02DaB8B220cd4D2d398f6f646e235', // TODO: Change to Sepolia Address once it will be there
},
{
iconSrc: '/images/icon-awakevc.svg',
titleKey: 'awakeTitle',
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
iconSrc: '/images/icon-myosin.svg',
titleKey: 'myosinTitle',
descKey: 'myosinDesc',
address: '0xdef90A94273a1A1A72B33D39129fa41E6C08Be3a',
},
],
],
Expand Down Expand Up @@ -192,7 +180,7 @@ export default function HomePage() {
</Text>
}
/>
{features ? (
{features && features.length > 0 ? (
<>
<Text
paddingTop="3.5rem"
Expand Down Expand Up @@ -227,8 +215,8 @@ export default function HomePage() {
desc={t(feature.descKey)}
address={feature.address}
marginBottom="2rem"
paddingEnd={{ sm: '0rem', lg: index === 0 ? '0.56rem' : '0rem' }}
paddingStart={{ sm: '0rem', lg: index === 1 ? '0.56rem' : '0rem' }}
paddingEnd={{ sm: '0rem', lg: index % 2 === 0 ? '0.56rem' : '0rem' }}
paddingStart={{ sm: '0rem', lg: index % 2 === 1 ? '0.56rem' : '0rem' }}
/>
);
})}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fractal-interface",
"version": "0.1.7",
"version": "0.1.8",
"private": true,
"dependencies": {
"@apollo/client": "^3.7.10",
Expand Down
6 changes: 6 additions & 0 deletions public/images/icon-myosin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions public/images/shutter-icon-only-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 22 additions & 21 deletions src/components/pages/DaoDashboard/Info/InfoGovernance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,34 @@ export function InfoGovernance() {
} = useFractal();
const provider = useEthersProvider();
const { getTimeDuration } = useTimeHelpers();

const [timelockPeriod, setTimelockPeriod] = useState<string>();
const [executionPeriod, setExecutionPeriod] = useState<string>();
useEffect(() => {
const setTimelockInfo = async () => {
if (!timelockPeriod && !executionPeriod) {
const formatBlocks = async (blocks: number): Promise<string | undefined> => {
return getTimeDuration(await blocksToSeconds(blocks, provider));
};
if (freezeGuardType == FreezeGuardType.MULTISIG) {
if (freezeGuardContract) {
const freezeGuard = freezeGuardContract.asProvider as MultisigFreezeGuard;
setTimelockPeriod(await formatBlocks(await freezeGuard.timelockPeriod()));
setExecutionPeriod(await formatBlocks(await freezeGuard.executionPeriod()));
}
} else if (dao?.isAzorius) {
const azoriusGovernance = governance as AzoriusGovernance;
const timelock = azoriusGovernance.votingStrategy?.timeLockPeriod;
if (timelock?.formatted) {
setTimelockPeriod(timelock.formatted);
}
// TODO Azorius execution period
// We don't have room to fit a 5th row on this card currently,
// so leaving this off until we can have a discussion with design
// setExecutionPeriod(await freezeGuard.executionPeriod());
const formatBlocks = async (blocks: number): Promise<string | undefined> => {
return getTimeDuration(await blocksToSeconds(blocks, provider));
};
if (freezeGuardType == FreezeGuardType.MULTISIG) {
if (freezeGuardContract) {
const freezeGuard = freezeGuardContract.asProvider as MultisigFreezeGuard;
setTimelockPeriod(await formatBlocks(await freezeGuard.timelockPeriod()));
setExecutionPeriod(await formatBlocks(await freezeGuard.executionPeriod()));
}
} else if (dao?.isAzorius) {
const azoriusGovernance = governance as AzoriusGovernance;
const timelock = azoriusGovernance.votingStrategy?.timeLockPeriod;
if (timelock?.formatted) {
setTimelockPeriod(timelock.formatted);
}
// TODO Azorius execution period
// We don't have room to fit a 5th row on this card currently,
// so leaving this off until we can have a discussion with design
// setExecutionPeriod(await freezeGuard.executionPeriod());
}
return () => {
setTimelockPeriod(undefined);
setExecutionPeriod(undefined);
};
};

setTimelockInfo();
Expand Down
2 changes: 2 additions & 0 deletions src/components/pages/DaoDashboard/Info/ParentLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useFractal } from '../../../../providers/App/AppProvider';
export function ParentLink() {
const {
node: { nodeHierarchy },
action,
} = useFractal();
const { t } = useTranslation('breadcrumbs');

Expand All @@ -22,6 +23,7 @@ export function ParentLink() {
color="gold.500"
_hover={{ textDecoration: 'none', color: 'gold.500-hover' }}
href={DAO_ROUTES.dao.relative(nodeHierarchy.parentAddress)}
onClick={action.resetDAO}
marginBottom="1rem"
as={NextLink}
>
Expand Down
11 changes: 5 additions & 6 deletions src/components/ui/forms/ABISelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import { isAddress } from 'ethers/lib/utils';
import detectProxyTarget from 'evm-proxy-detection';
import { useMemo, useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useEnsAddress } from 'wagmi';
import { useEnsAddress, usePublicClient } from 'wagmi';
import { logError } from '../../../helpers/errorLogging';
import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider';
import { useEIP1193Providers } from '../../../providers/NetworkConfig/utils';
import { LabelComponent } from './InputComponent';

export type ABIElement = {
Expand All @@ -30,15 +29,15 @@ export default function ABISelector({ target, onChange, onFetchABI }: IABISelect
const [abi, setABI] = useState<ABIElement[]>([]);
const { etherscanAPIBaseUrl } = useNetworkConfig();
const { t } = useTranslation('common');
const { eip1193InfuraProvider } = useEIP1193Providers();
const { data: ensAddress } = useEnsAddress({ name: target });
const client = usePublicClient();

useEffect(() => {
const loadABI = async () => {
if (target && ((ensAddress && isAddress(ensAddress)) || isAddress(target))) {
try {
const requestFunc = ({ method, params }: { method: string; params: any[] }) =>
eip1193InfuraProvider.send(method, params);
const requestFunc = ({ method, params }: { method: any; params: any }) =>
client.request({ method, params });

const proxy = await detectProxyTarget(ensAddress || target, requestFunc);

Expand Down Expand Up @@ -71,7 +70,7 @@ export default function ABISelector({ target, onChange, onFetchABI }: IABISelect
}
};
loadABI();
}, [target, ensAddress, etherscanAPIBaseUrl, onFetchABI, eip1193InfuraProvider]);
}, [target, ensAddress, etherscanAPIBaseUrl, onFetchABI, client]);

/*
* This makes component quite scoped to proposal / proposal template creation
Expand Down
38 changes: 6 additions & 32 deletions src/components/ui/menus/ManageDAO/ManageDAOMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@ import { VEllipsis } from '@decent-org/fractal-ui';
import {
ERC20FreezeVoting,
ERC721FreezeVoting,
ModuleProxyFactory,
MultisigFreezeVoting,
} from '@fractal-framework/fractal-contracts';
import { BigNumber } from 'ethers';
import { useRouter } from 'next/navigation';
import { useMemo, useCallback, useState, useEffect } from 'react';
import { DAO_ROUTES } from '../../../../constants/routes';
import { getEventRPC } from '../../../../helpers';
import {
isWithinFreezePeriod,
isWithinFreezeProposalPeriod,
} from '../../../../helpers/freezePeriodHelpers';
import useSubmitProposal from '../../../../hooks/DAO/proposal/useSubmitProposal';
import useUserERC721VotingTokens from '../../../../hooks/DAO/proposal/useUserERC721VotingTokens';
import useClawBack from '../../../../hooks/DAO/useClawBack';
import { CacheKeys } from '../../../../hooks/utils/cache/cacheDefaults';
import { useLocalStorage } from '../../../../hooks/utils/cache/useLocalStorage';
import useBlockTimestamp from '../../../../hooks/utils/useBlockTimestamp';
import { useMasterCopy } from '../../../../hooks/utils/useMasterCopy';
import { useFractal } from '../../../../providers/App/AppProvider';
import {
FractalGuardContracts,
Expand Down Expand Up @@ -71,8 +68,7 @@ export function ManageDAOMenu({
const currentTime = BigNumber.from(useBlockTimestamp());
const { push } = useRouter();
const safeAddress = fractalNode?.daoAddress;
const { setValue, getValue } = useLocalStorage();

const { getZodiacModuleProxyMasterCopyData } = useMasterCopy();
const { getCanUserCreateProposal } = useSubmitProposal();
const { getUserERC721VotingTokens } = useUserERC721VotingTokens(undefined, safeAddress, false);
const { handleClawBack } = useClawBack({
Expand Down Expand Up @@ -117,32 +113,11 @@ export function ManageDAOMenu({
0
)
)[1];
const cachedMasterCopyAddress = getValue(
CacheKeys.MASTER_COPY_PREFIX + votingContractAddress
);
let votingContractMasterCopyAddress = cachedMasterCopyAddress;
if (!votingContractMasterCopyAddress) {
const rpc = getEventRPC<ModuleProxyFactory>(zodiacModuleProxyFactoryContract);
const filter = rpc.filters.ModuleProxyCreation(votingContractAddress, null);
votingContractMasterCopyAddress = await rpc
.queryFilter(filter)
.then(proxiesCreated => {
return proxiesCreated[0].args.masterCopy;
});
setValue(
CacheKeys.MASTER_COPY_PREFIX + votingContractAddress,
votingContractMasterCopyAddress
);
}
const masterCopyData = await getZodiacModuleProxyMasterCopyData(votingContractAddress);

if (
votingContractMasterCopyAddress === linearVotingMasterCopyContract.asProvider.address
) {
if (masterCopyData.isOzLinearVoting) {
result = GovernanceType.AZORIUS_ERC20;
} else if (
votingContractMasterCopyAddress ===
linearVotingERC721MasterCopyContract.asProvider.address
) {
} else if (masterCopyData.isOzLinearVotingERC721) {
result = GovernanceType.AZORIUS_ERC721;
}
}
Expand All @@ -162,8 +137,7 @@ export function ManageDAOMenu({
safeAddress,
type,
zodiacModuleProxyFactoryContract,
getValue,
setValue,
getZodiacModuleProxyMasterCopyData,
]);

const handleNavigateToSettings = useCallback(
Expand Down
6 changes: 1 addition & 5 deletions src/hooks/DAO/loaders/useFractalGovernance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ export const useFractalGovernance = () => {
} = governanceContracts;

const newLoadKey =
daoAddress +
(azoriusContract ? '1' : '0') +
nodeHierarchy.parentAddress +
!!guardContracts.freezeGuardContract;

if (isLoaded && daoAddress && newLoadKey !== loadKey.current) {
if (isLoaded && newLoadKey !== loadKey.current) {
loadKey.current = newLoadKey;

if (azoriusContract) {
Expand Down Expand Up @@ -115,11 +114,8 @@ export const useFractalGovernance = () => {
payload: GovernanceType.MULTISIG,
});
}
} else if (!isLoaded) {
loadKey.current = undefined;
}
}, [
daoAddress,
governanceContracts,
loadDAOProposals,
loadUnderlyingERC20Token,
Expand Down
Loading

0 comments on commit a9d4ae7

Please sign in to comment.