Skip to content

Commit b1f7c99

Browse files
committed
edits to address reviewer comments
1 parent c3a362d commit b1f7c99

File tree

6 files changed

+39
-48
lines changed

6 files changed

+39
-48
lines changed

delegation-toolkit/concepts/delegation/index.md

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,22 @@ For example: Alice delegates the ability to spend her USDC to Bob, limiting the
2222

2323
The delegation lifecycle is as follows:
2424

25-
1. **Create a delegation** - The delegator account creates and signs a delegation.
26-
27-
2. **Apply caveats** - The caveats applied to the delegation specify conditions under which
28-
the delegation can be redeemed.
25+
1. **Create a delegation** - The delegator account creates a delegation, applying *caveats* which specify conditions under which the delegation can be redeemed.
26+
The delegator signs the delegation.
2927

3028
3. **Store the delegation** - A dapp can store the delegation, enabling retrieval for future redemption.
3129

3230
4. **Redeem the delegation** - The delegate (the account being granted the permission) redeems the delegation via the Delegation Manager,
3331
which verifies that the delegated authority is valid in order to perform the execution.
3432

35-
See [how to perform executions on a user's behalf](../../guides/delegation/execute-on-users-behalf.md) to get started with the delegation lifecycle.
33+
See [how to perform executions on a smart account's behalf](../../guides/delegation/execute-on-smart-accounts-behalf.md) to get started with the delegation lifecycle.
3634

3735
## Delegation types
3836

3937
You can create the following delegation types:
4038

41-
- **Root delegation** - A root delegation is a delegation that doesn't derive its authority from another delegation.
42-
It is when a delegator delegates its own authority away.
39+
- **Root delegation** - A root delegation is when a delegator delegates their own authority away, as opposed to *redelegating* permissions they received from a previous delegation.
40+
In a chain of delegations, the first delegation is the root delegation.
4341
For example, Alice delegates the ability to spend her USDC to Bob, limiting the amount to 100 USDC.
4442

4543
Use [`createDelegation`](../../reference/api/delegation.md#createdelegation) to create a root delegation.
@@ -49,7 +47,7 @@ You can create the following delegation types:
4947
For example, Alice delegates the ability to spend 100 of her USDC to anyone.
5048

5149
You must create open root delegations carefully, to ensure that they are not misused.
52-
Use [`createOpenDelegation`](../../reference/api/delegation.md#createopendelegation) to create a root delegation.
50+
Use [`createOpenDelegation`](../../reference/api/delegation.md#createopendelegation) to create an open root delegation.
5351

5452
- **Redelegation** - A delegate can redelegate permissions that have been granted to them, creating a chain of delegations across trusted parties.
5553
For example, Alice delegates the ability to spend 100 of her USDC to Bob.
@@ -87,18 +85,18 @@ It consists of the following components:
8785

8886
1. Validates the input data by ensuring the lengths of `delegations`, `modes`, and
8987
`executions` match.
90-
2. Decodes and validates the delegation, checking that the caller is the delegate
88+
2. Decodes and validates the delegation, checking that the caller is the delegate
9189
and that there are no empty signatures.
92-
3. Verifies delegation signatures, ensuring validity using ECDSA (for EOAs) or
90+
3. Verifies delegation signatures, ensuring validity using ECDSA (for EOAs) or
9391
`isValidSignature` (for contracts).
94-
4. Validates the delegation chain's authority and ensures delegations are not disabled.
95-
5. Executes the `beforeHook` for each [caveat](caveat-enforcers.md) in the delegation, passing relevant data (`terms`,
92+
4. Validates the delegation chain's authority and ensures delegations are not disabled.
93+
5. Executes the `beforeHook` for each [caveat](caveat-enforcers.md) in the delegation, passing relevant data (`terms`,
9694
`arguments`, `mode`, `execution` `calldata`, and `delegationHash`) to the caveat enforcer.
97-
6. Calls `executeFromExecutor` to perform the delegation's execution, either by the delegator or
95+
6. Calls `executeFromExecutor` to perform the delegation's execution, either by the delegator or
9896
the caller for self-authorized executions.
99-
7. Executes the `afterHook` for each caveat, similar to the `beforeHook`, passing required data
97+
7. Executes the `afterHook` for each caveat, similar to the `beforeHook`, passing required data
10098
to enforce post-execution conditions.
101-
8. Emits `RedeemedDelegation` events for each delegation that was successfully redeemed.
99+
8. Emits `RedeemedDelegation` events for each delegation that was successfully redeemed.
102100

103101
- **Caveat enforcers** - [Caveat enforcers](caveat-enforcers.md) manage rules and restrictions for delegations,
104102
providing fine-tuned control over delegated executions.
@@ -154,32 +152,29 @@ sequenceDiagram
154152
## Execution modes
155153

156154
When redeeming a delegation using [`redeemDelegations`](../../reference/api/delegation.md#redeemdelegations), you must pass an execution mode for each delegation chain you pass to the method.
157-
The Delegation Toolkit supports several execution modes based on [ERC-7579](https://erc7579.com/): `SINGLE_DEFAULT_MODE`, `SINGLE_TRY_MODE`, `BATCH_DEFAULT_MODE`, and `BATCH_TRY_MODE`.
155+
The Delegation Toolkit supports the following execution modes, based on [ERC-7579](https://erc7579.com/):
156+
157+
| Execution mode | Number of delegation chains passed to `redeemDelegations` | Processing method | Does user operation continue execution if redemption reverts? |
158+
|--|--|--|--|
159+
| `SINGLE_DEFAULT_MODE` | One | Sequential | No |
160+
| `SINGLE_TRY_MODE` | One | Sequential | Yes |
161+
| `BATCH_DEFAULT_MODE` | Multiple | Interleaved | No |
162+
| `BATCH_TRY_MODE` | Multiple | Interleaved | Yes |
158163

159-
### `SINGLE` execution modes
164+
### Sequential processing
160165

161-
In `SINGLE` modes, you can provide only one delegation chain and one execution.
162-
Processing is sequential:
166+
In `SINGLE` modes, processing is sequential:
163167

164168
1. For each delegation in the chain, all caveats' `before` hooks are called.
165169
2. The single redeemed action is executed.
166170
3. For each delegation in the chain, all caveats' `after` hooks are called.
167171

168-
### `BATCH` execution modes
172+
### Interleaved processing
169173

170-
In `BATCH` modes, you can provide multiple delegation chains and multiple executions.
171-
Processing is interleaved:
174+
In `BATCH` modes, processing is interleaved:
172175

173176
1. For each chain in the batch, and each delegation in the chain, all caveats' `before` hooks are called.
174177
2. Each redeemed action is executed.
175178
3. For each chain in the batch, and each delegation in the chain, all caveats' `after` hooks are called.
176179

177180
`BATCH` mode allows for powerful use cases, but the Delegation Framework currently does not include any `BATCH` compatible caveat enforcers.
178-
179-
### `DEFAULT` modes
180-
181-
In `DEFAULT` modes, if a revert occurs during redemption, the entire user operation reverts at that point.
182-
183-
### `TRY` modes
184-
185-
In `TRY` modes, if a revert occurs during redemption, execution of the user operation continues.

delegation-toolkit/get-started/smart-account-quickstart/eip7702.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,6 @@ const userOperationHash = await bundlerClient.sendUserOperation({
156156

157157
## Next steps
158158

159-
- To grant specific permissions to other accounts from your smart account, [create a delegation](../../guides/delegation/execute-on-users-behalf.md).
159+
- To grant specific permissions to other accounts from your smart account, [create a delegation](../../guides/delegation/execute-on-smart-accounts-behalf.md).
160160
- To quickly bootstrap a MetaMask Smart Accounts project, [use the CLI](../use-the-cli.md).
161161
- You can also [use MetaMask SDK to upgrade a MetaMask account to a smart account](/sdk/tutorials/upgrade-eoa-to-smart-account).

delegation-toolkit/get-started/smart-account-quickstart/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const userOperationHash = await bundlerClient.sendUserOperation({
9494

9595
## Next steps
9696

97-
- To grant specific permissions to other accounts from your smart account, [create a delegation](../../guides/delegation/execute-on-users-behalf.md).
97+
- To grant specific permissions to other accounts from your smart account, [create a delegation](../../guides/delegation/execute-on-smart-accounts-behalf.md).
9898
- This quickstart example uses a Hybrid smart account.
9999
You can also [configure other smart account types](../../guides/smart-accounts/create-smart-account.md).
100100
- To upgrade an EOA to a smart account, see the [EIP-7702 quickstart](eip7702.md).

delegation-toolkit/guides/delegation/execute-on-users-behalf.md renamed to delegation-toolkit/guides/delegation/execute-on-smart-accounts-behalf.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
description: Use delegations to perform executions on a user's behalf.
2+
description: Use delegations to perform executions on a smart account's behalf.
33
sidebar_position: 1
4-
sidebar_label: Execute on a user's behalf
4+
sidebar_label: Execute on a smart account's behalf
55
---
66

77
import Tabs from "@theme/Tabs";
88
import TabItem from "@theme/TabItem";
99

10-
# Perform executions on a user's behalf
10+
# Perform executions on a smart account's behalf
1111

1212
[Delegation](../../concepts/delegation/index.md) is the ability for a [MetaMask smart account](../../concepts/smart-accounts.md) to grant permission to another account to perform executions on its behalf.
1313

@@ -54,8 +54,8 @@ const bundlerClient = createBundlerClient({
5454
Create an account to represent Alice, the delegator who will create a delegation.
5555
The delegator must be a MetaMask smart account; use the toolkit's [`toMetaMaskSmartAccount`](../../reference/api/smart-account.md#tometamasksmartaccount) method to create the delegator account.
5656

57-
This example configures a Hybrid smart account,
58-
which is a flexible smart account implementation that supports both an externally owned account (EOA) owner and any number of P256 (passkey) signers:
57+
A Hybrid smart account is a flexible smart account implementation that supports both an externally owned account (EOA) owner and any number of P256 (passkey) signers.
58+
This examples configures a [Hybrid smart account with an Account signatory](../smart-accounts/create-smart-account.md#create-a-hybrid-smart-account-with-an-account-signatory):
5959

6060
```typescript
6161
import { Implementation, toMetaMaskSmartAccount } from "@metamask/delegation-toolkit"
@@ -121,8 +121,7 @@ export const delegateWalletClient = createWalletClient({
121121
### 5. Create a delegation
122122

123123
Create a [root delegation](../../concepts/delegation/index.md#delegation-types) from Alice to Bob.
124-
A root delegation is a delegation that doesn't derive its authority from another delegation.
125-
Alice is delegating her own authority away, as opposed to *redelegating* permissions she received from a previous delegation.
124+
With a root delegation, Alice is delegating her own authority away, as opposed to *redelegating* permissions she received from a previous delegation.
126125

127126
Use the toolkit's [`createDelegation`](../../reference/api/delegation.md#createdelegation) method to create a root delegation.
128127
This example passes an empty `caveats` array, which means Bob can perform any action on Alice's behalf. We recommend [restricting the delegation](restrict-delegation.md) by adding caveat enforcers.
@@ -162,7 +161,9 @@ const signedDelegation = {
162161
### 7. Redeem the delegation
163162

164163
Bob can now redeem the delegation. The redeem transaction is sent to the `DelegationManager` contract, which validates the delegation and executes actions on Alice's behalf.
164+
165165
To prepare the calldata for the redeem transaction, use the [`redeemDelegations`](../../reference/api/delegation.md#redeemdelegations) method from `DelegationManager`.
166+
Since Bob is redeeming a single delegation chain, use the [`SINGLE_DEFAULT_MODE`](../../concepts/delegation/index.md#execution-modes) execution mode.
166167

167168
Bob can redeem the delegation by submitting a user operation if his account is a smart account, or a regular transaction if his account is an EOA:
168169

@@ -226,8 +227,3 @@ const transactionHash = await delegateWalletClient.sendTransaction({
226227

227228
</TabItem>
228229
</Tabs>
229-
230-
:::note
231-
`SINGLE_DEFAULT_MODE` is the default execution mode.
232-
Learn about the different [execution modes](../../concepts/delegation/index.md#execution-modes).
233-
:::

delegation-toolkit/guides/smart-accounts/create-smart-account.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ You can create a Hybrid smart account with the following types of signatories.
2323

2424
### Create a Hybrid smart account with an Account signatory
2525

26-
Use [`toMetaMaskSmartAccount`](../../reference/api/smart-account.md#tometamasksmartaccount) and Viem's [`privateKeyToAccount`](https://viem.sh/docs/accounts/local/privateKeyToAccount) to create a Hybrid smart account with a signatory from a private key:
26+
Use [`toMetaMaskSmartAccount`](../../reference/api/smart-account.md#tometamasksmartaccount), and Viem's [`privateKeyToAccount` and `generatePrivateKey`](https://viem.sh/docs/accounts/local/privateKeyToAccount), to create a Hybrid smart account with a signatory from a randomly generated private key:
2727

2828
<Tabs>
2929
<TabItem value="example.ts">
@@ -415,5 +415,5 @@ With a MetaMask smart account, you can perform the following functions:
415415

416416
- In conjunction with [Viem Account Abstraction clients](../configure.md), deploy the smart account
417417
and [send user operations](send-user-operation.md).
418-
- [Create delegations](../delegation/execute-on-users-behalf.md) that can be used to grant specific rights and permissions to other accounts.
418+
- [Create delegations](../delegation/execute-on-smart-accounts-behalf.md) that can be used to grant specific rights and permissions to other accounts.
419419
Smart accounts that create delegations are called *delegator accounts*.

vercel.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,15 +732,15 @@
732732
},
733733
{
734734
"source": "/delegation-toolkit/development/how-to/create-delegation/",
735-
"destination": "/delegation-toolkit/development/guides/delegation/execute-on-users-behalf/"
735+
"destination": "/delegation-toolkit/development/guides/delegation/execute-on-smart-accounts-behalf/"
736736
},
737737
{
738738
"source": "/delegation-toolkit/development/how-to/create-delegation/:path*/",
739739
"destination": "/delegation-toolkit/development/guides/delegation/:path*/"
740740
},
741741
{
742742
"source": "/delegation-toolkit/development/how-to/redeem-delegation/",
743-
"destination": "/delegation-toolkit/development/guides/delegation/execute-on-users-behalf/"
743+
"destination": "/delegation-toolkit/development/guides/delegation/execute-on-smart-accounts-behalf/"
744744
},
745745
{
746746
"source": "/delegation-toolkit/development/get-started/quickstart/",

0 commit comments

Comments
 (0)