Skip to content

Commit

Permalink
Merge pull request #2702 from decentdao/release/v0.5.0
Browse files Browse the repository at this point in the history
Release v0.5.0
  • Loading branch information
johnqh authored Feb 1, 2025
2 parents c459474 + d5897ee commit 5171602
Show file tree
Hide file tree
Showing 132 changed files with 3,221 additions and 2,357 deletions.
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": "decent-interface",
"version": "0.4.8",
"version": "0.5.0",
"private": true,
"dependencies": {
"@amplitude/analytics-browser": "^2.11.1",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Activity/ActivityDescriptionGovernance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box, Flex, Text } from '@chakra-ui/react';
import { useTranslation } from 'react-i18next';
import { getAddress } from 'viem';
import { useGetMetadata } from '../../hooks/DAO/proposal/useGetMetadata';
import useAvatar from '../../hooks/utils/useAvatar';
import { useNetworkEnsAvatar } from '../../hooks/useNetworkEnsAvatar';
import { useGetAccountName } from '../../hooks/utils/useGetAccountName';
import {
GovernanceActivity,
Expand Down Expand Up @@ -54,7 +54,7 @@ function ProposalAuthor({ activity }: { activity: FractalProposal }) {
: undefined;

const { displayName: author } = useGetAccountName(proposer);
const avatarURL = useAvatar(author);
const { data: avatarURL } = useNetworkEnsAvatar({ name: author });

if (!proposer) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect, useState } from 'react';
import { getContract } from 'viem';
import { usePublicClient } from 'wagmi';
import LidoWithdrawalQueueAbi from '../../../assets/abi/LidoWithdrawalQueueAbi';
import useLidoStaking from '../../../hooks/stake/lido/useLidoStaking';
import useNetworkPublicClient from '../../../hooks/useNetworkPublicClient';
import { useCanUserCreateProposal } from '../../../hooks/utils/useCanUserSubmitProposal';
import { useFractal } from '../../../providers/App/AppProvider';
import { useNetworkConfigStore } from '../../../providers/NetworkConfig/useNetworkConfigStore';
Expand All @@ -17,7 +17,7 @@ export default function useTreasuryLidoInteractions() {
const { handleUnstake, handleClaimUnstakedETH } = useLidoStaking();
const { canUserCreateProposal } = useCanUserCreateProposal();
const { staking } = useNetworkConfigStore();
const publicClient = usePublicClient();
const publicClient = useNetworkPublicClient();

// --- Lido Stake button setup ---
const showStakeButton =
Expand Down Expand Up @@ -48,7 +48,7 @@ export default function useTreasuryLidoInteractions() {

useEffect(() => {
const getLidoClaimableStatus = async () => {
if (!staking.lido?.withdrawalQueueContractAddress || !lidoWithdrawalNFT || !publicClient) {
if (!staking.lido?.withdrawalQueueContractAddress || !lidoWithdrawalNFT) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function AzoriusNFTDetail({

useEffect(() => {
const loadNFTDetails = async () => {
if (hasAddressError || !publicClient) {
if (hasAddressError) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ export function AzoriusTokenDetails(props: ICreationStepProps) {

useStepRedirect({ values });
const updateImportFields = useCallback(async () => {
if (!publicClient) {
return;
}
const importAddress = values.erc20Token.tokenImportAddress;
const importError = errors?.erc20Token?.tokenImportAddress;
if (importAddress && !importError && isAddress(importAddress)) {
Expand Down
163 changes: 80 additions & 83 deletions src/components/DaoCreator/hooks/usePrepareFormData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback } from 'react';
import { Address, getContract } from 'viem';
import IVotesAbi from '../../../assets/abi/IVotes';
import { useNetworkEnsAddressAsync } from '../../../hooks/useNetworkEnsAddress';
import useNetworkPublicClient from '../../../hooks/useNetworkPublicClient';
import {
AzoriusERC20DAO,
Expand All @@ -18,7 +19,7 @@ type FreezeGuardConfigParam = { freezeGuard?: DAOFreezeGuardConfig<BigIntValuePa

export function usePrepareFormData() {
const publicClient = useNetworkPublicClient();

const { getEnsAddress } = useNetworkEnsAddressAsync();
// Helper function to prepare freezeGuard data
const prepareFreezeGuardData = useCallback(
async (
Expand Down Expand Up @@ -80,8 +81,8 @@ export function usePrepareFormData() {
}: SafeMultisigDAO & FreezeGuardConfigParam) => {
const resolvedAddresses = await Promise.all(
trustedAddresses.map(async inputValue => {
if (validateENSName(inputValue) && publicClient) {
const maybeEnsAddress = await publicClient.getEnsAddress({
if (validateENSName(inputValue)) {
const maybeEnsAddress = await getEnsAddress({
name: inputValue,
});
if (maybeEnsAddress) {
Expand All @@ -101,7 +102,7 @@ export function usePrepareFormData() {
...rest,
};
},
[publicClient, prepareFreezeGuardData],
[getEnsAddress, prepareFreezeGuardData],
);

const prepareAzoriusERC20FormData = useCallback(
Expand All @@ -120,52 +121,50 @@ export function usePrepareFormData() {
}: AzoriusERC20DAO<BigIntValuePair> & FreezeGuardConfigParam): Promise<
AzoriusERC20DAO | undefined
> => {
if (publicClient) {
const resolvedTokenAllocations = await Promise.all(
tokenAllocations.map(async allocation => {
let address = allocation.address;
if (validateENSName(address) && publicClient) {
const maybeEnsAddress = await publicClient.getEnsAddress({
name: allocation.address,
});
if (maybeEnsAddress) {
address = maybeEnsAddress;
}
const resolvedTokenAllocations = await Promise.all(
tokenAllocations.map(async allocation => {
let address = allocation.address;
if (validateENSName(address)) {
const maybeEnsAddress = await getEnsAddress({
name: allocation.address,
});
if (maybeEnsAddress) {
address = maybeEnsAddress;
}
return { amount: allocation.amount.bigintValue!, address: address };
}),
);
let freezeGuardData;
if (freezeGuard) {
freezeGuardData = await prepareFreezeGuardData(freezeGuard);
}
const isTokenImported =
tokenCreationType === TokenCreationType.IMPORTED && !!tokenImportAddress;
let isVotesToken: boolean | undefined = false;
if (isTokenImported) {
isVotesToken = await checkVotesToken(tokenImportAddress);
}
return {
tokenSupply: tokenSupply.bigintValue!,
parentAllocationAmount: parentAllocationAmount?.bigintValue!,
quorumPercentage: quorumPercentage.bigintValue!,
timelock: await getEstimatedNumberOfBlocks(timelock.bigintValue!, publicClient),
executionPeriod: await getEstimatedNumberOfBlocks(
executionPeriod.bigintValue!,
publicClient,
),
votingPeriod: await getEstimatedNumberOfBlocks(votingPeriod.bigintValue!, publicClient),
tokenAllocations: resolvedTokenAllocations,
tokenImportAddress,
tokenCreationType,
isTokenImported,
isVotesToken,
...freezeGuardData,
...rest,
};
}
return { amount: allocation.amount.bigintValue!, address: address };
}),
);
let freezeGuardData;
if (freezeGuard) {
freezeGuardData = await prepareFreezeGuardData(freezeGuard);
}
const isTokenImported =
tokenCreationType === TokenCreationType.IMPORTED && !!tokenImportAddress;
let isVotesToken: boolean | undefined = false;
if (isTokenImported) {
isVotesToken = await checkVotesToken(tokenImportAddress);
}
return {
tokenSupply: tokenSupply.bigintValue!,
parentAllocationAmount: parentAllocationAmount?.bigintValue!,
quorumPercentage: quorumPercentage.bigintValue!,
timelock: await getEstimatedNumberOfBlocks(timelock.bigintValue!, publicClient),
executionPeriod: await getEstimatedNumberOfBlocks(
executionPeriod.bigintValue!,
publicClient,
),
votingPeriod: await getEstimatedNumberOfBlocks(votingPeriod.bigintValue!, publicClient),
tokenAllocations: resolvedTokenAllocations,
tokenImportAddress,
tokenCreationType,
isTokenImported,
isVotesToken,
...freezeGuardData,
...rest,
};
},
[checkVotesToken, publicClient, prepareFreezeGuardData],
[publicClient, getEnsAddress, prepareFreezeGuardData, checkVotesToken],
);

const prepareAzoriusERC721FormData = useCallback(
Expand All @@ -181,46 +180,44 @@ export function usePrepareFormData() {
}: AzoriusERC721DAO<BigIntValuePair> & FreezeGuardConfigParam): Promise<
AzoriusERC721DAO | undefined
> => {
if (publicClient) {
let freezeGuardData;
if (freezeGuard) {
freezeGuardData = await prepareFreezeGuardData(freezeGuard);
}
let freezeGuardData;
if (freezeGuard) {
freezeGuardData = await prepareFreezeGuardData(freezeGuard);
}

const resolvedNFTs = await Promise.all(
nfts.map(async nft => {
let address = nft.tokenAddress;
if (validateENSName(address) && nft.tokenAddress) {
const maybeEnsAddress = await publicClient.getEnsAddress({
name: nft.tokenAddress,
});
if (maybeEnsAddress) {
address = maybeEnsAddress;
}
const resolvedNFTs = await Promise.all(
nfts.map(async nft => {
let address = nft.tokenAddress;
if (validateENSName(address) && nft.tokenAddress) {
const maybeEnsAddress = await getEnsAddress({
name: nft.tokenAddress,
});
if (maybeEnsAddress) {
address = maybeEnsAddress;
}
return {
tokenAddress: address,
tokenWeight: nft.tokenWeight.bigintValue!,
};
}),
);
}
return {
tokenAddress: address,
tokenWeight: nft.tokenWeight.bigintValue!,
};
}),
);

return {
quorumPercentage: quorumPercentage.bigintValue!,
timelock: await getEstimatedNumberOfBlocks(timelock.bigintValue!, publicClient),
executionPeriod: await getEstimatedNumberOfBlocks(
executionPeriod.bigintValue!,
publicClient,
),
votingPeriod: await getEstimatedNumberOfBlocks(votingPeriod.bigintValue!, publicClient),
nfts: resolvedNFTs,
quorumThreshold: quorumThreshold.bigintValue!,
...freezeGuardData,
...rest,
};
}
return {
quorumPercentage: quorumPercentage.bigintValue!,
timelock: await getEstimatedNumberOfBlocks(timelock.bigintValue!, publicClient),
executionPeriod: await getEstimatedNumberOfBlocks(
executionPeriod.bigintValue!,
publicClient,
),
votingPeriod: await getEstimatedNumberOfBlocks(votingPeriod.bigintValue!, publicClient),
nfts: resolvedNFTs,
quorumThreshold: quorumThreshold.bigintValue!,
...freezeGuardData,
...rest,
};
},
[prepareFreezeGuardData, publicClient],
[getEnsAddress, prepareFreezeGuardData, publicClient],
);
return {
prepareMultisigFormData,
Expand Down
10 changes: 6 additions & 4 deletions src/components/DaoDashboard/ERC20Claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { abis } from '@fractal-framework/fractal-contracts';
import { useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { getContract } from 'viem';
import { useAccount, usePublicClient, useWalletClient } from 'wagmi';
import { useAccount } from 'wagmi';
import { Alert as AlertIcon } from '../../assets/theme/custom/icons/Alert';
import useNetworkPublicClient from '../../hooks/useNetworkPublicClient';
import { useNetworkWalletClient } from '../../hooks/useNetworkWalletClient';
import { useTransaction } from '../../hooks/utils/useTransaction';
import { useFractal } from '../../providers/App/AppProvider';
import { AzoriusGovernance } from '../../types';
Expand All @@ -19,11 +21,11 @@ export function ERCO20Claim() {
const { t } = useTranslation(['dashboard', 'transaction']);
const [contractCall, pending] = useTransaction();
const azoriusGovernance = governance as AzoriusGovernance;
const publicClient = usePublicClient();
const { data: walletClient } = useWalletClient();
const publicClient = useNetworkPublicClient();
const { data: walletClient } = useNetworkWalletClient();

const loadClaim = useCallback(async () => {
if (!tokenClaimContractAddress || !type || !account || !publicClient) {
if (!tokenClaimContractAddress || !type || !account) {
return;
}
const tokenClaimContract = getContract({
Expand Down
13 changes: 6 additions & 7 deletions src/components/DaoDashboard/Info/InfoGovernance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Bank } from '@phosphor-icons/react';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { getContract } from 'viem';
import { usePublicClient } from 'wagmi';

import useNetworkPublicClient from '../../../hooks/useNetworkPublicClient';
import { useTimeHelpers } from '../../../hooks/utils/useTimeHelpers';
import { useFractal } from '../../../providers/App/AppProvider';
import { useDaoInfoStore } from '../../../store/daoInfo/useDaoInfoStore';
Expand All @@ -19,7 +20,7 @@ export function InfoGovernance({ showTitle = true }: { showTitle?: boolean }) {
guardContracts: { freezeGuardType, freezeGuardContractAddress },
} = useFractal();
const { safe } = useDaoInfoStore();
const publicClient = usePublicClient();
const publicClient = useNetworkPublicClient();
const { getTimeDuration } = useTimeHelpers();
const [timelockPeriod, setTimelockPeriod] = useState<string>();
const [executionPeriod, setExecutionPeriod] = useState<string>();
Expand All @@ -28,11 +29,9 @@ export function InfoGovernance({ showTitle = true }: { showTitle?: boolean }) {

useEffect(() => {
const setTimelockInfo = async () => {
const formatBlocks = async (blocks: number): Promise<string | undefined> => {
if (publicClient) {
return getTimeDuration(await blocksToSeconds(blocks, publicClient));
}
};
const formatBlocks = async (blocks: number): Promise<string | undefined> =>
getTimeDuration(await blocksToSeconds(blocks, publicClient));

if (freezeGuardType == FreezeGuardType.MULTISIG) {
if (freezeGuardContractAddress && publicClient) {
const freezeGuardContract = getContract({
Expand Down
Loading

0 comments on commit 5171602

Please sign in to comment.