From 94d9fcba4af5f0046f3a6c665a124081330891a3 Mon Sep 17 00:00:00 2001 From: youssefea Date: Wed, 13 Aug 2025 17:17:47 +0100 Subject: [PATCH 1/4] adding provider to spend permissions and updating types --- .../improve-ux/spend-permissions.mdx | 20 +++++++++ .../fetchPermissions.mdx | 42 +++++++++++++++++++ .../getPermissionStatus.mdx | 32 +++++++++++++- .../prepareRevokeCallData.mdx | 32 +++++++++++++- .../prepareSpendCallData.mdx | 33 ++++++++++++++- .../requestRevoke.mdx | 32 +++++++++++++- .../requestSpendPermission.mdx | 12 ++++++ 7 files changed, 198 insertions(+), 5 deletions(-) diff --git a/docs/base-account/improve-ux/spend-permissions.mdx b/docs/base-account/improve-ux/spend-permissions.mdx index 2f3a1ce2..ad9a055d 100644 --- a/docs/base-account/improve-ux/spend-permissions.mdx +++ b/docs/base-account/improve-ux/spend-permissions.mdx @@ -31,6 +31,14 @@ You create an EIP-712 payload that describes the permission and ask the user to ```tsx import { requestSpendPermission } from "@base-org/account/spend-permission"; +import { createBaseAccountSDK } from "@base-org/account"; +import { base } from "viem/chains"; + +const sdk = createBaseAccountSDK({ + appName: 'Base Account SDK Demo', + appLogoUrl: 'https://base.org/logo.png', + appChainIds: [base.id], +}); const permission = await requestSpendPermission({ account: "0x...", @@ -39,6 +47,7 @@ const permission = await requestSpendPermission({ chainId: 8453, // or any other supported chain allowance: 1_000_000n, periodInDays: 30, + provider: sdk.getProvider(), }); console.log("Spend Permission:", permission); @@ -177,6 +186,15 @@ import { prepareRevokeCallData, } from "@base-org/account/spend-permission"; +import { createBaseAccountSDK } from "@base-org/account"; +import { base } from "viem/chains"; + +const sdk = createBaseAccountSDK({ + appName: 'Base Account SDK Demo', + appLogoUrl: 'https://base.org/logo.png', + appChainIds: [base.id], +}); + const spender = "0xAppSpenderAddress"; // 1) Fetch available permissions @@ -184,6 +202,7 @@ const permissions = await fetchPermissions({ account: "0xUserBaseAccountAddress", chainId: 84532, spender, + provider: sdk.getProvider(), }); // ======================================== @@ -237,6 +256,7 @@ const newPermission = await requestSpendPermission({ chainId: 84532, allowance: 1_000_000n, periodInDays: 30, + provider: sdk.getProvider(), }); // 3. prepare the calls diff --git a/docs/base-account/reference/spend-permission-utilities/fetchPermissions.mdx b/docs/base-account/reference/spend-permission-utilities/fetchPermissions.mdx index f6e6827f..eaf2f12d 100644 --- a/docs/base-account/reference/spend-permission-utilities/fetchPermissions.mdx +++ b/docs/base-account/reference/spend-permission-utilities/fetchPermissions.mdx @@ -24,20 +24,62 @@ Defined in the [Base Account SDK](https://github.com/base/account-sdk) Spender address you intend to use for spending. + + EIP-1193 compliant Ethereum provider instance. Get this from `sdk.getProvider()`. + + ## Returns Array of spend permissions matching the query. + + + +Deterministic EIP-712 hash of the permission. + + + + Signature for the EIP-712 payload. + + + + Target chain ID. + + + +Underlying permission fields. + + + + + + +Duration in seconds. +Unix timestamp (seconds). +Unix timestamp (seconds). + + + + + ```typescript Fetch permissions import { fetchPermissions } from "@base-org/account/spend-permission"; +import { createBaseAccountSDK } from "@base-org/account"; + +const sdk = createBaseAccountSDK({ + appName: 'My App', + appLogoUrl: 'https://example.com/logo.png', + appChainIds: [84532], +}); const permissions = await fetchPermissions({ account: "0xUserBaseAccountAddress", chainId: 84532, spender: "0xAppSpenderAddress", + provider: sdk.getProvider(), }); ``` diff --git a/docs/base-account/reference/spend-permission-utilities/getPermissionStatus.mdx b/docs/base-account/reference/spend-permission-utilities/getPermissionStatus.mdx index 447368b6..ebb5d7f4 100644 --- a/docs/base-account/reference/spend-permission-utilities/getPermissionStatus.mdx +++ b/docs/base-account/reference/spend-permission-utilities/getPermissionStatus.mdx @@ -13,7 +13,37 @@ Defined in the [Base Account SDK](https://github.com/base/account-sdk) ## Parameters - Signed permission to evaluate. + Signed permission to evaluate. This should be a SpendPermission object returned from [`requestSpendPermission`](/base-account/reference/spend-permission-utilities/requestSpendPermission) or fetched via [`fetchPermissions`](/base-account/reference/spend-permission-utilities/fetchPermissions). + + + +Deterministic EIP-712 hash of the permission. + + + + Signature for the EIP-712 payload. + + + + Target chain ID. + + + +Underlying permission fields. + + + + + + +Duration in seconds. +Unix timestamp (seconds). +Unix timestamp (seconds). + + + + + ## Returns diff --git a/docs/base-account/reference/spend-permission-utilities/prepareRevokeCallData.mdx b/docs/base-account/reference/spend-permission-utilities/prepareRevokeCallData.mdx index af913f77..37e3950b 100644 --- a/docs/base-account/reference/spend-permission-utilities/prepareRevokeCallData.mdx +++ b/docs/base-account/reference/spend-permission-utilities/prepareRevokeCallData.mdx @@ -14,7 +14,37 @@ Defined in the [Base Account SDK](https://github.com/base/account-sdk) ## Parameters - The permission to revoke. + The spend permission to revoke. This should be a SpendPermission object returned from [`requestSpendPermission`](/base-account/reference/spend-permission-utilities/requestSpendPermission) or fetched via [`fetchPermissions`](/base-account/reference/spend-permission-utilities/fetchPermissions). + + + +Deterministic EIP-712 hash of the permission. + + + + Signature for the EIP-712 payload. + + + + Target chain ID. + + + +Underlying permission fields. + + + + + + +Duration in seconds. +Unix timestamp (seconds). +Unix timestamp (seconds). + + + + + ## Returns diff --git a/docs/base-account/reference/spend-permission-utilities/prepareSpendCallData.mdx b/docs/base-account/reference/spend-permission-utilities/prepareSpendCallData.mdx index b8111081..0c0ea604 100644 --- a/docs/base-account/reference/spend-permission-utilities/prepareSpendCallData.mdx +++ b/docs/base-account/reference/spend-permission-utilities/prepareSpendCallData.mdx @@ -14,8 +14,37 @@ Defined in the [Base Account SDK](https://github.com/base/account-sdk) ## Parameters - Signed permission returned from `requestSpendPermission` or fetched via - `fetchPermissions`. + Signed permission returned from [`requestSpendPermission`](/base-account/reference/spend-permission-utilities/requestSpendPermission) or fetched via [`fetchPermissions`](/base-account/reference/spend-permission-utilities/fetchPermissions). + + + +Deterministic EIP-712 hash of the permission. + + + + Signature for the EIP-712 payload. + + + + Target chain ID. + + + +Underlying permission fields. + + + + + + +Duration in seconds. +Unix timestamp (seconds). +Unix timestamp (seconds). + + + + + diff --git a/docs/base-account/reference/spend-permission-utilities/requestRevoke.mdx b/docs/base-account/reference/spend-permission-utilities/requestRevoke.mdx index fdf7eb17..28b56d5e 100644 --- a/docs/base-account/reference/spend-permission-utilities/requestRevoke.mdx +++ b/docs/base-account/reference/spend-permission-utilities/requestRevoke.mdx @@ -13,7 +13,37 @@ Defined in the [Base Account SDK](https://github.com/base/account-sdk) ## Parameters - The permission to revoke. + The spend permission to revoke. This should be a SpendPermission object returned from [`requestSpendPermission`](/base-account/reference/spend-permission-utilities/requestSpendPermission) or fetched via [`fetchPermissions`](/base-account/reference/spend-permission-utilities/fetchPermissions). + + + +Deterministic EIP-712 hash of the permission. + + + + Signature for the EIP-712 payload. + + + + Target chain ID. + + + +Underlying permission fields. + + + + + + +Duration in seconds. +Unix timestamp (seconds). +Unix timestamp (seconds). + + + + + ## Returns diff --git a/docs/base-account/reference/spend-permission-utilities/requestSpendPermission.mdx b/docs/base-account/reference/spend-permission-utilities/requestSpendPermission.mdx index e3c31b86..a75b3088 100644 --- a/docs/base-account/reference/spend-permission-utilities/requestSpendPermission.mdx +++ b/docs/base-account/reference/spend-permission-utilities/requestSpendPermission.mdx @@ -54,6 +54,10 @@ Defined in the [Base Account SDK](https://github.com/base/account-sdk) Arbitrary data to attach to the permission. Hex string. Defaults to `0x`. + + EIP-1193 compliant Ethereum provider instance. Get this from `sdk.getProvider()`. + + ## Returns @@ -93,6 +97,13 @@ Underlying permission fields. ```typescript Create and sign a spend permission import { requestSpendPermission } from "@base-org/account/spend-permission"; +import { createBaseAccountSDK } from "@base-org/account"; + +const sdk = createBaseAccountSDK({ + appName: 'My App', + appLogoUrl: 'https://example.com/logo.png', + appChainIds: [84532], +}); const permission = await requestSpendPermission({ account: "0xUserBaseAccountAddress", @@ -101,6 +112,7 @@ const permission = await requestSpendPermission({ chainId: 84532, allowance: 1_000_000n, periodInDays: 30, + provider: sdk.getProvider(), }); console.log("Spend Permission:", permission); From 78bfbec158cfaa760a63ad7f2c003adf92b558bb Mon Sep 17 00:00:00 2001 From: youssefea Date: Thu, 14 Aug 2025 15:55:58 +0100 Subject: [PATCH 2/4] add callout --- docs/base-account/improve-ux/spend-permissions.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/base-account/improve-ux/spend-permissions.mdx b/docs/base-account/improve-ux/spend-permissions.mdx index ad9a055d..00f8c8a8 100644 --- a/docs/base-account/improve-ux/spend-permissions.mdx +++ b/docs/base-account/improve-ux/spend-permissions.mdx @@ -11,6 +11,10 @@ After the user signs the permission, the `spender` can initiate transfers within Read more about the Spend Permission Manager contract and supported chains on [GitHub](https://github.com/coinbase/spend-permissions). + + Spend Permissions are currently not available on Base App Mini Apps. + + ## Usage ### Request a Spend Permission From 3aa333e5e35535f6580ec11d7881be69dccfcf86 Mon Sep 17 00:00:00 2001 From: youssefea Date: Thu, 14 Aug 2025 15:57:09 +0100 Subject: [PATCH 3/4] update --- docs/base-account/improve-ux/spend-permissions.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/base-account/improve-ux/spend-permissions.mdx b/docs/base-account/improve-ux/spend-permissions.mdx index 00f8c8a8..1fee4af1 100644 --- a/docs/base-account/improve-ux/spend-permissions.mdx +++ b/docs/base-account/improve-ux/spend-permissions.mdx @@ -13,6 +13,7 @@ Read more about the Spend Permission Manager contract and supported chains on [G Spend Permissions are currently not available on Base App Mini Apps. + They will be supported in the future. ## Usage From f8ef2c1805a9701edcb3bca22a7807c26add1a5b Mon Sep 17 00:00:00 2001 From: youssefea Date: Thu, 14 Aug 2025 18:32:51 +0100 Subject: [PATCH 4/4] update language --- docs/base-account/improve-ux/spend-permissions.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/base-account/improve-ux/spend-permissions.mdx b/docs/base-account/improve-ux/spend-permissions.mdx index 1fee4af1..ad9bb0ba 100644 --- a/docs/base-account/improve-ux/spend-permissions.mdx +++ b/docs/base-account/improve-ux/spend-permissions.mdx @@ -12,8 +12,7 @@ After the user signs the permission, the `spender` can initiate transfers within Read more about the Spend Permission Manager contract and supported chains on [GitHub](https://github.com/coinbase/spend-permissions). - Spend Permissions are currently not available on Base App Mini Apps. - They will be supported in the future. + Spend Permissions for Base App Mini Apps are coming soon and will be supported in a future update. ## Usage