Skip to content

Commit

Permalink
Get rid of more ethers.constants
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgall committed Apr 10, 2024
1 parent bdd54d5 commit fd670d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/hooks/DAO/loaders/useFractalFreeze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/DAO/loaders/useFractalGuardContracts.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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: '',
Expand All @@ -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 = {
Expand Down
11 changes: 4 additions & 7 deletions src/hooks/utils/useMasterCopy.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/utils/api.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { constants } from 'ethers';
import { zeroAddress } from 'viem';
import { buildSafeApiUrl } from './api';

describe('Safe URL builder tests', () => {
Expand All @@ -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);
});
});

0 comments on commit fd670d3

Please sign in to comment.