Skip to content

Commit 3d47932

Browse files
authored
chore: Update Basename naming (#1110)
1 parent abb5ee7 commit 3d47932

11 files changed

+36
-31
lines changed

.changeset/nasty-wolves-remember.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@coinbase/onchainkit": patch
3+
---
4+
5+
-**chore**: Update all cases of BaseName to Basename. Update WalletDropdownBaseName to WalletDropdownBasename. Update the identity type BaseName to Basename. Update WalletDropdownBaseNameReact to WalletDropdownBasenameReact. By @cpcramer #1110

src/identity/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type {
1717
AvatarReact,
1818
BadgeReact,
1919
BaseMainnetName,
20-
BaseName,
20+
Basename,
2121
BaseSepoliaName,
2222
EASChainDefinition,
2323
EASSchemaUid,

src/identity/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export type BaseMainnetName = `${string}.base.eth`;
5555
/**
5656
* Note: exported as public Type
5757
*/
58-
export type BaseName = BaseMainnetName | BaseSepoliaName;
58+
export type Basename = BaseMainnetName | BaseSepoliaName;
5959

6060
/**
6161
* Note: exported as public Type
@@ -126,7 +126,7 @@ export type GetName = {
126126
/**
127127
* Note: exported as public Type
128128
*/
129-
export type GetNameReturnType = string | BaseName | null;
129+
export type GetNameReturnType = string | Basename | null;
130130

131131
/**
132132
* Note: exported as public Type

src/identity/utils/getAvatar.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { isBase } from '../../isBase';
44
import { isEthereum } from '../../isEthereum';
55
import { getChainPublicClient } from '../../network/getChainPublicClient';
66
import { RESOLVER_ADDRESSES_BY_CHAIN_ID } from '../constants';
7-
import type { BaseName, GetAvatar, GetAvatarReturnType } from '../types';
7+
import type { Basename, GetAvatar, GetAvatarReturnType } from '../types';
88
import { getBaseDefaultProfilePicture } from './getBaseDefaultProfilePicture';
99
import { isBasename } from './isBasename';
1010

@@ -57,9 +57,9 @@ export const getAvatar = async ({
5757
return mainnetEnsAvatar;
5858
}
5959

60-
// 3. If username is a basename (.base.eth / .basetest.eth), use default basename avatars
60+
// 3. If username is a Basename (.base.eth / .basetest.eth), use default Basename avatars
6161
if (usernameIsBasename) {
62-
return getBaseDefaultProfilePicture(ensName as BaseName);
62+
return getBaseDefaultProfilePicture(ensName as Basename);
6363
}
6464

6565
// 4. No avatars to display

src/identity/utils/getBaseDefaultProfilePicture.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { BASE_DEFAULT_PROFILE_PICTURES } from '../constants';
2-
import type { BaseName } from '../types';
2+
import type { Basename } from '../types';
33
import { getBaseDefaultProfilePictureIndex } from './getBaseDefaultProfilePictureIndex';
44

5-
export const getBaseDefaultProfilePicture = (username: BaseName) => {
5+
export const getBaseDefaultProfilePicture = (username: Basename) => {
66
const profilePictureIndex = getBaseDefaultProfilePictureIndex(
77
username,
88
BASE_DEFAULT_PROFILE_PICTURES.length,

src/identity/utils/getName.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { isEthereum } from '../../isEthereum';
44
import { getChainPublicClient } from '../../network/getChainPublicClient';
55
import L2ResolverAbi from '../abis/L2ResolverAbi';
66
import { RESOLVER_ADDRESSES_BY_CHAIN_ID } from '../constants';
7-
import type { BaseName, GetName, GetNameReturnType } from '../types';
7+
import type { Basename, GetName, GetNameReturnType } from '../types';
88
import { convertReverseNodeToBytes } from './convertReverseNodeToBytes';
99

1010
/**
@@ -32,14 +32,14 @@ export const getName = async ({
3232
if (chainIsBase) {
3333
const addressReverseNode = convertReverseNodeToBytes(address, base.id);
3434
try {
35-
const baseName = await client.readContract({
35+
const basename = await client.readContract({
3636
abi: L2ResolverAbi,
3737
address: RESOLVER_ADDRESSES_BY_CHAIN_ID[chain.id],
3838
functionName: 'name',
3939
args: [addressReverseNode],
4040
});
41-
if (baseName) {
42-
return baseName as BaseName;
41+
if (basename) {
42+
return basename as Basename;
4343
}
4444
} catch (_error) {
4545
// This is a best effort attempt, so we don't need to do anything here.

src/internal/svg/baseNameSvg.tsx renamed to src/internal/svg/basenameSvg.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { fill } from '../../styles/theme';
22

3-
export const baseNameSvg = (
3+
export const basenameSvg = (
44
<svg
5-
data-testid="ockbaseNameSvg"
5+
data-testid="ockBasenameSvg"
66
role="img"
77
aria-label="ock-base-name"
88
width="100%"

src/wallet/components/WalletDropdownBaseName.test.tsx renamed to src/wallet/components/WalletDropdownBasename.test.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { base } from 'viem/chains';
55
import { describe, expect, it, vi } from 'vitest';
66
import { useAccount } from 'wagmi';
77
import { useName } from '../../identity/hooks/useName';
8-
import { WalletDropdownBaseName } from './WalletDropdownBaseName';
8+
import { WalletDropdownBasename } from './WalletDropdownBasename';
99
import { useWalletContext } from './WalletProvider';
1010

1111
vi.mock('wagmi', () => ({
@@ -20,7 +20,7 @@ vi.mock('./WalletProvider', () => ({
2020
useWalletContext: vi.fn(),
2121
}));
2222

23-
describe('WalletDropdownBaseName', () => {
23+
describe('WalletDropdownBasename', () => {
2424
it('should render "Claim Basename" when no basename', () => {
2525
(useAccount as vi.Mock<[], Partial<GetAccountReturnType>>).mockReturnValue({
2626
address: '0x1234' as `0x${string}`,
@@ -38,7 +38,7 @@ describe('WalletDropdownBaseName', () => {
3838
error: null,
3939
});
4040

41-
render(<WalletDropdownBaseName />);
41+
render(<WalletDropdownBasename />);
4242
expect(screen.getByText('Claim Basename')).toBeInTheDocument();
4343
expect(screen.getByText('NEW')).toBeInTheDocument();
4444
});
@@ -60,7 +60,7 @@ describe('WalletDropdownBaseName', () => {
6060
error: null,
6161
});
6262

63-
render(<WalletDropdownBaseName />);
63+
render(<WalletDropdownBasename />);
6464
expect(screen.getByText('Profile')).toBeInTheDocument();
6565
expect(screen.queryByText('NEW')).not.toBeInTheDocument();
6666
});
@@ -82,7 +82,7 @@ describe('WalletDropdownBaseName', () => {
8282
error: null,
8383
});
8484

85-
render(<WalletDropdownBaseName />);
85+
render(<WalletDropdownBasename />);
8686
expect(screen.getByTestId('ockSpinner')).toBeInTheDocument();
8787
expect(screen.queryByText('Claim Basename')).not.toBeInTheDocument();
8888
expect(screen.queryByText('Profile')).not.toBeInTheDocument();
@@ -98,7 +98,7 @@ describe('WalletDropdownBaseName', () => {
9898
chain: base,
9999
});
100100

101-
const { container } = render(<WalletDropdownBaseName />);
101+
const { container } = render(<WalletDropdownBasename />);
102102
expect(container.firstChild).toBeNull();
103103
});
104104
});

src/wallet/components/WalletDropdownBaseName.tsx renamed to src/wallet/components/WalletDropdownBasename.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import { useAccount } from 'wagmi';
22
import { useName } from '../../identity/hooks/useName';
33
import { Spinner } from '../../internal/components/Spinner';
4-
import { baseNameSvg } from '../../internal/svg/baseNameSvg';
4+
import { basenameSvg } from '../../internal/svg/basenameSvg';
55
import { cn, pressable, text } from '../../styles/theme';
6-
import type { WalletDropdownBaseNameReact } from '../types';
6+
import type { WalletDropdownBasenameReact } from '../types';
77
import { useWalletContext } from './WalletProvider';
88

9-
export function WalletDropdownBaseName({
9+
export function WalletDropdownBasename({
1010
className,
11-
}: WalletDropdownBaseNameReact) {
11+
}: WalletDropdownBasenameReact) {
1212
const { address } = useAccount();
1313
const { chain } = useWalletContext();
1414

1515
if (!address || !chain) {
1616
return null;
1717
}
1818

19-
const { data: baseName, isLoading } = useName({
19+
const { data: basename, isLoading } = useName({
2020
address,
2121
chain,
2222
});
2323

24-
const hasBaseUserName = !!baseName;
24+
const hasBaseUserName = !!basename;
2525
const title = hasBaseUserName ? 'Profile' : 'Claim Basename';
2626
const href = hasBaseUserName
27-
? `https://www.base.org/name/${baseName}`
27+
? `https://www.base.org/name/${basename}`
2828
: 'https://www.base.org/names';
2929

3030
return (
@@ -39,7 +39,7 @@ export function WalletDropdownBaseName({
3939
rel="noopener noreferrer"
4040
>
4141
<div className="-translate-y-1/2 absolute top-1/2 left-4 flex h-[1.125rem] w-[1.125rem] items-center justify-center">
42-
{baseNameSvg}
42+
{basenameSvg}
4343
</div>
4444
<div className="flex w-full items-center pl-6">
4545
{isLoading ? (

src/wallet/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
export { ConnectWallet } from './components/ConnectWallet';
33
export { Wallet } from './components/Wallet';
44
export { WalletDropdown } from './components/WalletDropdown';
5-
export { WalletDropdownBaseName } from './components/WalletDropdownBaseName';
5+
export { WalletDropdownBasename } from './components/WalletDropdownBasename';
66
export { WalletDropdownDisconnect } from './components/WalletDropdownDisconnect';
77
export { WalletDropdownFundLink } from './components/WalletDropdownFundLink';
88
export { WalletDropdownLink } from './components/WalletDropdownLink';
@@ -14,7 +14,7 @@ export type {
1414
IsWalletACoinbaseSmartWalletOptions,
1515
IsWalletACoinbaseSmartWalletResponse,
1616
WalletContextType,
17-
WalletDropdownBaseNameReact,
17+
WalletDropdownBasenameReact,
1818
WalletDropdownDisconnectReact,
1919
WalletDropdownFundLinkReact,
2020
WalletDropdownLinkReact,

src/wallet/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export type WalletBottomSheetReact = {
8484
/**
8585
* Note: exported as public Type
8686
*/
87-
export type WalletDropdownBaseNameReact = {
87+
export type WalletDropdownBasenameReact = {
8888
className?: string; // Optional className override for the element
8989
};
9090

0 commit comments

Comments
 (0)