@dvmkit/dvm-cli 0.0.0 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +67 -0
  2. package/NOTICE +2 -0
  3. package/README.md +28 -3
  4. package/dist/_esm-M2HUAA3B.js +883 -0
  5. package/dist/_esm-NRGECLJ7.js +35 -0
  6. package/dist/accounts-S747UW3A.js +73 -0
  7. package/dist/ccip-XZ5F5J6R.js +18 -0
  8. package/dist/chains-PINFXYUE.js +1460 -0
  9. package/dist/channel-store-GOV7TEDN.js +62 -0
  10. package/dist/chunk-3PPOU55E.js +312 -0
  11. package/dist/chunk-3TBULV3F.js +551 -0
  12. package/dist/chunk-4AQ4G7L5.js +1447 -0
  13. package/dist/chunk-5BUV73FO.js +2351 -0
  14. package/dist/chunk-6AJ7H2VX.js +4387 -0
  15. package/dist/chunk-6UGZAFIR.js +1485 -0
  16. package/dist/chunk-7UPZZGC5.js +30063 -0
  17. package/dist/chunk-ACNNU5RY.js +5485 -0
  18. package/dist/chunk-BZNZWRBB.js +189 -0
  19. package/dist/chunk-EY5K4BM3.js +1780 -0
  20. package/dist/chunk-G3RLVJF5.js +19 -0
  21. package/dist/chunk-GIDSTROG.js +16614 -0
  22. package/dist/chunk-HPRIQEJS.js +258 -0
  23. package/dist/chunk-IC6OXFYW.js +6484 -0
  24. package/dist/chunk-IYHTITNZ.js +45 -0
  25. package/dist/chunk-KC4UPK44.js +113 -0
  26. package/dist/chunk-MMJR6N3J.js +2426 -0
  27. package/dist/chunk-MTBCEXJ6.js +4602 -0
  28. package/dist/chunk-ONQMRWY3.js +83 -0
  29. package/dist/chunk-PHZHPRQE.js +1181 -0
  30. package/dist/chunk-RA24J4QM.js +3717 -0
  31. package/dist/chunk-RWBYCM47.js +339 -0
  32. package/dist/chunk-SLDVIXCS.js +21369 -0
  33. package/dist/chunk-TO47XRK7.js +24890 -0
  34. package/dist/chunk-U5TNSUYW.js +1757 -0
  35. package/dist/chunk-UU6QMSTQ.js +171 -0
  36. package/dist/chunk-UXQCP26E.js +2691 -0
  37. package/dist/chunk-XGABM4H5.js +3339 -0
  38. package/dist/chunk-YZUBKHHA.js +15436 -0
  39. package/dist/chunk-ZELLQI7F.js +248 -0
  40. package/dist/chunk-ZGXCK43G.js +9868 -0
  41. package/dist/client-D3XFLWOK.js +52 -0
  42. package/dist/dist-7MMV3EZA.js +46 -0
  43. package/dist/dvm.js +33650 -0
  44. package/dist/lifecycle-5RLM5JMN.js +29 -0
  45. package/dist/mine.wasm-DNBKYCTQ.js +12 -0
  46. package/dist/pocket-refill-GDYSTECR.js +133 -0
  47. package/dist/secp256k1-4YWQEMGF.js +19 -0
  48. package/dist/tempo-lifecycle-DHZPQTSB.js +31 -0
  49. package/dist/tempo-wallet-5FEOI4CF.js +35 -0
  50. package/dist/wallet-G3VOUCL4.js +30 -0
  51. package/dist/x402-VNFA3DBY.js +91 -0
  52. package/package.json +71 -6
  53. package/skills/dvm/SKILL.md +71 -0
@@ -0,0 +1,1447 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __dvmCreateRequire } from "node:module";
3
+ const require = __dvmCreateRequire(import.meta.url);
4
+ import {
5
+ Field,
6
+ assert2 as assert,
7
+ create,
8
+ createCurve,
9
+ extraEntropy,
10
+ extract,
11
+ from as from3,
12
+ fromRpcList,
13
+ sha256,
14
+ sha2562,
15
+ sha384,
16
+ sha512,
17
+ toBytes,
18
+ toHex,
19
+ toRpcList,
20
+ validate,
21
+ yParityToV
22
+ } from "./chunk-ZGXCK43G.js";
23
+ import {
24
+ BaseError,
25
+ concat,
26
+ concat2,
27
+ from,
28
+ from2,
29
+ fromArray,
30
+ fromBytes,
31
+ fromHex,
32
+ fromNumber,
33
+ fromString,
34
+ fromString2,
35
+ isEqual,
36
+ size,
37
+ slice2 as slice,
38
+ toBigInt,
39
+ toBigInt2,
40
+ toNumber,
41
+ toString2 as toString,
42
+ trimLeft
43
+ } from "./chunk-IC6OXFYW.js";
44
+ import {
45
+ __export
46
+ } from "./chunk-IYHTITNZ.js";
47
+
48
+ // node_modules/ox/_esm/core/Base64.js
49
+ var Base64_exports = {};
50
+ __export(Base64_exports, {
51
+ fromBytes: () => fromBytes2,
52
+ fromHex: () => fromHex2,
53
+ fromString: () => fromString3,
54
+ toBytes: () => toBytes2,
55
+ toHex: () => toHex2,
56
+ toString: () => toString2
57
+ });
58
+ var encoder = /* @__PURE__ */ new TextEncoder();
59
+ var decoder = /* @__PURE__ */ new TextDecoder();
60
+ var integerToCharacter = /* @__PURE__ */ Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((a, i) => [i, a.charCodeAt(0)]));
61
+ var characterToInteger = {
62
+ ...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((a, i) => [a.charCodeAt(0), i])),
63
+ ["=".charCodeAt(0)]: 0,
64
+ ["-".charCodeAt(0)]: 62,
65
+ ["_".charCodeAt(0)]: 63
66
+ };
67
+ function fromBytes2(value, options = {}) {
68
+ const { pad = true, url = false } = options;
69
+ const encoded = new Uint8Array(Math.ceil(value.length / 3) * 4);
70
+ for (let i = 0, j = 0; j < value.length; i += 4, j += 3) {
71
+ const y = (value[j] << 16) + (value[j + 1] << 8) + (value[j + 2] | 0);
72
+ encoded[i] = integerToCharacter[y >> 18];
73
+ encoded[i + 1] = integerToCharacter[y >> 12 & 63];
74
+ encoded[i + 2] = integerToCharacter[y >> 6 & 63];
75
+ encoded[i + 3] = integerToCharacter[y & 63];
76
+ }
77
+ const k = value.length % 3;
78
+ const end = Math.floor(value.length / 3) * 4 + (k && k + 1);
79
+ let base64 = decoder.decode(new Uint8Array(encoded.buffer, 0, end));
80
+ if (pad && k === 1)
81
+ base64 += "==";
82
+ if (pad && k === 2)
83
+ base64 += "=";
84
+ if (url)
85
+ base64 = base64.replaceAll("+", "-").replaceAll("/", "_");
86
+ return base64;
87
+ }
88
+ function fromHex2(value, options = {}) {
89
+ return fromBytes2(fromHex(value), options);
90
+ }
91
+ function fromString3(value, options = {}) {
92
+ return fromBytes2(fromString2(value), options);
93
+ }
94
+ function toBytes2(value) {
95
+ const base64 = value.replace(/=+$/, "");
96
+ const size2 = base64.length;
97
+ const decoded = new Uint8Array(size2 + 3);
98
+ encoder.encodeInto(base64 + "===", decoded);
99
+ for (let i = 0, j = 0; i < base64.length; i += 4, j += 3) {
100
+ const x = (characterToInteger[decoded[i]] << 18) + (characterToInteger[decoded[i + 1]] << 12) + (characterToInteger[decoded[i + 2]] << 6) + characterToInteger[decoded[i + 3]];
101
+ decoded[j] = x >> 16;
102
+ decoded[j + 1] = x >> 8 & 255;
103
+ decoded[j + 2] = x & 255;
104
+ }
105
+ const decodedSize = (size2 >> 2) * 3 + (size2 % 4 && size2 % 4 - 1);
106
+ return new Uint8Array(decoded.buffer, 0, decodedSize);
107
+ }
108
+ function toHex2(value) {
109
+ return fromBytes(toBytes2(value));
110
+ }
111
+ function toString2(value) {
112
+ return toString(toBytes2(value));
113
+ }
114
+
115
+ // node_modules/ox/_esm/core/AccessList.js
116
+ function fromTupleList(accessList) {
117
+ const list = [];
118
+ for (let i = 0; i < accessList.length; i++) {
119
+ const [address, storageKeys] = accessList[i];
120
+ if (address)
121
+ assert(address, { strict: false });
122
+ list.push({
123
+ address,
124
+ storageKeys: storageKeys.map((key) => validate(key) ? key : trimLeft(key))
125
+ });
126
+ }
127
+ return list;
128
+ }
129
+ function toTupleList(accessList) {
130
+ if (!accessList || accessList.length === 0)
131
+ return [];
132
+ const tuple = [];
133
+ for (const { address, storageKeys } of accessList) {
134
+ for (let j = 0; j < storageKeys.length; j++)
135
+ if (size(storageKeys[j]) !== 32)
136
+ throw new InvalidStorageKeySizeError({
137
+ storageKey: storageKeys[j]
138
+ });
139
+ if (address)
140
+ assert(address, { strict: false });
141
+ tuple.push([address, storageKeys]);
142
+ }
143
+ return tuple;
144
+ }
145
+ var InvalidStorageKeySizeError = class extends BaseError {
146
+ constructor({ storageKey }) {
147
+ super(`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${size(storageKey)} bytes.`);
148
+ Object.defineProperty(this, "name", {
149
+ enumerable: true,
150
+ configurable: true,
151
+ writable: true,
152
+ value: "AccessList.InvalidStorageKeySizeError"
153
+ });
154
+ }
155
+ };
156
+
157
+ // node_modules/ox/_esm/core/Transaction.js
158
+ var toRpcType = {
159
+ legacy: "0x0",
160
+ eip2930: "0x1",
161
+ eip1559: "0x2",
162
+ eip4844: "0x3",
163
+ eip7702: "0x4"
164
+ };
165
+ var fromRpcType = {
166
+ "0x0": "legacy",
167
+ "0x1": "eip2930",
168
+ "0x2": "eip1559",
169
+ "0x3": "eip4844",
170
+ "0x4": "eip7702"
171
+ };
172
+ function fromRpc(transaction, _options = {}) {
173
+ if (!transaction)
174
+ return null;
175
+ const signature = extract(transaction);
176
+ const transaction_ = {
177
+ ...transaction,
178
+ ...signature
179
+ };
180
+ transaction_.blockNumber = transaction.blockNumber ? BigInt(transaction.blockNumber) : null;
181
+ if ("blockTimestamp" in transaction)
182
+ transaction_.blockTimestamp = transaction.blockTimestamp ? BigInt(transaction.blockTimestamp) : transaction.blockTimestamp === null ? null : void 0;
183
+ transaction_.data = transaction.input;
184
+ transaction_.gas = BigInt(transaction.gas ?? 0n);
185
+ transaction_.nonce = BigInt(transaction.nonce ?? 0n);
186
+ transaction_.transactionIndex = transaction.transactionIndex ? Number(transaction.transactionIndex) : null;
187
+ transaction_.value = BigInt(transaction.value ?? 0n);
188
+ if (transaction.authorizationList)
189
+ transaction_.authorizationList = fromRpcList(transaction.authorizationList);
190
+ if (transaction.chainId)
191
+ transaction_.chainId = Number(transaction.chainId);
192
+ if (transaction.gasPrice)
193
+ transaction_.gasPrice = BigInt(transaction.gasPrice);
194
+ if (transaction.maxFeePerBlobGas)
195
+ transaction_.maxFeePerBlobGas = BigInt(transaction.maxFeePerBlobGas);
196
+ if (transaction.maxFeePerGas)
197
+ transaction_.maxFeePerGas = BigInt(transaction.maxFeePerGas);
198
+ if (transaction.maxPriorityFeePerGas)
199
+ transaction_.maxPriorityFeePerGas = BigInt(transaction.maxPriorityFeePerGas);
200
+ if (transaction.type)
201
+ transaction_.type = fromRpcType[transaction.type] ?? transaction.type;
202
+ if (signature)
203
+ transaction_.v = yParityToV(signature.yParity);
204
+ return transaction_;
205
+ }
206
+ function toRpc(transaction, _options) {
207
+ const rpc = {};
208
+ rpc.blockHash = transaction.blockHash;
209
+ rpc.blockNumber = typeof transaction.blockNumber === "bigint" ? fromNumber(transaction.blockNumber) : null;
210
+ if (typeof transaction.blockTimestamp === "bigint")
211
+ rpc.blockTimestamp = fromNumber(transaction.blockTimestamp);
212
+ else if (transaction.blockTimestamp === null)
213
+ rpc.blockTimestamp = null;
214
+ rpc.from = transaction.from;
215
+ rpc.gas = fromNumber(transaction.gas ?? 0n);
216
+ rpc.hash = transaction.hash;
217
+ rpc.input = transaction.input;
218
+ rpc.nonce = fromNumber(transaction.nonce ?? 0n);
219
+ rpc.to = transaction.to;
220
+ rpc.transactionIndex = transaction.transactionIndex ? fromNumber(transaction.transactionIndex) : null;
221
+ rpc.type = toRpcType[transaction.type] ?? transaction.type;
222
+ rpc.value = fromNumber(transaction.value ?? 0n);
223
+ if (transaction.accessList)
224
+ rpc.accessList = transaction.accessList;
225
+ if (transaction.authorizationList)
226
+ rpc.authorizationList = toRpcList(transaction.authorizationList);
227
+ if (transaction.blobVersionedHashes)
228
+ rpc.blobVersionedHashes = transaction.blobVersionedHashes;
229
+ if (transaction.chainId)
230
+ rpc.chainId = fromNumber(transaction.chainId);
231
+ if (typeof transaction.gasPrice === "bigint")
232
+ rpc.gasPrice = fromNumber(transaction.gasPrice);
233
+ if (typeof transaction.maxFeePerBlobGas === "bigint")
234
+ rpc.maxFeePerBlobGas = fromNumber(transaction.maxFeePerBlobGas);
235
+ if (typeof transaction.maxFeePerGas === "bigint")
236
+ rpc.maxFeePerGas = fromNumber(transaction.maxFeePerGas);
237
+ if (typeof transaction.maxPriorityFeePerGas === "bigint")
238
+ rpc.maxPriorityFeePerGas = fromNumber(transaction.maxPriorityFeePerGas);
239
+ if (typeof transaction.r === "bigint")
240
+ rpc.r = fromNumber(transaction.r, { size: 32 });
241
+ if (typeof transaction.s === "bigint")
242
+ rpc.s = fromNumber(transaction.s, { size: 32 });
243
+ if (typeof transaction.v === "number")
244
+ rpc.v = fromNumber(transaction.v, { size: 1 });
245
+ if (typeof transaction.yParity === "number")
246
+ rpc.yParity = transaction.yParity === 0 ? "0x0" : "0x1";
247
+ return rpc;
248
+ }
249
+
250
+ // node_modules/ox/_esm/core/Cbor.js
251
+ function encode(data, options = {}) {
252
+ const { as = "Hex" } = options;
253
+ const encodable = getEncodable(data);
254
+ const cursor = create(new Uint8Array(encodable.length));
255
+ encodable.encode(cursor);
256
+ if (as === "Hex")
257
+ return fromBytes(cursor.bytes);
258
+ return cursor.bytes;
259
+ }
260
+ var InvalidMajorTypeError = class extends BaseError {
261
+ constructor({ majorType }) {
262
+ super(`Invalid CBOR major type: ${majorType}`);
263
+ Object.defineProperty(this, "name", {
264
+ enumerable: true,
265
+ configurable: true,
266
+ writable: true,
267
+ value: "Cbor.InvalidMajorTypeError"
268
+ });
269
+ }
270
+ };
271
+ var InvalidAdditionalInfoError = class extends BaseError {
272
+ constructor({ additionalInfo }) {
273
+ super(`Invalid CBOR additional info: ${additionalInfo}`);
274
+ Object.defineProperty(this, "name", {
275
+ enumerable: true,
276
+ configurable: true,
277
+ writable: true,
278
+ value: "Cbor.InvalidAdditionalInfoError"
279
+ });
280
+ }
281
+ };
282
+ var Unsupported64BitIntegerError = class extends BaseError {
283
+ constructor() {
284
+ super("64-bit integers are not supported in CBOR decoding.");
285
+ Object.defineProperty(this, "name", {
286
+ enumerable: true,
287
+ configurable: true,
288
+ writable: true,
289
+ value: "Cbor.Unsupported64BitIntegerError"
290
+ });
291
+ }
292
+ };
293
+ var UnsupportedTagError = class extends BaseError {
294
+ constructor({ tag }) {
295
+ super(`CBOR tagged data (tag ${tag}) is not yet supported.`);
296
+ Object.defineProperty(this, "name", {
297
+ enumerable: true,
298
+ configurable: true,
299
+ writable: true,
300
+ value: "Cbor.UnsupportedTagError"
301
+ });
302
+ }
303
+ };
304
+ var InvalidIndefiniteLengthChunkError = class extends BaseError {
305
+ constructor({ type }) {
306
+ super(`Invalid chunk type in indefinite-length ${type}`);
307
+ Object.defineProperty(this, "name", {
308
+ enumerable: true,
309
+ configurable: true,
310
+ writable: true,
311
+ value: "Cbor.InvalidIndefiniteLengthChunkError"
312
+ });
313
+ }
314
+ };
315
+ var InvalidSimpleValueError = class extends BaseError {
316
+ constructor({ value }) {
317
+ super(`Invalid CBOR simple value: ${value}`);
318
+ Object.defineProperty(this, "name", {
319
+ enumerable: true,
320
+ configurable: true,
321
+ writable: true,
322
+ value: "Cbor.InvalidSimpleValueError"
323
+ });
324
+ }
325
+ };
326
+ var UnsupportedBigIntError = class extends BaseError {
327
+ constructor() {
328
+ super("BigInt values are not supported in CBOR encoding.");
329
+ Object.defineProperty(this, "name", {
330
+ enumerable: true,
331
+ configurable: true,
332
+ writable: true,
333
+ value: "Cbor.UnsupportedBigIntError"
334
+ });
335
+ }
336
+ };
337
+ var UnexpectedTokenError = class extends BaseError {
338
+ constructor({ token }) {
339
+ super(`Unexpected token: ${token}`);
340
+ Object.defineProperty(this, "name", {
341
+ enumerable: true,
342
+ configurable: true,
343
+ writable: true,
344
+ value: "Cbor.UnexpectedTokenError"
345
+ });
346
+ }
347
+ };
348
+ var NumberTooLargeError = class extends BaseError {
349
+ constructor({ number }) {
350
+ super(`Number exceeds maximum safe integer (${Number.MAX_SAFE_INTEGER}): ${number}`);
351
+ Object.defineProperty(this, "name", {
352
+ enumerable: true,
353
+ configurable: true,
354
+ writable: true,
355
+ value: "Cbor.NumberTooLargeError"
356
+ });
357
+ }
358
+ };
359
+ var StringTooLargeError = class extends BaseError {
360
+ constructor({ size: size2 }) {
361
+ super(`String length exceeds maximum (4294967295): ${size2}`);
362
+ Object.defineProperty(this, "name", {
363
+ enumerable: true,
364
+ configurable: true,
365
+ writable: true,
366
+ value: "Cbor.StringTooLargeError"
367
+ });
368
+ }
369
+ };
370
+ var ArrayTooLargeError = class extends BaseError {
371
+ constructor({ size: size2 }) {
372
+ super(`Array length exceeds maximum (4294967295): ${size2}`);
373
+ Object.defineProperty(this, "name", {
374
+ enumerable: true,
375
+ configurable: true,
376
+ writable: true,
377
+ value: "Cbor.ArrayTooLargeError"
378
+ });
379
+ }
380
+ };
381
+ var ObjectTooLargeError = class extends BaseError {
382
+ constructor({ size: size2 }) {
383
+ super(`Object size exceeds maximum (4294967295): ${size2}`);
384
+ Object.defineProperty(this, "name", {
385
+ enumerable: true,
386
+ configurable: true,
387
+ writable: true,
388
+ value: "Cbor.ObjectTooLargeError"
389
+ });
390
+ }
391
+ };
392
+ var ByteStringTooLargeError = class extends BaseError {
393
+ constructor({ size: size2 }) {
394
+ super(`Byte string length exceeds maximum (4294967295): ${size2}`);
395
+ Object.defineProperty(this, "name", {
396
+ enumerable: true,
397
+ configurable: true,
398
+ writable: true,
399
+ value: "Cbor.ByteStringTooLargeError"
400
+ });
401
+ }
402
+ };
403
+ function getEncodable(value) {
404
+ if (typeof value === "undefined")
405
+ return { length: 1, encode: (cursor) => cursor.pushUint8(247) };
406
+ if (value === null)
407
+ return { length: 1, encode: (cursor) => cursor.pushUint8(246) };
408
+ if (typeof value === "boolean")
409
+ return {
410
+ length: 1,
411
+ encode: (cursor) => cursor.pushUint8(value ? 245 : 244)
412
+ };
413
+ if (typeof value === "number")
414
+ return getEncodable.number(value);
415
+ if (typeof value === "bigint")
416
+ throw new UnsupportedBigIntError();
417
+ if (typeof value === "string")
418
+ return getEncodable.string(value);
419
+ if (Array.isArray(value))
420
+ return getEncodable.array(value);
421
+ if (value instanceof Uint8Array)
422
+ return getEncodable.byteString(value);
423
+ if (value instanceof ArrayBuffer)
424
+ return getEncodable.byteString(new Uint8Array(value));
425
+ if (ArrayBuffer.isView(value))
426
+ return getEncodable.byteString(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));
427
+ if (value instanceof Map)
428
+ return getEncodable.map(value);
429
+ if (typeof value === "object")
430
+ return getEncodable.object(value);
431
+ throw new UnexpectedTokenError({ token: String(value) });
432
+ }
433
+ (function(getEncodable2) {
434
+ function number(value) {
435
+ if (!Number.isSafeInteger(value)) {
436
+ const float32 = Math.fround(value);
437
+ if (Number.isNaN(value) || value === float32)
438
+ return {
439
+ length: 5,
440
+ // 1 byte prefix + 4 bytes float32
441
+ encode(cursor) {
442
+ cursor.pushUint8(250);
443
+ cursor.dataView.setFloat32(cursor.position, value, false);
444
+ cursor.position += 4;
445
+ }
446
+ };
447
+ return {
448
+ length: 9,
449
+ // 1 byte prefix + 8 bytes float64
450
+ encode(cursor) {
451
+ cursor.pushUint8(251);
452
+ cursor.dataView.setFloat64(cursor.position, value, false);
453
+ cursor.position += 8;
454
+ }
455
+ };
456
+ }
457
+ if (value >= 0) {
458
+ if (value <= 23)
459
+ return { length: 1, encode: (cursor) => cursor.pushUint8(value) };
460
+ if (value <= 255)
461
+ return {
462
+ length: 2,
463
+ // 1 byte prefix + 1 byte uint8
464
+ encode: (cursor) => {
465
+ cursor.pushUint8(24);
466
+ cursor.pushUint8(value);
467
+ }
468
+ };
469
+ if (value <= 65535)
470
+ return {
471
+ length: 3,
472
+ // 1 byte prefix + 2 bytes uint16
473
+ encode: (cursor) => {
474
+ cursor.pushUint8(25);
475
+ cursor.pushUint16(value);
476
+ }
477
+ };
478
+ if (value <= 4294967295)
479
+ return {
480
+ length: 5,
481
+ // 1 byte prefix + 4 bytes uint32
482
+ encode: (cursor) => {
483
+ cursor.pushUint8(26);
484
+ cursor.pushUint32(value);
485
+ }
486
+ };
487
+ throw new NumberTooLargeError({ number: value.toString(10) });
488
+ }
489
+ const positiveNumber = -1 - value;
490
+ if (value >= -24)
491
+ return {
492
+ length: 1,
493
+ encode: (cursor) => cursor.pushUint8(32 + positiveNumber)
494
+ };
495
+ if (positiveNumber <= 255)
496
+ return {
497
+ length: 2,
498
+ // 1 byte prefix + 1 byte uint8
499
+ encode: (cursor) => {
500
+ cursor.pushUint8(56);
501
+ cursor.pushUint8(positiveNumber);
502
+ }
503
+ };
504
+ if (positiveNumber <= 65535)
505
+ return {
506
+ length: 3,
507
+ // 1 byte prefix + 2 bytes uint16
508
+ encode: (cursor) => {
509
+ cursor.pushUint8(57);
510
+ cursor.pushUint16(positiveNumber);
511
+ }
512
+ };
513
+ if (positiveNumber <= 4294967295)
514
+ return {
515
+ length: 5,
516
+ // 1 byte prefix + 4 bytes uint32
517
+ encode: (cursor) => {
518
+ cursor.pushUint8(58);
519
+ cursor.pushUint32(positiveNumber);
520
+ }
521
+ };
522
+ throw new NumberTooLargeError({ number: value.toString(10) });
523
+ }
524
+ getEncodable2.number = number;
525
+ function string(value) {
526
+ const encoded = fromString2(value);
527
+ const size2 = encoded.length;
528
+ if (size2 <= 23)
529
+ return {
530
+ length: 1 + size2,
531
+ // 1 byte prefix + size bytes
532
+ encode(cursor) {
533
+ cursor.pushUint8(96 + size2);
534
+ if (size2 > 0)
535
+ cursor.pushBytes(encoded);
536
+ }
537
+ };
538
+ if (size2 <= 255)
539
+ return {
540
+ length: 2 + size2,
541
+ // 1 byte prefix + 1 byte uint8 + size bytes
542
+ encode(cursor) {
543
+ cursor.pushUint8(120);
544
+ cursor.pushUint8(size2);
545
+ cursor.pushBytes(encoded);
546
+ }
547
+ };
548
+ if (size2 <= 65535)
549
+ return {
550
+ length: 3 + size2,
551
+ // 1 byte prefix + 2 bytes uint16 + size bytes
552
+ encode(cursor) {
553
+ cursor.pushUint8(121);
554
+ cursor.pushUint16(size2);
555
+ cursor.pushBytes(encoded);
556
+ }
557
+ };
558
+ if (size2 <= 4294967295)
559
+ return {
560
+ length: 5 + size2,
561
+ // 1 byte prefix + 4 bytes uint32 + size bytes
562
+ encode(cursor) {
563
+ cursor.pushUint8(122);
564
+ cursor.pushUint32(size2);
565
+ cursor.pushBytes(encoded);
566
+ }
567
+ };
568
+ throw new StringTooLargeError({ size: size2 });
569
+ }
570
+ getEncodable2.string = string;
571
+ function array(value) {
572
+ const items = value.map((item) => getEncodable2(item));
573
+ const bodyLength = items.reduce((acc, item) => acc + item.length, 0);
574
+ const size2 = value.length;
575
+ if (size2 <= 23)
576
+ return {
577
+ length: 1 + bodyLength,
578
+ // 1 byte prefix + body length
579
+ encode(cursor) {
580
+ cursor.pushUint8(128 + size2);
581
+ for (const item of items)
582
+ item.encode(cursor);
583
+ }
584
+ };
585
+ if (size2 <= 255)
586
+ return {
587
+ length: 2 + bodyLength,
588
+ // 1 byte prefix + 1 byte uint8 + body length
589
+ encode(cursor) {
590
+ cursor.pushUint8(152);
591
+ cursor.pushUint8(size2);
592
+ for (const item of items)
593
+ item.encode(cursor);
594
+ }
595
+ };
596
+ if (size2 <= 65535)
597
+ return {
598
+ length: 3 + bodyLength,
599
+ // 1 byte prefix + 2 bytes uint16 + body length
600
+ encode(cursor) {
601
+ cursor.pushUint8(153);
602
+ cursor.pushUint16(size2);
603
+ for (const item of items)
604
+ item.encode(cursor);
605
+ }
606
+ };
607
+ if (size2 <= 4294967295)
608
+ return {
609
+ length: 5 + bodyLength,
610
+ // 1 byte prefix + 4 bytes uint32 + body length
611
+ encode(cursor) {
612
+ cursor.pushUint8(154);
613
+ cursor.pushUint32(size2);
614
+ for (const item of items)
615
+ item.encode(cursor);
616
+ }
617
+ };
618
+ throw new ArrayTooLargeError({ size: size2 });
619
+ }
620
+ getEncodable2.array = array;
621
+ function byteString(value) {
622
+ const size2 = value.byteLength;
623
+ if (size2 <= 23)
624
+ return {
625
+ length: 1 + size2,
626
+ // 1 byte prefix + size bytes
627
+ encode(cursor) {
628
+ cursor.pushUint8(64 + size2);
629
+ cursor.pushBytes(value);
630
+ }
631
+ };
632
+ if (size2 <= 255)
633
+ return {
634
+ length: 2 + size2,
635
+ // 1 byte prefix + 1 byte uint8 + size bytes
636
+ encode(cursor) {
637
+ cursor.pushUint8(88);
638
+ cursor.pushUint8(size2);
639
+ cursor.pushBytes(value);
640
+ }
641
+ };
642
+ if (size2 <= 65535)
643
+ return {
644
+ length: 3 + size2,
645
+ // 1 byte prefix + 2 bytes uint16 + size bytes
646
+ encode(cursor) {
647
+ cursor.pushUint8(89);
648
+ cursor.pushUint16(size2);
649
+ cursor.pushBytes(value);
650
+ }
651
+ };
652
+ if (size2 <= 4294967295)
653
+ return {
654
+ length: 5 + size2,
655
+ // 1 byte prefix + 4 bytes uint32 + size bytes
656
+ encode(cursor) {
657
+ cursor.pushUint8(90);
658
+ cursor.pushUint32(size2);
659
+ cursor.pushBytes(value);
660
+ }
661
+ };
662
+ throw new ByteStringTooLargeError({ size: size2 });
663
+ }
664
+ getEncodable2.byteString = byteString;
665
+ function object(value) {
666
+ const keys = Object.keys(value);
667
+ const entries = keys.map((key) => ({
668
+ key: getEncodable2(key),
669
+ value: getEncodable2(value[key])
670
+ }));
671
+ const bodyLength = entries.reduce((acc, entry) => acc + entry.key.length + entry.value.length, 0);
672
+ const size2 = keys.length;
673
+ if (size2 <= 23)
674
+ return {
675
+ length: 1 + bodyLength,
676
+ // 1 byte prefix + body length
677
+ encode(cursor) {
678
+ cursor.pushUint8(160 + size2);
679
+ for (const entry of entries) {
680
+ entry.key.encode(cursor);
681
+ entry.value.encode(cursor);
682
+ }
683
+ }
684
+ };
685
+ if (size2 <= 255)
686
+ return {
687
+ length: 2 + bodyLength,
688
+ // 1 byte prefix + 1 byte uint8 + body length
689
+ encode(cursor) {
690
+ cursor.pushUint8(184);
691
+ cursor.pushUint8(size2);
692
+ for (const entry of entries) {
693
+ entry.key.encode(cursor);
694
+ entry.value.encode(cursor);
695
+ }
696
+ }
697
+ };
698
+ if (size2 <= 65535)
699
+ return {
700
+ length: 3 + bodyLength,
701
+ // 1 byte prefix + 2 bytes uint16 + body length
702
+ encode(cursor) {
703
+ cursor.pushUint8(185);
704
+ cursor.pushUint16(size2);
705
+ for (const entry of entries) {
706
+ entry.key.encode(cursor);
707
+ entry.value.encode(cursor);
708
+ }
709
+ }
710
+ };
711
+ if (size2 <= 4294967295)
712
+ return {
713
+ length: 5 + bodyLength,
714
+ // 1 byte prefix + 4 bytes uint32 + body length
715
+ encode(cursor) {
716
+ cursor.pushUint8(186);
717
+ cursor.pushUint32(size2);
718
+ for (const entry of entries) {
719
+ entry.key.encode(cursor);
720
+ entry.value.encode(cursor);
721
+ }
722
+ }
723
+ };
724
+ throw new ObjectTooLargeError({ size: size2 });
725
+ }
726
+ getEncodable2.object = object;
727
+ function map(value) {
728
+ const entries = [];
729
+ for (const [k, v] of value)
730
+ entries.push({ key: getEncodable2(k), value: getEncodable2(v) });
731
+ const bodyLength = entries.reduce((acc, entry) => acc + entry.key.length + entry.value.length, 0);
732
+ const size2 = value.size;
733
+ if (size2 <= 23)
734
+ return {
735
+ length: 1 + bodyLength,
736
+ encode(cursor) {
737
+ cursor.pushUint8(160 + size2);
738
+ for (const entry of entries) {
739
+ entry.key.encode(cursor);
740
+ entry.value.encode(cursor);
741
+ }
742
+ }
743
+ };
744
+ if (size2 <= 255)
745
+ return {
746
+ length: 2 + bodyLength,
747
+ encode(cursor) {
748
+ cursor.pushUint8(184);
749
+ cursor.pushUint8(size2);
750
+ for (const entry of entries) {
751
+ entry.key.encode(cursor);
752
+ entry.value.encode(cursor);
753
+ }
754
+ }
755
+ };
756
+ if (size2 <= 65535)
757
+ return {
758
+ length: 3 + bodyLength,
759
+ encode(cursor) {
760
+ cursor.pushUint8(185);
761
+ cursor.pushUint16(size2);
762
+ for (const entry of entries) {
763
+ entry.key.encode(cursor);
764
+ entry.value.encode(cursor);
765
+ }
766
+ }
767
+ };
768
+ if (size2 <= 4294967295)
769
+ return {
770
+ length: 5 + bodyLength,
771
+ encode(cursor) {
772
+ cursor.pushUint8(186);
773
+ cursor.pushUint32(size2);
774
+ for (const entry of entries) {
775
+ entry.key.encode(cursor);
776
+ entry.value.encode(cursor);
777
+ }
778
+ }
779
+ };
780
+ throw new ObjectTooLargeError({ size: size2 });
781
+ }
782
+ getEncodable2.map = map;
783
+ })(getEncodable || (getEncodable = {}));
784
+ function decodeCursor(cursor) {
785
+ const initialByte = cursor.readUint8();
786
+ const majorType = initialByte >> 5;
787
+ const additionalInfo = initialByte & 31;
788
+ switch (majorType) {
789
+ // Major type 0: Unsigned integer
790
+ case 0:
791
+ return decodeCursor.readUnsignedInteger(cursor, additionalInfo);
792
+ // Major type 1: Negative integer
793
+ case 1:
794
+ return decodeCursor.readNegativeInteger(cursor, additionalInfo);
795
+ // Major type 2: Byte string
796
+ case 2:
797
+ return decodeCursor.readByteString(cursor, additionalInfo);
798
+ // Major type 3: Text string
799
+ case 3:
800
+ return decodeCursor.readTextString(cursor, additionalInfo);
801
+ // Major type 4: Array
802
+ case 4:
803
+ return decodeCursor.readArray(cursor, additionalInfo);
804
+ // Major type 5: Map
805
+ case 5:
806
+ return decodeCursor.readMap(cursor, additionalInfo);
807
+ // Major type 6: Tagged data (not yet supported)
808
+ case 6:
809
+ throw new UnsupportedTagError({ tag: additionalInfo });
810
+ // Major type 7: Simple values and floats
811
+ case 7:
812
+ return decodeCursor.readSimpleOrFloat(cursor, additionalInfo);
813
+ default:
814
+ throw new InvalidMajorTypeError({ majorType });
815
+ }
816
+ }
817
+ (function(decodeCursor2) {
818
+ function readLength(cursor, additionalInfo) {
819
+ if (additionalInfo < 24)
820
+ return additionalInfo;
821
+ if (additionalInfo === 24)
822
+ return cursor.readUint8();
823
+ if (additionalInfo === 25)
824
+ return cursor.readUint16();
825
+ if (additionalInfo === 26)
826
+ return cursor.readUint32();
827
+ if (additionalInfo === 27)
828
+ throw new Unsupported64BitIntegerError();
829
+ throw new InvalidAdditionalInfoError({ additionalInfo });
830
+ }
831
+ function readUnsignedInteger(cursor, additionalInfo) {
832
+ return readLength(cursor, additionalInfo);
833
+ }
834
+ decodeCursor2.readUnsignedInteger = readUnsignedInteger;
835
+ function readNegativeInteger(cursor, additionalInfo) {
836
+ const value = readLength(cursor, additionalInfo);
837
+ return -1 - value;
838
+ }
839
+ decodeCursor2.readNegativeInteger = readNegativeInteger;
840
+ function readByteString(cursor, additionalInfo) {
841
+ if (additionalInfo === 31) {
842
+ const chunks = [];
843
+ let totalLength = 0;
844
+ while (true) {
845
+ const byte = cursor.inspectUint8();
846
+ if (byte === 255) {
847
+ cursor.readUint8();
848
+ break;
849
+ }
850
+ const chunk = decodeCursor2(cursor);
851
+ if (!(chunk instanceof Uint8Array))
852
+ throw new InvalidIndefiniteLengthChunkError({ type: "byte string" });
853
+ chunks.push(chunk);
854
+ totalLength += chunk.length;
855
+ }
856
+ const result = new Uint8Array(totalLength);
857
+ let offset = 0;
858
+ for (const chunk of chunks) {
859
+ result.set(chunk, offset);
860
+ offset += chunk.length;
861
+ }
862
+ return result;
863
+ }
864
+ const length = readLength(cursor, additionalInfo);
865
+ return cursor.readBytes(length);
866
+ }
867
+ decodeCursor2.readByteString = readByteString;
868
+ function readTextString(cursor, additionalInfo) {
869
+ if (additionalInfo === 31) {
870
+ const chunks = [];
871
+ while (true) {
872
+ const byte = cursor.inspectUint8();
873
+ if (byte === 255) {
874
+ cursor.readUint8();
875
+ break;
876
+ }
877
+ const chunk = decodeCursor2(cursor);
878
+ if (typeof chunk !== "string")
879
+ throw new InvalidIndefiniteLengthChunkError({ type: "text string" });
880
+ chunks.push(chunk);
881
+ }
882
+ return chunks.join("");
883
+ }
884
+ const length = readLength(cursor, additionalInfo);
885
+ const bytes = cursor.readBytes(length);
886
+ return toString(bytes);
887
+ }
888
+ decodeCursor2.readTextString = readTextString;
889
+ function readArray(cursor, additionalInfo) {
890
+ if (additionalInfo === 31) {
891
+ const result2 = [];
892
+ while (true) {
893
+ const byte = cursor.inspectUint8();
894
+ if (byte === 255) {
895
+ cursor.readUint8();
896
+ break;
897
+ }
898
+ result2.push(decodeCursor2(cursor));
899
+ }
900
+ return result2;
901
+ }
902
+ const length = readLength(cursor, additionalInfo);
903
+ const result = [];
904
+ for (let i = 0; i < length; i++) {
905
+ result.push(decodeCursor2(cursor));
906
+ }
907
+ return result;
908
+ }
909
+ decodeCursor2.readArray = readArray;
910
+ function readMap(cursor, additionalInfo) {
911
+ if (additionalInfo === 31) {
912
+ const result2 = {};
913
+ while (true) {
914
+ const byte = cursor.inspectUint8();
915
+ if (byte === 255) {
916
+ cursor.readUint8();
917
+ break;
918
+ }
919
+ const key = decodeCursor2(cursor);
920
+ const keyStr = typeof key === "string" ? key : typeof key === "number" ? String(key) : String(key);
921
+ const value = decodeCursor2(cursor);
922
+ result2[keyStr] = value;
923
+ }
924
+ return result2;
925
+ }
926
+ const length = readLength(cursor, additionalInfo);
927
+ const result = {};
928
+ for (let i = 0; i < length; i++) {
929
+ const key = decodeCursor2(cursor);
930
+ const keyStr = typeof key === "string" ? key : typeof key === "number" ? String(key) : String(key);
931
+ const value = decodeCursor2(cursor);
932
+ result[keyStr] = value;
933
+ }
934
+ return result;
935
+ }
936
+ decodeCursor2.readMap = readMap;
937
+ function readSimpleOrFloat(cursor, additionalInfo) {
938
+ if (additionalInfo === 20)
939
+ return false;
940
+ if (additionalInfo === 21)
941
+ return true;
942
+ if (additionalInfo === 22)
943
+ return null;
944
+ if (additionalInfo === 23)
945
+ return void 0;
946
+ if (additionalInfo === 25) {
947
+ const bits = cursor.readUint16();
948
+ return getFloat16(bits);
949
+ }
950
+ if (additionalInfo === 26) {
951
+ const value = cursor.dataView.getFloat32(cursor.position, false);
952
+ cursor.position += 4;
953
+ return value;
954
+ }
955
+ if (additionalInfo === 27) {
956
+ const value = cursor.dataView.getFloat64(cursor.position, false);
957
+ cursor.position += 8;
958
+ return value;
959
+ }
960
+ if (additionalInfo === 24) {
961
+ const simpleValue = cursor.readUint8();
962
+ if (simpleValue < 32)
963
+ throw new InvalidSimpleValueError({ value: simpleValue });
964
+ return void 0;
965
+ }
966
+ throw new InvalidAdditionalInfoError({ additionalInfo });
967
+ }
968
+ decodeCursor2.readSimpleOrFloat = readSimpleOrFloat;
969
+ function getFloat16(bits) {
970
+ const sign5 = bits >> 15 & 1;
971
+ const exponent = bits >> 10 & 31;
972
+ const fraction = bits & 1023;
973
+ if (exponent === 0) {
974
+ if (fraction === 0)
975
+ return sign5 ? -0 : 0;
976
+ const value2 = 2 ** -14 * (fraction / 1024);
977
+ return sign5 ? -value2 : value2;
978
+ }
979
+ if (exponent === 31) {
980
+ if (fraction === 0)
981
+ return sign5 ? -Infinity : Infinity;
982
+ return NaN;
983
+ }
984
+ const value = 2 ** (exponent - 15) * (1 + fraction / 1024);
985
+ return sign5 ? -value : value;
986
+ }
987
+ })(decodeCursor || (decodeCursor = {}));
988
+
989
+ // node_modules/ox/_esm/core/CoseKey.js
990
+ function fromPublicKey(publicKey) {
991
+ const pkBytes = toBytes(publicKey);
992
+ const x = pkBytes.slice(1, 33);
993
+ const y = pkBytes.slice(33, 65);
994
+ return encode(/* @__PURE__ */ new Map([
995
+ [1, 2],
996
+ // kty: EC2
997
+ [3, -7],
998
+ // alg: ES256
999
+ [-1, 1],
1000
+ // crv: P-256
1001
+ [-2, x],
1002
+ // x coordinate
1003
+ [-3, y]
1004
+ // y coordinate
1005
+ ]));
1006
+ }
1007
+
1008
+ // node_modules/ox/node_modules/@noble/curves/esm/nist.js
1009
+ var Fp256 = Field(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"));
1010
+ var p256_a = Fp256.create(BigInt("-3"));
1011
+ var p256_b = BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");
1012
+ var p256 = createCurve({
1013
+ a: p256_a,
1014
+ b: p256_b,
1015
+ Fp: Fp256,
1016
+ n: BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
1017
+ Gx: BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),
1018
+ Gy: BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),
1019
+ h: BigInt(1),
1020
+ lowS: false
1021
+ }, sha256);
1022
+ var Fp384 = Field(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"));
1023
+ var p384_a = Fp384.create(BigInt("-3"));
1024
+ var p384_b = BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef");
1025
+ var p384 = createCurve({
1026
+ a: p384_a,
1027
+ b: p384_b,
1028
+ Fp: Fp384,
1029
+ n: BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),
1030
+ Gx: BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),
1031
+ Gy: BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),
1032
+ h: BigInt(1),
1033
+ lowS: false
1034
+ }, sha384);
1035
+ var Fp521 = Field(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
1036
+ var p521_a = Fp521.create(BigInt("-3"));
1037
+ var p521_b = BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00");
1038
+ var p521 = createCurve({
1039
+ a: p521_a,
1040
+ b: p521_b,
1041
+ Fp: Fp521,
1042
+ n: BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),
1043
+ Gx: BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),
1044
+ Gy: BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),
1045
+ h: BigInt(1),
1046
+ lowS: false,
1047
+ allowedPrivateKeyLengths: [130, 131, 132]
1048
+ // P521 keys are variable-length. Normalize to 132b
1049
+ }, sha512);
1050
+
1051
+ // node_modules/ox/node_modules/@noble/curves/esm/p256.js
1052
+ var p2562 = p256;
1053
+ var secp256r1 = p256;
1054
+
1055
+ // node_modules/ox/_esm/core/P256.js
1056
+ function getPublicKey(options) {
1057
+ const { privateKey } = options;
1058
+ const point = secp256r1.ProjectivePoint.fromPrivateKey(typeof privateKey === "string" ? privateKey.slice(2) : fromBytes(privateKey).slice(2));
1059
+ return from3(point);
1060
+ }
1061
+ function sign(options) {
1062
+ const { extraEntropy: extraEntropy2 = extraEntropy, hash, payload, privateKey } = options;
1063
+ const { r, s, recovery } = secp256r1.sign(payload instanceof Uint8Array ? payload : fromHex(payload), privateKey instanceof Uint8Array ? privateKey : fromHex(privateKey), {
1064
+ extraEntropy: typeof extraEntropy2 === "boolean" ? extraEntropy2 : from(extraEntropy2).slice(2),
1065
+ lowS: true,
1066
+ ...hash ? { prehash: true } : {}
1067
+ });
1068
+ return {
1069
+ r,
1070
+ s,
1071
+ yParity: recovery
1072
+ };
1073
+ }
1074
+ function verify(options) {
1075
+ const { hash, payload, publicKey, signature } = options;
1076
+ return secp256r1.verify(signature, payload instanceof Uint8Array ? payload : fromHex(payload), toHex(publicKey).substring(2), { lowS: true, ...hash ? { prehash: true } : {} });
1077
+ }
1078
+
1079
+ // node_modules/ox/_esm/core/TransactionRequest.js
1080
+ function fromRpc2(request) {
1081
+ const request_ = request;
1082
+ if (typeof request.authorizationList !== "undefined")
1083
+ request_.authorizationList = fromRpcList(request.authorizationList);
1084
+ if (typeof request.chainId !== "undefined")
1085
+ request_.chainId = toNumber(request.chainId);
1086
+ if (typeof request.gas !== "undefined")
1087
+ request_.gas = toBigInt(request.gas);
1088
+ if (typeof request.gasPrice !== "undefined")
1089
+ request_.gasPrice = toBigInt(request.gasPrice);
1090
+ if (typeof request.maxFeePerBlobGas !== "undefined")
1091
+ request_.maxFeePerBlobGas = toBigInt(request.maxFeePerBlobGas);
1092
+ if (typeof request.maxFeePerGas !== "undefined")
1093
+ request_.maxFeePerGas = toBigInt(request.maxFeePerGas);
1094
+ if (typeof request.maxPriorityFeePerGas !== "undefined")
1095
+ request_.maxPriorityFeePerGas = toBigInt(request.maxPriorityFeePerGas);
1096
+ if (typeof request.nonce !== "undefined")
1097
+ request_.nonce = toBigInt(request.nonce);
1098
+ if (typeof request.type !== "undefined")
1099
+ request_.type = fromRpcType[request.type] || request.type;
1100
+ if (typeof request.value !== "undefined")
1101
+ request_.value = toBigInt(request.value);
1102
+ return request_;
1103
+ }
1104
+ function toRpc2(request) {
1105
+ const request_rpc = {};
1106
+ if (typeof request.accessList !== "undefined")
1107
+ request_rpc.accessList = request.accessList;
1108
+ if (typeof request.authorizationList !== "undefined")
1109
+ request_rpc.authorizationList = toRpcList(request.authorizationList);
1110
+ if (typeof request.blobVersionedHashes !== "undefined")
1111
+ request_rpc.blobVersionedHashes = request.blobVersionedHashes;
1112
+ if (typeof request.blobs !== "undefined")
1113
+ request_rpc.blobs = request.blobs;
1114
+ if (typeof request.chainId !== "undefined")
1115
+ request_rpc.chainId = fromNumber(request.chainId);
1116
+ if (typeof request.data !== "undefined") {
1117
+ request_rpc.data = request.data;
1118
+ request_rpc.input = request.data;
1119
+ } else if (typeof request.input !== "undefined") {
1120
+ request_rpc.data = request.input;
1121
+ request_rpc.input = request.input;
1122
+ }
1123
+ if (typeof request.from !== "undefined")
1124
+ request_rpc.from = request.from;
1125
+ if (typeof request.gas !== "undefined")
1126
+ request_rpc.gas = fromNumber(request.gas);
1127
+ if (typeof request.gasPrice !== "undefined")
1128
+ request_rpc.gasPrice = fromNumber(request.gasPrice);
1129
+ if (typeof request.maxFeePerBlobGas !== "undefined")
1130
+ request_rpc.maxFeePerBlobGas = fromNumber(request.maxFeePerBlobGas);
1131
+ if (typeof request.maxFeePerGas !== "undefined")
1132
+ request_rpc.maxFeePerGas = fromNumber(request.maxFeePerGas);
1133
+ if (typeof request.maxPriorityFeePerGas !== "undefined")
1134
+ request_rpc.maxPriorityFeePerGas = fromNumber(request.maxPriorityFeePerGas);
1135
+ if (typeof request.maxPriorityFeePerGas !== "undefined")
1136
+ request_rpc.maxPriorityFeePerGas = fromNumber(request.maxPriorityFeePerGas);
1137
+ if (typeof request.nonce !== "undefined")
1138
+ request_rpc.nonce = fromNumber(request.nonce);
1139
+ if (typeof request.to !== "undefined")
1140
+ request_rpc.to = request.to;
1141
+ if (typeof request.type !== "undefined")
1142
+ request_rpc.type = toRpcType[request.type] || request.type;
1143
+ if (typeof request.value !== "undefined")
1144
+ request_rpc.value = fromNumber(request.value);
1145
+ return request_rpc;
1146
+ }
1147
+
1148
+ // node_modules/ox/_esm/core/Value.js
1149
+ var exponents = {
1150
+ wei: 0,
1151
+ gwei: 9,
1152
+ szabo: 12,
1153
+ finney: 15,
1154
+ ether: 18
1155
+ };
1156
+ function format(value, decimals = 0) {
1157
+ let display = value.toString();
1158
+ const negative = display.startsWith("-");
1159
+ if (negative)
1160
+ display = display.slice(1);
1161
+ display = display.padStart(decimals, "0");
1162
+ let [integer, fraction] = [
1163
+ display.slice(0, display.length - decimals),
1164
+ display.slice(display.length - decimals)
1165
+ ];
1166
+ fraction = fraction.replace(/(0+)$/, "");
1167
+ return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
1168
+ }
1169
+ function formatGwei(wei, unit = "wei") {
1170
+ return format(wei, exponents.gwei - exponents[unit]);
1171
+ }
1172
+
1173
+ // node_modules/ox/_esm/core/TxEnvelope.js
1174
+ var FeeCapTooHighError = class extends BaseError {
1175
+ constructor({ feeCap } = {}) {
1176
+ super(`The fee cap (\`maxFeePerGas\`/\`maxPriorityFeePerGas\`${feeCap ? ` = ${formatGwei(feeCap)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`);
1177
+ Object.defineProperty(this, "name", {
1178
+ enumerable: true,
1179
+ configurable: true,
1180
+ writable: true,
1181
+ value: "TransactionEnvelope.FeeCapTooHighError"
1182
+ });
1183
+ }
1184
+ };
1185
+ var InvalidChainIdError = class extends BaseError {
1186
+ constructor({ chainId }) {
1187
+ super(typeof chainId !== "undefined" ? `Chain ID "${chainId}" is invalid.` : "Chain ID is invalid.");
1188
+ Object.defineProperty(this, "name", {
1189
+ enumerable: true,
1190
+ configurable: true,
1191
+ writable: true,
1192
+ value: "TransactionEnvelope.InvalidChainIdError"
1193
+ });
1194
+ }
1195
+ };
1196
+ var InvalidSerializedError = class extends BaseError {
1197
+ constructor({ attributes, serialized, type }) {
1198
+ const missing = Object.entries(attributes).map(([key, value]) => typeof value === "undefined" ? key : void 0).filter(Boolean);
1199
+ super(`Invalid serialized transaction of type "${type}" was provided.`, {
1200
+ metaMessages: [
1201
+ `Serialized Transaction: "${serialized}"`,
1202
+ missing.length > 0 ? `Missing Attributes: ${missing.join(", ")}` : ""
1203
+ ].filter(Boolean)
1204
+ });
1205
+ Object.defineProperty(this, "name", {
1206
+ enumerable: true,
1207
+ configurable: true,
1208
+ writable: true,
1209
+ value: "TransactionEnvelope.InvalidSerializedError"
1210
+ });
1211
+ }
1212
+ };
1213
+ var TipAboveFeeCapError = class extends BaseError {
1214
+ constructor({ maxPriorityFeePerGas, maxFeePerGas } = {}) {
1215
+ super([
1216
+ `The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}).`
1217
+ ].join("\n"));
1218
+ Object.defineProperty(this, "name", {
1219
+ enumerable: true,
1220
+ configurable: true,
1221
+ writable: true,
1222
+ value: "TransactionEnvelope.TipAboveFeeCapError"
1223
+ });
1224
+ }
1225
+ };
1226
+
1227
+ // node_modules/ox/_esm/core/internal/webauthn.js
1228
+ function parseAsn1Signature(bytes) {
1229
+ const sig = p2562.Signature.fromDER(bytes).normalizeS();
1230
+ return { r: sig.r, s: sig.s };
1231
+ }
1232
+
1233
+ // node_modules/ox/_esm/webauthn/Authenticator.js
1234
+ function getAuthenticatorData(options = {}) {
1235
+ const { credential, flag = 5, rpId = window.location.hostname, signCount = 0 } = options;
1236
+ const rpIdHash = sha2562(fromString(rpId));
1237
+ const flag_bytes = fromNumber(flag, { size: 1 });
1238
+ const signCount_bytes = fromNumber(signCount, { size: 4 });
1239
+ const base = concat(rpIdHash, flag_bytes, signCount_bytes);
1240
+ if (!credential)
1241
+ return base;
1242
+ const aaguid = fromBytes(new Uint8Array(16));
1243
+ const credentialId = fromBytes(credential.id);
1244
+ const credIdLen = fromNumber(credential.id.length, { size: 2 });
1245
+ const coseKey = fromPublicKey(credential.publicKey);
1246
+ return concat(base, aaguid, credIdLen, credentialId, coseKey);
1247
+ }
1248
+ function getClientDataJSON(options) {
1249
+ const { challenge, crossOrigin = false, extraClientData, origin = window.location.origin, type = "webauthn.get" } = options;
1250
+ return JSON.stringify({
1251
+ type,
1252
+ challenge: fromHex2(challenge, { url: true, pad: false }),
1253
+ origin,
1254
+ crossOrigin,
1255
+ ...extraClientData
1256
+ });
1257
+ }
1258
+
1259
+ // node_modules/ox/_esm/webauthn/Authentication.js
1260
+ function getOptions(options) {
1261
+ const { credentialId, challenge, extensions, rpId = window.location.hostname, userVerification = "required" } = options;
1262
+ return {
1263
+ publicKey: {
1264
+ ...credentialId ? {
1265
+ allowCredentials: Array.isArray(credentialId) ? credentialId.map((id) => ({
1266
+ id: toBytes2(id),
1267
+ type: "public-key"
1268
+ })) : [
1269
+ {
1270
+ id: toBytes2(credentialId),
1271
+ type: "public-key"
1272
+ }
1273
+ ]
1274
+ } : {},
1275
+ challenge: fromHex(challenge),
1276
+ ...extensions && { extensions },
1277
+ rpId,
1278
+ userVerification
1279
+ }
1280
+ };
1281
+ }
1282
+ function getSignPayload(options) {
1283
+ const { challenge, crossOrigin, extraClientData, flag, origin, rpId, signCount, userVerification = "required" } = options;
1284
+ const authenticatorData = getAuthenticatorData({
1285
+ flag,
1286
+ rpId,
1287
+ signCount
1288
+ });
1289
+ const clientDataJSON = getClientDataJSON({
1290
+ challenge,
1291
+ crossOrigin,
1292
+ extraClientData,
1293
+ origin
1294
+ });
1295
+ const clientDataJSONHash = sha2562(fromString(clientDataJSON));
1296
+ const challengeIndex = clientDataJSON.indexOf('"challenge"');
1297
+ const typeIndex = clientDataJSON.indexOf('"type"');
1298
+ const metadata = {
1299
+ authenticatorData,
1300
+ clientDataJSON,
1301
+ challengeIndex,
1302
+ typeIndex,
1303
+ userVerificationRequired: userVerification === "required"
1304
+ };
1305
+ const payload = concat(authenticatorData, clientDataJSONHash);
1306
+ return { metadata, payload };
1307
+ }
1308
+ async function sign2(options) {
1309
+ const { getFn = (opts) => window.navigator.credentials.get(opts), ...rest } = options;
1310
+ const requestOptions = "publicKey" in rest ? rest : getOptions(rest);
1311
+ try {
1312
+ const credential = await getFn(requestOptions);
1313
+ if (!credential)
1314
+ throw new SignFailedError();
1315
+ const response = credential.response;
1316
+ const clientDataJSONBytes = new Uint8Array(response.clientDataJSON);
1317
+ const authenticatorDataBytes = new Uint8Array(response.authenticatorData);
1318
+ const signatureBytes = new Uint8Array(response.signature);
1319
+ const id = credential.id;
1320
+ const clientDataJSON = String.fromCharCode(...clientDataJSONBytes);
1321
+ const challengeIndex = clientDataJSON.indexOf('"challenge"');
1322
+ const typeIndex = clientDataJSON.indexOf('"type"');
1323
+ const signature = parseAsn1Signature(signatureBytes);
1324
+ return {
1325
+ id,
1326
+ metadata: {
1327
+ authenticatorData: fromBytes(authenticatorDataBytes),
1328
+ clientDataJSON,
1329
+ challengeIndex,
1330
+ typeIndex,
1331
+ userVerificationRequired: requestOptions.publicKey.userVerification === "required"
1332
+ },
1333
+ signature,
1334
+ raw: credential
1335
+ };
1336
+ } catch (error) {
1337
+ throw new SignFailedError({
1338
+ cause: error
1339
+ });
1340
+ }
1341
+ }
1342
+ var SignFailedError = class extends BaseError {
1343
+ constructor({ cause } = {}) {
1344
+ super("Failed to request credential.", {
1345
+ cause
1346
+ });
1347
+ Object.defineProperty(this, "name", {
1348
+ enumerable: true,
1349
+ configurable: true,
1350
+ writable: true,
1351
+ value: "Authentication.SignFailedError"
1352
+ });
1353
+ }
1354
+ };
1355
+ function verify2(options) {
1356
+ const { challenge, metadata, origin, publicKey, rpId, signature } = options;
1357
+ const { authenticatorData, clientDataJSON, userVerificationRequired } = metadata;
1358
+ const authenticatorDataBytes = fromHex(authenticatorData);
1359
+ if (authenticatorDataBytes.length < 37)
1360
+ return false;
1361
+ if (rpId !== void 0) {
1362
+ const rpIdHash = authenticatorDataBytes.slice(0, 32);
1363
+ const expectedRpIdHash = sha2562(fromString(rpId), { as: "Bytes" });
1364
+ if (!isEqual(rpIdHash, expectedRpIdHash))
1365
+ return false;
1366
+ }
1367
+ const flag = authenticatorDataBytes[32];
1368
+ if ((flag & 1) !== 1)
1369
+ return false;
1370
+ if (userVerificationRequired && (flag & 4) !== 4)
1371
+ return false;
1372
+ if ((flag & 8) !== 8 && (flag & 16) === 16)
1373
+ return false;
1374
+ const clientData = JSON.parse(clientDataJSON);
1375
+ if (clientData.type !== "webauthn.get")
1376
+ return false;
1377
+ if (!clientData.challenge || fromBytes(toBytes2(clientData.challenge)) !== challenge)
1378
+ return false;
1379
+ if (origin !== void 0) {
1380
+ const origins = Array.isArray(origin) ? origin : [origin];
1381
+ if (!origins.includes(clientData.origin))
1382
+ return false;
1383
+ }
1384
+ const clientDataJSONHash = sha2562(fromString2(clientDataJSON), {
1385
+ as: "Bytes"
1386
+ });
1387
+ const payload = concat2(authenticatorDataBytes, clientDataJSONHash);
1388
+ return verify({
1389
+ hash: true,
1390
+ payload,
1391
+ publicKey,
1392
+ signature
1393
+ });
1394
+ }
1395
+
1396
+ // node_modules/ox/_esm/core/WebAuthnP256.js
1397
+ var getSignPayload2 = getSignPayload;
1398
+ async function sign3(options) {
1399
+ return sign2(options);
1400
+ }
1401
+ function verify3(options) {
1402
+ return verify2(options);
1403
+ }
1404
+
1405
+ // node_modules/ox/_esm/core/WebCryptoP256.js
1406
+ async function sign4(options) {
1407
+ const { payload, privateKey } = options;
1408
+ const signature = await globalThis.crypto.subtle.sign({
1409
+ name: "ECDSA",
1410
+ hash: "SHA-256"
1411
+ }, privateKey, from2(payload));
1412
+ const signature_bytes = fromArray(new Uint8Array(signature));
1413
+ const r = toBigInt2(slice(signature_bytes, 0, 32));
1414
+ let s = toBigInt2(slice(signature_bytes, 32, 64));
1415
+ if (s > p2562.CURVE.n / 2n)
1416
+ s = p2562.CURVE.n - s;
1417
+ return { r, s };
1418
+ }
1419
+
1420
+ export {
1421
+ fromTupleList,
1422
+ toTupleList,
1423
+ Base64_exports,
1424
+ toRpcType,
1425
+ fromRpcType,
1426
+ fromRpc,
1427
+ toRpc,
1428
+ getPublicKey,
1429
+ sign,
1430
+ verify,
1431
+ fromRpc2,
1432
+ toRpc2,
1433
+ FeeCapTooHighError,
1434
+ InvalidChainIdError,
1435
+ InvalidSerializedError,
1436
+ TipAboveFeeCapError,
1437
+ getSignPayload2 as getSignPayload,
1438
+ sign3 as sign2,
1439
+ verify3 as verify2,
1440
+ sign4 as sign3
1441
+ };
1442
+ /*! Bundled license information:
1443
+
1444
+ @noble/curves/esm/nist.js:
1445
+ @noble/curves/esm/p256.js:
1446
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
1447
+ */