diff --git a/.changeset/thin-windows-attend.md b/.changeset/thin-windows-attend.md index 44fc9fd14a..ed36c9bc59 100644 --- a/.changeset/thin-windows-attend.md +++ b/.changeset/thin-windows-attend.md @@ -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 diff --git a/README.md b/README.md index 4fe5558fbf..1034a29156 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ # OnchainKit

- 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.

@@ -40,6 +40,10 @@

+## Documentation + +For documentation and guides, visit [onchainkit.xyz](https://onchainkit.xyz/). + ## Getting Started Add OnchainKit to your project, install the required packages. @@ -59,8 +63,11 @@ pnpm add @coinbase/onchainkit viem@2.x 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-)

diff --git a/site/.yarn/install-state.gz b/site/.yarn/install-state.gz index ea0407f98d..8e9efe360f 100644 Binary files a/site/.yarn/install-state.gz and b/site/.yarn/install-state.gz differ diff --git a/site/docs/pages/farcasterkit/get-farcaster-user-address.mdx b/site/docs/pages/farcasterkit/get-farcaster-user-address.mdx new file mode 100644 index 0000000000..c4b5df17d2 --- /dev/null +++ b/site/docs/pages/farcasterkit/get-farcaster-user-address.mdx @@ -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] +}); +``` diff --git a/site/docs/pages/farcasterkit/introduction.mdx b/site/docs/pages/farcasterkit/introduction.mdx index cb25eff23c..2d2741d1bc 100644 --- a/site/docs/pages/farcasterkit/introduction.mdx +++ b/site/docs/pages/farcasterkit/introduction.mdx @@ -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]() diff --git a/site/docs/pages/farcasterkit/types.mdx b/site/docs/pages/farcasterkit/types.mdx new file mode 100644 index 0000000000..23d48b3fd7 --- /dev/null +++ b/site/docs/pages/farcasterkit/types.mdx @@ -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 +}; +``` diff --git a/site/sidebar.ts b/site/sidebar.ts index f0f279c028..ea11b856cf 100644 --- a/site/sidebar.ts +++ b/site/sidebar.ts @@ -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', diff --git a/src/version.ts b/src/version.ts index 358203cd28..935ba09f91 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version = '0.6.1'; +export const version = '0.6.2';