From 7429a111fbbedc8a7456b483ff8d3c2110f270a2 Mon Sep 17 00:00:00 2001 From: Patrick Hughes Date: Sat, 21 Dec 2024 13:20:17 -0600 Subject: [PATCH] format --- .../coinbase-fetchpermissions.mdx | 93 ++++++++++++++++--- vocs.config.tsx | 2 +- 2 files changed, 80 insertions(+), 15 deletions(-) diff --git a/docs/pages/guides/spend-permissions/api-reference/coinbase-fetchpermissions.mdx b/docs/pages/guides/spend-permissions/api-reference/coinbase-fetchpermissions.mdx index a076409..805d48d 100644 --- a/docs/pages/guides/spend-permissions/api-reference/coinbase-fetchpermissions.mdx +++ b/docs/pages/guides/spend-permissions/api-reference/coinbase-fetchpermissions.mdx @@ -1,32 +1,69 @@ -## Coinbase Wallet API +# Coinbase Wallet API - Spend Permissions -### `coinbase_fetchPermissions` +The `coinbase_fetchPermissions` RPC method retrieves permissions associated with a specific account, chain, and spender. This method excludes permissions that have expired or been revoked. -A utility API endpoint for recalling permissions previously granted for a specific user. -Excludes permissions that have expired or been revoked. +## Overview -#### Schema +**RPC Method:** `coinbase_fetchPermissions` **Endpoint:** `https://rpc.wallet.coinbase.com` +This RPC method allows you to query active spend permissions for an account on a specific chain and spender. + +## Example Request + +Below is an example of how to use the `coinbase_fetchPermissions` method with a cURL request: + +```bash +curl --location 'https://rpc.wallet.coinbase.com' \ +--header 'Content-Type: application/json' \ +--data '{ + "jsonrpc": "2.0", + "method": "coinbase_fetchPermissions", + "params": [ + { + "account": "0xfB2adc8629FC9F54e243377ffcECEb437a42934C", + "chainId": "0x14A34", + "spender": "0x2a83b0e4462449660b6e7567b2c81ac6d04d877d" + } + ], + "id": 1 +}' +``` + +## Request Schema + ```typescript type FetchPermissionsRequest = { chainId: string; // hex, uint256 account: string; // address spender: string; // address pageOptions?: { - pageSize number; // number of items requested, defaults to 50 - cursor string; // identifier for where the page should start - } -} + pageSize: number; // number of items requested, defaults to 50 + cursor: string; // identifier for where the page should start + }; +}; +``` + +### Parameters + +- **`chainId`**: The ID of the blockchain, in hexadecimal format. +- **`account`**: The address of the account whose permissions are being queried. +- **`spender`**: The entity granted with the permission to spend the `account`'s funds. +- **`pageOptions`** _(optional)_: + - **`pageSize`**: The number of permissions to fetch in a single request (default: 50). + - **`cursor`**: A unique identifier to start fetching from a specific page. +## Response Schema + +```typescript type FetchPermissionsResult = { permissions: FetchPermissionsResultItem[]; pageDescription: { - pageSize number; // number of items returned - nextCursor string; // identifier for where the next page should start - } -} + pageSize: number; // number of items returned + nextCursor: string; // identifier for where the next page should start + }; +}; type FetchPermissionsResultItem = { createdAt: number; // UTC timestamp for when the permission was granted @@ -43,5 +80,33 @@ type FetchPermissionsResultItem = { salt: string; // base 10 numeric string extraData: string; // hex }; -} +}; ``` + +### Fields + +- **`permissions`**: An array of permission objects. +- **`pageDescription`**: + - **`pageSize`**: Number of permissions returned in this response. + - **`nextCursor`**: The cursor to be used for the next page of results. + +### Permission Object + +- **`createdAt`**: The UTC timestamp when the permission was granted. +- **`permissionHash`**: A unique hash representing the permission. +- **`signature`**: The cryptographic signature for the permission. +- **`permission`**: + - **`account`**: The address of the account granting the permission. + - **`spender`**: The address of the spender receiving the permission. + - **`token`**: The address of the token involved. + - **`allowance`**: The amount allowed, represented as a base 10 numeric string. + - **`period`**: Duration of the permission in Unix seconds. + - **`start`**: Start time of the permission in Unix seconds. + - **`end`**: End time of the permission in Unix seconds. + - **`salt`**: A unique salt value as a base 10 numeric string. + - **`extraData`**: Additional data in hexadecimal format. + +## Notes + +- Ensure the `chainId`, `account`, and `spender` parameters are correctly formatted and valid for the blockchain you are querying. +- This RPC method only returns active permissions. diff --git a/vocs.config.tsx b/vocs.config.tsx index 46d69c6..e862e62 100644 --- a/vocs.config.tsx +++ b/vocs.config.tsx @@ -148,7 +148,7 @@ export default defineConfig({ link: "/guides/spend-permissions/api-reference/spendpermissionmanager", }, { - text: "coinbase_fetchPermissions", + text: "Fetch Permissions API", link: "/guides/spend-permissions/api-reference/coinbase-fetchpermissions", }, {