diff --git a/.eslintrc b/.eslintrc index e0a39438c7..46af4b0b28 100644 --- a/.eslintrc +++ b/.eslintrc @@ -63,10 +63,6 @@ "fixBatchSize": 0, }, ], - "no-warning-comments": [ - "warn", - { "terms": ["TODO(v5)"], "location": "anywhere" }, - ], }, "overrides": [ { @@ -98,7 +94,12 @@ }, }, { - "files": ["packages/**/*.test.ts", "packages/**/*.test-d.ts", "packages/**/test-utils/**/*", "packages/**/__tests__/**/*"], + "files": [ + "packages/**/*.test.ts", + "packages/**/*.test-d.ts", + "packages/**/test-utils/**/*", + "packages/**/__tests__/**/*", + ], "rules": { "no-restricted-syntax": "off", }, diff --git a/docs/pages/reference/smart-accounts/src/README.mdx b/docs/pages/reference/smart-accounts/src/README.mdx index d578a1f960..4da77600e6 100644 --- a/docs/pages/reference/smart-accounts/src/README.mdx +++ b/docs/pages/reference/smart-accounts/src/README.mdx @@ -61,7 +61,6 @@ layout: reference | [InstallValidationParams](/wallets/reference/smart-accounts/type-aliases/InstallValidationParams) | - | | [LightAccount](/wallets/reference/smart-accounts/type-aliases/LightAccount) | - | | [LightAccountAbi](/wallets/reference/smart-accounts/type-aliases/LightAccountAbi) | - | -| [LightAccountActions](/wallets/reference/smart-accounts/type-aliases/LightAccountActions) | - | | [LightAccountType](/wallets/reference/smart-accounts/type-aliases/LightAccountType) | - | | [LightAccountVersion](/wallets/reference/smart-accounts/type-aliases/LightAccountVersion) | - | | [ModularAccountV1Base](/wallets/reference/smart-accounts/type-aliases/ModularAccountV1Base) | - | @@ -69,9 +68,7 @@ layout: reference | [ModularAccountV2Base](/wallets/reference/smart-accounts/type-aliases/ModularAccountV2Base) | - | | [ModuleEntity](/wallets/reference/smart-accounts/type-aliases/ModuleEntity) | - | | [MultiOwnerLightAccount](/wallets/reference/smart-accounts/type-aliases/MultiOwnerLightAccount) | - | -| [MultiOwnerLightAccountActions](/wallets/reference/smart-accounts/type-aliases/MultiOwnerLightAccountActions) | - | | [MultiOwnerModularAccountV1](/wallets/reference/smart-accounts/type-aliases/MultiOwnerModularAccountV1) | - | -| [MultiOwnerModularAccountV1Actions](/wallets/reference/smart-accounts/type-aliases/MultiOwnerModularAccountV1Actions) | - | | [Pack1271SignatureParams](/wallets/reference/smart-accounts/type-aliases/Pack1271SignatureParams) | - | | [PackUOSignatureParams](/wallets/reference/smart-accounts/type-aliases/PackUOSignatureParams) | - | | [Permission](/wallets/reference/smart-accounts/type-aliases/Permission) | - | @@ -155,12 +152,10 @@ layout: reference | [getModularAccountV2AddressFromFactoryData](/wallets/reference/smart-accounts/functions/getModularAccountV2AddressFromFactoryData) | Gets the modular account v2 address from factory data. If the factory is a known default (SMA), decodes the args and predicts without RPC. Otherwise falls back to calling the entry point's getSenderAddress. | | [getMultiOwnerLightAccountAddressFromFactoryData](/wallets/reference/smart-accounts/functions/getMultiOwnerLightAccountAddressFromFactoryData) | Gets the multi-owner light account address from factory data. If the factory is a known default, decodes the args and predicts without RPC. Otherwise falls back to calling the entry point's getSenderAddress. | | [getMultiOwnerModularAccountV1AddressFromFactoryData](/wallets/reference/smart-accounts/functions/getMultiOwnerModularAccountV1AddressFromFactoryData) | Gets the multi-owner modular account v1 address from factory data. If the factory is a known default, decodes the args and predicts without RPC. Otherwise falls back to calling the entry point's getSenderAddress. | -| [installValidationActions](/wallets/reference/smart-accounts/functions/installValidationActions) | Provides validation installation and uninstallation functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`. | +| [installValidationActions](/wallets/reference/smart-accounts/functions/installValidationActions) | Provides validation installation and uninstallation encoding functionalities for a MA v2 client. | | [isLightAccountVersion1](/wallets/reference/smart-accounts/functions/isLightAccountVersion1) | Type guard to check if a version is a Light Account v1 version | | [isLightAccountVersion2](/wallets/reference/smart-accounts/functions/isLightAccountVersion2) | Type guard to check if a version is a Light Account v2 version | | [isModularAccountV2](/wallets/reference/smart-accounts/functions/isModularAccountV2) | Checks if an account is a ModularAccountV2. | -| [multiOwnerLightAccountActions](/wallets/reference/smart-accounts/functions/multiOwnerLightAccountActions) | Generates client actions for a multi-owner light account, including the ability to update owners. | -| [multiOwnerModularAccountV1Actions](/wallets/reference/smart-accounts/functions/multiOwnerModularAccountV1Actions) | Generates client actions for a multi-owner MAv1 account, including the ability to update owners. | | [pack1271Signature](/wallets/reference/smart-accounts/functions/pack1271Signature) | Signature packing utility for 1271 signatures. | | [packUOSignature](/wallets/reference/smart-accounts/functions/packUOSignature) | Signature packing utility for user operations. | | [parseDeferredAction](/wallets/reference/smart-accounts/functions/parseDeferredAction) | Parses out the 3 components from a deferred action. | @@ -171,7 +166,6 @@ layout: reference | [serializeHookConfig](/wallets/reference/smart-accounts/functions/serializeHookConfig) | Serializes a `HookConfig` object into a `Hex` format by encoding the hook type, presence of post/pre hooks, address, and entity ID. | | [serializeModuleEntity](/wallets/reference/smart-accounts/functions/serializeModuleEntity) | Serializes a module entity into a hexadecimal format by concatenating the module address and entity ID. | | [serializeValidationConfig](/wallets/reference/smart-accounts/functions/serializeValidationConfig) | Serializes a validation configuration into a hexadecimal string representation. This involves converting boolean flags into bitwise representation and combining them with serialized module entity data. | -| [singleOwnerLightAccountActions](/wallets/reference/smart-accounts/functions/singleOwnerLightAccountActions) | A decorator that can be used with viem's bundler client to add light account actions to the client | | [toLightAccount](/wallets/reference/smart-accounts/functions/toLightAccount) | Creates a light account. | | [toModularAccountV1Base](/wallets/reference/smart-accounts/functions/toModularAccountV1Base) | Creates a ModularAccountV1Base instance. | | [toModularAccountV2](/wallets/reference/smart-accounts/functions/toModularAccountV2) | Creates a MAv2 account. | diff --git a/docs/pages/reference/smart-accounts/src/functions/buildFullNonceKey.mdx b/docs/pages/reference/smart-accounts/src/functions/buildFullNonceKey.mdx index 5bbb4d8322..44e2a4092d 100644 --- a/docs/pages/reference/smart-accounts/src/functions/buildFullNonceKey.mdx +++ b/docs/pages/reference/smart-accounts/src/functions/buildFullNonceKey.mdx @@ -11,7 +11,7 @@ layout: reference function buildFullNonceKey(params): bigint; ``` -Defined in: [packages/smart-accounts/src/ma-v2/utils/account.ts:86](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/utils/account.ts#L86) +Defined in: [packages/smart-accounts/src/ma-v2/utils/account.ts:84](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/utils/account.ts#L84) Builds a full nonce key. diff --git a/docs/pages/reference/smart-accounts/src/functions/defaultLightAccountVersion.mdx b/docs/pages/reference/smart-accounts/src/functions/defaultLightAccountVersion.mdx index 5c379e8589..8f14d3a5ce 100644 --- a/docs/pages/reference/smart-accounts/src/functions/defaultLightAccountVersion.mdx +++ b/docs/pages/reference/smart-accounts/src/functions/defaultLightAccountVersion.mdx @@ -13,7 +13,7 @@ function defaultLightAccountVersion< >(): keyof object[TLightAccountType]; ``` -Defined in: [packages/smart-accounts/src/light-account/utils.ts:21](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/utils.ts#L21) +Defined in: [packages/smart-accounts/src/light-account/utils.ts:15](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/utils.ts#L15) Get the default light account version for the given light account type diff --git a/docs/pages/reference/smart-accounts/src/functions/getLightAccountImplAddress.mdx b/docs/pages/reference/smart-accounts/src/functions/getLightAccountImplAddress.mdx index 1ba4426671..34c660fbc2 100644 --- a/docs/pages/reference/smart-accounts/src/functions/getLightAccountImplAddress.mdx +++ b/docs/pages/reference/smart-accounts/src/functions/getLightAccountImplAddress.mdx @@ -11,7 +11,7 @@ layout: reference function getLightAccountImplAddress(account): Promise<`0x${string}`>; ``` -Defined in: [packages/smart-accounts/src/light-account/utils.ts:55](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/utils.ts#L55) +Defined in: [packages/smart-accounts/src/light-account/utils.ts:49](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/utils.ts#L49) Get the light account implementation address for the given light account diff --git a/docs/pages/reference/smart-accounts/src/functions/installValidationActions.mdx b/docs/pages/reference/smart-accounts/src/functions/installValidationActions.mdx index fa2c06ae80..977b814319 100644 --- a/docs/pages/reference/smart-accounts/src/functions/installValidationActions.mdx +++ b/docs/pages/reference/smart-accounts/src/functions/installValidationActions.mdx @@ -15,25 +15,23 @@ function installValidationActions( >; ``` -Defined in: [packages/smart-accounts/src/ma-v2/decorators/installValidation.ts:111](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts#L111) +Defined in: [packages/smart-accounts/src/ma-v2/decorators/installValidation.ts:95](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts#L95) -Provides validation installation and uninstallation functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`. +Provides validation installation and uninstallation encoding functionalities for a MA v2 client. ## Example ```ts -import { createModularAccountV2Client, installValidationActions, getDefaultSingleSignerValidationModuleAddress, SingleSignerValidationModule } from "@alchemy/smart-accounts"; +import { installValidationActions, SingleSignerValidationModule } from "@alchemy/smart-accounts"; import { Address } from "viem"; const client = (await createModularAccountV2Client({ ... })).extend(installValidationActions); const sessionKeyAddress: Address = "0x1234"; const sessionKeyEntityId: number = 1; -await client.installValidation({ +const callData = await client.encodeInstallValidation({ validationConfig: { - moduleAddress: getDefaultSingleSignerValidationModuleAddress( - client.chain - ), + moduleAddress: getDefaultSingleSignerValidationModuleAddress(client.chain), entityId: sessionKeyEntityId, isGlobal: true, isSignatureValidation: false, @@ -47,15 +45,7 @@ await client.installValidation({ hooks: [], }); -await client.uninstallValidation({ - moduleAddress: sessionKeyAddress, - entityId: sessionKeyEntityId, - uninstallData: SingleSignerValidationModule.encodeOnUninstallData({ - entityId: sessionKeyEntityId, - }), - hookUninstallDatas: [], -}); - +await client.sendUserOperation({ callData, account }); ``` ## Type Parameters @@ -124,7 +114,7 @@ await client.uninstallValidation({ - The client instance which provides account and sendUserOperation functionality. + The client instance which provides account functionality. @@ -135,4 +125,4 @@ await client.uninstallValidation({ [`InstallValidationActions`](../type-aliases/InstallValidationActions)\<[`IsUndefined`](https://viem.sh)\<`TAccount`> _extends_ `true` ? `undefined` : [`ModularAccountV2`](../type-aliases/ModularAccountV2)> -- An object containing two methods, `installValidation` and `uninstallValidation`. +- An object containing `encodeInstallValidation` and `encodeUninstallValidation`. diff --git a/docs/pages/reference/smart-accounts/src/functions/isModularAccountV2.mdx b/docs/pages/reference/smart-accounts/src/functions/isModularAccountV2.mdx index 9bbb6d5427..f2b4fa2b4e 100644 --- a/docs/pages/reference/smart-accounts/src/functions/isModularAccountV2.mdx +++ b/docs/pages/reference/smart-accounts/src/functions/isModularAccountV2.mdx @@ -11,7 +11,7 @@ layout: reference function isModularAccountV2(account): account is ModularAccountV2Base; ``` -Defined in: [packages/smart-accounts/src/ma-v2/utils/account.ts:130](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/utils/account.ts#L130) +Defined in: [packages/smart-accounts/src/ma-v2/utils/account.ts:128](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/utils/account.ts#L128) Checks if an account is a ModularAccountV2. diff --git a/docs/pages/reference/smart-accounts/src/functions/multiOwnerLightAccountActions.mdx b/docs/pages/reference/smart-accounts/src/functions/multiOwnerLightAccountActions.mdx deleted file mode 100644 index e9fbe68c0e..0000000000 --- a/docs/pages/reference/smart-accounts/src/functions/multiOwnerLightAccountActions.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: multiOwnerLightAccountActions -description: Overview of the multiOwnerLightAccountActions function -slug: wallets/reference/smart-accounts/functions/multiOwnerLightAccountActions -layout: reference ---- - -{/* This file is auto-generated by TypeDoc. Do not edit manually. */} - -```ts -function multiOwnerLightAccountActions( - client, -): MultiOwnerLightAccountActions< - IsUndefined extends true ? undefined : MultiOwnerLightAccount ->; -``` - -Defined in: [packages/smart-accounts/src/light-account/decorators/multiOwner.ts:36](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/decorators/multiOwner.ts#L36) - -Generates client actions for a multi-owner light account, including the ability to update owners. - -## Type Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Type ParameterDefault type
- `TTransport` *extends* [`Transport`](https://viem.sh) - - [`Transport`](https://viem.sh) -
- `TChain` *extends* [`Chain`](https://viem.sh) | `undefined` - - [`Chain`](https://viem.sh) | `undefined` -
- `TAccount` *extends* [`SmartAccount`](https://viem.sh) | `undefined` - - [`SmartAccount`](https://viem.sh) | `undefined` -
- -## Parameters - - - - - - - - - - - - - - - - - - - - -
ParameterTypeDescription
- `client` - - [`Client`](https://viem.sh)\<`TTransport`, `TChain`, `TAccount`> - - The client instance used to interact with the account -
- -## Returns - -[`MultiOwnerLightAccountActions`](../type-aliases/MultiOwnerLightAccountActions)\<[`IsUndefined`](https://viem.sh)\<`TAccount`> _extends_ `true` ? `undefined` : [`MultiOwnerLightAccount`](../type-aliases/MultiOwnerLightAccount)> - -An object containing the client actions specifically for a multi-owner light account diff --git a/docs/pages/reference/smart-accounts/src/functions/multiOwnerModularAccountV1Actions.mdx b/docs/pages/reference/smart-accounts/src/functions/multiOwnerModularAccountV1Actions.mdx deleted file mode 100644 index fd216a0d29..0000000000 --- a/docs/pages/reference/smart-accounts/src/functions/multiOwnerModularAccountV1Actions.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: multiOwnerModularAccountV1Actions -description: Overview of the multiOwnerModularAccountV1Actions function -slug: wallets/reference/smart-accounts/functions/multiOwnerModularAccountV1Actions -layout: reference ---- - -{/* This file is auto-generated by TypeDoc. Do not edit manually. */} - -```ts -function multiOwnerModularAccountV1Actions( - client, -): MultiOwnerModularAccountV1Actions< - IsUndefined extends true ? undefined : MultiOwnerModularAccountV1 ->; -``` - -Defined in: [packages/smart-accounts/src/ma-v1/decorators/multiOwner.ts:36](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v1/decorators/multiOwner.ts#L36) - -Generates client actions for a multi-owner MAv1 account, including the ability to update owners. - -## Type Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Type ParameterDefault type
- `TTransport` *extends* [`Transport`](https://viem.sh) - - [`Transport`](https://viem.sh) -
- `TChain` *extends* [`Chain`](https://viem.sh) | `undefined` - - [`Chain`](https://viem.sh) | `undefined` -
- `TAccount` *extends* [`SmartAccount`](https://viem.sh) | `undefined` - - [`SmartAccount`](https://viem.sh) | `undefined` -
- -## Parameters - - - - - - - - - - - - - - - - - - - - -
ParameterTypeDescription
- `client` - - [`Client`](https://viem.sh)\<`TTransport`, `TChain`, `TAccount`> - - The client instance used to interact with the account -
- -## Returns - -[`MultiOwnerModularAccountV1Actions`](../type-aliases/MultiOwnerModularAccountV1Actions)\<[`IsUndefined`](https://viem.sh)\<`TAccount`> _extends_ `true` ? `undefined` : [`MultiOwnerModularAccountV1`](../type-aliases/MultiOwnerModularAccountV1)> - -An object containing the client actions specifically for a multi-owner modular account diff --git a/docs/pages/reference/smart-accounts/src/functions/serializeModuleEntity.mdx b/docs/pages/reference/smart-accounts/src/functions/serializeModuleEntity.mdx index 92bc3eb0dd..259da78af1 100644 --- a/docs/pages/reference/smart-accounts/src/functions/serializeModuleEntity.mdx +++ b/docs/pages/reference/smart-accounts/src/functions/serializeModuleEntity.mdx @@ -11,7 +11,7 @@ layout: reference function serializeModuleEntity(config): `0x${string}`; ``` -Defined in: [packages/smart-accounts/src/ma-v2/utils/account.ts:120](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/utils/account.ts#L120) +Defined in: [packages/smart-accounts/src/ma-v2/utils/account.ts:118](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/utils/account.ts#L118) Serializes a module entity into a hexadecimal format by concatenating the module address and entity ID. diff --git a/docs/pages/reference/smart-accounts/src/functions/singleOwnerLightAccountActions.mdx b/docs/pages/reference/smart-accounts/src/functions/singleOwnerLightAccountActions.mdx deleted file mode 100644 index 8d62ac0975..0000000000 --- a/docs/pages/reference/smart-accounts/src/functions/singleOwnerLightAccountActions.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: singleOwnerLightAccountActions -description: Overview of the singleOwnerLightAccountActions function -slug: wallets/reference/smart-accounts/functions/singleOwnerLightAccountActions -layout: reference ---- - -{/* This file is auto-generated by TypeDoc. Do not edit manually. */} - -```ts -function singleOwnerLightAccountActions( - client, -): LightAccountActions< - IsUndefined extends true ? undefined : LightAccount ->; -``` - -Defined in: [packages/smart-accounts/src/light-account/decorators/singleOwner.ts:30](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/decorators/singleOwner.ts#L30) - -A decorator that can be used with viem's bundler client to add light account actions to the client - -## Type Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Type ParameterDefault type
- `TTransport` *extends* [`Transport`](https://viem.sh) - - [`Transport`](https://viem.sh) -
- `TChain` *extends* [`Chain`](https://viem.sh) | `undefined` - - [`Chain`](https://viem.sh) | `undefined` -
- `TAccount` *extends* [`SmartAccount`](https://viem.sh) | `undefined` - - [`SmartAccount`](https://viem.sh) | `undefined` -
- -## Parameters - - - - - - - - - - - - - - - - - - - - -
ParameterTypeDescription
- `client` - - [`Client`](https://viem.sh)\<`TTransport`, `TChain`, `TAccount`> - - The client instance for which to provide the light account actions -
- -## Returns - -[`LightAccountActions`](../type-aliases/LightAccountActions)\<[`IsUndefined`](https://viem.sh)\<`TAccount`> _extends_ `true` ? `undefined` : [`LightAccount`](../type-aliases/LightAccount)> - -An object containing the available light account actions diff --git a/docs/pages/reference/smart-accounts/src/type-aliases/BuildNonceParams.mdx b/docs/pages/reference/smart-accounts/src/type-aliases/BuildNonceParams.mdx index 6425f632d6..11fdeb52a8 100644 --- a/docs/pages/reference/smart-accounts/src/type-aliases/BuildNonceParams.mdx +++ b/docs/pages/reference/smart-accounts/src/type-aliases/BuildNonceParams.mdx @@ -11,7 +11,7 @@ layout: reference type BuildNonceParams = object; ``` -Defined in: [packages/smart-accounts/src/ma-v2/utils/account.ts:72](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/utils/account.ts#L72) +Defined in: [packages/smart-accounts/src/ma-v2/utils/account.ts:70](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/utils/account.ts#L70) ## Properties diff --git a/docs/pages/reference/smart-accounts/src/type-aliases/InstallValidationActions.mdx b/docs/pages/reference/smart-accounts/src/type-aliases/InstallValidationActions.mdx index eb4112de9e..8db22b8810 100644 --- a/docs/pages/reference/smart-accounts/src/type-aliases/InstallValidationActions.mdx +++ b/docs/pages/reference/smart-accounts/src/type-aliases/InstallValidationActions.mdx @@ -11,7 +11,7 @@ layout: reference type InstallValidationActions = object; ``` -Defined in: [packages/smart-accounts/src/ma-v2/decorators/installValidation.ts:51](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts#L51) +Defined in: [packages/smart-accounts/src/ma-v2/decorators/installValidation.ts:50](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts#L50) ## Type Parameters @@ -68,25 +68,5 @@ Defined in: [packages/smart-accounts/src/ma-v2/decorators/installValidation.ts:5 - - - `installValidation` - - - - (`args`) => `Promise`\<[`Hex`](https://viem.sh)> - - - - - - `uninstallValidation` - - - - (`args`) => `Promise`\<[`Hex`](https://viem.sh)> - - - diff --git a/docs/pages/reference/smart-accounts/src/type-aliases/InstallValidationParams.mdx b/docs/pages/reference/smart-accounts/src/type-aliases/InstallValidationParams.mdx index 96d5f5fdc2..f49178dcac 100644 --- a/docs/pages/reference/smart-accounts/src/type-aliases/InstallValidationParams.mdx +++ b/docs/pages/reference/smart-accounts/src/type-aliases/InstallValidationParams.mdx @@ -12,7 +12,7 @@ type InstallValidationParams = object & GetAccountParameter; ``` -Defined in: [packages/smart-accounts/src/ma-v2/decorators/installValidation.ts:30](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts#L30) +Defined in: [packages/smart-accounts/src/ma-v2/decorators/installValidation.ts:29](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts#L29) ## Type Declaration diff --git a/docs/pages/reference/smart-accounts/src/type-aliases/LightAccountActions.mdx b/docs/pages/reference/smart-accounts/src/type-aliases/LightAccountActions.mdx deleted file mode 100644 index 9f264be624..0000000000 --- a/docs/pages/reference/smart-accounts/src/type-aliases/LightAccountActions.mdx +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: LightAccountActions -description: Overview of LightAccountActions -slug: wallets/reference/smart-accounts/type-aliases/LightAccountActions -layout: reference ---- - -{/* This file is auto-generated by TypeDoc. Do not edit manually. */} - -```ts -type LightAccountActions = object; -``` - -Defined in: [packages/smart-accounts/src/light-account/decorators/singleOwner.ts:8](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/decorators/singleOwner.ts#L8) - -## Type Parameters - - - - - - - - - - - - - - - - - -
Type ParameterDefault type
- `TAccount` *extends* [`LightAccount`](LightAccount) | `undefined` - - [`LightAccount`](LightAccount) | `undefined` -
- -## Properties - - - - - - - - - - - - - - - - - -
PropertyType
- `transferOwnership` - - (`args`) => `Promise`\<[`Hex`](https://viem.sh)> -
diff --git a/docs/pages/reference/smart-accounts/src/type-aliases/MultiOwnerLightAccountActions.mdx b/docs/pages/reference/smart-accounts/src/type-aliases/MultiOwnerLightAccountActions.mdx deleted file mode 100644 index a0c97c5b12..0000000000 --- a/docs/pages/reference/smart-accounts/src/type-aliases/MultiOwnerLightAccountActions.mdx +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: MultiOwnerLightAccountActions -description: Overview of MultiOwnerLightAccountActions -slug: wallets/reference/smart-accounts/type-aliases/MultiOwnerLightAccountActions -layout: reference ---- - -{/* This file is auto-generated by TypeDoc. Do not edit manually. */} - -```ts -type MultiOwnerLightAccountActions = object; -``` - -Defined in: [packages/smart-accounts/src/light-account/decorators/multiOwner.ts:8](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/decorators/multiOwner.ts#L8) - -## Type Parameters - - - - - - - - - - - - - - - - - -
Type ParameterDefault type
- `TAccount` *extends* [`MultiOwnerLightAccount`](MultiOwnerLightAccount) | `undefined` - - [`MultiOwnerLightAccount`](MultiOwnerLightAccount) | `undefined` -
- -## Properties - - - - - - - - - - - - - - - - - -
PropertyType
- `updateOwners` - - (`args`) => `Promise`\<[`Hex`](https://viem.sh)> -
diff --git a/docs/pages/reference/smart-accounts/src/type-aliases/MultiOwnerModularAccountV1Actions.mdx b/docs/pages/reference/smart-accounts/src/type-aliases/MultiOwnerModularAccountV1Actions.mdx deleted file mode 100644 index 3a661f4af4..0000000000 --- a/docs/pages/reference/smart-accounts/src/type-aliases/MultiOwnerModularAccountV1Actions.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: MultiOwnerModularAccountV1Actions -description: Overview of MultiOwnerModularAccountV1Actions -slug: wallets/reference/smart-accounts/type-aliases/MultiOwnerModularAccountV1Actions -layout: reference ---- - -{/* This file is auto-generated by TypeDoc. Do not edit manually. */} - -```ts -type MultiOwnerModularAccountV1Actions = object; -``` - -Defined in: [packages/smart-accounts/src/ma-v1/decorators/multiOwner.ts:8](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v1/decorators/multiOwner.ts#L8) - -## Type Parameters - - - - - - - - - - - - - - - - - -
Type ParameterDefault type
- `TAccount` *extends* - | [`MultiOwnerModularAccountV1`](MultiOwnerModularAccountV1) - | `undefined` - - | [`MultiOwnerModularAccountV1`](MultiOwnerModularAccountV1) - | `undefined` -
- -## Properties - - - - - - - - - - - - - - - - - -
PropertyType
- `updateOwners` - - (`args`) => `Promise`\<[`Hex`](https://viem.sh)> -
diff --git a/docs/pages/reference/smart-accounts/src/type-aliases/SemiModularAccount7702StaticImpl.mdx b/docs/pages/reference/smart-accounts/src/type-aliases/SemiModularAccount7702StaticImpl.mdx index b0e5adebe2..0c003fc822 100644 --- a/docs/pages/reference/smart-accounts/src/type-aliases/SemiModularAccount7702StaticImpl.mdx +++ b/docs/pages/reference/smart-accounts/src/type-aliases/SemiModularAccount7702StaticImpl.mdx @@ -18,4 +18,4 @@ type SemiModularAccount7702StaticImpl = StaticSmartAccountImplementation< >; ``` -Defined in: [packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts:65](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts#L65) +Defined in: [packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts:63](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts#L63) diff --git a/docs/pages/reference/smart-accounts/src/type-aliases/UninstallValidationParams.mdx b/docs/pages/reference/smart-accounts/src/type-aliases/UninstallValidationParams.mdx index 14c3ad752f..b774e7bb43 100644 --- a/docs/pages/reference/smart-accounts/src/type-aliases/UninstallValidationParams.mdx +++ b/docs/pages/reference/smart-accounts/src/type-aliases/UninstallValidationParams.mdx @@ -12,7 +12,7 @@ type UninstallValidationParams = object & GetAccountParameter; ``` -Defined in: [packages/smart-accounts/src/ma-v2/decorators/installValidation.ts:42](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts#L42) +Defined in: [packages/smart-accounts/src/ma-v2/decorators/installValidation.ts:41](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts#L41) ## Type Declaration diff --git a/docs/pages/reference/smart-accounts/src/variables/LightAccountUnsupported1271Factories.mdx b/docs/pages/reference/smart-accounts/src/variables/LightAccountUnsupported1271Factories.mdx index c36d43bd11..798dc74c10 100644 --- a/docs/pages/reference/smart-accounts/src/variables/LightAccountUnsupported1271Factories.mdx +++ b/docs/pages/reference/smart-accounts/src/variables/LightAccountUnsupported1271Factories.mdx @@ -11,7 +11,7 @@ layout: reference const LightAccountUnsupported1271Factories: Set<`0x${string}`>; ``` -Defined in: [packages/smart-accounts/src/light-account/utils.ts:42](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/utils.ts#L42) +Defined in: [packages/smart-accounts/src/light-account/utils.ts:36](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/utils.ts#L36) Can be used to check if the account with one of the following factory addresses to not support 1271 signing. diff --git a/docs/pages/reference/smart-accounts/src/variables/LightAccountUnsupported1271Impls.mdx b/docs/pages/reference/smart-accounts/src/variables/LightAccountUnsupported1271Impls.mdx index fdeec99d93..857cb84c3b 100644 --- a/docs/pages/reference/smart-accounts/src/variables/LightAccountUnsupported1271Impls.mdx +++ b/docs/pages/reference/smart-accounts/src/variables/LightAccountUnsupported1271Impls.mdx @@ -11,7 +11,7 @@ layout: reference const LightAccountUnsupported1271Impls: LightAccountV1StaticImpl[]; ``` -Defined in: [packages/smart-accounts/src/light-account/utils.ts:31](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/utils.ts#L31) +Defined in: [packages/smart-accounts/src/light-account/utils.ts:25](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/light-account/utils.ts#L25) Can be used to check if the account with one of the following implementation addresses to not support 1271 signing. diff --git a/docs/pages/reference/smart-accounts/src/variables/multiOwnerModularAccountStaticImpl.mdx b/docs/pages/reference/smart-accounts/src/variables/multiOwnerModularAccountStaticImpl.mdx index 34660fd80c..0396029d83 100644 --- a/docs/pages/reference/smart-accounts/src/variables/multiOwnerModularAccountStaticImpl.mdx +++ b/docs/pages/reference/smart-accounts/src/variables/multiOwnerModularAccountStaticImpl.mdx @@ -1,6 +1,6 @@ --- title: multiOwnerModularAccountStaticImpl -description: "Static implementation logic for ModularAccountV1. TODO(v5): update JSDoc format when doc-gen supports structs or records." +description: Static implementation logic for ModularAccountV1. slug: wallets/reference/smart-accounts/variables/multiOwnerModularAccountStaticImpl layout: reference --- @@ -18,8 +18,6 @@ const multiOwnerModularAccountStaticImpl: StaticSmartAccountImplementation< >; ``` -Defined in: [packages/smart-accounts/src/ma-v1/mav1StaticImpl.ts:20](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v1/mav1StaticImpl.ts#L20) +Defined in: [packages/smart-accounts/src/ma-v1/mav1StaticImpl.ts:18](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v1/mav1StaticImpl.ts#L18) Static implementation logic for ModularAccountV1. - -TODO(v5): update JSDoc format when doc-gen supports structs or records. diff --git a/docs/pages/reference/smart-accounts/src/variables/semiModularAccount7702StaticImpl.mdx b/docs/pages/reference/smart-accounts/src/variables/semiModularAccount7702StaticImpl.mdx index b52c239747..eb7b9719b5 100644 --- a/docs/pages/reference/smart-accounts/src/variables/semiModularAccount7702StaticImpl.mdx +++ b/docs/pages/reference/smart-accounts/src/variables/semiModularAccount7702StaticImpl.mdx @@ -1,6 +1,6 @@ --- title: semiModularAccount7702StaticImpl -description: "Static implementation logic for SemiModularAccount7702. TODO(v5): update JSDoc format when doc-gen supports structs or records." +description: Static implementation logic for SemiModularAccount7702. slug: wallets/reference/smart-accounts/variables/semiModularAccount7702StaticImpl layout: reference --- @@ -11,8 +11,6 @@ layout: reference const semiModularAccount7702StaticImpl: SemiModularAccount7702StaticImpl; ``` -Defined in: [packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts:79](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts#L79) +Defined in: [packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts:75](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts#L75) Static implementation logic for SemiModularAccount7702. - -TODO(v5): update JSDoc format when doc-gen supports structs or records. diff --git a/docs/pages/reference/smart-accounts/src/variables/semiModularAccountV2StaticImpl.mdx b/docs/pages/reference/smart-accounts/src/variables/semiModularAccountV2StaticImpl.mdx index f5a2ce8089..c277d8d594 100644 --- a/docs/pages/reference/smart-accounts/src/variables/semiModularAccountV2StaticImpl.mdx +++ b/docs/pages/reference/smart-accounts/src/variables/semiModularAccountV2StaticImpl.mdx @@ -1,6 +1,6 @@ --- title: semiModularAccountV2StaticImpl -description: "Static implementation logic for SemiModularAccountV2. TODO(v5): update JSDoc format when doc-gen supports structs or records." +description: Static implementation logic for SemiModularAccountV2. slug: wallets/reference/smart-accounts/variables/semiModularAccountV2StaticImpl layout: reference --- @@ -11,8 +11,6 @@ layout: reference const semiModularAccountV2StaticImpl: SemiModularAccountV2StaticImpl; ``` -Defined in: [packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts:42](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts#L42) +Defined in: [packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts:40](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts#L40) Static implementation logic for SemiModularAccountV2. - -TODO(v5): update JSDoc format when doc-gen supports structs or records. diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index 0714e0800d..ef3322c49e 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -1,12 +1,12 @@ -// http -- TODO(v5): not currently exported -// export type * from "./rest/restClient.js"; -// export type * from "./rest/types.js"; -// export { AlchemyRestClient } from "./rest/restClient.js"; - // transport export type * from "./transport/alchemy.js"; export { alchemyTransport, isAlchemyTransport } from "./transport/alchemy.js"; +// http -- Revisit exporting this once it has a use case. +// export type * from "./rest/restClient.js"; +// export type * from "./rest/types.js"; +// export { AlchemyRestClient } from "./rest/restClient.js"; + // chain registry utilities export { getAlchemyRpcUrl, diff --git a/packages/smart-accounts/README.md b/packages/smart-accounts/README.md index 450a187658..f393b0e3a1 100644 --- a/packages/smart-accounts/README.md +++ b/packages/smart-accounts/README.md @@ -15,12 +15,10 @@ npm install @alchemy/smart-accounts @alchemy/common viem - **`toLightAccount`** - Single-owner LightAccount - **`toMultiOwnerLightAccount`** - Multi-owner variant - **`predictLightAccountAddress`** / **`predictMultiOwnerLightAccountAddress`** - Counterfactual address prediction -- **`singleOwnerLightAccountActions`** / **`multiOwnerLightAccountActions`** - Client decorators ### Modular Account v1 (ERC-6900) - **`toMultiOwnerModularAccountV1`** - Account constructor -- **`multiOwnerModularAccountV1Actions`** - Client decorator - **`predictMultiOwnerModularAccountV1Address`** - Address prediction ### Modular Account v2 diff --git a/packages/smart-accounts/src/index.ts b/packages/smart-accounts/src/index.ts index 4d6507e69e..b043f531db 100644 --- a/packages/smart-accounts/src/index.ts +++ b/packages/smart-accounts/src/index.ts @@ -7,16 +7,6 @@ export { toLightAccount } from "./light-account/accounts/account.js"; export type * from "./light-account/accounts/multi-owner-account.js"; export { toMultiOwnerLightAccount } from "./light-account/accounts/multi-owner-account.js"; -// TODO(v5): Something to consider for v5 - can we cut the exports for the account-specific actions -// from the public interface, and just consume these internally with account + rely on the standard -// bundlerClient actions for performing state writes (i.e. rotating owners)? I'm not sure it's useful -// to consumers outside of attaching to instances of a client with the right action. -export type * from "./light-account/decorators/singleOwner.js"; -export { singleOwnerLightAccountActions } from "./light-account/decorators/singleOwner.js"; - -export type * from "./light-account/decorators/multiOwner.js"; -export { multiOwnerLightAccountActions } from "./light-account/decorators/multiOwner.js"; - export type * from "./light-account/predictAddress.js"; export { predictLightAccountAddress, @@ -52,9 +42,6 @@ export { toModularAccountV1Base } from "./ma-v1/accounts/base.js"; export type * from "./ma-v1/accounts/multi-owner-account.js"; export { toMultiOwnerModularAccountV1 } from "./ma-v1/accounts/multi-owner-account.js"; -export type * from "./ma-v1/decorators/multiOwner.js"; -export { multiOwnerModularAccountV1Actions } from "./ma-v1/decorators/multiOwner.js"; - export type * from "./ma-v1/predictAddress.js"; export { predictMultiOwnerModularAccountV1Address } from "./ma-v1/predictAddress.js"; diff --git a/packages/smart-accounts/src/light-account/accounts/account.test.ts b/packages/smart-accounts/src/light-account/accounts/account.test.ts index 584de2959b..de1ab31669 100644 --- a/packages/smart-accounts/src/light-account/accounts/account.test.ts +++ b/packages/smart-accounts/src/light-account/accounts/account.test.ts @@ -16,7 +16,6 @@ import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; import { setBalance } from "viem/actions"; import { accounts } from "~test/constants.js"; import { localInstance } from "~test/instances.js"; -import { singleOwnerLightAccountActions } from "../decorators/singleOwner.js"; import type { LightAccountVersion } from "../registry.js"; import { AccountVersionRegistry } from "../registry.js"; import { toLightAccount } from "./account.js"; @@ -436,8 +435,15 @@ describe("Light Account Tests", () => { // create new signer and transfer ownership const newOwner = privateKeyToAccount(generatePrivateKey()); - const hash = await throwawayClient.transferOwnership({ - newOwner: newOwner.address, + const hash = await throwawayClient.sendUserOperation({ + calls: [ + { + to: throwawayClient.account.address, + data: throwawayClient.account.encodeTransferOwnership( + newOwner.address, + ), + }, + ], }); await throwawayClient.waitForUserOperationReceipt({ hash }); @@ -457,10 +463,6 @@ describe("Light Account Tests", () => { ); }); - // TODO(v5): implement test for upgrading account to MSCA? - - // TODO(v5): implement test for upgrading account to MAv2 (prob will do this in the MAv2 tests) - it("should derive correct address from factoryData without accountAddress", async () => { // First create an account normally to get expected address and factory data const provider = await givenConnectedProvider({ @@ -521,6 +523,6 @@ describe("Light Account Tests", () => { userOperation: { estimateFeesPerGas, }, - }).extend((client) => singleOwnerLightAccountActions(client)); + }); }; }); diff --git a/packages/smart-accounts/src/light-account/accounts/base.ts b/packages/smart-accounts/src/light-account/accounts/base.ts index 33d5f4b474..419dce2bee 100644 --- a/packages/smart-accounts/src/light-account/accounts/base.ts +++ b/packages/smart-accounts/src/light-account/accounts/base.ts @@ -128,7 +128,6 @@ export async function toLightAccountBase< ).map((x) => x.accountImplementation); const getStorageAtAction = getAction(client, getStorageAt, "getStorageAt"); - // TODO(v5): This is a super fragile workflow, and we should consider not supporting this on the SmartAccount level in v5. const storage = await getStorageAtAction({ address: accountAddress, slot: EIP1967_PROXY_IMPL_STORAGE_SLOT, diff --git a/packages/smart-accounts/src/light-account/accounts/multi-owner-account.test.ts b/packages/smart-accounts/src/light-account/accounts/multi-owner-account.test.ts index d89782a20f..94010886eb 100644 --- a/packages/smart-accounts/src/light-account/accounts/multi-owner-account.test.ts +++ b/packages/smart-accounts/src/light-account/accounts/multi-owner-account.test.ts @@ -20,7 +20,6 @@ import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; import { setBalance } from "viem/actions"; import { accounts, poolId } from "~test/constants.js"; import { localInstance } from "~test/instances.js"; -import { multiOwnerLightAccountActions } from "../decorators/multiOwner.js"; import type { LightAccountVersion } from "../registry.js"; import { toMultiOwnerLightAccount } from "./multi-owner-account.js"; import { estimateFeesPerGas } from "@alchemy/aa-infra"; @@ -253,9 +252,16 @@ describe.sequential("MultiOwner Light Account Tests", () => { chain: client.chain, }); - const hash = await throwawayClient.updateOwners({ - ownersToAdd: [newOwner.account.address], - ownersToRemove: [throwawaySigner.account.address], + const hash = await throwawayClient.sendUserOperation({ + calls: [ + { + to: throwawayClient.account.address, + data: throwawayClient.account.encodeUpdateOwners( + [newOwner.account.address], + [throwawaySigner.account.address], + ), + }, + ], }); await throwawayClient.waitForUserOperationReceipt({ hash }); @@ -271,8 +277,6 @@ describe.sequential("MultiOwner Light Account Tests", () => { expect(newOwnerAddresses).toContain(newOwner.account.address); }, 100000); - // TODO(v5): implement test for upgrading account to MSCA? - const givenConnectedProvider = async ({ signer, accountAddress, @@ -317,6 +321,6 @@ describe.sequential("MultiOwner Light Account Tests", () => { userOperation: { estimateFeesPerGas, }, - }).extend(multiOwnerLightAccountActions); + }); }; }); diff --git a/packages/smart-accounts/src/light-account/decorators/multiOwner.ts b/packages/smart-accounts/src/light-account/decorators/multiOwner.ts deleted file mode 100644 index f3216cf814..0000000000 --- a/packages/smart-accounts/src/light-account/decorators/multiOwner.ts +++ /dev/null @@ -1,72 +0,0 @@ -import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem"; -import { sendUserOperation, type SmartAccount } from "viem/account-abstraction"; -import { getAction } from "viem/utils"; -import type { GetAccountParameter } from "../../types.js"; -import type { MultiOwnerLightAccount } from "../accounts/multi-owner-account.js"; -import { AccountNotFoundError } from "@alchemy/common"; - -export type MultiOwnerLightAccountActions< - TAccount extends MultiOwnerLightAccount | undefined = - | MultiOwnerLightAccount - | undefined, -> = { - updateOwners: ( - args: { - ownersToAdd: Address[]; - ownersToRemove: Address[]; - } & GetAccountParameter, - ) => Promise; -}; - -function isMultiOwnerLightAccount( - account: SmartAccount, -): account is MultiOwnerLightAccount { - return ( - "smartAccountType" in account && - account.smartAccountType === "MultiOwnerLightAccount" - ); -} - -/** - * Generates client actions for a multi-owner light account, including the ability to update owners. - * - * @param {Client} client The client instance used to interact with the account - * @returns {MultiOwnerLightAccountActions} An object containing the client actions specifically for a multi-owner light account - */ -export function multiOwnerLightAccountActions< - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TAccount extends SmartAccount | undefined = SmartAccount | undefined, ->( - client: Client, -): MultiOwnerLightAccountActions< - IsUndefined extends true ? undefined : MultiOwnerLightAccount -> { - return { - // TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that - // implicitly do a sendUserOperation internally. These are non-composable with batching - // and have a number of other issues that are solved with viem writeContract. - updateOwners: async (args) => { - const { ownersToAdd, ownersToRemove, account = client.account } = args; - - if (!account || !isMultiOwnerLightAccount(account)) { - throw new AccountNotFoundError(); - } - - const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove); - - const action = getAction(client, sendUserOperation, "sendUserOperation"); - const result = await action({ - calls: [ - { - to: account.address, - data, - }, - ], - account, - }); - - return result; - }, - }; -} diff --git a/packages/smart-accounts/src/light-account/decorators/singleOwner.ts b/packages/smart-accounts/src/light-account/decorators/singleOwner.ts deleted file mode 100644 index 282906116d..0000000000 --- a/packages/smart-accounts/src/light-account/decorators/singleOwner.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { AccountNotFoundError } from "@alchemy/common"; -import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem"; -import { sendUserOperation, type SmartAccount } from "viem/account-abstraction"; -import { getAction } from "viem/utils"; -import type { GetAccountParameter } from "../../types.js"; -import type { LightAccount } from "../accounts/account.js"; - -export type LightAccountActions< - TAccount extends LightAccount | undefined = LightAccount | undefined, -> = { - transferOwnership: ( - args: { - newOwner: Address; - } & GetAccountParameter, - ) => Promise; -}; - -function isLightAccount(account: SmartAccount): account is LightAccount { - return ( - "smartAccountType" in account && account.smartAccountType === "LightAccount" - ); -} - -/** - * A decorator that can be used with viem's bundler client to add light account actions to the client - * - * @param {BundlerClient} client The client instance for which to provide the light account actions - * @returns {LightAccountActions} An object containing the available light account actions - */ -export function singleOwnerLightAccountActions< - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TAccount extends SmartAccount | undefined = SmartAccount | undefined, ->( - client: Client, -): LightAccountActions< - IsUndefined extends true ? undefined : LightAccount -> { - return { - transferOwnership: async (args) => { - const { newOwner, account = client.account } = args; - - if (!account || !isLightAccount(account)) { - throw new AccountNotFoundError(); - } - - const data = account.encodeTransferOwnership(newOwner); - - const action = getAction(client, sendUserOperation, "sendUserOperation"); - const result = await action({ - calls: [ - { - to: account.address, - data, - }, - ], - account, - }); - - return result; - }, - }; -} diff --git a/packages/smart-accounts/src/light-account/utils.ts b/packages/smart-accounts/src/light-account/utils.ts index b7c5af8d2f..96192a7013 100644 --- a/packages/smart-accounts/src/light-account/utils.ts +++ b/packages/smart-accounts/src/light-account/utils.ts @@ -6,12 +6,6 @@ import type { LightAccountBase } from "./accounts/base.js"; import type { LightAccountType, LightAccountVersion } from "./registry.js"; import { AccountVersionRegistry } from "./registry.js"; -// TODO(v5): The pattern of getDefaultXYZAddress(…) doesn’t really make sense as a standalone. -// We built this expecting lots of diverging addresses per chain, but in practice we have none -// (and we’ve turned down things that require this). Instead: we could build the -// default-but-overridable behavior into the consuming functions themselves (i.e. -// createLightAccount defaulting to a factory address, but make it overridable) - /** * Get the default light account version for the given light account type * diff --git a/packages/smart-accounts/src/ma-v1/accounts/base.ts b/packages/smart-accounts/src/ma-v1/accounts/base.ts index 75998a3246..a7d234ea51 100644 --- a/packages/smart-accounts/src/ma-v1/accounts/base.ts +++ b/packages/smart-accounts/src/ma-v1/accounts/base.ts @@ -160,7 +160,7 @@ export async function toModularAccountV1Base< ); const { type, data } = await prepareSignature({ type: "eth_signTypedData_v4", - data: params as TypedDataDefinition, // TODO(v5): try harder to avoid this cast? + data: params as TypedDataDefinition, }); return type === "personal_sign" ? signMessageAction({ account: owner, message: data }) diff --git a/packages/smart-accounts/src/ma-v1/accounts/multi-owner-account.test.ts b/packages/smart-accounts/src/ma-v1/accounts/multi-owner-account.test.ts index 960b1e11a2..43c786a153 100644 --- a/packages/smart-accounts/src/ma-v1/accounts/multi-owner-account.test.ts +++ b/packages/smart-accounts/src/ma-v1/accounts/multi-owner-account.test.ts @@ -24,7 +24,6 @@ import { } from "viem/account-abstraction"; import { estimateFeesPerGas } from "@alchemy/aa-infra"; import { toMultiOwnerModularAccountV1 } from "./multi-owner-account.js"; -import { multiOwnerModularAccountV1Actions } from "../decorators/multiOwner.js"; import { setBalance } from "viem/actions"; // Note: These tests maintain a shared state to not break the local-running rundler by desyncing the chain. @@ -236,9 +235,16 @@ describe("MA v1 Account Tests", async () => { value: parseEther("10"), }); - const hash = await throwawayClient.updateOwners({ - ownersToAdd: [signer.address, ...otherOwners.map((o) => o.address)], - ownersToRemove: [throwawaySigner.address], + const hash = await throwawayClient.sendUserOperation({ + calls: [ + { + to: throwawayClient.account.address, + data: throwawayClient.account.encodeUpdateOwners( + [signer.address, ...otherOwners.map((o) => o.address)], + [throwawaySigner.address], + ), + }, + ], }); await throwawayClient.waitForUserOperationReceipt({ hash }); @@ -425,7 +431,7 @@ describe("MA v1 Account Tests", async () => { userOperation: { estimateFeesPerGas, }, - }).extend(multiOwnerModularAccountV1Actions); + }); }; const sortOwners = (owners: Address[] | readonly Address[]): Address[] => diff --git a/packages/smart-accounts/src/ma-v1/decorators/multiOwner.ts b/packages/smart-accounts/src/ma-v1/decorators/multiOwner.ts deleted file mode 100644 index 3addfd7a1e..0000000000 --- a/packages/smart-accounts/src/ma-v1/decorators/multiOwner.ts +++ /dev/null @@ -1,72 +0,0 @@ -import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem"; -import { sendUserOperation, type SmartAccount } from "viem/account-abstraction"; -import { getAction } from "viem/utils"; -import type { GetAccountParameter } from "../../types.js"; -import { AccountNotFoundError } from "@alchemy/common"; -import type { MultiOwnerModularAccountV1 } from "../accounts/multi-owner-account.js"; - -export type MultiOwnerModularAccountV1Actions< - TAccount extends MultiOwnerModularAccountV1 | undefined = - | MultiOwnerModularAccountV1 - | undefined, -> = { - updateOwners: ( - args: { - ownersToAdd: Address[]; - ownersToRemove: Address[]; - } & GetAccountParameter, - ) => Promise; -}; - -function isMultiOwnerModularAccountV1( - account: SmartAccount, -): account is MultiOwnerModularAccountV1 { - return ( - "smartAccountType" in account && - account.smartAccountType === "MultiOwnerModularAccountV1" - ); -} - -/** - * Generates client actions for a multi-owner MAv1 account, including the ability to update owners. - * - * @param {Client} client The client instance used to interact with the account - * @returns {MultiOwnerLightAccountActions} An object containing the client actions specifically for a multi-owner modular account - */ -export function multiOwnerModularAccountV1Actions< - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TAccount extends SmartAccount | undefined = SmartAccount | undefined, ->( - client: Client, -): MultiOwnerModularAccountV1Actions< - IsUndefined extends true ? undefined : MultiOwnerModularAccountV1 -> { - return { - // TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that - // implicitly do a sendUserOperation internally. These are non-composable with batching - // and have a number of other issues that are solved with viem writeContract. - updateOwners: async (args) => { - const { ownersToAdd, ownersToRemove, account = client.account } = args; - - if (!account || !isMultiOwnerModularAccountV1(account)) { - throw new AccountNotFoundError(); - } - - const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove); - - const action = getAction(client, sendUserOperation, "sendUserOperation"); - const result = await action({ - calls: [ - { - to: account.address, - data, - }, - ], - account, - }); - - return result; - }, - }; -} diff --git a/packages/smart-accounts/src/ma-v1/mav1StaticImpl.ts b/packages/smart-accounts/src/ma-v1/mav1StaticImpl.ts index 36fd9357f4..e39d5c0e8d 100644 --- a/packages/smart-accounts/src/ma-v1/mav1StaticImpl.ts +++ b/packages/smart-accounts/src/ma-v1/mav1StaticImpl.ts @@ -14,8 +14,6 @@ export type MultiOwnerModularAccountV1FactoryArgs = { /** * Static implementation logic for ModularAccountV1. - * - * TODO(v5): update JSDoc format when doc-gen supports structs or records. */ export const multiOwnerModularAccountStaticImpl: StaticSmartAccountImplementation< false, diff --git a/packages/smart-accounts/src/ma-v2/accounts/account.test.ts b/packages/smart-accounts/src/ma-v2/accounts/account.test.ts index e247735eb5..a483addb36 100644 --- a/packages/smart-accounts/src/ma-v2/accounts/account.test.ts +++ b/packages/smart-accounts/src/ma-v2/accounts/account.test.ts @@ -294,7 +294,7 @@ describe("MA v2 Account Tests", async () => { }); // UO deploys the account to test 1271 against - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -309,6 +309,10 @@ describe("MA v2 Account Tests", async () => { }), hooks: [], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); @@ -365,7 +369,7 @@ describe("MA v2 Account Tests", async () => { }); // UO deploys the account to test 1271 against - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -380,6 +384,10 @@ describe("MA v2 Account Tests", async () => { }), hooks: [], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); @@ -571,7 +579,7 @@ describe("MA v2 Account Tests", async () => { value: parseEther("2"), }); - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -586,6 +594,10 @@ describe("MA v2 Account Tests", async () => { }), hooks: [], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); @@ -945,7 +957,7 @@ describe("MA v2 Account Tests", async () => { // First, install a session key with installValidation access // (needed to sign deferred actions that install other keys) - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: sessionKeyEntityId, @@ -964,6 +976,10 @@ describe("MA v2 Account Tests", async () => { }), hooks: [], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); @@ -1055,7 +1071,7 @@ describe("MA v2 Account Tests", async () => { value: parseEther("2"), }); - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -1070,10 +1086,14 @@ describe("MA v2 Account Tests", async () => { }), hooks: [], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); - const hash2 = await provider.uninstallValidation({ + const callData2 = await provider.encodeUninstallValidation({ moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, uninstallData: SingleSignerValidationModule.encodeOnUninstallData({ @@ -1081,6 +1101,10 @@ describe("MA v2 Account Tests", async () => { }), hookUninstallDatas: [], }); + const hash2 = await provider.sendUserOperation({ + callData: callData2, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash: hash2, @@ -1127,7 +1151,7 @@ describe("MA v2 Account Tests", async () => { paymaster: paymaster, }); - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -1153,6 +1177,10 @@ describe("MA v2 Account Tests", async () => { }, ], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); // verify hook installation succeeded await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); @@ -1188,7 +1216,7 @@ describe("MA v2 Account Tests", async () => { entityId: 1, }); - const hash3 = await provider.uninstallValidation({ + const callData3 = await provider.encodeUninstallValidation({ moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, uninstallData: SingleSignerValidationModule.encodeOnUninstallData({ @@ -1196,6 +1224,10 @@ describe("MA v2 Account Tests", async () => { }), hookUninstallDatas: [hookUninstallData], }); + const hash3 = await provider.sendUserOperation({ + callData: callData3, + account: provider.account, + }); // verify uninstall await expect( @@ -1223,7 +1255,7 @@ describe("MA v2 Account Tests", async () => { paymaster: paymaster, }); - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -1249,6 +1281,10 @@ describe("MA v2 Account Tests", async () => { }, ], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); // verify hook installation succeeded await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); @@ -1279,7 +1315,7 @@ describe("MA v2 Account Tests", async () => { entityId: 1, }); - const hash2 = await provider.uninstallValidation({ + const callData2 = await provider.encodeUninstallValidation({ moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, uninstallData: SingleSignerValidationModule.encodeOnUninstallData({ @@ -1287,6 +1323,10 @@ describe("MA v2 Account Tests", async () => { }), hookUninstallDatas: [hookUninstallData], }); + const hash2 = await provider.sendUserOperation({ + callData: callData2, + account: provider.account, + }); // verify uninstall await expect( @@ -1305,7 +1345,7 @@ describe("MA v2 Account Tests", async () => { }); // install validation module - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -1320,6 +1360,10 @@ describe("MA v2 Account Tests", async () => { }), hooks: [], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); @@ -1362,7 +1406,7 @@ describe("MA v2 Account Tests", async () => { }); // install hook - const hash3 = await provider.installValidation({ + const callData3 = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -1385,6 +1429,10 @@ describe("MA v2 Account Tests", async () => { }, ], }); + const hash3 = await provider.sendUserOperation({ + callData: callData3, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash: hash3, @@ -1434,7 +1482,7 @@ describe("MA v2 Account Tests", async () => { ], }); - const hash5 = await provider.uninstallValidation({ + const callData5 = await provider.encodeUninstallValidation({ moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, uninstallData: SingleSignerValidationModule.encodeOnUninstallData({ @@ -1442,6 +1490,10 @@ describe("MA v2 Account Tests", async () => { }), hookUninstallDatas: [hookUninstallData], }); + const hash5 = await provider.sendUserOperation({ + callData: callData5, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash: hash5, @@ -1464,7 +1516,7 @@ describe("MA v2 Account Tests", async () => { const spendLimit = parseEther("0.5"); - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -1503,6 +1555,10 @@ describe("MA v2 Account Tests", async () => { }, ], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); @@ -1543,7 +1599,7 @@ describe("MA v2 Account Tests", async () => { }), ).rejects.toThrowError(); - const hash5 = await provider.uninstallValidation({ + const callData5 = await provider.encodeUninstallValidation({ moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, uninstallData: SingleSignerValidationModule.encodeOnUninstallData({ @@ -1556,6 +1612,10 @@ describe("MA v2 Account Tests", async () => { "0x", ], }); + const hash5 = await provider.sendUserOperation({ + callData: callData5, + account: provider.account, + }); await provider.waitForUserOperationReceipt({ hash: hash5, @@ -1591,7 +1651,7 @@ describe("MA v2 Account Tests", async () => { validUntil: 1934507101, }); - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -1617,6 +1677,10 @@ describe("MA v2 Account Tests", async () => { }, ], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); // verify hook installation succeeded await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); @@ -1718,7 +1782,7 @@ describe("MA v2 Account Tests", async () => { validUntil: 1934507101, }); - const hash = await provider.installValidation({ + const callData = await provider.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 2, @@ -1744,6 +1808,10 @@ describe("MA v2 Account Tests", async () => { }, ], }); + const hash = await provider.sendUserOperation({ + callData, + account: provider.account, + }); // verify hook installation succeeded await provider.waitForUserOperationReceipt({ hash, timeout: 30_000 }); @@ -1873,7 +1941,7 @@ describe("MA v2 Account Tests", async () => { } // deploy the account and install at entity id 1 with global validation - const hash = await newClient.installValidation({ + const callData = await newClient.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 1, @@ -1888,6 +1956,10 @@ describe("MA v2 Account Tests", async () => { }), hooks: [], }); + const hash = await newClient.sendUserOperation({ + callData, + account: newClient.account, + }); await newClient.waitForUserOperationReceipt({ hash, timeout: 30_000 }); const fns: ContractFunctionName[] = [ @@ -1904,7 +1976,7 @@ describe("MA v2 Account Tests", async () => { ); // deploy the account and install some entity ids with selector validation - const hash2 = await newClient.installValidation({ + const callData2 = await newClient.encodeInstallValidation({ validationConfig: { moduleAddress: DefaultModuleAddress.SINGLE_SIGNER_VALIDATION, entityId: 2, @@ -1919,6 +1991,10 @@ describe("MA v2 Account Tests", async () => { }), hooks: [], }); + const hash2 = await newClient.sendUserOperation({ + callData: callData2, + account: newClient.account, + }); await newClient.waitForUserOperationReceipt({ hash: hash2, timeout: 30_000, @@ -1993,12 +2069,40 @@ describe("MA v2 Account Tests", async () => { ], }); - await lightAccountClient.waitForUserOperationReceipt({ + const receipt = await lightAccountClient.waitForUserOperationReceipt({ hash, timeout: 30_000, }); - // TODO(v5): should we verify anything here? v4 test did not. + expect(receipt.success).toBe(true); + + // Verify the upgraded account works as MAv2 by sending a UO + const mav2Provider = await givenConnectedProvider({ + signer: owner, + accountAddress: lightAccount.address, + }); + + const startingAddressBalance = await getTargetBalance(); + + const mav2Hash = await mav2Provider.sendUserOperation({ + calls: [ + { + to: target, + value: sendAmount, + data: "0x", + }, + ], + }); + + const mav2Receipt = await mav2Provider.waitForUserOperationReceipt({ + hash: mav2Hash, + timeout: 30_000, + }); + + expect(mav2Receipt.success).toBe(true); + await expect(getTargetBalance()).resolves.toEqual( + startingAddressBalance + sendAmount, + ); }); it( diff --git a/packages/smart-accounts/src/ma-v2/accounts/account.ts b/packages/smart-accounts/src/ma-v2/accounts/account.ts index 0f771d1876..d2d2c85f49 100644 --- a/packages/smart-accounts/src/ma-v2/accounts/account.ts +++ b/packages/smart-accounts/src/ma-v2/accounts/account.ts @@ -27,7 +27,7 @@ import { LOGGER } from "../../logger.js"; type Mode = "default" | "7702"; -// TODO(v5): does this need to be extended w/ any more methods like LightAccount does? +// This may be extended in the future with additional MAv2-specific methods. export type ModularAccountV2 = ModularAccountV2Base & {}; export type ToModularAccountV2Params< @@ -193,6 +193,6 @@ export async function toModularAccountV2({ return { ...base, - // TODO(v5): does this need to be extended w/ any more methods like LightAccount does? + // This may be extended in the future with additional MAv2-specific methods. }; } diff --git a/packages/smart-accounts/src/ma-v2/accounts/base.ts b/packages/smart-accounts/src/ma-v2/accounts/base.ts index 334ecd5391..0b620d823c 100644 --- a/packages/smart-accounts/src/ma-v2/accounts/base.ts +++ b/packages/smart-accounts/src/ma-v2/accounts/base.ts @@ -380,7 +380,7 @@ export async function toModularAccountV2Base< const { data } = await prepareSignature({ type: "eth_signTypedData_v4", - data: td as TypedDataDefinition, // TODO(v5): Try harder to satisfy this w/o casting. + data: td as TypedDataDefinition, }); const action = getAction(client, signTypedData, "signTypedData"); diff --git a/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts b/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts index eb3850da66..bd2f8708a4 100644 --- a/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts +++ b/packages/smart-accounts/src/ma-v2/decorators/installValidation.ts @@ -13,8 +13,7 @@ import type { HookConfig, ValidationConfig } from "../types.js"; import type { ModularAccountV2 } from "../accounts/account.js"; import type { GetAccountParameter } from "../../types.js"; import { semiModularAccountBytecodeAbi } from "../abis/semiModularAccountBytecodeAbi.js"; -import { type SmartAccount, sendUserOperation } from "viem/account-abstraction"; -import { getAction } from "viem/utils"; +import type { SmartAccount } from "viem/account-abstraction"; import { AccountNotFoundError } from "@alchemy/common"; import { EntityIdOverrideError } from "../../errors/EntityIdOverrideError.js"; import { @@ -54,33 +53,26 @@ export type InstallValidationActions< encodeInstallValidation: ( args: InstallValidationParams, ) => Promise; - installValidation: (args: InstallValidationParams) => Promise; encodeUninstallValidation: ( args: UninstallValidationParams, ) => Promise; - uninstallValidation: ( - args: UninstallValidationParams, - ) => Promise; }; -// TODO(v5): update jsdoc /** - * Provides validation installation and uninstallation functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`. + * Provides validation installation and uninstallation encoding functionalities for a MA v2 client. * * @example * ```ts - * import { createModularAccountV2Client, installValidationActions, getDefaultSingleSignerValidationModuleAddress, SingleSignerValidationModule } from "@alchemy/smart-accounts"; + * import { installValidationActions, SingleSignerValidationModule } from "@alchemy/smart-accounts"; * import { Address } from "viem"; * * const client = (await createModularAccountV2Client({ ... })).extend(installValidationActions); * const sessionKeyAddress: Address = "0x1234"; * const sessionKeyEntityId: number = 1; * - * await client.installValidation({ + * const callData = await client.encodeInstallValidation({ * validationConfig: { - * moduleAddress: getDefaultSingleSignerValidationModuleAddress( - * client.chain - * ), + * moduleAddress: getDefaultSingleSignerValidationModuleAddress(client.chain), * entityId: sessionKeyEntityId, * isGlobal: true, * isSignatureValidation: false, @@ -94,19 +86,11 @@ export type InstallValidationActions< * hooks: [], * }); * - * await client.uninstallValidation({ - * moduleAddress: sessionKeyAddress, - * entityId: sessionKeyEntityId, - * uninstallData: SingleSignerValidationModule.encodeOnUninstallData({ - * entityId: sessionKeyEntityId, - * }), - * hookUninstallDatas: [], - * }); - * + * await client.sendUserOperation({ callData, account }); * ``` * - * @param {object} client - The client instance which provides account and sendUserOperation functionality. - * @returns {object} - An object containing two methods, `installValidation` and `uninstallValidation`. + * @param {object} client - The client instance which provides account functionality. + * @returns {object} - An object containing `encodeInstallValidation` and `encodeUninstallValidation`. */ export function installValidationActions< TTransport extends Transport = Transport, @@ -194,64 +178,5 @@ export function installValidationActions< return { encodeInstallValidation, encodeUninstallValidation, - installValidation: async (args) => { - const { - validationConfig, - selectors, - installData, - hooks, - account = client.account, - } = args; - - if (!account || !isModularAccountV2(account)) { - throw new AccountNotFoundError(); - } - - const callData = await encodeInstallValidation({ - validationConfig, - selectors, - installData, - hooks, - account, - }); - - const action = getAction(client, sendUserOperation, "sendUserOperation"); - const result = await action({ - callData, - account, - }); - - return result; - }, - - uninstallValidation: async (args) => { - const { - moduleAddress, - entityId, - uninstallData, - hookUninstallDatas, - account = client.account, - } = args; - - if (!account || !isModularAccountV2(account)) { - throw new AccountNotFoundError(); - } - - const callData = await encodeUninstallValidation({ - moduleAddress, - entityId, - uninstallData, - hookUninstallDatas, - account, - }); - - const action = getAction(client, sendUserOperation, "sendUserOperation"); - const result = await action({ - callData, - account, - }); - - return result; - }, }; } diff --git a/packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts b/packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts index dc274dcd6b..dd183f4d11 100644 --- a/packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts +++ b/packages/smart-accounts/src/ma-v2/mav2StaticImpl.ts @@ -36,8 +36,6 @@ const semiModularAccountBase = { /** * Static implementation logic for SemiModularAccountV2. - * - * TODO(v5): update JSDoc format when doc-gen supports structs or records. */ export const semiModularAccountV2StaticImpl: SemiModularAccountV2StaticImpl = { ...semiModularAccountBase, @@ -73,8 +71,6 @@ export type SemiModularAccount7702StaticImpl = StaticSmartAccountImplementation< /** * Static implementation logic for SemiModularAccount7702. - * - * TODO(v5): update JSDoc format when doc-gen supports structs or records. */ export const semiModularAccount7702StaticImpl: SemiModularAccount7702StaticImpl = { diff --git a/packages/smart-accounts/src/ma-v2/utils/account.ts b/packages/smart-accounts/src/ma-v2/utils/account.ts index dbb8ccd0ab..5c90cfc681 100644 --- a/packages/smart-accounts/src/ma-v2/utils/account.ts +++ b/packages/smart-accounts/src/ma-v2/utils/account.ts @@ -64,8 +64,6 @@ export async function getMAV2UpgradeToData( return { implAddress: DefaultAddress.SMAV2_STORAGE, initializationData: initData, - // TODO(v5): do we need `createModularAccountV2FromExisting()` in the return type here like we had in v4 or no? - // Almost certainly not, but we need to clean up other parts in SDK for client-side upgrades. }; }