@account-kit/smart-contracts 4.0.0-alpha.5 → 4.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/cjs/src/index.d.ts +1 -1
  2. package/dist/cjs/src/index.js +2 -2
  3. package/dist/cjs/src/index.js.map +1 -1
  4. package/dist/cjs/src/light-account/accounts/account.d.ts +5 -6
  5. package/dist/cjs/src/light-account/accounts/account.js +3 -2
  6. package/dist/cjs/src/light-account/accounts/account.js.map +1 -1
  7. package/dist/cjs/src/light-account/accounts/base.d.ts +7 -6
  8. package/dist/cjs/src/light-account/accounts/base.js +8 -8
  9. package/dist/cjs/src/light-account/accounts/base.js.map +1 -1
  10. package/dist/cjs/src/light-account/accounts/multiOwner.d.ts +5 -5
  11. package/dist/cjs/src/light-account/accounts/multiOwner.js +3 -2
  12. package/dist/cjs/src/light-account/accounts/multiOwner.js.map +1 -1
  13. package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.d.ts +1 -1
  14. package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
  15. package/dist/cjs/src/light-account/types.d.ts +23 -31
  16. package/dist/cjs/src/light-account/types.js.map +1 -1
  17. package/dist/cjs/src/light-account/utils.d.ts +7 -10
  18. package/dist/cjs/src/light-account/utils.js +59 -88
  19. package/dist/cjs/src/light-account/utils.js.map +1 -1
  20. package/dist/cjs/src/msca/plugins/multisig/middleware.js.map +1 -1
  21. package/dist/cjs/src/msca/plugins/multisig/utils/formatSignatures.js.map +1 -1
  22. package/dist/cjs/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +3 -2
  23. package/dist/cjs/src/msca/plugins/multisig/utils/splitAggregatedSignature.js.map +1 -1
  24. package/dist/cjs/src/msca/plugins/session-key/permissions.js.map +1 -1
  25. package/dist/cjs/src/msca/plugins/session-key/signer.js.map +1 -1
  26. package/dist/cjs/src/msca/utils.js.map +1 -1
  27. package/dist/esm/src/index.d.ts +1 -1
  28. package/dist/esm/src/index.js +1 -1
  29. package/dist/esm/src/index.js.map +1 -1
  30. package/dist/esm/src/light-account/accounts/account.d.ts +5 -6
  31. package/dist/esm/src/light-account/accounts/account.js +3 -2
  32. package/dist/esm/src/light-account/accounts/account.js.map +1 -1
  33. package/dist/esm/src/light-account/accounts/base.d.ts +7 -6
  34. package/dist/esm/src/light-account/accounts/base.js +8 -8
  35. package/dist/esm/src/light-account/accounts/base.js.map +1 -1
  36. package/dist/esm/src/light-account/accounts/multiOwner.d.ts +5 -5
  37. package/dist/esm/src/light-account/accounts/multiOwner.js +4 -3
  38. package/dist/esm/src/light-account/accounts/multiOwner.js.map +1 -1
  39. package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.d.ts +1 -1
  40. package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
  41. package/dist/esm/src/light-account/types.d.ts +23 -31
  42. package/dist/esm/src/light-account/types.js.map +1 -1
  43. package/dist/esm/src/light-account/utils.d.ts +7 -10
  44. package/dist/esm/src/light-account/utils.js +57 -85
  45. package/dist/esm/src/light-account/utils.js.map +1 -1
  46. package/dist/esm/src/msca/plugins/multisig/middleware.js.map +1 -1
  47. package/dist/esm/src/msca/plugins/multisig/utils/formatSignatures.js.map +1 -1
  48. package/dist/esm/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +3 -2
  49. package/dist/esm/src/msca/plugins/multisig/utils/splitAggregatedSignature.js.map +1 -1
  50. package/dist/esm/src/msca/plugins/session-key/permissions.js.map +1 -1
  51. package/dist/esm/src/msca/plugins/session-key/signer.js.map +1 -1
  52. package/dist/esm/src/msca/utils.js.map +1 -1
  53. package/dist/types/src/index.d.ts +1 -1
  54. package/dist/types/src/index.d.ts.map +1 -1
  55. package/dist/types/src/light-account/accounts/account.d.ts +5 -6
  56. package/dist/types/src/light-account/accounts/account.d.ts.map +1 -1
  57. package/dist/types/src/light-account/accounts/base.d.ts +7 -6
  58. package/dist/types/src/light-account/accounts/base.d.ts.map +1 -1
  59. package/dist/types/src/light-account/accounts/multiOwner.d.ts +5 -5
  60. package/dist/types/src/light-account/accounts/multiOwner.d.ts.map +1 -1
  61. package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts +1 -1
  62. package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts.map +1 -1
  63. package/dist/types/src/light-account/types.d.ts +23 -118
  64. package/dist/types/src/light-account/types.d.ts.map +1 -1
  65. package/dist/types/src/light-account/utils.d.ts +19 -48
  66. package/dist/types/src/light-account/utils.d.ts.map +1 -1
  67. package/dist/types/src/msca/plugins/multisig/middleware.d.ts +6 -6
  68. package/dist/types/src/msca/plugins/multisig/utils/formatSignatures.d.ts +3 -3
  69. package/dist/types/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +13 -12
  70. package/dist/types/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts.map +1 -1
  71. package/dist/types/src/msca/plugins/session-key/permissions.d.ts +147 -1
  72. package/dist/types/src/msca/plugins/session-key/permissions.d.ts.map +1 -1
  73. package/dist/types/src/msca/plugins/session-key/signer.d.ts +71 -1
  74. package/dist/types/src/msca/plugins/session-key/signer.d.ts.map +1 -1
  75. package/dist/types/src/msca/utils.d.ts +6 -6
  76. package/package.json +6 -5
  77. package/src/index.ts +1 -1
  78. package/src/light-account/accounts/account.ts +24 -45
  79. package/src/light-account/accounts/base.ts +39 -68
  80. package/src/light-account/accounts/multiOwner.ts +29 -43
  81. package/src/light-account/clients/multiOwnerAlchemyClient.ts +1 -1
  82. package/src/light-account/types.ts +31 -188
  83. package/src/light-account/utils.ts +91 -245
  84. package/src/msca/plugins/multisig/middleware.ts +6 -6
  85. package/src/msca/plugins/multisig/utils/formatSignatures.ts +3 -3
  86. package/src/msca/plugins/multisig/utils/splitAggregatedSignature.ts +15 -12
  87. package/src/msca/plugins/session-key/permissions.ts +147 -1
  88. package/src/msca/plugins/session-key/signer.ts +71 -1
  89. package/src/msca/utils.ts +6 -6
  90. package/dist/cjs/src/light-account/schema.d.ts +0 -21
  91. package/dist/cjs/src/light-account/schema.js +0 -30
  92. package/dist/cjs/src/light-account/schema.js.map +0 -1
  93. package/dist/esm/src/light-account/schema.d.ts +0 -21
  94. package/dist/esm/src/light-account/schema.js +0 -27
  95. package/dist/esm/src/light-account/schema.js.map +0 -1
  96. package/dist/types/src/light-account/schema.d.ts +0 -22
  97. package/dist/types/src/light-account/schema.d.ts.map +0 -1
  98. package/src/light-account/schema.ts +0 -39
@@ -1,142 +1,71 @@
1
- import { DefaultFactoryNotDefinedError, toRecord } from "@aa-sdk/core";
2
- import {
3
- arbitrum,
4
- arbitrumGoerli,
5
- arbitrumSepolia,
6
- base,
7
- baseGoerli,
8
- baseSepolia,
9
- fraxtal,
10
- fraxtalSepolia,
11
- goerli,
12
- mainnet,
13
- optimism,
14
- optimismGoerli,
15
- optimismSepolia,
16
- polygon,
17
- polygonAmoy,
18
- polygonMumbai,
19
- sepolia,
20
- zora,
21
- zoraSepolia,
22
- } from "@account-kit/infra";
1
+ import type { GetEntryPointFromAccount } from "@aa-sdk/core";
23
2
  import { fromHex, type Address, type Chain } from "viem";
24
3
  import type { LightAccountBase } from "./accounts/base";
25
4
  import type {
26
- AccountVersionDef,
27
- GetLightAccountType,
28
- GetLightAccountVersion,
29
- GetLightAccountVersionFromAccount,
30
- IAccountVersionRegistry,
31
5
  LightAccountType,
32
6
  LightAccountVersion,
33
- LightAccountVersionDef,
7
+ LightAccountVersionConfig,
8
+ LightAccountVersionConfigs,
34
9
  } from "./types";
35
10
 
36
- /**
37
- * Light account deployed chains
38
- *
39
- */
40
- export const supportedChains: Chain[] = [
41
- mainnet,
42
- sepolia,
43
- goerli,
44
- polygon,
45
- polygonAmoy,
46
- polygonMumbai,
47
- optimism,
48
- optimismGoerli,
49
- optimismSepolia,
50
- arbitrum,
51
- arbitrumGoerli,
52
- arbitrumSepolia,
53
- base,
54
- baseGoerli,
55
- baseSepolia,
56
- fraxtal,
57
- fraxtalSepolia,
58
- zora,
59
- zoraSepolia,
60
- ];
61
-
62
11
  /**
63
12
  * Account version registry interface that defines the light account versions
64
13
  * and the version definition for each light account type
65
14
  *
66
15
  */
67
- export const AccountVersionRegistry: IAccountVersionRegistry = {
16
+ export const AccountVersionRegistry: LightAccountVersionConfigs = {
68
17
  LightAccount: {
69
18
  "v1.0.1": {
70
- type: "LightAccount",
71
- version: "v1.0.1",
72
- address: toRecord<Chain, "id", { factory: Address; impl: Address }>(
73
- supportedChains,
74
- "id",
75
- () => ({
19
+ entryPointVersion: "0.6.0",
20
+ addresses: {
21
+ default: {
76
22
  factory:
77
23
  "0x000000893A26168158fbeaDD9335Be5bC96592E2".toLowerCase() as Address,
78
24
  impl: "0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0".toLowerCase() as Address,
79
- })
80
- ),
81
- entryPointVersion: "0.6.0",
25
+ },
26
+ },
82
27
  },
83
28
  "v1.0.2": {
84
- type: "LightAccount",
85
- version: "v1.0.2",
86
- address: toRecord<Chain, "id", { factory: Address; impl: Address }>(
87
- supportedChains,
88
- "id",
89
- () => ({
29
+ entryPointVersion: "0.6.0",
30
+ addresses: {
31
+ default: {
90
32
  factory:
91
33
  "0x00000055C0b4fA41dde26A74435ff03692292FBD".toLowerCase() as Address,
92
34
  impl: "0x5467b1947F47d0646704EB801E075e72aeAe8113".toLowerCase() as Address,
93
- })
94
- ),
95
- entryPointVersion: "0.6.0",
35
+ },
36
+ },
96
37
  },
97
38
  "v1.1.0": {
98
- type: "LightAccount",
99
- version: "v1.1.0",
100
- address: toRecord<Chain, "id", { factory: Address; impl: Address }>(
101
- supportedChains,
102
- "id",
103
- () => ({
39
+ entryPointVersion: "0.6.0",
40
+ addresses: {
41
+ default: {
104
42
  factory:
105
43
  "0x00004EC70002a32400f8ae005A26081065620D20".toLowerCase() as Address,
106
44
  impl: "0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba".toLowerCase() as Address,
107
- })
108
- ),
109
- entryPointVersion: "0.6.0",
45
+ },
46
+ },
110
47
  },
111
48
  "v2.0.0": {
112
- type: "LightAccount",
113
- version: "v2.0.0",
114
- address: toRecord<Chain, "id", { factory: Address; impl: Address }>(
115
- supportedChains,
116
- "id",
117
- () => ({
49
+ entryPointVersion: "0.7.0",
50
+ addresses: {
51
+ default: {
118
52
  factory:
119
53
  "0x0000000000400CdFef5E2714E63d8040b700BC24".toLowerCase() as Address,
120
54
  impl: "0x8E8e658E22B12ada97B402fF0b044D6A325013C7".toLowerCase() as Address,
121
- })
122
- ),
123
- entryPointVersion: "0.7.0",
55
+ },
56
+ },
124
57
  },
125
58
  },
126
59
  MultiOwnerLightAccount: {
127
60
  "v2.0.0": {
128
- type: "MultiOwnerLightAccount",
129
- version: "v2.0.0",
130
- address: toRecord<Chain, "id", { factory: Address; impl: Address }>(
131
- supportedChains,
132
- "id",
133
- () => ({
61
+ entryPointVersion: "0.7.0",
62
+ addresses: {
63
+ default: {
134
64
  factory:
135
65
  "0x000000000019d2Ee9F2729A65AfE20bb0020AefC".toLowerCase() as Address,
136
66
  impl: "0xd2c27F9eE8E4355f71915ffD5568cB3433b6823D".toLowerCase() as Address,
137
- })
138
- ),
139
- entryPointVersion: "0.7.0",
67
+ },
68
+ },
140
69
  },
141
70
  },
142
71
  };
@@ -145,60 +74,48 @@ export const AccountVersionRegistry: IAccountVersionRegistry = {
145
74
  * Get the default light account version for the given light account type
146
75
  *
147
76
  * @template {LightAccountType} TLightAccountType
148
- * @param type - the light account type to get the default version for
149
- * @returns the default version for the given light account type
77
+ * @returns {LightAccountVersion<TLightAccountType>} the default version for the given light account type
150
78
  */
151
79
  export const defaultLightAccountVersion = <
152
80
  TLightAccountType extends LightAccountType
153
- >(
154
- type: TLightAccountType
155
- ): GetLightAccountVersion<TLightAccountType> =>
156
- (type === "LightAccount"
157
- ? "v1.1.0"
158
- : "v2.0.0") as GetLightAccountVersion<TLightAccountType>;
81
+ >(): LightAccountVersion<TLightAccountType> => "v2.0.0";
159
82
 
160
83
  /**
161
- * Utility method returning the default light account factory address given a {@link Chain} object
84
+ * Utility method returning the default light account factory address given a Chain object
162
85
  *
163
- * @param chain - a {@link Chain} object
164
- * @param version - the version of the light account to get the factory address for
165
- * @returns a {@link Address} for the given chain
86
+ * @param {Chain} chain - a Chain object
87
+ * @param {LightAccountVersion} version - the version of the light account to get the factory address for
88
+ * @returns {Address} an for the given chain
166
89
  * @throws if the chain doesn't have an address currently deployed
167
90
  */
168
91
  export const getDefaultLightAccountFactoryAddress = (
169
92
  chain: Chain,
170
- version: GetLightAccountVersion<"LightAccount">
93
+ version: LightAccountVersion<"LightAccount">
171
94
  ): Address => {
172
- const address =
173
- AccountVersionRegistry.LightAccount[version].address[chain.id] ??
174
- AccountVersionRegistry.LightAccount[version].address[supportedChains[0].id];
175
- if (!address)
176
- throw new DefaultFactoryNotDefinedError("LightAccount", chain, "0.6.0");
177
- return address.factory;
95
+ return (
96
+ AccountVersionRegistry.LightAccount[version].addresses.overrides?.[chain.id]
97
+ ?.factory ??
98
+ AccountVersionRegistry.LightAccount[version].addresses.default.factory
99
+ );
178
100
  };
179
101
 
180
102
  /**
181
- * Utility method returning the default multi owner light account factory address given a {@link Chain} object
103
+ * Utility method returning the default multi owner light account factory address given a Chain object
182
104
  *
183
- * @param chain - a {@link Chain} object
184
- * @param version - the version of the light account to get the factory address for
185
- * @returns a {@link Address} for the given chain
186
- * @throws if the chain doesn't have an address currently deployed
105
+ * @param {Chain} chain - a Chain object
106
+ * @param {string} version - the version of the light account to get the factory address for
107
+ * @returns {Address} an Address for the given chain
187
108
  */
188
109
  export const getDefaultMultiOwnerLightAccountFactoryAddress = (
189
110
  chain: Chain,
190
- version: GetLightAccountVersion<"MultiOwnerLightAccount">
111
+ version: LightAccountVersion<"MultiOwnerLightAccount">
191
112
  ) => {
192
- const address =
193
- AccountVersionRegistry.LightAccount[version].address[chain.id] ??
194
- AccountVersionRegistry.LightAccount[version].address[supportedChains[0].id];
195
- if (!address)
196
- throw new DefaultFactoryNotDefinedError(
197
- "MultiOwnerLightAccount",
198
- chain,
199
- "0.7.0"
200
- );
201
- return address.factory;
113
+ return (
114
+ AccountVersionRegistry.MultiOwnerLightAccount[version].addresses
115
+ .overrides?.[chain.id]?.factory ??
116
+ AccountVersionRegistry.MultiOwnerLightAccount[version].addresses.default
117
+ .factory
118
+ );
202
119
  };
203
120
 
204
121
  /**
@@ -219,98 +136,60 @@ export const LightAccountUnsupported1271Impls = [
219
136
  * Light accounts with versions v1.0.1 and v1.0.2 do not support 1271 signing.
220
137
  */
221
138
  export const LightAccountUnsupported1271Factories = new Set(
222
- LightAccountUnsupported1271Impls.map((x) =>
223
- Object.values(x.address).map((addr) => addr.factory)
224
- ).flat()
139
+ LightAccountUnsupported1271Impls.map((x) => [
140
+ x.addresses.default.factory,
141
+ ...Object.values(x.addresses.overrides ?? {}).map((z) => z.factory),
142
+ ]).flat()
225
143
  );
226
144
 
227
145
  /**
228
146
  * Get the light account version definition for the given light account and chain
229
147
  *
230
148
  * @template {LightAccountBase} TAccount
231
- * @template {GetLightAccountType<TAccount>} TLightAccountType
232
- * @template {GetLightAccountVersion<TLightAccountType>} TLightAccountVersion
233
- * @param account - the light account to get the version for
234
- * @param chain - the chain to get the version for
235
- * @returns the light account version definition for the given light account and chain
236
- */
237
- export async function getLightAccountVersionDef<
238
- TAccount extends LightAccountBase,
239
- TLightAccountType extends GetLightAccountType<TAccount> = GetLightAccountType<TAccount>,
240
- TLightAccountVersion extends GetLightAccountVersion<TLightAccountType> = GetLightAccountVersion<TLightAccountType>
241
- >(
242
- account: TAccount,
243
- chain: Chain
244
- ): Promise<LightAccountVersionDef<TLightAccountType, TLightAccountVersion>>;
245
-
246
- /**
247
- * Get the light account version definition for the given light account and chain
248
- *
249
- * @template {LightAccountBase} TAccount
250
- * @template {GetLightAccountType<TAccount>} TLightAccountType
251
- * @param account - the light account to get the version for
252
- * @param chain - the chain to get the version for
253
- * @returns the light account version definition for the given light account and chain
149
+ * @param {LightAccountBase} account the light account to get the version for
150
+ * @param {Chain} chain - the chain to get the version for
151
+ * @returns {Promise<LightAccountVersionConfig>} the light account version definition for the given light account and chain
254
152
  */
255
- export async function getLightAccountVersionDef<
256
- TAccount extends LightAccountBase,
257
- TLightAccountType extends GetLightAccountType<TAccount> = GetLightAccountType<TAccount>
258
- >(
259
- account: TAccount,
260
- chain: Chain
261
- ): Promise<
262
- AccountVersionDef<
263
- TLightAccountType,
264
- GetLightAccountVersion<TLightAccountType>
265
- >
266
- >;
267
-
268
- /**
269
- * Get the light account version definition for the given light account and chain
270
- *
271
- * @template {LightAccountBase} TAccount
272
- * @param account - the light account to get the version for
273
- * @param chain - the chain to get the version for
274
- * @returns the light account version definition for the given light account and chain
275
- */
276
- export async function getLightAccountVersionDef<
153
+ export async function getLightAccountVersionForAccount<
277
154
  TAccount extends LightAccountBase
278
- >(account: TAccount, chain: Chain): Promise<AccountVersionDef> {
155
+ >(account: TAccount, chain: Chain): Promise<LightAccountVersionConfig> {
279
156
  const accountType = account.source as LightAccountType;
280
157
  const factoryAddress = await account.getFactoryAddress();
281
158
  const implAddress = await account.getImplementationAddress();
282
159
  const implToVersion = new Map(
283
- Object.entries(AccountVersionRegistry[accountType])
284
- .map((pair) => {
285
- const [version, def] = pair as [
286
- GetLightAccountVersionFromAccount<TAccount>,
287
- LightAccountVersionDef
288
- ];
289
- return chain.id in def.address
290
- ? [def.address[chain.id].impl, version]
291
- : [def.address[supportedChains[0].id].impl, version];
292
- })
293
- .filter(([impl]) => impl !== null) as [
294
- Address,
295
- keyof IAccountVersionRegistry[typeof accountType]
296
- ][]
160
+ Object.entries(AccountVersionRegistry[accountType]).map((pair) => {
161
+ const [version, def] = pair as [
162
+ LightAccountVersion<LightAccountType>,
163
+ LightAccountVersionConfig<GetEntryPointFromAccount<TAccount>>
164
+ ];
165
+
166
+ if (
167
+ def.addresses.overrides != null &&
168
+ chain.id in def.addresses.overrides!
169
+ ) {
170
+ return [def.addresses.overrides[chain.id].impl, version];
171
+ }
172
+
173
+ return [def.addresses.default.impl, version];
174
+ })
297
175
  );
298
176
 
299
177
  const factoryToVersion = new Map(
300
- Object.entries(AccountVersionRegistry[accountType])
301
- .map((pair) => {
302
- const [version, def] = pair as [
303
- keyof IAccountVersionRegistry[typeof accountType],
304
- LightAccountVersionDef
305
- ];
306
- return chain.id in def.address
307
- ? [def.address[chain.id].factory, version]
308
- : [def.address[supportedChains[0].id].factory, version];
309
- })
310
- .filter(([impl]) => impl !== null) as [
311
- Address,
312
- keyof IAccountVersionRegistry[typeof accountType]
313
- ][]
178
+ Object.entries(AccountVersionRegistry[accountType]).map((pair) => {
179
+ const [version, def] = pair as [
180
+ LightAccountVersion<LightAccountType>,
181
+ LightAccountVersionConfig<GetEntryPointFromAccount<TAccount>>
182
+ ];
183
+
184
+ if (
185
+ def.addresses.overrides != null &&
186
+ chain.id in def.addresses.overrides!
187
+ ) {
188
+ return [def.addresses.overrides[chain.id].factory, version];
189
+ }
190
+
191
+ return [def.addresses.default.factory, version];
192
+ })
314
193
  );
315
194
 
316
195
  const version =
@@ -326,36 +205,3 @@ export async function getLightAccountVersionDef<
326
205
 
327
206
  return AccountVersionRegistry[accountType][version];
328
207
  }
329
-
330
- /**
331
- * @param account - the light account to get the version for
332
- * @param chain - the chain to get the version for
333
- *
334
- * @deprecated don't use this function as this function is replaced with getLightAccountVersionDef.
335
- * Migrate to using getLightAccountVersionDef instead
336
- *
337
- * @returns the light account version for the given light account and chain
338
- */
339
- export async function getLightAccountVersion<
340
- TAccount extends LightAccountBase,
341
- TLightAccountType extends GetLightAccountType<TAccount> = GetLightAccountType<TAccount>
342
- >(
343
- account: TAccount,
344
- chain?: Chain
345
- ): Promise<GetLightAccountVersion<TLightAccountType>>;
346
-
347
- /**
348
- * Get the light account version for the given light account and chain
349
- *
350
- * @deprecated don't use this function as this function is replaced with getLightAccountVersionDef.
351
- *
352
- * @param account - the light account to get the version for
353
- * @param chain - the chain to get the version for
354
- * @returns the light account version for the given light account and chain
355
- */
356
- export async function getLightAccountVersion(
357
- account: LightAccountBase,
358
- chain: Chain = supportedChains[0]
359
- ): Promise<LightAccountVersion> {
360
- return (await getLightAccountVersionDef(account, chain)).version;
361
- }
@@ -27,12 +27,12 @@ import {
27
27
  * This middleware handles correctly aggregating signatures passed through
28
28
  * as context when sending UserOperations, proposing UserOperations, or adding signatures to a UserOperation.
29
29
  *
30
- * @param struct the user operation struct to be signed
31
- * @param param the parameters to be passed to the middleware
32
- * @param param.account the account to be used for signing
33
- * @param param.client the smart account client that will be used for RPC requests
34
- * @param param.context the context object containing the signatures to be aggregated {@link MultisigUserOperationContext}
35
- * @returns a Promise containing a UserOperation with an aggregated signature in the `signature` field
30
+ * @param {Deferrable<UserOperationStruct<TEntryPointVersion>>} struct the user operation struct to be signed
31
+ * @param {ClientMiddlewareArgs<TAccount, C, TContext, TEntryPointVersion>} args the parameters to be passed to the middleware
32
+ * @param {UserOperationOverrides<TEntryPointVersion>} args.account the account to be used for signing
33
+ * @param {MiddlewareClient} args.client the smart account client that will be used for RPC requests
34
+ * @param {MultisigUserOperationContext} args.context the context object containing the signatures to be aggregated MultisigUserOperationContext
35
+ * @returns {Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>} a Promise containing a UserOperation with an aggregated signature in the `signature` field
36
36
  */
37
37
  export const multisigSignatureMiddleware: ClientMiddlewareFn<
38
38
  MultisigUserOperationContext
@@ -8,9 +8,9 @@ import type { Signature } from "../types";
8
8
  * by signer address. The EOA SIGS contain the 65 signautre data for EOA signers and 65 bytes containing SIGNER | OFFSET | V for contract signers.
9
9
  * The OFFSET is used to fetch the signature data from the CONTRACT_SIG_DATAS.
10
10
  *
11
- * @param signatures the array of {@link Signature} objects to combine into the correct aggregated signature format excluding the upper limits
12
- * @param usingMaxValues a boolean indicating wether or not the UserOperation is using the UPPER_LIMIT for the gas and fee values
13
- * @returns the Hex representation of the signature
11
+ * @param {Signature[]} signatures the array of Signature objects to combine into the correct aggregated signature format excluding the upper limits
12
+ * @param {boolean} usingMaxValues a boolean indicating wether or not the UserOperation is using the UPPER_LIMIT for the gas and fee values
13
+ * @returns {Hex} the Hex representation of the signature
14
14
  */
15
15
  export const formatSignatures = (
16
16
  signatures: Signature[],
@@ -19,15 +19,23 @@ export type SplitAggregateSignatureParams<
19
19
  account: SmartContractAccount;
20
20
  request: UserOperationRequest<TEntryPointVersion>;
21
21
  };
22
+
23
+ export type SplitAggregateSignatureResult = {
24
+ upperLimitPvg: Hex;
25
+ upperLimitMaxFeePerGas: Hex;
26
+ upperLimitMaxPriorityFeePerGas: Hex;
27
+ signatures: Signature[];
28
+ };
29
+
22
30
  /**
23
31
  * Takes an aggregated signature and threshold and splits it into its components
24
32
  *
25
- * @param args - the arguments for the split
26
- * @param args.aggregateSignature - the aggregated signature to split
27
- * @param args.threshold - the threshold for the signature
28
- * @param args.account - the account which the signature is valid for
29
- * @param args.request - the user operation request that the signature is for
30
- * @returns the signature split into its upper limits and current signatures
33
+ * @param {SplitAggregateSignatureParams<TAccount>} args - the arguments for the split
34
+ * @param {Hex} args.aggregateSignature - the aggregated signature to split
35
+ * @param {number} args.threshold - the threshold for the signature
36
+ * @param {SmartContractAccount} args.account - the account which the signature is valid for
37
+ * @param {UserOperationRequest<TEntryPointVersion>} args.request - the user operation request that the signature is for
38
+ * @returns {Promise<SplitAggregateSignatureResult>} the signature split into its upper limits and current signatures
31
39
  */
32
40
  export const splitAggregatedSignature = async <
33
41
  TAccount extends SmartContractAccount | undefined =
@@ -35,12 +43,7 @@ export const splitAggregatedSignature = async <
35
43
  | undefined
36
44
  >(
37
45
  args: SplitAggregateSignatureParams<TAccount>
38
- ): Promise<{
39
- upperLimitPvg: Hex;
40
- upperLimitMaxFeePerGas: Hex;
41
- upperLimitMaxPriorityFeePerGas: Hex;
42
- signatures: Signature[];
43
- }> => {
46
+ ): Promise<SplitAggregateSignatureResult> => {
44
47
  const { aggregatedSignature, threshold, account, request } = args;
45
48
  if (aggregatedSignature.length < 192 + (65 * threshold - 1)) {
46
49
  throw new InvalidAggregatedSignatureError();