@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.
- package/dist/cjs/plugindefs/multi-owner/config.js +16 -17
- package/dist/cjs/plugindefs/multi-owner/config.js.map +1 -1
- package/dist/cjs/plugindefs/multisig/config.js +15 -15
- package/dist/cjs/plugindefs/multisig/config.js.map +1 -1
- package/dist/cjs/plugindefs/session-key/config.js +17 -17
- package/dist/cjs/plugindefs/session-key/config.js.map +1 -1
- 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/alchemyClient.d.ts +1 -1
- package/dist/cjs/src/light-account/clients/alchemyClient.js.map +1 -1
- package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.d.ts +2 -2
- package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
- package/dist/cjs/src/light-account/decorators/lightAccount.js.map +1 -1
- package/dist/cjs/src/light-account/decorators/multiOwnerLightAccount.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 -87
- package/dist/cjs/src/light-account/utils.js.map +1 -1
- package/dist/cjs/src/msca/client/alchemyClient.d.ts +1 -1
- package/dist/cjs/src/msca/client/alchemyClient.js.map +1 -1
- package/dist/cjs/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
- package/dist/cjs/src/msca/client/multiSigAlchemyClient.js +1 -1
- package/dist/cjs/src/msca/client/multiSigAlchemyClient.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 +11 -10
- package/dist/cjs/src/msca/utils.js.map +1 -1
- package/dist/esm/plugindefs/multi-owner/config.js +1 -2
- package/dist/esm/plugindefs/multi-owner/config.js.map +1 -1
- package/dist/esm/plugindefs/multisig/config.js +1 -1
- package/dist/esm/plugindefs/multisig/config.js.map +1 -1
- package/dist/esm/plugindefs/session-key/config.js +1 -1
- package/dist/esm/plugindefs/session-key/config.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/alchemyClient.d.ts +1 -1
- package/dist/esm/src/light-account/clients/alchemyClient.js.map +1 -1
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.d.ts +2 -2
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
- package/dist/esm/src/light-account/decorators/lightAccount.js.map +1 -1
- package/dist/esm/src/light-account/decorators/multiOwnerLightAccount.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 -84
- package/dist/esm/src/light-account/utils.js.map +1 -1
- package/dist/esm/src/msca/client/alchemyClient.d.ts +1 -1
- package/dist/esm/src/msca/client/alchemyClient.js.map +1 -1
- package/dist/esm/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
- package/dist/esm/src/msca/client/multiSigAlchemyClient.js +1 -1
- package/dist/esm/src/msca/client/multiSigAlchemyClient.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 +2 -1
- package/dist/esm/src/msca/utils.js.map +1 -1
- package/dist/types/plugindefs/multi-owner/config.d.ts.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/alchemyClient.d.ts +1 -1
- package/dist/types/src/light-account/clients/alchemyClient.d.ts.map +1 -1
- package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts +2 -2
- package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts.map +1 -1
- package/dist/types/src/light-account/decorators/lightAccount.d.ts +1 -1
- package/dist/types/src/light-account/decorators/multiOwnerLightAccount.d.ts +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/client/alchemyClient.d.ts +1 -1
- package/dist/types/src/msca/client/alchemyClient.d.ts.map +1 -1
- package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
- package/dist/types/src/msca/client/multiSigAlchemyClient.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/dist/types/src/msca/utils.d.ts.map +1 -1
- package/package.json +7 -6
- package/plugindefs/multi-owner/config.ts +1 -2
- package/plugindefs/multisig/config.ts +1 -1
- package/plugindefs/session-key/config.ts +1 -1
- 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/alchemyClient.ts +2 -2
- package/src/light-account/clients/multiOwnerAlchemyClient.ts +3 -3
- package/src/light-account/decorators/lightAccount.ts +1 -1
- package/src/light-account/decorators/multiOwnerLightAccount.ts +1 -1
- package/src/light-account/types.ts +31 -188
- package/src/light-account/utils.ts +91 -246
- package/src/msca/client/alchemyClient.ts +2 -2
- package/src/msca/client/multiSigAlchemyClient.ts +5 -5
- 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 +15 -13
- 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,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
|
-
|
|
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:
|
|
16
|
+
export const AccountVersionRegistry: LightAccountVersionConfigs = {
|
|
69
17
|
LightAccount: {
|
|
70
18
|
"v1.0.1": {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
* @
|
|
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
|
|
84
|
+
* Utility method returning the default light account factory address given a Chain object
|
|
163
85
|
*
|
|
164
|
-
* @param chain - a
|
|
165
|
-
* @param version - the version of the light account to get the factory address for
|
|
166
|
-
* @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
|
|
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:
|
|
93
|
+
version: LightAccountVersion<"LightAccount">
|
|
172
94
|
): Address => {
|
|
173
|
-
|
|
174
|
-
AccountVersionRegistry.LightAccount[version].
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
|
103
|
+
* Utility method returning the default multi owner light account factory address given a Chain object
|
|
183
104
|
*
|
|
184
|
-
* @param chain - a
|
|
185
|
-
* @param version - the version of the light account to get the factory address for
|
|
186
|
-
* @returns
|
|
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:
|
|
111
|
+
version: LightAccountVersion<"MultiOwnerLightAccount">
|
|
192
112
|
) => {
|
|
193
|
-
|
|
194
|
-
AccountVersionRegistry.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
225
|
-
|
|
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
|
-
* @
|
|
233
|
-
* @
|
|
234
|
-
* @
|
|
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
|
|
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<
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
|
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
|
|
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
|
|
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();
|