Skip to content

Commit

Permalink
docs: polish site (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia authored Feb 18, 2024
1 parent 0e727f6 commit 3788d05
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 43 deletions.
5 changes: 3 additions & 2 deletions .changeset/thin-windows-attend.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
'@coinbase/onchainkit': patch
---

- Added `getFarcasterUserAddress` utility to extract user's custody and/or verified addresses.
- Updates the version of `@types/jest` package
- **docs**: Init https://onchainkit.xyz . By @zizzamia #131
- **feat**: Added `getFarcasterUserAddress` utility to extract the user's custody and/or verified addresses. By @Sneh1999 #114 #121
- **feat**: Updates the version of `@types/jest` package. By @Sneh1999 #114
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# OnchainKit

<p align="left">
OnchainKit is a collection of lightweight, composable, and type-safe React components along with TypeScript utilities to create top-tier onchain applications.
OnchainKit: React components and TypeScript utilities for top-tier onchain apps.
<p>

<p align="left">
Expand Down Expand Up @@ -40,6 +40,10 @@
</a>
</p>

## Documentation

For documentation and guides, visit [onchainkit.xyz](https://onchainkit.xyz/).

## Getting Started

Add OnchainKit to your project, install the required packages.
Expand All @@ -59,8 +63,11 @@ pnpm add @coinbase/onchainkit [email protected] react@18 react-dom@18

OnchainKit is divided into various theme utilities and components that are available for your use:

- [Frame Kit 🖼️](https://github.com/coinbase/onchainkit?tab=readme-ov-file#frame-kit-%EF%B8%8F)
- [Identity Kit 👨‍🚀](https://github.com/coinbase/onchainkit?tab=readme-ov-file#identity-kit-)
- [Farcaster Kit](https://onchainkit.xyz/farcasterkit/introduction)
- Utilitis:
- [`getFarcasterUserAddress`](https://onchainkit.xyz/farcasterkit/get-farcaster-user-address)
- [Frame Kit](https://github.com/coinbase/onchainkit?tab=readme-ov-file#frame-kit-%EF%B8%8F)
- [Identity Kit](https://github.com/coinbase/onchainkit?tab=readme-ov-file#identity-kit-)

<br />
<br />
Expand Down
Binary file modified site/.yarn/install-state.gz
Binary file not shown.
66 changes: 66 additions & 0 deletions site/docs/pages/farcasterkit/get-farcaster-user-address.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# getFarcasterUserAddress

The `getFarcasterUserAddress` function retrieves the user address associated
with a given Farcaster ID (fid). It provides options to specify whether
the client wants **custody address** and/or **verified addresses**,
and also allows the user to provide their own neynar api key.

By default, both **custody** and **verified** addresses are provided.

## Usage

```ts
import { getFarcasterUserAddress } from '@coinbase/onchainkit/farcaster';

const userAddress = await getFarcasterUserAddress(fid, options); // [!code focus]
```

## Returns

[`GetFarcasterUserAddressResponse`](/farcasterkit/types#getfarcasteruseraddressresponse)

Returns the Custody Address and the list of all verified addresses of a given fid.

## Parameters

### fid

- **Type:** `string`

Farcaster ID

### options.neynarApiKey

- **Type:** `string`

Default to onchain-kit's default key.

```ts
const userAddress = await getFarcasterUserAddress(fid, {
neynarApiKey: 'MY_NEYNAR_API_KEY', // [!code focus]
});
```

### options.hasCustodyAddress

- **Type:** `boolean`

Optional options to specify if the client wants custody addresses. Default to true.

```ts
const userAddress = await getFarcasterUserAddress(fid, {
hasCustodyAddress: false, // [!code focus]
});
```

### options.hasVerifiedAddresses

- **Type:** `boolean`

Optional options to specify if the client wants verified addresses. Default to true.

```ts
const userAddress = await getFarcasterUserAddress(fid, {
hasVerifiedAddresses: false, // [!code focus]
});
```
50 changes: 14 additions & 36 deletions site/docs/pages/farcasterkit/introduction.mdx
Original file line number Diff line number Diff line change
@@ -1,43 +1,21 @@
### getFarcasterUserAddress
# Introduction to Farcaster Kit [A brief introduction on essential Farcaster knowledge.]

The `getFarcasterUserAddress` function retrieves the user address associated with a given Farcaster ID (fid). It provides options to specify whether the client wants `custody address` and/or `verified addresses`, and also allows the user to provide their own neynar api key. By default, both `custody` and `verified` addresses are provided.
Farcaster is a decentralized social network on Ethereum.
Users create profiles, post "casts," and follow others.
They own their [accounts](https://docs.farcaster.xyz/learn/what-is-farcaster/accounts) and relationships.

```tsx
import { getFarcasterUserAddress } from '@coinbase/onchainkit/farcaster';
To join, users need an Ethereum address for onchain registration.

async function fetchUserAddress(fid: number) {
// Returns custody and verified addresses. If there is an error, returns null
const userAddress = await getFarcasterUserAddress(fid);
console.log(userAddress);
}
Farcaster [contracts](https://docs.farcaster.xyz/learn/architecture/contracts) are deployed on Optimism, an Ethereum Layer 2 network.
Core contracts include ID Registry, Key Registry, and Storage Registry.

fetchUserAddress(3);
```
[ID Registry](https://docs.farcaster.xyz/reference/contracts/reference/id-registry) tracks Farcaster IDs (aka FID), linking them to Ethereum addresses. [Key Registry](https://docs.farcaster.xyz/reference/contracts/reference/key-gateway) links Farcaster IDs with ed25519 public keys.

**@Param**
Only [messages](https://docs.farcaster.xyz/learn/what-is-farcaster/messages) signed by registered keys are valid.

```ts
// Fid - Farcaster Id
fid: number;
To assist you in engaging with Farcaster, here is the Farcaster Kit which includes:

// Optional options to specify whether the client wants custody and/or verified addresses
// along with their neynar api key
type GetFarcasterUserAddressOptions =
| {
neynarApiKey?: string; // default to onchain-kit's default key
hasCustodyAddress?: boolean; // default to true
hasVerifiedAddresses?: boolean; // default to true
}
| undefined;
```

**@Returns**

```ts
type GetFarcasterUserAddressResponse = {
// Custody Address of a given fid
custodyAddress?: string;
// List of all verified addresses for a given fid
verifiedAddresses?: string[];
};
```
- Utilities:
- [getFarcasterUserAddress](/farcasterkit/get-farcaster-user-address)
- Types:
- [GetFarcasterUserAddressResponse]()
10 changes: 10 additions & 0 deletions site/docs/pages/farcasterkit/types.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Types [Glossary of Types in Farcaster Kit.]

## `GetFarcasterUserAddressResponse`

```ts
type GetFarcasterUserAddressResponse = {
custodyAddress?: string; // Custody Address of a given fid
verifiedAddresses?: string[]; // List of all verified addresses for a given fid
};
```
20 changes: 19 additions & 1 deletion site/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,25 @@ export const sidebar = [
},
{
text: 'Farcaster Kit',
items: [{ text: 'Introduction', link: '/farcasterkit/introduction' }],
items: [
{
text: 'Introduction',
link: '/farcasterkit/introduction',
},
{
text: 'Utilities',
items: [
{
text: 'getFarcasterUserAddress',
link: '/farcasterkit/get-farcaster-user-address',
},
],
},
{
text: 'Types',
link: '/farcasterkit/types',
},
],
},
{
text: 'Frame Kit',
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '0.6.1';
export const version = '0.6.2';

0 comments on commit 3788d05

Please sign in to comment.