diff --git a/README.md b/README.md index 5372b410df5..7242a833635 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,6 @@ Build the documentation site locally using the following steps. npm start ``` - Once the server starts, you can view the documentation at `http://localhost:3000`. + Once the server starts, you can view the documentation at `http://localhost:3003`. For more information on contributing to the documentation, see the [full contribution guidelines](CONTRIBUTING.md). diff --git a/gator_versioned_docs/version-0.1.0/guides/advanced-permissions/execute-on-metamask-users-behalf.md b/gator_versioned_docs/version-0.1.0/guides/advanced-permissions/execute-on-metamask-users-behalf.md index 08674e6f206..3f3447c81e8 100644 --- a/gator_versioned_docs/version-0.1.0/guides/advanced-permissions/execute-on-metamask-users-behalf.md +++ b/gator_versioned_docs/version-0.1.0/guides/advanced-permissions/execute-on-metamask-users-behalf.md @@ -96,9 +96,9 @@ const sessionAccount = privateKeyToAccount("0x..."); ### 4. Check the EOA account code -Advanced Permissions support the automatic upgrading of a MetaMask user's account to a [MetaMask smart account](../../concepts/smart-accounts.md), -when using MetaMask Flask version 13.9.0 or later. For earlier versions, you must ensure that the -user is upgraded to a smart account before requesting Advanced Permissions. +With MetaMask Flask 13.9.0 or later, Advanced Permissions support automatically upgrading a user’s +account to a [MetaMask smart account](../../concepts/smart-accounts.md). On earlier versions, upgrade +the user to a smart account before requesting Advanced Permissions. 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 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) { ### 5. Request Advanced Permissions -Request Advanced Permissions from the user using the Wallet Client's `requestExecutionPermissions` action. +Request Advanced Permissions from the user with the Wallet Client's `requestExecutionPermissions` action. In this example, you'll request an [ERC-20 periodic permission](use-permissions/erc20-token.md#erc-20-periodic-permission). diff --git a/gator_versioned_docs/version-0.1.0/guides/configure-toolkit.md b/gator_versioned_docs/version-0.1.0/guides/configure-toolkit.md index 5e75a8c9136..698fc4d629f 100644 --- a/gator_versioned_docs/version-0.1.0/guides/configure-toolkit.md +++ b/gator_versioned_docs/version-0.1.0/guides/configure-toolkit.md @@ -1,7 +1,7 @@ --- description: Learn how to configure the bundler client, paymaster client, and toolkit environment. sidebar_label: Configure the toolkit -keywords: [configure, smart accounts kit, bundler, paymaster, delegator environment] +keywords: [configure, smart accounts kit, bundler, paymaster, smart accounts environment] --- import Tabs from "@theme/Tabs"; @@ -133,7 +133,7 @@ const environment: SmartAccountsEnvironment = getSmartAccountsEnvironment(111551 ### Deploy a custom environment -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. +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. 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) 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. ```typescript import { walletClient, publicClient } from "./config.ts"; import { sepolia as chain } from "viem/chains"; -import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils"; +import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils"; -const environment = await deployDeleGatorEnvironment( +const environment = await deploySmartAccountsEnvironment( walletClient, publicClient, chain @@ -182,16 +182,16 @@ export const publicClient = createPublicClient({ -You can also override specific contracts when calling `deployDelegatorEnvironment`. +You can also override specific contracts when calling `deploySmartAccountsEnvironment`. For example, if you've already deployed the `EntryPoint` contract on the target chain, you can pass the contract address to the function. ```typescript // The config.ts is the same as in the previous example. import { walletClient, publicClient } from "./config.ts"; import { sepolia as chain } from "viem/chains"; -import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils"; +import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils"; -const environment = await deployDeleGatorEnvironment( +const environment = await deploySmartAccountsEnvironment( walletClient, publicClient, chain, @@ -217,10 +217,10 @@ import { sepolia as chain } from "viem/chains"; import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; import { overrideDeployedEnvironment, - deployDeleGatorEnvironment + deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; -const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment( +const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment( walletClient, publicClient, chain @@ -233,7 +233,7 @@ overrideDeployedEnvironment( ); ``` -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. +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. ```typescript // remove-start @@ -244,11 +244,11 @@ import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; import { overrideDeployedEnvironment, // remove-next-line -- deployDeleGatorEnvironment +- deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; // remove-start -- const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment( +- const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment( - walletClient, - publicClient, - chain diff --git a/gator_versioned_docs/version-0.1.0/reference/delegation/index.md b/gator_versioned_docs/version-0.1.0/reference/delegation/index.md index 792dc43191c..a786619396b 100644 --- a/gator_versioned_docs/version-0.1.0/reference/delegation/index.md +++ b/gator_versioned_docs/version-0.1.0/reference/delegation/index.md @@ -109,7 +109,7 @@ const delegation = createDelegation({ // Address to which the delegation is being granted to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", // Alternatively you can use environment property of MetaMask smart account. - environment: getSmartAccountsEnvironment(sepolia.id); + environment: getSmartAccountsEnvironment(sepolia.id), scope: { type: "nativeTokenTransferAmount", // 0.001 ETH in wei format. @@ -145,7 +145,7 @@ const delegation = createOpenDelegation({ // Address that is granting the delegation from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", // Alternatively you can use environment property of MetaMask smart account. - environment: getSmartAccountsEnvironment(sepolia.id); + environment: getSmartAccountsEnvironment(sepolia.id), scope: { type: "nativeTokenTransferAmount", // 0.001 ETH in wei format. @@ -182,7 +182,25 @@ const execution = createExecution({ }); ``` -## `deployDeleGatorEnvironment` +## `decodeDelegations` + +Decodes an ABI-encoded hex string to an array of delegations. + +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| `encoded` | `Hex` | Yes | The ABI encoded hex string to decode. | + +### Example + +```ts +import { decodeDelegations } from "@metamask/smart-accounts-kit/utils"; + +const delegations = decodeDelegations("0x7f0db33d..c06aeeac"); +``` + +## `deploySmartAccountsEnvironment` Deploys the Delegation Framework contracts to an EVM chain. @@ -201,11 +219,11 @@ Deploys the Delegation Framework contracts to an EVM chain. ```ts -import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils"; +import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils"; import { walletClient, publicClient } from "./config.ts"; import { sepolia as chain } from "viem/chains"; -const environment = await deployDeleGatorEnvironment( +const environment = await deploySmartAccountsEnvironment( walletClient, publicClient, chain @@ -250,10 +268,10 @@ import { sepolia as chain } from "viem/chains"; import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; import { overrideDeployedEnvironment, - deployDeleGatorEnvironment, + deploySmartAccountsEnvironment, } from "@metamask/smart-accounts-kit/utils"; -const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment( +const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment( walletClient, publicClient, chain @@ -303,7 +321,7 @@ import { parseEther } from "viem"; export const delegation = createDelegation({ from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", - environment: getSmartAccountsEnvironment(sepolia.id); + environment: getSmartAccountsEnvironment(sepolia.id), scope: { type: "nativeTokenTransferAmount", // 0.001 ETH in wei format. @@ -315,6 +333,50 @@ export const delegation = createDelegation({ +## `encodeDelegations` + +Encodes an array of delegations to an ABI-encoded hex string. + +### Parameters + +| Name | Type | Required | Description | +| --- | --- | --- | --- | +| `delegations` | `Delegation[]` | Yes | The delegation array to be encoded. | + +### Example + + + + +```ts +import { encodeDelegations } from "@metamask/smart-accounts-kit/utils"; +import { delegation } from "./delegation.ts"; + +const encodedDelegations = encodeDelegations([delegation]); +``` + + + + +```ts +import { createDelegation } from "@metamask/smart-accounts-kit"; +import { sepolia } from "viem/chains"; +import { parseEther } from "viem"; + +export const delegation = createDelegation({ + from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", + to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", + environment: getSmartAccountsEnvironment(sepolia.id), + scope: { + type: "nativeTokenTransferAmount", + // 0.001 ETH in wei format. + maxAmount: parseEther("0.001"), + }, +}); +``` + + + ## `getDelegationHashOffchain` diff --git a/gator_versioned_sidebars/version-0.1.0-sidebars.json b/gator_versioned_sidebars/version-0.1.0-sidebars.json index 0e0cc3faece..3a9f5dd2238 100644 --- a/gator_versioned_sidebars/version-0.1.0-sidebars.json +++ b/gator_versioned_sidebars/version-0.1.0-sidebars.json @@ -30,6 +30,11 @@ "get-started/use-scaffold-eth/advanced-permissions" ] }, + { + "type": "link", + "label": "LLM context", + "href": "https://docs.metamask.io/llms-smart-accounts-kit-full.txt" + }, "get-started/supported-networks" ] }, diff --git a/smart-accounts-kit/guides/configure-toolkit.md b/smart-accounts-kit/guides/configure-toolkit.md index 5e75a8c9136..698fc4d629f 100644 --- a/smart-accounts-kit/guides/configure-toolkit.md +++ b/smart-accounts-kit/guides/configure-toolkit.md @@ -1,7 +1,7 @@ --- description: Learn how to configure the bundler client, paymaster client, and toolkit environment. sidebar_label: Configure the toolkit -keywords: [configure, smart accounts kit, bundler, paymaster, delegator environment] +keywords: [configure, smart accounts kit, bundler, paymaster, smart accounts environment] --- import Tabs from "@theme/Tabs"; @@ -133,7 +133,7 @@ const environment: SmartAccountsEnvironment = getSmartAccountsEnvironment(111551 ### Deploy a custom environment -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. +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. 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) 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. ```typescript import { walletClient, publicClient } from "./config.ts"; import { sepolia as chain } from "viem/chains"; -import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils"; +import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils"; -const environment = await deployDeleGatorEnvironment( +const environment = await deploySmartAccountsEnvironment( walletClient, publicClient, chain @@ -182,16 +182,16 @@ export const publicClient = createPublicClient({ -You can also override specific contracts when calling `deployDelegatorEnvironment`. +You can also override specific contracts when calling `deploySmartAccountsEnvironment`. For example, if you've already deployed the `EntryPoint` contract on the target chain, you can pass the contract address to the function. ```typescript // The config.ts is the same as in the previous example. import { walletClient, publicClient } from "./config.ts"; import { sepolia as chain } from "viem/chains"; -import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils"; +import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils"; -const environment = await deployDeleGatorEnvironment( +const environment = await deploySmartAccountsEnvironment( walletClient, publicClient, chain, @@ -217,10 +217,10 @@ import { sepolia as chain } from "viem/chains"; import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; import { overrideDeployedEnvironment, - deployDeleGatorEnvironment + deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; -const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment( +const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment( walletClient, publicClient, chain @@ -233,7 +233,7 @@ overrideDeployedEnvironment( ); ``` -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. +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. ```typescript // remove-start @@ -244,11 +244,11 @@ import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; import { overrideDeployedEnvironment, // remove-next-line -- deployDeleGatorEnvironment +- deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; // remove-start -- const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment( +- const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment( - walletClient, - publicClient, - chain diff --git a/smart-accounts-kit/reference/delegation/index.md b/smart-accounts-kit/reference/delegation/index.md index fa3bff8c5d7..a786619396b 100644 --- a/smart-accounts-kit/reference/delegation/index.md +++ b/smart-accounts-kit/reference/delegation/index.md @@ -109,7 +109,7 @@ const delegation = createDelegation({ // Address to which the delegation is being granted to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", // Alternatively you can use environment property of MetaMask smart account. - environment: getSmartAccountsEnvironment(sepolia.id); + environment: getSmartAccountsEnvironment(sepolia.id), scope: { type: "nativeTokenTransferAmount", // 0.001 ETH in wei format. @@ -145,7 +145,7 @@ const delegation = createOpenDelegation({ // Address that is granting the delegation from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", // Alternatively you can use environment property of MetaMask smart account. - environment: getSmartAccountsEnvironment(sepolia.id); + environment: getSmartAccountsEnvironment(sepolia.id), scope: { type: "nativeTokenTransferAmount", // 0.001 ETH in wei format. @@ -195,12 +195,12 @@ Decodes an ABI-encoded hex string to an array of delegations. ### Example ```ts -import { deocdeDelegation } from "@metamask/smart-accounts-kit/utils"; +import { decodeDelegations } from "@metamask/smart-accounts-kit/utils"; const delegations = decodeDelegations("0x7f0db33d..c06aeeac"); ``` -## `deployDeleGatorEnvironment` +## `deploySmartAccountsEnvironment` Deploys the Delegation Framework contracts to an EVM chain. @@ -219,11 +219,11 @@ Deploys the Delegation Framework contracts to an EVM chain. ```ts -import { deployDeleGatorEnvironment } from "@metamask/smart-accounts-kit/utils"; +import { deploySmartAccountsEnvironment } from "@metamask/smart-accounts-kit/utils"; import { walletClient, publicClient } from "./config.ts"; import { sepolia as chain } from "viem/chains"; -const environment = await deployDeleGatorEnvironment( +const environment = await deploySmartAccountsEnvironment( walletClient, publicClient, chain @@ -268,10 +268,10 @@ import { sepolia as chain } from "viem/chains"; import { SmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; import { overrideDeployedEnvironment, - deployDeleGatorEnvironment, + deploySmartAccountsEnvironment, } from "@metamask/smart-accounts-kit/utils"; -const environment: SmartAccountsEnvironment = await deployDeleGatorEnvironment( +const environment: SmartAccountsEnvironment = await deploySmartAccountsEnvironment( walletClient, publicClient, chain @@ -321,7 +321,7 @@ import { parseEther } from "viem"; export const delegation = createDelegation({ from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", - environment: getSmartAccountsEnvironment(sepolia.id); + environment: getSmartAccountsEnvironment(sepolia.id), scope: { type: "nativeTokenTransferAmount", // 0.001 ETH in wei format. @@ -349,7 +349,7 @@ Encodes an array of delegations to an ABI-encoded hex string. ```ts -import { enocdeDelegations } from "@metamask/smart-accounts-kit/utils"; +import { encodeDelegations } from "@metamask/smart-accounts-kit/utils"; import { delegation } from "./delegation.ts"; const encodedDelegations = encodeDelegations([delegation]); @@ -366,7 +366,7 @@ import { parseEther } from "viem"; export const delegation = createDelegation({ from: "0x7E48cA6b7fe6F3d57fdd0448B03b839958416fC1", to: "0x2B2dBd1D5fbeB77C4613B66e9F35dBfE12cB0488", - environment: getSmartAccountsEnvironment(sepolia.id); + environment: getSmartAccountsEnvironment(sepolia.id), scope: { type: "nativeTokenTransferAmount", // 0.001 ETH in wei format.