Skip to content

Commit 586ba0e

Browse files
Update API references
* adds encode and decode delegation methods reference * expose llm context * minor fixes * update link * Apply suggestions from code review Co-authored-by: Alexandra Carrillo <[email protected]> --------- Co-authored-by: Alexandra Carrillo <[email protected]>
1 parent aa7f596 commit 586ba0e

File tree

3 files changed

+71
-4
lines changed

3 files changed

+71
-4
lines changed

gator-sidebar.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ const sidebar = {
3434
'get-started/use-scaffold-eth/advanced-permissions',
3535
],
3636
},
37+
{
38+
type: "link",
39+
label: "LLM context",
40+
href: "https://docs.metamask.io/llms-smart-accounts-kit-full.txt"
41+
},
3742
'get-started/supported-networks',
3843
],
3944
},

smart-accounts-kit/guides/advanced-permissions/execute-on-metamask-users-behalf.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ const sessionAccount = privateKeyToAccount("0x...");
9696

9797
### 4. Check the EOA account code
9898

99-
Advanced Permissions support the automatic upgrading of a MetaMask user's account to a [MetaMask smart account](../../concepts/smart-accounts.md),
100-
when using MetaMask Flask version 13.9.0 or later. For earlier versions, you must ensure that the
101-
user is upgraded to a smart account before requesting Advanced Permissions.
99+
With MetaMask Flask 13.9.0 or later, Advanced Permissions support automatically upgrading a user’s
100+
account to a [MetaMask smart account](../../concepts/smart-accounts.md). On earlier versions, upgrade
101+
the user to a smart account before requesting Advanced Permissions.
102102

103103
If the user has not yet been upgraded, you can handle the upgrade [programmatically](/wallet/how-to/send-transactions/send-batch-transactions/#about-atomic-batch-transactions) or ask the
104104
user to [switch to a smart account manually](https://support.metamask.io/configure/accounts/switch-to-or-revert-from-a-smart-account/#how-to-switch-to-a-metamask-smart-account).
@@ -140,7 +140,7 @@ if (code) {
140140

141141
### 5. Request Advanced Permissions
142142

143-
Request Advanced Permissions from the user using the Wallet Client's `requestExecutionPermissions` action.
143+
Request Advanced Permissions from the user with the Wallet Client's `requestExecutionPermissions` action.
144144
In this example, you'll request an
145145
[ERC-20 periodic permission](use-permissions/erc20-token.md#erc-20-periodic-permission).
146146

smart-accounts-kit/reference/delegation/index.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,24 @@ const execution = createExecution({
182182
});
183183
```
184184

185+
## `decodeDelegations`
186+
187+
Decodes an ABI-encoded hex string to an array of delegations.
188+
189+
### Parameters
190+
191+
| Name | Type | Required | Description |
192+
| ---- | ---- | -------- | ----------- |
193+
| `encoded` | `Hex` | Yes | The ABI encoded hex string to decode. |
194+
195+
### Example
196+
197+
```ts
198+
import { deocdeDelegation } from "@metamask/smart-accounts-kit/utils";
199+
200+
const delegations = decodeDelegations("0x7f0db33d..c06aeeac");
201+
```
202+
185203
## `deployDeleGatorEnvironment`
186204

187205
Deploys the Delegation Framework contracts to an EVM chain.
@@ -315,6 +333,50 @@ export const delegation = createDelegation({
315333
</TabItem>
316334
</Tabs>
317335

336+
## `encodeDelegations`
337+
338+
Encodes an array of delegations to an ABI-encoded hex string.
339+
340+
### Parameters
341+
342+
| Name | Type | Required | Description |
343+
| --- | --- | --- | --- |
344+
| `delegations` | `Delegation[]` | Yes | The delegation array to be encoded. |
345+
346+
### Example
347+
348+
<Tabs>
349+
<TabItem value="example.ts">
350+
351+
```ts
352+
import { enocdeDelegations } from "@metamask/smart-accounts-kit/utils";
353+
import { delegation } from "./delegation.ts";
354+
355+
const encodedDelegations = encodeDelegations([delegation]);
356+
```
357+
358+
</TabItem>
359+
<TabItem value="delegation.ts">
360+
361+
```ts
362+
import { createDelegation } from "@metamask/smart-accounts-kit";
363+
import { sepolia } from "viem/chains";
364+
import { parseEther } from "viem";
365+
366+
export const delegation = createDelegation({
367+
from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1",
368+
to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488",
369+
environment: getSmartAccountsEnvironment(sepolia.id);
370+
scope: {
371+
type: "nativeTokenTransferAmount",
372+
// 0.001 ETH in wei format.
373+
maxAmount: parseEther("0.001"),
374+
},
375+
});
376+
```
377+
378+
</TabItem>
379+
</Tabs>
318380

319381
## `getDelegationHashOffchain`
320382

0 commit comments

Comments
 (0)