@latticexyz/common 2.2.15-entrykit-07c5b562497802c5296541b07435eaa39fc3e483 → 2.2.15-entrykit-d77b89f552d347913d6c4d75ad2a3e5e0b90379c
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/accounts.d.ts +654 -0
- package/dist/accounts.js +2 -0
- package/dist/accounts.js.map +1 -0
- package/dist/actions.d.ts +2 -2
- package/dist/actions.js +1 -1
- package/dist/actions.js.map +1 -1
- package/dist/kms.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
import { Address, Client, OneOf, LocalAccount, Prettify, Assign, Hash, Account } from 'viem';
|
|
2
|
+
import { WebAuthnAccount, SmartAccount, SmartAccountImplementation, entryPoint07Abi } from 'viem/account-abstraction';
|
|
3
|
+
import { Hex, WebAuthnData } from 'webauthn-p256';
|
|
4
|
+
|
|
5
|
+
declare const abi: readonly [{
|
|
6
|
+
readonly inputs: readonly [];
|
|
7
|
+
readonly stateMutability: "nonpayable";
|
|
8
|
+
readonly type: "constructor";
|
|
9
|
+
}, {
|
|
10
|
+
readonly inputs: readonly [{
|
|
11
|
+
readonly name: "owner";
|
|
12
|
+
readonly type: "bytes";
|
|
13
|
+
}];
|
|
14
|
+
readonly name: "AlreadyOwner";
|
|
15
|
+
readonly type: "error";
|
|
16
|
+
}, {
|
|
17
|
+
readonly inputs: readonly [];
|
|
18
|
+
readonly name: "Initialized";
|
|
19
|
+
readonly type: "error";
|
|
20
|
+
}, {
|
|
21
|
+
readonly inputs: readonly [{
|
|
22
|
+
readonly name: "owner";
|
|
23
|
+
readonly type: "bytes";
|
|
24
|
+
}];
|
|
25
|
+
readonly name: "InvalidEthereumAddressOwner";
|
|
26
|
+
readonly type: "error";
|
|
27
|
+
}, {
|
|
28
|
+
readonly inputs: readonly [{
|
|
29
|
+
readonly name: "key";
|
|
30
|
+
readonly type: "uint256";
|
|
31
|
+
}];
|
|
32
|
+
readonly name: "InvalidNonceKey";
|
|
33
|
+
readonly type: "error";
|
|
34
|
+
}, {
|
|
35
|
+
readonly inputs: readonly [{
|
|
36
|
+
readonly name: "owner";
|
|
37
|
+
readonly type: "bytes";
|
|
38
|
+
}];
|
|
39
|
+
readonly name: "InvalidOwnerBytesLength";
|
|
40
|
+
readonly type: "error";
|
|
41
|
+
}, {
|
|
42
|
+
readonly inputs: readonly [];
|
|
43
|
+
readonly name: "LastOwner";
|
|
44
|
+
readonly type: "error";
|
|
45
|
+
}, {
|
|
46
|
+
readonly inputs: readonly [{
|
|
47
|
+
readonly name: "index";
|
|
48
|
+
readonly type: "uint256";
|
|
49
|
+
}];
|
|
50
|
+
readonly name: "NoOwnerAtIndex";
|
|
51
|
+
readonly type: "error";
|
|
52
|
+
}, {
|
|
53
|
+
readonly inputs: readonly [{
|
|
54
|
+
readonly name: "ownersRemaining";
|
|
55
|
+
readonly type: "uint256";
|
|
56
|
+
}];
|
|
57
|
+
readonly name: "NotLastOwner";
|
|
58
|
+
readonly type: "error";
|
|
59
|
+
}, {
|
|
60
|
+
readonly inputs: readonly [{
|
|
61
|
+
readonly name: "selector";
|
|
62
|
+
readonly type: "bytes4";
|
|
63
|
+
}];
|
|
64
|
+
readonly name: "SelectorNotAllowed";
|
|
65
|
+
readonly type: "error";
|
|
66
|
+
}, {
|
|
67
|
+
readonly inputs: readonly [];
|
|
68
|
+
readonly name: "Unauthorized";
|
|
69
|
+
readonly type: "error";
|
|
70
|
+
}, {
|
|
71
|
+
readonly inputs: readonly [];
|
|
72
|
+
readonly name: "UnauthorizedCallContext";
|
|
73
|
+
readonly type: "error";
|
|
74
|
+
}, {
|
|
75
|
+
readonly inputs: readonly [];
|
|
76
|
+
readonly name: "UpgradeFailed";
|
|
77
|
+
readonly type: "error";
|
|
78
|
+
}, {
|
|
79
|
+
readonly inputs: readonly [{
|
|
80
|
+
readonly name: "index";
|
|
81
|
+
readonly type: "uint256";
|
|
82
|
+
}, {
|
|
83
|
+
readonly name: "expectedOwner";
|
|
84
|
+
readonly type: "bytes";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "actualOwner";
|
|
87
|
+
readonly type: "bytes";
|
|
88
|
+
}];
|
|
89
|
+
readonly name: "WrongOwnerAtIndex";
|
|
90
|
+
readonly type: "error";
|
|
91
|
+
}, {
|
|
92
|
+
readonly anonymous: false;
|
|
93
|
+
readonly inputs: readonly [{
|
|
94
|
+
readonly indexed: true;
|
|
95
|
+
readonly name: "index";
|
|
96
|
+
readonly type: "uint256";
|
|
97
|
+
}, {
|
|
98
|
+
readonly indexed: false;
|
|
99
|
+
readonly name: "owner";
|
|
100
|
+
readonly type: "bytes";
|
|
101
|
+
}];
|
|
102
|
+
readonly name: "AddOwner";
|
|
103
|
+
readonly type: "event";
|
|
104
|
+
}, {
|
|
105
|
+
readonly anonymous: false;
|
|
106
|
+
readonly inputs: readonly [{
|
|
107
|
+
readonly indexed: true;
|
|
108
|
+
readonly name: "index";
|
|
109
|
+
readonly type: "uint256";
|
|
110
|
+
}, {
|
|
111
|
+
readonly indexed: false;
|
|
112
|
+
readonly name: "owner";
|
|
113
|
+
readonly type: "bytes";
|
|
114
|
+
}];
|
|
115
|
+
readonly name: "RemoveOwner";
|
|
116
|
+
readonly type: "event";
|
|
117
|
+
}, {
|
|
118
|
+
readonly anonymous: false;
|
|
119
|
+
readonly inputs: readonly [{
|
|
120
|
+
readonly indexed: true;
|
|
121
|
+
readonly name: "implementation";
|
|
122
|
+
readonly type: "address";
|
|
123
|
+
}];
|
|
124
|
+
readonly name: "Upgraded";
|
|
125
|
+
readonly type: "event";
|
|
126
|
+
}, {
|
|
127
|
+
readonly stateMutability: "payable";
|
|
128
|
+
readonly type: "fallback";
|
|
129
|
+
}, {
|
|
130
|
+
readonly inputs: readonly [];
|
|
131
|
+
readonly name: "REPLAYABLE_NONCE_KEY";
|
|
132
|
+
readonly outputs: readonly [{
|
|
133
|
+
readonly name: "";
|
|
134
|
+
readonly type: "uint256";
|
|
135
|
+
}];
|
|
136
|
+
readonly stateMutability: "view";
|
|
137
|
+
readonly type: "function";
|
|
138
|
+
}, {
|
|
139
|
+
readonly inputs: readonly [{
|
|
140
|
+
readonly name: "owner";
|
|
141
|
+
readonly type: "address";
|
|
142
|
+
}];
|
|
143
|
+
readonly name: "addOwnerAddress";
|
|
144
|
+
readonly outputs: readonly [];
|
|
145
|
+
readonly stateMutability: "nonpayable";
|
|
146
|
+
readonly type: "function";
|
|
147
|
+
}, {
|
|
148
|
+
readonly inputs: readonly [{
|
|
149
|
+
readonly name: "x";
|
|
150
|
+
readonly type: "bytes32";
|
|
151
|
+
}, {
|
|
152
|
+
readonly name: "y";
|
|
153
|
+
readonly type: "bytes32";
|
|
154
|
+
}];
|
|
155
|
+
readonly name: "addOwnerPublicKey";
|
|
156
|
+
readonly outputs: readonly [];
|
|
157
|
+
readonly stateMutability: "nonpayable";
|
|
158
|
+
readonly type: "function";
|
|
159
|
+
}, {
|
|
160
|
+
readonly inputs: readonly [{
|
|
161
|
+
readonly name: "functionSelector";
|
|
162
|
+
readonly type: "bytes4";
|
|
163
|
+
}];
|
|
164
|
+
readonly name: "canSkipChainIdValidation";
|
|
165
|
+
readonly outputs: readonly [{
|
|
166
|
+
readonly name: "";
|
|
167
|
+
readonly type: "bool";
|
|
168
|
+
}];
|
|
169
|
+
readonly stateMutability: "pure";
|
|
170
|
+
readonly type: "function";
|
|
171
|
+
}, {
|
|
172
|
+
readonly inputs: readonly [];
|
|
173
|
+
readonly name: "domainSeparator";
|
|
174
|
+
readonly outputs: readonly [{
|
|
175
|
+
readonly name: "";
|
|
176
|
+
readonly type: "bytes32";
|
|
177
|
+
}];
|
|
178
|
+
readonly stateMutability: "view";
|
|
179
|
+
readonly type: "function";
|
|
180
|
+
}, {
|
|
181
|
+
readonly inputs: readonly [];
|
|
182
|
+
readonly name: "eip712Domain";
|
|
183
|
+
readonly outputs: readonly [{
|
|
184
|
+
readonly name: "fields";
|
|
185
|
+
readonly type: "bytes1";
|
|
186
|
+
}, {
|
|
187
|
+
readonly name: "name";
|
|
188
|
+
readonly type: "string";
|
|
189
|
+
}, {
|
|
190
|
+
readonly name: "version";
|
|
191
|
+
readonly type: "string";
|
|
192
|
+
}, {
|
|
193
|
+
readonly name: "chainId";
|
|
194
|
+
readonly type: "uint256";
|
|
195
|
+
}, {
|
|
196
|
+
readonly name: "verifyingContract";
|
|
197
|
+
readonly type: "address";
|
|
198
|
+
}, {
|
|
199
|
+
readonly name: "salt";
|
|
200
|
+
readonly type: "bytes32";
|
|
201
|
+
}, {
|
|
202
|
+
readonly name: "extensions";
|
|
203
|
+
readonly type: "uint256[]";
|
|
204
|
+
}];
|
|
205
|
+
readonly stateMutability: "view";
|
|
206
|
+
readonly type: "function";
|
|
207
|
+
}, {
|
|
208
|
+
readonly inputs: readonly [];
|
|
209
|
+
readonly name: "entryPoint";
|
|
210
|
+
readonly outputs: readonly [{
|
|
211
|
+
readonly name: "";
|
|
212
|
+
readonly type: "address";
|
|
213
|
+
}];
|
|
214
|
+
readonly stateMutability: "view";
|
|
215
|
+
readonly type: "function";
|
|
216
|
+
}, {
|
|
217
|
+
readonly inputs: readonly [{
|
|
218
|
+
readonly name: "target";
|
|
219
|
+
readonly type: "address";
|
|
220
|
+
}, {
|
|
221
|
+
readonly name: "value";
|
|
222
|
+
readonly type: "uint256";
|
|
223
|
+
}, {
|
|
224
|
+
readonly name: "data";
|
|
225
|
+
readonly type: "bytes";
|
|
226
|
+
}];
|
|
227
|
+
readonly name: "execute";
|
|
228
|
+
readonly outputs: readonly [];
|
|
229
|
+
readonly stateMutability: "payable";
|
|
230
|
+
readonly type: "function";
|
|
231
|
+
}, {
|
|
232
|
+
readonly inputs: readonly [{
|
|
233
|
+
readonly components: readonly [{
|
|
234
|
+
readonly name: "target";
|
|
235
|
+
readonly type: "address";
|
|
236
|
+
}, {
|
|
237
|
+
readonly name: "value";
|
|
238
|
+
readonly type: "uint256";
|
|
239
|
+
}, {
|
|
240
|
+
readonly name: "data";
|
|
241
|
+
readonly type: "bytes";
|
|
242
|
+
}];
|
|
243
|
+
readonly name: "calls";
|
|
244
|
+
readonly type: "tuple[]";
|
|
245
|
+
}];
|
|
246
|
+
readonly name: "executeBatch";
|
|
247
|
+
readonly outputs: readonly [];
|
|
248
|
+
readonly stateMutability: "payable";
|
|
249
|
+
readonly type: "function";
|
|
250
|
+
}, {
|
|
251
|
+
readonly inputs: readonly [{
|
|
252
|
+
readonly name: "calls";
|
|
253
|
+
readonly type: "bytes[]";
|
|
254
|
+
}];
|
|
255
|
+
readonly name: "executeWithoutChainIdValidation";
|
|
256
|
+
readonly outputs: readonly [];
|
|
257
|
+
readonly stateMutability: "payable";
|
|
258
|
+
readonly type: "function";
|
|
259
|
+
}, {
|
|
260
|
+
readonly inputs: readonly [{
|
|
261
|
+
readonly components: readonly [{
|
|
262
|
+
readonly name: "sender";
|
|
263
|
+
readonly type: "address";
|
|
264
|
+
}, {
|
|
265
|
+
readonly name: "nonce";
|
|
266
|
+
readonly type: "uint256";
|
|
267
|
+
}, {
|
|
268
|
+
readonly name: "initCode";
|
|
269
|
+
readonly type: "bytes";
|
|
270
|
+
}, {
|
|
271
|
+
readonly name: "callData";
|
|
272
|
+
readonly type: "bytes";
|
|
273
|
+
}, {
|
|
274
|
+
readonly name: "callGasLimit";
|
|
275
|
+
readonly type: "uint256";
|
|
276
|
+
}, {
|
|
277
|
+
readonly name: "verificationGasLimit";
|
|
278
|
+
readonly type: "uint256";
|
|
279
|
+
}, {
|
|
280
|
+
readonly name: "preVerificationGas";
|
|
281
|
+
readonly type: "uint256";
|
|
282
|
+
}, {
|
|
283
|
+
readonly name: "maxFeePerGas";
|
|
284
|
+
readonly type: "uint256";
|
|
285
|
+
}, {
|
|
286
|
+
readonly name: "maxPriorityFeePerGas";
|
|
287
|
+
readonly type: "uint256";
|
|
288
|
+
}, {
|
|
289
|
+
readonly name: "paymasterAndData";
|
|
290
|
+
readonly type: "bytes";
|
|
291
|
+
}, {
|
|
292
|
+
readonly name: "signature";
|
|
293
|
+
readonly type: "bytes";
|
|
294
|
+
}];
|
|
295
|
+
readonly name: "userOp";
|
|
296
|
+
readonly type: "tuple";
|
|
297
|
+
}];
|
|
298
|
+
readonly name: "getUserOpHashWithoutChainId";
|
|
299
|
+
readonly outputs: readonly [{
|
|
300
|
+
readonly name: "";
|
|
301
|
+
readonly type: "bytes32";
|
|
302
|
+
}];
|
|
303
|
+
readonly stateMutability: "view";
|
|
304
|
+
readonly type: "function";
|
|
305
|
+
}, {
|
|
306
|
+
readonly inputs: readonly [];
|
|
307
|
+
readonly name: "implementation";
|
|
308
|
+
readonly outputs: readonly [{
|
|
309
|
+
readonly name: "$";
|
|
310
|
+
readonly type: "address";
|
|
311
|
+
}];
|
|
312
|
+
readonly stateMutability: "view";
|
|
313
|
+
readonly type: "function";
|
|
314
|
+
}, {
|
|
315
|
+
readonly inputs: readonly [{
|
|
316
|
+
readonly name: "owners";
|
|
317
|
+
readonly type: "bytes[]";
|
|
318
|
+
}];
|
|
319
|
+
readonly name: "initialize";
|
|
320
|
+
readonly outputs: readonly [];
|
|
321
|
+
readonly stateMutability: "payable";
|
|
322
|
+
readonly type: "function";
|
|
323
|
+
}, {
|
|
324
|
+
readonly inputs: readonly [{
|
|
325
|
+
readonly name: "account";
|
|
326
|
+
readonly type: "address";
|
|
327
|
+
}];
|
|
328
|
+
readonly name: "isOwnerAddress";
|
|
329
|
+
readonly outputs: readonly [{
|
|
330
|
+
readonly name: "";
|
|
331
|
+
readonly type: "bool";
|
|
332
|
+
}];
|
|
333
|
+
readonly stateMutability: "view";
|
|
334
|
+
readonly type: "function";
|
|
335
|
+
}, {
|
|
336
|
+
readonly inputs: readonly [{
|
|
337
|
+
readonly name: "account";
|
|
338
|
+
readonly type: "bytes";
|
|
339
|
+
}];
|
|
340
|
+
readonly name: "isOwnerBytes";
|
|
341
|
+
readonly outputs: readonly [{
|
|
342
|
+
readonly name: "";
|
|
343
|
+
readonly type: "bool";
|
|
344
|
+
}];
|
|
345
|
+
readonly stateMutability: "view";
|
|
346
|
+
readonly type: "function";
|
|
347
|
+
}, {
|
|
348
|
+
readonly inputs: readonly [{
|
|
349
|
+
readonly name: "x";
|
|
350
|
+
readonly type: "bytes32";
|
|
351
|
+
}, {
|
|
352
|
+
readonly name: "y";
|
|
353
|
+
readonly type: "bytes32";
|
|
354
|
+
}];
|
|
355
|
+
readonly name: "isOwnerPublicKey";
|
|
356
|
+
readonly outputs: readonly [{
|
|
357
|
+
readonly name: "";
|
|
358
|
+
readonly type: "bool";
|
|
359
|
+
}];
|
|
360
|
+
readonly stateMutability: "view";
|
|
361
|
+
readonly type: "function";
|
|
362
|
+
}, {
|
|
363
|
+
readonly inputs: readonly [{
|
|
364
|
+
readonly name: "hash";
|
|
365
|
+
readonly type: "bytes32";
|
|
366
|
+
}, {
|
|
367
|
+
readonly name: "signature";
|
|
368
|
+
readonly type: "bytes";
|
|
369
|
+
}];
|
|
370
|
+
readonly name: "isValidSignature";
|
|
371
|
+
readonly outputs: readonly [{
|
|
372
|
+
readonly name: "result";
|
|
373
|
+
readonly type: "bytes4";
|
|
374
|
+
}];
|
|
375
|
+
readonly stateMutability: "view";
|
|
376
|
+
readonly type: "function";
|
|
377
|
+
}, {
|
|
378
|
+
readonly inputs: readonly [];
|
|
379
|
+
readonly name: "nextOwnerIndex";
|
|
380
|
+
readonly outputs: readonly [{
|
|
381
|
+
readonly name: "";
|
|
382
|
+
readonly type: "uint256";
|
|
383
|
+
}];
|
|
384
|
+
readonly stateMutability: "view";
|
|
385
|
+
readonly type: "function";
|
|
386
|
+
}, {
|
|
387
|
+
readonly inputs: readonly [{
|
|
388
|
+
readonly name: "index";
|
|
389
|
+
readonly type: "uint256";
|
|
390
|
+
}];
|
|
391
|
+
readonly name: "ownerAtIndex";
|
|
392
|
+
readonly outputs: readonly [{
|
|
393
|
+
readonly name: "";
|
|
394
|
+
readonly type: "bytes";
|
|
395
|
+
}];
|
|
396
|
+
readonly stateMutability: "view";
|
|
397
|
+
readonly type: "function";
|
|
398
|
+
}, {
|
|
399
|
+
readonly inputs: readonly [];
|
|
400
|
+
readonly name: "ownerCount";
|
|
401
|
+
readonly outputs: readonly [{
|
|
402
|
+
readonly name: "";
|
|
403
|
+
readonly type: "uint256";
|
|
404
|
+
}];
|
|
405
|
+
readonly stateMutability: "view";
|
|
406
|
+
readonly type: "function";
|
|
407
|
+
}, {
|
|
408
|
+
readonly inputs: readonly [];
|
|
409
|
+
readonly name: "proxiableUUID";
|
|
410
|
+
readonly outputs: readonly [{
|
|
411
|
+
readonly name: "";
|
|
412
|
+
readonly type: "bytes32";
|
|
413
|
+
}];
|
|
414
|
+
readonly stateMutability: "view";
|
|
415
|
+
readonly type: "function";
|
|
416
|
+
}, {
|
|
417
|
+
readonly inputs: readonly [{
|
|
418
|
+
readonly name: "index";
|
|
419
|
+
readonly type: "uint256";
|
|
420
|
+
}, {
|
|
421
|
+
readonly name: "owner";
|
|
422
|
+
readonly type: "bytes";
|
|
423
|
+
}];
|
|
424
|
+
readonly name: "removeLastOwner";
|
|
425
|
+
readonly outputs: readonly [];
|
|
426
|
+
readonly stateMutability: "nonpayable";
|
|
427
|
+
readonly type: "function";
|
|
428
|
+
}, {
|
|
429
|
+
readonly inputs: readonly [{
|
|
430
|
+
readonly name: "index";
|
|
431
|
+
readonly type: "uint256";
|
|
432
|
+
}, {
|
|
433
|
+
readonly name: "owner";
|
|
434
|
+
readonly type: "bytes";
|
|
435
|
+
}];
|
|
436
|
+
readonly name: "removeOwnerAtIndex";
|
|
437
|
+
readonly outputs: readonly [];
|
|
438
|
+
readonly stateMutability: "nonpayable";
|
|
439
|
+
readonly type: "function";
|
|
440
|
+
}, {
|
|
441
|
+
readonly inputs: readonly [];
|
|
442
|
+
readonly name: "removedOwnersCount";
|
|
443
|
+
readonly outputs: readonly [{
|
|
444
|
+
readonly name: "";
|
|
445
|
+
readonly type: "uint256";
|
|
446
|
+
}];
|
|
447
|
+
readonly stateMutability: "view";
|
|
448
|
+
readonly type: "function";
|
|
449
|
+
}, {
|
|
450
|
+
readonly inputs: readonly [{
|
|
451
|
+
readonly name: "hash";
|
|
452
|
+
readonly type: "bytes32";
|
|
453
|
+
}];
|
|
454
|
+
readonly name: "replaySafeHash";
|
|
455
|
+
readonly outputs: readonly [{
|
|
456
|
+
readonly name: "";
|
|
457
|
+
readonly type: "bytes32";
|
|
458
|
+
}];
|
|
459
|
+
readonly stateMutability: "view";
|
|
460
|
+
readonly type: "function";
|
|
461
|
+
}, {
|
|
462
|
+
readonly inputs: readonly [{
|
|
463
|
+
readonly name: "newImplementation";
|
|
464
|
+
readonly type: "address";
|
|
465
|
+
}, {
|
|
466
|
+
readonly name: "data";
|
|
467
|
+
readonly type: "bytes";
|
|
468
|
+
}];
|
|
469
|
+
readonly name: "upgradeToAndCall";
|
|
470
|
+
readonly outputs: readonly [];
|
|
471
|
+
readonly stateMutability: "payable";
|
|
472
|
+
readonly type: "function";
|
|
473
|
+
}, {
|
|
474
|
+
readonly inputs: readonly [{
|
|
475
|
+
readonly components: readonly [{
|
|
476
|
+
readonly name: "sender";
|
|
477
|
+
readonly type: "address";
|
|
478
|
+
}, {
|
|
479
|
+
readonly name: "nonce";
|
|
480
|
+
readonly type: "uint256";
|
|
481
|
+
}, {
|
|
482
|
+
readonly name: "initCode";
|
|
483
|
+
readonly type: "bytes";
|
|
484
|
+
}, {
|
|
485
|
+
readonly name: "callData";
|
|
486
|
+
readonly type: "bytes";
|
|
487
|
+
}, {
|
|
488
|
+
readonly name: "callGasLimit";
|
|
489
|
+
readonly type: "uint256";
|
|
490
|
+
}, {
|
|
491
|
+
readonly name: "verificationGasLimit";
|
|
492
|
+
readonly type: "uint256";
|
|
493
|
+
}, {
|
|
494
|
+
readonly name: "preVerificationGas";
|
|
495
|
+
readonly type: "uint256";
|
|
496
|
+
}, {
|
|
497
|
+
readonly name: "maxFeePerGas";
|
|
498
|
+
readonly type: "uint256";
|
|
499
|
+
}, {
|
|
500
|
+
readonly name: "maxPriorityFeePerGas";
|
|
501
|
+
readonly type: "uint256";
|
|
502
|
+
}, {
|
|
503
|
+
readonly name: "paymasterAndData";
|
|
504
|
+
readonly type: "bytes";
|
|
505
|
+
}, {
|
|
506
|
+
readonly name: "signature";
|
|
507
|
+
readonly type: "bytes";
|
|
508
|
+
}];
|
|
509
|
+
readonly name: "userOp";
|
|
510
|
+
readonly type: "tuple";
|
|
511
|
+
}, {
|
|
512
|
+
readonly name: "userOpHash";
|
|
513
|
+
readonly type: "bytes32";
|
|
514
|
+
}, {
|
|
515
|
+
readonly name: "missingAccountFunds";
|
|
516
|
+
readonly type: "uint256";
|
|
517
|
+
}];
|
|
518
|
+
readonly name: "validateUserOp";
|
|
519
|
+
readonly outputs: readonly [{
|
|
520
|
+
readonly name: "validationData";
|
|
521
|
+
readonly type: "uint256";
|
|
522
|
+
}];
|
|
523
|
+
readonly stateMutability: "nonpayable";
|
|
524
|
+
readonly type: "function";
|
|
525
|
+
}, {
|
|
526
|
+
readonly stateMutability: "payable";
|
|
527
|
+
readonly type: "receive";
|
|
528
|
+
}];
|
|
529
|
+
type abi = typeof abi;
|
|
530
|
+
|
|
531
|
+
declare const factoryAbi: readonly [{
|
|
532
|
+
readonly inputs: readonly [{
|
|
533
|
+
readonly name: "implementation_";
|
|
534
|
+
readonly type: "address";
|
|
535
|
+
}];
|
|
536
|
+
readonly stateMutability: "payable";
|
|
537
|
+
readonly type: "constructor";
|
|
538
|
+
}, {
|
|
539
|
+
readonly inputs: readonly [];
|
|
540
|
+
readonly name: "OwnerRequired";
|
|
541
|
+
readonly type: "error";
|
|
542
|
+
}, {
|
|
543
|
+
readonly inputs: readonly [{
|
|
544
|
+
readonly name: "owners";
|
|
545
|
+
readonly type: "bytes[]";
|
|
546
|
+
}, {
|
|
547
|
+
readonly name: "nonce";
|
|
548
|
+
readonly type: "uint256";
|
|
549
|
+
}];
|
|
550
|
+
readonly name: "createAccount";
|
|
551
|
+
readonly outputs: readonly [{
|
|
552
|
+
readonly name: "account";
|
|
553
|
+
readonly type: "address";
|
|
554
|
+
}];
|
|
555
|
+
readonly stateMutability: "payable";
|
|
556
|
+
readonly type: "function";
|
|
557
|
+
}, {
|
|
558
|
+
readonly inputs: readonly [{
|
|
559
|
+
readonly name: "owners";
|
|
560
|
+
readonly type: "bytes[]";
|
|
561
|
+
}, {
|
|
562
|
+
readonly name: "nonce";
|
|
563
|
+
readonly type: "uint256";
|
|
564
|
+
}];
|
|
565
|
+
readonly name: "getAddress";
|
|
566
|
+
readonly outputs: readonly [{
|
|
567
|
+
readonly name: "";
|
|
568
|
+
readonly type: "address";
|
|
569
|
+
}];
|
|
570
|
+
readonly stateMutability: "view";
|
|
571
|
+
readonly type: "function";
|
|
572
|
+
}, {
|
|
573
|
+
readonly inputs: readonly [];
|
|
574
|
+
readonly name: "implementation";
|
|
575
|
+
readonly outputs: readonly [{
|
|
576
|
+
readonly name: "";
|
|
577
|
+
readonly type: "address";
|
|
578
|
+
}];
|
|
579
|
+
readonly stateMutability: "view";
|
|
580
|
+
readonly type: "function";
|
|
581
|
+
}, {
|
|
582
|
+
readonly inputs: readonly [];
|
|
583
|
+
readonly name: "initCodeHash";
|
|
584
|
+
readonly outputs: readonly [{
|
|
585
|
+
readonly name: "";
|
|
586
|
+
readonly type: "bytes32";
|
|
587
|
+
}];
|
|
588
|
+
readonly stateMutability: "view";
|
|
589
|
+
readonly type: "function";
|
|
590
|
+
}];
|
|
591
|
+
type factoryAbi = typeof factoryAbi;
|
|
592
|
+
|
|
593
|
+
type ToCoinbaseSmartAccountParameters = {
|
|
594
|
+
address?: Address | undefined;
|
|
595
|
+
client: Client;
|
|
596
|
+
owners: readonly OneOf<LocalAccount | WebAuthnAccount>[];
|
|
597
|
+
nonce?: bigint | undefined;
|
|
598
|
+
signer?: OneOf<LocalAccount | WebAuthnAccount>;
|
|
599
|
+
};
|
|
600
|
+
type ToCoinbaseSmartAccountReturnType = Prettify<SmartAccount<CoinbaseSmartAccountImplementation>>;
|
|
601
|
+
type CoinbaseSmartAccountImplementation = Assign<SmartAccountImplementation<typeof entryPoint07Abi, "0.7", {
|
|
602
|
+
__isCoinbaseSmartAccount: true;
|
|
603
|
+
abi: abi;
|
|
604
|
+
factory: {
|
|
605
|
+
abi: factoryAbi;
|
|
606
|
+
address: Address;
|
|
607
|
+
};
|
|
608
|
+
signer: OneOf<LocalAccount | WebAuthnAccount>;
|
|
609
|
+
}>, {
|
|
610
|
+
sign: NonNullable<SmartAccountImplementation["sign"]>;
|
|
611
|
+
isOwner: (account: LocalAccount | WebAuthnAccount) => Promise<boolean>;
|
|
612
|
+
}>;
|
|
613
|
+
/**
|
|
614
|
+
* @description Create a Coinbase Smart Account.
|
|
615
|
+
*
|
|
616
|
+
* @param parameters - {@link ToCoinbaseSmartAccountParameters}
|
|
617
|
+
* @returns Coinbase Smart Account. {@link ToCoinbaseSmartAccountReturnType}
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
|
|
621
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
622
|
+
* import { client } from './client.js'
|
|
623
|
+
*
|
|
624
|
+
* const account = toCoinbaseSmartAccount({
|
|
625
|
+
* client,
|
|
626
|
+
* owners: [privateKeyToAccount('0x...')],
|
|
627
|
+
* })
|
|
628
|
+
*/
|
|
629
|
+
declare function toCoinbaseSmartAccount(parameters: ToCoinbaseSmartAccountParameters): Promise<ToCoinbaseSmartAccountReturnType>;
|
|
630
|
+
/** @internal */
|
|
631
|
+
declare function sign({ hash, owner, }: {
|
|
632
|
+
hash: Hash;
|
|
633
|
+
owner: OneOf<LocalAccount | WebAuthnAccount>;
|
|
634
|
+
}): Promise<Hex>;
|
|
635
|
+
/** @internal */
|
|
636
|
+
declare function toReplaySafeHash({ address, chainId, hash }: {
|
|
637
|
+
address: Address;
|
|
638
|
+
chainId: number;
|
|
639
|
+
hash: Hash;
|
|
640
|
+
}): Hex;
|
|
641
|
+
/** @internal */
|
|
642
|
+
declare function toWebAuthnSignature({ webauthn, signature }: {
|
|
643
|
+
webauthn: WebAuthnData;
|
|
644
|
+
signature: Hex;
|
|
645
|
+
}): Hex;
|
|
646
|
+
/** @internal */
|
|
647
|
+
declare function wrapSignature(parameters: {
|
|
648
|
+
ownerIndex: number;
|
|
649
|
+
signature: Hex;
|
|
650
|
+
}): Hex;
|
|
651
|
+
|
|
652
|
+
declare function isCoinbaseSmartAccount(account: Account | undefined): account is ToCoinbaseSmartAccountReturnType;
|
|
653
|
+
|
|
654
|
+
export { CoinbaseSmartAccountImplementation, ToCoinbaseSmartAccountParameters, ToCoinbaseSmartAccountReturnType, isCoinbaseSmartAccount, sign, toCoinbaseSmartAccount, toReplaySafeHash, toWebAuthnSignature, wrapSignature };
|
package/dist/accounts.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function F(t){return t!=null&&"__isCoinbaseSmartAccount"in t&&t.__isCoinbaseSmartAccount===!0}import{pad as D,encodeFunctionData as w,hashMessage as P,hashTypedData as M,encodeAbiParameters as S,stringToHex as T,size as L,encodePacked as H,parseSignature as N,BaseError as W}from"viem";import{entryPoint07Abi as B,entryPoint07Address as G,getUserOperationHash as U,toSmartAccount as _}from"viem/account-abstraction";import{readContract as v}from"viem/actions";import{parseSignature as E}from"webauthn-p256";var c=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"owner",type:"bytes"}],name:"AlreadyOwner",type:"error"},{inputs:[],name:"Initialized",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidEthereumAddressOwner",type:"error"},{inputs:[{name:"key",type:"uint256"}],name:"InvalidNonceKey",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidOwnerBytesLength",type:"error"},{inputs:[],name:"LastOwner",type:"error"},{inputs:[{name:"index",type:"uint256"}],name:"NoOwnerAtIndex",type:"error"},{inputs:[{name:"ownersRemaining",type:"uint256"}],name:"NotLastOwner",type:"error"},{inputs:[{name:"selector",type:"bytes4"}],name:"SelectorNotAllowed",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"UnauthorizedCallContext",type:"error"},{inputs:[],name:"UpgradeFailed",type:"error"},{inputs:[{name:"index",type:"uint256"},{name:"expectedOwner",type:"bytes"},{name:"actualOwner",type:"bytes"}],name:"WrongOwnerAtIndex",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"AddOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"RemoveOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"REPLAYABLE_NONCE_KEY",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"addOwnerAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"addOwnerPublicKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"functionSelector",type:"bytes4"}],name:"canSkipChainIdValidation",outputs:[{name:"",type:"bool"}],stateMutability:"pure",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"entryPoint",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"execute",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"executeBatch",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"calls",type:"bytes[]"}],name:"executeWithoutChainIdValidation",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHashWithoutChainId",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"$",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"owners",type:"bytes[]"}],name:"initialize",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"isOwnerAddress",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"bytes"}],name:"isOwnerBytes",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"isOwnerPublicKey",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"result",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextOwnerIndex",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"}],name:"ownerAtIndex",outputs:[{name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"ownerCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeLastOwner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeOwnerAtIndex",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"removedOwnersCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"}],name:"replaySafeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"newImplementation",type:"address"},{name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"missingAccountFunds",type:"uint256"}],name:"validateUserOp",outputs:[{name:"validationData",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}];var O=[{inputs:[{name:"implementation_",type:"address"}],stateMutability:"payable",type:"constructor"},{inputs:[],name:"OwnerRequired",type:"error"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"createAccount",outputs:[{name:"account",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"getAddress",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initCodeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"}];async function ce(t){let{client:n,owners:i,nonce:s=0n}=t,x=t.address,f={abi:B,address:G,version:"0.7"},d={abi:O,address:"0x356336adA1619BeC1Ae4E6D94Dd9c0490DA414a8"};if(!i.length)throw new Error("`owners` must have at least one account.");function l(e){return e.type==="webAuthn"?e.publicKey:D(e.address)}let o=t.signer??i[0],p=i.indexOf(o);if(p===-1)throw new Error("`signer` must be one of `owners`.");let A=0n;return _({client:n,entryPoint:f,extend:{__isCoinbaseSmartAccount:!0,abi:c,factory:d,signer:o},async encodeCalls(e){if(e.length===1){let a=e[0];return w({abi:c,functionName:"execute",args:[a.to,a.value??0n,a.data??"0x"]})}return w({abi:c,functionName:"executeBatch",args:[e.map(a=>({data:a.data??"0x",target:a.to,value:a.value??0n}))]})},async getAddress(){return x??=await v(n,{...d,functionName:"getAddress",args:[i.map(l),s]}),x},async getNonce(){let e=8n;return A=(A+1n)%(1n<<e),(BigInt(Date.now())<<e)+A<<64n},async getFactoryArgs(){let e=w({abi:d.abi,functionName:"createAccount",args:[i.map(l),s]});return{factory:d.address,factoryData:e}},async getStubSignature(){return o.type==="webAuthn"?"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000":m({signature:"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",ownerIndex:p})},async sign(e){let a=await this.getAddress(),r=h({address:a,chainId:n.chain.id,hash:e.hash}),u=await b({hash:r,owner:o});return m({signature:u,ownerIndex:p})},async signMessage(e){let{message:a}=e,r=await this.getAddress(),u=h({address:r,chainId:n.chain.id,hash:P(a)}),y=await b({hash:u,owner:o});return m({signature:y,ownerIndex:p})},async signTypedData(e){let{domain:a,types:r,primaryType:u,message:y}=e,g=await this.getAddress(),I=h({address:g,chainId:n.chain.id,hash:M({domain:a,message:y,primaryType:u,types:r})}),C=await b({hash:I,owner:o});return m({signature:C,ownerIndex:p})},async signUserOperation(e){let{chainId:a=n.chain.id,...r}=e,u=await this.getAddress(),y=U({chainId:a,entryPointAddress:f.address,entryPointVersion:f.version,userOperation:{...r,sender:u}}),g=await b({hash:y,owner:o});return m({signature:g,ownerIndex:p})},userOperation:{async estimateGas(e){if(o.type==="webAuthn")return{verificationGasLimit:BigInt(Math.max(Number(e.verificationGasLimit??0n),8e5))}}},async isOwner(e){return await v(n,{abi:c,address:await this.getAddress(),functionName:"isOwnerBytes",args:[l(e)]})}})}async function b({hash:t,owner:n}){if(n.type==="webAuthn"){let{signature:i,webauthn:s}=await n.sign({hash:t});return R({signature:i,webauthn:s})}if(n.sign)return n.sign({hash:t});throw new W("`owner` does not support raw sign.")}function h({address:t,chainId:n,hash:i}){return M({domain:{chainId:n,name:"Coinbase Smart Wallet",verifyingContract:t,version:"1"},types:{CoinbaseSmartWalletMessage:[{name:"hash",type:"bytes32"}]},primaryType:"CoinbaseSmartWalletMessage",message:{hash:i}})}function R({webauthn:t,signature:n}){let{r:i,s}=E(n);return S([{components:[{name:"authenticatorData",type:"bytes"},{name:"clientDataJSON",type:"bytes"},{name:"challengeIndex",type:"uint256"},{name:"typeIndex",type:"uint256"},{name:"r",type:"uint256"},{name:"s",type:"uint256"}],type:"tuple"}],[{authenticatorData:t.authenticatorData,clientDataJSON:T(t.clientDataJSON),challengeIndex:BigInt(t.challengeIndex),typeIndex:BigInt(t.typeIndex),r:i,s}])}function m(t){let{ownerIndex:n}=t,i=(()=>{if(L(t.signature)!==65)return t.signature;let s=N(t.signature);return H(["bytes32","bytes32","uint8"],[s.r,s.s,s.yParity===0?27:28])})();return S([{components:[{name:"ownerIndex",type:"uint8"},{name:"signatureData",type:"bytes"}],type:"tuple"}],[{ownerIndex:n,signatureData:i}])}export{F as isCoinbaseSmartAccount,b as sign,ce as toCoinbaseSmartAccount,h as toReplaySafeHash,R as toWebAuthnSignature,m as wrapSignature};
|
|
2
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/accounts/coinbase-smart-account/isCoinbaseSmartAccount.ts","../src/accounts/coinbase-smart-account/toCoinbaseSmartAccount.ts","../src/accounts/coinbase-smart-account/abi.ts","../src/accounts/coinbase-smart-account/factoryAbi.ts"],"sourcesContent":["import { Account } from \"viem\";\nimport { ToCoinbaseSmartAccountReturnType } from \"./toCoinbaseSmartAccount\";\n\nexport function isCoinbaseSmartAccount(account: Account | undefined): account is ToCoinbaseSmartAccountReturnType {\n return account != null && \"__isCoinbaseSmartAccount\" in account && account.__isCoinbaseSmartAccount === true;\n}\n","// Forked from https://github.com/wevm/viem/blob/main/src/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.ts\n// to match our forked contracts (upgrade to v0.7 entrypoint)\nimport {\n Client,\n OneOf,\n LocalAccount,\n Prettify,\n Assign,\n pad,\n encodeFunctionData,\n hashMessage,\n TypedDataDefinition,\n hashTypedData,\n Hash,\n encodeAbiParameters,\n stringToHex,\n size,\n encodePacked,\n parseSignature,\n Address,\n TypedData,\n BaseError,\n} from \"viem\";\nimport {\n WebAuthnAccount,\n SmartAccount,\n SmartAccountImplementation,\n entryPoint07Abi,\n entryPoint07Address,\n getUserOperationHash,\n UserOperation,\n toSmartAccount,\n} from \"viem/account-abstraction\";\nimport { readContract } from \"viem/actions\";\nimport { type WebAuthnData, parseSignature as parseP256Signature, Hex } from \"webauthn-p256\";\nimport { abi } from \"./abi\";\nimport { factoryAbi } from \"./factoryAbi\";\n\nexport type ToCoinbaseSmartAccountParameters = {\n address?: Address | undefined;\n client: Client;\n owners: readonly OneOf<LocalAccount | WebAuthnAccount>[];\n nonce?: bigint | undefined;\n signer?: OneOf<LocalAccount | WebAuthnAccount>;\n};\n\nexport type ToCoinbaseSmartAccountReturnType = Prettify<SmartAccount<CoinbaseSmartAccountImplementation>>;\n\nexport type CoinbaseSmartAccountImplementation = Assign<\n SmartAccountImplementation<\n typeof entryPoint07Abi,\n \"0.7\",\n {\n __isCoinbaseSmartAccount: true;\n abi: abi;\n factory: { abi: factoryAbi; address: Address };\n signer: OneOf<LocalAccount | WebAuthnAccount>;\n }\n >,\n {\n sign: NonNullable<SmartAccountImplementation[\"sign\"]>;\n // TODO: should this be inside `extend` of `SmartAccountImplementation`?\n isOwner: (account: LocalAccount | WebAuthnAccount) => Promise<boolean>;\n }\n>;\n\n/**\n * @description Create a Coinbase Smart Account.\n *\n * @param parameters - {@link ToCoinbaseSmartAccountParameters}\n * @returns Coinbase Smart Account. {@link ToCoinbaseSmartAccountReturnType}\n *\n * @example\n * import { toCoinbaseSmartAccount } from 'viem/account-abstraction'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { client } from './client.js'\n *\n * const account = toCoinbaseSmartAccount({\n * client,\n * owners: [privateKeyToAccount('0x...')],\n * })\n */\nexport async function toCoinbaseSmartAccount(\n parameters: ToCoinbaseSmartAccountParameters,\n): Promise<ToCoinbaseSmartAccountReturnType> {\n const { client, owners, nonce = 0n } = parameters;\n\n let address = parameters.address;\n\n const entryPoint = {\n abi: entryPoint07Abi,\n address: entryPoint07Address,\n version: \"0.7\",\n } as const;\n const factory = {\n abi: factoryAbi,\n // TODO: make configurable?\n address: \"0x356336adA1619BeC1Ae4E6D94Dd9c0490DA414a8\",\n } as const;\n\n if (!owners.length) {\n throw new Error(\"`owners` must have at least one account.\");\n }\n\n function accountToBytes(account: LocalAccount | WebAuthnAccount): Hex {\n return account.type === \"webAuthn\" ? account.publicKey : pad(account.address);\n }\n\n const owner = parameters.signer ?? owners[0]!;\n const ownerIndex = owners.indexOf(owner);\n if (ownerIndex === -1) {\n throw new Error(\"`signer` must be one of `owners`.\");\n }\n\n let counter = 0n;\n\n return toSmartAccount({\n client,\n entryPoint,\n\n extend: {\n __isCoinbaseSmartAccount: true as const,\n abi,\n factory,\n signer: owner,\n },\n\n async encodeCalls(calls) {\n if (calls.length === 1) {\n const call = calls[0]!;\n return encodeFunctionData({\n abi,\n functionName: \"execute\",\n args: [call.to, call.value ?? 0n, call.data ?? \"0x\"],\n });\n }\n\n return encodeFunctionData({\n abi,\n functionName: \"executeBatch\",\n args: [\n calls.map((call) => ({\n data: call.data ?? \"0x\",\n target: call.to,\n value: call.value ?? 0n,\n })),\n ],\n });\n },\n\n async getAddress() {\n address ??= await readContract(client, {\n ...factory,\n functionName: \"getAddress\",\n args: [owners.map(accountToBytes), nonce],\n });\n return address;\n },\n\n async getNonce() {\n // allows for 256 nonces per ms\n const counterBits = 8n;\n counter = (counter + 1n) % (1n << counterBits);\n\n const timestamp = BigInt(Date.now());\n const nonce = ((timestamp << counterBits) + counter) << 64n;\n\n return nonce;\n },\n\n async getFactoryArgs() {\n const factoryData = encodeFunctionData({\n abi: factory.abi,\n functionName: \"createAccount\",\n args: [owners.map(accountToBytes), nonce],\n });\n return { factory: factory.address, factoryData };\n },\n\n async getStubSignature() {\n if (owner.type === \"webAuthn\")\n // eslint-disable-next-line max-len\n return \"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000\";\n return wrapSignature({\n signature:\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\",\n ownerIndex,\n });\n },\n\n async sign(parameters) {\n const address = await this.getAddress();\n\n const hash = toReplaySafeHash({\n address,\n chainId: client.chain!.id,\n hash: parameters.hash,\n });\n\n const signature = await sign({ hash, owner });\n\n return wrapSignature({ signature, ownerIndex });\n },\n\n async signMessage(parameters) {\n const { message } = parameters;\n const address = await this.getAddress();\n\n const hash = toReplaySafeHash({\n address,\n chainId: client.chain!.id,\n hash: hashMessage(message),\n });\n\n const signature = await sign({ hash, owner });\n\n return wrapSignature({ signature, ownerIndex });\n },\n\n async signTypedData(parameters) {\n const { domain, types, primaryType, message } = parameters as TypedDataDefinition<TypedData, string>;\n const address = await this.getAddress();\n\n const hash = toReplaySafeHash({\n address,\n chainId: client.chain!.id,\n hash: hashTypedData({\n domain,\n message,\n primaryType,\n types,\n }),\n });\n\n const signature = await sign({ hash, owner });\n\n return wrapSignature({ signature, ownerIndex });\n },\n\n async signUserOperation(parameters) {\n const { chainId = client.chain!.id, ...userOperation } = parameters;\n\n const address = await this.getAddress();\n const hash = getUserOperationHash({\n chainId,\n entryPointAddress: entryPoint.address,\n entryPointVersion: entryPoint.version,\n userOperation: {\n ...(userOperation as unknown as UserOperation),\n sender: address,\n },\n });\n\n const signature = await sign({ hash, owner });\n\n return wrapSignature({ signature, ownerIndex });\n },\n\n userOperation: {\n async estimateGas(userOperation) {\n if (owner.type !== \"webAuthn\") return;\n\n // Accounts with WebAuthn owner require a minimum verification gas limit of 800,000.\n return {\n verificationGasLimit: BigInt(Math.max(Number(userOperation.verificationGasLimit ?? 0n), 800_000)),\n };\n },\n },\n\n async isOwner(account: LocalAccount | WebAuthnAccount) {\n return await readContract(client, {\n abi,\n address: await this.getAddress(),\n functionName: \"isOwnerBytes\",\n args: [accountToBytes(account)],\n });\n },\n });\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n// Utilities\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n/** @internal */\nexport async function sign({\n hash,\n owner,\n}: {\n hash: Hash;\n owner: OneOf<LocalAccount | WebAuthnAccount>;\n}): Promise<Hex> {\n // WebAuthn Account (Passkey)\n if (owner.type === \"webAuthn\") {\n const { signature, webauthn } = await owner.sign({\n hash,\n });\n return toWebAuthnSignature({ signature, webauthn });\n }\n\n if (owner.sign) return owner.sign({ hash });\n\n throw new BaseError(\"`owner` does not support raw sign.\");\n}\n\n/** @internal */\nexport function toReplaySafeHash({ address, chainId, hash }: { address: Address; chainId: number; hash: Hash }): Hex {\n return hashTypedData({\n domain: {\n chainId,\n name: \"Coinbase Smart Wallet\",\n verifyingContract: address,\n version: \"1\",\n },\n types: {\n CoinbaseSmartWalletMessage: [\n {\n name: \"hash\",\n type: \"bytes32\",\n },\n ],\n },\n primaryType: \"CoinbaseSmartWalletMessage\",\n message: {\n hash,\n },\n });\n}\n\n/** @internal */\nexport function toWebAuthnSignature({ webauthn, signature }: { webauthn: WebAuthnData; signature: Hex }): Hex {\n const { r, s } = parseP256Signature(signature);\n return encodeAbiParameters(\n [\n {\n components: [\n {\n name: \"authenticatorData\",\n type: \"bytes\",\n },\n { name: \"clientDataJSON\", type: \"bytes\" },\n { name: \"challengeIndex\", type: \"uint256\" },\n { name: \"typeIndex\", type: \"uint256\" },\n {\n name: \"r\",\n type: \"uint256\",\n },\n {\n name: \"s\",\n type: \"uint256\",\n },\n ],\n type: \"tuple\",\n },\n ],\n [\n {\n authenticatorData: webauthn.authenticatorData,\n clientDataJSON: stringToHex(webauthn.clientDataJSON),\n challengeIndex: BigInt(webauthn.challengeIndex),\n typeIndex: BigInt(webauthn.typeIndex),\n r,\n s,\n },\n ],\n );\n}\n\n/** @internal */\nexport function wrapSignature(parameters: { ownerIndex: number; signature: Hex }): Hex {\n const { ownerIndex } = parameters;\n const signatureData = ((): Hex => {\n if (size(parameters.signature) !== 65) return parameters.signature;\n const signature = parseSignature(parameters.signature);\n return encodePacked([\"bytes32\", \"bytes32\", \"uint8\"], [signature.r, signature.s, signature.yParity === 0 ? 27 : 28]);\n })();\n return encodeAbiParameters(\n [\n {\n components: [\n {\n name: \"ownerIndex\",\n type: \"uint8\",\n },\n {\n name: \"signatureData\",\n type: \"bytes\",\n },\n ],\n type: \"tuple\",\n },\n ],\n [\n {\n ownerIndex,\n signatureData,\n },\n ],\n );\n}\n","export const abi = [\n { inputs: [], stateMutability: \"nonpayable\", type: \"constructor\" },\n {\n inputs: [{ name: \"owner\", type: \"bytes\" }],\n name: \"AlreadyOwner\",\n type: \"error\",\n },\n { inputs: [], name: \"Initialized\", type: \"error\" },\n {\n inputs: [{ name: \"owner\", type: \"bytes\" }],\n name: \"InvalidEthereumAddressOwner\",\n type: \"error\",\n },\n {\n inputs: [{ name: \"key\", type: \"uint256\" }],\n name: \"InvalidNonceKey\",\n type: \"error\",\n },\n {\n inputs: [{ name: \"owner\", type: \"bytes\" }],\n name: \"InvalidOwnerBytesLength\",\n type: \"error\",\n },\n { inputs: [], name: \"LastOwner\", type: \"error\" },\n {\n inputs: [{ name: \"index\", type: \"uint256\" }],\n name: \"NoOwnerAtIndex\",\n type: \"error\",\n },\n {\n inputs: [{ name: \"ownersRemaining\", type: \"uint256\" }],\n name: \"NotLastOwner\",\n type: \"error\",\n },\n {\n inputs: [{ name: \"selector\", type: \"bytes4\" }],\n name: \"SelectorNotAllowed\",\n type: \"error\",\n },\n { inputs: [], name: \"Unauthorized\", type: \"error\" },\n { inputs: [], name: \"UnauthorizedCallContext\", type: \"error\" },\n { inputs: [], name: \"UpgradeFailed\", type: \"error\" },\n {\n inputs: [\n { name: \"index\", type: \"uint256\" },\n { name: \"expectedOwner\", type: \"bytes\" },\n { name: \"actualOwner\", type: \"bytes\" },\n ],\n name: \"WrongOwnerAtIndex\",\n type: \"error\",\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n\n name: \"index\",\n type: \"uint256\",\n },\n { indexed: false, name: \"owner\", type: \"bytes\" },\n ],\n name: \"AddOwner\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n\n name: \"index\",\n type: \"uint256\",\n },\n { indexed: false, name: \"owner\", type: \"bytes\" },\n ],\n name: \"RemoveOwner\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n\n name: \"implementation\",\n type: \"address\",\n },\n ],\n name: \"Upgraded\",\n type: \"event\",\n },\n { stateMutability: \"payable\", type: \"fallback\" },\n {\n inputs: [],\n name: \"REPLAYABLE_NONCE_KEY\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"owner\", type: \"address\" }],\n name: \"addOwnerAddress\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"x\", type: \"bytes32\" },\n { name: \"y\", type: \"bytes32\" },\n ],\n name: \"addOwnerPublicKey\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"functionSelector\", type: \"bytes4\" }],\n name: \"canSkipChainIdValidation\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"pure\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"domainSeparator\",\n outputs: [{ name: \"\", type: \"bytes32\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"eip712Domain\",\n outputs: [\n { name: \"fields\", type: \"bytes1\" },\n { name: \"name\", type: \"string\" },\n { name: \"version\", type: \"string\" },\n { name: \"chainId\", type: \"uint256\" },\n { name: \"verifyingContract\", type: \"address\" },\n { name: \"salt\", type: \"bytes32\" },\n { name: \"extensions\", type: \"uint256[]\" },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"entryPoint\",\n outputs: [{ name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"target\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"data\", type: \"bytes\" },\n ],\n name: \"execute\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n components: [\n { name: \"target\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"data\", type: \"bytes\" },\n ],\n\n name: \"calls\",\n type: \"tuple[]\",\n },\n ],\n name: \"executeBatch\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"calls\", type: \"bytes[]\" }],\n name: \"executeWithoutChainIdValidation\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n components: [\n { name: \"sender\", type: \"address\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"initCode\", type: \"bytes\" },\n { name: \"callData\", type: \"bytes\" },\n { name: \"callGasLimit\", type: \"uint256\" },\n {\n name: \"verificationGasLimit\",\n type: \"uint256\",\n },\n {\n name: \"preVerificationGas\",\n type: \"uint256\",\n },\n { name: \"maxFeePerGas\", type: \"uint256\" },\n {\n name: \"maxPriorityFeePerGas\",\n type: \"uint256\",\n },\n { name: \"paymasterAndData\", type: \"bytes\" },\n { name: \"signature\", type: \"bytes\" },\n ],\n\n name: \"userOp\",\n type: \"tuple\",\n },\n ],\n name: \"getUserOpHashWithoutChainId\",\n outputs: [{ name: \"\", type: \"bytes32\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"implementation\",\n outputs: [{ name: \"$\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"owners\", type: \"bytes[]\" }],\n name: \"initialize\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"isOwnerAddress\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"account\", type: \"bytes\" }],\n name: \"isOwnerBytes\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"x\", type: \"bytes32\" },\n { name: \"y\", type: \"bytes32\" },\n ],\n name: \"isOwnerPublicKey\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"hash\", type: \"bytes32\" },\n { name: \"signature\", type: \"bytes\" },\n ],\n name: \"isValidSignature\",\n outputs: [{ name: \"result\", type: \"bytes4\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"nextOwnerIndex\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"index\", type: \"uint256\" }],\n name: \"ownerAtIndex\",\n outputs: [{ name: \"\", type: \"bytes\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"ownerCount\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"proxiableUUID\",\n outputs: [{ name: \"\", type: \"bytes32\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"index\", type: \"uint256\" },\n { name: \"owner\", type: \"bytes\" },\n ],\n name: \"removeLastOwner\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"index\", type: \"uint256\" },\n { name: \"owner\", type: \"bytes\" },\n ],\n name: \"removeOwnerAtIndex\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"removedOwnersCount\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"hash\", type: \"bytes32\" }],\n name: \"replaySafeHash\",\n outputs: [{ name: \"\", type: \"bytes32\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"newImplementation\", type: \"address\" },\n { name: \"data\", type: \"bytes\" },\n ],\n name: \"upgradeToAndCall\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n components: [\n { name: \"sender\", type: \"address\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"initCode\", type: \"bytes\" },\n { name: \"callData\", type: \"bytes\" },\n { name: \"callGasLimit\", type: \"uint256\" },\n {\n name: \"verificationGasLimit\",\n type: \"uint256\",\n },\n {\n name: \"preVerificationGas\",\n type: \"uint256\",\n },\n { name: \"maxFeePerGas\", type: \"uint256\" },\n {\n name: \"maxPriorityFeePerGas\",\n type: \"uint256\",\n },\n { name: \"paymasterAndData\", type: \"bytes\" },\n { name: \"signature\", type: \"bytes\" },\n ],\n\n name: \"userOp\",\n type: \"tuple\",\n },\n { name: \"userOpHash\", type: \"bytes32\" },\n { name: \"missingAccountFunds\", type: \"uint256\" },\n ],\n name: \"validateUserOp\",\n outputs: [{ name: \"validationData\", type: \"uint256\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n { stateMutability: \"payable\", type: \"receive\" },\n] as const;\n\nexport type abi = typeof abi;\n","export const factoryAbi = [\n {\n inputs: [{ name: \"implementation_\", type: \"address\" }],\n stateMutability: \"payable\",\n type: \"constructor\",\n },\n { inputs: [], name: \"OwnerRequired\", type: \"error\" },\n {\n inputs: [\n { name: \"owners\", type: \"bytes[]\" },\n { name: \"nonce\", type: \"uint256\" },\n ],\n name: \"createAccount\",\n outputs: [\n {\n name: \"account\",\n type: \"address\",\n },\n ],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owners\", type: \"bytes[]\" },\n { name: \"nonce\", type: \"uint256\" },\n ],\n name: \"getAddress\",\n outputs: [{ name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"implementation\",\n outputs: [{ name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"initCodeHash\",\n outputs: [{ name: \"\", type: \"bytes32\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n\nexport type factoryAbi = typeof factoryAbi;\n"],"mappings":"AAGO,SAASA,EAAuBC,EAA2E,CAChH,OAAOA,GAAW,MAAQ,6BAA8BA,GAAWA,EAAQ,2BAA6B,EAC1G,CCHA,OAME,OAAAC,EACA,sBAAAC,EACA,eAAAC,EAEA,iBAAAC,EAEA,uBAAAC,EACA,eAAAC,EACA,QAAAC,EACA,gBAAAC,EACA,kBAAAC,EAGA,aAAAC,MACK,OACP,OAIE,mBAAAC,EACA,uBAAAC,EACA,wBAAAC,EAEA,kBAAAC,MACK,2BACP,OAAS,gBAAAC,MAAoB,eAC7B,OAA4B,kBAAkBC,MAA+B,gBClCtE,IAAMC,EAAM,CACjB,CAAE,OAAQ,CAAC,EAAG,gBAAiB,aAAc,KAAM,aAAc,EACjE,CACE,OAAQ,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EAAG,CAACrB,EAAU,EAAGA,EAAU,EAAGA,EAAU,UAAY,EAAI,GAAK,EAAE,CAAC,CACpH,GAAG,EACH,OAAOgB,EACL,CACE,CACE,WAAY,CACV,CACE,KAAM,aACN,KAAM,OACR,EACA,CACE,KAAM,gBACN,KAAM,OACR,CACF,EACA,KAAM,OACR,CACF,EACA,CACE,CACE,WAAA7B,EACA,cAAA+B,CACF,CACF,CACF,CACF","names":["isCoinbaseSmartAccount","account","pad","encodeFunctionData","hashMessage","hashTypedData","encodeAbiParameters","stringToHex","size","encodePacked","parseSignature","BaseError","entryPoint07Abi","entryPoint07Address","getUserOperationHash","toSmartAccount","readContract","parseP256Signature","abi","factoryAbi","toCoinbaseSmartAccount","parameters","client","owners","nonce","address","entryPoint","entryPoint07Abi","entryPoint07Address","factory","factoryAbi","accountToBytes","account","pad","owner","ownerIndex","counter","toSmartAccount","abi","calls","call","encodeFunctionData","readContract","counterBits","factoryData","wrapSignature","hash","toReplaySafeHash","signature","sign","message","hashMessage","domain","types","primaryType","hashTypedData","chainId","userOperation","getUserOperationHash","webauthn","toWebAuthnSignature","BaseError","r","parseP256Signature","encodeAbiParameters","stringToHex","signatureData","size","parseSignature","encodePacked"]}
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Chain, Client, Transport, Account, WalletActions } from 'viem';
|
|
2
2
|
import { C as ContractWrite } from './getContract-93922960.js';
|
|
3
3
|
|
|
4
|
-
type TransactionQueueOptions<chain extends Chain> = {
|
|
4
|
+
type TransactionQueueOptions<chain extends Chain | undefined> = {
|
|
5
5
|
/**
|
|
6
6
|
* `publicClient` can be provided to be used in place of the extended viem client for making public action calls
|
|
7
7
|
* (`getChainId`, `getTransactionCount`, `simulateContract`, `call`). This helps in cases where the extended
|
|
@@ -17,7 +17,7 @@ type TransactionQueueOptions<chain extends Chain> = {
|
|
|
17
17
|
*/
|
|
18
18
|
queueConcurrency?: number;
|
|
19
19
|
};
|
|
20
|
-
declare function transactionQueue<chain extends Chain>(opts?: TransactionQueueOptions<chain>): <transport extends Transport, account extends Account | undefined = Account | undefined>(client: Client<transport, chain, account>) => Pick<WalletActions<chain, account>, "writeContract" | "sendTransaction">;
|
|
20
|
+
declare function transactionQueue<chain extends Chain | undefined>(opts?: TransactionQueueOptions<chain>): <transport extends Transport, account extends Account | undefined = Account | undefined>(client: Client<transport, chain, account>) => Pick<WalletActions<chain, account>, "writeContract" | "sendTransaction">;
|
|
21
21
|
|
|
22
22
|
type WriteObserverParameters = {
|
|
23
23
|
onWrite: (write: ContractWrite) => void;
|
package/dist/actions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as
|
|
1
|
+
import{e as o,f as a}from"./chunk-KYWXD3AM.js";import"./chunk-TCWGPC6G.js";function d(n={}){return e=>({writeContract:t=>o(e,t,n),sendTransaction:t=>a(e,t,n)})}import{getAction as s}from"viem/utils";import{writeContract as u}from"viem/actions";function f({onWrite:n}){let e=0;return t=>({writeContract:r=>{let i=s(t,u,"writeContract")(r),c=`${t.chain.id}:${t.account.address}:${e++}`;return n({id:c,request:r,result:i}),i}})}export{d as transactionQueue,f as writeObserver};
|
|
2
2
|
//# sourceMappingURL=actions.js.map
|
package/dist/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/actions/transactionQueue.ts","../src/actions/writeObserver.ts"],"sourcesContent":["import type { Transport, Chain, Account, WalletActions, Client } from \"viem\";\nimport { writeContract as mud_writeContract } from \"../writeContract\";\nimport { sendTransaction as mud_sendTransaction } from \"../sendTransaction\";\n\nexport type TransactionQueueOptions<chain extends Chain> = {\n /**\n * `publicClient` can be provided to be used in place of the extended viem client for making public action calls\n * (`getChainId`, `getTransactionCount`, `simulateContract`, `call`). This helps in cases where the extended\n * viem client is a smart account client, like in [permissionless.js](https://github.com/pimlicolabs/permissionless.js),\n * where the transport is the bundler, not an RPC.\n */\n publicClient?: Client<Transport, chain>;\n /**\n * Adjust the number of concurrent calls to the mempool. This defaults to `1` to ensure transactions are ordered\n * and nonces are handled properly. Any number greater than that is likely to see nonce errors and/or transactions\n * arriving out of order, but this may be an acceptable trade-off for some applications that can safely retry.\n * @default 1\n */\n queueConcurrency?: number;\n};\n\nexport function transactionQueue<chain extends Chain>(\n opts: TransactionQueueOptions<chain> = {},\n): <transport extends Transport, account extends Account | undefined = Account | undefined>(\n client: Client<transport, chain, account>,\n) => Pick<WalletActions<chain, account>, \"writeContract\" | \"sendTransaction\"> {\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args) => mud_writeContract(client, args, opts),\n // Applies to: `client.sendTransaction`\n sendTransaction: (args) => mud_sendTransaction(client, args, opts),\n });\n}\n","import type {\n WriteContractParameters,\n Transport,\n Chain,\n Account,\n WalletActions,\n WriteContractReturnType,\n Client,\n} from \"viem\";\nimport { getAction } from \"viem/utils\";\nimport { writeContract } from \"viem/actions\";\nimport { type ContractWrite } from \"../getContract\";\n\ntype WriteObserverParameters = { onWrite: (write: ContractWrite) => void };\n\nexport function writeObserver<TChain extends Chain, TAccount extends Account>({\n onWrite,\n}: WriteObserverParameters): (\n client: Client<Transport, TChain, TAccount>,\n) => Pick<WalletActions<TChain, TAccount>, \"writeContract\"> {\n let nextWriteId = 0;\n\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args): Promise<WriteContractReturnType> => {\n const result = getAction(client, writeContract, \"writeContract\")(args);\n\n const id = `${client.chain.id}:${client.account.address}:${nextWriteId++}`;\n onWrite({ id, request: args as WriteContractParameters, result });\n\n return result;\n },\n });\n}\n"],"mappings":"2EAqBO,SAASA,EACdC,EAAuC,CAAC,EAGoC,CAC5E,OAAQC,IAAY,CAElB,cAAgBC,GAASC,EAAkBF,EAAQC,EAAMF,CAAI,EAE7D,gBAAkBE,GAASE,EAAoBH,EAAQC,EAAMF,CAAI,CACnE,EACF,CCvBA,OAAS,aAAAK,MAAiB,aAC1B,OAAS,iBAAAC,MAAqB,eAKvB,SAASC,EAA8D,CAC5E,QAAAC,CACF,EAE4D,CAC1D,IAAIC,EAAc,EAElB,OAAQC,IAAY,CAElB,cAAgBC,GAA2C,CACzD,IAAMC,EAASP,EAAUK,EAAQJ,EAAe,eAAe,EAAEK,CAAI,EAE/DE,EAAK,GAAGH,EAAO,MAAM,MAAMA,EAAO,QAAQ,WAAWD,MAC3D,OAAAD,EAAQ,CAAE,GAAAK,EAAI,QAASF,EAAiC,OAAAC,CAAO,CAAC,EAEzDA,CACT,CACF,EACF","names":["transactionQueue","opts","client","args","writeContract","sendTransaction","getAction","writeContract","writeObserver","onWrite","nextWriteId","client","args","result","id"]}
|
|
1
|
+
{"version":3,"sources":["../src/actions/transactionQueue.ts","../src/actions/writeObserver.ts"],"sourcesContent":["import type { Transport, Chain, Account, WalletActions, Client } from \"viem\";\nimport { writeContract as mud_writeContract } from \"../writeContract\";\nimport { sendTransaction as mud_sendTransaction } from \"../sendTransaction\";\n\nexport type TransactionQueueOptions<chain extends Chain | undefined> = {\n /**\n * `publicClient` can be provided to be used in place of the extended viem client for making public action calls\n * (`getChainId`, `getTransactionCount`, `simulateContract`, `call`). This helps in cases where the extended\n * viem client is a smart account client, like in [permissionless.js](https://github.com/pimlicolabs/permissionless.js),\n * where the transport is the bundler, not an RPC.\n */\n publicClient?: Client<Transport, chain>;\n /**\n * Adjust the number of concurrent calls to the mempool. This defaults to `1` to ensure transactions are ordered\n * and nonces are handled properly. Any number greater than that is likely to see nonce errors and/or transactions\n * arriving out of order, but this may be an acceptable trade-off for some applications that can safely retry.\n * @default 1\n */\n queueConcurrency?: number;\n};\n\nexport function transactionQueue<chain extends Chain | undefined>(\n opts: TransactionQueueOptions<chain> = {},\n): <transport extends Transport, account extends Account | undefined = Account | undefined>(\n client: Client<transport, chain, account>,\n) => Pick<WalletActions<chain, account>, \"writeContract\" | \"sendTransaction\"> {\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args) => mud_writeContract(client, args, opts),\n // Applies to: `client.sendTransaction`\n sendTransaction: (args) => mud_sendTransaction(client, args, opts),\n });\n}\n","import type {\n WriteContractParameters,\n Transport,\n Chain,\n Account,\n WalletActions,\n WriteContractReturnType,\n Client,\n} from \"viem\";\nimport { getAction } from \"viem/utils\";\nimport { writeContract } from \"viem/actions\";\nimport { type ContractWrite } from \"../getContract\";\n\ntype WriteObserverParameters = { onWrite: (write: ContractWrite) => void };\n\nexport function writeObserver<TChain extends Chain, TAccount extends Account>({\n onWrite,\n}: WriteObserverParameters): (\n client: Client<Transport, TChain, TAccount>,\n) => Pick<WalletActions<TChain, TAccount>, \"writeContract\"> {\n let nextWriteId = 0;\n\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args): Promise<WriteContractReturnType> => {\n const result = getAction(client, writeContract, \"writeContract\")(args);\n\n const id = `${client.chain.id}:${client.account.address}:${nextWriteId++}`;\n onWrite({ id, request: args as WriteContractParameters, result });\n\n return result;\n },\n });\n}\n"],"mappings":"2EAqBO,SAASA,EACdC,EAAuC,CAAC,EAGoC,CAC5E,OAAQC,IAAY,CAElB,cAAgBC,GAASC,EAAkBF,EAAQC,EAAMF,CAAI,EAE7D,gBAAkBE,GAASE,EAAoBH,EAAQC,EAAMF,CAAI,CACnE,EACF,CCvBA,OAAS,aAAAK,MAAiB,aAC1B,OAAS,iBAAAC,MAAqB,eAKvB,SAASC,EAA8D,CAC5E,QAAAC,CACF,EAE4D,CAC1D,IAAIC,EAAc,EAElB,OAAQC,IAAY,CAElB,cAAgBC,GAA2C,CACzD,IAAMC,EAASP,EAAUK,EAAQJ,EAAe,eAAe,EAAEK,CAAI,EAE/DE,EAAK,GAAGH,EAAO,MAAM,MAAMA,EAAO,QAAQ,WAAWD,MAC3D,OAAAD,EAAQ,CAAE,GAAAK,EAAI,QAASF,EAAiC,OAAAC,CAAO,CAAC,EAEzDA,CACT,CACF,EACF","names":["transactionQueue","opts","client","args","writeContract","sendTransaction","getAction","writeContract","writeObserver","onWrite","nextWriteId","client","args","result","id"]}
|
package/dist/kms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/account/kms/kmsKeyToAccount.ts","../src/account/kms/signWithKms.ts","../src/account/kms/sign.ts","../src/account/kms/getAddressFromKms.ts","../src/account/kms/getPublicKey.ts"],"sourcesContent":["import { KMSClient } from \"@aws-sdk/client-kms\";\nimport { LocalAccount, hashMessage, hashTypedData, keccak256, serializeTransaction, signatureToHex } from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport { signWithKms } from \"./signWithKms\";\nimport { getAddressFromKms } from \"./getAddressFromKms\";\n\nexport type KmsKeyToAccountOptions = {\n keyId: string;\n client?: KMSClient;\n};\n\nexport type KmsAccount = LocalAccount<\"aws-kms\"> & {\n getKeyId(): string;\n};\n\n/**\n * @description Creates an Account from a KMS key.\n *\n * @returns A Local Account.\n */\nexport async function kmsKeyToAccount({\n keyId,\n client = new KMSClient(),\n}: KmsKeyToAccountOptions): Promise<KmsAccount> {\n const address = await getAddressFromKms({ keyId, client });\n\n const account = toAccount({\n address,\n async signMessage({ message }) {\n const signature = await signWithKms({\n client,\n keyId,\n hash: hashMessage(message),\n address,\n });\n\n return signatureToHex(signature);\n },\n // The logic of this function should be align with viem's signTransaction\n // https://github.com/wevm/viem/blob/main/src/accounts/utils/signTransaction.ts\n async signTransaction(transaction, { serializer = serializeTransaction } = {}) {\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n const signableTransaction = (() => {\n // For EIP-4844 Transactions, we want to sign the transaction payload body (tx_payload_body) without the sidecars (ie. without the network wrapper).\n // See: https://github.com/ethereum/EIPs/blob/e00f4daa66bd56e2dbd5f1d36d09fd613811a48b/EIPS/eip-4844.md#networking\n if (transaction.type === \"eip4844\")\n return {\n ...transaction,\n sidecars: false,\n };\n return transaction;\n })();\n\n const signature = await signWithKms({\n client,\n keyId,\n hash: keccak256(serializer(signableTransaction)),\n address,\n });\n\n return serializer(transaction, signature);\n },\n async signTypedData(typedData) {\n const signature = await signWithKms({\n client,\n keyId,\n hash: hashTypedData(typedData),\n address,\n });\n\n return signatureToHex(signature);\n },\n });\n\n return {\n ...account,\n source: \"aws-kms\",\n getKeyId: () => keyId,\n };\n}\n","import { Hex, Signature, isAddressEqual, signatureToHex, toHex } from \"viem\";\nimport { recoverAddress } from \"viem/utils\";\nimport { KMSClient, SignCommandInput } from \"@aws-sdk/client-kms\";\nimport { sign } from \"./sign\";\n// @ts-expect-error Could not find a declaration file for module 'asn1.js'.\nimport asn1 from \"asn1.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst EcdsaSigAsnParse = asn1.define(\"EcdsaSig\", function (this: any) {\n this.seq().obj(this.key(\"r\").int(), this.key(\"s\").int());\n});\n\nasync function getRS(signParams: {\n hash: Hex;\n keyId: SignCommandInput[\"KeyId\"];\n client: KMSClient;\n}): Promise<{ r: Hex; s: Hex }> {\n const signature = await sign(signParams);\n\n if (signature.Signature === undefined) {\n throw new Error(\"Signature is undefined.\");\n }\n\n const decoded = EcdsaSigAsnParse.decode(Buffer.from(signature.Signature), \"der\");\n\n const r = BigInt(decoded.r);\n let s = BigInt(decoded.s);\n\n const secp256k1N = BigInt(\"0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\");\n const secp256k1halfN = secp256k1N / 2n;\n\n if (s > secp256k1halfN) {\n s = secp256k1N - s;\n }\n\n return {\n r: toHex(r),\n s: toHex(s),\n };\n}\n\nasync function getRecovery(hash: Hex, r: Hex, s: Hex, expectedAddress: Hex): Promise<number> {\n let recovery: number;\n for (recovery = 0; recovery <= 1; recovery++) {\n const signature = signatureToHex({\n r,\n s,\n v: recovery ? 28n : 27n,\n yParity: recovery,\n });\n\n const address = await recoverAddress({ hash, signature });\n\n if (isAddressEqual(address, expectedAddress)) {\n return recovery;\n }\n }\n throw new Error(\"Failed to calculate recovery param\");\n}\n\ntype SignParameters = {\n hash: Hex;\n keyId: SignCommandInput[\"KeyId\"];\n client: KMSClient;\n address: Hex;\n};\n\ntype SignReturnType = Signature;\n\n/**\n * @description Signs a hash with a given KMS key.\n *\n * @param hash The hash to sign.\n *\n * @returns The signature.\n */\nexport async function signWithKms({ hash, address, keyId, client }: SignParameters): Promise<SignReturnType> {\n const { r, s } = await getRS({ keyId, hash, client });\n const recovery = await getRecovery(hash, r, s, address);\n\n return {\n r,\n s,\n v: recovery ? 28n : 27n,\n yParity: recovery,\n };\n}\n","import { KMSClient, SignCommand, SignCommandInput, SignCommandOutput } from \"@aws-sdk/client-kms\";\nimport { Hex, fromHex } from \"viem\";\n\nexport async function sign({\n keyId,\n hash,\n client,\n}: {\n hash: Hex;\n keyId: SignCommandInput[\"KeyId\"];\n client: KMSClient;\n}): Promise<SignCommandOutput> {\n const formatted = Buffer.from(fromHex(hash, \"bytes\"));\n\n const command = new SignCommand({\n KeyId: keyId,\n Message: formatted,\n SigningAlgorithm: \"ECDSA_SHA_256\",\n MessageType: \"DIGEST\",\n });\n\n return client.send(command);\n}\n","import { Address, toHex } from \"viem\";\nimport { publicKeyToAddress } from \"viem/utils\";\nimport { GetPublicKeyCommandInput, KMSClient } from \"@aws-sdk/client-kms\";\nimport { getPublicKey } from \"./getPublicKey\";\n// @ts-expect-error Could not find a declaration file for module 'asn1.js'.\nimport asn1 from \"asn1.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst EcdsaPubKey = asn1.define(\"EcdsaPubKey\", function (this: any) {\n this.seq().obj(this.key(\"algo\").seq().obj(this.key(\"a\").objid(), this.key(\"b\").objid()), this.key(\"pubKey\").bitstr());\n});\n\nfunction publicKeyKmsToAddress(publicKey: Uint8Array): Address {\n const res = EcdsaPubKey.decode(Buffer.from(publicKey));\n\n const publicKeyBuffer: Buffer = res.pubKey.data;\n\n const publicKeyHex = toHex(publicKeyBuffer);\n const address = publicKeyToAddress(publicKeyHex);\n\n return address;\n}\n\nexport async function getAddressFromKms({\n keyId,\n client,\n}: {\n keyId: GetPublicKeyCommandInput[\"KeyId\"];\n client: KMSClient;\n}): Promise<Address> {\n const KMSKey = await getPublicKey({ keyId, client });\n\n return publicKeyKmsToAddress(KMSKey.PublicKey as Uint8Array);\n}\n","import {\n GetPublicKeyCommand,\n GetPublicKeyCommandInput,\n GetPublicKeyCommandOutput,\n KMSClient,\n} from \"@aws-sdk/client-kms\";\n\nexport function getPublicKey({\n keyId,\n client,\n}: {\n keyId: GetPublicKeyCommandInput[\"KeyId\"];\n client: KMSClient;\n}): Promise<GetPublicKeyCommandOutput> {\n const command = new GetPublicKeyCommand({ KeyId: keyId });\n\n return client.send(command);\n}\n"],"mappings":"AAAA,OAAS,aAAAA,MAAiB,sBAC1B,OAAuB,eAAAC,EAAa,iBAAAC,EAAe,aAAAC,EAAW,wBAAAC,EAAsB,kBAAAC,MAAsB,OAC1G,OAAS,aAAAC,MAAiB,gBCF1B,OAAyB,kBAAAC,EAAgB,kBAAAC,EAAgB,SAAAC,MAAa,OACtE,OAAS,kBAAAC,MAAsB,aCD/B,OAAoB,eAAAC,MAAwD,sBAC5E,OAAc,WAAAC,MAAe,OAE7B,eAAsBC,EAAK,CACzB,MAAAC,EACA,KAAAC,EACA,OAAAC,CACF,EAI+B,CAC7B,IAAMC,EAAY,OAAO,KAAKL,EAAQG,EAAM,OAAO,CAAC,EAE9CG,EAAU,IAAIP,EAAY,CAC9B,MAAOG,EACP,QAASG,EACT,iBAAkB,gBAClB,YAAa,QACf,CAAC,EAED,OAAOD,EAAO,KAAKE,CAAO,CAC5B,CDjBA,OAAOC,MAAU,UAGjB,IAAMC,EAAmBD,EAAK,OAAO,WAAY,UAAqB,CACpE,KAAK,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,EAAE,IAAI,EAAG,KAAK,IAAI,GAAG,EAAE,IAAI,CAAC,CACzD,CAAC,EAED,eAAeE,EAAMC,EAIW,CAC9B,IAAMC,EAAY,MAAMC,EAAKF,CAAU,EAEvC,GAAIC,EA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OAAAP,EACA,MAAAD,EACA,KAAMe,EAAUH,EAAWE,CAAmB,CAAC,EAC/C,QAAAX,CACF,CAAC,EAED,OAAOS,EAAWD,EAAaJ,CAAS,CAC1C,EACA,MAAM,cAAcS,EAAW,CAC7B,IAAMT,EAAY,MAAMC,EAAY,CAClC,OAAAP,EACA,MAAAD,EACA,KAAMiB,EAAcD,CAAS,EAC7B,QAAAb,CACF,CAAC,EAED,OAAOO,EAAeH,CAAS,CACjC,CACF,CAAC,EAIC,OAAQ,UACR,SAAU,IAAMP,CAClB,CACF","names":["KMSClient","hashMessage","hashTypedData","keccak256","serializeTransaction","signatureToHex","toAccount","isAddressEqual","signatureToHex","toHex","recoverAddress","SignCommand","fromHex","sign","keyId","hash","client","formatted","command","asn1","EcdsaSigAsnParse","getRS","signParams","signature","sign","decoded","r","s","secp256k1N","secp256k1halfN","toHex","getRecovery","hash","expectedAddress","recovery","signatureToHex","address","recoverAddress","isAddressEqual","signWithKms","keyId","client","toHex","publicKeyToAddress","GetPublicKeyCommand","getPublicKey","keyId","client","command","asn1","EcdsaPubKey","publicKeyKmsToAddress","publicKey","publicKeyBuffer","publicKeyHex","toHex","publicKeyToAddress","getAddressFromKms","keyId","client","KMSKey","getPublicKey","kmsKeyToAccount","keyId","client","KMSClient","address","getAddressFromKms","toAccount","message","signature","signWithKms","hashMessage","signatureToHex","transaction","serializer","serializeTransaction","signableTransaction","keccak256","typedData","hashTypedData"]}
|
|
1
|
+
{"version":3,"sources":["../src/kms/kmsKeyToAccount.ts","../src/kms/signWithKms.ts","../src/kms/sign.ts","../src/kms/getAddressFromKms.ts","../src/kms/getPublicKey.ts"],"sourcesContent":["import { KMSClient } from \"@aws-sdk/client-kms\";\nimport { LocalAccount, hashMessage, hashTypedData, keccak256, serializeTransaction, signatureToHex } from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport { signWithKms } from \"./signWithKms\";\nimport { getAddressFromKms } from \"./getAddressFromKms\";\n\nexport type KmsKeyToAccountOptions = {\n keyId: string;\n client?: KMSClient;\n};\n\nexport type KmsAccount = LocalAccount<\"aws-kms\"> & {\n getKeyId(): string;\n};\n\n/**\n * @description Creates an Account from a KMS key.\n *\n * @returns A Local Account.\n */\nexport async function kmsKeyToAccount({\n keyId,\n client = new KMSClient(),\n}: KmsKeyToAccountOptions): Promise<KmsAccount> {\n const address = await getAddressFromKms({ keyId, client });\n\n const account = toAccount({\n address,\n async signMessage({ message }) {\n const signature = await signWithKms({\n client,\n keyId,\n hash: hashMessage(message),\n address,\n });\n\n return signatureToHex(signature);\n },\n // The logic of this function should be align with viem's signTransaction\n // https://github.com/wevm/viem/blob/main/src/accounts/utils/signTransaction.ts\n async signTransaction(transaction, { serializer = serializeTransaction } = {}) {\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n const signableTransaction = (() => {\n // For EIP-4844 Transactions, we want to sign the transaction payload body (tx_payload_body) without the sidecars (ie. without the network wrapper).\n // See: https://github.com/ethereum/EIPs/blob/e00f4daa66bd56e2dbd5f1d36d09fd613811a48b/EIPS/eip-4844.md#networking\n if (transaction.type === \"eip4844\")\n return {\n ...transaction,\n sidecars: false,\n };\n return transaction;\n })();\n\n const signature = await signWithKms({\n client,\n keyId,\n hash: keccak256(serializer(signableTransaction)),\n address,\n });\n\n return serializer(transaction, signature);\n },\n async signTypedData(typedData) {\n const signature = await signWithKms({\n client,\n keyId,\n hash: hashTypedData(typedData),\n address,\n });\n\n return signatureToHex(signature);\n },\n });\n\n return {\n ...account,\n source: \"aws-kms\",\n getKeyId: () => keyId,\n };\n}\n","import { Hex, Signature, isAddressEqual, signatureToHex, toHex } from \"viem\";\nimport { recoverAddress } from \"viem/utils\";\nimport { KMSClient, SignCommandInput } from \"@aws-sdk/client-kms\";\nimport { sign } from \"./sign\";\n// @ts-expect-error Could not find a declaration file for module 'asn1.js'.\nimport asn1 from \"asn1.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst EcdsaSigAsnParse = asn1.define(\"EcdsaSig\", function (this: any) {\n this.seq().obj(this.key(\"r\").int(), this.key(\"s\").int());\n});\n\nasync function getRS(signParams: {\n hash: Hex;\n keyId: SignCommandInput[\"KeyId\"];\n client: KMSClient;\n}): Promise<{ r: Hex; s: Hex }> {\n const signature = await sign(signParams);\n\n if (signature.Signature === undefined) {\n throw new Error(\"Signature is undefined.\");\n }\n\n const decoded = EcdsaSigAsnParse.decode(Buffer.from(signature.Signature), \"der\");\n\n const r = BigInt(decoded.r);\n let s = BigInt(decoded.s);\n\n const secp256k1N = BigInt(\"0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\");\n const secp256k1halfN = secp256k1N / 2n;\n\n if (s > secp256k1halfN) {\n s = secp256k1N - s;\n }\n\n return {\n r: toHex(r),\n s: toHex(s),\n };\n}\n\nasync function getRecovery(hash: Hex, r: Hex, s: Hex, expectedAddress: Hex): Promise<number> {\n let recovery: number;\n for (recovery = 0; recovery <= 1; recovery++) {\n const signature = signatureToHex({\n r,\n s,\n v: recovery ? 28n : 27n,\n yParity: recovery,\n });\n\n const address = await recoverAddress({ hash, signature });\n\n if (isAddressEqual(address, expectedAddress)) {\n return recovery;\n }\n }\n throw new Error(\"Failed to calculate recovery param\");\n}\n\ntype SignParameters = {\n hash: Hex;\n keyId: SignCommandInput[\"KeyId\"];\n client: KMSClient;\n address: Hex;\n};\n\ntype SignReturnType = Signature;\n\n/**\n * @description Signs a hash with a given KMS key.\n *\n * @param hash The hash to sign.\n *\n * @returns The signature.\n */\nexport async function signWithKms({ hash, address, keyId, client }: SignParameters): Promise<SignReturnType> {\n const { r, s } = await getRS({ keyId, hash, client });\n const recovery = await getRecovery(hash, r, s, address);\n\n return {\n r,\n s,\n v: recovery ? 28n : 27n,\n yParity: recovery,\n };\n}\n","import { KMSClient, SignCommand, SignCommandInput, SignCommandOutput } from \"@aws-sdk/client-kms\";\nimport { Hex, fromHex } from \"viem\";\n\nexport async function sign({\n keyId,\n hash,\n client,\n}: {\n hash: Hex;\n keyId: SignCommandInput[\"KeyId\"];\n client: KMSClient;\n}): Promise<SignCommandOutput> {\n const formatted = Buffer.from(fromHex(hash, \"bytes\"));\n\n const command = new SignCommand({\n KeyId: keyId,\n Message: formatted,\n SigningAlgorithm: \"ECDSA_SHA_256\",\n MessageType: \"DIGEST\",\n });\n\n return client.send(command);\n}\n","import { Address, toHex } from \"viem\";\nimport { publicKeyToAddress } from \"viem/utils\";\nimport { GetPublicKeyCommandInput, KMSClient } from \"@aws-sdk/client-kms\";\nimport { getPublicKey } from \"./getPublicKey\";\n// @ts-expect-error Could not find a declaration file for module 'asn1.js'.\nimport asn1 from \"asn1.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst EcdsaPubKey = asn1.define(\"EcdsaPubKey\", function (this: any) {\n this.seq().obj(this.key(\"algo\").seq().obj(this.key(\"a\").objid(), this.key(\"b\").objid()), this.key(\"pubKey\").bitstr());\n});\n\nfunction publicKeyKmsToAddress(publicKey: Uint8Array): Address {\n const res = EcdsaPubKey.decode(Buffer.from(publicKey));\n\n const publicKeyBuffer: Buffer = res.pubKey.data;\n\n const publicKeyHex = toHex(publicKeyBuffer);\n const address = publicKeyToAddress(publicKeyHex);\n\n return address;\n}\n\nexport async function getAddressFromKms({\n keyId,\n client,\n}: {\n keyId: GetPublicKeyCommandInput[\"KeyId\"];\n client: KMSClient;\n}): Promise<Address> {\n const KMSKey = await getPublicKey({ keyId, client });\n\n return publicKeyKmsToAddress(KMSKey.PublicKey as Uint8Array);\n}\n","import {\n GetPublicKeyCommand,\n GetPublicKeyCommandInput,\n GetPublicKeyCommandOutput,\n KMSClient,\n} from \"@aws-sdk/client-kms\";\n\nexport function getPublicKey({\n keyId,\n client,\n}: {\n keyId: GetPublicKeyCommandInput[\"KeyId\"];\n client: KMSClient;\n}): Promise<GetPublicKeyCommandOutput> {\n const command = new GetPublicKeyCommand({ KeyId: keyId });\n\n return client.send(command);\n}\n"],"mappings":"AAAA,OAAS,aAAAA,MAAiB,sBAC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G1C,OAFgBG,EAAmBF,CAAY,CAGjD,CAEA,eAAsBG,EAAkB,CACtC,MAAAC,EACA,OAAAC,CACF,EAGqB,CACnB,IAAMC,EAAS,MAAMC,EAAa,CAAE,MAAAH,EAAO,OAAAC,CAAO,CAAC,EAEnD,OAAOR,EAAsBS,EAAO,SAAuB,CAC7D,CHbA,eAAsBE,EAAgB,CACpC,MAAAC,EACA,OAAAC,EAAS,IAAIC,CACf,EAAgD,CAC9C,IAAMC,EAAU,MAAMC,EAAkB,CAAE,MAAAJ,EAAO,OAAAC,CAAO,CAAC,EAkDzD,MAAO,CACL,GAjDcI,EAAU,CACxB,QAAAF,EACA,MAAM,YAAY,CAAE,QAAAG,CAAQ,EAAG,CAC7B,IAAMC,EAAY,MAAMC,EAAY,CAClC,OAAAP,EACA,MAAAD,EACA,KAAMS,EAAYH,CAAO,EACzB,QAAAH,CACF,CAAC,EAED,OAAOO,EAAeH,CAAS,CACjC,EAGA,MAAM,gBAAgBI,EAAa,CAAE,WAAAC,EAAaC,CAAqB,EAAI,CAAC,EAAG,CAE7E,IAAMC,GAAuB,IAGvBH,EAAY,OAAS,UAChB,CACL,GAAGA,EACH,SAAU,EACZ,EACKA,GACN,EAEGJ,EAAY,MAAMC,EAAY,CAClC,OAAAP,EACA,MAAAD,EACA,KAAMe,EAAUH,EAAWE,CAAmB,CAAC,EAC/C,QAAAX,CACF,CAAC,EAED,OAAOS,EAAWD,EAAaJ,CAAS,CAC1C,EACA,MAAM,cAAcS,EAAW,CAC7B,IAAMT,EAAY,MAAMC,EAAY,CAClC,OAAAP,EACA,MAAAD,EACA,KAAMiB,EAAcD,CAAS,EAC7B,QAAAb,CACF,CAAC,EAED,OAAOO,EAAeH,CAAS,CACjC,CACF,CAAC,EAIC,OAAQ,UACR,SAAU,IAAMP,CAClB,CACF","names":["KMSClient","hashMessage","hashTypedData","keccak256","serializeTransaction","signatureToHex","toAccount","isAddressEqual","signatureToHex","toHex","recoverAddress","SignCommand","fromHex","sign","keyId","hash","client","formatted","command","asn1","EcdsaSigAsnParse","getRS","signParams","signature","sign","decoded","r","s","secp256k1N","secp256k1halfN","toHex","getRecovery","hash","expectedAddress","recovery","signatureToHex","address","recoverAddress","isAddressEqual","signWithKms","keyId","client","toHex","publicKeyToAddress","GetPublicKeyCommand","getPublicKey","keyId","client","command","asn1","EcdsaPubKey","publicKeyKmsToAddress","publicKey","publicKeyBuffer","publicKeyHex","toHex","publicKeyToAddress","getAddressFromKms","keyId","client","KMSKey","getPublicKey","kmsKeyToAccount","keyId","client","KMSClient","address","getAddressFromKms","toAccount","message","signature","signWithKms","hashMessage","signatureToHex","transaction","serializer","serializeTransaction","signableTransaction","keccak256","typedData","hashTypedData"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/common",
|
|
3
|
-
"version": "2.2.15-entrykit-
|
|
3
|
+
"version": "2.2.15-entrykit-d77b89f552d347913d6c4d75ad2a3e5e0b90379c",
|
|
4
4
|
"description": "Common low level logic shared between packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"./type-utils": "./dist/type-utils.js",
|
|
20
20
|
"./utils": "./dist/utils.js",
|
|
21
21
|
"./kms": "./dist/kms.js",
|
|
22
|
+
"./accounts": "./dist/accounts.js",
|
|
22
23
|
"./tsconfig.base.json": "./tsconfig.base.json"
|
|
23
24
|
},
|
|
24
25
|
"typesVersions": {
|
|
@@ -65,7 +66,8 @@
|
|
|
65
66
|
"p-retry": "^5.1.2",
|
|
66
67
|
"prettier": "3.2.5",
|
|
67
68
|
"prettier-plugin-solidity": "1.3.1",
|
|
68
|
-
"
|
|
69
|
+
"webauthn-p256": "^0.0.10",
|
|
70
|
+
"@latticexyz/schema-type": "2.2.15-entrykit-d77b89f552d347913d6c4d75ad2a3e5e0b90379c"
|
|
69
71
|
},
|
|
70
72
|
"devDependencies": {
|
|
71
73
|
"@types/debug": "^4.1.7",
|