Skip to content

Commit

Permalink
Update type
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcramer committed Mar 11, 2025
1 parent 8f3f1dd commit 6544327
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/identity/hooks/useNames.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('useNames', () => {
() =>
useNames({
addresses: testAddresses,
chain: base as unknown as typeof mainnet,
chain: base,
}),
{
wrapper: getNewReactQueryTestProvider(),
Expand All @@ -89,7 +89,7 @@ describe('useNames', () => {
() =>
useNames({
addresses: testAddresses,
chain: optimism as unknown as typeof mainnet,
chain: optimism,
}),
{
wrapper: getNewReactQueryTestProvider(),
Expand Down
3 changes: 2 additions & 1 deletion src/identity/hooks/useNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { DEFAULT_QUERY_OPTIONS } from '@/internal/constants';
import { useQuery } from '@tanstack/react-query';
import type { Address } from 'viem';
import { mainnet } from 'viem/chains';
import type { Chain } from 'wagmi/chains';
import type { GetNameReturnType, UseQueryOptions } from '../types';

export type UseNamesOptions = {
addresses: Address[];
chain?: typeof mainnet;
chain?: Chain;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/identity/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export type UseNamesOptions = {
/** Array of addresses to resolve ENS or Basenames for */
addresses: Address[];
/** Optional chain for domain resolution */
chain?: typeof mainnet;
chain?: Chain;
};

/**
Expand Down
10 changes: 5 additions & 5 deletions src/identity/utils/getNames.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { publicClient } from '@/core/network/client';
import type { Address } from 'viem';
import { base, type mainnet, optimism } from 'viem/chains';
import { base, optimism } from 'viem/chains';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import type { Mock } from 'vitest';
import L2ResolverAbi from '../abis/L2ResolverAbi';
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('getNames', () => {

const names = await getNames({
addresses: walletAddresses,
chain: base as unknown as typeof mainnet,
chain: base,
});

expect(names).toEqual(expectedBaseNames);
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('getNames', () => {

const names = await getNames({
addresses: walletAddresses,
chain: base as unknown as typeof mainnet,
chain: base,
});

expect(names).toEqual(['user1.base', 'user2.base', 'user3.eth']);
Expand All @@ -129,7 +129,7 @@ describe('getNames', () => {

const names = await getNames({
addresses: walletAddresses,
chain: base as unknown as typeof mainnet,
chain: base,
});

expect(names).toEqual(expectedEnsNames);
Expand All @@ -141,7 +141,7 @@ describe('getNames', () => {
await expect(
getNames({
addresses: walletAddresses,
chain: optimism as unknown as typeof mainnet,
chain: optimism,
}),
).rejects.toBe(
'ChainId not supported, name resolution is only supported on Ethereum and Base.',
Expand Down
3 changes: 2 additions & 1 deletion src/identity/utils/getNames.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Basename, GetNameReturnType } from '@/identity/types';
import type { Address } from 'viem';
import { mainnet } from 'viem/chains';
import type { Chain } from 'wagmi/chains';
import { getChainPublicClient } from '../../core/network/getChainPublicClient';
import { isBase } from '../../core/utils/isBase';
import { isEthereum } from '../../core/utils/isEthereum';
Expand All @@ -10,7 +11,7 @@ import { convertReverseNodeToBytes } from './convertReverseNodeToBytes';

export type GetNames = {
addresses: Address[];
chain?: typeof mainnet;
chain?: Chain;
};

/**
Expand Down

0 comments on commit 6544327

Please sign in to comment.