diff --git a/src/hooks/DAO/loaders/useFractalFreeze.ts b/src/hooks/DAO/loaders/useFractalFreeze.ts index 40a92b46e7..16ce49105b 100644 --- a/src/hooks/DAO/loaders/useFractalFreeze.ts +++ b/src/hooks/DAO/loaders/useFractalFreeze.ts @@ -5,8 +5,8 @@ import { } from '@fractal-framework/fractal-contracts'; import { TypedListener } from '@fractal-framework/fractal-contracts/dist/typechain-types/common'; import { FreezeVoteCastEvent } from '@fractal-framework/fractal-contracts/dist/typechain-types/contracts/ERC20FreezeVoting'; -import { constants } from 'ethers'; import { useCallback, useEffect, useRef } from 'react'; +import { zeroAddress } from 'viem'; import { useAccount } from 'wagmi'; import { isWithinFreezeProposalPeriod, @@ -80,7 +80,7 @@ export const useFractalFreeze = ({ const freezePeriod = await blocksToSeconds(freezePeriodBlock, provider); const userHasFreezeVoted = await freezeVotingContract.userHasFreezeVoted( - account || constants.AddressZero, + account || zeroAddress, freezeCreatedBlock, ); const isFrozen = await freezeVotingContract.isFrozen(); diff --git a/src/hooks/DAO/loaders/useFractalGuardContracts.ts b/src/hooks/DAO/loaders/useFractalGuardContracts.ts index 520e9f186c..e023ae95dd 100644 --- a/src/hooks/DAO/loaders/useFractalGuardContracts.ts +++ b/src/hooks/DAO/loaders/useFractalGuardContracts.ts @@ -1,6 +1,6 @@ import { AzoriusFreezeGuard, MultisigFreezeGuard } from '@fractal-framework/fractal-contracts'; -import { constants } from 'ethers'; import { useCallback, useEffect, useRef } from 'react'; +import { zeroAddress } from 'viem'; import { useFractal } from '../../../providers/App/AppProvider'; import { GuardContractAction } from '../../../providers/App/guardContracts/action'; import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider'; @@ -51,7 +51,7 @@ export const useFractalGuardContracts = ({ loadOnMount = true }: { loadOnMount?: if (!!azoriusModule && azoriusModule.moduleContract) { const azoriusGuardAddress = await azoriusModule.moduleContract.getGuard(); - if (azoriusGuardAddress === constants.AddressZero) { + if (azoriusGuardAddress === zeroAddress) { return { freezeGuardContractAddress: '', freezeVotingContractAddress: '', @@ -66,7 +66,7 @@ export const useFractalGuardContracts = ({ loadOnMount = true }: { loadOnMount?: }; freezeGuardType = FreezeGuardType.AZORIUS; } else { - const hasNoGuard = _safe.guard === constants.AddressZero; + const hasNoGuard = _safe.guard === zeroAddress; const masterCopyData = await getZodiacModuleProxyMasterCopyData(guard!); if (masterCopyData.isMultisigFreezeGuard && !hasNoGuard) { freezeGuardContract = { diff --git a/src/hooks/utils/useMasterCopy.ts b/src/hooks/utils/useMasterCopy.ts index 8bb49a6926..89598241dc 100644 --- a/src/hooks/utils/useMasterCopy.ts +++ b/src/hooks/utils/useMasterCopy.ts @@ -1,6 +1,7 @@ import { ModuleProxyFactory } from '@fractal-framework/fractal-contracts'; -import { Contract, constants } from 'ethers'; +import { Contract } from 'ethers'; import { useCallback } from 'react'; +import { zeroAddress } from 'viem'; import { getEventRPC } from '../../helpers'; import { useFractal } from '../../providers/App/AppProvider'; import { CacheExpiry, CacheKeys } from './cache/cacheDefaults'; @@ -59,12 +60,8 @@ export function useMasterCopy() { return contract.queryFilter(filter).then(proxiesCreated => { // @dev to prevent redundant queries, cache the master copy address as AddressZero if no proxies were created if (proxiesCreated.length === 0) { - setValue( - CacheKeys.MASTER_COPY_PREFIX + proxyAddress, - constants.AddressZero, - CacheExpiry.ONE_WEEK, - ); - return [constants.AddressZero, 'No proxies created'] as const; + setValue(CacheKeys.MASTER_COPY_PREFIX + proxyAddress, zeroAddress, CacheExpiry.ONE_WEEK); + return [zeroAddress, 'No proxies created'] as const; } const masterCopyAddress = proxiesCreated[0].args!.masterCopy; setValue(CacheKeys.MASTER_COPY_PREFIX + proxyAddress, masterCopyAddress); diff --git a/src/utils/api.spec.ts b/src/utils/api.spec.ts index 67537c7929..d16c7f5a61 100644 --- a/src/utils/api.spec.ts +++ b/src/utils/api.spec.ts @@ -1,4 +1,4 @@ -import { constants } from 'ethers'; +import { zeroAddress } from 'viem'; import { buildSafeApiUrl } from './api'; describe('Safe URL builder tests', () => { @@ -16,11 +16,11 @@ describe('Safe URL builder tests', () => { test('Creates Safe Transaction Service URL, with params', async () => { const safeTransactionURL = buildSafeApiUrl( 'https://safe-transaction-sepolia.safe.global', - `/safes/${constants.AddressZero}/multisig-transactions`, - { target: constants.AddressZero }, + `/safes/${zeroAddress}/multisig-transactions`, + { target: zeroAddress }, 'v1', ); - const EXPECTED_URL = `https://safe-transaction-sepolia.safe.global/api/v1/safes/${constants.AddressZero}/multisig-transactions?target=${constants.AddressZero}`; + const EXPECTED_URL = `https://safe-transaction-sepolia.safe.global/api/v1/safes/${zeroAddress}/multisig-transactions?target=${zeroAddress}`; expect(safeTransactionURL).toEqual(EXPECTED_URL); }); });