Skip to content

Commit

Permalink
docs: use basename
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Aug 27, 2024
1 parent ccac2a1 commit 4815844
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 27 deletions.
45 changes: 45 additions & 0 deletions site/docs/pages/identity/get-address.mdx
Original file line number Diff line number Diff line change
@@ -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<GetAddressReturnType>`](/identity/types#getaddressreturntype)

## Parameters

[`GetAddress`](/identity/types#getaddress)
40 changes: 28 additions & 12 deletions site/docs/pages/identity/types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
};
```

Expand Down Expand Up @@ -94,6 +95,21 @@ type EthBalanceReact = {
};
```

## `GetAddress`

```ts
type GetAddress = {
name: string | Basename;
chain?: Chain;
};
```

## `GetAddressReturnType`

```ts
type GetAddressReturnType = Address | null;
```

## `GetAttestationsOptions`

```ts
Expand Down Expand Up @@ -168,6 +184,15 @@ type NameReact = {
} & HTMLAttributes<HTMLSpanElement>; // 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
Expand All @@ -177,10 +202,10 @@ type UseAvatarOptions = {
};
```

## `UseAvatarQueryOptions`
## `UseQueryOptions`

```ts
type UseAvatarQueryOptions = {
type UseQueryOptions = {
enabled?: boolean;
cacheTime?: number;
};
Expand All @@ -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.
};
```
4 changes: 4 additions & 0 deletions site/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ export const sidebar = [
{
text: 'Identity',
items: [
{
text: 'getAddress',
link: '/identity/get-address',
},
{
text: 'getAttestations',
link: '/identity/get-attestations',
Expand Down
28 changes: 13 additions & 15 deletions src/identity/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
*/
Expand All @@ -131,11 +134,6 @@ export type GetName = {
chain?: Chain;
};

/**
* Note: exported as public Type
*/
export type GetAddressReturnType = Address | null;

/**
* Note: exported as public Type
*/
Expand Down

0 comments on commit 4815844

Please sign in to comment.