@account-kit/smart-contracts 4.0.0-alpha.1 → 4.0.0-alpha.10

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 (148) hide show
  1. package/dist/cjs/plugindefs/multi-owner/config.js +16 -17
  2. package/dist/cjs/plugindefs/multi-owner/config.js.map +1 -1
  3. package/dist/cjs/plugindefs/multisig/config.js +15 -15
  4. package/dist/cjs/plugindefs/multisig/config.js.map +1 -1
  5. package/dist/cjs/plugindefs/session-key/config.js +17 -17
  6. package/dist/cjs/plugindefs/session-key/config.js.map +1 -1
  7. package/dist/cjs/src/index.d.ts +1 -1
  8. package/dist/cjs/src/index.js +2 -2
  9. package/dist/cjs/src/index.js.map +1 -1
  10. package/dist/cjs/src/light-account/accounts/account.d.ts +5 -6
  11. package/dist/cjs/src/light-account/accounts/account.js +3 -2
  12. package/dist/cjs/src/light-account/accounts/account.js.map +1 -1
  13. package/dist/cjs/src/light-account/accounts/base.d.ts +7 -6
  14. package/dist/cjs/src/light-account/accounts/base.js +8 -8
  15. package/dist/cjs/src/light-account/accounts/base.js.map +1 -1
  16. package/dist/cjs/src/light-account/accounts/multiOwner.d.ts +5 -5
  17. package/dist/cjs/src/light-account/accounts/multiOwner.js +3 -2
  18. package/dist/cjs/src/light-account/accounts/multiOwner.js.map +1 -1
  19. package/dist/cjs/src/light-account/clients/alchemyClient.d.ts +1 -1
  20. package/dist/cjs/src/light-account/clients/alchemyClient.js.map +1 -1
  21. package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.d.ts +2 -2
  22. package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
  23. package/dist/cjs/src/light-account/decorators/lightAccount.js.map +1 -1
  24. package/dist/cjs/src/light-account/decorators/multiOwnerLightAccount.js.map +1 -1
  25. package/dist/cjs/src/light-account/types.d.ts +23 -31
  26. package/dist/cjs/src/light-account/types.js.map +1 -1
  27. package/dist/cjs/src/light-account/utils.d.ts +7 -10
  28. package/dist/cjs/src/light-account/utils.js +59 -87
  29. package/dist/cjs/src/light-account/utils.js.map +1 -1
  30. package/dist/cjs/src/msca/client/alchemyClient.d.ts +1 -1
  31. package/dist/cjs/src/msca/client/alchemyClient.js.map +1 -1
  32. package/dist/cjs/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
  33. package/dist/cjs/src/msca/client/multiSigAlchemyClient.js +1 -1
  34. package/dist/cjs/src/msca/client/multiSigAlchemyClient.js.map +1 -1
  35. package/dist/cjs/src/msca/plugins/multisig/middleware.js.map +1 -1
  36. package/dist/cjs/src/msca/plugins/multisig/utils/formatSignatures.js.map +1 -1
  37. package/dist/cjs/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +3 -2
  38. package/dist/cjs/src/msca/plugins/multisig/utils/splitAggregatedSignature.js.map +1 -1
  39. package/dist/cjs/src/msca/plugins/session-key/permissions.js.map +1 -1
  40. package/dist/cjs/src/msca/plugins/session-key/signer.js.map +1 -1
  41. package/dist/cjs/src/msca/utils.js +11 -10
  42. package/dist/cjs/src/msca/utils.js.map +1 -1
  43. package/dist/esm/plugindefs/multi-owner/config.js +1 -2
  44. package/dist/esm/plugindefs/multi-owner/config.js.map +1 -1
  45. package/dist/esm/plugindefs/multisig/config.js +1 -1
  46. package/dist/esm/plugindefs/multisig/config.js.map +1 -1
  47. package/dist/esm/plugindefs/session-key/config.js +1 -1
  48. package/dist/esm/plugindefs/session-key/config.js.map +1 -1
  49. package/dist/esm/src/index.d.ts +1 -1
  50. package/dist/esm/src/index.js +1 -1
  51. package/dist/esm/src/index.js.map +1 -1
  52. package/dist/esm/src/light-account/accounts/account.d.ts +5 -6
  53. package/dist/esm/src/light-account/accounts/account.js +3 -2
  54. package/dist/esm/src/light-account/accounts/account.js.map +1 -1
  55. package/dist/esm/src/light-account/accounts/base.d.ts +7 -6
  56. package/dist/esm/src/light-account/accounts/base.js +8 -8
  57. package/dist/esm/src/light-account/accounts/base.js.map +1 -1
  58. package/dist/esm/src/light-account/accounts/multiOwner.d.ts +5 -5
  59. package/dist/esm/src/light-account/accounts/multiOwner.js +4 -3
  60. package/dist/esm/src/light-account/accounts/multiOwner.js.map +1 -1
  61. package/dist/esm/src/light-account/clients/alchemyClient.d.ts +1 -1
  62. package/dist/esm/src/light-account/clients/alchemyClient.js.map +1 -1
  63. package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.d.ts +2 -2
  64. package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
  65. package/dist/esm/src/light-account/decorators/lightAccount.js.map +1 -1
  66. package/dist/esm/src/light-account/decorators/multiOwnerLightAccount.js.map +1 -1
  67. package/dist/esm/src/light-account/types.d.ts +23 -31
  68. package/dist/esm/src/light-account/types.js.map +1 -1
  69. package/dist/esm/src/light-account/utils.d.ts +7 -10
  70. package/dist/esm/src/light-account/utils.js +57 -84
  71. package/dist/esm/src/light-account/utils.js.map +1 -1
  72. package/dist/esm/src/msca/client/alchemyClient.d.ts +1 -1
  73. package/dist/esm/src/msca/client/alchemyClient.js.map +1 -1
  74. package/dist/esm/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
  75. package/dist/esm/src/msca/client/multiSigAlchemyClient.js +1 -1
  76. package/dist/esm/src/msca/client/multiSigAlchemyClient.js.map +1 -1
  77. package/dist/esm/src/msca/plugins/multisig/middleware.js.map +1 -1
  78. package/dist/esm/src/msca/plugins/multisig/utils/formatSignatures.js.map +1 -1
  79. package/dist/esm/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +3 -2
  80. package/dist/esm/src/msca/plugins/multisig/utils/splitAggregatedSignature.js.map +1 -1
  81. package/dist/esm/src/msca/plugins/session-key/permissions.js.map +1 -1
  82. package/dist/esm/src/msca/plugins/session-key/signer.js.map +1 -1
  83. package/dist/esm/src/msca/utils.js +2 -1
  84. package/dist/esm/src/msca/utils.js.map +1 -1
  85. package/dist/types/plugindefs/multi-owner/config.d.ts.map +1 -1
  86. package/dist/types/src/index.d.ts +1 -1
  87. package/dist/types/src/index.d.ts.map +1 -1
  88. package/dist/types/src/light-account/accounts/account.d.ts +5 -6
  89. package/dist/types/src/light-account/accounts/account.d.ts.map +1 -1
  90. package/dist/types/src/light-account/accounts/base.d.ts +7 -6
  91. package/dist/types/src/light-account/accounts/base.d.ts.map +1 -1
  92. package/dist/types/src/light-account/accounts/multiOwner.d.ts +5 -5
  93. package/dist/types/src/light-account/accounts/multiOwner.d.ts.map +1 -1
  94. package/dist/types/src/light-account/clients/alchemyClient.d.ts +1 -1
  95. package/dist/types/src/light-account/clients/alchemyClient.d.ts.map +1 -1
  96. package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts +2 -2
  97. package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts.map +1 -1
  98. package/dist/types/src/light-account/decorators/lightAccount.d.ts +1 -1
  99. package/dist/types/src/light-account/decorators/multiOwnerLightAccount.d.ts +1 -1
  100. package/dist/types/src/light-account/types.d.ts +23 -118
  101. package/dist/types/src/light-account/types.d.ts.map +1 -1
  102. package/dist/types/src/light-account/utils.d.ts +19 -48
  103. package/dist/types/src/light-account/utils.d.ts.map +1 -1
  104. package/dist/types/src/msca/client/alchemyClient.d.ts +1 -1
  105. package/dist/types/src/msca/client/alchemyClient.d.ts.map +1 -1
  106. package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
  107. package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts.map +1 -1
  108. package/dist/types/src/msca/plugins/multisig/middleware.d.ts +6 -6
  109. package/dist/types/src/msca/plugins/multisig/utils/formatSignatures.d.ts +3 -3
  110. package/dist/types/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +13 -12
  111. package/dist/types/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts.map +1 -1
  112. package/dist/types/src/msca/plugins/session-key/permissions.d.ts +147 -1
  113. package/dist/types/src/msca/plugins/session-key/permissions.d.ts.map +1 -1
  114. package/dist/types/src/msca/plugins/session-key/signer.d.ts +71 -1
  115. package/dist/types/src/msca/plugins/session-key/signer.d.ts.map +1 -1
  116. package/dist/types/src/msca/utils.d.ts +6 -6
  117. package/dist/types/src/msca/utils.d.ts.map +1 -1
  118. package/package.json +7 -6
  119. package/plugindefs/multi-owner/config.ts +1 -2
  120. package/plugindefs/multisig/config.ts +1 -1
  121. package/plugindefs/session-key/config.ts +1 -1
  122. package/src/index.ts +1 -1
  123. package/src/light-account/accounts/account.ts +24 -45
  124. package/src/light-account/accounts/base.ts +39 -68
  125. package/src/light-account/accounts/multiOwner.ts +29 -43
  126. package/src/light-account/clients/alchemyClient.ts +2 -2
  127. package/src/light-account/clients/multiOwnerAlchemyClient.ts +3 -3
  128. package/src/light-account/decorators/lightAccount.ts +1 -1
  129. package/src/light-account/decorators/multiOwnerLightAccount.ts +1 -1
  130. package/src/light-account/types.ts +31 -188
  131. package/src/light-account/utils.ts +91 -246
  132. package/src/msca/client/alchemyClient.ts +2 -2
  133. package/src/msca/client/multiSigAlchemyClient.ts +5 -5
  134. package/src/msca/plugins/multisig/middleware.ts +6 -6
  135. package/src/msca/plugins/multisig/utils/formatSignatures.ts +3 -3
  136. package/src/msca/plugins/multisig/utils/splitAggregatedSignature.ts +15 -12
  137. package/src/msca/plugins/session-key/permissions.ts +147 -1
  138. package/src/msca/plugins/session-key/signer.ts +71 -1
  139. package/src/msca/utils.ts +15 -13
  140. package/dist/cjs/src/light-account/schema.d.ts +0 -21
  141. package/dist/cjs/src/light-account/schema.js +0 -30
  142. package/dist/cjs/src/light-account/schema.js.map +0 -1
  143. package/dist/esm/src/light-account/schema.d.ts +0 -21
  144. package/dist/esm/src/light-account/schema.js +0 -27
  145. package/dist/esm/src/light-account/schema.js.map +0 -1
  146. package/dist/types/src/light-account/schema.d.ts +0 -22
  147. package/dist/types/src/light-account/schema.d.ts.map +0 -1
  148. package/src/light-account/schema.ts +0 -39
@@ -1,143 +1,71 @@
1
- import {
2
- DefaultFactoryNotDefinedError,
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
- toRecord,
21
- zora,
22
- zoraSepolia,
23
- } from "@aa-sdk/core";
1
+ import type { GetEntryPointFromAccount } from "@aa-sdk/core";
24
2
  import { fromHex, type Address, type Chain } from "viem";
25
3
  import type { LightAccountBase } from "./accounts/base";
26
4
  import type {
27
- AccountVersionDef,
28
- GetLightAccountType,
29
- GetLightAccountVersion,
30
- GetLightAccountVersionFromAccount,
31
- IAccountVersionRegistry,
32
5
  LightAccountType,
33
6
  LightAccountVersion,
34
- LightAccountVersionDef,
7
+ LightAccountVersionConfig,
8
+ LightAccountVersionConfigs,
35
9
  } from "./types";
36
10
 
37
- /**
38
- * Light account deployed chains
39
- *
40
- */
41
- export const supportedChains: Chain[] = [
42
- mainnet,
43
- sepolia,
44
- goerli,
45
- polygon,
46
- polygonAmoy,
47
- polygonMumbai,
48
- optimism,
49
- optimismGoerli,
50
- optimismSepolia,
51
- arbitrum,
52
- arbitrumGoerli,
53
- arbitrumSepolia,
54
- base,
55
- baseGoerli,
56
- baseSepolia,
57
- fraxtal,
58
- fraxtalSepolia,
59
- zora,
60
- zoraSepolia,
61
- ];
62
-
63
11
  /**
64
12
  * Account version registry interface that defines the light account versions
65
13
  * and the version definition for each light account type
66
14
  *
67
15
  */
68
- export const AccountVersionRegistry: IAccountVersionRegistry = {
16
+ export const AccountVersionRegistry: LightAccountVersionConfigs = {
69
17
  LightAccount: {
70
18
  "v1.0.1": {
71
- type: "LightAccount",
72
- version: "v1.0.1",
73
- address: toRecord<Chain, "id", { factory: Address; impl: Address }>(
74
- supportedChains,
75
- "id",
76
- () => ({
19
+ entryPointVersion: "0.6.0",
20
+ addresses: {
21
+ default: {
77
22
  factory:
78
23
  "0x000000893A26168158fbeaDD9335Be5bC96592E2".toLowerCase() as Address,
79
24
  impl: "0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0".toLowerCase() as Address,
80
- })
81
- ),
82
- entryPointVersion: "0.6.0",
25
+ },
26
+ },
83
27
  },
84
28
  "v1.0.2": {
85
- type: "LightAccount",
86
- version: "v1.0.2",
87
- address: toRecord<Chain, "id", { factory: Address; impl: Address }>(
88
- supportedChains,
89
- "id",
90
- () => ({
29
+ entryPointVersion: "0.6.0",
30
+ addresses: {
31
+ default: {
91
32
  factory:
92
33
  "0x00000055C0b4fA41dde26A74435ff03692292FBD".toLowerCase() as Address,
93
34
  impl: "0x5467b1947F47d0646704EB801E075e72aeAe8113".toLowerCase() as Address,
94
- })
95
- ),
96
- entryPointVersion: "0.6.0",
35
+ },
36
+ },
97
37
  },
98
38
  "v1.1.0": {
99
- type: "LightAccount",
100
- version: "v1.1.0",
101
- address: toRecord<Chain, "id", { factory: Address; impl: Address }>(
102
- supportedChains,
103
- "id",
104
- () => ({
39
+ entryPointVersion: "0.6.0",
40
+ addresses: {
41
+ default: {
105
42
  factory:
106
43
  "0x00004EC70002a32400f8ae005A26081065620D20".toLowerCase() as Address,
107
44
  impl: "0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba".toLowerCase() as Address,
108
- })
109
- ),
110
- entryPointVersion: "0.6.0",
45
+ },
46
+ },
111
47
  },
112
48
  "v2.0.0": {
113
- type: "LightAccount",
114
- version: "v2.0.0",
115
- address: toRecord<Chain, "id", { factory: Address; impl: Address }>(
116
- supportedChains,
117
- "id",
118
- () => ({
49
+ entryPointVersion: "0.7.0",
50
+ addresses: {
51
+ default: {
119
52
  factory:
120
53
  "0x0000000000400CdFef5E2714E63d8040b700BC24".toLowerCase() as Address,
121
54
  impl: "0x8E8e658E22B12ada97B402fF0b044D6A325013C7".toLowerCase() as Address,
122
- })
123
- ),
124
- entryPointVersion: "0.7.0",
55
+ },
56
+ },
125
57
  },
126
58
  },
127
59
  MultiOwnerLightAccount: {
128
60
  "v2.0.0": {
129
- type: "MultiOwnerLightAccount",
130
- version: "v2.0.0",
131
- address: toRecord<Chain, "id", { factory: Address; impl: Address }>(
132
- supportedChains,
133
- "id",
134
- () => ({
61
+ entryPointVersion: "0.7.0",
62
+ addresses: {
63
+ default: {
135
64
  factory:
136
65
  "0x000000000019d2Ee9F2729A65AfE20bb0020AefC".toLowerCase() as Address,
137
66
  impl: "0xd2c27F9eE8E4355f71915ffD5568cB3433b6823D".toLowerCase() as Address,
138
- })
139
- ),
140
- entryPointVersion: "0.7.0",
67
+ },
68
+ },
141
69
  },
142
70
  },
143
71
  };
@@ -146,60 +74,48 @@ export const AccountVersionRegistry: IAccountVersionRegistry = {
146
74
  * Get the default light account version for the given light account type
147
75
  *
148
76
  * @template {LightAccountType} TLightAccountType
149
- * @param type - the light account type to get the default version for
150
- * @returns the default version for the given light account type
77
+ * @returns {LightAccountVersion<TLightAccountType>} the default version for the given light account type
151
78
  */
152
79
  export const defaultLightAccountVersion = <
153
80
  TLightAccountType extends LightAccountType
154
- >(
155
- type: TLightAccountType
156
- ): GetLightAccountVersion<TLightAccountType> =>
157
- (type === "LightAccount"
158
- ? "v1.1.0"
159
- : "v2.0.0") as GetLightAccountVersion<TLightAccountType>;
81
+ >(): LightAccountVersion<TLightAccountType> => "v2.0.0";
160
82
 
161
83
  /**
162
- * 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
163
85
  *
164
- * @param chain - a {@link Chain} object
165
- * @param version - the version of the light account to get the factory address for
166
- * @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
167
89
  * @throws if the chain doesn't have an address currently deployed
168
90
  */
169
91
  export const getDefaultLightAccountFactoryAddress = (
170
92
  chain: Chain,
171
- version: GetLightAccountVersion<"LightAccount">
93
+ version: LightAccountVersion<"LightAccount">
172
94
  ): Address => {
173
- const address =
174
- AccountVersionRegistry.LightAccount[version].address[chain.id] ??
175
- AccountVersionRegistry.LightAccount[version].address[supportedChains[0].id];
176
- if (!address)
177
- throw new DefaultFactoryNotDefinedError("LightAccount", chain, "0.6.0");
178
- return address.factory;
95
+ return (
96
+ AccountVersionRegistry.LightAccount[version].addresses.overrides?.[chain.id]
97
+ ?.factory ??
98
+ AccountVersionRegistry.LightAccount[version].addresses.default.factory
99
+ );
179
100
  };
180
101
 
181
102
  /**
182
- * 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
183
104
  *
184
- * @param chain - a {@link Chain} object
185
- * @param version - the version of the light account to get the factory address for
186
- * @returns a {@link Address} for the given chain
187
- * @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
188
108
  */
189
109
  export const getDefaultMultiOwnerLightAccountFactoryAddress = (
190
110
  chain: Chain,
191
- version: GetLightAccountVersion<"MultiOwnerLightAccount">
111
+ version: LightAccountVersion<"MultiOwnerLightAccount">
192
112
  ) => {
193
- const address =
194
- AccountVersionRegistry.LightAccount[version].address[chain.id] ??
195
- AccountVersionRegistry.LightAccount[version].address[supportedChains[0].id];
196
- if (!address)
197
- throw new DefaultFactoryNotDefinedError(
198
- "MultiOwnerLightAccount",
199
- chain,
200
- "0.7.0"
201
- );
202
- return address.factory;
113
+ return (
114
+ AccountVersionRegistry.MultiOwnerLightAccount[version].addresses
115
+ .overrides?.[chain.id]?.factory ??
116
+ AccountVersionRegistry.MultiOwnerLightAccount[version].addresses.default
117
+ .factory
118
+ );
203
119
  };
204
120
 
205
121
  /**
@@ -220,98 +136,60 @@ export const LightAccountUnsupported1271Impls = [
220
136
  * Light accounts with versions v1.0.1 and v1.0.2 do not support 1271 signing.
221
137
  */
222
138
  export const LightAccountUnsupported1271Factories = new Set(
223
- LightAccountUnsupported1271Impls.map((x) =>
224
- Object.values(x.address).map((addr) => addr.factory)
225
- ).flat()
139
+ LightAccountUnsupported1271Impls.map((x) => [
140
+ x.addresses.default.factory,
141
+ ...Object.values(x.addresses.overrides ?? {}).map((z) => z.factory),
142
+ ]).flat()
226
143
  );
227
144
 
228
145
  /**
229
146
  * Get the light account version definition for the given light account and chain
230
147
  *
231
148
  * @template {LightAccountBase} TAccount
232
- * @template {GetLightAccountType<TAccount>} TLightAccountType
233
- * @template {GetLightAccountVersion<TLightAccountType>} TLightAccountVersion
234
- * @param account - the light account to get the version for
235
- * @param chain - the chain to get the version for
236
- * @returns the light account version definition for the given light account and chain
237
- */
238
- export async function getLightAccountVersionDef<
239
- TAccount extends LightAccountBase,
240
- TLightAccountType extends GetLightAccountType<TAccount> = GetLightAccountType<TAccount>,
241
- TLightAccountVersion extends GetLightAccountVersion<TLightAccountType> = GetLightAccountVersion<TLightAccountType>
242
- >(
243
- account: TAccount,
244
- chain: Chain
245
- ): Promise<LightAccountVersionDef<TLightAccountType, TLightAccountVersion>>;
246
-
247
- /**
248
- * Get the light account version definition for the given light account and chain
249
- *
250
- * @template {LightAccountBase} TAccount
251
- * @template {GetLightAccountType<TAccount>} TLightAccountType
252
- * @param account - the light account to get the version for
253
- * @param chain - the chain to get the version for
254
- * @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
255
152
  */
256
- export async function getLightAccountVersionDef<
257
- TAccount extends LightAccountBase,
258
- TLightAccountType extends GetLightAccountType<TAccount> = GetLightAccountType<TAccount>
259
- >(
260
- account: TAccount,
261
- chain: Chain
262
- ): Promise<
263
- AccountVersionDef<
264
- TLightAccountType,
265
- GetLightAccountVersion<TLightAccountType>
266
- >
267
- >;
268
-
269
- /**
270
- * Get the light account version definition for the given light account and chain
271
- *
272
- * @template {LightAccountBase} TAccount
273
- * @param account - the light account to get the version for
274
- * @param chain - the chain to get the version for
275
- * @returns the light account version definition for the given light account and chain
276
- */
277
- export async function getLightAccountVersionDef<
153
+ export async function getLightAccountVersionForAccount<
278
154
  TAccount extends LightAccountBase
279
- >(account: TAccount, chain: Chain): Promise<AccountVersionDef> {
155
+ >(account: TAccount, chain: Chain): Promise<LightAccountVersionConfig> {
280
156
  const accountType = account.source as LightAccountType;
281
157
  const factoryAddress = await account.getFactoryAddress();
282
158
  const implAddress = await account.getImplementationAddress();
283
159
  const implToVersion = new Map(
284
- Object.entries(AccountVersionRegistry[accountType])
285
- .map((pair) => {
286
- const [version, def] = pair as [
287
- GetLightAccountVersionFromAccount<TAccount>,
288
- LightAccountVersionDef
289
- ];
290
- return chain.id in def.address
291
- ? [def.address[chain.id].impl, version]
292
- : [def.address[supportedChains[0].id].impl, version];
293
- })
294
- .filter(([impl]) => impl !== null) as [
295
- Address,
296
- keyof IAccountVersionRegistry[typeof accountType]
297
- ][]
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
+ })
298
175
  );
299
176
 
300
177
  const factoryToVersion = new Map(
301
- Object.entries(AccountVersionRegistry[accountType])
302
- .map((pair) => {
303
- const [version, def] = pair as [
304
- keyof IAccountVersionRegistry[typeof accountType],
305
- LightAccountVersionDef
306
- ];
307
- return chain.id in def.address
308
- ? [def.address[chain.id].factory, version]
309
- : [def.address[supportedChains[0].id].factory, version];
310
- })
311
- .filter(([impl]) => impl !== null) as [
312
- Address,
313
- keyof IAccountVersionRegistry[typeof accountType]
314
- ][]
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
+ })
315
193
  );
316
194
 
317
195
  const version =
@@ -327,36 +205,3 @@ export async function getLightAccountVersionDef<
327
205
 
328
206
  return AccountVersionRegistry[accountType][version];
329
207
  }
330
-
331
- /**
332
- * @param account - the light account to get the version for
333
- * @param chain - the chain to get the version for
334
- *
335
- * @deprecated don't use this function as this function is replaced with getLightAccountVersionDef.
336
- * Migrate to using getLightAccountVersionDef instead
337
- *
338
- * @returns the light account version for the given light account and chain
339
- */
340
- export async function getLightAccountVersion<
341
- TAccount extends LightAccountBase,
342
- TLightAccountType extends GetLightAccountType<TAccount> = GetLightAccountType<TAccount>
343
- >(
344
- account: TAccount,
345
- chain?: Chain
346
- ): Promise<GetLightAccountVersion<TLightAccountType>>;
347
-
348
- /**
349
- * Get the light account version for the given light account and chain
350
- *
351
- * @deprecated don't use this function as this function is replaced with getLightAccountVersionDef.
352
- *
353
- * @param account - the light account to get the version for
354
- * @param chain - the chain to get the version for
355
- * @returns the light account version for the given light account and chain
356
- */
357
- export async function getLightAccountVersion(
358
- account: LightAccountBase,
359
- chain: Chain = supportedChains[0]
360
- ): Promise<LightAccountVersion> {
361
- return (await getLightAccountVersionDef(account, chain)).version;
362
- }
@@ -1,3 +1,4 @@
1
+ import type { SmartAccountSigner } from "@aa-sdk/core";
1
2
  import {
2
3
  AlchemyProviderConfigSchema,
3
4
  createAlchemyPublicRpcClient,
@@ -17,7 +18,6 @@ import {
17
18
  type MultiOwnerPluginActions,
18
19
  type PluginManagerActions,
19
20
  } from "@account-kit/smart-contracts";
20
- import type { SmartAccountSigner } from "@aa-sdk/core";
21
21
  import {
22
22
  custom,
23
23
  type Chain,
@@ -58,7 +58,7 @@ export function createModularAccountAlchemyClient<
58
58
  * @example
59
59
  * ```ts
60
60
  * import { createModularAccountAlchemyClient } from "@account-kit/smart-contracts";
61
- * import { sepolia } from "@account-kit/infra/chains";
61
+ * import { sepolia } from "@account-kit/infra";
62
62
  * import { LocalAccountSigner } from "@aa-sdk/core";
63
63
  * import { generatePrivateKey } from "viem"
64
64
  *
@@ -1,3 +1,7 @@
1
+ import {
2
+ smartAccountClientActions,
3
+ type SmartAccountSigner,
4
+ } from "@aa-sdk/core";
1
5
  import {
2
6
  AlchemyProviderConfigSchema,
3
7
  createAlchemyPublicRpcClient,
@@ -19,10 +23,6 @@ import {
19
23
  type MultisigUserOperationContext,
20
24
  type PluginManagerActions,
21
25
  } from "@account-kit/smart-contracts";
22
- import {
23
- smartAccountClientActions,
24
- type SmartAccountSigner,
25
- } from "@aa-sdk/core";
26
26
  import {
27
27
  custom,
28
28
  type Chain,
@@ -71,7 +71,7 @@ export function createMultisigAccountAlchemyClient<
71
71
  * @example
72
72
  * ```ts
73
73
  * import { createMultisigAccountAlchemyClient } from "@account-kit/smart-contracts";
74
- * import { sepolia } from "@account-kit/infra/chains";
74
+ * import { sepolia } from "@account-kit/infra";
75
75
  * import { LocalAccountSigner } from "@aa-sdk/core";
76
76
  * import { generatePrivateKey } from "viem"
77
77
  *
@@ -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();