Skip to content

Commit a41e53f

Browse files
Merge branch 'main' into fix-focus
2 parents b3b2bbc + e68e3c6 commit a41e53f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1701
-1223
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"singleQuote": true,
88
"tabWidth": 2,
99
"trailingComma": "es5",
10-
"proseWrap": "never",
10+
"proseWrap": "preserve",
1111
"printWidth": 100,
1212
"htmlWhitespaceSensitivity": "css",
1313
"vueIndentScriptAndStyle": true

delegation-toolkit/concepts/delegation.md

Lines changed: 0 additions & 140 deletions
This file was deleted.

delegation-toolkit/concepts/caveat-enforcers.md renamed to delegation-toolkit/concepts/delegation/caveat-enforcers.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
description: Learn about caveat enforcers and how they restrict delegations.
3-
sidebar_position: 4
3+
sidebar_position: 2
44
---
55

66
# Caveat enforcers
77

88
The MetaMask Delegation Toolkit provides *caveat enforcers*, which are smart contracts that implement rules and restrictions (*caveats*) on delegations.
9-
They serve as the underlying mechanism that enables conditional execution within the [Delegation Framework](delegation.md#delegation-framework).
9+
They serve as the underlying mechanism that enables conditional execution within the [Delegation Framework](index.md#delegation-framework).
1010

1111
A caveat enforcer acts as a gate that validates whether a delegation can be used for a particular execution. When a delegate attempts to execute an action on behalf of a delegator, each caveat enforcer specified in the delegation evaluates whether the execution meets its defined criteria.
1212

@@ -119,23 +119,23 @@ This "all-or-nothing" approach ensures that delegations only execute exactly as
119119

120120
## Caveat builder
121121

122-
While caveat enforcers operate at the smart contract level, most developers interact with them through the [`CaveatBuilder`](../how-to/create-delegation/restrict-delegation.md) interface in the MetaMask Delegation Toolkit.
122+
While caveat enforcers operate at the smart contract level, most developers interact with them through the [`CaveatBuilder`](../../guides/delegation/restrict-delegation.md) interface in the MetaMask Delegation Toolkit.
123123

124124
The `CaveatBuilder` provides a developer-friendly TypeScript API that:
125125

126126
- Abstracts away the complexity of correctly formatting and encoding caveat terms.
127127
- Provides type-checking and validation for caveat parameters.
128128
- Handles the creation of the `caveats` array needed when creating a delegation.
129129

130-
Each [caveat type](../reference/caveats.md) in the `CaveatBuilder`
130+
Each [caveat type](../../reference/caveats.md) in the `CaveatBuilder`
131131
corresponds to a specific caveat enforcer contract. For example, when you use:
132132

133133
```typescript
134134
caveatBuilder.addCaveat("allowedTargets", ["0xc11F3a8E5C7D16b75c9E2F60d26f5321C6Af5E92"]);
135135
```
136136

137137
The builder is creating a caveat that references the
138-
[`AllowedTargetsEnforcer`](../reference/caveats.md#allowedtargets) contract address and
138+
[`AllowedTargetsEnforcer`](../../reference/caveats.md#allowedtargets) contract address and
139139
properly encodes the provided addresses as terms for that enforcer.
140140

141141
## Caveat enforcer best practices
@@ -145,26 +145,26 @@ When designing delegations with caveats, consider these best practices:
145145
- **Combine caveat enforcers appropriately** - Use multiple caveat enforcers to create comprehensive restrictions.
146146

147147
- **Consider caveat enforcer order** - When using caveat enforcers that modify external contract states, the order matters.
148-
For example, using [`NativeTokenPaymentEnforcer`](../reference/caveats.md#nativetokenpayment) before
149-
[`NativeBalanceChangeEnforcer`](../reference/caveats.md#nativebalancechange) might cause validation failures.
148+
For example, using [`NativeTokenPaymentEnforcer`](../../reference/caveats.md#nativetokenpayment) before
149+
[`NativeBalanceChangeEnforcer`](../../reference/caveats.md#nativebalancechange) might cause validation failures.
150150

151151
- **Be careful with unbounded delegations** - Always include appropriate caveat enforcers to limit what a delegate can do.
152152

153153
## Available caveat enforcers
154154

155-
The Delegation Toolkit provides [many out-of-the-box caveat enforcers](../reference/caveats.md)
155+
The Delegation Toolkit provides [out-of-the-box caveat enforcers](../../reference/caveats.md)
156156
for common restriction patterns, including:
157157

158158
- Limiting target addresses and methods.
159159
- Setting time or block number constraints.
160160
- Restricting token transfers and approvals.
161161
- Limiting execution frequency.
162162

163-
For more complex scenarios, you can also [create custom caveat enforcers](../how-to/create-delegation/create-custom-caveat-enforcer.md) by implementing the `ICaveatEnforcer` interface.
163+
For other restriction patterns, you can also [create custom caveat enforcers](../../tutorials/create-custom-caveat-enforcer.md) by implementing the `ICaveatEnforcer` interface.
164164

165165
## Attenuating authority with redelegations
166166

167-
When [creating chains of delegations](../how-to/create-delegation/index.md#create-a-redelegation), it's important to understand how authority flows and can be restricted.
167+
When creating chains of delegations via [redelegations](index.md#delegation-types), it's important to understand how authority flows and can be restricted.
168168

169169
Caveats applied to a chain of delegations are *accumulative*—they stack on top of each other:
170170

0 commit comments

Comments
 (0)