Skip to content

Commit f13b93d

Browse files
authored
update spend permissions docs (#188)
1 parent e8d0976 commit f13b93d

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

docs/base-account/improve-ux/spend-permissions.mdx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,13 @@ console.log("Spend Permission:", permission);
4848

4949
Using a permission is 2 steps:
5050

51-
1. **Prepare the calls** — Call `prepareSpendCallData` with the permission and an `amount`.
51+
1. **Prepare the calls** — Call `prepareSpendCallData` with the permission and the requested `amount`.
5252
2. **Submit the calls** — Submit the calls using your app's spender account.
5353

5454
`prepareSpendCallData` returns an array of calls needed to spend the tokens:
5555

5656
- `approveWithSignature` — When the permission is not yet registered onchain, this call would be prepended to the `spend` call.
57-
- `spend` — The call to spend the tokens.
58-
59-
This array should have 1 or 2 calls, submit them in order using your app's spender account.
57+
- `spend` — The call to spend the tokens from the user's Base Account.
6058

6159
```tsx
6260
import { prepareSpendCallData } from "@base-org/account/spend-permission";
@@ -98,6 +96,15 @@ await Promise.all(
9896
);
9997
```
10098

99+
<Note>
100+
**About the `spendCalls` array**
101+
102+
This array has 2 calls when submitting the permission onchain for *the first time*.
103+
When the permission is already registered onchain, this array has only 1 call (the `spend` call).
104+
105+
For most use cases, you don't need to worry about this.
106+
</Note>
107+
101108
### Revoke a Spend Permission
102109

103110
You can revoke a permission in two ways:

docs/docs.json

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@
229229
"base-account/reference/base-pay/pay",
230230
"base-account/reference/base-pay/getPaymentStatus",
231231
"base-account/reference/core/getProvider",
232+
"base-account/reference/spend-permission-utilities/requestSpendPermission",
233+
"base-account/reference/spend-permission-utilities/prepareSpendCallData",
234+
"base-account/reference/spend-permission-utilities/fetchPermissions",
235+
"base-account/reference/spend-permission-utilities/getPermissionStatus",
236+
"base-account/reference/spend-permission-utilities/requestRevoke",
237+
"base-account/reference/spend-permission-utilities/prepareRevokeCallData",
232238
"base-account/reference/core/generateKeyPair",
233239
"base-account/reference/core/getKeypair",
234240
"base-account/reference/core/getCryptoKeyAccount"
@@ -296,17 +302,6 @@
296302
}
297303
]
298304
},
299-
{
300-
"group": "Spend Permission Utilities",
301-
"pages": [
302-
"base-account/reference/spend-permission-utilities/requestSpendPermission",
303-
"base-account/reference/spend-permission-utilities/prepareSpendCallData",
304-
"base-account/reference/spend-permission-utilities/fetchPermissions",
305-
"base-account/reference/spend-permission-utilities/getPermissionStatus",
306-
"base-account/reference/spend-permission-utilities/requestRevoke",
307-
"base-account/reference/spend-permission-utilities/prepareRevokeCallData"
308-
]
309-
},
310305
{
311306
"group": "UI Elements",
312307
"pages": [

0 commit comments

Comments
 (0)