@alchemy/smart-accounts 5.0.0-beta.2 → 5.0.0-beta.21

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 (91) hide show
  1. package/README.md +0 -2
  2. package/dist/esm/index.d.ts +3 -6
  3. package/dist/esm/index.js +3 -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/accounts/calldataCodec.d.ts +17 -0
  8. package/dist/esm/light-account/accounts/calldataCodec.js +17 -0
  9. package/dist/esm/light-account/accounts/calldataCodec.js.map +1 -1
  10. package/dist/esm/light-account/utils.js +0 -5
  11. package/dist/esm/light-account/utils.js.map +1 -1
  12. package/dist/esm/ma-v1/accounts/base.js +6 -50
  13. package/dist/esm/ma-v1/accounts/base.js.map +1 -1
  14. package/dist/esm/ma-v1/accounts/calldataCodec.d.ts +20 -0
  15. package/dist/esm/ma-v1/accounts/calldataCodec.js +69 -0
  16. package/dist/esm/ma-v1/accounts/calldataCodec.js.map +1 -0
  17. package/dist/esm/ma-v1/mav1StaticImpl.d.ts +0 -2
  18. package/dist/esm/ma-v1/mav1StaticImpl.js +0 -2
  19. package/dist/esm/ma-v1/mav1StaticImpl.js.map +1 -1
  20. package/dist/esm/ma-v2/accounts/account.js +1 -1
  21. package/dist/esm/ma-v2/accounts/account.js.map +1 -1
  22. package/dist/esm/ma-v2/accounts/base.js +7 -54
  23. package/dist/esm/ma-v2/accounts/base.js.map +1 -1
  24. package/dist/esm/ma-v2/accounts/calldataCodec.d.ts +20 -0
  25. package/dist/esm/ma-v2/accounts/calldataCodec.js +77 -0
  26. package/dist/esm/ma-v2/accounts/calldataCodec.js.map +1 -0
  27. package/dist/esm/ma-v2/decorators/installValidation.d.ts +8 -20
  28. package/dist/esm/ma-v2/decorators/installValidation.js +7 -58
  29. package/dist/esm/ma-v2/decorators/installValidation.js.map +1 -1
  30. package/dist/esm/ma-v2/mav2StaticImpl.d.ts +0 -4
  31. package/dist/esm/ma-v2/mav2StaticImpl.js +0 -4
  32. package/dist/esm/ma-v2/mav2StaticImpl.js.map +1 -1
  33. package/dist/esm/ma-v2/utils/account.js +0 -2
  34. package/dist/esm/ma-v2/utils/account.js.map +1 -1
  35. package/dist/esm/version.d.ts +1 -1
  36. package/dist/esm/version.js +1 -1
  37. package/dist/esm/version.js.map +1 -1
  38. package/dist/types/index.d.ts +3 -6
  39. package/dist/types/index.d.ts.map +1 -1
  40. package/dist/types/light-account/accounts/base.d.ts.map +1 -1
  41. package/dist/types/light-account/accounts/calldataCodec.d.ts +17 -0
  42. package/dist/types/light-account/accounts/calldataCodec.d.ts.map +1 -1
  43. package/dist/types/light-account/utils.d.ts.map +1 -1
  44. package/dist/types/ma-v1/accounts/base.d.ts.map +1 -1
  45. package/dist/types/ma-v1/accounts/calldataCodec.d.ts +21 -0
  46. package/dist/types/ma-v1/accounts/calldataCodec.d.ts.map +1 -0
  47. package/dist/types/ma-v1/mav1StaticImpl.d.ts +0 -2
  48. package/dist/types/ma-v1/mav1StaticImpl.d.ts.map +1 -1
  49. package/dist/types/ma-v2/accounts/base.d.ts.map +1 -1
  50. package/dist/types/ma-v2/accounts/calldataCodec.d.ts +21 -0
  51. package/dist/types/ma-v2/accounts/calldataCodec.d.ts.map +1 -0
  52. package/dist/types/ma-v2/decorators/installValidation.d.ts +8 -20
  53. package/dist/types/ma-v2/decorators/installValidation.d.ts.map +1 -1
  54. package/dist/types/ma-v2/mav2StaticImpl.d.ts +0 -4
  55. package/dist/types/ma-v2/mav2StaticImpl.d.ts.map +1 -1
  56. package/dist/types/ma-v2/utils/account.d.ts.map +1 -1
  57. package/dist/types/version.d.ts +1 -1
  58. package/dist/types/version.d.ts.map +1 -1
  59. package/package.json +6 -6
  60. package/src/index.ts +15 -13
  61. package/src/light-account/accounts/base.ts +0 -1
  62. package/src/light-account/accounts/calldataCodec.ts +17 -0
  63. package/src/light-account/utils.ts +0 -6
  64. package/src/ma-v1/accounts/base.ts +4 -55
  65. package/src/ma-v1/accounts/calldataCodec.ts +80 -0
  66. package/src/ma-v1/mav1StaticImpl.ts +0 -2
  67. package/src/ma-v2/accounts/account.ts +2 -2
  68. package/src/ma-v2/accounts/base.ts +6 -68
  69. package/src/ma-v2/accounts/calldataCodec.ts +89 -0
  70. package/src/ma-v2/decorators/installValidation.ts +8 -83
  71. package/src/ma-v2/mav2StaticImpl.ts +0 -4
  72. package/src/ma-v2/utils/account.ts +0 -2
  73. package/src/version.ts +1 -1
  74. package/dist/esm/light-account/decorators/multiOwner.d.ts +0 -17
  75. package/dist/esm/light-account/decorators/multiOwner.js +0 -39
  76. package/dist/esm/light-account/decorators/multiOwner.js.map +0 -1
  77. package/dist/esm/light-account/decorators/singleOwner.d.ts +0 -16
  78. package/dist/esm/light-account/decorators/singleOwner.js +0 -35
  79. package/dist/esm/light-account/decorators/singleOwner.js.map +0 -1
  80. package/dist/esm/ma-v1/decorators/multiOwner.d.ts +0 -17
  81. package/dist/esm/ma-v1/decorators/multiOwner.js +0 -39
  82. package/dist/esm/ma-v1/decorators/multiOwner.js.map +0 -1
  83. package/dist/types/light-account/decorators/multiOwner.d.ts +0 -18
  84. package/dist/types/light-account/decorators/multiOwner.d.ts.map +0 -1
  85. package/dist/types/light-account/decorators/singleOwner.d.ts +0 -17
  86. package/dist/types/light-account/decorators/singleOwner.d.ts.map +0 -1
  87. package/dist/types/ma-v1/decorators/multiOwner.d.ts +0 -18
  88. package/dist/types/ma-v1/decorators/multiOwner.d.ts.map +0 -1
  89. package/src/light-account/decorators/multiOwner.ts +0 -72
  90. package/src/light-account/decorators/singleOwner.ts +0 -63
  91. package/src/ma-v1/decorators/multiOwner.ts +0 -72
@@ -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
- }
@@ -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 { AccountNotFoundError } from "@alchemy/common";
6
- import type { MultiOwnerModularAccountV1 } from "../accounts/multi-owner-account.js";
7
-
8
- export type MultiOwnerModularAccountV1Actions<
9
- TAccount extends MultiOwnerModularAccountV1 | undefined =
10
- | MultiOwnerModularAccountV1
11
- | undefined,
12
- > = {
13
- updateOwners: (
14
- args: {
15
- ownersToAdd: Address[];
16
- ownersToRemove: Address[];
17
- } & GetAccountParameter<TAccount, MultiOwnerModularAccountV1>,
18
- ) => Promise<Hex>;
19
- };
20
-
21
- function isMultiOwnerModularAccountV1(
22
- account: SmartAccount,
23
- ): account is MultiOwnerModularAccountV1 {
24
- return (
25
- "smartAccountType" in account &&
26
- account.smartAccountType === "MultiOwnerModularAccountV1"
27
- );
28
- }
29
-
30
- /**
31
- * Generates client actions for a multi-owner MAv1 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 modular account
35
- */
36
- export function multiOwnerModularAccountV1Actions<
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
- ): MultiOwnerModularAccountV1Actions<
43
- IsUndefined<TAccount> extends true ? undefined : MultiOwnerModularAccountV1
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 || !isMultiOwnerModularAccountV1(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
- }