-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
334 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,255 @@ | ||
--- | ||
outline: deep | ||
head: | ||
- - meta | ||
- property: og:title | ||
content: Migration Guide | ||
- - meta | ||
- name: description | ||
content: How to update from Entrypoint v0.6 to v0.7. | ||
- - meta | ||
- property: og:description | ||
content: How to update from Entrypoint v0.6 to v0.7. | ||
- - meta | ||
- name: twitter:title | ||
content: Migration Guide | ||
- - meta | ||
- name: twitter:description | ||
content: How to update from Entrypoint v0.6 to v0.7. | ||
--- | ||
|
||
# Entrypoint v0.7 Update Guide | ||
|
||
## Entrypoint v0.7: A Milestone in Account Abstraction | ||
|
||
Version 0.7, the latest advancement, brings significant updates and optimizations driven by community feedback and evolving needs: | ||
|
||
Optimized Gas Management: Making transactions more cost-effective. | ||
Advanced Security: Introducing stringent security measures for better account and transaction protection. | ||
Enhanced Developer Tools: Offering improved resources for creating AA-enabled dApps. | ||
With upgrade made for `aa-sdk` version `v3.8.4`, `aa-sdk` now supports both EntryPoint v0.6.0 and v.0.7.0 contract for different smart accounts. | ||
|
||
Below are the steps to update your project from using Entrypoint v0.6.0 to v0.7.0 of the `aa-sdk`. | ||
|
||
::: tip Note | ||
This migration guide is assuming you are currently using the `aa-sdk` version `^3.x.x` to version `^3.8.4`. If you are looking to upgrade from the older versions of `aa-sdk`, you can follow the [Migration Guide](./migrating-to-v3.md) for `aa-sdk` version `3.x.x`. | ||
::: | ||
|
||
Upgrading to the latest version `v3.8.4` of `aa-sdk` will **not** involve breaking changes if you continue to stay on using Entrypoint v0.6.0 for your smart accounts. If you are looking into update to using Entrypoint v0.7.0, it simply requires passing in the optional entrypoint version parameter as `0.7.0` to your `SmartContractAccounts`. Otherwise, the default Entrypoint version is `0.6.0` for the initial launch of Entrypoint v0.7 support in `aa-sdk` version `^3.x.x`. | ||
|
||
### Account Support | ||
|
||
Because [Entrypoint](https://eips.ethereum.org/EIPS/eip-4337#definitions) is a singleton contract, where there is only one implementation and one instance exists on each chain, you first need to make sure the smart account and the bundler you are using is updated with a certain Entrypoint version. | ||
|
||
From version `^3.8.4`, `aa-sdk` lets you easily configure which Entrypoint version compatible Smart Account to use. `aa-sdk` supports 4 types of accounts natively, and the below table details which EntryPoints each account is valid for. | ||
|
||
| Account | EntryPoint v0.7 | EntryPoint v0.6 | | ||
| :---------------------------- | :-------------- | :-------------- | | ||
| SimpleAccount | ✅ | ✅ | | ||
| LightAccount v1 (_< v.2.0.0_) | ❌ | ✅ | | ||
| LightAccount v2 (_>= v2.0.0_) | ✅ | ❌ | | ||
| MultiOwnerLightAccount | ✅ | ❌ | | ||
| MultiOwnerModularAccount | ❌ | ✅ | | ||
| MultisigModularAccount | ❌ | ✅ | | ||
|
||
### Account: [`ToSmartContractAccountParams`](/resources/types#ToSmartContractAccountParams)'s optional `entryPoint` parameter | ||
|
||
The only change that needs to be made to update to using Entrypoint v.7 is to specify the optional `entryPoint` parameter of the [`ToSmartContractAccountParams`](/resources/types#ToSmartContractAccountParams) used for the [`toSmartContractAccount`](/packages/aa-core/accounts/) function when instantiating a `SmartContractAccount`. Based on the `entryPoint` parameter, which is of type [`EntryPointDef`](/resources/types#EntryPointDef) of the specific `EntryPointVersion`, the output `SmartContractAccount` will be strongly-typed with the structure compatible to perform the desired `EntryPointVersion` user operations. Using `SimpleAccount` as an example, you will have to make the following changes: | ||
|
||
```ts | ||
import { createSimpleAccount } from "@alchemy/aa-core"; | ||
import { LocalAccountSigner, type Hex } from "@alchemy/aa-core"; | ||
import { sepolia } from "@alchemy/aa-core"; | ||
|
||
const chain = sepolia; | ||
|
||
const account = await createSimpleAccount({ | ||
transport: http("RPC_URL"), | ||
signer, | ||
chain, | ||
entryPoint: getEntryPoint(chain, { version: "0.7.0" }), // [!code ++] | ||
}); | ||
``` | ||
|
||
### Client: signature changes on methods | ||
|
||
To support [the various ways](/migration-guides/migrating-to-v3#account-connecting-to-a-smart-account) of connecting to a smart account, the signatures of the methods on `SmartAccountClient` have changed. Almost all methods now have an optional param for `account` and have been converted into single argument functions that take an object with the their properties instead. | ||
|
||
### Account: Connecting to a Smart Account | ||
|
||
In earlier versions, a provider could not be used with a smart account until it was connected to one using `.connect`. In version 3.x.x, | ||
you have the option of keeping the two disconnected and passing the account to the client methods directly. You also have the option to hoist the account | ||
so that you don't have to pass the account to every method. | ||
|
||
#### Option 1: Passing the Account to the Client Methods | ||
|
||
```ts | ||
import { createLightAccount } from "@alchemy/aa-accounts"; | ||
import { | ||
createBundlerClient, | ||
createSmartAccountClientFromExisting | ||
LocalAccountSigner, | ||
type Hex, | ||
} from "@alchemy/aa-core"; | ||
import { sepolia } from "@alchemy/aa-core"; | ||
import { custom, http } from "viem"; | ||
|
||
const chain = sepolia; | ||
|
||
const client = createBundlerClient({ | ||
chain, | ||
transport: http("JSON_RPC_URL"), | ||
}); | ||
|
||
// [!code focus:99] | ||
// createSmartAccountClientFromExisting is a helper method that allows you | ||
// to reuse a JSON RPC client to create a Smart Account client. | ||
const smartAccountClient = createSmartAccountClientFromExisting({ | ||
client, | ||
}); | ||
|
||
const account = await createLightAccount({ | ||
signer, | ||
chain, | ||
transport: custom(client), | ||
}); | ||
|
||
const { hash } = await smartAccountClient.sendUserOperation({ | ||
uo: { | ||
target: "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef", | ||
data: "0x", | ||
value: 10n, | ||
}, | ||
account, // [!code ++] | ||
}); | ||
``` | ||
|
||
#### Option 2: Hoisting the Account | ||
|
||
Hoisting the account is similar to using `.connect` in previous versions. You simply create your client with an account passed in to it. | ||
|
||
```ts | ||
import { createLightAccount } from "@alchemy/aa-accounts"; | ||
import { | ||
createBundlerClient, | ||
createSmartAccountClientFromExisting | ||
LocalAccountSigner, | ||
type Hex, | ||
} from "@alchemy/aa-core"; | ||
import { sepolia } from "@alchemy/aa-core"; | ||
import { http, custom } from "viem"; | ||
|
||
const chain = sepolia; | ||
|
||
const client = createBundlerClient({ | ||
chain, | ||
transport: http("JSON_RPC_URL"), | ||
}); | ||
|
||
// [!code focus:99] | ||
const account = await createLightAccount({ | ||
signer, | ||
transport: custom(client), | ||
chain, | ||
}); | ||
|
||
const smartAccountClient = createSmartAccountClientFromExisting({ | ||
account, // [!code ++] | ||
client, | ||
}); | ||
|
||
const { hash } = await smartAccountClient.sendUserOperation({ | ||
uo: { | ||
target: "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef", | ||
data: "0x", | ||
value: 10n, | ||
}, | ||
account, // [!code --] | ||
}); | ||
``` | ||
|
||
### Account: Custom Accounts | ||
|
||
In prior versions, using your own smart contract account implementations required that you extend `BaseSmartContractAccount`. In version 3.x.x, you can use the | ||
`toSmartContractAccount` method which will allow you to use any account with `SmartAccountClient`. `toSmartContractAccount` has the form of: | ||
|
||
```ts | ||
type toSmartContractAccount = < | ||
Name extends string = string, | ||
TTransport extends Transport = Transport | ||
>({ | ||
transport, | ||
chain, | ||
source, | ||
entryPointAddress, | ||
accountAddress, | ||
getAccountInitCode, | ||
signMessage, | ||
signTypedData, | ||
encodeBatchExecute, | ||
encodeExecute, | ||
getDummySignature, | ||
signUserOperationHash, | ||
encodeUpgradeToAndCall, | ||
}: ToSmartContractAccountParams<Name, TTransport>) => Promise< | ||
SmartContractAccount<Name> | ||
>; | ||
``` | ||
|
||
### Account: SimpleAccount and NaniAccount initialization params | ||
|
||
`chain` and `transport` have been added to the constructor and `rpcClient` has been removed. | ||
|
||
### Account: SimpleAccount and LightAccount intialization params | ||
|
||
`index` is now called `salt` | ||
|
||
### Signer: `signTypedData` signature change | ||
|
||
The `signTypedData` method found on `SmartAccountSigner` has been updated to match the signature found on `SmartContractAccount` and viem's `Account`. | ||
|
||
```ts | ||
signTypedData: (params: SignTypedDataParams) => Promise<Hex>; // [!code --] | ||
|
||
signTypedData: < | ||
const TTypedData extends TypedData | { [key: string]: unknown }, | ||
TPrimaryType extends string = string | ||
>( | ||
params: TypedDataDefinition<TTypedData, TPrimaryType> | ||
) => Promise<Hex>; | ||
``` | ||
|
||
### Ethers: Removed methods | ||
|
||
The `with*` methods have been removed from the Provider and Signer classes. | ||
The `connect` methods has been removed in favor of immutable properties on the Provider and Signer classes. See updated AccountSigner constructor below. | ||
|
||
### Ethers: `getPublicErc4337Client` → `getBundlerClient` | ||
|
||
The `getPublicErc4337Client` method has been renamed to `getBundlerClient` to match the naming found in `aa-core`. | ||
|
||
### Ethers: Updated Signer Adapter constructor | ||
|
||
The `AccountSigner` now takes in a `SmartContractAccount` as a param in its constructor. | ||
|
||
### Core: Transition from ~~`Percent`~~ to `Multiplier` api and types | ||
|
||
The `Percent` type and `PercentSchema` have been removed in favor of the `Multiplier` type and `MultiplierSchema`. | ||
|
||
Going forward when using the feeOptions, you can specify the `Multiplier` type instead of a `Percent`. The `Multiplier` type is a number that represents direct multipliaction of the estimation. For example, `0.1` is 10% of the estimated value and `1` is 100% of the estimated value. | ||
|
||
```ts | ||
createModularAccountAlchemyClient({ | ||
... | ||
opts: { | ||
... | ||
// The maxFeePerGas and maxPriorityFeePerGas estimated values will now be multipled by 1.5 | ||
feeOptions: { | ||
// This was previously { percent: 50n } | ||
maxFeePerGas: { multiplier: 1.5 }, | ||
// This was previously { percent: 25n } | ||
maxPriorityFeePerGas: { multiplier: 1.25 }, | ||
}, | ||
}, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.