@alchemy/smart-accounts 5.0.0-beta.4 → 5.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +0 -2
  2. package/dist/esm/index.d.ts +0 -6
  3. package/dist/esm/index.js +0 -3
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/esm/light-account/accounts/base.js +0 -1
  6. package/dist/esm/light-account/accounts/base.js.map +1 -1
  7. package/dist/esm/light-account/utils.js +0 -5
  8. package/dist/esm/light-account/utils.js.map +1 -1
  9. package/dist/esm/ma-v1/accounts/base.js +1 -1
  10. package/dist/esm/ma-v1/accounts/base.js.map +1 -1
  11. package/dist/esm/ma-v1/mav1StaticImpl.d.ts +0 -2
  12. package/dist/esm/ma-v1/mav1StaticImpl.js +0 -2
  13. package/dist/esm/ma-v1/mav1StaticImpl.js.map +1 -1
  14. package/dist/esm/ma-v2/accounts/account.js +1 -1
  15. package/dist/esm/ma-v2/accounts/account.js.map +1 -1
  16. package/dist/esm/ma-v2/accounts/base.js +1 -1
  17. package/dist/esm/ma-v2/accounts/base.js.map +1 -1
  18. package/dist/esm/ma-v2/decorators/installValidation.d.ts +8 -20
  19. package/dist/esm/ma-v2/decorators/installValidation.js +7 -58
  20. package/dist/esm/ma-v2/decorators/installValidation.js.map +1 -1
  21. package/dist/esm/ma-v2/mav2StaticImpl.d.ts +0 -4
  22. package/dist/esm/ma-v2/mav2StaticImpl.js +0 -4
  23. package/dist/esm/ma-v2/mav2StaticImpl.js.map +1 -1
  24. package/dist/esm/ma-v2/utils/account.js +0 -2
  25. package/dist/esm/ma-v2/utils/account.js.map +1 -1
  26. package/dist/esm/version.d.ts +1 -1
  27. package/dist/esm/version.js +1 -1
  28. package/dist/esm/version.js.map +1 -1
  29. package/dist/types/index.d.ts +0 -6
  30. package/dist/types/index.d.ts.map +1 -1
  31. package/dist/types/light-account/accounts/base.d.ts.map +1 -1
  32. package/dist/types/light-account/utils.d.ts.map +1 -1
  33. package/dist/types/ma-v1/mav1StaticImpl.d.ts +0 -2
  34. package/dist/types/ma-v1/mav1StaticImpl.d.ts.map +1 -1
  35. package/dist/types/ma-v2/decorators/installValidation.d.ts +8 -20
  36. package/dist/types/ma-v2/decorators/installValidation.d.ts.map +1 -1
  37. package/dist/types/ma-v2/mav2StaticImpl.d.ts +0 -4
  38. package/dist/types/ma-v2/mav2StaticImpl.d.ts.map +1 -1
  39. package/dist/types/ma-v2/utils/account.d.ts.map +1 -1
  40. package/dist/types/version.d.ts +1 -1
  41. package/package.json +4 -4
  42. package/src/index.ts +0 -13
  43. package/src/light-account/accounts/base.ts +0 -1
  44. package/src/light-account/utils.ts +0 -6
  45. package/src/ma-v1/accounts/base.ts +1 -1
  46. package/src/ma-v1/mav1StaticImpl.ts +0 -2
  47. package/src/ma-v2/accounts/account.ts +2 -2
  48. package/src/ma-v2/accounts/base.ts +1 -1
  49. package/src/ma-v2/decorators/installValidation.ts +8 -83
  50. package/src/ma-v2/mav2StaticImpl.ts +0 -4
  51. package/src/ma-v2/utils/account.ts +0 -2
  52. package/src/version.ts +1 -1
  53. package/dist/esm/light-account/decorators/multiOwner.d.ts +0 -17
  54. package/dist/esm/light-account/decorators/multiOwner.js +0 -39
  55. package/dist/esm/light-account/decorators/multiOwner.js.map +0 -1
  56. package/dist/esm/light-account/decorators/singleOwner.d.ts +0 -16
  57. package/dist/esm/light-account/decorators/singleOwner.js +0 -35
  58. package/dist/esm/light-account/decorators/singleOwner.js.map +0 -1
  59. package/dist/esm/ma-v1/decorators/multiOwner.d.ts +0 -17
  60. package/dist/esm/ma-v1/decorators/multiOwner.js +0 -39
  61. package/dist/esm/ma-v1/decorators/multiOwner.js.map +0 -1
  62. package/dist/types/light-account/decorators/multiOwner.d.ts +0 -18
  63. package/dist/types/light-account/decorators/multiOwner.d.ts.map +0 -1
  64. package/dist/types/light-account/decorators/singleOwner.d.ts +0 -17
  65. package/dist/types/light-account/decorators/singleOwner.d.ts.map +0 -1
  66. package/dist/types/ma-v1/decorators/multiOwner.d.ts +0 -18
  67. package/dist/types/ma-v1/decorators/multiOwner.d.ts.map +0 -1
  68. package/src/light-account/decorators/multiOwner.ts +0 -72
  69. package/src/light-account/decorators/singleOwner.ts +0 -63
  70. package/src/ma-v1/decorators/multiOwner.ts +0 -72
@@ -13,8 +13,7 @@ import type { HookConfig, ValidationConfig } from "../types.js";
13
13
  import type { ModularAccountV2 } from "../accounts/account.js";
14
14
  import type { GetAccountParameter } from "../../types.js";
15
15
  import { semiModularAccountBytecodeAbi } from "../abis/semiModularAccountBytecodeAbi.js";
16
- import { type SmartAccount, sendUserOperation } from "viem/account-abstraction";
17
- import { getAction } from "viem/utils";
16
+ import type { SmartAccount } from "viem/account-abstraction";
18
17
  import { AccountNotFoundError } from "@alchemy/common";
19
18
  import { EntityIdOverrideError } from "../../errors/EntityIdOverrideError.js";
20
19
  import {
@@ -54,33 +53,26 @@ export type InstallValidationActions<
54
53
  encodeInstallValidation: (
55
54
  args: InstallValidationParams<TAccount>,
56
55
  ) => Promise<Hex>;
57
- installValidation: (args: InstallValidationParams<TAccount>) => Promise<Hex>;
58
56
  encodeUninstallValidation: (
59
57
  args: UninstallValidationParams<TAccount>,
60
58
  ) => Promise<Hex>;
61
- uninstallValidation: (
62
- args: UninstallValidationParams<TAccount>,
63
- ) => Promise<Hex>;
64
59
  };
65
60
 
66
- // TODO(v5): update jsdoc
67
61
  /**
68
- * Provides validation installation and uninstallation functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`.
62
+ * Provides validation installation and uninstallation encoding functionalities for a MA v2 client.
69
63
  *
70
64
  * @example
71
65
  * ```ts
72
- * import { createModularAccountV2Client, installValidationActions, getDefaultSingleSignerValidationModuleAddress, SingleSignerValidationModule } from "@alchemy/smart-accounts";
66
+ * import { installValidationActions, SingleSignerValidationModule } from "@alchemy/smart-accounts";
73
67
  * import { Address } from "viem";
74
68
  *
75
69
  * const client = (await createModularAccountV2Client({ ... })).extend(installValidationActions);
76
70
  * const sessionKeyAddress: Address = "0x1234";
77
71
  * const sessionKeyEntityId: number = 1;
78
72
  *
79
- * await client.installValidation({
73
+ * const callData = await client.encodeInstallValidation({
80
74
  * validationConfig: {
81
- * moduleAddress: getDefaultSingleSignerValidationModuleAddress(
82
- * client.chain
83
- * ),
75
+ * moduleAddress: getDefaultSingleSignerValidationModuleAddress(client.chain),
84
76
  * entityId: sessionKeyEntityId,
85
77
  * isGlobal: true,
86
78
  * isSignatureValidation: false,
@@ -94,19 +86,11 @@ export type InstallValidationActions<
94
86
  * hooks: [],
95
87
  * });
96
88
  *
97
- * await client.uninstallValidation({
98
- * moduleAddress: sessionKeyAddress,
99
- * entityId: sessionKeyEntityId,
100
- * uninstallData: SingleSignerValidationModule.encodeOnUninstallData({
101
- * entityId: sessionKeyEntityId,
102
- * }),
103
- * hookUninstallDatas: [],
104
- * });
105
- *
89
+ * await client.sendUserOperation({ callData, account });
106
90
  * ```
107
91
  *
108
- * @param {object} client - The client instance which provides account and sendUserOperation functionality.
109
- * @returns {object} - An object containing two methods, `installValidation` and `uninstallValidation`.
92
+ * @param {object} client - The client instance which provides account functionality.
93
+ * @returns {object} - An object containing `encodeInstallValidation` and `encodeUninstallValidation`.
110
94
  */
111
95
  export function installValidationActions<
112
96
  TTransport extends Transport = Transport,
@@ -194,64 +178,5 @@ export function installValidationActions<
194
178
  return {
195
179
  encodeInstallValidation,
196
180
  encodeUninstallValidation,
197
- installValidation: async (args) => {
198
- const {
199
- validationConfig,
200
- selectors,
201
- installData,
202
- hooks,
203
- account = client.account,
204
- } = args;
205
-
206
- if (!account || !isModularAccountV2(account)) {
207
- throw new AccountNotFoundError();
208
- }
209
-
210
- const callData = await encodeInstallValidation({
211
- validationConfig,
212
- selectors,
213
- installData,
214
- hooks,
215
- account,
216
- });
217
-
218
- const action = getAction(client, sendUserOperation, "sendUserOperation");
219
- const result = await action({
220
- callData,
221
- account,
222
- });
223
-
224
- return result;
225
- },
226
-
227
- uninstallValidation: async (args) => {
228
- const {
229
- moduleAddress,
230
- entityId,
231
- uninstallData,
232
- hookUninstallDatas,
233
- account = client.account,
234
- } = args;
235
-
236
- if (!account || !isModularAccountV2(account)) {
237
- throw new AccountNotFoundError();
238
- }
239
-
240
- const callData = await encodeUninstallValidation({
241
- moduleAddress,
242
- entityId,
243
- uninstallData,
244
- hookUninstallDatas,
245
- account,
246
- });
247
-
248
- const action = getAction(client, sendUserOperation, "sendUserOperation");
249
- const result = await action({
250
- callData,
251
- account,
252
- });
253
-
254
- return result;
255
- },
256
181
  };
257
182
  }
@@ -36,8 +36,6 @@ const semiModularAccountBase = {
36
36
 
37
37
  /**
38
38
  * Static implementation logic for SemiModularAccountV2.
39
- *
40
- * TODO(v5): update JSDoc format when doc-gen supports structs or records.
41
39
  */
42
40
  export const semiModularAccountV2StaticImpl: SemiModularAccountV2StaticImpl = {
43
41
  ...semiModularAccountBase,
@@ -73,8 +71,6 @@ export type SemiModularAccount7702StaticImpl = StaticSmartAccountImplementation<
73
71
 
74
72
  /**
75
73
  * Static implementation logic for SemiModularAccount7702.
76
- *
77
- * TODO(v5): update JSDoc format when doc-gen supports structs or records.
78
74
  */
79
75
  export const semiModularAccount7702StaticImpl: SemiModularAccount7702StaticImpl =
80
76
  {
@@ -64,8 +64,6 @@ export async function getMAV2UpgradeToData(
64
64
  return {
65
65
  implAddress: DefaultAddress.SMAV2_STORAGE,
66
66
  initializationData: initData,
67
- // TODO(v5): do we need `createModularAccountV2FromExisting()` in the return type here like we had in v4 or no?
68
- // Almost certainly not, but we need to clean up other parts in SDK for client-side upgrades.
69
67
  };
70
68
  }
71
69
 
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "5.0.0-beta.4";
3
+ export const VERSION = "5.0.0-beta.6";
@@ -1,17 +0,0 @@
1
- import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
2
- import { type SmartAccount } from "viem/account-abstraction";
3
- import type { GetAccountParameter } from "../../types.js";
4
- import type { MultiOwnerLightAccount } from "../accounts/multi-owner-account.js";
5
- export type MultiOwnerLightAccountActions<TAccount extends MultiOwnerLightAccount | undefined = MultiOwnerLightAccount | undefined> = {
6
- updateOwners: (args: {
7
- ownersToAdd: Address[];
8
- ownersToRemove: Address[];
9
- } & GetAccountParameter<TAccount, MultiOwnerLightAccount>) => Promise<Hex>;
10
- };
11
- /**
12
- * Generates client actions for a multi-owner light account, including the ability to update owners.
13
- *
14
- * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
15
- * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner light account
16
- */
17
- export declare function multiOwnerLightAccountActions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): MultiOwnerLightAccountActions<IsUndefined<TAccount> extends true ? undefined : MultiOwnerLightAccount>;
@@ -1,39 +0,0 @@
1
- import { sendUserOperation } from "viem/account-abstraction";
2
- import { getAction } from "viem/utils";
3
- import { AccountNotFoundError } from "@alchemy/common";
4
- function isMultiOwnerLightAccount(account) {
5
- return ("smartAccountType" in account &&
6
- account.smartAccountType === "MultiOwnerLightAccount");
7
- }
8
- /**
9
- * Generates client actions for a multi-owner light account, including the ability to update owners.
10
- *
11
- * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
12
- * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner light account
13
- */
14
- export function multiOwnerLightAccountActions(client) {
15
- return {
16
- // TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that
17
- // implicitly do a sendUserOperation internally. These are non-composable with batching
18
- // and have a number of other issues that are solved with viem writeContract.
19
- updateOwners: async (args) => {
20
- const { ownersToAdd, ownersToRemove, account = client.account } = args;
21
- if (!account || !isMultiOwnerLightAccount(account)) {
22
- throw new AccountNotFoundError();
23
- }
24
- const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);
25
- const action = getAction(client, sendUserOperation, "sendUserOperation");
26
- const result = await action({
27
- calls: [
28
- {
29
- to: account.address,
30
- data,
31
- },
32
- ],
33
- account,
34
- });
35
- return result;
36
- },
37
- };
38
- }
39
- //# sourceMappingURL=multiOwner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multiOwner.js","sourceRoot":"","sources":["../../../../src/light-account/decorators/multiOwner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAevD,SAAS,wBAAwB,CAC/B,OAAqB;IAErB,OAAO,CACL,kBAAkB,IAAI,OAAO;QAC7B,OAAO,CAAC,gBAAgB,KAAK,wBAAwB,CACtD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAK3C,MAA4C;IAI5C,OAAO;QACL,yFAAyF;QACzF,uFAAuF;QACvF,6EAA6E;QAC7E,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC3B,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;YAEvE,IAAI,CAAC,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,MAAM,IAAI,oBAAoB,EAAE,CAAC;YACnC,CAAC;YAED,MAAM,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAErE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;YACzE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC;gBAC1B,KAAK,EAAE;oBACL;wBACE,EAAE,EAAE,OAAO,CAAC,OAAO;wBACnB,IAAI;qBACL;iBACF;gBACD,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Address, Chain, Client, Hex, IsUndefined, Transport } from \"viem\";\nimport { sendUserOperation, type SmartAccount } from \"viem/account-abstraction\";\nimport { getAction } from \"viem/utils\";\nimport type { GetAccountParameter } from \"../../types.js\";\nimport type { MultiOwnerLightAccount } from \"../accounts/multi-owner-account.js\";\nimport { AccountNotFoundError } from \"@alchemy/common\";\n\nexport type MultiOwnerLightAccountActions<\n TAccount extends MultiOwnerLightAccount | undefined =\n | MultiOwnerLightAccount\n | undefined,\n> = {\n updateOwners: (\n args: {\n ownersToAdd: Address[];\n ownersToRemove: Address[];\n } & GetAccountParameter<TAccount, MultiOwnerLightAccount>,\n ) => Promise<Hex>;\n};\n\nfunction isMultiOwnerLightAccount(\n account: SmartAccount,\n): account is MultiOwnerLightAccount {\n return (\n \"smartAccountType\" in account &&\n account.smartAccountType === \"MultiOwnerLightAccount\"\n );\n}\n\n/**\n * Generates client actions for a multi-owner light account, including the ability to update owners.\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account\n * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner light account\n */\nexport function multiOwnerLightAccountActions<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n): MultiOwnerLightAccountActions<\n IsUndefined<TAccount> extends true ? undefined : MultiOwnerLightAccount\n> {\n return {\n // TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that\n // implicitly do a sendUserOperation internally. These are non-composable with batching\n // and have a number of other issues that are solved with viem writeContract.\n updateOwners: async (args) => {\n const { ownersToAdd, ownersToRemove, account = client.account } = args;\n\n if (!account || !isMultiOwnerLightAccount(account)) {\n throw new AccountNotFoundError();\n }\n\n const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);\n\n const action = getAction(client, sendUserOperation, \"sendUserOperation\");\n const result = await action({\n calls: [\n {\n to: account.address,\n data,\n },\n ],\n account,\n });\n\n return result;\n },\n };\n}\n"]}
@@ -1,16 +0,0 @@
1
- import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
2
- import { type SmartAccount } from "viem/account-abstraction";
3
- import type { GetAccountParameter } from "../../types.js";
4
- import type { LightAccount } from "../accounts/account.js";
5
- export type LightAccountActions<TAccount extends LightAccount | undefined = LightAccount | undefined> = {
6
- transferOwnership: (args: {
7
- newOwner: Address;
8
- } & GetAccountParameter<TAccount, LightAccount>) => Promise<Hex>;
9
- };
10
- /**
11
- * A decorator that can be used with viem's bundler client to add light account actions to the client
12
- *
13
- * @param {BundlerClient<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions
14
- * @returns {LightAccountActions<TAccount>} An object containing the available light account actions
15
- */
16
- export declare function singleOwnerLightAccountActions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): LightAccountActions<IsUndefined<TAccount> extends true ? undefined : LightAccount>;
@@ -1,35 +0,0 @@
1
- import { AccountNotFoundError } from "@alchemy/common";
2
- import { sendUserOperation } from "viem/account-abstraction";
3
- import { getAction } from "viem/utils";
4
- function isLightAccount(account) {
5
- return ("smartAccountType" in account && account.smartAccountType === "LightAccount");
6
- }
7
- /**
8
- * A decorator that can be used with viem's bundler client to add light account actions to the client
9
- *
10
- * @param {BundlerClient<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions
11
- * @returns {LightAccountActions<TAccount>} An object containing the available light account actions
12
- */
13
- export function singleOwnerLightAccountActions(client) {
14
- return {
15
- transferOwnership: async (args) => {
16
- const { newOwner, account = client.account } = args;
17
- if (!account || !isLightAccount(account)) {
18
- throw new AccountNotFoundError();
19
- }
20
- const data = account.encodeTransferOwnership(newOwner);
21
- const action = getAction(client, sendUserOperation, "sendUserOperation");
22
- const result = await action({
23
- calls: [
24
- {
25
- to: account.address,
26
- data,
27
- },
28
- ],
29
- account,
30
- });
31
- return result;
32
- },
33
- };
34
- }
35
- //# sourceMappingURL=singleOwner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"singleOwner.js","sourceRoot":"","sources":["../../../../src/light-account/decorators/singleOwner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAqB,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAcvC,SAAS,cAAc,CAAC,OAAqB;IAC3C,OAAO,CACL,kBAAkB,IAAI,OAAO,IAAI,OAAO,CAAC,gBAAgB,KAAK,cAAc,CAC7E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAK5C,MAA4C;IAI5C,OAAO;QACL,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAChC,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;YAEpD,IAAI,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;gBACzC,MAAM,IAAI,oBAAoB,EAAE,CAAC;YACnC,CAAC;YAED,MAAM,IAAI,GAAG,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;YAEvD,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;YACzE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC;gBAC1B,KAAK,EAAE;oBACL;wBACE,EAAE,EAAE,OAAO,CAAC,OAAO;wBACnB,IAAI;qBACL;iBACF;gBACD,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { AccountNotFoundError } from \"@alchemy/common\";\nimport type { Address, Chain, Client, Hex, IsUndefined, Transport } from \"viem\";\nimport { sendUserOperation, type SmartAccount } from \"viem/account-abstraction\";\nimport { getAction } from \"viem/utils\";\nimport type { GetAccountParameter } from \"../../types.js\";\nimport type { LightAccount } from \"../accounts/account.js\";\n\nexport type LightAccountActions<\n TAccount extends LightAccount | undefined = LightAccount | undefined,\n> = {\n transferOwnership: (\n args: {\n newOwner: Address;\n } & GetAccountParameter<TAccount, LightAccount>,\n ) => Promise<Hex>;\n};\n\nfunction isLightAccount(account: SmartAccount): account is LightAccount {\n return (\n \"smartAccountType\" in account && account.smartAccountType === \"LightAccount\"\n );\n}\n\n/**\n * A decorator that can be used with viem's bundler client to add light account actions to the client\n *\n * @param {BundlerClient<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions\n * @returns {LightAccountActions<TAccount>} An object containing the available light account actions\n */\nexport function singleOwnerLightAccountActions<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n): LightAccountActions<\n IsUndefined<TAccount> extends true ? undefined : LightAccount\n> {\n return {\n transferOwnership: async (args) => {\n const { newOwner, account = client.account } = args;\n\n if (!account || !isLightAccount(account)) {\n throw new AccountNotFoundError();\n }\n\n const data = account.encodeTransferOwnership(newOwner);\n\n const action = getAction(client, sendUserOperation, \"sendUserOperation\");\n const result = await action({\n calls: [\n {\n to: account.address,\n data,\n },\n ],\n account,\n });\n\n return result;\n },\n };\n}\n"]}
@@ -1,17 +0,0 @@
1
- import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
2
- import { type SmartAccount } from "viem/account-abstraction";
3
- import type { GetAccountParameter } from "../../types.js";
4
- import type { MultiOwnerModularAccountV1 } from "../accounts/multi-owner-account.js";
5
- export type MultiOwnerModularAccountV1Actions<TAccount extends MultiOwnerModularAccountV1 | undefined = MultiOwnerModularAccountV1 | undefined> = {
6
- updateOwners: (args: {
7
- ownersToAdd: Address[];
8
- ownersToRemove: Address[];
9
- } & GetAccountParameter<TAccount, MultiOwnerModularAccountV1>) => Promise<Hex>;
10
- };
11
- /**
12
- * Generates client actions for a multi-owner MAv1 account, including the ability to update owners.
13
- *
14
- * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
15
- * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner modular account
16
- */
17
- export declare function multiOwnerModularAccountV1Actions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): MultiOwnerModularAccountV1Actions<IsUndefined<TAccount> extends true ? undefined : MultiOwnerModularAccountV1>;
@@ -1,39 +0,0 @@
1
- import { sendUserOperation } from "viem/account-abstraction";
2
- import { getAction } from "viem/utils";
3
- import { AccountNotFoundError } from "@alchemy/common";
4
- function isMultiOwnerModularAccountV1(account) {
5
- return ("smartAccountType" in account &&
6
- account.smartAccountType === "MultiOwnerModularAccountV1");
7
- }
8
- /**
9
- * Generates client actions for a multi-owner MAv1 account, including the ability to update owners.
10
- *
11
- * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
12
- * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner modular account
13
- */
14
- export function multiOwnerModularAccountV1Actions(client) {
15
- return {
16
- // TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that
17
- // implicitly do a sendUserOperation internally. These are non-composable with batching
18
- // and have a number of other issues that are solved with viem writeContract.
19
- updateOwners: async (args) => {
20
- const { ownersToAdd, ownersToRemove, account = client.account } = args;
21
- if (!account || !isMultiOwnerModularAccountV1(account)) {
22
- throw new AccountNotFoundError();
23
- }
24
- const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);
25
- const action = getAction(client, sendUserOperation, "sendUserOperation");
26
- const result = await action({
27
- calls: [
28
- {
29
- to: account.address,
30
- data,
31
- },
32
- ],
33
- account,
34
- });
35
- return result;
36
- },
37
- };
38
- }
39
- //# sourceMappingURL=multiOwner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multiOwner.js","sourceRoot":"","sources":["../../../../src/ma-v1/decorators/multiOwner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAgBvD,SAAS,4BAA4B,CACnC,OAAqB;IAErB,OAAO,CACL,kBAAkB,IAAI,OAAO;QAC7B,OAAO,CAAC,gBAAgB,KAAK,4BAA4B,CAC1D,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAK/C,MAA4C;IAI5C,OAAO;QACL,yFAAyF;QACzF,uFAAuF;QACvF,6EAA6E;QAC7E,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC3B,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;YAEvE,IAAI,CAAC,OAAO,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvD,MAAM,IAAI,oBAAoB,EAAE,CAAC;YACnC,CAAC;YAED,MAAM,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAErE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;YACzE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC;gBAC1B,KAAK,EAAE;oBACL;wBACE,EAAE,EAAE,OAAO,CAAC,OAAO;wBACnB,IAAI;qBACL;iBACF;gBACD,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Address, Chain, Client, Hex, IsUndefined, Transport } from \"viem\";\nimport { sendUserOperation, type SmartAccount } from \"viem/account-abstraction\";\nimport { getAction } from \"viem/utils\";\nimport type { GetAccountParameter } from \"../../types.js\";\nimport { AccountNotFoundError } from \"@alchemy/common\";\nimport type { MultiOwnerModularAccountV1 } from \"../accounts/multi-owner-account.js\";\n\nexport type MultiOwnerModularAccountV1Actions<\n TAccount extends MultiOwnerModularAccountV1 | undefined =\n | MultiOwnerModularAccountV1\n | undefined,\n> = {\n updateOwners: (\n args: {\n ownersToAdd: Address[];\n ownersToRemove: Address[];\n } & GetAccountParameter<TAccount, MultiOwnerModularAccountV1>,\n ) => Promise<Hex>;\n};\n\nfunction isMultiOwnerModularAccountV1(\n account: SmartAccount,\n): account is MultiOwnerModularAccountV1 {\n return (\n \"smartAccountType\" in account &&\n account.smartAccountType === \"MultiOwnerModularAccountV1\"\n );\n}\n\n/**\n * Generates client actions for a multi-owner MAv1 account, including the ability to update owners.\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account\n * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner modular account\n */\nexport function multiOwnerModularAccountV1Actions<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n): MultiOwnerModularAccountV1Actions<\n IsUndefined<TAccount> extends true ? undefined : MultiOwnerModularAccountV1\n> {\n return {\n // TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that\n // implicitly do a sendUserOperation internally. These are non-composable with batching\n // and have a number of other issues that are solved with viem writeContract.\n updateOwners: async (args) => {\n const { ownersToAdd, ownersToRemove, account = client.account } = args;\n\n if (!account || !isMultiOwnerModularAccountV1(account)) {\n throw new AccountNotFoundError();\n }\n\n const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);\n\n const action = getAction(client, sendUserOperation, \"sendUserOperation\");\n const result = await action({\n calls: [\n {\n to: account.address,\n data,\n },\n ],\n account,\n });\n\n return result;\n },\n };\n}\n"]}
@@ -1,18 +0,0 @@
1
- import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
2
- import { type SmartAccount } from "viem/account-abstraction";
3
- import type { GetAccountParameter } from "../../types.js";
4
- import type { MultiOwnerLightAccount } from "../accounts/multi-owner-account.js";
5
- export type MultiOwnerLightAccountActions<TAccount extends MultiOwnerLightAccount | undefined = MultiOwnerLightAccount | undefined> = {
6
- updateOwners: (args: {
7
- ownersToAdd: Address[];
8
- ownersToRemove: Address[];
9
- } & GetAccountParameter<TAccount, MultiOwnerLightAccount>) => Promise<Hex>;
10
- };
11
- /**
12
- * Generates client actions for a multi-owner light account, including the ability to update owners.
13
- *
14
- * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
15
- * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner light account
16
- */
17
- export declare function multiOwnerLightAccountActions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): MultiOwnerLightAccountActions<IsUndefined<TAccount> extends true ? undefined : MultiOwnerLightAccount>;
18
- //# sourceMappingURL=multiOwner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multiOwner.d.ts","sourceRoot":"","sources":["../../../../src/light-account/decorators/multiOwner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAGjF,MAAM,MAAM,6BAA6B,CACvC,QAAQ,SAAS,sBAAsB,GAAG,SAAS,GAC/C,sBAAsB,GACtB,SAAS,IACX;IACF,YAAY,EAAE,CACZ,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO,EAAE,CAAC;QACvB,cAAc,EAAE,OAAO,EAAE,CAAC;KAC3B,GAAG,mBAAmB,CAAC,QAAQ,EAAE,sBAAsB,CAAC,KACtD,OAAO,CAAC,GAAG,CAAC,CAAC;CACnB,CAAC;AAWF;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,EAEpE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,GAC3C,6BAA6B,CAC9B,WAAW,CAAC,QAAQ,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,sBAAsB,CACxE,CA4BA"}
@@ -1,17 +0,0 @@
1
- import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
2
- import { type SmartAccount } from "viem/account-abstraction";
3
- import type { GetAccountParameter } from "../../types.js";
4
- import type { LightAccount } from "../accounts/account.js";
5
- export type LightAccountActions<TAccount extends LightAccount | undefined = LightAccount | undefined> = {
6
- transferOwnership: (args: {
7
- newOwner: Address;
8
- } & GetAccountParameter<TAccount, LightAccount>) => Promise<Hex>;
9
- };
10
- /**
11
- * A decorator that can be used with viem's bundler client to add light account actions to the client
12
- *
13
- * @param {BundlerClient<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions
14
- * @returns {LightAccountActions<TAccount>} An object containing the available light account actions
15
- */
16
- export declare function singleOwnerLightAccountActions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): LightAccountActions<IsUndefined<TAccount> extends true ? undefined : LightAccount>;
17
- //# sourceMappingURL=singleOwner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"singleOwner.d.ts","sourceRoot":"","sources":["../../../../src/light-account/decorators/singleOwner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,MAAM,mBAAmB,CAC7B,QAAQ,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,IAClE;IACF,iBAAiB,EAAE,CACjB,IAAI,EAAE;QACJ,QAAQ,EAAE,OAAO,CAAC;KACnB,GAAG,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,KAC5C,OAAO,CAAC,GAAG,CAAC,CAAC;CACnB,CAAC;AAQF;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,EAEpE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,GAC3C,mBAAmB,CACpB,WAAW,CAAC,QAAQ,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,YAAY,CAC9D,CAyBA"}
@@ -1,18 +0,0 @@
1
- import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
2
- import { type SmartAccount } from "viem/account-abstraction";
3
- import type { GetAccountParameter } from "../../types.js";
4
- import type { MultiOwnerModularAccountV1 } from "../accounts/multi-owner-account.js";
5
- export type MultiOwnerModularAccountV1Actions<TAccount extends MultiOwnerModularAccountV1 | undefined = MultiOwnerModularAccountV1 | undefined> = {
6
- updateOwners: (args: {
7
- ownersToAdd: Address[];
8
- ownersToRemove: Address[];
9
- } & GetAccountParameter<TAccount, MultiOwnerModularAccountV1>) => Promise<Hex>;
10
- };
11
- /**
12
- * Generates client actions for a multi-owner MAv1 account, including the ability to update owners.
13
- *
14
- * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
15
- * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner modular account
16
- */
17
- export declare function multiOwnerModularAccountV1Actions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): MultiOwnerModularAccountV1Actions<IsUndefined<TAccount> extends true ? undefined : MultiOwnerModularAccountV1>;
18
- //# sourceMappingURL=multiOwner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multiOwner.d.ts","sourceRoot":"","sources":["../../../../src/ma-v1/decorators/multiOwner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAErF,MAAM,MAAM,iCAAiC,CAC3C,QAAQ,SAAS,0BAA0B,GAAG,SAAS,GACnD,0BAA0B,GAC1B,SAAS,IACX;IACF,YAAY,EAAE,CACZ,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO,EAAE,CAAC;QACvB,cAAc,EAAE,OAAO,EAAE,CAAC;KAC3B,GAAG,mBAAmB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,KAC1D,OAAO,CAAC,GAAG,CAAC,CAAC;CACnB,CAAC;AAWF;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,EAEpE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,GAC3C,iCAAiC,CAClC,WAAW,CAAC,QAAQ,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,0BAA0B,CAC5E,CA4BA"}
@@ -1,72 +0,0 @@
1
- import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
2
- import { sendUserOperation, type SmartAccount } from "viem/account-abstraction";
3
- import { getAction } from "viem/utils";
4
- import type { GetAccountParameter } from "../../types.js";
5
- import type { MultiOwnerLightAccount } from "../accounts/multi-owner-account.js";
6
- import { AccountNotFoundError } from "@alchemy/common";
7
-
8
- export type MultiOwnerLightAccountActions<
9
- TAccount extends MultiOwnerLightAccount | undefined =
10
- | MultiOwnerLightAccount
11
- | undefined,
12
- > = {
13
- updateOwners: (
14
- args: {
15
- ownersToAdd: Address[];
16
- ownersToRemove: Address[];
17
- } & GetAccountParameter<TAccount, MultiOwnerLightAccount>,
18
- ) => Promise<Hex>;
19
- };
20
-
21
- function isMultiOwnerLightAccount(
22
- account: SmartAccount,
23
- ): account is MultiOwnerLightAccount {
24
- return (
25
- "smartAccountType" in account &&
26
- account.smartAccountType === "MultiOwnerLightAccount"
27
- );
28
- }
29
-
30
- /**
31
- * Generates client actions for a multi-owner light account, including the ability to update owners.
32
- *
33
- * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
34
- * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner light account
35
- */
36
- export function multiOwnerLightAccountActions<
37
- TTransport extends Transport = Transport,
38
- TChain extends Chain | undefined = Chain | undefined,
39
- TAccount extends SmartAccount | undefined = SmartAccount | undefined,
40
- >(
41
- client: Client<TTransport, TChain, TAccount>,
42
- ): MultiOwnerLightAccountActions<
43
- IsUndefined<TAccount> extends true ? undefined : MultiOwnerLightAccount
44
- > {
45
- return {
46
- // TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that
47
- // implicitly do a sendUserOperation internally. These are non-composable with batching
48
- // and have a number of other issues that are solved with viem writeContract.
49
- updateOwners: async (args) => {
50
- const { ownersToAdd, ownersToRemove, account = client.account } = args;
51
-
52
- if (!account || !isMultiOwnerLightAccount(account)) {
53
- throw new AccountNotFoundError();
54
- }
55
-
56
- const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);
57
-
58
- const action = getAction(client, sendUserOperation, "sendUserOperation");
59
- const result = await action({
60
- calls: [
61
- {
62
- to: account.address,
63
- data,
64
- },
65
- ],
66
- account,
67
- });
68
-
69
- return result;
70
- },
71
- };
72
- }
@@ -1,63 +0,0 @@
1
- import { AccountNotFoundError } from "@alchemy/common";
2
- import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
3
- import { sendUserOperation, type SmartAccount } from "viem/account-abstraction";
4
- import { getAction } from "viem/utils";
5
- import type { GetAccountParameter } from "../../types.js";
6
- import type { LightAccount } from "../accounts/account.js";
7
-
8
- export type LightAccountActions<
9
- TAccount extends LightAccount | undefined = LightAccount | undefined,
10
- > = {
11
- transferOwnership: (
12
- args: {
13
- newOwner: Address;
14
- } & GetAccountParameter<TAccount, LightAccount>,
15
- ) => Promise<Hex>;
16
- };
17
-
18
- function isLightAccount(account: SmartAccount): account is LightAccount {
19
- return (
20
- "smartAccountType" in account && account.smartAccountType === "LightAccount"
21
- );
22
- }
23
-
24
- /**
25
- * A decorator that can be used with viem's bundler client to add light account actions to the client
26
- *
27
- * @param {BundlerClient<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions
28
- * @returns {LightAccountActions<TAccount>} An object containing the available light account actions
29
- */
30
- export function singleOwnerLightAccountActions<
31
- TTransport extends Transport = Transport,
32
- TChain extends Chain | undefined = Chain | undefined,
33
- TAccount extends SmartAccount | undefined = SmartAccount | undefined,
34
- >(
35
- client: Client<TTransport, TChain, TAccount>,
36
- ): LightAccountActions<
37
- IsUndefined<TAccount> extends true ? undefined : LightAccount
38
- > {
39
- return {
40
- transferOwnership: async (args) => {
41
- const { newOwner, account = client.account } = args;
42
-
43
- if (!account || !isLightAccount(account)) {
44
- throw new AccountNotFoundError();
45
- }
46
-
47
- const data = account.encodeTransferOwnership(newOwner);
48
-
49
- const action = getAction(client, sendUserOperation, "sendUserOperation");
50
- const result = await action({
51
- calls: [
52
- {
53
- to: account.address,
54
- data,
55
- },
56
- ],
57
- account,
58
- });
59
-
60
- return result;
61
- },
62
- };
63
- }