From 481584446cd402cb91803c84255119c765153366 Mon Sep 17 00:00:00 2001 From: Leonardo Zizzamia Date: Tue, 27 Aug 2024 16:15:25 -0700 Subject: [PATCH] docs: use basename --- site/docs/pages/identity/get-address.mdx | 45 ++++++++++++++++++++++++ site/docs/pages/identity/types.mdx | 40 ++++++++++++++------- site/sidebar.ts | 4 +++ src/identity/types.ts | 28 +++++++-------- 4 files changed, 90 insertions(+), 27 deletions(-) create mode 100644 site/docs/pages/identity/get-address.mdx diff --git a/site/docs/pages/identity/get-address.mdx b/site/docs/pages/identity/get-address.mdx new file mode 100644 index 0000000000..3533b82492 --- /dev/null +++ b/site/docs/pages/identity/get-address.mdx @@ -0,0 +1,45 @@ +# `getAddress` + +The `getAddress` utility is designed to retrieve an address from an onchain identity provider for a given name. + +## Usage + +Get ENS Name from mainnet chain + +:::code-group +```tsx [code] +import { getAddress } from '@coinbase/onchainkit/identity'; + +const address = await getAddress({ name: 'zizzamia.eth' }); +``` + +```ts [return value] +0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1 +``` + +::: + +Get Basename from base chain + +:::code-group + +```tsx [code] +import { getAddress } from '@coinbase/onchainkit/identity'; +import { base } from 'viem/chains'; + +const address = await getAddress({ name: 'zizzamia.base.eth', chain: base }); +``` + +```ts [return value] +0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1 +``` + +::: + +## Returns + +[`Promise`](/identity/types#getaddressreturntype) + +## Parameters + +[`GetAddress`](/identity/types#getaddress) diff --git a/site/docs/pages/identity/types.mdx b/site/docs/pages/identity/types.mdx index 802b04ccf8..d893062adf 100644 --- a/site/docs/pages/identity/types.mdx +++ b/site/docs/pages/identity/types.mdx @@ -9,8 +9,9 @@ description: Glossary of Types in Identity components & utilities. ```ts type AddressReact = { - address?: Address | null; // The Ethereum address to render + address?: Address | null; // The Ethereum address to render. className?: string; // Optional className override for top span element. + isSliced?: boolean; // Determines if the displayed address should be sliced. }; ``` @@ -94,6 +95,21 @@ type EthBalanceReact = { }; ``` +## `GetAddress` + +```ts +type GetAddress = { + name: string | Basename; + chain?: Chain; +}; +``` + +## `GetAddressReturnType` + +```ts +type GetAddressReturnType = Address | null; +``` + ## `GetAttestationsOptions` ```ts @@ -168,6 +184,15 @@ type NameReact = { } & HTMLAttributes; // Optional additional span attributes to apply to the name. ``` +## `UseAddressOptions` + +```ts +type UseAddressOptions = { + name: string | Basename; // The ENS or Basename for which the Ethereum address is to be fetched + chain?: Chain; // Optional chain for domain resolution +}; +``` + ## `UseAvatarOptions` ```ts @@ -177,10 +202,10 @@ type UseAvatarOptions = { }; ``` -## `UseAvatarQueryOptions` +## `UseQueryOptions` ```ts -type UseAvatarQueryOptions = { +type UseQueryOptions = { enabled?: boolean; cacheTime?: number; }; @@ -194,12 +219,3 @@ type UseNameOptions = { chain?: Chain; // Optional chain for domain resolution }; ``` - -## `UseNameQueryOptions` - -```ts -type UseNameQueryOptions = { - enabled?: boolean; // Whether the query should be enabled. Defaults to true. - cacheTime?: number; // Cache time in milliseconds. -}; -``` diff --git a/site/sidebar.ts b/site/sidebar.ts index 0fd00310d8..4310577f37 100644 --- a/site/sidebar.ts +++ b/site/sidebar.ts @@ -227,6 +227,10 @@ export const sidebar = [ { text: 'Identity', items: [ + { + text: 'getAddress', + link: '/identity/get-address', + }, { text: 'getAttestations', link: '/identity/get-attestations', diff --git a/src/identity/types.ts b/src/identity/types.ts index ec9f3828a0..c34f782f9a 100644 --- a/src/identity/types.ts +++ b/src/identity/types.ts @@ -91,8 +91,19 @@ export type EthBalanceReact = { }; /** - * Attestation Options - * + * Note: exported as public Type + */ +export type GetAddress = { + name: string | Basename; + chain?: Chain; +}; + +/** + * Note: exported as public Type + */ +export type GetAddressReturnType = Address | null; + +/** * Note: exported as public Type */ export type GetAttestationsOptions = { @@ -115,14 +126,6 @@ export type GetAvatar = { */ export type GetAvatarReturnType = string | null; -/** - * Note: exported as public Type - */ -export type GetAddress = { - name: string | Basename; - chain?: Chain; -}; - /** * Note: exported as public Type */ @@ -131,11 +134,6 @@ export type GetName = { chain?: Chain; }; -/** - * Note: exported as public Type - */ -export type GetAddressReturnType = Address | null; - /** * Note: exported as public Type */