@account-kit/smart-contracts 4.0.0-alpha.5 → 4.0.0-alpha.7
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/cjs/src/index.d.ts +1 -1
- package/dist/cjs/src/index.js +2 -2
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/light-account/accounts/account.d.ts +5 -6
- package/dist/cjs/src/light-account/accounts/account.js +3 -2
- package/dist/cjs/src/light-account/accounts/account.js.map +1 -1
- package/dist/cjs/src/light-account/accounts/base.d.ts +7 -6
- package/dist/cjs/src/light-account/accounts/base.js +8 -8
- package/dist/cjs/src/light-account/accounts/base.js.map +1 -1
- package/dist/cjs/src/light-account/accounts/multiOwner.d.ts +5 -5
- package/dist/cjs/src/light-account/accounts/multiOwner.js +3 -2
- package/dist/cjs/src/light-account/accounts/multiOwner.js.map +1 -1
- package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.d.ts +1 -1
- package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
- package/dist/cjs/src/light-account/types.d.ts +23 -31
- package/dist/cjs/src/light-account/types.js.map +1 -1
- package/dist/cjs/src/light-account/utils.d.ts +7 -10
- package/dist/cjs/src/light-account/utils.js +59 -88
- package/dist/cjs/src/light-account/utils.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/middleware.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/utils/formatSignatures.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +3 -2
- package/dist/cjs/src/msca/plugins/multisig/utils/splitAggregatedSignature.js.map +1 -1
- package/dist/cjs/src/msca/plugins/session-key/permissions.js.map +1 -1
- package/dist/cjs/src/msca/plugins/session-key/signer.js.map +1 -1
- package/dist/cjs/src/msca/utils.js.map +1 -1
- package/dist/esm/src/index.d.ts +1 -1
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/light-account/accounts/account.d.ts +5 -6
- package/dist/esm/src/light-account/accounts/account.js +3 -2
- package/dist/esm/src/light-account/accounts/account.js.map +1 -1
- package/dist/esm/src/light-account/accounts/base.d.ts +7 -6
- package/dist/esm/src/light-account/accounts/base.js +8 -8
- package/dist/esm/src/light-account/accounts/base.js.map +1 -1
- package/dist/esm/src/light-account/accounts/multiOwner.d.ts +5 -5
- package/dist/esm/src/light-account/accounts/multiOwner.js +4 -3
- package/dist/esm/src/light-account/accounts/multiOwner.js.map +1 -1
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.d.ts +1 -1
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
- package/dist/esm/src/light-account/types.d.ts +23 -31
- package/dist/esm/src/light-account/types.js.map +1 -1
- package/dist/esm/src/light-account/utils.d.ts +7 -10
- package/dist/esm/src/light-account/utils.js +57 -85
- package/dist/esm/src/light-account/utils.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/middleware.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/utils/formatSignatures.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +3 -2
- package/dist/esm/src/msca/plugins/multisig/utils/splitAggregatedSignature.js.map +1 -1
- package/dist/esm/src/msca/plugins/session-key/permissions.js.map +1 -1
- package/dist/esm/src/msca/plugins/session-key/signer.js.map +1 -1
- package/dist/esm/src/msca/utils.js.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/light-account/accounts/account.d.ts +5 -6
- package/dist/types/src/light-account/accounts/account.d.ts.map +1 -1
- package/dist/types/src/light-account/accounts/base.d.ts +7 -6
- package/dist/types/src/light-account/accounts/base.d.ts.map +1 -1
- package/dist/types/src/light-account/accounts/multiOwner.d.ts +5 -5
- package/dist/types/src/light-account/accounts/multiOwner.d.ts.map +1 -1
- package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts +1 -1
- package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts.map +1 -1
- package/dist/types/src/light-account/types.d.ts +23 -118
- package/dist/types/src/light-account/types.d.ts.map +1 -1
- package/dist/types/src/light-account/utils.d.ts +19 -48
- package/dist/types/src/light-account/utils.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multisig/middleware.d.ts +6 -6
- package/dist/types/src/msca/plugins/multisig/utils/formatSignatures.d.ts +3 -3
- package/dist/types/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +13 -12
- package/dist/types/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/session-key/permissions.d.ts +147 -1
- package/dist/types/src/msca/plugins/session-key/permissions.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/session-key/signer.d.ts +71 -1
- package/dist/types/src/msca/plugins/session-key/signer.d.ts.map +1 -1
- package/dist/types/src/msca/utils.d.ts +6 -6
- package/package.json +6 -5
- package/src/index.ts +1 -1
- package/src/light-account/accounts/account.ts +24 -45
- package/src/light-account/accounts/base.ts +39 -68
- package/src/light-account/accounts/multiOwner.ts +29 -43
- package/src/light-account/clients/multiOwnerAlchemyClient.ts +1 -1
- package/src/light-account/types.ts +31 -188
- package/src/light-account/utils.ts +91 -245
- package/src/msca/plugins/multisig/middleware.ts +6 -6
- package/src/msca/plugins/multisig/utils/formatSignatures.ts +3 -3
- package/src/msca/plugins/multisig/utils/splitAggregatedSignature.ts +15 -12
- package/src/msca/plugins/session-key/permissions.ts +147 -1
- package/src/msca/plugins/session-key/signer.ts +71 -1
- package/src/msca/utils.ts +6 -6
- package/dist/cjs/src/light-account/schema.d.ts +0 -21
- package/dist/cjs/src/light-account/schema.js +0 -30
- package/dist/cjs/src/light-account/schema.js.map +0 -1
- package/dist/esm/src/light-account/schema.d.ts +0 -21
- package/dist/esm/src/light-account/schema.js +0 -27
- package/dist/esm/src/light-account/schema.js.map +0 -1
- package/dist/types/src/light-account/schema.d.ts +0 -22
- package/dist/types/src/light-account/schema.d.ts.map +0 -1
- package/src/light-account/schema.ts +0 -39
|
@@ -1,142 +1,71 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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:
|
|
16
|
+
export const AccountVersionRegistry: LightAccountVersionConfigs = {
|
|
68
17
|
LightAccount: {
|
|
69
18
|
"v1.0.1": {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
* @
|
|
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
|
|
84
|
+
* Utility method returning the default light account factory address given a Chain object
|
|
162
85
|
*
|
|
163
|
-
* @param chain - a
|
|
164
|
-
* @param version - the version of the light account to get the factory address for
|
|
165
|
-
* @returns
|
|
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:
|
|
93
|
+
version: LightAccountVersion<"LightAccount">
|
|
171
94
|
): Address => {
|
|
172
|
-
|
|
173
|
-
AccountVersionRegistry.LightAccount[version].
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
|
103
|
+
* Utility method returning the default multi owner light account factory address given a Chain object
|
|
182
104
|
*
|
|
183
|
-
* @param chain - a
|
|
184
|
-
* @param version - the version of the light account to get the factory address for
|
|
185
|
-
* @returns
|
|
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:
|
|
111
|
+
version: LightAccountVersion<"MultiOwnerLightAccount">
|
|
191
112
|
) => {
|
|
192
|
-
|
|
193
|
-
AccountVersionRegistry.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
224
|
-
|
|
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
|
-
* @
|
|
232
|
-
* @
|
|
233
|
-
* @
|
|
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
|
|
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<
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
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
|
|
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();
|