@alchemy/smart-accounts 5.0.0-beta.2 → 5.0.0-beta.4
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.
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/light-account/accounts/calldataCodec.d.ts +17 -0
- package/dist/esm/light-account/accounts/calldataCodec.js +17 -0
- package/dist/esm/light-account/accounts/calldataCodec.js.map +1 -1
- package/dist/esm/ma-v1/accounts/base.js +5 -49
- package/dist/esm/ma-v1/accounts/base.js.map +1 -1
- package/dist/esm/ma-v1/accounts/calldataCodec.d.ts +20 -0
- package/dist/esm/ma-v1/accounts/calldataCodec.js +69 -0
- package/dist/esm/ma-v1/accounts/calldataCodec.js.map +1 -0
- package/dist/esm/ma-v2/accounts/base.js +6 -53
- package/dist/esm/ma-v2/accounts/base.js.map +1 -1
- package/dist/esm/ma-v2/accounts/calldataCodec.d.ts +20 -0
- package/dist/esm/ma-v2/accounts/calldataCodec.js +77 -0
- package/dist/esm/ma-v2/accounts/calldataCodec.js.map +1 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/light-account/accounts/calldataCodec.d.ts +17 -0
- package/dist/types/light-account/accounts/calldataCodec.d.ts.map +1 -1
- package/dist/types/ma-v1/accounts/base.d.ts.map +1 -1
- package/dist/types/ma-v1/accounts/calldataCodec.d.ts +21 -0
- package/dist/types/ma-v1/accounts/calldataCodec.d.ts.map +1 -0
- package/dist/types/ma-v2/accounts/base.d.ts.map +1 -1
- package/dist/types/ma-v2/accounts/calldataCodec.d.ts +21 -0
- package/dist/types/ma-v2/accounts/calldataCodec.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/index.ts +15 -0
- package/src/light-account/accounts/calldataCodec.ts +17 -0
- package/src/ma-v1/accounts/base.ts +3 -54
- package/src/ma-v1/accounts/calldataCodec.ts +80 -0
- package/src/ma-v2/accounts/base.ts +5 -67
- package/src/ma-v2/accounts/calldataCodec.ts +89 -0
- 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,77 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Encodes an array of calls into ModularAccountV2 calldata for `execute` or `executeBatch`.
|
|
7
|
+
* Used internally by the ModularAccountV2 SmartAccount implementation. Typically not needed
|
|
8
|
+
* directly unless you have an advanced use case.
|
|
9
|
+
*
|
|
10
|
+
* @param {Call[]} calls The calls to encode.
|
|
11
|
+
* @returns {Hex} The encoded calldata.
|
|
12
|
+
*/
|
|
13
|
+
export function encodeCallsMAv2(calls) {
|
|
14
|
+
if (calls.length === 1) {
|
|
15
|
+
return encodeFunctionData({
|
|
16
|
+
abi: modularAccountAbi,
|
|
17
|
+
functionName: "execute",
|
|
18
|
+
args: [calls[0].to, calls[0].value ?? 0n, calls[0].data ?? "0x"],
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return encodeFunctionData({
|
|
22
|
+
abi: modularAccountAbi,
|
|
23
|
+
functionName: "executeBatch",
|
|
24
|
+
args: [
|
|
25
|
+
calls.map((call) => ({
|
|
26
|
+
target: call.to,
|
|
27
|
+
data: call.data ?? "0x",
|
|
28
|
+
value: call.value ?? 0n,
|
|
29
|
+
})),
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Decodes ModularAccountV2 calldata back into an array of calls. Strips the `EXECUTE_USER_OP_SELECTOR` prefix if present.
|
|
35
|
+
* Used internally by the ModularAccountV2 SmartAccount implementation. Typically not needed
|
|
36
|
+
* directly unless you have an advanced use case.
|
|
37
|
+
*
|
|
38
|
+
* @param {Hex} data The calldata to decode.
|
|
39
|
+
* @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.
|
|
40
|
+
* @returns {Call[]} The decoded calls.
|
|
41
|
+
*/
|
|
42
|
+
export function decodeCallsMAv2(data, accountAddress) {
|
|
43
|
+
// Strip the EXECUTE_USER_OP_SELECTOR prefix if present.
|
|
44
|
+
const trimmedData = data
|
|
45
|
+
.toLowerCase()
|
|
46
|
+
.startsWith(EXECUTE_USER_OP_SELECTOR.toLowerCase())
|
|
47
|
+
? sliceHex(data, 4)
|
|
48
|
+
: data;
|
|
49
|
+
const decoded = decodeFunctionData({
|
|
50
|
+
abi: modularAccountAbi,
|
|
51
|
+
data: trimmedData,
|
|
52
|
+
});
|
|
53
|
+
if (decoded.functionName === "execute") {
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
to: decoded.args[0],
|
|
57
|
+
value: decoded.args[1],
|
|
58
|
+
data: decoded.args[2],
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
if (decoded.functionName === "executeBatch") {
|
|
63
|
+
return decoded.args[0].map((call) => ({
|
|
64
|
+
to: call.target,
|
|
65
|
+
value: call.value,
|
|
66
|
+
data: call.data,
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
// If the data is not for an `execute` or `executeBatch` call, treat it as a single call to the account itself.
|
|
70
|
+
return [
|
|
71
|
+
{
|
|
72
|
+
to: accountAddress,
|
|
73
|
+
data,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
//# 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;AAE/D;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAsB;IACpD,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,K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,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\";\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 === 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"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "5.0.0-beta.
|
|
1
|
+
export declare const VERSION = "5.0.0-beta.3";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -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
|
+
{"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.3\";\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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,m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,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,CAyBzD;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,KAAK,YAAY,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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,KAAK,IAAI,EACT,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAGd;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,GAAG,CAoB3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,GAAG,IAAI,EAAE,CA+B1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/ma-v2/accounts/base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/ma-v2/accounts/base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EASf,MAAM,MAAM,CAAC;AACd,OAAO,EACL,eAAe,EACf,KAAK,0BAA0B,EAI/B,KAAK,wBAAwB,EAC9B,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EACV,gBAAgB,EAChB,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AAoBxB,MAAM,MAAM,oBAAoB,GAC5B;IACE,uBAAuB,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,uBAAuB,CAAC,EAAE,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,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;AAKd;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,GAAG,CAoB3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,GAAG,IAAI,EAAE,CAsC1E"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "5.0.0-beta.
|
|
1
|
+
export declare const VERSION = "5.0.0-beta.3";
|
|
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.
|
|
3
|
+
"version": "5.0.0-beta.4",
|
|
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.
|
|
42
|
+
"@alchemy/aa-infra": "^5.0.0-beta.4",
|
|
43
43
|
"typescript-template": "*",
|
|
44
44
|
"viem": "^2.45.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@alchemy/common": "^5.0.0-beta.
|
|
47
|
+
"@alchemy/common": "^5.0.0-beta.4"
|
|
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": "
|
|
64
|
+
"gitHead": "8580e16013bbbe65d6e22bbf482c65727387ba7e"
|
|
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,6 +10,14 @@ 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 {
|
|
14
22
|
if (calls.length === 1) {
|
|
15
23
|
return encodeFunctionData({
|
|
@@ -37,6 +45,15 @@ export function encodeCallsLA(calls: readonly Call[]): Hex {
|
|
|
37
45
|
});
|
|
38
46
|
}
|
|
39
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Decodes LightAccount calldata back into an array of calls.
|
|
50
|
+
* Used internally by the LightAccount SmartAccount implementation. Typically not needed
|
|
51
|
+
* directly unless you have an advanced use case.
|
|
52
|
+
*
|
|
53
|
+
* @param {Hex} data The calldata to decode.
|
|
54
|
+
* @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.
|
|
55
|
+
* @returns {Call[]} The decoded calls.
|
|
56
|
+
*/
|
|
40
57
|
export function decodeCallsLA(data: Hex, accountAddress: Address): Call[] {
|
|
41
58
|
const decoded = decodeFunctionData({
|
|
42
59
|
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
|
|
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
|
-
|
|
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,80 @@
|
|
|
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
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Encodes an array of calls into ModularAccountV1 calldata for `execute` or `executeBatch`.
|
|
12
|
+
* Used internally by the ModularAccountV1 SmartAccount implementation. Typically not needed
|
|
13
|
+
* directly unless you have an advanced use case.
|
|
14
|
+
*
|
|
15
|
+
* @param {Call[]} calls The calls to encode.
|
|
16
|
+
* @returns {Hex} The encoded calldata.
|
|
17
|
+
*/
|
|
18
|
+
export function encodeCallsMAv1(calls: readonly Call[]): Hex {
|
|
19
|
+
if (calls.length === 1) {
|
|
20
|
+
return encodeFunctionData({
|
|
21
|
+
abi: IStandardExecutorAbi,
|
|
22
|
+
functionName: "execute",
|
|
23
|
+
args: [calls[0].to, calls[0].value ?? 0n, calls[0].data ?? "0x"],
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return encodeFunctionData({
|
|
28
|
+
abi: IStandardExecutorAbi,
|
|
29
|
+
functionName: "executeBatch",
|
|
30
|
+
args: [
|
|
31
|
+
calls.map((call) => ({
|
|
32
|
+
target: call.to,
|
|
33
|
+
value: call.value ?? 0n,
|
|
34
|
+
data: call.data ?? "0x",
|
|
35
|
+
})),
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Decodes ModularAccountV1 calldata back into an array of calls.
|
|
42
|
+
* Used internally by the ModularAccountV1 SmartAccount implementation. Typically not needed
|
|
43
|
+
* directly unless you have an advanced use case.
|
|
44
|
+
*
|
|
45
|
+
* @param {Hex} data The calldata to decode.
|
|
46
|
+
* @param {Address} accountAddress The account address, used as the `to` for unrecognized selectors.
|
|
47
|
+
* @returns {Call[]} The decoded calls.
|
|
48
|
+
*/
|
|
49
|
+
export function decodeCallsMAv1(data: Hex, accountAddress: Address): Call[] {
|
|
50
|
+
const decoded = decodeFunctionData({
|
|
51
|
+
abi: IStandardExecutorAbi,
|
|
52
|
+
data,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (decoded.functionName === "execute") {
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
to: decoded.args[0],
|
|
59
|
+
value: decoded.args[1],
|
|
60
|
+
data: decoded.args[2],
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (decoded.functionName === "executeBatch") {
|
|
66
|
+
return decoded.args[0].map((call) => ({
|
|
67
|
+
to: call.target,
|
|
68
|
+
value: call.value,
|
|
69
|
+
data: call.data,
|
|
70
|
+
}));
|
|
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
|
+
}
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
type Transport,
|
|
9
9
|
concat,
|
|
10
10
|
concatHex,
|
|
11
|
-
encodeFunctionData,
|
|
12
11
|
hashMessage,
|
|
13
12
|
hashTypedData,
|
|
14
13
|
type TypedDataDefinition,
|
|
@@ -42,12 +41,7 @@ import type {
|
|
|
42
41
|
SignatureRequest,
|
|
43
42
|
SmartAccountWithDecodeCalls,
|
|
44
43
|
} from "../../types.js";
|
|
45
|
-
import {
|
|
46
|
-
decodeFunctionData,
|
|
47
|
-
getAction,
|
|
48
|
-
isAddressEqual,
|
|
49
|
-
sliceHex,
|
|
50
|
-
} from "viem/utils";
|
|
44
|
+
import { getAction, isAddressEqual } from "viem/utils";
|
|
51
45
|
import {
|
|
52
46
|
DEFAULT_OWNER_ENTITY_ID,
|
|
53
47
|
DefaultModuleAddress,
|
|
@@ -64,6 +58,7 @@ import { InvalidDeferredActionNonceError } from "../../errors/InvalidDeferredAct
|
|
|
64
58
|
import { InvalidNonceKeyError } from "../../errors/InvalidNonceKeyError.js";
|
|
65
59
|
import { InvalidEntityIdError } from "../../errors/InvalidEntityIdError.js";
|
|
66
60
|
import { is7702Delegated } from "../../utils.js";
|
|
61
|
+
import { encodeCallsMAv2, decodeCallsMAv2 } from "./calldataCodec.js";
|
|
67
62
|
|
|
68
63
|
export type ValidationDataParams =
|
|
69
64
|
| {
|
|
@@ -336,76 +331,19 @@ export async function toModularAccountV2Base<
|
|
|
336
331
|
if (isAddressEqual(call.to, accountAddress)) {
|
|
337
332
|
// If the call is to the account itself, we need to avoid wrapping it in an `execute` call.
|
|
338
333
|
|
|
339
|
-
if (call.data
|
|
334
|
+
if (call.data == null) {
|
|
340
335
|
throw new BaseError("Data is required for an account self-call.");
|
|
341
336
|
}
|
|
342
337
|
|
|
343
338
|
return encodeCallData(call.data);
|
|
344
339
|
}
|
|
345
|
-
|
|
346
|
-
return encodeCallData(
|
|
347
|
-
encodeFunctionData({
|
|
348
|
-
abi: modularAccountAbi,
|
|
349
|
-
functionName: "execute",
|
|
350
|
-
args: [call.to, call.value ?? 0n, call.data ?? "0x"],
|
|
351
|
-
}),
|
|
352
|
-
);
|
|
353
340
|
}
|
|
354
341
|
|
|
355
|
-
return encodeCallData(
|
|
356
|
-
encodeFunctionData({
|
|
357
|
-
abi: modularAccountAbi,
|
|
358
|
-
functionName: "executeBatch",
|
|
359
|
-
args: [
|
|
360
|
-
calls.map((call) => ({
|
|
361
|
-
target: call.to,
|
|
362
|
-
data: call.data ?? "0x",
|
|
363
|
-
value: call.value ?? 0n,
|
|
364
|
-
})),
|
|
365
|
-
],
|
|
366
|
-
}),
|
|
367
|
-
);
|
|
342
|
+
return encodeCallData(encodeCallsMAv2(calls));
|
|
368
343
|
},
|
|
369
344
|
|
|
370
345
|
async decodeCalls(data) {
|
|
371
|
-
|
|
372
|
-
// Trim the EXECUTE_USER_OP_SELECTOR if it is present.
|
|
373
|
-
const trimmedData = data
|
|
374
|
-
.toLowerCase()
|
|
375
|
-
.startsWith(EXECUTE_USER_OP_SELECTOR.toLowerCase())
|
|
376
|
-
? sliceHex(data, 4)
|
|
377
|
-
: data;
|
|
378
|
-
|
|
379
|
-
const decoded = decodeFunctionData({
|
|
380
|
-
abi: modularAccountAbi,
|
|
381
|
-
data: trimmedData,
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
if (decoded.functionName === "execute") {
|
|
385
|
-
return [
|
|
386
|
-
{
|
|
387
|
-
to: decoded.args[0],
|
|
388
|
-
value: decoded.args[1],
|
|
389
|
-
data: decoded.args[2],
|
|
390
|
-
},
|
|
391
|
-
];
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (decoded.functionName === "executeBatch") {
|
|
395
|
-
return decoded.args[0].map((call) => ({
|
|
396
|
-
to: call.target,
|
|
397
|
-
value: call.value,
|
|
398
|
-
data: call.data,
|
|
399
|
-
}));
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// If the data is not for an `execute` or `executeBatch` call, we treat it as a single call to the account itself.
|
|
403
|
-
return [
|
|
404
|
-
{
|
|
405
|
-
to: accountAddress,
|
|
406
|
-
data,
|
|
407
|
-
},
|
|
408
|
-
];
|
|
346
|
+
return decodeCallsMAv2(data, accountAddress);
|
|
409
347
|
},
|
|
410
348
|
|
|
411
349
|
async getStubSignature() {
|