@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
|
@@ -23,11 +23,9 @@ import {
|
|
|
23
23
|
type Transport,
|
|
24
24
|
} from "viem";
|
|
25
25
|
import type {
|
|
26
|
-
|
|
27
|
-
GetEntryPointForLightAccountVersion,
|
|
28
|
-
GetLightAccountVersion,
|
|
26
|
+
LightAccountEntryPointVersion,
|
|
29
27
|
LightAccountType,
|
|
30
|
-
|
|
28
|
+
LightAccountVersion,
|
|
31
29
|
} from "../types.js";
|
|
32
30
|
import { AccountVersionRegistry } from "../utils.js";
|
|
33
31
|
|
|
@@ -40,91 +38,60 @@ enum SignatureType {
|
|
|
40
38
|
export type LightAccountBase<
|
|
41
39
|
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
42
40
|
TLightAccountType extends LightAccountType = LightAccountType,
|
|
43
|
-
TLightAccountVersion extends
|
|
44
|
-
TEntryPointVersion extends GetEntryPointForLightAccountVersion<
|
|
45
|
-
TLightAccountType,
|
|
46
|
-
TLightAccountVersion
|
|
47
|
-
> = GetEntryPointForLightAccountVersion<
|
|
48
|
-
TLightAccountType,
|
|
49
|
-
TLightAccountVersion
|
|
50
|
-
>
|
|
41
|
+
TLightAccountVersion extends LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>
|
|
51
42
|
> = SmartContractAccountWithSigner<
|
|
52
43
|
TLightAccountType,
|
|
53
44
|
TSigner,
|
|
54
|
-
|
|
45
|
+
LightAccountEntryPointVersion<TLightAccountType, TLightAccountVersion>
|
|
55
46
|
> & {
|
|
56
47
|
getLightAccountVersion: () => TLightAccountVersion;
|
|
57
48
|
};
|
|
58
49
|
|
|
59
50
|
//#region CreateLightAccountBaseParams
|
|
60
51
|
export type CreateLightAccountBaseParams<
|
|
52
|
+
TLightAccountType extends LightAccountType,
|
|
53
|
+
TLightAccountVersion extends LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>,
|
|
61
54
|
TTransport extends Transport = Transport,
|
|
62
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
63
|
-
TLightAccountType extends LightAccountType = LightAccountType,
|
|
64
|
-
TLightAccountVersion extends GetLightAccountVersion<TLightAccountType> = GetLightAccountVersion<TLightAccountType>,
|
|
65
|
-
TEntryPointVersion extends GetEntryPointForLightAccountVersion<
|
|
66
|
-
TLightAccountType,
|
|
67
|
-
TLightAccountVersion
|
|
68
|
-
> = GetEntryPointForLightAccountVersion<
|
|
69
|
-
TLightAccountType,
|
|
70
|
-
TLightAccountVersion
|
|
71
|
-
>
|
|
55
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
72
56
|
> = Pick<
|
|
73
|
-
ToSmartContractAccountParams<
|
|
74
|
-
TLightAccountType,
|
|
75
|
-
TTransport,
|
|
76
|
-
Chain,
|
|
77
|
-
TEntryPointVersion
|
|
78
|
-
>,
|
|
57
|
+
ToSmartContractAccountParams<TLightAccountType, TTransport, Chain>,
|
|
79
58
|
"transport" | "chain" | "getAccountInitCode"
|
|
80
59
|
> & {
|
|
81
60
|
abi: Abi;
|
|
82
61
|
signer: TSigner;
|
|
83
62
|
accountAddress: Address;
|
|
84
|
-
|
|
85
|
-
|
|
63
|
+
type: TLightAccountType;
|
|
64
|
+
version: TLightAccountVersion;
|
|
65
|
+
entryPoint: EntryPointDef<
|
|
66
|
+
LightAccountEntryPointVersion<TLightAccountType, TLightAccountVersion>,
|
|
67
|
+
Chain
|
|
68
|
+
>;
|
|
86
69
|
};
|
|
87
70
|
//#endregion CreateLightAccountBaseParams
|
|
88
71
|
|
|
89
72
|
export async function createLightAccountBase<
|
|
73
|
+
TLightAccountType extends LightAccountType,
|
|
74
|
+
TLightAccountVersion extends LightAccountVersion<TLightAccountType>,
|
|
90
75
|
TTransport extends Transport = Transport,
|
|
91
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
92
|
-
|
|
93
|
-
TLightAccountVersion extends GetLightAccountVersion<TLightAccountType> = GetLightAccountVersion<TLightAccountType>,
|
|
94
|
-
TEntryPointVersion extends GetEntryPointForLightAccountVersion<
|
|
95
|
-
TLightAccountType,
|
|
96
|
-
TLightAccountVersion
|
|
97
|
-
> = GetEntryPointForLightAccountVersion<
|
|
98
|
-
TLightAccountType,
|
|
99
|
-
TLightAccountVersion
|
|
100
|
-
>
|
|
101
|
-
>(
|
|
102
|
-
config: CreateLightAccountBaseParams<
|
|
103
|
-
TTransport,
|
|
104
|
-
TSigner,
|
|
105
|
-
TLightAccountType,
|
|
106
|
-
TLightAccountVersion,
|
|
107
|
-
TEntryPointVersion
|
|
108
|
-
>
|
|
109
|
-
): Promise<
|
|
110
|
-
LightAccountBase<
|
|
111
|
-
TSigner,
|
|
112
|
-
TLightAccountType,
|
|
113
|
-
TLightAccountVersion,
|
|
114
|
-
TEntryPointVersion
|
|
115
|
-
>
|
|
116
|
-
>;
|
|
117
|
-
|
|
118
|
-
export async function createLightAccountBase({
|
|
76
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
77
|
+
>({
|
|
119
78
|
transport,
|
|
120
79
|
chain,
|
|
121
80
|
signer,
|
|
122
81
|
abi,
|
|
123
|
-
version
|
|
82
|
+
version,
|
|
83
|
+
type,
|
|
124
84
|
entryPoint,
|
|
125
85
|
accountAddress,
|
|
126
86
|
getAccountInitCode,
|
|
127
|
-
}: CreateLightAccountBaseParams
|
|
87
|
+
}: CreateLightAccountBaseParams<
|
|
88
|
+
TLightAccountType,
|
|
89
|
+
TLightAccountVersion,
|
|
90
|
+
TTransport,
|
|
91
|
+
TSigner
|
|
92
|
+
>): Promise<
|
|
93
|
+
LightAccountBase<TSigner, TLightAccountType, TLightAccountVersion>
|
|
94
|
+
> {
|
|
128
95
|
const client = createBundlerClient({
|
|
129
96
|
transport,
|
|
130
97
|
chain,
|
|
@@ -149,7 +116,9 @@ export async function createLightAccountBase({
|
|
|
149
116
|
|
|
150
117
|
const implementationAddresses = Object.values(
|
|
151
118
|
AccountVersionRegistry[type]
|
|
152
|
-
).map(
|
|
119
|
+
).map(
|
|
120
|
+
(x) => x.addresses.overrides?.[chain.id]?.impl ?? x.addresses.default.impl
|
|
121
|
+
);
|
|
153
122
|
|
|
154
123
|
// only upgrade undeployed accounts (storage 0) or deployed light accounts, error otherwise
|
|
155
124
|
if (
|
|
@@ -157,7 +126,9 @@ export async function createLightAccountBase({
|
|
|
157
126
|
!implementationAddresses.some((x) => x === trim(storage))
|
|
158
127
|
) {
|
|
159
128
|
throw new Error(
|
|
160
|
-
`could not determine if smart account implementation is ${type} ${
|
|
129
|
+
`could not determine if smart account implementation is ${type} ${String(
|
|
130
|
+
version
|
|
131
|
+
)}`
|
|
161
132
|
);
|
|
162
133
|
}
|
|
163
134
|
|
|
@@ -234,7 +205,7 @@ export async function createLightAccountBase({
|
|
|
234
205
|
case "v1.0.1":
|
|
235
206
|
return signer.signMessage(message);
|
|
236
207
|
case "v1.0.2":
|
|
237
|
-
throw new Error(`${type} ${version} doesn't support 1271`);
|
|
208
|
+
throw new Error(`${type} ${String(version)} doesn't support 1271`);
|
|
238
209
|
case "v1.1.0":
|
|
239
210
|
return signWith1271WrapperV1(hashMessage(message));
|
|
240
211
|
case "v2.0.0":
|
|
@@ -242,7 +213,7 @@ export async function createLightAccountBase({
|
|
|
242
213
|
// TODO: handle case where signer is an SCA.
|
|
243
214
|
return concat([SignatureType.EOA, signature]);
|
|
244
215
|
default:
|
|
245
|
-
throw new Error(`Unknown version ${type} of ${version}`);
|
|
216
|
+
throw new Error(`Unknown version ${type} of ${String(version)}`);
|
|
246
217
|
}
|
|
247
218
|
},
|
|
248
219
|
async signTypedData(params) {
|
|
@@ -253,7 +224,7 @@ export async function createLightAccountBase({
|
|
|
253
224
|
);
|
|
254
225
|
case "v1.0.2":
|
|
255
226
|
throw new Error(
|
|
256
|
-
`Version ${version} of LightAccount doesn't support 1271`
|
|
227
|
+
`Version ${String(version)} of LightAccount doesn't support 1271`
|
|
257
228
|
);
|
|
258
229
|
case "v1.1.0":
|
|
259
230
|
return signWith1271WrapperV1(hashTypedData(params));
|
|
@@ -262,7 +233,7 @@ export async function createLightAccountBase({
|
|
|
262
233
|
// TODO: handle case where signer is an SCA.
|
|
263
234
|
return concat([SignatureType.EOA, signature]);
|
|
264
235
|
default:
|
|
265
|
-
throw new Error(`Unknown version ${version} of LightAccount`);
|
|
236
|
+
throw new Error(`Unknown version ${String(version)} of LightAccount`);
|
|
266
237
|
}
|
|
267
238
|
},
|
|
268
239
|
getDummySignature: (): Hex => {
|
|
@@ -276,7 +247,7 @@ export async function createLightAccountBase({
|
|
|
276
247
|
case "v2.0.0":
|
|
277
248
|
return concat([SignatureType.EOA, signature]);
|
|
278
249
|
default:
|
|
279
|
-
throw new Error(`Unknown version ${type} of ${version}`);
|
|
250
|
+
throw new Error(`Unknown version ${type} of ${String(version)}`);
|
|
280
251
|
}
|
|
281
252
|
},
|
|
282
253
|
encodeUpgradeToAndCall,
|
|
@@ -17,11 +17,10 @@ import {
|
|
|
17
17
|
import { MultiOwnerLightAccountAbi } from "../abis/MultiOwnerLightAccountAbi.js";
|
|
18
18
|
import { MultiOwnerLightAccountFactoryAbi } from "../abis/MultiOwnerLightAccountFactoryAbi.js";
|
|
19
19
|
import type {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
LightAccountEntryPointVersion,
|
|
21
|
+
LightAccountVersion,
|
|
22
22
|
} from "../types.js";
|
|
23
23
|
import {
|
|
24
|
-
AccountVersionRegistry,
|
|
25
24
|
defaultLightAccountVersion,
|
|
26
25
|
getDefaultMultiOwnerLightAccountFactoryAddress,
|
|
27
26
|
} from "../utils.js";
|
|
@@ -33,19 +32,11 @@ import {
|
|
|
33
32
|
|
|
34
33
|
export type MultiOwnerLightAccount<
|
|
35
34
|
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
36
|
-
TLightAccountVersion extends
|
|
37
|
-
TEntryPointVersion extends GetEntryPointForLightAccountVersion<
|
|
38
|
-
"MultiOwnerLightAccount",
|
|
39
|
-
TLightAccountVersion
|
|
40
|
-
> = GetEntryPointForLightAccountVersion<
|
|
41
|
-
"MultiOwnerLightAccount",
|
|
42
|
-
TLightAccountVersion
|
|
43
|
-
>
|
|
35
|
+
TLightAccountVersion extends LightAccountVersion<"MultiOwnerLightAccount"> = LightAccountVersion<"MultiOwnerLightAccount">
|
|
44
36
|
> = LightAccountBase<
|
|
45
37
|
TSigner,
|
|
46
38
|
"MultiOwnerLightAccount",
|
|
47
|
-
TLightAccountVersion
|
|
48
|
-
TEntryPointVersion
|
|
39
|
+
TLightAccountVersion
|
|
49
40
|
> & {
|
|
50
41
|
encodeUpdateOwners: (
|
|
51
42
|
ownersToAdd: Address[],
|
|
@@ -57,54 +48,47 @@ export type MultiOwnerLightAccount<
|
|
|
57
48
|
export type CreateMultiOwnerLightAccountParams<
|
|
58
49
|
TTransport extends Transport = Transport,
|
|
59
50
|
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
60
|
-
TLightAccountVersion extends
|
|
61
|
-
TEntryPointVersion extends GetEntryPointForLightAccountVersion<
|
|
62
|
-
"MultiOwnerLightAccount",
|
|
63
|
-
TLightAccountVersion
|
|
64
|
-
> = GetEntryPointForLightAccountVersion<
|
|
65
|
-
"MultiOwnerLightAccount",
|
|
66
|
-
TLightAccountVersion
|
|
67
|
-
>
|
|
51
|
+
TLightAccountVersion extends LightAccountVersion<"MultiOwnerLightAccount"> = LightAccountVersion<"MultiOwnerLightAccount">
|
|
68
52
|
> = Omit<
|
|
69
53
|
CreateLightAccountBaseParams<
|
|
70
|
-
TTransport,
|
|
71
|
-
TSigner,
|
|
72
54
|
"MultiOwnerLightAccount",
|
|
73
55
|
TLightAccountVersion,
|
|
74
|
-
|
|
56
|
+
TTransport,
|
|
57
|
+
TSigner
|
|
75
58
|
>,
|
|
76
|
-
|
|
59
|
+
| "getAccountInitCode"
|
|
60
|
+
| "entryPoint"
|
|
61
|
+
| "version"
|
|
62
|
+
| "abi"
|
|
63
|
+
| "accountAddress"
|
|
64
|
+
| "type"
|
|
77
65
|
> & {
|
|
78
66
|
salt?: bigint;
|
|
79
67
|
initCode?: Hex;
|
|
80
68
|
accountAddress?: Address;
|
|
81
69
|
factoryAddress?: Address;
|
|
82
70
|
version?: TLightAccountVersion;
|
|
83
|
-
entryPoint?: EntryPointDef<
|
|
71
|
+
entryPoint?: EntryPointDef<
|
|
72
|
+
LightAccountEntryPointVersion<
|
|
73
|
+
"MultiOwnerLightAccount",
|
|
74
|
+
TLightAccountVersion
|
|
75
|
+
>,
|
|
76
|
+
Chain
|
|
77
|
+
>;
|
|
84
78
|
owners?: Address[];
|
|
85
79
|
};
|
|
86
80
|
|
|
87
81
|
export async function createMultiOwnerLightAccount<
|
|
88
82
|
TTransport extends Transport = Transport,
|
|
89
83
|
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
90
|
-
TLightAccountVersion extends
|
|
91
|
-
TEntryPointVersion extends GetEntryPointForLightAccountVersion<
|
|
92
|
-
"MultiOwnerLightAccount",
|
|
93
|
-
TLightAccountVersion
|
|
94
|
-
> = GetEntryPointForLightAccountVersion<
|
|
95
|
-
"MultiOwnerLightAccount",
|
|
96
|
-
TLightAccountVersion
|
|
97
|
-
>
|
|
84
|
+
TLightAccountVersion extends LightAccountVersion<"MultiOwnerLightAccount"> = LightAccountVersion<"MultiOwnerLightAccount">
|
|
98
85
|
>(
|
|
99
86
|
config: CreateMultiOwnerLightAccountParams<
|
|
100
87
|
TTransport,
|
|
101
88
|
TSigner,
|
|
102
|
-
TLightAccountVersion
|
|
103
|
-
TEntryPointVersion
|
|
89
|
+
TLightAccountVersion
|
|
104
90
|
>
|
|
105
|
-
): Promise<
|
|
106
|
-
MultiOwnerLightAccount<TSigner, TLightAccountVersion, TEntryPointVersion>
|
|
107
|
-
>;
|
|
91
|
+
): Promise<MultiOwnerLightAccount<TSigner, TLightAccountVersion>>;
|
|
108
92
|
|
|
109
93
|
/**
|
|
110
94
|
* Creates a multi-owner light account using the provided parameters, including transport, chain, signer, initialization code, version, account address, factory address, salt, and owners. Ensures the owners list is deduplicated, ordered, and valid.
|
|
@@ -131,7 +115,7 @@ export async function createMultiOwnerLightAccount({
|
|
|
131
115
|
chain,
|
|
132
116
|
signer,
|
|
133
117
|
initCode,
|
|
134
|
-
version = defaultLightAccountVersion(
|
|
118
|
+
version = defaultLightAccountVersion(),
|
|
135
119
|
entryPoint = getEntryPoint(chain, {
|
|
136
120
|
version: "0.7.0",
|
|
137
121
|
}),
|
|
@@ -181,15 +165,17 @@ export async function createMultiOwnerLightAccount({
|
|
|
181
165
|
});
|
|
182
166
|
|
|
183
167
|
const account = await createLightAccountBase<
|
|
168
|
+
"MultiOwnerLightAccount",
|
|
169
|
+
LightAccountVersion<"MultiOwnerLightAccount">,
|
|
184
170
|
Transport,
|
|
185
|
-
SmartAccountSigner
|
|
186
|
-
"MultiOwnerLightAccount"
|
|
171
|
+
SmartAccountSigner
|
|
187
172
|
>({
|
|
188
173
|
transport,
|
|
189
174
|
chain,
|
|
190
175
|
signer,
|
|
191
176
|
abi: MultiOwnerLightAccountAbi,
|
|
192
|
-
version
|
|
177
|
+
version,
|
|
178
|
+
type: "MultiOwnerLightAccount",
|
|
193
179
|
entryPoint,
|
|
194
180
|
accountAddress: address,
|
|
195
181
|
getAccountInitCode,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
1
2
|
import {
|
|
2
3
|
AlchemyProviderConfigSchema,
|
|
3
4
|
createAlchemyPublicRpcClient,
|
|
@@ -12,7 +13,6 @@ import {
|
|
|
12
13
|
type LightAccount,
|
|
13
14
|
type LightAccountClientActions,
|
|
14
15
|
} from "@account-kit/smart-contracts";
|
|
15
|
-
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
16
16
|
import { custom, type Chain, type CustomTransport, type Transport } from "viem";
|
|
17
17
|
|
|
18
18
|
export type AlchemyLightAccountClientConfig<
|
|
@@ -45,7 +45,7 @@ export async function createLightAccountAlchemyClient<
|
|
|
45
45
|
* @example
|
|
46
46
|
* ```ts
|
|
47
47
|
* import { createLightAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
48
|
-
* import { sepolia } from "@account-kit/infra
|
|
48
|
+
* import { sepolia } from "@account-kit/infra";
|
|
49
49
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
50
50
|
* import { generatePrivateKey } from "viem"
|
|
51
51
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
1
2
|
import {
|
|
2
3
|
AlchemyProviderConfigSchema,
|
|
3
4
|
createAlchemyPublicRpcClient,
|
|
@@ -12,14 +13,13 @@ import {
|
|
|
12
13
|
type MultiOwnerLightAccount,
|
|
13
14
|
type MultiOwnerLightAccountClientActions,
|
|
14
15
|
} from "@account-kit/smart-contracts";
|
|
15
|
-
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
16
16
|
import { custom, type Chain, type CustomTransport, type Transport } from "viem";
|
|
17
17
|
|
|
18
18
|
export type AlchemyMultiOwnerLightAccountClientConfig<
|
|
19
19
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
20
20
|
> = Omit<
|
|
21
21
|
CreateMultiOwnerLightAccountParams<HttpTransport, TSigner>,
|
|
22
|
-
"transport" | "chain"
|
|
22
|
+
"transport" | "chain" | "type"
|
|
23
23
|
> &
|
|
24
24
|
Omit<
|
|
25
25
|
AlchemySmartAccountClientConfig<
|
|
@@ -49,7 +49,7 @@ export async function createMultiOwnerLightAccountAlchemyClient<
|
|
|
49
49
|
* @example
|
|
50
50
|
* ```ts
|
|
51
51
|
* import { createMultiOwnerLightAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
52
|
-
* import { sepolia } from "@account-kit/infra
|
|
52
|
+
* import { sepolia } from "@account-kit/infra";
|
|
53
53
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
54
54
|
* import { generatePrivateKey } from "viem"
|
|
55
55
|
*
|
|
@@ -24,7 +24,7 @@ export type LightAccountClientActions<
|
|
|
24
24
|
* ```ts
|
|
25
25
|
* import { lightAccountClientActions, createLightAccount } from "@account-kit/smart-contracts";
|
|
26
26
|
* import { createAlchemySmartAccountClient } from "@account-kit/infra";
|
|
27
|
-
* import { sepolia } from "@account-kit/infra
|
|
27
|
+
* import { sepolia } from "@account-kit/infra";
|
|
28
28
|
*
|
|
29
29
|
* const smartAccountClient = createAlchemySmartAccountClient({
|
|
30
30
|
* account: await createLightAccount(...),
|
|
@@ -24,7 +24,7 @@ export type MultiOwnerLightAccountClientActions<
|
|
|
24
24
|
* ```ts
|
|
25
25
|
* import { multiOwnerLightAccountClientActions, createMultiOwnerLightAccount } from "@account-kit/smart-contracts";
|
|
26
26
|
* import { createAlchemySmartAccountClient } from "@account-kit/infra";
|
|
27
|
-
* import { sepolia } from "@account-kit/infra
|
|
27
|
+
* import { sepolia } from "@account-kit/infra";
|
|
28
28
|
*
|
|
29
29
|
* const smartAccountClient = createAlchemySmartAccountClient({
|
|
30
30
|
* account: await createMultiOwnerLightAccount(...),
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type EntryPointVersion,
|
|
3
|
-
type GetAccountParameter,
|
|
4
|
-
type OneOf,
|
|
5
|
-
type SmartAccountSigner,
|
|
6
|
-
type SmartContractAccount,
|
|
7
|
-
} from "@aa-sdk/core";
|
|
1
|
+
import { type EntryPointVersion } from "@aa-sdk/core";
|
|
8
2
|
import { type Address, type Chain } from "viem";
|
|
9
3
|
import type { LightAccountBase } from "./accounts/base";
|
|
10
4
|
|
|
@@ -12,199 +6,48 @@ import type { LightAccountBase } from "./accounts/base";
|
|
|
12
6
|
* Light account types supported: LightAccount, MultiOwnerLightAccount
|
|
13
7
|
*
|
|
14
8
|
*/
|
|
15
|
-
export type LightAccountType =
|
|
9
|
+
export type LightAccountType = "LightAccount" | "MultiOwnerLightAccount";
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
* Account version definition, which is the base type defining the LightAccountVersionDef interface
|
|
19
|
-
*
|
|
20
|
-
* @template {LightAccountType} TLightAccountType type
|
|
21
|
-
* @template {GetLightAccountVersion<TLightAccountType>} TLightAccountVersion version
|
|
22
|
-
* @template {EntryPointVersion} TEntryPointVersion entryPointVersion
|
|
23
|
-
*/
|
|
24
|
-
export type AccountVersionDef<
|
|
25
|
-
TLightAccountType extends LightAccountType = LightAccountType,
|
|
26
|
-
TLightAccountVersion extends GetLightAccountVersion<TLightAccountType> = GetLightAccountVersion<TLightAccountType>,
|
|
11
|
+
export type LightAccountVersionConfig<
|
|
27
12
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
28
13
|
> = {
|
|
29
|
-
type: TLightAccountType;
|
|
30
|
-
version: TLightAccountVersion;
|
|
31
14
|
entryPointVersion: TEntryPointVersion;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{
|
|
15
|
+
addresses: {
|
|
16
|
+
default: {
|
|
35
17
|
factory: Address;
|
|
36
18
|
impl: Address;
|
|
37
|
-
}
|
|
38
|
-
|
|
19
|
+
};
|
|
20
|
+
overrides?: Record<
|
|
21
|
+
Chain["id"],
|
|
22
|
+
{
|
|
23
|
+
factory: Address;
|
|
24
|
+
impl: Address;
|
|
25
|
+
}
|
|
26
|
+
>;
|
|
27
|
+
};
|
|
39
28
|
};
|
|
40
29
|
|
|
41
|
-
|
|
42
|
-
* Light account version type defs for tightly coupled types for smart accounts
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
export type LightAccountVersion =
|
|
46
|
-
| keyof IAccountVersionRegistry["LightAccount"]
|
|
47
|
-
| keyof IAccountVersionRegistry["MultiOwnerLightAccount"];
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Get the light account versions available for the given light account type
|
|
51
|
-
*
|
|
52
|
-
* @template {LightAccountType} TLightAccountType
|
|
53
|
-
*/
|
|
54
|
-
export type GetLightAccountVersion<
|
|
55
|
-
TLightAccountType extends LightAccountType = LightAccountType
|
|
56
|
-
> = keyof IAccountVersionRegistry[TLightAccountType];
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Light account version definition type based on the light account type and version
|
|
60
|
-
*
|
|
61
|
-
* @template {LightAccountType} TLightAccountType
|
|
62
|
-
* @template {GetLightAccountVersion<TLightAccountType>} TLightAccountVersion
|
|
63
|
-
*/
|
|
64
|
-
export type LightAccountVersionDef<
|
|
65
|
-
TLightAccountType extends LightAccountType = LightAccountType,
|
|
66
|
-
TLightAccountVersion extends GetLightAccountVersion<TLightAccountType> = GetLightAccountVersion<TLightAccountType>
|
|
67
|
-
> = IAccountVersionRegistry[TLightAccountType][TLightAccountVersion];
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Light account version registry interface defining the supported light account versions
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
73
|
-
export interface IAccountVersionRegistry {
|
|
30
|
+
export type LightAccountVersionConfigs = {
|
|
74
31
|
LightAccount: {
|
|
75
|
-
|
|
76
|
-
"v1.0.
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
"v1.1.0": AccountVersionDef<"LightAccount", "v1.1.0", "0.6.0">;
|
|
80
|
-
/**
|
|
81
|
-
* LightAccount v2 Changelog.
|
|
82
|
-
* It is recommended to use v2.0.0
|
|
83
|
-
* https://alchemotion.notion.site/External-Light-Account-v2-Changelog-725b306ab1e04eb0a3e596521dd8f0bd
|
|
84
|
-
*/
|
|
85
|
-
"v2.0.0": AccountVersionDef<"LightAccount", "v2.0.0", "0.7.0">;
|
|
32
|
+
"v1.0.1": LightAccountVersionConfig<"0.6.0">;
|
|
33
|
+
"v1.0.2": LightAccountVersionConfig<"0.6.0">;
|
|
34
|
+
"v1.1.0": LightAccountVersionConfig<"0.6.0">;
|
|
35
|
+
"v2.0.0": LightAccountVersionConfig<"0.7.0">;
|
|
86
36
|
};
|
|
87
37
|
MultiOwnerLightAccount: {
|
|
88
|
-
|
|
89
|
-
* MultiOwnerLightAccount v2 Changelog
|
|
90
|
-
* It is recommended to use v2.0.0
|
|
91
|
-
* https://alchemotion.notion.site/External-Light-Account-v2-Changelog-725b306ab1e04eb0a3e596521dd8f0bd
|
|
92
|
-
*/
|
|
93
|
-
"v2.0.0": AccountVersionDef<"MultiOwnerLightAccount", "v2.0.0", "0.7.0">;
|
|
38
|
+
"v2.0.0": LightAccountVersionConfig<"0.7.0">;
|
|
94
39
|
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get the light account version definitions available for the given light account type
|
|
99
|
-
*
|
|
100
|
-
* @template {LightAccountType} TLightAccountType
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* type T1 = GetLightAccountVersionsForType<"LightAccount">;
|
|
104
|
-
* const t1: T1 = AccountVersionRegistry.LightAccount["v1.0.2"];
|
|
105
|
-
*/
|
|
106
|
-
export type GetLightAccountVersionDefsForType<TType extends LightAccountType> =
|
|
107
|
-
Extract<
|
|
108
|
-
IAccountVersionRegistry[TType][keyof IAccountVersionRegistry[TType]],
|
|
109
|
-
{ type: TType }
|
|
110
|
-
>;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Get the light account version definition for the given light account type and version
|
|
114
|
-
*
|
|
115
|
-
* @template {LightAccountType} TType
|
|
116
|
-
* @template {GetLightAccountVersion<TType>} TLightAccountVersion
|
|
117
|
-
*/
|
|
118
|
-
export type GetLightAccountVersionDef<
|
|
119
|
-
TType extends LightAccountType,
|
|
120
|
-
TLightAccountVersion extends GetLightAccountVersion<TType>
|
|
121
|
-
> = IAccountVersionRegistry[TType][TLightAccountVersion];
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @example
|
|
125
|
-
* type T = GetLightAccountVersionDefsForEntryPoint<"LightAccount", "0.6.0">;
|
|
126
|
-
* const t_1: T = AccountVersionRegistry.LightAccount["v1.0.2"]; // compiles
|
|
127
|
-
* const t_2: T = AccountVersionRegistry.LightAccount["v2.0.0"]; // errors
|
|
128
|
-
*/
|
|
129
|
-
export type GetLightAccountVersionDefsForEntryPoint<
|
|
130
|
-
TType extends LightAccountType,
|
|
131
|
-
TEntryPointVersion extends EntryPointVersion
|
|
132
|
-
> = Extract<
|
|
133
|
-
GetLightAccountVersionDefsForType<TType>,
|
|
134
|
-
{ entryPointVersion: TEntryPointVersion }
|
|
135
|
-
>;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Get the light account type for the given light account by inferring from its type definition
|
|
139
|
-
*
|
|
140
|
-
* @template {SmartContractAccount | undefined} TAccount
|
|
141
|
-
* @template {SmartContractAccount} TAccountOverride
|
|
142
|
-
*/
|
|
143
|
-
export type GetLightAccountType<
|
|
144
|
-
TAccount extends SmartContractAccount | undefined,
|
|
145
|
-
TAccountOverride extends SmartContractAccount = SmartContractAccount
|
|
146
|
-
> = GetAccountParameter<TAccount, TAccountOverride> extends LightAccountBase<
|
|
147
|
-
SmartAccountSigner,
|
|
148
|
-
infer TLightAccountType
|
|
149
|
-
>
|
|
150
|
-
? OneOf<TLightAccountType, LightAccountType>
|
|
151
|
-
: LightAccountType;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Get the light account version for the given light account by inferring from its type definition
|
|
155
|
-
*
|
|
156
|
-
* @template {LightAccountBase | undefined} TAccount
|
|
157
|
-
* @template {LightAccountBase} TAccountOverride
|
|
158
|
-
*/
|
|
159
|
-
export type GetLightAccountVersionFromAccount<
|
|
160
|
-
TAccount extends LightAccountBase | undefined,
|
|
161
|
-
TAccountOverride extends LightAccountBase = LightAccountBase
|
|
162
|
-
> = GetAccountParameter<TAccount, TAccountOverride> extends LightAccountBase<
|
|
163
|
-
SmartAccountSigner,
|
|
164
|
-
LightAccountType,
|
|
165
|
-
infer TLightAccountVersion
|
|
166
|
-
>
|
|
167
|
-
? OneOf<TLightAccountVersion, LightAccountVersion>
|
|
168
|
-
: LightAccountVersion;
|
|
40
|
+
};
|
|
169
41
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
*
|
|
173
|
-
* @template {LightAccountType} TLightAccountType
|
|
174
|
-
* @template {GetLightAccountVersion<TLightAccountType>} TLightAccountVersion
|
|
175
|
-
*/
|
|
176
|
-
export type GetEntryPointForLightAccountVersion<
|
|
177
|
-
TLightAccountType extends LightAccountType = LightAccountType,
|
|
178
|
-
TLightAccountVersion extends GetLightAccountVersion<TLightAccountType> = GetLightAccountVersion<TLightAccountType>
|
|
179
|
-
> = GetLightAccountVersionDef<
|
|
180
|
-
TLightAccountType,
|
|
181
|
-
TLightAccountVersion
|
|
182
|
-
> extends AccountVersionDef<
|
|
183
|
-
TLightAccountType,
|
|
184
|
-
TLightAccountVersion,
|
|
185
|
-
infer TEntryPointVersion
|
|
186
|
-
>
|
|
187
|
-
? TEntryPointVersion
|
|
188
|
-
: EntryPointVersion;
|
|
42
|
+
export type LightAccountVersion<TAccountType extends LightAccountType> =
|
|
43
|
+
keyof LightAccountVersionConfigs[TAccountType];
|
|
189
44
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
*
|
|
193
|
-
* @template {LightAccountVersion} TLightAccountVersion
|
|
194
|
-
*/
|
|
195
|
-
export type GetLightAccountTypesForVersion<
|
|
196
|
-
TLightAccountVersion extends LightAccountVersion = LightAccountVersion
|
|
197
|
-
> = TLightAccountVersion extends GetLightAccountVersion<infer TLightAccountType>
|
|
198
|
-
? TLightAccountType
|
|
199
|
-
: LightAccountType;
|
|
45
|
+
export type GetLightAccountType<TAccount extends LightAccountBase> =
|
|
46
|
+
TAccount["source"] extends LightAccountType ? TAccount["source"] : never;
|
|
200
47
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
TLightAccountType extends LightAccountType = LightAccountType
|
|
208
|
-
> = TLightAccountType extends "MultiOwnerLightAccount"
|
|
209
|
-
? "v2.0.0" & LightAccountVersion
|
|
210
|
-
: "v1.1.0" & LightAccountVersion;
|
|
48
|
+
export type LightAccountEntryPointVersion<
|
|
49
|
+
TLightAccountType extends LightAccountType,
|
|
50
|
+
TLightAccountVersion extends LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>
|
|
51
|
+
> = LightAccountVersionConfigs[TLightAccountType][TLightAccountVersion] extends LightAccountVersionConfig
|
|
52
|
+
? LightAccountVersionConfigs[TLightAccountType][TLightAccountVersion]["entryPointVersion"]
|
|
53
|
+
: never;
|