From 311b027e6f2acf7c9cad3534ca0cd130c9897314 Mon Sep 17 00:00:00 2001 From: Alvaro Raminelli Date: Wed, 21 Feb 2024 23:25:50 -0800 Subject: [PATCH] chore: bump add docs for `getEASAttestations` (#126) --- .changeset/stale-waves-wink.md | 5 ++ README.md | 2 + .../identitykit/get-eas-attestations.mdx | 68 +++++++++++++++++++ site/docs/pages/identitykit/introduction.mdx | 4 +- site/sidebar.ts | 9 +++ 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 .changeset/stale-waves-wink.md create mode 100644 site/docs/pages/identitykit/get-eas-attestations.mdx diff --git a/.changeset/stale-waves-wink.md b/.changeset/stale-waves-wink.md new file mode 100644 index 0000000000..6fc07e7f50 --- /dev/null +++ b/.changeset/stale-waves-wink.md @@ -0,0 +1,5 @@ +--- +'@coinbase/onchainkit': minor +--- + +- **feat**: added initial version of `getEASAttestations`, which helps getting the user attestations from the Ethereum Attetation Service (EAS). diff --git a/README.md b/README.md index 44d7a5ed89..54cb3d9197 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ OnchainKit offers three themes packed with React components and TypeScript utili - Components: - [``](https://onchainkit.xyz/identitykit/avatar) - [``](https://onchainkit.xyz/identitykit/name) + - Utilities: + - [`getEASAttestations`](https://onchainkit.xyz/identitykit/get-eas-attestations) - [XMTP Kit](https://onchainkit.xyz/xmtpkit/introduction) - Utilities: diff --git a/site/docs/pages/identitykit/get-eas-attestations.mdx b/site/docs/pages/identitykit/get-eas-attestations.mdx new file mode 100644 index 0000000000..1328993229 --- /dev/null +++ b/site/docs/pages/identitykit/get-eas-attestations.mdx @@ -0,0 +1,68 @@ +# getEASAttestations + +The `getEASAttestations` function fetches attestations for a specified address and blockchain in Ethereum Attestation Service (EAS). It allows optional filtering based on schema IDs, revocation status, expiration time, and the number of attestations to return. + +## Usage + +```ts +import { getEASAttestations } from '@coinbase/onchainkit'; +import { base } from 'viem/chains'; + +const attestations = await getEASAttestations({ + '0x1234567890abcdef1234567890abcdef12345678', + base, + { + // Optional schemas to filter the attestations. + schemas: ['0x1801901fabd0e6189356b4fb52bb0ab855276d84f7ec140839fbd1f6801ca065'], + }, +}); + +console.log(attestations); +``` + +## Returns + +```ts +// Array of EAS Attestation objects +type GetEASAttestationsResponse = EASAttestation[]; + +type EASAttestation = { + attester: EASAttesterAddress; // the attester who created the attestation. + decodedDataJson: string; // The attestation data decoded to JSON. + expirationTime: number; // The Unix timestamp when the attestation expires (0 for no expiration). + id: string; // The unique identifier of the attestation. + recipient: Address; // The Ethereum address of the recipient of the attestation. + revocationTime: number; // The Unix timestamp when the attestation was revoked, if applicable. + revoked: boolean; // A boolean indicating whether the attestation is revocable or not. + schemaId: EASSchemaUid; // The schema identifier associated with the attestation. + time: number; // The Unix timestamp when the attestation was created. +}; + +type EASAttesterAddress = Address; + +type EASSchemaUid = Address; + +type Address = `0x${string}`; +``` + +## Parameters + +```ts +// Address - Ethereum address for which attestations are being queried +address: Address; + +// Chain - The blockchain of interest +chain: Chain; + +// Optional filtering options for the attestations query +type GetEASAttestationsOptions = { + schemas?: EASSchemaUid[]; // Schema IDs to filter attestations + revoked?: boolean; // Filter for revoked attestations (default: false) + expirationTime?: number; // Unix timestamp to filter based on expiration time (default: current time) + limit?: number; // Maximum number of attestations to return (default: 10) +}; + +type EASSchemaUid = Address; + +type Address = `0x${string}`; +``` diff --git a/site/docs/pages/identitykit/introduction.mdx b/site/docs/pages/identitykit/introduction.mdx index 6497e19584..f1a8ef39d3 100644 --- a/site/docs/pages/identitykit/introduction.mdx +++ b/site/docs/pages/identitykit/introduction.mdx @@ -11,5 +11,7 @@ It provides a set of tools to resolve Ethereum addresses to ENS names, and more. To assist you in engaging with onchain Identity, here is the Identity Kit which includes: - Components: - - [`
`](/identitykit/avatar): A component to display an Ethereum address. + - [``](/identitykit/avatar): A component to display an ENS avatar. - [``](/identitykit/name): A component to display an ENS name. +- Utilities: + - [`getEASAttestations`](/identitykit/get-eas-attestations): A function to fetche EAS attestations. diff --git a/site/sidebar.ts b/site/sidebar.ts index 846225620e..7d25edb02e 100644 --- a/site/sidebar.ts +++ b/site/sidebar.ts @@ -84,6 +84,15 @@ export const sidebar = [ }, ], }, + { + text: 'Utilities', + items: [ + { + text: 'getEASAttestations', + link: '/identitykit/get-eas-attestations', + }, + ], + }, { text: 'Types', link: '/identitykit/types',