Skip to content

Commit

Permalink
docs: add createClientDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
moldy530 committed Jan 31, 2024
1 parent 9b8c661 commit 806d207
Show file tree
Hide file tree
Showing 50 changed files with 200 additions and 862 deletions.
2 changes: 1 addition & 1 deletion packages/accounts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ If you are looking to add a new account type, please follow the following struct
export const MyContractAbi = [] as const; // the as const is important so we can get correct typing from viem
```

4. If you need to extend the [`SmartAccountProvider`](https://accountkit.alchemy.com/packages/aa-core/provider/introduction.html) class, add a file called `provider.ts` and add your implementation for `SmartAccountProvider`.
4. If you need to extend the [`SmartAccountProvider`](https://accountkit.alchemy.com/packages/aa-core/smart-account-client/introduction.html) class, add a file called `provider.ts` and add your implementation for `SmartAccountProvider`.

- Ideally, your `Account` impl should _just_ work with the base provider provided by `aa-core`.
- If not, consider generalizing the use case and updating SmartAccountProvider
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/client/smartAccountClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ export function createSmartAccountClientFromExisting<
>(
config: Omit<
SmartAccountClientConfig<Transport, TChain, TAccount>,
"transport"
"transport" | "chain"
> & { client: TClient }
): SmartAccountClient<CustomTransport, TChain, TAccount, TActions, TRpcSchema>;

export function createSmartAccountClientFromExisting(
config: Omit<SmartAccountClientConfig, "transport"> & {
config: Omit<SmartAccountClientConfig, "transport" | "chain"> & {
client: BundlerClient;
}
): SmartAccountClient {
Expand Down
59 changes: 8 additions & 51 deletions site/.vitepress/sidebar/packages/aa-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ export const aaCoreSidebar: DefaultTheme.SidebarItem = {
link: "/",
},
{
text: "Provider",
text: "Smart Account Client",
base: "/packages/aa-core/smart-account-client",
link: "/index",
},
{
text: "Smart Account Actions",
collapsed: true,
base: "/packages/aa-core/provider",
base: "/packages/aa-core/smart-account-client/actions",
items: [
{
text: "Introduction",
link: "/introduction",
},
{
text: "constructor",
link: "/constructor",
},
{
text: "sendUserOperation",
link: "/sendUserOperation",
Expand Down Expand Up @@ -86,49 +83,9 @@ export const aaCoreSidebar: DefaultTheme.SidebarItem = {
text: "getAddress",
link: "/getAddress",
},
{
text: "getEntryPointAddress",
link: "/getEntryPointAddress",
},
{
text: "isConnected",
link: "/isConnected",
},
{
text: "withPaymasterMiddleware",
link: "/withPaymasterMiddleware",
},
{
text: "withGasEstimator",
link: "/withGasEstimator",
},
{
text: "withFeeDataGetter",
link: "/withFeeDataGetter",
},
{
text: "withCustomMiddleware",
link: "/withCustomMiddleware",
},
{
text: "withUOSimulationMiddleware",
link: "/withUOSimulationMiddleware",
},
{
text: "connect",
link: "/connect",
},
{
text: "disconnect",
link: "/disconnect",
},
{
text: "extend",
link: "/extend",
},
{
text: "Types",
base: "/packages/aa-core/provider/types",
base: "/packages/aa-core/smart-account-client/types",
collapsed: true,
items: [
{
Expand Down
67 changes: 0 additions & 67 deletions site/getting-started.md

This file was deleted.

14 changes: 7 additions & 7 deletions site/overview/faqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ If the `UserOperation` (meta-transaction for 4337 accounts) is correctly priced
::: details Answer
This can happen when `UserOperation`s (UOs) become underpriced, frequently due to fee market movement between when gas and fees are estimations and when the UO is actually submitted.

You may experience this when calling the [`waitForUserOperationTransaction`](/packages/aa-core/provider/waitForUserOperationTransaction.html#waitForUserOperationTransaction) method. It may throw an error if it does not find the UO in a mined Transaction within its retry limits.
You may experience this when calling the [`waitForUserOperationTransaction`](/packages/aa-core/smart-account-client/waitForUserOperationTransaction.html#waitForUserOperationTransaction) method. It may throw an error if it does not find the UO in a mined Transaction within its retry limits.

You can mitigate this by defining a more flexible retry period when constructing a [`Provider`](/packages/aa-core/provider/constructor.html#constructor) (i.e. `txMaxRetries`, `txRetryIntervalMs`, `txRetryMultiplier` in `opts`). If your UO continues to be delayed beyond a limit you are willing to wait, you can resubmit it using [`dropAndReplaceUserOperation`](/packages/aa-core/provider/dropAndReplaceUserOperation.html#dropandreplaceuseroperation).
You can mitigate this by defining a more flexible retry period when constructing a [`Provider`](/packages/aa-core/smart-account-client/createSmartAccountClient.html#constructor) (i.e. `txMaxRetries`, `txRetryIntervalMs`, `txRetryMultiplier` in `opts`). If your UO continues to be delayed beyond a limit you are willing to wait, you can resubmit it using [`dropAndReplaceUserOperation`](/packages/aa-core/smart-account-client/dropAndReplaceUserOperation.html#dropandreplaceuseroperation).
:::

### Are `UserOperation`s protected from MEV bots?
Expand All @@ -86,7 +86,7 @@ Yes! Check out [this guide](/tutorials/sim-user-operation.html).
### How does gas estimation for 4337 smart contract accounts work?

::: details Answer
Our bundler estimates gas and submits `UserOperation`s (UOs) under the hood of the aa-sdk. Our gas estimations are just that, estimations that optimize for UOs landing on chain, and you may need to adjust gas limits based on your needs using [overrides](/packages/aa-core/provider/types/userOperationOverrides.html).
Our bundler estimates gas and submits `UserOperation`s (UOs) under the hood of the aa-sdk. Our gas estimations are just that, estimations that optimize for UOs landing on chain, and you may need to adjust gas limits based on your needs using [overrides](/packages/aa-core/smart-account-client/types/userOperationOverrides.html).

Learn more about gas estimation and how it is implemented in our [Bundler](https://www.alchemy.com/blog/erc-4337-gas-estimation).

Expand Down Expand Up @@ -142,7 +142,7 @@ Precheck failed errors are often related to gas and/or fees. Our Bundler follows

These errors are often related to market movement between the time when gas and fees are estimated and the time when UOs are submitted to the bundler. This fluctuation in the market is especially variant on testnet. To ensure your UO is included in a block, we currently reject sending any UOs that are underpriced compared to the network rate .

To handle these errors, we recommend you use our [override fields](/packages/aa-core/provider/types/userOperationOverrides) to increase buffers on top of our estimates and implement retry mechanisms as needed.
To handle these errors, we recommend you use our [override fields](/packages/aa-core/smart-account-client/types/userOperationOverrides) to increase buffers on top of our estimates and implement retry mechanisms as needed.

Our gas and fee estimations are just that, estimations, but we are always working to improve these estimates!
:::
Expand All @@ -156,9 +156,9 @@ Currently our Bundler allows max 10M gas in aggregate between `preVerificationGa
### `waitForUserOperationTransaction` timeout

::: details Answer
[`waitForUserOperationTransaction`](/packages/aa-core/provider/waitForUserOperationTransaction) may throw this error if it does not find the mined User Operation within its retry limits.
[`waitForUserOperationTransaction`](/packages/aa-core/smart-account-client/waitForUserOperationTransaction) may throw this error if it does not find the mined User Operation within its retry limits.

You can mitigate this by defining a more flexible retry period when constructing a [`Provider`](/packages/aa-core/provider/constructor.html#constructor) (i.e. `txMaxRetries`, `txRetryIntervalMs`, `txRetryMultiplier` in `opts`).
You can mitigate this by defining a more flexible retry period when constructing a [`Client`](/packages/aa-core/smart-account-client/createSmartAccountClient.html#usage) (i.e. `txMaxRetries`, `txRetryIntervalMs`, `txRetryMultiplier` in `opts`).

If your `UserOperation` continues to be delayed beyond a limit you are willing to wait, you can resubmit the user operation using [`dropAndReplaceUserOperation`](/packages/aa-core/provider/dropAndReplaceUserOperation.html#dropandreplaceuseroperation).
If your `UserOperation` continues to be delayed beyond a limit you are willing to wait, you can resubmit the user operation using [`dropAndReplaceUserOperation`](/packages/aa-core/smart-account-client/dropAndReplaceUserOperation.html#dropandreplaceuseroperation).
:::
4 changes: 2 additions & 2 deletions site/packages/aa-accounts/light-account/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ A Promise containing a new `SmartAccountProvider` connected to a Light Account.

- `txRetryMulitplier: string | undefined` -- [optional] the mulitplier on interval length to wait between retries while waiting for transaction receipts (default: 1.5).

- `feeOptions:` [`UserOperationFeeOptions`](/packages/aa-core/provider/types/userOperationFeeOptions.md) `| undefined` --[optional] user operation fee options to be used for gas estimation, set at the global level on the provider.
If not set, default fee options for the chain are used. Available fields in `feeOptions` include `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` where each field is of type [`UserOperationFeeOptionsField`](/packages/aa-core/provider/types/userOperationFeeOptionsField.md).
- `feeOptions:` [`UserOperationFeeOptions`](/packages/aa-core/smart-account-client/types/userOperationFeeOptions.md) `| undefined` --[optional] user operation fee options to be used for gas estimation, set at the global level on the provider.
If not set, default fee options for the chain are used. Available fields in `feeOptions` include `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` where each field is of type [`UserOperationFeeOptionsField`](/packages/aa-core/smart-account-client/types/userOperationFeeOptionsField.md).

- `maxFeePerGas`: `UserOperationFeeOptionsField`
- `maxPriorityFeePerGas`: `UserOperationFeeOptionsField`
Expand Down
12 changes: 2 additions & 10 deletions site/packages/aa-alchemy/provider/constructor.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,11 @@ A new instance of an `AlchemyProvider`.

- `txRetryMulitplier: string | undefined` -- [optional] the mulitplier on interval length to wait between retries while waiting for transaction receipts (default: 1.5).

- `feeOptions:` [`UserOperationFeeOptions`](/packages/aa-core/provider/types/userOperationFeeOptions.md) `| undefined` --[optional] user operation fee options to be used for gas estimation, set at the global level on the provider.
If not set, default fee options for the chain are used. Available fields in `feeOptions` include `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` where each field is of type [`UserOperationFeeOptionsField`](/packages/aa-core/provider/types/userOperationFeeOptionsField.md).
- `feeOptions:` [`UserOperationFeeOptions`](/packages/aa-core/smart-account-client/types/userOperationFeeOptions.md) `| undefined` --[optional] user operation fee options to be used for gas estimation, set at the global level on the provider.
If not set, default fee options for the chain are used. Available fields in `feeOptions` include `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` where each field is of type [`UserOperationFeeOptionsField`](/packages/aa-core/smart-account-client/types/userOperationFeeOptionsField.md).

- `maxFeePerGas`: `UserOperationFeeOptionsField`
- `maxPriorityFeePerGas`: `UserOperationFeeOptionsField`
- `callGasLimit`: `UserOperationFeeOptionsField`
- `verificationGasLimit`: `UserOperationFeeOptionsField`
- `preVerificationGas`: `UserOperationFeeOptionsField`

:::tip Note
The fee options set upon the provider initialization are available from each middleware of the `SmartAccountProvider`. For example, the default middlewares such as [`gasEstimator`](/packages/aa-core/provider/withGasEstimator.md) or [`feeDataGetter`](/packages/aa-core/provider/withFeeDataGetter.md) apply the fee options to the estimated values if the fee options are set.
:::

:::tip Note
If you are using your own middleware, for example a custom `feeDataGetter` using [`withFeeDataGetter`](/packages/aa-core/provider/withFeeDataGetter.md) method on the provider, then the default `feeDataGetter` middleware is overriden. As you are opting out of using the default middleware, you are also responsible for handling the fee options appropriately for the fee options set upon provider initialization.
:::
2 changes: 1 addition & 1 deletion site/packages/aa-alchemy/provider/gasEstimator.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ the resulting user operation struct after gas estimation, run as part of a middl

### `struct: Deferrable<UserOperationStruct>` -- the struct containing UserOperation fields, where each field may be asychronously returned from the middleware used to generate its final value.

Note: You typically will call this method as part of a middleware chain when building and sending UserOperations, so the parameters of `UserOperationStruct` should be generated for you, as long as you pass in the initial parameters needed for [sendUserOperation](/packages/aa-core/provider/sendUserOperation).
Note: You typically will call this method as part of a middleware chain when building and sending UserOperations, so the parameters of `UserOperationStruct` should be generated for you, as long as you pass in the initial parameters needed for [sendUserOperation](/packages/aa-core/smart-account-client/sendUserOperation).
4 changes: 2 additions & 2 deletions site/packages/aa-alchemy/provider/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ head:

# AlchemyProvider

`AlchemyProvider` is an extension of the [`SmartAccountProvider`](/packages/aa-core/provider/introduction) implementation. It's a simpler interface you can use to leverage the Alchemy stack - JSON-RPC requests via API Key or JSON Web Token (JWT), Rundler (an [EIP-4337](https://eips.ethereum.org/EIPS/eip-4337) Bundler), and Gas Manager (an [EIP-4337](https://eips.ethereum.org/EIPS/eip-4337) Paymaster).
`AlchemyProvider` is an extension of the [`SmartAccountProvider`](/packages/aa-core/smart-account-client/introduction) implementation. It's a simpler interface you can use to leverage the Alchemy stack - JSON-RPC requests via API Key or JSON Web Token (JWT), Rundler (an [EIP-4337](https://eips.ethereum.org/EIPS/eip-4337) Bundler), and Gas Manager (an [EIP-4337](https://eips.ethereum.org/EIPS/eip-4337) Paymaster).

Notable differences between `AlchemyProvider` and `SmartAccountProvider` are implementations for:

1. [`gasEstimator`](/packages/aa-core/provider/withGasEstimator.md) -- overrides the base `SmartAccountProvider` gas estimator.
1. [`gasEstimator`](/packages/aa-core/smart-account-client/withGasEstimator.md) -- overrides the base `SmartAccountProvider` gas estimator.
2. [`withAlchemyGasManager`](/packages/aa-alchemy/provider/withAlchemyGasManager.md) -- adds the Alchemy Gas Manager middleware to the provider.

## Usage
Expand Down
4 changes: 2 additions & 2 deletions site/packages/aa-alchemy/provider/light-account-factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ A Promise containing a new `AlchemyProvider` connected to a Light Account.

- `txRetryMulitplier: string | undefined` -- [optional] the mulitplier on interval length to wait between retries while waiting for transaction receipts (default: 1.5).

- `feeOptions:` [`UserOperationFeeOptions`](/packages/aa-core/provider/types/userOperationFeeOptions.md) `| undefined` --[optional] user operation fee options to be used for gas estimation, set at the global level on the provider.
If not set, default fee options for the chain are used. Available fields in `feeOptions` include `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` where each field is of type [`UserOperationFeeOptionsField`](/packages/aa-core/provider/types/userOperationFeeOptionsField.md).
- `feeOptions:` [`UserOperationFeeOptions`](/packages/aa-core/smart-account-client/types/userOperationFeeOptions.md) `| undefined` --[optional] user operation fee options to be used for gas estimation, set at the global level on the provider.
If not set, default fee options for the chain are used. Available fields in `feeOptions` include `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` where each field is of type [`UserOperationFeeOptionsField`](/packages/aa-core/smart-account-client/types/userOperationFeeOptionsField.md).

- `maxFeePerGas`: `UserOperationFeeOptionsField`
- `maxPriorityFeePerGas`: `UserOperationFeeOptionsField`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ const uo = await provider.sendUserOperation(uoStruct);
- `data: Hex` - can be either `0x` or a call data string
- `value?: bigint` - optionally, set the value in wei you want to send to the target

### `overrides?:` [`UserOperationOverrides`](/packages/aa-core/provider/types/userOperationOverrides.md)
### `overrides?:` [`UserOperationOverrides`](/packages/aa-core/smart-account-client/types/userOperationOverrides.md)

Optional parameter where you can specify override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData` on the user operation request
Loading

0 comments on commit 806d207

Please sign in to comment.