@springmicro/auth 0.7.2 → 0.7.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.
@@ -0,0 +1,1291 @@
1
+ import { t as te, i as A, q as c, B as u, o as Te, s as x, y as ne, C as Be, u as Ee, d as g, n as y, h as O, g as I, e as K } from "./Web3Auth-C1gorwXx.js";
2
+ import { w as Oe, H as Fe, n as X, d as Ge, e as Y, t as Le, b as $e, o as Ue, s as ze } from "./sha256-JJGtJ2gn.js";
3
+ const E = /* @__PURE__ */ BigInt(2 ** 32 - 1), W = /* @__PURE__ */ BigInt(32);
4
+ function Ce(e, t = !1) {
5
+ return t ? { h: Number(e & E), l: Number(e >> W & E) } : { h: Number(e >> W & E) | 0, l: Number(e & E) | 0 };
6
+ }
7
+ function je(e, t = !1) {
8
+ let n = new Uint32Array(e.length), i = new Uint32Array(e.length);
9
+ for (let s = 0; s < e.length; s++) {
10
+ const { h: o, l: r } = Ce(e[s], t);
11
+ [n[s], i[s]] = [o, r];
12
+ }
13
+ return [n, i];
14
+ }
15
+ const Ae = (e, t, n) => e << n | t >>> 32 - n, He = (e, t, n) => t << n | e >>> 32 - n, ke = (e, t, n) => t << n - 32 | e >>> 64 - n, Ne = (e, t, n) => e << n - 32 | t >>> 64 - n, [se, ie, re] = [[], [], []], Se = /* @__PURE__ */ BigInt(0), v = /* @__PURE__ */ BigInt(1), Ve = /* @__PURE__ */ BigInt(2), Me = /* @__PURE__ */ BigInt(7), _e = /* @__PURE__ */ BigInt(256), Re = /* @__PURE__ */ BigInt(113);
16
+ for (let e = 0, t = v, n = 1, i = 0; e < 24; e++) {
17
+ [n, i] = [i, (2 * n + 3 * i) % 5], se.push(2 * (5 * i + n)), ie.push((e + 1) * (e + 2) / 2 % 64);
18
+ let s = Se;
19
+ for (let o = 0; o < 7; o++)
20
+ t = (t << v ^ (t >> Me) * Re) % _e, t & Ve && (s ^= v << (v << /* @__PURE__ */ BigInt(o)) - v);
21
+ re.push(s);
22
+ }
23
+ const [De, Ke] = /* @__PURE__ */ je(re, !0), J = (e, t, n) => n > 32 ? ke(e, t, n) : Ae(e, t, n), Q = (e, t, n) => n > 32 ? Ne(e, t, n) : He(e, t, n);
24
+ function Xe(e, t = 24) {
25
+ const n = new Uint32Array(10);
26
+ for (let i = 24 - t; i < 24; i++) {
27
+ for (let r = 0; r < 10; r++)
28
+ n[r] = e[r] ^ e[r + 10] ^ e[r + 20] ^ e[r + 30] ^ e[r + 40];
29
+ for (let r = 0; r < 10; r += 2) {
30
+ const a = (r + 8) % 10, l = (r + 2) % 10, f = n[l], d = n[l + 1], b = J(f, d, 1) ^ n[a], p = Q(f, d, 1) ^ n[a + 1];
31
+ for (let h = 0; h < 50; h += 10)
32
+ e[r + h] ^= b, e[r + h + 1] ^= p;
33
+ }
34
+ let s = e[2], o = e[3];
35
+ for (let r = 0; r < 24; r++) {
36
+ const a = ie[r], l = J(s, o, a), f = Q(s, o, a), d = se[r];
37
+ s = e[d], o = e[d + 1], e[d] = l, e[d + 1] = f;
38
+ }
39
+ for (let r = 0; r < 50; r += 10) {
40
+ for (let a = 0; a < 10; a++)
41
+ n[a] = e[r + a];
42
+ for (let a = 0; a < 10; a++)
43
+ e[r + a] ^= ~n[(a + 2) % 10] & n[(a + 4) % 10];
44
+ }
45
+ e[0] ^= De[i], e[1] ^= Ke[i];
46
+ }
47
+ n.fill(0);
48
+ }
49
+ class H extends Fe {
50
+ // NOTE: we accept arguments in bytes instead of bits here.
51
+ constructor(t, n, i, s = !1, o = 24) {
52
+ if (super(), this.blockLen = t, this.suffix = n, this.outputLen = i, this.enableXOF = s, this.rounds = o, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, X(i), 0 >= this.blockLen || this.blockLen >= 200)
53
+ throw new Error("Sha3 supports only keccak-f1600 function");
54
+ this.state = new Uint8Array(200), this.state32 = Ge(this.state);
55
+ }
56
+ keccak() {
57
+ Xe(this.state32, this.rounds), this.posOut = 0, this.pos = 0;
58
+ }
59
+ update(t) {
60
+ Y(this);
61
+ const { blockLen: n, state: i } = this;
62
+ t = Le(t);
63
+ const s = t.length;
64
+ for (let o = 0; o < s; ) {
65
+ const r = Math.min(n - this.pos, s - o);
66
+ for (let a = 0; a < r; a++)
67
+ i[this.pos++] ^= t[o++];
68
+ this.pos === n && this.keccak();
69
+ }
70
+ return this;
71
+ }
72
+ finish() {
73
+ if (this.finished)
74
+ return;
75
+ this.finished = !0;
76
+ const { state: t, suffix: n, pos: i, blockLen: s } = this;
77
+ t[i] ^= n, n & 128 && i === s - 1 && this.keccak(), t[s - 1] ^= 128, this.keccak();
78
+ }
79
+ writeInto(t) {
80
+ Y(this, !1), $e(t), this.finish();
81
+ const n = this.state, { blockLen: i } = this;
82
+ for (let s = 0, o = t.length; s < o; ) {
83
+ this.posOut >= i && this.keccak();
84
+ const r = Math.min(i - this.posOut, o - s);
85
+ t.set(n.subarray(this.posOut, this.posOut + r), s), this.posOut += r, s += r;
86
+ }
87
+ return t;
88
+ }
89
+ xofInto(t) {
90
+ if (!this.enableXOF)
91
+ throw new Error("XOF is not possible for this instance");
92
+ return this.writeInto(t);
93
+ }
94
+ xof(t) {
95
+ return X(t), this.xofInto(new Uint8Array(t));
96
+ }
97
+ digestInto(t) {
98
+ if (Ue(t, this), this.finished)
99
+ throw new Error("digest() was already called");
100
+ return this.writeInto(t), this.destroy(), t;
101
+ }
102
+ digest() {
103
+ return this.digestInto(new Uint8Array(this.outputLen));
104
+ }
105
+ destroy() {
106
+ this.destroyed = !0, this.state.fill(0);
107
+ }
108
+ _cloneInto(t) {
109
+ const { blockLen: n, suffix: i, outputLen: s, rounds: o, enableXOF: r } = this;
110
+ return t || (t = new H(n, i, s, r, o)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = o, t.suffix = i, t.outputLen = s, t.enableXOF = r, t.destroyed = this.destroyed, t;
111
+ }
112
+ }
113
+ const Ye = (e, t, n) => Oe(() => new H(t, e, n)), We = /* @__PURE__ */ Ye(1, 136, 256 / 8);
114
+ function Je(e, t) {
115
+ const n = t || "hex", i = We(A(e, { strict: !1 }) ? te(e) : e);
116
+ return n === "bytes" ? i : c(i);
117
+ }
118
+ class G extends u {
119
+ constructor({ address: t }) {
120
+ super(`Address "${t}" is invalid.`, {
121
+ metaMessages: [
122
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
123
+ "- Address must match its checksum counterpart."
124
+ ]
125
+ }), Object.defineProperty(this, "name", {
126
+ enumerable: !0,
127
+ configurable: !0,
128
+ writable: !0,
129
+ value: "InvalidAddressError"
130
+ });
131
+ }
132
+ }
133
+ class oe extends Map {
134
+ constructor(t) {
135
+ super(), Object.defineProperty(this, "maxSize", {
136
+ enumerable: !0,
137
+ configurable: !0,
138
+ writable: !0,
139
+ value: void 0
140
+ }), this.maxSize = t;
141
+ }
142
+ set(t, n) {
143
+ return super.set(t, n), this.maxSize && this.size > this.maxSize && this.delete(this.keys().next().value), this;
144
+ }
145
+ }
146
+ const C = /* @__PURE__ */ new oe(8192);
147
+ function Qe(e, t) {
148
+ if (C.has(`${e}.${t}`))
149
+ return C.get(`${e}.${t}`);
150
+ const n = e.substring(2).toLowerCase(), i = Je(Te(n), "bytes"), s = n.split("");
151
+ for (let r = 0; r < 40; r += 2)
152
+ i[r >> 1] >> 4 >= 8 && s[r] && (s[r] = s[r].toUpperCase()), (i[r >> 1] & 15) >= 8 && s[r + 1] && (s[r + 1] = s[r + 1].toUpperCase());
153
+ const o = `0x${s.join("")}`;
154
+ return C.set(`${e}.${t}`, o), o;
155
+ }
156
+ const Ze = /^0x[a-fA-F0-9]{40}$/, j = /* @__PURE__ */ new oe(8192);
157
+ function L(e, t) {
158
+ const { strict: n = !0 } = t ?? {};
159
+ if (j.has(e))
160
+ return j.get(e);
161
+ const i = Ze.test(e) ? e.toLowerCase() === e ? !0 : n ? Qe(e) === e : !0 : !1;
162
+ return j.set(e, i), i;
163
+ }
164
+ function Rt(e) {
165
+ return typeof e[0] == "string" ? $(e) : qe(e);
166
+ }
167
+ function qe(e) {
168
+ let t = 0;
169
+ for (const s of e)
170
+ t += s.length;
171
+ const n = new Uint8Array(t);
172
+ let i = 0;
173
+ for (const s of e)
174
+ n.set(s, i), i += s.length;
175
+ return n;
176
+ }
177
+ function $(e) {
178
+ return `0x${e.reduce((t, n) => t + n.replace("0x", ""), "")}`;
179
+ }
180
+ function et(e, t, n, { strict: i } = {}) {
181
+ return A(e, { strict: !1 }) ? nt(e, t, n, {
182
+ strict: i
183
+ }) : tt(e, t, n, {
184
+ strict: i
185
+ });
186
+ }
187
+ function ae(e, t) {
188
+ if (typeof t == "number" && t > 0 && t > x(e) - 1)
189
+ throw new ne({
190
+ offset: t,
191
+ position: "start",
192
+ size: x(e)
193
+ });
194
+ }
195
+ function ue(e, t, n) {
196
+ if (typeof t == "number" && typeof n == "number" && x(e) !== n - t)
197
+ throw new ne({
198
+ offset: n,
199
+ position: "end",
200
+ size: x(e)
201
+ });
202
+ }
203
+ function tt(e, t, n, { strict: i } = {}) {
204
+ ae(e, t);
205
+ const s = e.slice(t, n);
206
+ return i && ue(s, t, n), s;
207
+ }
208
+ function nt(e, t, n, { strict: i } = {}) {
209
+ ae(e, t);
210
+ const s = `0x${e.replace("0x", "").slice((t ?? 0) * 2, (n ?? e.length) * 2)}`;
211
+ return i && ue(s, t, n), s;
212
+ }
213
+ class Z extends u {
214
+ constructor({ offset: t }) {
215
+ super(`Offset \`${t}\` cannot be negative.`), Object.defineProperty(this, "name", {
216
+ enumerable: !0,
217
+ configurable: !0,
218
+ writable: !0,
219
+ value: "NegativeOffsetError"
220
+ });
221
+ }
222
+ }
223
+ class st extends u {
224
+ constructor({ length: t, position: n }) {
225
+ super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`), Object.defineProperty(this, "name", {
226
+ enumerable: !0,
227
+ configurable: !0,
228
+ writable: !0,
229
+ value: "PositionOutOfBoundsError"
230
+ });
231
+ }
232
+ }
233
+ class it extends u {
234
+ constructor({ count: t, limit: n }) {
235
+ super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`), Object.defineProperty(this, "name", {
236
+ enumerable: !0,
237
+ configurable: !0,
238
+ writable: !0,
239
+ value: "RecursiveReadLimitExceededError"
240
+ });
241
+ }
242
+ }
243
+ const rt = {
244
+ bytes: new Uint8Array(),
245
+ dataView: new DataView(new ArrayBuffer(0)),
246
+ position: 0,
247
+ positionReadCount: /* @__PURE__ */ new Map(),
248
+ recursiveReadCount: 0,
249
+ recursiveReadLimit: Number.POSITIVE_INFINITY,
250
+ assertReadLimit() {
251
+ if (this.recursiveReadCount >= this.recursiveReadLimit)
252
+ throw new it({
253
+ count: this.recursiveReadCount + 1,
254
+ limit: this.recursiveReadLimit
255
+ });
256
+ },
257
+ assertPosition(e) {
258
+ if (e < 0 || e > this.bytes.length - 1)
259
+ throw new st({
260
+ length: this.bytes.length,
261
+ position: e
262
+ });
263
+ },
264
+ decrementPosition(e) {
265
+ if (e < 0)
266
+ throw new Z({ offset: e });
267
+ const t = this.position - e;
268
+ this.assertPosition(t), this.position = t;
269
+ },
270
+ getReadCount(e) {
271
+ return this.positionReadCount.get(e || this.position) || 0;
272
+ },
273
+ incrementPosition(e) {
274
+ if (e < 0)
275
+ throw new Z({ offset: e });
276
+ const t = this.position + e;
277
+ this.assertPosition(t), this.position = t;
278
+ },
279
+ inspectByte(e) {
280
+ const t = e ?? this.position;
281
+ return this.assertPosition(t), this.bytes[t];
282
+ },
283
+ inspectBytes(e, t) {
284
+ const n = t ?? this.position;
285
+ return this.assertPosition(n + e - 1), this.bytes.subarray(n, n + e);
286
+ },
287
+ inspectUint8(e) {
288
+ const t = e ?? this.position;
289
+ return this.assertPosition(t), this.bytes[t];
290
+ },
291
+ inspectUint16(e) {
292
+ const t = e ?? this.position;
293
+ return this.assertPosition(t + 1), this.dataView.getUint16(t);
294
+ },
295
+ inspectUint24(e) {
296
+ const t = e ?? this.position;
297
+ return this.assertPosition(t + 2), (this.dataView.getUint16(t) << 8) + this.dataView.getUint8(t + 2);
298
+ },
299
+ inspectUint32(e) {
300
+ const t = e ?? this.position;
301
+ return this.assertPosition(t + 3), this.dataView.getUint32(t);
302
+ },
303
+ pushByte(e) {
304
+ this.assertPosition(this.position), this.bytes[this.position] = e, this.position++;
305
+ },
306
+ pushBytes(e) {
307
+ this.assertPosition(this.position + e.length - 1), this.bytes.set(e, this.position), this.position += e.length;
308
+ },
309
+ pushUint8(e) {
310
+ this.assertPosition(this.position), this.bytes[this.position] = e, this.position++;
311
+ },
312
+ pushUint16(e) {
313
+ this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, e), this.position += 2;
314
+ },
315
+ pushUint24(e) {
316
+ this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, e >> 8), this.dataView.setUint8(this.position + 2, e & 255), this.position += 3;
317
+ },
318
+ pushUint32(e) {
319
+ this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, e), this.position += 4;
320
+ },
321
+ readByte() {
322
+ this.assertReadLimit(), this._touch();
323
+ const e = this.inspectByte();
324
+ return this.position++, e;
325
+ },
326
+ readBytes(e, t) {
327
+ this.assertReadLimit(), this._touch();
328
+ const n = this.inspectBytes(e);
329
+ return this.position += t ?? e, n;
330
+ },
331
+ readUint8() {
332
+ this.assertReadLimit(), this._touch();
333
+ const e = this.inspectUint8();
334
+ return this.position += 1, e;
335
+ },
336
+ readUint16() {
337
+ this.assertReadLimit(), this._touch();
338
+ const e = this.inspectUint16();
339
+ return this.position += 2, e;
340
+ },
341
+ readUint24() {
342
+ this.assertReadLimit(), this._touch();
343
+ const e = this.inspectUint24();
344
+ return this.position += 3, e;
345
+ },
346
+ readUint32() {
347
+ this.assertReadLimit(), this._touch();
348
+ const e = this.inspectUint32();
349
+ return this.position += 4, e;
350
+ },
351
+ get remaining() {
352
+ return this.bytes.length - this.position;
353
+ },
354
+ setPosition(e) {
355
+ const t = this.position;
356
+ return this.assertPosition(e), this.position = e, () => this.position = t;
357
+ },
358
+ _touch() {
359
+ if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
360
+ return;
361
+ const e = this.getReadCount();
362
+ this.positionReadCount.set(this.position, e + 1), e > 0 && this.recursiveReadCount++;
363
+ }
364
+ };
365
+ function ce(e, { recursiveReadLimit: t = 8192 } = {}) {
366
+ const n = Object.create(rt);
367
+ return n.bytes = e, n.dataView = new DataView(e.buffer, e.byteOffset, e.byteLength), n.positionReadCount = /* @__PURE__ */ new Map(), n.recursiveReadLimit = t, n;
368
+ }
369
+ function F(e, t = "wei") {
370
+ return Be(e, Ee[t]);
371
+ }
372
+ function ot(e) {
373
+ const t = Object.entries(e).map(([i, s]) => s === void 0 || s === !1 ? null : [i, s]).filter(Boolean), n = t.reduce((i, [s]) => Math.max(i, s.length), 0);
374
+ return t.map(([i, s]) => ` ${`${i}:`.padEnd(n + 1)} ${s}`).join(`
375
+ `);
376
+ }
377
+ class Dt extends u {
378
+ constructor() {
379
+ super([
380
+ "Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.",
381
+ "Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."
382
+ ].join(`
383
+ `)), Object.defineProperty(this, "name", {
384
+ enumerable: !0,
385
+ configurable: !0,
386
+ writable: !0,
387
+ value: "FeeConflictError"
388
+ });
389
+ }
390
+ }
391
+ class at extends u {
392
+ constructor({ v: t }) {
393
+ super(`Invalid \`v\` value "${t}". Expected 27 or 28.`), Object.defineProperty(this, "name", {
394
+ enumerable: !0,
395
+ configurable: !0,
396
+ writable: !0,
397
+ value: "InvalidLegacyVError"
398
+ });
399
+ }
400
+ }
401
+ class ut extends u {
402
+ constructor({ transaction: t }) {
403
+ super("Cannot infer a transaction type from provided transaction.", {
404
+ metaMessages: [
405
+ "Provided Transaction:",
406
+ "{",
407
+ ot(t),
408
+ "}",
409
+ "",
410
+ "To infer the type, either provide:",
411
+ "- a `type` to the Transaction, or",
412
+ "- an EIP-1559 Transaction with `maxFeePerGas`, or",
413
+ "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
414
+ "- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
415
+ "- a Legacy Transaction with `gasPrice`"
416
+ ]
417
+ }), Object.defineProperty(this, "name", {
418
+ enumerable: !0,
419
+ configurable: !0,
420
+ writable: !0,
421
+ value: "InvalidSerializableTransactionError"
422
+ });
423
+ }
424
+ }
425
+ class ct extends u {
426
+ constructor({ storageKey: t }) {
427
+ super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length - 2) / 2)} bytes.`), Object.defineProperty(this, "name", {
428
+ enumerable: !0,
429
+ configurable: !0,
430
+ writable: !0,
431
+ value: "InvalidStorageKeySizeError"
432
+ });
433
+ }
434
+ }
435
+ class Kt extends u {
436
+ constructor({ blockHash: t, blockNumber: n, blockTag: i, hash: s, index: o }) {
437
+ let r = "Transaction";
438
+ i && o !== void 0 && (r = `Transaction at block time "${i}" at index "${o}"`), t && o !== void 0 && (r = `Transaction at block hash "${t}" at index "${o}"`), n && o !== void 0 && (r = `Transaction at block number "${n}" at index "${o}"`), s && (r = `Transaction with hash "${s}"`), super(`${r} could not be found.`), Object.defineProperty(this, "name", {
439
+ enumerable: !0,
440
+ configurable: !0,
441
+ writable: !0,
442
+ value: "TransactionNotFoundError"
443
+ });
444
+ }
445
+ }
446
+ class Xt extends u {
447
+ constructor({ hash: t }) {
448
+ super(`Transaction receipt with hash "${t}" could not be found. The Transaction may not be processed on a block yet.`), Object.defineProperty(this, "name", {
449
+ enumerable: !0,
450
+ configurable: !0,
451
+ writable: !0,
452
+ value: "TransactionReceiptNotFoundError"
453
+ });
454
+ }
455
+ }
456
+ class Yt extends u {
457
+ constructor({ hash: t }) {
458
+ super(`Timed out while waiting for transaction with hash "${t}" to be confirmed.`), Object.defineProperty(this, "name", {
459
+ enumerable: !0,
460
+ configurable: !0,
461
+ writable: !0,
462
+ value: "WaitForTransactionReceiptTimeoutError"
463
+ });
464
+ }
465
+ }
466
+ class le extends u {
467
+ constructor({ cause: t, message: n } = {}) {
468
+ var s;
469
+ const i = (s = n == null ? void 0 : n.replace("execution reverted: ", "")) == null ? void 0 : s.replace("execution reverted", "");
470
+ super(`Execution reverted ${i ? `with reason: ${i}` : "for an unknown reason"}.`, {
471
+ cause: t
472
+ }), Object.defineProperty(this, "name", {
473
+ enumerable: !0,
474
+ configurable: !0,
475
+ writable: !0,
476
+ value: "ExecutionRevertedError"
477
+ });
478
+ }
479
+ }
480
+ Object.defineProperty(le, "code", {
481
+ enumerable: !0,
482
+ configurable: !0,
483
+ writable: !0,
484
+ value: 3
485
+ });
486
+ Object.defineProperty(le, "nodeMessage", {
487
+ enumerable: !0,
488
+ configurable: !0,
489
+ writable: !0,
490
+ value: /execution reverted/
491
+ });
492
+ class U extends u {
493
+ constructor({ cause: t, maxFeePerGas: n } = {}) {
494
+ super(`The fee cap (\`maxFeePerGas\`${n ? ` = ${F(n)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
495
+ cause: t
496
+ }), Object.defineProperty(this, "name", {
497
+ enumerable: !0,
498
+ configurable: !0,
499
+ writable: !0,
500
+ value: "FeeCapTooHigh"
501
+ });
502
+ }
503
+ }
504
+ Object.defineProperty(U, "nodeMessage", {
505
+ enumerable: !0,
506
+ configurable: !0,
507
+ writable: !0,
508
+ value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
509
+ });
510
+ class lt extends u {
511
+ constructor({ cause: t, maxFeePerGas: n } = {}) {
512
+ super(`The fee cap (\`maxFeePerGas\`${n ? ` = ${F(n)}` : ""} gwei) cannot be lower than the block base fee.`, {
513
+ cause: t
514
+ }), Object.defineProperty(this, "name", {
515
+ enumerable: !0,
516
+ configurable: !0,
517
+ writable: !0,
518
+ value: "FeeCapTooLow"
519
+ });
520
+ }
521
+ }
522
+ Object.defineProperty(lt, "nodeMessage", {
523
+ enumerable: !0,
524
+ configurable: !0,
525
+ writable: !0,
526
+ value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/
527
+ });
528
+ class ft extends u {
529
+ constructor({ cause: t, nonce: n } = {}) {
530
+ super(`Nonce provided for the transaction ${n ? `(${n}) ` : ""}is higher than the next one expected.`, { cause: t }), Object.defineProperty(this, "name", {
531
+ enumerable: !0,
532
+ configurable: !0,
533
+ writable: !0,
534
+ value: "NonceTooHighError"
535
+ });
536
+ }
537
+ }
538
+ Object.defineProperty(ft, "nodeMessage", {
539
+ enumerable: !0,
540
+ configurable: !0,
541
+ writable: !0,
542
+ value: /nonce too high/
543
+ });
544
+ class dt extends u {
545
+ constructor({ cause: t, nonce: n } = {}) {
546
+ super([
547
+ `Nonce provided for the transaction ${n ? `(${n}) ` : ""}is lower than the current nonce of the account.`,
548
+ "Try increasing the nonce or find the latest nonce with `getTransactionCount`."
549
+ ].join(`
550
+ `), { cause: t }), Object.defineProperty(this, "name", {
551
+ enumerable: !0,
552
+ configurable: !0,
553
+ writable: !0,
554
+ value: "NonceTooLowError"
555
+ });
556
+ }
557
+ }
558
+ Object.defineProperty(dt, "nodeMessage", {
559
+ enumerable: !0,
560
+ configurable: !0,
561
+ writable: !0,
562
+ value: /nonce too low|transaction already imported|already known/
563
+ });
564
+ class ht extends u {
565
+ constructor({ cause: t, nonce: n } = {}) {
566
+ super(`Nonce provided for the transaction ${n ? `(${n}) ` : ""}exceeds the maximum allowed nonce.`, { cause: t }), Object.defineProperty(this, "name", {
567
+ enumerable: !0,
568
+ configurable: !0,
569
+ writable: !0,
570
+ value: "NonceMaxValueError"
571
+ });
572
+ }
573
+ }
574
+ Object.defineProperty(ht, "nodeMessage", {
575
+ enumerable: !0,
576
+ configurable: !0,
577
+ writable: !0,
578
+ value: /nonce has max value/
579
+ });
580
+ class bt extends u {
581
+ constructor({ cause: t } = {}) {
582
+ super([
583
+ "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."
584
+ ].join(`
585
+ `), {
586
+ cause: t,
587
+ metaMessages: [
588
+ "This error could arise when the account does not have enough funds to:",
589
+ " - pay for the total gas fee,",
590
+ " - pay for the value to send.",
591
+ " ",
592
+ "The cost of the transaction is calculated as `gas * gas fee + value`, where:",
593
+ " - `gas` is the amount of gas needed for transaction to execute,",
594
+ " - `gas fee` is the gas fee,",
595
+ " - `value` is the amount of ether to send to the recipient."
596
+ ]
597
+ }), Object.defineProperty(this, "name", {
598
+ enumerable: !0,
599
+ configurable: !0,
600
+ writable: !0,
601
+ value: "InsufficientFundsError"
602
+ });
603
+ }
604
+ }
605
+ Object.defineProperty(bt, "nodeMessage", {
606
+ enumerable: !0,
607
+ configurable: !0,
608
+ writable: !0,
609
+ value: /insufficient funds/
610
+ });
611
+ class pt extends u {
612
+ constructor({ cause: t, gas: n } = {}) {
613
+ super(`The amount of gas ${n ? `(${n}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, {
614
+ cause: t
615
+ }), Object.defineProperty(this, "name", {
616
+ enumerable: !0,
617
+ configurable: !0,
618
+ writable: !0,
619
+ value: "IntrinsicGasTooHighError"
620
+ });
621
+ }
622
+ }
623
+ Object.defineProperty(pt, "nodeMessage", {
624
+ enumerable: !0,
625
+ configurable: !0,
626
+ writable: !0,
627
+ value: /intrinsic gas too high|gas limit reached/
628
+ });
629
+ class mt extends u {
630
+ constructor({ cause: t, gas: n } = {}) {
631
+ super(`The amount of gas ${n ? `(${n}) ` : ""}provided for the transaction is too low.`, {
632
+ cause: t
633
+ }), Object.defineProperty(this, "name", {
634
+ enumerable: !0,
635
+ configurable: !0,
636
+ writable: !0,
637
+ value: "IntrinsicGasTooLowError"
638
+ });
639
+ }
640
+ }
641
+ Object.defineProperty(mt, "nodeMessage", {
642
+ enumerable: !0,
643
+ configurable: !0,
644
+ writable: !0,
645
+ value: /intrinsic gas too low/
646
+ });
647
+ class yt extends u {
648
+ constructor({ cause: t }) {
649
+ super("The transaction type is not supported for this chain.", {
650
+ cause: t
651
+ }), Object.defineProperty(this, "name", {
652
+ enumerable: !0,
653
+ configurable: !0,
654
+ writable: !0,
655
+ value: "TransactionTypeNotSupportedError"
656
+ });
657
+ }
658
+ }
659
+ Object.defineProperty(yt, "nodeMessage", {
660
+ enumerable: !0,
661
+ configurable: !0,
662
+ writable: !0,
663
+ value: /transaction type not valid/
664
+ });
665
+ class fe extends u {
666
+ constructor({ cause: t, maxPriorityFeePerGas: n, maxFeePerGas: i } = {}) {
667
+ super([
668
+ `The provided tip (\`maxPriorityFeePerGas\`${n ? ` = ${F(n)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${i ? ` = ${F(i)} gwei` : ""}).`
669
+ ].join(`
670
+ `), {
671
+ cause: t
672
+ }), Object.defineProperty(this, "name", {
673
+ enumerable: !0,
674
+ configurable: !0,
675
+ writable: !0,
676
+ value: "TipAboveFeeCapError"
677
+ });
678
+ }
679
+ }
680
+ Object.defineProperty(fe, "nodeMessage", {
681
+ enumerable: !0,
682
+ configurable: !0,
683
+ writable: !0,
684
+ value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
685
+ });
686
+ class Wt extends u {
687
+ constructor({ cause: t }) {
688
+ super(`An error occurred while executing: ${t == null ? void 0 : t.shortMessage}`, {
689
+ cause: t
690
+ }), Object.defineProperty(this, "name", {
691
+ enumerable: !0,
692
+ configurable: !0,
693
+ writable: !0,
694
+ value: "UnknownNodeError"
695
+ });
696
+ }
697
+ }
698
+ function z(e, t) {
699
+ return ({ exclude: n, format: i }) => ({
700
+ exclude: n,
701
+ format: (s) => {
702
+ const o = t(s);
703
+ if (n)
704
+ for (const r of n)
705
+ delete o[r];
706
+ return {
707
+ ...o,
708
+ ...i(s)
709
+ };
710
+ },
711
+ type: e
712
+ });
713
+ }
714
+ const gt = {
715
+ legacy: "0x0",
716
+ eip2930: "0x1",
717
+ eip1559: "0x2",
718
+ eip4844: "0x3"
719
+ };
720
+ function xt(e) {
721
+ const t = {};
722
+ return typeof e.accessList < "u" && (t.accessList = e.accessList), typeof e.blobVersionedHashes < "u" && (t.blobVersionedHashes = e.blobVersionedHashes), typeof e.blobs < "u" && (typeof e.blobs[0] != "string" ? t.blobs = e.blobs.map((n) => g(n)) : t.blobs = e.blobs), typeof e.data < "u" && (t.data = e.data), typeof e.from < "u" && (t.from = e.from), typeof e.gas < "u" && (t.gas = y(e.gas)), typeof e.gasPrice < "u" && (t.gasPrice = y(e.gasPrice)), typeof e.maxFeePerBlobGas < "u" && (t.maxFeePerBlobGas = y(e.maxFeePerBlobGas)), typeof e.maxFeePerGas < "u" && (t.maxFeePerGas = y(e.maxFeePerGas)), typeof e.maxPriorityFeePerGas < "u" && (t.maxPriorityFeePerGas = y(e.maxPriorityFeePerGas)), typeof e.nonce < "u" && (t.nonce = y(e.nonce)), typeof e.to < "u" && (t.to = e.to), typeof e.type < "u" && (t.type = gt[e.type]), typeof e.value < "u" && (t.value = y(e.value)), t;
723
+ }
724
+ const Jt = /* @__PURE__ */ z("transactionRequest", xt), de = {
725
+ "0x0": "legacy",
726
+ "0x1": "eip2930",
727
+ "0x2": "eip1559",
728
+ "0x3": "eip4844"
729
+ };
730
+ function he(e) {
731
+ const t = {
732
+ ...e,
733
+ blockHash: e.blockHash ? e.blockHash : null,
734
+ blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
735
+ chainId: e.chainId ? O(e.chainId) : void 0,
736
+ gas: e.gas ? BigInt(e.gas) : void 0,
737
+ gasPrice: e.gasPrice ? BigInt(e.gasPrice) : void 0,
738
+ maxFeePerBlobGas: e.maxFeePerBlobGas ? BigInt(e.maxFeePerBlobGas) : void 0,
739
+ maxFeePerGas: e.maxFeePerGas ? BigInt(e.maxFeePerGas) : void 0,
740
+ maxPriorityFeePerGas: e.maxPriorityFeePerGas ? BigInt(e.maxPriorityFeePerGas) : void 0,
741
+ nonce: e.nonce ? O(e.nonce) : void 0,
742
+ to: e.to ? e.to : null,
743
+ transactionIndex: e.transactionIndex ? Number(e.transactionIndex) : null,
744
+ type: e.type ? de[e.type] : void 0,
745
+ typeHex: e.type ? e.type : void 0,
746
+ value: e.value ? BigInt(e.value) : void 0,
747
+ v: e.v ? BigInt(e.v) : void 0
748
+ };
749
+ return t.yParity = (() => {
750
+ if (e.yParity)
751
+ return Number(e.yParity);
752
+ if (typeof t.v == "bigint") {
753
+ if (t.v === 0n || t.v === 27n)
754
+ return 0;
755
+ if (t.v === 1n || t.v === 28n)
756
+ return 1;
757
+ if (t.v >= 35n)
758
+ return t.v % 2n === 0n ? 1 : 0;
759
+ }
760
+ })(), t.type === "legacy" && (delete t.accessList, delete t.maxFeePerBlobGas, delete t.maxFeePerGas, delete t.maxPriorityFeePerGas, delete t.yParity), t.type === "eip2930" && (delete t.maxFeePerBlobGas, delete t.maxFeePerGas, delete t.maxPriorityFeePerGas), t.type === "eip1559" && delete t.maxFeePerBlobGas, t;
761
+ }
762
+ const Qt = /* @__PURE__ */ z("transaction", he);
763
+ function wt(e) {
764
+ var n;
765
+ const t = (n = e.transactions) == null ? void 0 : n.map((i) => typeof i == "string" ? i : he(i));
766
+ return {
767
+ ...e,
768
+ baseFeePerGas: e.baseFeePerGas ? BigInt(e.baseFeePerGas) : null,
769
+ blobGasUsed: e.blobGasUsed ? BigInt(e.blobGasUsed) : void 0,
770
+ difficulty: e.difficulty ? BigInt(e.difficulty) : void 0,
771
+ excessBlobGas: e.excessBlobGas ? BigInt(e.excessBlobGas) : void 0,
772
+ gasLimit: e.gasLimit ? BigInt(e.gasLimit) : void 0,
773
+ gasUsed: e.gasUsed ? BigInt(e.gasUsed) : void 0,
774
+ hash: e.hash ? e.hash : null,
775
+ logsBloom: e.logsBloom ? e.logsBloom : null,
776
+ nonce: e.nonce ? e.nonce : null,
777
+ number: e.number ? BigInt(e.number) : null,
778
+ size: e.size ? BigInt(e.size) : void 0,
779
+ timestamp: e.timestamp ? BigInt(e.timestamp) : void 0,
780
+ transactions: t,
781
+ totalDifficulty: e.totalDifficulty ? BigInt(e.totalDifficulty) : null
782
+ };
783
+ }
784
+ const Zt = /* @__PURE__ */ z("block", wt);
785
+ function be(e) {
786
+ const { kzg: t } = e, n = e.to ?? (typeof e.blobs[0] == "string" ? "hex" : "bytes"), i = typeof e.blobs[0] == "string" ? e.blobs.map((o) => I(o)) : e.blobs, s = [];
787
+ for (const o of i)
788
+ s.push(Uint8Array.from(t.blobToKzgCommitment(o)));
789
+ return n === "bytes" ? s : s.map((o) => g(o));
790
+ }
791
+ function pe(e) {
792
+ const { kzg: t } = e, n = e.to ?? (typeof e.blobs[0] == "string" ? "hex" : "bytes"), i = typeof e.blobs[0] == "string" ? e.blobs.map((r) => I(r)) : e.blobs, s = typeof e.commitments[0] == "string" ? e.commitments.map((r) => I(r)) : e.commitments, o = [];
793
+ for (let r = 0; r < i.length; r++) {
794
+ const a = i[r], l = s[r];
795
+ o.push(Uint8Array.from(t.computeBlobKzgProof(a, l)));
796
+ }
797
+ return n === "bytes" ? o : o.map((r) => g(r));
798
+ }
799
+ function Pt(e, t) {
800
+ const n = t || "hex", i = ze(A(e, { strict: !1 }) ? te(e) : e);
801
+ return n === "bytes" ? i : c(i);
802
+ }
803
+ function vt(e) {
804
+ const { commitment: t, version: n = 1 } = e, i = e.to ?? (typeof t == "string" ? "hex" : "bytes"), s = Pt(t, "bytes");
805
+ return s.set([n], 0), i === "bytes" ? s : g(s);
806
+ }
807
+ function It(e) {
808
+ const { commitments: t, version: n } = e, i = e.to ?? (typeof t[0] == "string" ? "hex" : "bytes"), s = [];
809
+ for (const o of t)
810
+ s.push(vt({
811
+ commitment: o,
812
+ to: i,
813
+ version: n
814
+ }));
815
+ return s;
816
+ }
817
+ const q = 6, me = 32, k = 4096, ye = me * k, ee = ye * q - // terminator byte (0x80).
818
+ 1 - // zero byte (0x00) appended to each field element.
819
+ 1 * k * q, ge = 1;
820
+ class Tt extends u {
821
+ constructor({ maxSize: t, size: n }) {
822
+ super("Blob size is too large.", {
823
+ metaMessages: [`Max: ${t} bytes`, `Given: ${n} bytes`]
824
+ }), Object.defineProperty(this, "name", {
825
+ enumerable: !0,
826
+ configurable: !0,
827
+ writable: !0,
828
+ value: "BlobSizeTooLargeError"
829
+ });
830
+ }
831
+ }
832
+ class xe extends u {
833
+ constructor() {
834
+ super("Blob data must not be empty."), Object.defineProperty(this, "name", {
835
+ enumerable: !0,
836
+ configurable: !0,
837
+ writable: !0,
838
+ value: "EmptyBlobError"
839
+ });
840
+ }
841
+ }
842
+ class Bt extends u {
843
+ constructor({ hash: t, size: n }) {
844
+ super(`Versioned hash "${t}" size is invalid.`, {
845
+ metaMessages: ["Expected: 32", `Received: ${n}`]
846
+ }), Object.defineProperty(this, "name", {
847
+ enumerable: !0,
848
+ configurable: !0,
849
+ writable: !0,
850
+ value: "InvalidVersionedHashSizeError"
851
+ });
852
+ }
853
+ }
854
+ class Et extends u {
855
+ constructor({ hash: t, version: n }) {
856
+ super(`Versioned hash "${t}" version is invalid.`, {
857
+ metaMessages: [
858
+ `Expected: ${ge}`,
859
+ `Received: ${n}`
860
+ ]
861
+ }), Object.defineProperty(this, "name", {
862
+ enumerable: !0,
863
+ configurable: !0,
864
+ writable: !0,
865
+ value: "InvalidVersionedHashVersionError"
866
+ });
867
+ }
868
+ }
869
+ function Ot(e) {
870
+ const t = e.to ?? (typeof e.data == "string" ? "hex" : "bytes"), n = typeof e.data == "string" ? I(e.data) : e.data, i = x(n);
871
+ if (!i)
872
+ throw new xe();
873
+ if (i > ee)
874
+ throw new Tt({
875
+ maxSize: ee,
876
+ size: i
877
+ });
878
+ const s = [];
879
+ let o = !0, r = 0;
880
+ for (; o; ) {
881
+ const a = ce(new Uint8Array(ye));
882
+ let l = 0;
883
+ for (; l < k; ) {
884
+ const f = n.slice(r, r + (me - 1));
885
+ if (a.pushByte(0), a.pushBytes(f), f.length < 31) {
886
+ a.pushByte(128), o = !1;
887
+ break;
888
+ }
889
+ l++, r += 31;
890
+ }
891
+ s.push(a);
892
+ }
893
+ return t === "bytes" ? s.map((a) => a.bytes) : s.map((a) => g(a.bytes));
894
+ }
895
+ function Ft(e) {
896
+ const { data: t, kzg: n, to: i } = e, s = e.blobs ?? Ot({ data: t, to: i }), o = e.commitments ?? be({ blobs: s, kzg: n, to: i }), r = e.proofs ?? pe({ blobs: s, commitments: o, kzg: n, to: i }), a = [];
897
+ for (let l = 0; l < s.length; l++)
898
+ a.push({
899
+ blob: s[l],
900
+ commitment: o[l],
901
+ proof: r[l]
902
+ });
903
+ return a;
904
+ }
905
+ function Gt(e) {
906
+ if (e.type)
907
+ return e.type;
908
+ if (typeof e.blobs < "u" || typeof e.blobVersionedHashes < "u" || typeof e.maxFeePerBlobGas < "u" || typeof e.sidecars < "u")
909
+ return "eip4844";
910
+ if (typeof e.maxFeePerGas < "u" || typeof e.maxPriorityFeePerGas < "u")
911
+ return "eip1559";
912
+ if (typeof e.gasPrice < "u")
913
+ return typeof e.accessList < "u" ? "eip2930" : "legacy";
914
+ throw new ut({ transaction: e });
915
+ }
916
+ function Lt(e, { args: t, eventName: n } = {}) {
917
+ return {
918
+ ...e,
919
+ blockHash: e.blockHash ? e.blockHash : null,
920
+ blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
921
+ logIndex: e.logIndex ? Number(e.logIndex) : null,
922
+ transactionHash: e.transactionHash ? e.transactionHash : null,
923
+ transactionIndex: e.transactionIndex ? Number(e.transactionIndex) : null,
924
+ ...n ? { args: t, eventName: n } : {}
925
+ };
926
+ }
927
+ class qt extends u {
928
+ constructor({ blockNumber: t, chain: n, contract: i }) {
929
+ super(`Chain "${n.name}" does not support contract "${i.name}".`, {
930
+ metaMessages: [
931
+ "This could be due to any of the following:",
932
+ ...t && i.blockCreated && i.blockCreated > t ? [
933
+ `- The contract "${i.name}" was not deployed until block ${i.blockCreated} (current block ${t}).`
934
+ ] : [
935
+ `- The chain does not have the contract "${i.name}" configured.`
936
+ ]
937
+ ]
938
+ }), Object.defineProperty(this, "name", {
939
+ enumerable: !0,
940
+ configurable: !0,
941
+ writable: !0,
942
+ value: "ChainDoesNotSupportContract"
943
+ });
944
+ }
945
+ }
946
+ class en extends u {
947
+ constructor() {
948
+ super("No chain was provided to the Client."), Object.defineProperty(this, "name", {
949
+ enumerable: !0,
950
+ configurable: !0,
951
+ writable: !0,
952
+ value: "ClientChainNotConfiguredError"
953
+ });
954
+ }
955
+ }
956
+ class N extends u {
957
+ constructor({ chainId: t }) {
958
+ super(typeof t == "number" ? `Chain ID "${t}" is invalid.` : "Chain ID is invalid."), Object.defineProperty(this, "name", {
959
+ enumerable: !0,
960
+ configurable: !0,
961
+ writable: !0,
962
+ value: "InvalidChainIdError"
963
+ });
964
+ }
965
+ }
966
+ function tn(e) {
967
+ return {
968
+ formatters: void 0,
969
+ fees: void 0,
970
+ serializers: void 0,
971
+ ...e
972
+ };
973
+ }
974
+ function T(e, t = "hex") {
975
+ const n = we(e), i = ce(new Uint8Array(n.length));
976
+ return n.encode(i), t === "hex" ? g(i.bytes) : i.bytes;
977
+ }
978
+ function we(e) {
979
+ return Array.isArray(e) ? $t(e.map((t) => we(t))) : Ut(e);
980
+ }
981
+ function $t(e) {
982
+ const t = e.reduce((s, o) => s + o.length, 0), n = Pe(t);
983
+ return {
984
+ length: t <= 55 ? 1 + t : 1 + n + t,
985
+ encode(s) {
986
+ t <= 55 ? s.pushByte(192 + t) : (s.pushByte(247 + n), n === 1 ? s.pushUint8(t) : n === 2 ? s.pushUint16(t) : n === 3 ? s.pushUint24(t) : s.pushUint32(t));
987
+ for (const { encode: o } of e)
988
+ o(s);
989
+ }
990
+ };
991
+ }
992
+ function Ut(e) {
993
+ const t = typeof e == "string" ? I(e) : e, n = Pe(t.length);
994
+ return {
995
+ length: t.length === 1 && t[0] < 128 ? 1 : t.length <= 55 ? 1 + t.length : 1 + n + t.length,
996
+ encode(s) {
997
+ t.length === 1 && t[0] < 128 ? s.pushBytes(t) : t.length <= 55 ? (s.pushByte(128 + t.length), s.pushBytes(t)) : (s.pushByte(183 + n), n === 1 ? s.pushUint8(t.length) : n === 2 ? s.pushUint16(t.length) : n === 3 ? s.pushUint24(t.length) : s.pushUint32(t.length), s.pushBytes(t));
998
+ }
999
+ };
1000
+ }
1001
+ function Pe(e) {
1002
+ if (e < 2 ** 8)
1003
+ return 1;
1004
+ if (e < 2 ** 16)
1005
+ return 2;
1006
+ if (e < 2 ** 24)
1007
+ return 3;
1008
+ if (e < 2 ** 32)
1009
+ return 4;
1010
+ throw new u("Length is too large.");
1011
+ }
1012
+ const zt = {
1013
+ "0x0": "reverted",
1014
+ "0x1": "success"
1015
+ };
1016
+ function Ct(e) {
1017
+ const t = {
1018
+ ...e,
1019
+ blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
1020
+ contractAddress: e.contractAddress ? e.contractAddress : null,
1021
+ cumulativeGasUsed: e.cumulativeGasUsed ? BigInt(e.cumulativeGasUsed) : null,
1022
+ effectiveGasPrice: e.effectiveGasPrice ? BigInt(e.effectiveGasPrice) : null,
1023
+ gasUsed: e.gasUsed ? BigInt(e.gasUsed) : null,
1024
+ logs: e.logs ? e.logs.map((n) => Lt(n)) : null,
1025
+ to: e.to ? e.to : null,
1026
+ transactionIndex: e.transactionIndex ? O(e.transactionIndex) : null,
1027
+ status: e.status ? zt[e.status] : null,
1028
+ type: e.type ? de[e.type] || e.type : null
1029
+ };
1030
+ return e.blobGasPrice && (t.blobGasPrice = BigInt(e.blobGasPrice)), e.blobGasUsed && (t.blobGasUsed = BigInt(e.blobGasUsed)), t;
1031
+ }
1032
+ const nn = /* @__PURE__ */ z("transactionReceipt", Ct);
1033
+ function jt(e) {
1034
+ const { blobVersionedHashes: t } = e;
1035
+ if (t) {
1036
+ if (t.length === 0)
1037
+ throw new xe();
1038
+ for (const n of t) {
1039
+ const i = x(n), s = O(et(n, 0, 1));
1040
+ if (i !== 32)
1041
+ throw new Bt({ hash: n, size: i });
1042
+ if (s !== ge)
1043
+ throw new Et({
1044
+ hash: n,
1045
+ version: s
1046
+ });
1047
+ }
1048
+ }
1049
+ ve(e);
1050
+ }
1051
+ function ve(e) {
1052
+ const { chainId: t, maxPriorityFeePerGas: n, maxFeePerGas: i, to: s } = e;
1053
+ if (t <= 0)
1054
+ throw new N({ chainId: t });
1055
+ if (s && !L(s))
1056
+ throw new G({ address: s });
1057
+ if (i && i > 2n ** 256n - 1n)
1058
+ throw new U({ maxFeePerGas: i });
1059
+ if (n && i && n > i)
1060
+ throw new fe({ maxFeePerGas: i, maxPriorityFeePerGas: n });
1061
+ }
1062
+ function At(e) {
1063
+ const { chainId: t, maxPriorityFeePerGas: n, gasPrice: i, maxFeePerGas: s, to: o } = e;
1064
+ if (t <= 0)
1065
+ throw new N({ chainId: t });
1066
+ if (o && !L(o))
1067
+ throw new G({ address: o });
1068
+ if (n || s)
1069
+ throw new u("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");
1070
+ if (i && i > 2n ** 256n - 1n)
1071
+ throw new U({ maxFeePerGas: i });
1072
+ }
1073
+ function Ht(e) {
1074
+ const { chainId: t, maxPriorityFeePerGas: n, gasPrice: i, maxFeePerGas: s, to: o, accessList: r } = e;
1075
+ if (o && !L(o))
1076
+ throw new G({ address: o });
1077
+ if (typeof t < "u" && t <= 0)
1078
+ throw new N({ chainId: t });
1079
+ if (n || s)
1080
+ throw new u("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");
1081
+ if (i && i > 2n ** 256n - 1n)
1082
+ throw new U({ maxFeePerGas: i });
1083
+ if (r)
1084
+ throw new u("`accessList` is not a valid Legacy Transaction attribute.");
1085
+ }
1086
+ function S(e) {
1087
+ if (!e || e.length === 0)
1088
+ return [];
1089
+ const t = [];
1090
+ for (let n = 0; n < e.length; n++) {
1091
+ const { address: i, storageKeys: s } = e[n];
1092
+ for (let o = 0; o < s.length; o++)
1093
+ if (s[o].length - 2 !== 64)
1094
+ throw new ct({ storageKey: s[o] });
1095
+ if (!L(i, { strict: !1 }))
1096
+ throw new G({ address: i });
1097
+ t.push([i, s]);
1098
+ }
1099
+ return t;
1100
+ }
1101
+ function sn(e, t) {
1102
+ const n = Gt(e);
1103
+ return n === "eip1559" ? Nt(e, t) : n === "eip2930" ? St(e, t) : n === "eip4844" ? kt(e, t) : Vt(e, t);
1104
+ }
1105
+ function kt(e, t) {
1106
+ const { chainId: n, gas: i, nonce: s, to: o, value: r, maxFeePerBlobGas: a, maxFeePerGas: l, maxPriorityFeePerGas: f, accessList: d, data: b } = e;
1107
+ jt(e);
1108
+ let p = e.blobVersionedHashes, h = e.sidecars;
1109
+ if (e.blobs && (typeof p > "u" || typeof h > "u")) {
1110
+ const m = typeof e.blobs[0] == "string" ? e.blobs : e.blobs.map((P) => g(P)), B = e.kzg, w = be({
1111
+ blobs: m,
1112
+ kzg: B
1113
+ });
1114
+ if (typeof p > "u" && (p = It({
1115
+ commitments: w
1116
+ })), typeof h > "u") {
1117
+ const P = pe({ blobs: m, commitments: w, kzg: B });
1118
+ h = Ft({ blobs: m, commitments: w, proofs: P });
1119
+ }
1120
+ }
1121
+ const Ie = S(d), M = [
1122
+ c(n),
1123
+ s ? c(s) : "0x",
1124
+ f ? c(f) : "0x",
1125
+ l ? c(l) : "0x",
1126
+ i ? c(i) : "0x",
1127
+ o ?? "0x",
1128
+ r ? c(r) : "0x",
1129
+ b ?? "0x",
1130
+ Ie,
1131
+ a ? c(a) : "0x",
1132
+ p ?? [],
1133
+ ...V(e, t)
1134
+ ], _ = [], R = [], D = [];
1135
+ if (h)
1136
+ for (let m = 0; m < h.length; m++) {
1137
+ const { blob: B, commitment: w, proof: P } = h[m];
1138
+ _.push(B), R.push(w), D.push(P);
1139
+ }
1140
+ return $([
1141
+ "0x03",
1142
+ // If sidecars are enabled, envelope turns into a "wrapper":
1143
+ T(h ? [M, _, R, D] : M)
1144
+ ]);
1145
+ }
1146
+ function Nt(e, t) {
1147
+ const { chainId: n, gas: i, nonce: s, to: o, value: r, maxFeePerGas: a, maxPriorityFeePerGas: l, accessList: f, data: d } = e;
1148
+ ve(e);
1149
+ const b = S(f), p = [
1150
+ c(n),
1151
+ s ? c(s) : "0x",
1152
+ l ? c(l) : "0x",
1153
+ a ? c(a) : "0x",
1154
+ i ? c(i) : "0x",
1155
+ o ?? "0x",
1156
+ r ? c(r) : "0x",
1157
+ d ?? "0x",
1158
+ b,
1159
+ ...V(e, t)
1160
+ ];
1161
+ return $([
1162
+ "0x02",
1163
+ T(p)
1164
+ ]);
1165
+ }
1166
+ function St(e, t) {
1167
+ const { chainId: n, gas: i, data: s, nonce: o, to: r, value: a, accessList: l, gasPrice: f } = e;
1168
+ At(e);
1169
+ const d = S(l), b = [
1170
+ c(n),
1171
+ o ? c(o) : "0x",
1172
+ f ? c(f) : "0x",
1173
+ i ? c(i) : "0x",
1174
+ r ?? "0x",
1175
+ a ? c(a) : "0x",
1176
+ s ?? "0x",
1177
+ d,
1178
+ ...V(e, t)
1179
+ ];
1180
+ return $([
1181
+ "0x01",
1182
+ T(b)
1183
+ ]);
1184
+ }
1185
+ function Vt(e, t) {
1186
+ const { chainId: n = 0, gas: i, data: s, nonce: o, to: r, value: a, gasPrice: l } = e;
1187
+ Ht(e);
1188
+ let f = [
1189
+ o ? c(o) : "0x",
1190
+ l ? c(l) : "0x",
1191
+ i ? c(i) : "0x",
1192
+ r ?? "0x",
1193
+ a ? c(a) : "0x",
1194
+ s ?? "0x"
1195
+ ];
1196
+ if (t) {
1197
+ const d = (() => {
1198
+ if (t.v >= 35n)
1199
+ return (t.v - 35n) / 2n > 0 ? t.v : 27n + (t.v === 35n ? 0n : 1n);
1200
+ if (n > 0)
1201
+ return BigInt(n * 2) + BigInt(35n + t.v - 27n);
1202
+ const b = 27n + (t.v === 27n ? 0n : 1n);
1203
+ if (t.v !== b)
1204
+ throw new at({ v: t.v });
1205
+ return b;
1206
+ })();
1207
+ f = [
1208
+ ...f,
1209
+ c(d),
1210
+ t.r,
1211
+ t.s
1212
+ ];
1213
+ } else n > 0 && (f = [
1214
+ ...f,
1215
+ c(n),
1216
+ "0x",
1217
+ "0x"
1218
+ ]);
1219
+ return T(f);
1220
+ }
1221
+ function V(e, t) {
1222
+ const { r: n, s: i, v: s, yParity: o } = t ?? e;
1223
+ return typeof n > "u" ? [] : typeof i > "u" ? [] : typeof s > "u" && typeof o > "u" ? [] : [typeof o == "number" ? o ? c(1) : "0x" : s === 0n ? "0x" : s === 1n ? c(1) : s === 27n ? "0x" : c(1), K(n), K(i)];
1224
+ }
1225
+ const rn = 2n ** 16n - 1n;
1226
+ export {
1227
+ At as $,
1228
+ en as A,
1229
+ Kt as B,
1230
+ qt as C,
1231
+ he as D,
1232
+ le as E,
1233
+ U as F,
1234
+ Xt as G,
1235
+ Ct as H,
1236
+ G as I,
1237
+ rn as J,
1238
+ N as K,
1239
+ at as L,
1240
+ ut as M,
1241
+ ft as N,
1242
+ ct as O,
1243
+ st as P,
1244
+ Zt as Q,
1245
+ Qt as R,
1246
+ de as S,
1247
+ yt as T,
1248
+ Wt as U,
1249
+ nn as V,
1250
+ Yt as W,
1251
+ Jt as X,
1252
+ gt as Y,
1253
+ T as Z,
1254
+ ve as _,
1255
+ $ as a,
1256
+ Ht as a0,
1257
+ vt as a1,
1258
+ Ot as a2,
1259
+ qe as a3,
1260
+ tn as a4,
1261
+ Pt as a5,
1262
+ S as a6,
1263
+ sn as a7,
1264
+ nt as a8,
1265
+ V as a9,
1266
+ ce as b,
1267
+ Rt as c,
1268
+ Qe as d,
1269
+ tt as e,
1270
+ F as f,
1271
+ lt as g,
1272
+ dt as h,
1273
+ L as i,
1274
+ ht as j,
1275
+ Je as k,
1276
+ bt as l,
1277
+ pt as m,
1278
+ mt as n,
1279
+ fe as o,
1280
+ ot as p,
1281
+ Dt as q,
1282
+ wt as r,
1283
+ et as s,
1284
+ be as t,
1285
+ It as u,
1286
+ pe as v,
1287
+ Ft as w,
1288
+ Gt as x,
1289
+ xt as y,
1290
+ Lt as z
1291
+ };