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

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 (38) hide show
  1. package/dist/esm/index.d.ts +3 -0
  2. package/dist/esm/index.js +3 -0
  3. package/dist/esm/index.js.map +1 -1
  4. package/dist/esm/light-account/accounts/calldataCodec.d.ts +17 -0
  5. package/dist/esm/light-account/accounts/calldataCodec.js +20 -0
  6. package/dist/esm/light-account/accounts/calldataCodec.js.map +1 -1
  7. package/dist/esm/ma-v1/accounts/base.js +5 -49
  8. package/dist/esm/ma-v1/accounts/base.js.map +1 -1
  9. package/dist/esm/ma-v1/accounts/calldataCodec.d.ts +20 -0
  10. package/dist/esm/ma-v1/accounts/calldataCodec.js +73 -0
  11. package/dist/esm/ma-v1/accounts/calldataCodec.js.map +1 -0
  12. package/dist/esm/ma-v2/accounts/base.js +6 -53
  13. package/dist/esm/ma-v2/accounts/base.js.map +1 -1
  14. package/dist/esm/ma-v2/accounts/calldataCodec.d.ts +20 -0
  15. package/dist/esm/ma-v2/accounts/calldataCodec.js +81 -0
  16. package/dist/esm/ma-v2/accounts/calldataCodec.js.map +1 -0
  17. package/dist/esm/version.d.ts +1 -1
  18. package/dist/esm/version.js +1 -1
  19. package/dist/esm/version.js.map +1 -1
  20. package/dist/types/index.d.ts +3 -0
  21. package/dist/types/index.d.ts.map +1 -1
  22. package/dist/types/light-account/accounts/calldataCodec.d.ts +17 -0
  23. package/dist/types/light-account/accounts/calldataCodec.d.ts.map +1 -1
  24. package/dist/types/ma-v1/accounts/base.d.ts.map +1 -1
  25. package/dist/types/ma-v1/accounts/calldataCodec.d.ts +21 -0
  26. package/dist/types/ma-v1/accounts/calldataCodec.d.ts.map +1 -0
  27. package/dist/types/ma-v2/accounts/base.d.ts.map +1 -1
  28. package/dist/types/ma-v2/accounts/calldataCodec.d.ts +21 -0
  29. package/dist/types/ma-v2/accounts/calldataCodec.d.ts.map +1 -0
  30. package/dist/types/version.d.ts +1 -1
  31. package/package.json +4 -4
  32. package/src/index.ts +15 -0
  33. package/src/light-account/accounts/calldataCodec.ts +21 -0
  34. package/src/ma-v1/accounts/base.ts +3 -54
  35. package/src/ma-v1/accounts/calldataCodec.ts +85 -0
  36. package/src/ma-v2/accounts/base.ts +5 -67
  37. package/src/ma-v2/accounts/calldataCodec.ts +94 -0
  38. package/src/version.ts +1 -1
@@ -0,0 +1,20 @@
1
+ import { type Address, type Call, type Hex } from "viem";
2
+ /**
3
+ * Encodes an array of calls into ModularAccountV2 calldata for `execute` or `executeBatch`.
4
+ * Used internally by the ModularAccountV2 SmartAccount implementation. Typically not needed
5
+ * directly unless you have an advanced use case.
6
+ *
7
+ * @param {Call[]} calls The calls to encode.
8
+ * @returns {Hex} The encoded calldata.
9
+ */
10
+ export declare function encodeCallsMAv2(calls: readonly Call[]): Hex;
11
+ /**
12
+ * Decodes ModularAccountV2 calldata back into an array of calls. Strips the `EXECUTE_USER_OP_SELECTOR` prefix if present.
13
+ * Used internally by the ModularAccountV2 SmartAccount implementation. Typically not needed
14
+ * directly unless you have an advanced use case.
15
+ *
16
+ * @param {Hex} data The calldata to decode.
17
+ * @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.
18
+ * @returns {Call[]} The decoded calls.
19
+ */
20
+ export declare function decodeCallsMAv2(data: Hex, accountAddress: Address): Call[];
@@ -0,0 +1,81 @@
1
+ import { decodeFunctionData, encodeFunctionData, } from "viem";
2
+ import { sliceHex } from "viem/utils";
3
+ import { modularAccountAbi } from "../abis/modularAccountAbi.js";
4
+ import { EXECUTE_USER_OP_SELECTOR } from "../utils/account.js";
5
+ import { BaseError } from "@alchemy/common";
6
+ /**
7
+ * Encodes an array of calls into ModularAccountV2 calldata for `execute` or `executeBatch`.
8
+ * Used internally by the ModularAccountV2 SmartAccount implementation. Typically not needed
9
+ * directly unless you have an advanced use case.
10
+ *
11
+ * @param {Call[]} calls The calls to encode.
12
+ * @returns {Hex} The encoded calldata.
13
+ */
14
+ export function encodeCallsMAv2(calls) {
15
+ if (!calls.length) {
16
+ throw new BaseError("No calls to encode.");
17
+ }
18
+ if (calls.length === 1) {
19
+ return encodeFunctionData({
20
+ abi: modularAccountAbi,
21
+ functionName: "execute",
22
+ args: [calls[0].to, calls[0].value ?? 0n, calls[0].data ?? "0x"],
23
+ });
24
+ }
25
+ return encodeFunctionData({
26
+ abi: modularAccountAbi,
27
+ functionName: "executeBatch",
28
+ args: [
29
+ calls.map((call) => ({
30
+ target: call.to,
31
+ data: call.data ?? "0x",
32
+ value: call.value ?? 0n,
33
+ })),
34
+ ],
35
+ });
36
+ }
37
+ /**
38
+ * Decodes ModularAccountV2 calldata back into an array of calls. Strips the `EXECUTE_USER_OP_SELECTOR` prefix if present.
39
+ * Used internally by the ModularAccountV2 SmartAccount implementation. Typically not needed
40
+ * directly unless you have an advanced use case.
41
+ *
42
+ * @param {Hex} data The calldata to decode.
43
+ * @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.
44
+ * @returns {Call[]} The decoded calls.
45
+ */
46
+ export function decodeCallsMAv2(data, accountAddress) {
47
+ // Strip the EXECUTE_USER_OP_SELECTOR prefix if present.
48
+ const trimmedData = data
49
+ .toLowerCase()
50
+ .startsWith(EXECUTE_USER_OP_SELECTOR.toLowerCase())
51
+ ? sliceHex(data, 4)
52
+ : data;
53
+ const decoded = decodeFunctionData({
54
+ abi: modularAccountAbi,
55
+ data: trimmedData,
56
+ });
57
+ if (decoded.functionName === "execute") {
58
+ return [
59
+ {
60
+ to: decoded.args[0],
61
+ value: decoded.args[1],
62
+ data: decoded.args[2],
63
+ },
64
+ ];
65
+ }
66
+ if (decoded.functionName === "executeBatch") {
67
+ return decoded.args[0].map((call) => ({
68
+ to: call.target,
69
+ value: call.value,
70
+ data: call.data,
71
+ }));
72
+ }
73
+ // If the data is not for an `execute` or `executeBatch` call, treat it as a single call to the account itself.
74
+ return [
75
+ {
76
+ to: accountAddress,
77
+ data,
78
+ },
79
+ ];
80
+ }
81
+ //# sourceMappingURL=calldataCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calldataCodec.js","sourceRoot":"","sources":["../../../../src/ma-v2/accounts/calldataCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAInB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAsB;IACpD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,kBAAkB,CAAC;YACxB,GAAG,EAAE,iBAAiB;YACtB,YAAY,EAAE,SAAS;YACvB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC;SACjE,CAAC,CAAC;IACL,CAAC;IAED,OAAO,kBAAkB,CAAC;QACxB,GAAG,EAAE,iBAAiB;QACtB,YAAY,EAAE,cAAc;QAC5B,IAAI,EAAE;YACJ,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACnB,MAAM,EAAE,IAAI,CAAC,EAAE;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI;gBACvB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;aACxB,CAAC,CAAC;SACJ;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,IAAS,EAAE,cAAuB;IAChE,wDAAwD;IACxD,MAAM,WAAW,GAAG,IAAI;SACrB,WAAW,EAAE;SACb,UAAU,CAAC,wBAAwB,CAAC,WAAW,EAAE,CAAC;QACnD,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QACnB,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,OAAO,GAAG,kBAAkB,CAAC;QACjC,GAAG,EAAE,iBAAiB;QACtB,IAAI,EAAE,WAAW;KAClB,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO;YACL;gBACE,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;gBACnB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;gBACtB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;aACtB;SACF,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,YAAY,KAAK,cAAc,EAAE,CAAC;QAC5C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACpC,EAAE,EAAE,IAAI,CAAC,MAAM;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC,CAAC;IACN,CAAC;IAED,+GAA+G;IAC/G,OAAO;QACL;YACE,EAAE,EAAE,cAAc;YAClB,IAAI;SACL;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n decodeFunctionData,\n encodeFunctionData,\n type Address,\n type Call,\n type Hex,\n} from \"viem\";\nimport { sliceHex } from \"viem/utils\";\nimport { modularAccountAbi } from \"../abis/modularAccountAbi.js\";\nimport { EXECUTE_USER_OP_SELECTOR } from \"../utils/account.js\";\nimport { BaseError } from \"@alchemy/common\";\n\n/**\n * Encodes an array of calls into ModularAccountV2 calldata for `execute` or `executeBatch`.\n * Used internally by the ModularAccountV2 SmartAccount implementation. Typically not needed\n * directly unless you have an advanced use case.\n *\n * @param {Call[]} calls The calls to encode.\n * @returns {Hex} The encoded calldata.\n */\nexport function encodeCallsMAv2(calls: readonly Call[]): Hex {\n if (!calls.length) {\n throw new BaseError(\"No calls to encode.\");\n }\n\n if (calls.length === 1) {\n return encodeFunctionData({\n abi: modularAccountAbi,\n functionName: \"execute\",\n args: [calls[0].to, calls[0].value ?? 0n, calls[0].data ?? \"0x\"],\n });\n }\n\n return encodeFunctionData({\n abi: modularAccountAbi,\n functionName: \"executeBatch\",\n args: [\n calls.map((call) => ({\n target: call.to,\n data: call.data ?? \"0x\",\n value: call.value ?? 0n,\n })),\n ],\n });\n}\n\n/**\n * Decodes ModularAccountV2 calldata back into an array of calls. Strips the `EXECUTE_USER_OP_SELECTOR` prefix if present.\n * Used internally by the ModularAccountV2 SmartAccount implementation. Typically not needed\n * directly unless you have an advanced use case.\n *\n * @param {Hex} data The calldata to decode.\n * @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.\n * @returns {Call[]} The decoded calls.\n */\nexport function decodeCallsMAv2(data: Hex, accountAddress: Address): Call[] {\n // Strip the EXECUTE_USER_OP_SELECTOR prefix if present.\n const trimmedData = data\n .toLowerCase()\n .startsWith(EXECUTE_USER_OP_SELECTOR.toLowerCase())\n ? sliceHex(data, 4)\n : data;\n\n const decoded = decodeFunctionData({\n abi: modularAccountAbi,\n data: trimmedData,\n });\n\n if (decoded.functionName === \"execute\") {\n return [\n {\n to: decoded.args[0],\n value: decoded.args[1],\n data: decoded.args[2],\n },\n ];\n }\n\n if (decoded.functionName === \"executeBatch\") {\n return decoded.args[0].map((call) => ({\n to: call.target,\n value: call.value,\n data: call.data,\n }));\n }\n\n // If the data is not for an `execute` or `executeBatch` call, treat it as a single call to the account itself.\n return [\n {\n to: accountAddress,\n data,\n },\n ];\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "5.0.0-beta.1";
1
+ export declare const VERSION = "5.0.0-beta.2";
@@ -1,4 +1,4 @@
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.1";
3
+ export const VERSION = "5.0.0-beta.2";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.1\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.2\";\n"]}
@@ -12,6 +12,7 @@ export { predictLightAccountAddress, predictMultiOwnerLightAccountAddress, } fro
12
12
  export { AccountVersionRegistry } from "./light-account/registry.js";
13
13
  export type * from "./light-account/registry.js";
14
14
  export { defaultLightAccountVersion, getLightAccountImplAddress, LightAccountUnsupported1271Factories, LightAccountUnsupported1271Impls, } from "./light-account/utils.js";
15
+ export { encodeCallsLA, decodeCallsLA, } from "./light-account/accounts/calldataCodec.js";
15
16
  export { lightAccountStaticImplV1_0_1, lightAccountStaticImplV1_0_2, lightAccountStaticImplV1_1_0, lightAccountStaticImplV2_0_0, multiOwnerLightAccountStaticImplV2_0_0, } from "./light-account/lightAccountStaticImpl.js";
16
17
  export type * from "./ma-v1/accounts/base.js";
17
18
  export { toModularAccountV1Base } from "./ma-v1/accounts/base.js";
@@ -23,10 +24,12 @@ export type * from "./ma-v1/predictAddress.js";
23
24
  export { predictMultiOwnerModularAccountV1Address } from "./ma-v1/predictAddress.js";
24
25
  export { multiOwnerModularAccountStaticImpl } from "./ma-v1/mav1StaticImpl.js";
25
26
  export { DefaultMaV1Address, DefaultMaV1PluginAddress, } from "./ma-v1/account.js";
27
+ export { encodeCallsMAv1, decodeCallsMAv1, } from "./ma-v1/accounts/calldataCodec.js";
26
28
  export type * from "./ma-v2/accounts/account.js";
27
29
  export { toModularAccountV2 } from "./ma-v2/accounts/account.js";
28
30
  export type * from "./ma-v2/accounts/base.js";
29
31
  export { toModularAccountV2Base } from "./ma-v2/accounts/base.js";
32
+ export { encodeCallsMAv2, decodeCallsMAv2, } from "./ma-v2/accounts/calldataCodec.js";
30
33
  export type * from "./ma-v2/decorators/deferralActions.js";
31
34
  export { deferralActions } from "./ma-v2/decorators/deferralActions.js";
32
35
  export type * from "./ma-v2/decorators/installValidation.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAC;AAGhC,mBAAmB,qCAAqC,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,mBAAmB,iDAAiD,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAM3F,mBAAmB,2CAA2C,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAE3F,mBAAmB,0CAA0C,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AAEzF,mBAAmB,mCAAmC,CAAC;AACvD,OAAO,EACL,0BAA0B,EAC1B,oCAAoC,GACrC,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,mBAAmB,6BAA6B,CAAC;AACjD,OAA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O,EACL,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,mBAAmB,kCAAkC,CAAC;AACtD,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,kCAAkC,CAAC;AAE1C,mBAAmB,wBAAwB,CAAC;AAC5C,OAAO,EACL,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,mBAAmB,4BAA4B,CAAC;AAChD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,gCAAgC,EAChC,gBAAgB,EAChB,qBAAqB,EACrB,8BAA8B,EAC9B,kBAAkB,GACnB,MAAM,qCAAqC,CAAC"}
@@ -1,4 +1,21 @@
1
1
  import { type Address, type Call, type Hex } from "viem";
2
+ /**
3
+ * Encodes an array of calls into LightAccount calldata for `execute` or `executeBatch`.
4
+ * Used internally by the LightAccount SmartAccount implementation. Typically not needed
5
+ * directly unless you have an advanced use case.
6
+ *
7
+ * @param {Call[]} calls The calls to encode.
8
+ * @returns {Hex} The encoded calldata.
9
+ */
2
10
  export declare function encodeCallsLA(calls: readonly Call[]): Hex;
11
+ /**
12
+ * Decodes LightAccount calldata back into an array of calls.
13
+ * Used internally by the LightAccount SmartAccount implementation. Typically not needed
14
+ * directly unless you have an advanced use case.
15
+ *
16
+ * @param {Hex} data The calldata to decode.
17
+ * @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.
18
+ * @returns {Call[]} The decoded calls.
19
+ */
3
20
  export declare function decodeCallsLA(data: Hex, accountAddress: Address): Call[];
4
21
  //# sourceMappingURL=calldataCodec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"calldataCodec.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/calldataCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAMd,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,GAAG,CAyBzD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,GAAG,IAAI,EAAE,CAqDxE"}
1
+ {"version":3,"file":"calldataCodec.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/calldataCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAMd;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,GAAG,CA6BzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,GAAG,IAAI,EAAE,CAqDxE"}
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/ma-v1/accounts/base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,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AAE,MAAM,OAAO,CAAC;QAC5B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC9B,WAAW,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;KAC/B,CAAC,CAAC;IACH,aAAa,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC3D,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,EACA,MAAM,EACN,cAAc,EACd,KAAK,EACL,cAAc,EACd,aAAa,EACb,IAAI,GACL,EAAE,4BAA4B,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAuH1E"}
@@ -0,0 +1,21 @@
1
+ import { type Address, type Call, type Hex } from "viem";
2
+ /**
3
+ * Encodes an array of calls into ModularAccountV1 calldata for `execute` or `executeBatch`.
4
+ * Used internally by the ModularAccountV1 SmartAccount implementation. Typically not needed
5
+ * directly unless you have an advanced use case.
6
+ *
7
+ * @param {Call[]} calls The calls to encode.
8
+ * @returns {Hex} The encoded calldata.
9
+ */
10
+ export declare function encodeCallsMAv1(calls: readonly Call[]): Hex;
11
+ /**
12
+ * Decodes ModularAccountV1 calldata back into an array of calls.
13
+ * Used internally by the ModularAccountV1 SmartAccount implementation. Typically not needed
14
+ * directly unless you have an advanced use case.
15
+ *
16
+ * @param {Hex} data The calldata to decode.
17
+ * @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.
18
+ * @returns {Call[]} The decoded calls.
19
+ */
20
+ export declare function decodeCallsMAv1(data: Hex, accountAddress: Address): Call[];
21
+ //# sourceMappingURL=calldataCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calldataCodec.d.ts","sourceRoot":"","sources":["../../../../src/ma-v1/accounts/calldataCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAA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2BAA2B,CAAC,kCAAkC,CAAC,CAAC;AAElE,MAAM,MAAM,4BAA4B,CACtC,UAAU,SAAS,SAAS,GAAG,SAAS,IACtC;IACF,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAC7E,KAAK,EAAE,cAAc,GAAG,YAAY,CAAC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,MAAM,OAAO,CAAC;QAC5B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC9B,WAAW,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;KAC/B,CAAC,CAAC;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,aAAa,CAAC,EAAE,wBAAwB,CAAC,eAAe,CAAC,CAAC;CAC3D,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,EACA,MAAM,EACN,KAAK,EACL,cAAc,EACd,cAAc,EACd,YAGC,EACD,cAAc,EACd,aAAa,GACd,EAAE,4BAA4B,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4T1E"}
@@ -0,0 +1,21 @@
1
+ import { type Address, type Call, type Hex } from "viem";
2
+ /**
3
+ * Encodes an array of calls into ModularAccountV2 calldata for `execute` or `executeBatch`.
4
+ * Used internally by the ModularAccountV2 SmartAccount implementation. Typically not needed
5
+ * directly unless you have an advanced use case.
6
+ *
7
+ * @param {Call[]} calls The calls to encode.
8
+ * @returns {Hex} The encoded calldata.
9
+ */
10
+ export declare function encodeCallsMAv2(calls: readonly Call[]): Hex;
11
+ /**
12
+ * Decodes ModularAccountV2 calldata back into an array of calls. Strips the `EXECUTE_USER_OP_SELECTOR` prefix if present.
13
+ * Used internally by the ModularAccountV2 SmartAccount implementation. Typically not needed
14
+ * directly unless you have an advanced use case.
15
+ *
16
+ * @param {Hex} data The calldata to decode.
17
+ * @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.
18
+ * @returns {Call[]} The decoded calls.
19
+ */
20
+ export declare function decodeCallsMAv2(data: Hex, accountAddress: Address): Call[];
21
+ //# sourceMappingURL=calldataCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calldataCodec.d.ts","sourceRoot":"","sources":["../../../../src/ma-v2/accounts/calldataCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAMd;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,GAAG,CAwB3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,GAAG,IAAI,EAAE,CAsC1E"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.0.0-beta.1";
1
+ export declare const VERSION = "5.0.0-beta.2";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy/smart-accounts",
3
- "version": "5.0.0-beta.2",
3
+ "version": "5.0.0-beta.3",
4
4
  "description": "This package contains all of the viem interfaces for Alchemy's Smart Contract Accounts",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -39,12 +39,12 @@
39
39
  "test:run": "vitest run"
40
40
  },
41
41
  "devDependencies": {
42
- "@alchemy/aa-infra": "^5.0.0-beta.2",
42
+ "@alchemy/aa-infra": "^5.0.0-beta.3",
43
43
  "typescript-template": "*",
44
44
  "viem": "^2.45.0"
45
45
  },
46
46
  "dependencies": {
47
- "@alchemy/common": "^5.0.0-beta.2"
47
+ "@alchemy/common": "^5.0.0-beta.3"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "viem": "^2.45.0"
@@ -61,5 +61,5 @@
61
61
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
62
62
  },
63
63
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
64
- "gitHead": "9042002b7414ac2ae8a6251ee4cf96555b091eca"
64
+ "gitHead": "976c754b1859cce753bea18117c0716804f266c4"
65
65
  }
package/src/index.ts CHANGED
@@ -32,6 +32,11 @@ export {
32
32
  LightAccountUnsupported1271Impls,
33
33
  } from "./light-account/utils.js";
34
34
 
35
+ export {
36
+ encodeCallsLA,
37
+ decodeCallsLA,
38
+ } from "./light-account/accounts/calldataCodec.js";
39
+
35
40
  export {
36
41
  lightAccountStaticImplV1_0_1,
37
42
  lightAccountStaticImplV1_0_2,
@@ -60,6 +65,11 @@ export {
60
65
  DefaultMaV1PluginAddress,
61
66
  } from "./ma-v1/account.js";
62
67
 
68
+ export {
69
+ encodeCallsMAv1,
70
+ decodeCallsMAv1,
71
+ } from "./ma-v1/accounts/calldataCodec.js";
72
+
63
73
  // ModularAccountV2
64
74
  export type * from "./ma-v2/accounts/account.js";
65
75
  export { toModularAccountV2 } from "./ma-v2/accounts/account.js";
@@ -67,6 +77,11 @@ export { toModularAccountV2 } from "./ma-v2/accounts/account.js";
67
77
  export type * from "./ma-v2/accounts/base.js";
68
78
  export { toModularAccountV2Base } from "./ma-v2/accounts/base.js";
69
79
 
80
+ export {
81
+ encodeCallsMAv2,
82
+ decodeCallsMAv2,
83
+ } from "./ma-v2/accounts/calldataCodec.js";
84
+
70
85
  export type * from "./ma-v2/decorators/deferralActions.js";
71
86
  export { deferralActions } from "./ma-v2/decorators/deferralActions.js";
72
87
 
@@ -10,7 +10,19 @@ import { BaseError } from "@alchemy/common";
10
10
 
11
11
  // Conveniently, all variants of LA up to v2.0.0 use the same function signatures for `execute` and `executeBatch`.
12
12
 
13
+ /**
14
+ * Encodes an array of calls into LightAccount calldata for `execute` or `executeBatch`.
15
+ * Used internally by the LightAccount SmartAccount implementation. Typically not needed
16
+ * directly unless you have an advanced use case.
17
+ *
18
+ * @param {Call[]} calls The calls to encode.
19
+ * @returns {Hex} The encoded calldata.
20
+ */
13
21
  export function encodeCallsLA(calls: readonly Call[]): Hex {
22
+ if (!calls.length) {
23
+ throw new BaseError("No calls to encode.");
24
+ }
25
+
14
26
  if (calls.length === 1) {
15
27
  return encodeFunctionData({
16
28
  abi: LightAccountAbi_v1,
@@ -37,6 +49,15 @@ export function encodeCallsLA(calls: readonly Call[]): Hex {
37
49
  });
38
50
  }
39
51
 
52
+ /**
53
+ * Decodes LightAccount calldata back into an array of calls.
54
+ * Used internally by the LightAccount SmartAccount implementation. Typically not needed
55
+ * directly unless you have an advanced use case.
56
+ *
57
+ * @param {Hex} data The calldata to decode.
58
+ * @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.
59
+ * @returns {Call[]} The decoded calls.
60
+ */
40
61
  export function decodeCallsLA(data: Hex, accountAddress: Address): Call[] {
41
62
  const decoded = decodeFunctionData({
42
63
  abi: LightAccountAbi_v1,
@@ -8,7 +8,6 @@ import {
8
8
  type Transport,
9
9
  type Hash,
10
10
  type TypedDataDefinition,
11
- encodeFunctionData,
12
11
  } from "viem";
13
12
  import {
14
13
  entryPoint06Abi,
@@ -21,16 +20,15 @@ import type {
21
20
  SignatureRequest,
22
21
  SmartAccountWithDecodeCalls,
23
22
  } from "../../types.js";
24
- import { IStandardExecutorAbi } from "../abis/IStandardExecutor.js";
25
23
  import { signMessage, signTypedData } from "viem/actions";
26
24
  import {
27
- decodeFunctionData,
28
25
  getAction,
29
26
  hashMessage,
30
27
  hashTypedData,
31
28
  isAddressEqual,
32
29
  } from "viem/utils";
33
30
  import { BaseError } from "@alchemy/common";
31
+ import { encodeCallsMAv1, decodeCallsMAv1 } from "./calldataCodec.js";
34
32
 
35
33
  type MaV1AccountType = "MultiOwnerModularAccountV1"; // Currently no SDK v5 support for "MultiSigModularAccountV1".
36
34
 
@@ -112,10 +110,6 @@ export async function toModularAccountV1Base<
112
110
  },
113
111
 
114
112
  async encodeCalls(calls) {
115
- if (!calls.length) {
116
- throw new BaseError("No calls to encode.");
117
- }
118
-
119
113
  if (calls.length === 1) {
120
114
  const call = calls[0];
121
115
 
@@ -127,59 +121,14 @@ export async function toModularAccountV1Base<
127
121
 
128
122
  return call.data;
129
123
  }
130
-
131
- return encodeFunctionData({
132
- abi: IStandardExecutorAbi,
133
- functionName: "execute",
134
- args: [call.to, call.value ?? 0n, call.data ?? "0x"],
135
- });
136
124
  }
137
125
 
138
- return encodeFunctionData({
139
- abi: IStandardExecutorAbi,
140
- functionName: "executeBatch",
141
- args: [
142
- calls.map((call) => ({
143
- target: call.to,
144
- value: call.value ?? 0n,
145
- data: call.data ?? "0x",
146
- })),
147
- ],
148
- });
126
+ return encodeCallsMAv1(calls);
149
127
  },
150
128
 
151
129
  // Inverse of `encodeCalls`.
152
130
  async decodeCalls(data) {
153
- const decoded = decodeFunctionData({
154
- abi: IStandardExecutorAbi,
155
- data,
156
- });
157
-
158
- if (decoded.functionName === "execute") {
159
- return [
160
- {
161
- to: decoded.args[0],
162
- value: decoded.args[1],
163
- data: decoded.args[2],
164
- },
165
- ];
166
- }
167
-
168
- if (decoded.functionName === "executeBatch") {
169
- return decoded.args[0].map((call) => ({
170
- to: call.target,
171
- value: call.value,
172
- data: call.data,
173
- }));
174
- }
175
-
176
- // If the data is not for an `execute` or `executeBatch` call, we treat it as a single call to the account itself.
177
- return [
178
- {
179
- to: accountAddress,
180
- data,
181
- },
182
- ];
131
+ return decodeCallsMAv1(data, accountAddress);
183
132
  },
184
133
 
185
134
  async getStubSignature() {
@@ -0,0 +1,85 @@
1
+ import {
2
+ decodeFunctionData,
3
+ encodeFunctionData,
4
+ type Address,
5
+ type Call,
6
+ type Hex,
7
+ } from "viem";
8
+ import { IStandardExecutorAbi } from "../abis/IStandardExecutor.js";
9
+ import { BaseError } from "@alchemy/common";
10
+
11
+ /**
12
+ * Encodes an array of calls into ModularAccountV1 calldata for `execute` or `executeBatch`.
13
+ * Used internally by the ModularAccountV1 SmartAccount implementation. Typically not needed
14
+ * directly unless you have an advanced use case.
15
+ *
16
+ * @param {Call[]} calls The calls to encode.
17
+ * @returns {Hex} The encoded calldata.
18
+ */
19
+ export function encodeCallsMAv1(calls: readonly Call[]): Hex {
20
+ if (!calls.length) {
21
+ throw new BaseError("No calls to encode.");
22
+ }
23
+
24
+ if (calls.length === 1) {
25
+ return encodeFunctionData({
26
+ abi: IStandardExecutorAbi,
27
+ functionName: "execute",
28
+ args: [calls[0].to, calls[0].value ?? 0n, calls[0].data ?? "0x"],
29
+ });
30
+ }
31
+
32
+ return encodeFunctionData({
33
+ abi: IStandardExecutorAbi,
34
+ functionName: "executeBatch",
35
+ args: [
36
+ calls.map((call) => ({
37
+ target: call.to,
38
+ value: call.value ?? 0n,
39
+ data: call.data ?? "0x",
40
+ })),
41
+ ],
42
+ });
43
+ }
44
+
45
+ /**
46
+ * Decodes ModularAccountV1 calldata back into an array of calls.
47
+ * Used internally by the ModularAccountV1 SmartAccount implementation. Typically not needed
48
+ * directly unless you have an advanced use case.
49
+ *
50
+ * @param {Hex} data The calldata to decode.
51
+ * @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.
52
+ * @returns {Call[]} The decoded calls.
53
+ */
54
+ export function decodeCallsMAv1(data: Hex, accountAddress: Address): Call[] {
55
+ const decoded = decodeFunctionData({
56
+ abi: IStandardExecutorAbi,
57
+ data,
58
+ });
59
+
60
+ if (decoded.functionName === "execute") {
61
+ return [
62
+ {
63
+ to: decoded.args[0],
64
+ value: decoded.args[1],
65
+ data: decoded.args[2],
66
+ },
67
+ ];
68
+ }
69
+
70
+ if (decoded.functionName === "executeBatch") {
71
+ return decoded.args[0].map((call) => ({
72
+ to: call.target,
73
+ value: call.value,
74
+ data: call.data,
75
+ }));
76
+ }
77
+
78
+ // If the data is not for an `execute` or `executeBatch` call, treat it as a single call to the account itself.
79
+ return [
80
+ {
81
+ to: accountAddress,
82
+ data,
83
+ },
84
+ ];
85
+ }