Skip to content

Commit 1b50dfa

Browse files
Smart Accounts Kit hot fixes
* hotfixes * update sidebar * fix typo issues * migrate utility function
1 parent 53d6ce2 commit 1b50dfa

File tree

7 files changed

+115
-48
lines changed

7 files changed

+115
-48
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ Build the documentation site locally using the following steps.
4343
npm start
4444
```
4545

46-
Once the server starts, you can view the documentation at `http://localhost:3000`.
46+
Once the server starts, you can view the documentation at `http://localhost:3003`.
4747

4848
For more information on contributing to the documentation, see the [full contribution guidelines](CONTRIBUTING.md).

gator_versioned_docs/version-0.1.0/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

gator_versioned_docs/version-0.1.0/guides/configure-toolkit.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Learn how to configure the bundler client, paymaster client, and toolkit environment.
33
sidebar_label: Configure the toolkit
4-
keywords: [configure, smart accounts kit, bundler, paymaster, delegator environment]
4+
keywords: [configure, smart accounts kit, bundler, paymaster, smart accounts environment]
55
---
66

77
import Tabs from "@theme/Tabs";
@@ -133,7 +133,7 @@ const environment: SmartAccountsEnvironment = getSmartAccountsEnvironment(111551
133133

134134
### Deploy a custom environment
135135

136-
You can deploy the contracts using any method, but the toolkit provides a convenient [`deployDelegatorEnvironment`](../reference/delegation/index.md#deploydelegatorenvironment) function. This function simplifies deploying the Delegation Framework contracts to your desired EVM chain.
136+
You can deploy the contracts using any method, but the toolkit provides a convenient [`deploySmartAccountsEnvironment`](../reference/delegation/index.md#deploysmartaccountsenvironment) function. This function simplifies deploying the Delegation Framework contracts to your desired EVM chain.
137137

138138
This function requires a Viem [Public Client](https://viem.sh/docs/clients/public), [Wallet Client](https://viem.sh/docs/clients/wallet), and [Chain](https://viem.sh/docs/glossary/types#chain)
139139
to deploy the contracts and resolve the `SmartAccountsEnvironment`.
@@ -146,9 +146,9 @@ Your wallet must have a sufficient native token balance to deploy the contracts.
146146
```typescript
147147
import { walletClient, publicClient } from "./config.ts";
148148
import { sepolia as chain } from "viem/chains";
149-
import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils";
149+
import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils";
150150

151-
const environment = await deployDeleGatorEnvironment(
151+
const environment = await deploySmartAccountsEnvironment(
152152
walletClient,
153153
publicClient,
154154
chain
@@ -182,16 +182,16 @@ export const publicClient = createPublicClient({
182182
</TabItem>
183183
</Tabs>
184184

185-
You can also override specific contracts when calling `deployDelegatorEnvironment`.
185+
You can also override specific contracts when calling `deploySmartAccountsEnvironment`.
186186
For example, if you've already deployed the `EntryPoint` contract on the target chain, you can pass the contract address to the function.
187187

188188
```typescript
189189
// The config.ts is the same as in the previous example.
190190
import { walletClient, publicClient } from "./config.ts";
191191
import { sepolia as chain } from "viem/chains";
192-
import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils";
192+
import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils";
193193

194-
const environment = await deployDeleGatorEnvironment(
194+
const environment = await deploySmartAccountsEnvironment(
195195
walletClient,
196196
publicClient,
197197
chain,
@@ -217,10 +217,10 @@ import { sepolia as chain } from "viem/chains";
217217
import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit";
218218
import {
219219
overrideDeployedEnvironment,
220-
deployDeleGatorEnvironment
220+
deploySmartAccountsEnvironment
221221
} from "@metamask/smart-accounts-kit";
222222

223-
const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment(
223+
const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment(
224224
walletClient,
225225
publicClient,
226226
chain
@@ -233,7 +233,7 @@ overrideDeployedEnvironment(
233233
);
234234
```
235235

236-
If you've already deployed the contracts using a different method, you can create a `DelegatorEnvironment` instance with the required contract addresses, and pass it to the function.
236+
If you've already deployed the contracts using a different method, you can create a `SmartAccountsEnvironment` instance with the required contract addresses, and pass it to the function.
237237

238238
```typescript
239239
// remove-start
@@ -244,11 +244,11 @@ import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit";
244244
import {
245245
overrideDeployedEnvironment,
246246
// remove-next-line
247-
- deployDeleGatorEnvironment
247+
- deploySmartAccountsEnvironment
248248
} from "@metamask/smart-accounts-kit";
249249

250250
// remove-start
251-
- const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment(
251+
- const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment(
252252
- walletClient,
253253
- publicClient,
254254
- chain

gator_versioned_docs/version-0.1.0/reference/delegation/index.md

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const delegation = createDelegation({
109109
// Address to which the delegation is being granted
110110
to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488",
111111
// Alternatively you can use environment property of MetaMask smart account.
112-
environment: getSmartAccountsEnvironment(sepolia.id);
112+
environment: getSmartAccountsEnvironment(sepolia.id),
113113
scope: {
114114
type: "nativeTokenTransferAmount",
115115
// 0.001 ETH in wei format.
@@ -145,7 +145,7 @@ const delegation = createOpenDelegation({
145145
// Address that is granting the delegation
146146
from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1",
147147
// Alternatively you can use environment property of MetaMask smart account.
148-
environment: getSmartAccountsEnvironment(sepolia.id);
148+
environment: getSmartAccountsEnvironment(sepolia.id),
149149
scope: {
150150
type: "nativeTokenTransferAmount",
151151
// 0.001 ETH in wei format.
@@ -182,7 +182,25 @@ const execution = createExecution({
182182
});
183183
```
184184

185-
## `deployDeleGatorEnvironment`
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 { decodeDelegations } from "@metamask/smart-accounts-kit/utils";
199+
200+
const delegations = decodeDelegations("0x7f0db33d..c06aeeac");
201+
```
202+
203+
## `deploySmartAccountsEnvironment`
186204

187205
Deploys the Delegation Framework contracts to an EVM chain.
188206

@@ -201,11 +219,11 @@ Deploys the Delegation Framework contracts to an EVM chain.
201219
<TabItem value="example.ts">
202220

203221
```ts
204-
import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils";
222+
import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils";
205223
import { walletClient, publicClient } from "./config.ts";
206224
import { sepolia as chain } from "viem/chains";
207225

208-
const environment = await deployDeleGatorEnvironment(
226+
const environment = await deploySmartAccountsEnvironment(
209227
walletClient,
210228
publicClient,
211229
chain
@@ -250,10 +268,10 @@ import { sepolia as chain } from "viem/chains";
250268
import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit";
251269
import {
252270
overrideDeployedEnvironment,
253-
deployDeleGatorEnvironment,
271+
deploySmartAccountsEnvironment,
254272
} from "@metamask/smart-accounts-kit/utils";
255273

256-
const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment(
274+
const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment(
257275
walletClient,
258276
publicClient,
259277
chain
@@ -303,7 +321,7 @@ import { parseEther } from "viem";
303321
export const delegation = createDelegation({
304322
from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1",
305323
to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488",
306-
environment: getSmartAccountsEnvironment(sepolia.id);
324+
environment: getSmartAccountsEnvironment(sepolia.id),
307325
scope: {
308326
type: "nativeTokenTransferAmount",
309327
// 0.001 ETH in wei format.
@@ -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 { encodeDelegations } 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

gator_versioned_sidebars/version-0.1.0-sidebars.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
"get-started/use-scaffold-eth/advanced-permissions"
3131
]
3232
},
33+
{
34+
"type": "link",
35+
"label": "LLM context",
36+
"href": "https://docs.metamask.io/llms-smart-accounts-kit-full.txt"
37+
},
3338
"get-started/supported-networks"
3439
]
3540
},

smart-accounts-kit/guides/configure-toolkit.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Learn how to configure the bundler client, paymaster client, and toolkit environment.
33
sidebar_label: Configure the toolkit
4-
keywords: [configure, smart accounts kit, bundler, paymaster, delegator environment]
4+
keywords: [configure, smart accounts kit, bundler, paymaster, smart accounts environment]
55
---
66

77
import Tabs from "@theme/Tabs";
@@ -133,7 +133,7 @@ const environment: SmartAccountsEnvironment = getSmartAccountsEnvironment(111551
133133

134134
### Deploy a custom environment
135135

136-
You can deploy the contracts using any method, but the toolkit provides a convenient [`deployDelegatorEnvironment`](../reference/delegation/index.md#deploydelegatorenvironment) function. This function simplifies deploying the Delegation Framework contracts to your desired EVM chain.
136+
You can deploy the contracts using any method, but the toolkit provides a convenient [`deploySmartAccountsEnvironment`](../reference/delegation/index.md#deploysmartaccountsenvironment) function. This function simplifies deploying the Delegation Framework contracts to your desired EVM chain.
137137

138138
This function requires a Viem [Public Client](https://viem.sh/docs/clients/public), [Wallet Client](https://viem.sh/docs/clients/wallet), and [Chain](https://viem.sh/docs/glossary/types#chain)
139139
to deploy the contracts and resolve the `SmartAccountsEnvironment`.
@@ -146,9 +146,9 @@ Your wallet must have a sufficient native token balance to deploy the contracts.
146146
```typescript
147147
import { walletClient, publicClient } from "./config.ts";
148148
import { sepolia as chain } from "viem/chains";
149-
import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils";
149+
import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils";
150150

151-
const environment = await deployDeleGatorEnvironment(
151+
const environment = await deploySmartAccountsEnvironment(
152152
walletClient,
153153
publicClient,
154154
chain
@@ -182,16 +182,16 @@ export const publicClient = createPublicClient({
182182
</TabItem>
183183
</Tabs>
184184

185-
You can also override specific contracts when calling `deployDelegatorEnvironment`.
185+
You can also override specific contracts when calling `deploySmartAccountsEnvironment`.
186186
For example, if you've already deployed the `EntryPoint` contract on the target chain, you can pass the contract address to the function.
187187

188188
```typescript
189189
// The config.ts is the same as in the previous example.
190190
import { walletClient, publicClient } from "./config.ts";
191191
import { sepolia as chain } from "viem/chains";
192-
import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils";
192+
import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils";
193193

194-
const environment = await deployDeleGatorEnvironment(
194+
const environment = await deploySmartAccountsEnvironment(
195195
walletClient,
196196
publicClient,
197197
chain,
@@ -217,10 +217,10 @@ import { sepolia as chain } from "viem/chains";
217217
import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit";
218218
import {
219219
overrideDeployedEnvironment,
220-
deployDeleGatorEnvironment
220+
deploySmartAccountsEnvironment
221221
} from "@metamask/smart-accounts-kit";
222222

223-
const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment(
223+
const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment(
224224
walletClient,
225225
publicClient,
226226
chain
@@ -233,7 +233,7 @@ overrideDeployedEnvironment(
233233
);
234234
```
235235

236-
If you've already deployed the contracts using a different method, you can create a `DelegatorEnvironment` instance with the required contract addresses, and pass it to the function.
236+
If you've already deployed the contracts using a different method, you can create a `SmartAccountsEnvironment` instance with the required contract addresses, and pass it to the function.
237237

238238
```typescript
239239
// remove-start
@@ -244,11 +244,11 @@ import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit";
244244
import {
245245
overrideDeployedEnvironment,
246246
// remove-next-line
247-
- deployDeleGatorEnvironment
247+
- deploySmartAccountsEnvironment
248248
} from "@metamask/smart-accounts-kit";
249249

250250
// remove-start
251-
- const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment(
251+
- const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment(
252252
- walletClient,
253253
- publicClient,
254254
- chain

0 commit comments

Comments
 (0)