@fuel-ts/account 0.0.0-rc-2037-20240510180649 → 0.0.0-rc-1356-20240513141855

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.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

@@ -59,178 +59,12 @@
59
59
  return method;
60
60
  };
61
61
 
62
- // ../../node_modules/.pnpm/bech32@2.0.0/node_modules/bech32/dist/index.js
63
- var require_dist = __commonJS({
64
- "../../node_modules/.pnpm/bech32@2.0.0/node_modules/bech32/dist/index.js"(exports) {
65
- "use strict";
66
- Object.defineProperty(exports, "__esModule", { value: true });
67
- exports.bech32m = exports.bech32 = void 0;
68
- var ALPHABET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
69
- var ALPHABET_MAP = {};
70
- for (let z = 0; z < ALPHABET.length; z++) {
71
- const x = ALPHABET.charAt(z);
72
- ALPHABET_MAP[x] = z;
73
- }
74
- function polymodStep(pre) {
75
- const b = pre >> 25;
76
- return (pre & 33554431) << 5 ^ -(b >> 0 & 1) & 996825010 ^ -(b >> 1 & 1) & 642813549 ^ -(b >> 2 & 1) & 513874426 ^ -(b >> 3 & 1) & 1027748829 ^ -(b >> 4 & 1) & 705979059;
77
- }
78
- function prefixChk(prefix) {
79
- let chk = 1;
80
- for (let i = 0; i < prefix.length; ++i) {
81
- const c = prefix.charCodeAt(i);
82
- if (c < 33 || c > 126)
83
- return "Invalid prefix (" + prefix + ")";
84
- chk = polymodStep(chk) ^ c >> 5;
85
- }
86
- chk = polymodStep(chk);
87
- for (let i = 0; i < prefix.length; ++i) {
88
- const v = prefix.charCodeAt(i);
89
- chk = polymodStep(chk) ^ v & 31;
90
- }
91
- return chk;
92
- }
93
- function convert2(data, inBits, outBits, pad3) {
94
- let value = 0;
95
- let bits = 0;
96
- const maxV = (1 << outBits) - 1;
97
- const result = [];
98
- for (let i = 0; i < data.length; ++i) {
99
- value = value << inBits | data[i];
100
- bits += inBits;
101
- while (bits >= outBits) {
102
- bits -= outBits;
103
- result.push(value >> bits & maxV);
104
- }
105
- }
106
- if (pad3) {
107
- if (bits > 0) {
108
- result.push(value << outBits - bits & maxV);
109
- }
110
- } else {
111
- if (bits >= inBits)
112
- return "Excess padding";
113
- if (value << outBits - bits & maxV)
114
- return "Non-zero padding";
115
- }
116
- return result;
117
- }
118
- function toWords(bytes3) {
119
- return convert2(bytes3, 8, 5, true);
120
- }
121
- function fromWordsUnsafe(words) {
122
- const res = convert2(words, 5, 8, false);
123
- if (Array.isArray(res))
124
- return res;
125
- }
126
- function fromWords(words) {
127
- const res = convert2(words, 5, 8, false);
128
- if (Array.isArray(res))
129
- return res;
130
- throw new Error(res);
131
- }
132
- function getLibraryFromEncoding(encoding) {
133
- let ENCODING_CONST;
134
- if (encoding === "bech32") {
135
- ENCODING_CONST = 1;
136
- } else {
137
- ENCODING_CONST = 734539939;
138
- }
139
- function encode(prefix, words, LIMIT) {
140
- LIMIT = LIMIT || 90;
141
- if (prefix.length + 7 + words.length > LIMIT)
142
- throw new TypeError("Exceeds length limit");
143
- prefix = prefix.toLowerCase();
144
- let chk = prefixChk(prefix);
145
- if (typeof chk === "string")
146
- throw new Error(chk);
147
- let result = prefix + "1";
148
- for (let i = 0; i < words.length; ++i) {
149
- const x = words[i];
150
- if (x >> 5 !== 0)
151
- throw new Error("Non 5-bit word");
152
- chk = polymodStep(chk) ^ x;
153
- result += ALPHABET.charAt(x);
154
- }
155
- for (let i = 0; i < 6; ++i) {
156
- chk = polymodStep(chk);
157
- }
158
- chk ^= ENCODING_CONST;
159
- for (let i = 0; i < 6; ++i) {
160
- const v = chk >> (5 - i) * 5 & 31;
161
- result += ALPHABET.charAt(v);
162
- }
163
- return result;
164
- }
165
- function __decode(str, LIMIT) {
166
- LIMIT = LIMIT || 90;
167
- if (str.length < 8)
168
- return str + " too short";
169
- if (str.length > LIMIT)
170
- return "Exceeds length limit";
171
- const lowered = str.toLowerCase();
172
- const uppered = str.toUpperCase();
173
- if (str !== lowered && str !== uppered)
174
- return "Mixed-case string " + str;
175
- str = lowered;
176
- const split2 = str.lastIndexOf("1");
177
- if (split2 === -1)
178
- return "No separator character for " + str;
179
- if (split2 === 0)
180
- return "Missing prefix for " + str;
181
- const prefix = str.slice(0, split2);
182
- const wordChars = str.slice(split2 + 1);
183
- if (wordChars.length < 6)
184
- return "Data too short";
185
- let chk = prefixChk(prefix);
186
- if (typeof chk === "string")
187
- return chk;
188
- const words = [];
189
- for (let i = 0; i < wordChars.length; ++i) {
190
- const c = wordChars.charAt(i);
191
- const v = ALPHABET_MAP[c];
192
- if (v === void 0)
193
- return "Unknown character " + c;
194
- chk = polymodStep(chk) ^ v;
195
- if (i + 6 >= wordChars.length)
196
- continue;
197
- words.push(v);
198
- }
199
- if (chk !== ENCODING_CONST)
200
- return "Invalid checksum for " + str;
201
- return { prefix, words };
202
- }
203
- function decodeUnsafe(str, LIMIT) {
204
- const res = __decode(str, LIMIT);
205
- if (typeof res === "object")
206
- return res;
207
- }
208
- function decode(str, LIMIT) {
209
- const res = __decode(str, LIMIT);
210
- if (typeof res === "object")
211
- return res;
212
- throw new Error(res);
213
- }
214
- return {
215
- decodeUnsafe,
216
- decode,
217
- encode,
218
- toWords,
219
- fromWordsUnsafe,
220
- fromWords
221
- };
222
- }
223
- exports.bech32 = getLibraryFromEncoding("bech32");
224
- exports.bech32m = getLibraryFromEncoding("bech32m");
225
- }
226
- });
227
-
228
62
  // ../../node_modules/.pnpm/bn.js@5.2.1/node_modules/bn.js/lib/bn.js
229
63
  var require_bn = __commonJS({
230
64
  "../../node_modules/.pnpm/bn.js@5.2.1/node_modules/bn.js/lib/bn.js"(exports, module) {
231
65
  (function(module2, exports2) {
232
66
  "use strict";
233
- function assert3(val, msg) {
67
+ function assert2(val, msg) {
234
68
  if (!val)
235
69
  throw new Error(msg || "Assertion failed");
236
70
  }
@@ -242,20 +76,20 @@
242
76
  ctor.prototype = new TempCtor();
243
77
  ctor.prototype.constructor = ctor;
244
78
  }
245
- function BN2(number3, base, endian) {
246
- if (BN2.isBN(number3)) {
247
- return number3;
79
+ function BN2(number2, base, endian) {
80
+ if (BN2.isBN(number2)) {
81
+ return number2;
248
82
  }
249
83
  this.negative = 0;
250
84
  this.words = null;
251
85
  this.length = 0;
252
86
  this.red = null;
253
- if (number3 !== null) {
87
+ if (number2 !== null) {
254
88
  if (base === "le" || base === "be") {
255
89
  endian = base;
256
90
  base = 10;
257
91
  }
258
- this._init(number3 || 0, base || 10, endian || "be");
92
+ this._init(number2 || 0, base || 10, endian || "be");
259
93
  }
260
94
  }
261
95
  if (typeof module2 === "object") {
@@ -290,53 +124,53 @@
290
124
  return left;
291
125
  return right;
292
126
  };
293
- BN2.prototype._init = function init(number3, base, endian) {
294
- if (typeof number3 === "number") {
295
- return this._initNumber(number3, base, endian);
127
+ BN2.prototype._init = function init(number2, base, endian) {
128
+ if (typeof number2 === "number") {
129
+ return this._initNumber(number2, base, endian);
296
130
  }
297
- if (typeof number3 === "object") {
298
- return this._initArray(number3, base, endian);
131
+ if (typeof number2 === "object") {
132
+ return this._initArray(number2, base, endian);
299
133
  }
300
134
  if (base === "hex") {
301
135
  base = 16;
302
136
  }
303
- assert3(base === (base | 0) && base >= 2 && base <= 36);
304
- number3 = number3.toString().replace(/\s+/g, "");
137
+ assert2(base === (base | 0) && base >= 2 && base <= 36);
138
+ number2 = number2.toString().replace(/\s+/g, "");
305
139
  var start = 0;
306
- if (number3[0] === "-") {
140
+ if (number2[0] === "-") {
307
141
  start++;
308
142
  this.negative = 1;
309
143
  }
310
- if (start < number3.length) {
144
+ if (start < number2.length) {
311
145
  if (base === 16) {
312
- this._parseHex(number3, start, endian);
146
+ this._parseHex(number2, start, endian);
313
147
  } else {
314
- this._parseBase(number3, base, start);
148
+ this._parseBase(number2, base, start);
315
149
  if (endian === "le") {
316
150
  this._initArray(this.toArray(), base, endian);
317
151
  }
318
152
  }
319
153
  }
320
154
  };
321
- BN2.prototype._initNumber = function _initNumber(number3, base, endian) {
322
- if (number3 < 0) {
155
+ BN2.prototype._initNumber = function _initNumber(number2, base, endian) {
156
+ if (number2 < 0) {
323
157
  this.negative = 1;
324
- number3 = -number3;
158
+ number2 = -number2;
325
159
  }
326
- if (number3 < 67108864) {
327
- this.words = [number3 & 67108863];
160
+ if (number2 < 67108864) {
161
+ this.words = [number2 & 67108863];
328
162
  this.length = 1;
329
- } else if (number3 < 4503599627370496) {
163
+ } else if (number2 < 4503599627370496) {
330
164
  this.words = [
331
- number3 & 67108863,
332
- number3 / 67108864 & 67108863
165
+ number2 & 67108863,
166
+ number2 / 67108864 & 67108863
333
167
  ];
334
168
  this.length = 2;
335
169
  } else {
336
- assert3(number3 < 9007199254740992);
170
+ assert2(number2 < 9007199254740992);
337
171
  this.words = [
338
- number3 & 67108863,
339
- number3 / 67108864 & 67108863,
172
+ number2 & 67108863,
173
+ number2 / 67108864 & 67108863,
340
174
  1
341
175
  ];
342
176
  this.length = 3;
@@ -345,14 +179,14 @@
345
179
  return;
346
180
  this._initArray(this.toArray(), base, endian);
347
181
  };
348
- BN2.prototype._initArray = function _initArray(number3, base, endian) {
349
- assert3(typeof number3.length === "number");
350
- if (number3.length <= 0) {
182
+ BN2.prototype._initArray = function _initArray(number2, base, endian) {
183
+ assert2(typeof number2.length === "number");
184
+ if (number2.length <= 0) {
351
185
  this.words = [0];
352
186
  this.length = 1;
353
187
  return this;
354
188
  }
355
- this.length = Math.ceil(number3.length / 3);
189
+ this.length = Math.ceil(number2.length / 3);
356
190
  this.words = new Array(this.length);
357
191
  for (var i = 0; i < this.length; i++) {
358
192
  this.words[i] = 0;
@@ -360,8 +194,8 @@
360
194
  var j, w;
361
195
  var off = 0;
362
196
  if (endian === "be") {
363
- for (i = number3.length - 1, j = 0; i >= 0; i -= 3) {
364
- w = number3[i] | number3[i - 1] << 8 | number3[i - 2] << 16;
197
+ for (i = number2.length - 1, j = 0; i >= 0; i -= 3) {
198
+ w = number2[i] | number2[i - 1] << 8 | number2[i - 2] << 16;
365
199
  this.words[j] |= w << off & 67108863;
366
200
  this.words[j + 1] = w >>> 26 - off & 67108863;
367
201
  off += 24;
@@ -371,8 +205,8 @@
371
205
  }
372
206
  }
373
207
  } else if (endian === "le") {
374
- for (i = 0, j = 0; i < number3.length; i += 3) {
375
- w = number3[i] | number3[i + 1] << 8 | number3[i + 2] << 16;
208
+ for (i = 0, j = 0; i < number2.length; i += 3) {
209
+ w = number2[i] | number2[i + 1] << 8 | number2[i + 2] << 16;
376
210
  this.words[j] |= w << off & 67108863;
377
211
  this.words[j + 1] = w >>> 26 - off & 67108863;
378
212
  off += 24;
@@ -393,7 +227,7 @@
393
227
  } else if (c >= 97 && c <= 102) {
394
228
  return c - 87;
395
229
  } else {
396
- assert3(false, "Invalid character in " + string);
230
+ assert2(false, "Invalid character in " + string);
397
231
  }
398
232
  }
399
233
  function parseHexByte(string, lowerBound, index) {
@@ -403,8 +237,8 @@
403
237
  }
404
238
  return r;
405
239
  }
406
- BN2.prototype._parseHex = function _parseHex(number3, start, endian) {
407
- this.length = Math.ceil((number3.length - start) / 6);
240
+ BN2.prototype._parseHex = function _parseHex(number2, start, endian) {
241
+ this.length = Math.ceil((number2.length - start) / 6);
408
242
  this.words = new Array(this.length);
409
243
  for (var i = 0; i < this.length; i++) {
410
244
  this.words[i] = 0;
@@ -413,8 +247,8 @@
413
247
  var j = 0;
414
248
  var w;
415
249
  if (endian === "be") {
416
- for (i = number3.length - 1; i >= start; i -= 2) {
417
- w = parseHexByte(number3, start, i) << off;
250
+ for (i = number2.length - 1; i >= start; i -= 2) {
251
+ w = parseHexByte(number2, start, i) << off;
418
252
  this.words[j] |= w & 67108863;
419
253
  if (off >= 18) {
420
254
  off -= 18;
@@ -425,9 +259,9 @@
425
259
  }
426
260
  }
427
261
  } else {
428
- var parseLength = number3.length - start;
429
- for (i = parseLength % 2 === 0 ? start + 1 : start; i < number3.length; i += 2) {
430
- w = parseHexByte(number3, start, i) << off;
262
+ var parseLength = number2.length - start;
263
+ for (i = parseLength % 2 === 0 ? start + 1 : start; i < number2.length; i += 2) {
264
+ w = parseHexByte(number2, start, i) << off;
431
265
  this.words[j] |= w & 67108863;
432
266
  if (off >= 18) {
433
267
  off -= 18;
@@ -454,12 +288,12 @@
454
288
  } else {
455
289
  b = c;
456
290
  }
457
- assert3(c >= 0 && b < mul, "Invalid character");
291
+ assert2(c >= 0 && b < mul, "Invalid character");
458
292
  r += b;
459
293
  }
460
294
  return r;
461
295
  }
462
- BN2.prototype._parseBase = function _parseBase(number3, base, start) {
296
+ BN2.prototype._parseBase = function _parseBase(number2, base, start) {
463
297
  this.words = [0];
464
298
  this.length = 1;
465
299
  for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) {
@@ -467,12 +301,12 @@
467
301
  }
468
302
  limbLen--;
469
303
  limbPow = limbPow / base | 0;
470
- var total = number3.length - start;
304
+ var total = number2.length - start;
471
305
  var mod2 = total % limbLen;
472
306
  var end = Math.min(total, total - mod2) + start;
473
307
  var word = 0;
474
308
  for (var i = start; i < end; i += limbLen) {
475
- word = parseBase(number3, i, i + limbLen, base);
309
+ word = parseBase(number2, i, i + limbLen, base);
476
310
  this.imuln(limbPow);
477
311
  if (this.words[0] + word < 67108864) {
478
312
  this.words[0] += word;
@@ -482,7 +316,7 @@
482
316
  }
483
317
  if (mod2 !== 0) {
484
318
  var pow3 = 1;
485
- word = parseBase(number3, i, number3.length, base);
319
+ word = parseBase(number2, i, number2.length, base);
486
320
  for (i = 0; i < mod2; i++) {
487
321
  pow3 *= base;
488
322
  }
@@ -714,7 +548,7 @@
714
548
  }
715
549
  return out;
716
550
  }
717
- assert3(false, "Base should be between 2 and 36");
551
+ assert2(false, "Base should be between 2 and 36");
718
552
  };
719
553
  BN2.prototype.toNumber = function toNumber3() {
720
554
  var ret2 = this.words[0];
@@ -723,7 +557,7 @@
723
557
  } else if (this.length === 3 && this.words[2] === 1) {
724
558
  ret2 += 4503599627370496 + this.words[1] * 67108864;
725
559
  } else if (this.length > 2) {
726
- assert3(false, "Number can only safely store up to 53 bits");
560
+ assert2(false, "Number can only safely store up to 53 bits");
727
561
  }
728
562
  return this.negative !== 0 ? -ret2 : ret2;
729
563
  };
@@ -748,8 +582,8 @@
748
582
  this._strip();
749
583
  var byteLength = this.byteLength();
750
584
  var reqLength = length || Math.max(1, byteLength);
751
- assert3(byteLength <= reqLength, "byte array longer than desired length");
752
- assert3(reqLength > 0, "Requested array length <= 0");
585
+ assert2(byteLength <= reqLength, "byte array longer than desired length");
586
+ assert2(reqLength > 0, "Requested array length <= 0");
753
587
  var res = allocate(ArrayType, reqLength);
754
588
  var postfix = endian === "le" ? "LE" : "BE";
755
589
  this["_toArrayLike" + postfix](res, byteLength);
@@ -931,7 +765,7 @@
931
765
  return this._strip();
932
766
  };
933
767
  BN2.prototype.ior = function ior(num) {
934
- assert3((this.negative | num.negative) === 0);
768
+ assert2((this.negative | num.negative) === 0);
935
769
  return this.iuor(num);
936
770
  };
937
771
  BN2.prototype.or = function or(num) {
@@ -958,7 +792,7 @@
958
792
  return this._strip();
959
793
  };
960
794
  BN2.prototype.iand = function iand(num) {
961
- assert3((this.negative | num.negative) === 0);
795
+ assert2((this.negative | num.negative) === 0);
962
796
  return this.iuand(num);
963
797
  };
964
798
  BN2.prototype.and = function and(num) {
@@ -993,7 +827,7 @@
993
827
  return this._strip();
994
828
  };
995
829
  BN2.prototype.ixor = function ixor(num) {
996
- assert3((this.negative | num.negative) === 0);
830
+ assert2((this.negative | num.negative) === 0);
997
831
  return this.iuxor(num);
998
832
  };
999
833
  BN2.prototype.xor = function xor(num) {
@@ -1007,7 +841,7 @@
1007
841
  return num.clone().iuxor(this);
1008
842
  };
1009
843
  BN2.prototype.inotn = function inotn(width) {
1010
- assert3(typeof width === "number" && width >= 0);
844
+ assert2(typeof width === "number" && width >= 0);
1011
845
  var bytesNeeded = Math.ceil(width / 26) | 0;
1012
846
  var bitsLeft = width % 26;
1013
847
  this._expand(bytesNeeded);
@@ -1026,7 +860,7 @@
1026
860
  return this.clone().inotn(width);
1027
861
  };
1028
862
  BN2.prototype.setn = function setn(bit, val) {
1029
- assert3(typeof bit === "number" && bit >= 0);
863
+ assert2(typeof bit === "number" && bit >= 0);
1030
864
  var off = bit / 26 | 0;
1031
865
  var wbit = bit % 26;
1032
866
  this._expand(off + 1);
@@ -1892,8 +1726,8 @@
1892
1726
  for (i = 2 * len; i < N; ++i) {
1893
1727
  rws[i] = 0;
1894
1728
  }
1895
- assert3(carry === 0);
1896
- assert3((carry & ~8191) === 0);
1729
+ assert2(carry === 0);
1730
+ assert2((carry & ~8191) === 0);
1897
1731
  };
1898
1732
  FFTM.prototype.stub = function stub(N) {
1899
1733
  var ph = new Array(N);
@@ -1948,8 +1782,8 @@
1948
1782
  var isNegNum = num < 0;
1949
1783
  if (isNegNum)
1950
1784
  num = -num;
1951
- assert3(typeof num === "number");
1952
- assert3(num < 67108864);
1785
+ assert2(typeof num === "number");
1786
+ assert2(num < 67108864);
1953
1787
  var carry = 0;
1954
1788
  for (var i = 0; i < this.length; i++) {
1955
1789
  var w = (this.words[i] | 0) * num;
@@ -1993,7 +1827,7 @@
1993
1827
  return res;
1994
1828
  };
1995
1829
  BN2.prototype.iushln = function iushln(bits) {
1996
- assert3(typeof bits === "number" && bits >= 0);
1830
+ assert2(typeof bits === "number" && bits >= 0);
1997
1831
  var r = bits % 26;
1998
1832
  var s = (bits - r) / 26;
1999
1833
  var carryMask = 67108863 >>> 26 - r << 26 - r;
@@ -2023,11 +1857,11 @@
2023
1857
  return this._strip();
2024
1858
  };
2025
1859
  BN2.prototype.ishln = function ishln(bits) {
2026
- assert3(this.negative === 0);
1860
+ assert2(this.negative === 0);
2027
1861
  return this.iushln(bits);
2028
1862
  };
2029
1863
  BN2.prototype.iushrn = function iushrn(bits, hint, extended) {
2030
- assert3(typeof bits === "number" && bits >= 0);
1864
+ assert2(typeof bits === "number" && bits >= 0);
2031
1865
  var h;
2032
1866
  if (hint) {
2033
1867
  h = (hint - hint % 26) / 26;
@@ -2072,7 +1906,7 @@
2072
1906
  return this._strip();
2073
1907
  };
2074
1908
  BN2.prototype.ishrn = function ishrn(bits, hint, extended) {
2075
- assert3(this.negative === 0);
1909
+ assert2(this.negative === 0);
2076
1910
  return this.iushrn(bits, hint, extended);
2077
1911
  };
2078
1912
  BN2.prototype.shln = function shln(bits) {
@@ -2088,7 +1922,7 @@
2088
1922
  return this.clone().iushrn(bits);
2089
1923
  };
2090
1924
  BN2.prototype.testn = function testn(bit) {
2091
- assert3(typeof bit === "number" && bit >= 0);
1925
+ assert2(typeof bit === "number" && bit >= 0);
2092
1926
  var r = bit % 26;
2093
1927
  var s = (bit - r) / 26;
2094
1928
  var q = 1 << r;
@@ -2098,10 +1932,10 @@
2098
1932
  return !!(w & q);
2099
1933
  };
2100
1934
  BN2.prototype.imaskn = function imaskn(bits) {
2101
- assert3(typeof bits === "number" && bits >= 0);
1935
+ assert2(typeof bits === "number" && bits >= 0);
2102
1936
  var r = bits % 26;
2103
1937
  var s = (bits - r) / 26;
2104
- assert3(this.negative === 0, "imaskn works only with positive numbers");
1938
+ assert2(this.negative === 0, "imaskn works only with positive numbers");
2105
1939
  if (this.length <= s) {
2106
1940
  return this;
2107
1941
  }
@@ -2119,8 +1953,8 @@
2119
1953
  return this.clone().imaskn(bits);
2120
1954
  };
2121
1955
  BN2.prototype.iaddn = function iaddn(num) {
2122
- assert3(typeof num === "number");
2123
- assert3(num < 67108864);
1956
+ assert2(typeof num === "number");
1957
+ assert2(num < 67108864);
2124
1958
  if (num < 0)
2125
1959
  return this.isubn(-num);
2126
1960
  if (this.negative !== 0) {
@@ -2150,8 +1984,8 @@
2150
1984
  return this;
2151
1985
  };
2152
1986
  BN2.prototype.isubn = function isubn(num) {
2153
- assert3(typeof num === "number");
2154
- assert3(num < 67108864);
1987
+ assert2(typeof num === "number");
1988
+ assert2(num < 67108864);
2155
1989
  if (num < 0)
2156
1990
  return this.iaddn(-num);
2157
1991
  if (this.negative !== 0) {
@@ -2205,7 +2039,7 @@
2205
2039
  }
2206
2040
  if (carry === 0)
2207
2041
  return this._strip();
2208
- assert3(carry === -1);
2042
+ assert2(carry === -1);
2209
2043
  carry = 0;
2210
2044
  for (i = 0; i < this.length; i++) {
2211
2045
  w = -(this.words[i] | 0) + carry;
@@ -2273,7 +2107,7 @@
2273
2107
  };
2274
2108
  };
2275
2109
  BN2.prototype.divmod = function divmod(num, mode, positive) {
2276
- assert3(!num.isZero());
2110
+ assert2(!num.isZero());
2277
2111
  if (this.isZero()) {
2278
2112
  return {
2279
2113
  div: new BN2(0),
@@ -2371,7 +2205,7 @@
2371
2205
  var isNegNum = num < 0;
2372
2206
  if (isNegNum)
2373
2207
  num = -num;
2374
- assert3(num <= 67108863);
2208
+ assert2(num <= 67108863);
2375
2209
  var p = (1 << 26) % num;
2376
2210
  var acc = 0;
2377
2211
  for (var i = this.length - 1; i >= 0; i--) {
@@ -2386,7 +2220,7 @@
2386
2220
  var isNegNum = num < 0;
2387
2221
  if (isNegNum)
2388
2222
  num = -num;
2389
- assert3(num <= 67108863);
2223
+ assert2(num <= 67108863);
2390
2224
  var carry = 0;
2391
2225
  for (var i = this.length - 1; i >= 0; i--) {
2392
2226
  var w = (this.words[i] | 0) + carry * 67108864;
@@ -2400,8 +2234,8 @@
2400
2234
  return this.clone().idivn(num);
2401
2235
  };
2402
2236
  BN2.prototype.egcd = function egcd(p) {
2403
- assert3(p.negative === 0);
2404
- assert3(!p.isZero());
2237
+ assert2(p.negative === 0);
2238
+ assert2(!p.isZero());
2405
2239
  var x = this;
2406
2240
  var y = p.clone();
2407
2241
  if (x.negative !== 0) {
@@ -2465,8 +2299,8 @@
2465
2299
  };
2466
2300
  };
2467
2301
  BN2.prototype._invmp = function _invmp(p) {
2468
- assert3(p.negative === 0);
2469
- assert3(!p.isZero());
2302
+ assert2(p.negative === 0);
2303
+ assert2(!p.isZero());
2470
2304
  var a = this;
2471
2305
  var b = p.clone();
2472
2306
  if (a.negative !== 0) {
@@ -2564,7 +2398,7 @@
2564
2398
  return this.words[0] & num;
2565
2399
  };
2566
2400
  BN2.prototype.bincn = function bincn(bit) {
2567
- assert3(typeof bit === "number");
2401
+ assert2(typeof bit === "number");
2568
2402
  var r = bit % 26;
2569
2403
  var s = (bit - r) / 26;
2570
2404
  var q = 1 << r;
@@ -2604,7 +2438,7 @@
2604
2438
  if (negative) {
2605
2439
  num = -num;
2606
2440
  }
2607
- assert3(num <= 67108863, "Number is too big");
2441
+ assert2(num <= 67108863, "Number is too big");
2608
2442
  var w = this.words[0] | 0;
2609
2443
  res = w === num ? 0 : w < num ? -1 : 1;
2610
2444
  }
@@ -2676,12 +2510,12 @@
2676
2510
  return new Red(num);
2677
2511
  };
2678
2512
  BN2.prototype.toRed = function toRed(ctx) {
2679
- assert3(!this.red, "Already a number in reduction context");
2680
- assert3(this.negative === 0, "red works only with positives");
2513
+ assert2(!this.red, "Already a number in reduction context");
2514
+ assert2(this.negative === 0, "red works only with positives");
2681
2515
  return ctx.convertTo(this)._forceRed(ctx);
2682
2516
  };
2683
2517
  BN2.prototype.fromRed = function fromRed() {
2684
- assert3(this.red, "fromRed works only with numbers in reduction context");
2518
+ assert2(this.red, "fromRed works only with numbers in reduction context");
2685
2519
  return this.red.convertFrom(this);
2686
2520
  };
2687
2521
  BN2.prototype._forceRed = function _forceRed(ctx) {
@@ -2689,66 +2523,66 @@
2689
2523
  return this;
2690
2524
  };
2691
2525
  BN2.prototype.forceRed = function forceRed(ctx) {
2692
- assert3(!this.red, "Already a number in reduction context");
2526
+ assert2(!this.red, "Already a number in reduction context");
2693
2527
  return this._forceRed(ctx);
2694
2528
  };
2695
2529
  BN2.prototype.redAdd = function redAdd(num) {
2696
- assert3(this.red, "redAdd works only with red numbers");
2530
+ assert2(this.red, "redAdd works only with red numbers");
2697
2531
  return this.red.add(this, num);
2698
2532
  };
2699
2533
  BN2.prototype.redIAdd = function redIAdd(num) {
2700
- assert3(this.red, "redIAdd works only with red numbers");
2534
+ assert2(this.red, "redIAdd works only with red numbers");
2701
2535
  return this.red.iadd(this, num);
2702
2536
  };
2703
2537
  BN2.prototype.redSub = function redSub(num) {
2704
- assert3(this.red, "redSub works only with red numbers");
2538
+ assert2(this.red, "redSub works only with red numbers");
2705
2539
  return this.red.sub(this, num);
2706
2540
  };
2707
2541
  BN2.prototype.redISub = function redISub(num) {
2708
- assert3(this.red, "redISub works only with red numbers");
2542
+ assert2(this.red, "redISub works only with red numbers");
2709
2543
  return this.red.isub(this, num);
2710
2544
  };
2711
2545
  BN2.prototype.redShl = function redShl(num) {
2712
- assert3(this.red, "redShl works only with red numbers");
2546
+ assert2(this.red, "redShl works only with red numbers");
2713
2547
  return this.red.shl(this, num);
2714
2548
  };
2715
2549
  BN2.prototype.redMul = function redMul(num) {
2716
- assert3(this.red, "redMul works only with red numbers");
2550
+ assert2(this.red, "redMul works only with red numbers");
2717
2551
  this.red._verify2(this, num);
2718
2552
  return this.red.mul(this, num);
2719
2553
  };
2720
2554
  BN2.prototype.redIMul = function redIMul(num) {
2721
- assert3(this.red, "redMul works only with red numbers");
2555
+ assert2(this.red, "redMul works only with red numbers");
2722
2556
  this.red._verify2(this, num);
2723
2557
  return this.red.imul(this, num);
2724
2558
  };
2725
2559
  BN2.prototype.redSqr = function redSqr() {
2726
- assert3(this.red, "redSqr works only with red numbers");
2560
+ assert2(this.red, "redSqr works only with red numbers");
2727
2561
  this.red._verify1(this);
2728
2562
  return this.red.sqr(this);
2729
2563
  };
2730
2564
  BN2.prototype.redISqr = function redISqr() {
2731
- assert3(this.red, "redISqr works only with red numbers");
2565
+ assert2(this.red, "redISqr works only with red numbers");
2732
2566
  this.red._verify1(this);
2733
2567
  return this.red.isqr(this);
2734
2568
  };
2735
2569
  BN2.prototype.redSqrt = function redSqrt() {
2736
- assert3(this.red, "redSqrt works only with red numbers");
2570
+ assert2(this.red, "redSqrt works only with red numbers");
2737
2571
  this.red._verify1(this);
2738
2572
  return this.red.sqrt(this);
2739
2573
  };
2740
2574
  BN2.prototype.redInvm = function redInvm() {
2741
- assert3(this.red, "redInvm works only with red numbers");
2575
+ assert2(this.red, "redInvm works only with red numbers");
2742
2576
  this.red._verify1(this);
2743
2577
  return this.red.invm(this);
2744
2578
  };
2745
2579
  BN2.prototype.redNeg = function redNeg() {
2746
- assert3(this.red, "redNeg works only with red numbers");
2580
+ assert2(this.red, "redNeg works only with red numbers");
2747
2581
  this.red._verify1(this);
2748
2582
  return this.red.neg(this);
2749
2583
  };
2750
2584
  BN2.prototype.redPow = function redPow(num) {
2751
- assert3(this.red && !num.red, "redPow(normalNum)");
2585
+ assert2(this.red && !num.red, "redPow(normalNum)");
2752
2586
  this.red._verify1(this);
2753
2587
  return this.red.pow(this, num);
2754
2588
  };
@@ -2808,20 +2642,20 @@
2808
2642
  );
2809
2643
  }
2810
2644
  inherits(K256, MPrime);
2811
- K256.prototype.split = function split2(input, output3) {
2645
+ K256.prototype.split = function split2(input, output2) {
2812
2646
  var mask2 = 4194303;
2813
2647
  var outLen = Math.min(input.length, 9);
2814
2648
  for (var i = 0; i < outLen; i++) {
2815
- output3.words[i] = input.words[i];
2649
+ output2.words[i] = input.words[i];
2816
2650
  }
2817
- output3.length = outLen;
2651
+ output2.length = outLen;
2818
2652
  if (input.length <= 9) {
2819
2653
  input.words[0] = 0;
2820
2654
  input.length = 1;
2821
2655
  return;
2822
2656
  }
2823
2657
  var prev = input.words[9];
2824
- output3.words[output3.length++] = prev & mask2;
2658
+ output2.words[output2.length++] = prev & mask2;
2825
2659
  for (i = 10; i < input.length; i++) {
2826
2660
  var next = input.words[i] | 0;
2827
2661
  input.words[i - 10] = (next & mask2) << 4 | prev >>> 22;
@@ -2916,18 +2750,18 @@
2916
2750
  this.m = prime.p;
2917
2751
  this.prime = prime;
2918
2752
  } else {
2919
- assert3(m.gtn(1), "modulus must be greater than 1");
2753
+ assert2(m.gtn(1), "modulus must be greater than 1");
2920
2754
  this.m = m;
2921
2755
  this.prime = null;
2922
2756
  }
2923
2757
  }
2924
2758
  Red.prototype._verify1 = function _verify1(a) {
2925
- assert3(a.negative === 0, "red works only with positives");
2926
- assert3(a.red, "red works only with red numbers");
2759
+ assert2(a.negative === 0, "red works only with positives");
2760
+ assert2(a.red, "red works only with red numbers");
2927
2761
  };
2928
2762
  Red.prototype._verify2 = function _verify2(a, b) {
2929
- assert3((a.negative | b.negative) === 0, "red works only with positives");
2930
- assert3(
2763
+ assert2((a.negative | b.negative) === 0, "red works only with positives");
2764
+ assert2(
2931
2765
  a.red && a.red === b.red,
2932
2766
  "red works only with red numbers"
2933
2767
  );
@@ -2998,7 +2832,7 @@
2998
2832
  if (a.isZero())
2999
2833
  return a.clone();
3000
2834
  var mod3 = this.m.andln(3);
3001
- assert3(mod3 % 2 === 1);
2835
+ assert2(mod3 % 2 === 1);
3002
2836
  if (mod3 === 3) {
3003
2837
  var pow3 = this.m.add(new BN2(1)).iushrn(2);
3004
2838
  return this.pow(a, pow3);
@@ -3009,7 +2843,7 @@
3009
2843
  s++;
3010
2844
  q.iushrn(1);
3011
2845
  }
3012
- assert3(!q.isZero());
2846
+ assert2(!q.isZero());
3013
2847
  var one = new BN2(1).toRed(this);
3014
2848
  var nOne = one.redNeg();
3015
2849
  var lpow = this.m.subn(1).iushrn(1);
@@ -3027,7 +2861,7 @@
3027
2861
  for (var i = 0; tmp.cmp(one) !== 0; i++) {
3028
2862
  tmp = tmp.redSqr();
3029
2863
  }
3030
- assert3(i < m);
2864
+ assert2(i < m);
3031
2865
  var b = this.pow(c, new BN2(1).iushln(m - i - 1));
3032
2866
  r = r.redMul(b);
3033
2867
  c = b.redSqr();
@@ -3161,6 +2995,172 @@
3161
2995
  }
3162
2996
  });
3163
2997
 
2998
+ // ../../node_modules/.pnpm/bech32@2.0.0/node_modules/bech32/dist/index.js
2999
+ var require_dist = __commonJS({
3000
+ "../../node_modules/.pnpm/bech32@2.0.0/node_modules/bech32/dist/index.js"(exports) {
3001
+ "use strict";
3002
+ Object.defineProperty(exports, "__esModule", { value: true });
3003
+ exports.bech32m = exports.bech32 = void 0;
3004
+ var ALPHABET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
3005
+ var ALPHABET_MAP = {};
3006
+ for (let z = 0; z < ALPHABET.length; z++) {
3007
+ const x = ALPHABET.charAt(z);
3008
+ ALPHABET_MAP[x] = z;
3009
+ }
3010
+ function polymodStep(pre) {
3011
+ const b = pre >> 25;
3012
+ return (pre & 33554431) << 5 ^ -(b >> 0 & 1) & 996825010 ^ -(b >> 1 & 1) & 642813549 ^ -(b >> 2 & 1) & 513874426 ^ -(b >> 3 & 1) & 1027748829 ^ -(b >> 4 & 1) & 705979059;
3013
+ }
3014
+ function prefixChk(prefix) {
3015
+ let chk = 1;
3016
+ for (let i = 0; i < prefix.length; ++i) {
3017
+ const c = prefix.charCodeAt(i);
3018
+ if (c < 33 || c > 126)
3019
+ return "Invalid prefix (" + prefix + ")";
3020
+ chk = polymodStep(chk) ^ c >> 5;
3021
+ }
3022
+ chk = polymodStep(chk);
3023
+ for (let i = 0; i < prefix.length; ++i) {
3024
+ const v = prefix.charCodeAt(i);
3025
+ chk = polymodStep(chk) ^ v & 31;
3026
+ }
3027
+ return chk;
3028
+ }
3029
+ function convert2(data, inBits, outBits, pad3) {
3030
+ let value = 0;
3031
+ let bits = 0;
3032
+ const maxV = (1 << outBits) - 1;
3033
+ const result = [];
3034
+ for (let i = 0; i < data.length; ++i) {
3035
+ value = value << inBits | data[i];
3036
+ bits += inBits;
3037
+ while (bits >= outBits) {
3038
+ bits -= outBits;
3039
+ result.push(value >> bits & maxV);
3040
+ }
3041
+ }
3042
+ if (pad3) {
3043
+ if (bits > 0) {
3044
+ result.push(value << outBits - bits & maxV);
3045
+ }
3046
+ } else {
3047
+ if (bits >= inBits)
3048
+ return "Excess padding";
3049
+ if (value << outBits - bits & maxV)
3050
+ return "Non-zero padding";
3051
+ }
3052
+ return result;
3053
+ }
3054
+ function toWords(bytes2) {
3055
+ return convert2(bytes2, 8, 5, true);
3056
+ }
3057
+ function fromWordsUnsafe(words) {
3058
+ const res = convert2(words, 5, 8, false);
3059
+ if (Array.isArray(res))
3060
+ return res;
3061
+ }
3062
+ function fromWords(words) {
3063
+ const res = convert2(words, 5, 8, false);
3064
+ if (Array.isArray(res))
3065
+ return res;
3066
+ throw new Error(res);
3067
+ }
3068
+ function getLibraryFromEncoding(encoding) {
3069
+ let ENCODING_CONST;
3070
+ if (encoding === "bech32") {
3071
+ ENCODING_CONST = 1;
3072
+ } else {
3073
+ ENCODING_CONST = 734539939;
3074
+ }
3075
+ function encode(prefix, words, LIMIT) {
3076
+ LIMIT = LIMIT || 90;
3077
+ if (prefix.length + 7 + words.length > LIMIT)
3078
+ throw new TypeError("Exceeds length limit");
3079
+ prefix = prefix.toLowerCase();
3080
+ let chk = prefixChk(prefix);
3081
+ if (typeof chk === "string")
3082
+ throw new Error(chk);
3083
+ let result = prefix + "1";
3084
+ for (let i = 0; i < words.length; ++i) {
3085
+ const x = words[i];
3086
+ if (x >> 5 !== 0)
3087
+ throw new Error("Non 5-bit word");
3088
+ chk = polymodStep(chk) ^ x;
3089
+ result += ALPHABET.charAt(x);
3090
+ }
3091
+ for (let i = 0; i < 6; ++i) {
3092
+ chk = polymodStep(chk);
3093
+ }
3094
+ chk ^= ENCODING_CONST;
3095
+ for (let i = 0; i < 6; ++i) {
3096
+ const v = chk >> (5 - i) * 5 & 31;
3097
+ result += ALPHABET.charAt(v);
3098
+ }
3099
+ return result;
3100
+ }
3101
+ function __decode(str, LIMIT) {
3102
+ LIMIT = LIMIT || 90;
3103
+ if (str.length < 8)
3104
+ return str + " too short";
3105
+ if (str.length > LIMIT)
3106
+ return "Exceeds length limit";
3107
+ const lowered = str.toLowerCase();
3108
+ const uppered = str.toUpperCase();
3109
+ if (str !== lowered && str !== uppered)
3110
+ return "Mixed-case string " + str;
3111
+ str = lowered;
3112
+ const split2 = str.lastIndexOf("1");
3113
+ if (split2 === -1)
3114
+ return "No separator character for " + str;
3115
+ if (split2 === 0)
3116
+ return "Missing prefix for " + str;
3117
+ const prefix = str.slice(0, split2);
3118
+ const wordChars = str.slice(split2 + 1);
3119
+ if (wordChars.length < 6)
3120
+ return "Data too short";
3121
+ let chk = prefixChk(prefix);
3122
+ if (typeof chk === "string")
3123
+ return chk;
3124
+ const words = [];
3125
+ for (let i = 0; i < wordChars.length; ++i) {
3126
+ const c = wordChars.charAt(i);
3127
+ const v = ALPHABET_MAP[c];
3128
+ if (v === void 0)
3129
+ return "Unknown character " + c;
3130
+ chk = polymodStep(chk) ^ v;
3131
+ if (i + 6 >= wordChars.length)
3132
+ continue;
3133
+ words.push(v);
3134
+ }
3135
+ if (chk !== ENCODING_CONST)
3136
+ return "Invalid checksum for " + str;
3137
+ return { prefix, words };
3138
+ }
3139
+ function decodeUnsafe(str, LIMIT) {
3140
+ const res = __decode(str, LIMIT);
3141
+ if (typeof res === "object")
3142
+ return res;
3143
+ }
3144
+ function decode(str, LIMIT) {
3145
+ const res = __decode(str, LIMIT);
3146
+ if (typeof res === "object")
3147
+ return res;
3148
+ throw new Error(res);
3149
+ }
3150
+ return {
3151
+ decodeUnsafe,
3152
+ decode,
3153
+ encode,
3154
+ toWords,
3155
+ fromWordsUnsafe,
3156
+ fromWords
3157
+ };
3158
+ }
3159
+ exports.bech32 = getLibraryFromEncoding("bech32");
3160
+ exports.bech32m = getLibraryFromEncoding("bech32m");
3161
+ }
3162
+ });
3163
+
3164
3164
  // ../../node_modules/.pnpm/webidl-conversions@3.0.1/node_modules/webidl-conversions/lib/index.js
3165
3165
  var require_lib = __commonJS({
3166
3166
  "../../node_modules/.pnpm/webidl-conversions@3.0.1/node_modules/webidl-conversions/lib/index.js"(exports, module) {
@@ -3591,18 +3591,18 @@
3591
3591
  }
3592
3592
  function utf8PercentDecode(str) {
3593
3593
  const input = new Buffer(str);
3594
- const output3 = [];
3594
+ const output2 = [];
3595
3595
  for (let i = 0; i < input.length; ++i) {
3596
3596
  if (input[i] !== 37) {
3597
- output3.push(input[i]);
3597
+ output2.push(input[i]);
3598
3598
  } else if (input[i] === 37 && isASCIIHex(input[i + 1]) && isASCIIHex(input[i + 2])) {
3599
- output3.push(parseInt(input.slice(i + 1, i + 3).toString(), 16));
3599
+ output2.push(parseInt(input.slice(i + 1, i + 3).toString(), 16));
3600
3600
  i += 2;
3601
3601
  } else {
3602
- output3.push(input[i]);
3602
+ output2.push(input[i]);
3603
3603
  }
3604
3604
  }
3605
- return new Buffer(output3).toString();
3605
+ return new Buffer(output2).toString();
3606
3606
  }
3607
3607
  function isC0ControlPercentEncode(c) {
3608
3608
  return c <= 31 || c > 126;
@@ -3678,16 +3678,16 @@
3678
3678
  return ipv4;
3679
3679
  }
3680
3680
  function serializeIPv4(address) {
3681
- let output3 = "";
3681
+ let output2 = "";
3682
3682
  let n = address;
3683
3683
  for (let i = 1; i <= 4; ++i) {
3684
- output3 = String(n % 256) + output3;
3684
+ output2 = String(n % 256) + output2;
3685
3685
  if (i !== 4) {
3686
- output3 = "." + output3;
3686
+ output2 = "." + output2;
3687
3687
  }
3688
3688
  n = Math.floor(n / 256);
3689
3689
  }
3690
- return output3;
3690
+ return output2;
3691
3691
  }
3692
3692
  function parseIPv6(input) {
3693
3693
  const address = [0, 0, 0, 0, 0, 0, 0, 0];
@@ -3745,13 +3745,13 @@
3745
3745
  return failure;
3746
3746
  }
3747
3747
  while (isASCIIDigit(input[pointer])) {
3748
- const number3 = parseInt(at(input, pointer));
3748
+ const number2 = parseInt(at(input, pointer));
3749
3749
  if (ipv4Piece === null) {
3750
- ipv4Piece = number3;
3750
+ ipv4Piece = number2;
3751
3751
  } else if (ipv4Piece === 0) {
3752
3752
  return failure;
3753
3753
  } else {
3754
- ipv4Piece = ipv4Piece * 10 + number3;
3754
+ ipv4Piece = ipv4Piece * 10 + number2;
3755
3755
  }
3756
3756
  if (ipv4Piece > 255) {
3757
3757
  return failure;
@@ -3795,7 +3795,7 @@
3795
3795
  return address;
3796
3796
  }
3797
3797
  function serializeIPv6(address) {
3798
- let output3 = "";
3798
+ let output2 = "";
3799
3799
  const seqResult = findLongestZeroSequence(address);
3800
3800
  const compress = seqResult.idx;
3801
3801
  let ignore0 = false;
@@ -3807,16 +3807,16 @@
3807
3807
  }
3808
3808
  if (compress === pieceIndex) {
3809
3809
  const separator = pieceIndex === 0 ? "::" : ":";
3810
- output3 += separator;
3810
+ output2 += separator;
3811
3811
  ignore0 = true;
3812
3812
  continue;
3813
3813
  }
3814
- output3 += address[pieceIndex].toString(16);
3814
+ output2 += address[pieceIndex].toString(16);
3815
3815
  if (pieceIndex !== 7) {
3816
- output3 += ":";
3816
+ output2 += ":";
3817
3817
  }
3818
3818
  }
3819
- return output3;
3819
+ return output2;
3820
3820
  }
3821
3821
  function parseHost(input, isSpecialArg) {
3822
3822
  if (input[0] === "[") {
@@ -3846,12 +3846,12 @@
3846
3846
  if (containsForbiddenHostCodePointExcludingPercent(input)) {
3847
3847
  return failure;
3848
3848
  }
3849
- let output3 = "";
3849
+ let output2 = "";
3850
3850
  const decoded = punycode.ucs2.decode(input);
3851
3851
  for (let i = 0; i < decoded.length; ++i) {
3852
- output3 += percentEncodeChar(decoded[i], isC0ControlPercentEncode);
3852
+ output2 += percentEncodeChar(decoded[i], isC0ControlPercentEncode);
3853
3853
  }
3854
- return output3;
3854
+ return output2;
3855
3855
  }
3856
3856
  function findLongestZeroSequence(arr) {
3857
3857
  let maxIdx = null;
@@ -4476,37 +4476,37 @@
4476
4476
  return true;
4477
4477
  };
4478
4478
  function serializeURL(url, excludeFragment) {
4479
- let output3 = url.scheme + ":";
4479
+ let output2 = url.scheme + ":";
4480
4480
  if (url.host !== null) {
4481
- output3 += "//";
4481
+ output2 += "//";
4482
4482
  if (url.username !== "" || url.password !== "") {
4483
- output3 += url.username;
4483
+ output2 += url.username;
4484
4484
  if (url.password !== "") {
4485
- output3 += ":" + url.password;
4485
+ output2 += ":" + url.password;
4486
4486
  }
4487
- output3 += "@";
4487
+ output2 += "@";
4488
4488
  }
4489
- output3 += serializeHost(url.host);
4489
+ output2 += serializeHost(url.host);
4490
4490
  if (url.port !== null) {
4491
- output3 += ":" + url.port;
4491
+ output2 += ":" + url.port;
4492
4492
  }
4493
4493
  } else if (url.host === null && url.scheme === "file") {
4494
- output3 += "//";
4494
+ output2 += "//";
4495
4495
  }
4496
4496
  if (url.cannotBeABaseURL) {
4497
- output3 += url.path[0];
4497
+ output2 += url.path[0];
4498
4498
  } else {
4499
4499
  for (const string of url.path) {
4500
- output3 += "/" + string;
4500
+ output2 += "/" + string;
4501
4501
  }
4502
4502
  }
4503
4503
  if (url.query !== null) {
4504
- output3 += "?" + url.query;
4504
+ output2 += "?" + url.query;
4505
4505
  }
4506
4506
  if (!excludeFragment && url.fragment !== null) {
4507
- output3 += "#" + url.fragment;
4507
+ output2 += "#" + url.fragment;
4508
4508
  }
4509
- return output3;
4509
+ return output2;
4510
4510
  }
4511
4511
  function serializeOrigin(tuple) {
4512
4512
  let result = tuple.scheme + "://";
@@ -6450,19 +6450,19 @@
6450
6450
  return "GraphQLError";
6451
6451
  }
6452
6452
  toString() {
6453
- let output3 = this.message;
6453
+ let output2 = this.message;
6454
6454
  if (this.nodes) {
6455
6455
  for (const node of this.nodes) {
6456
6456
  if (node.loc) {
6457
- output3 += "\n\n" + (0, _printLocation.printLocation)(node.loc);
6457
+ output2 += "\n\n" + (0, _printLocation.printLocation)(node.loc);
6458
6458
  }
6459
6459
  }
6460
6460
  } else if (this.source && this.locations) {
6461
6461
  for (const location of this.locations) {
6462
- output3 += "\n\n" + (0, _printLocation.printSourceLocation)(this.source, location);
6462
+ output2 += "\n\n" + (0, _printLocation.printSourceLocation)(this.source, location);
6463
6463
  }
6464
6464
  }
6465
- return output3;
6465
+ return output2;
6466
6466
  }
6467
6467
  toJSON() {
6468
6468
  const formattedError = {
@@ -18777,7 +18777,7 @@ spurious results.`);
18777
18777
  module.exports = iterate;
18778
18778
  function iterate(list, iterator, state, callback) {
18779
18779
  var key = state["keyedList"] ? state["keyedList"][state.index] : state.index;
18780
- state.jobs[key] = runJob(iterator, key, list[key], function(error, output3) {
18780
+ state.jobs[key] = runJob(iterator, key, list[key], function(error, output2) {
18781
18781
  if (!(key in state.jobs)) {
18782
18782
  return;
18783
18783
  }
@@ -18785,7 +18785,7 @@ spurious results.`);
18785
18785
  if (error) {
18786
18786
  abort(state);
18787
18787
  } else {
18788
- state.results[key] = output3;
18788
+ state.results[key] = output2;
18789
18789
  }
18790
18790
  callback(error, state.results);
18791
18791
  });
@@ -20547,8 +20547,8 @@ spurious results.`);
20547
20547
  const ret3 = wasm$1.retd(addr, len);
20548
20548
  return Instruction.__wrap(ret3);
20549
20549
  }
20550
- function aloc(bytes3) {
20551
- const ret3 = wasm$1.aloc(bytes3);
20550
+ function aloc(bytes2) {
20551
+ const ret3 = wasm$1.aloc(bytes2);
20552
20552
  return Instruction.__wrap(ret3);
20553
20553
  }
20554
20554
  function mcl(dst_addr, len) {
@@ -21762,9 +21762,9 @@ spurious results.`);
21762
21762
  * Construct the instruction from its parts.
21763
21763
  * @param {RegId} bytes
21764
21764
  */
21765
- constructor(bytes3) {
21766
- _assertClass(bytes3, RegId);
21767
- var ptr0 = bytes3.__destroy_into_raw();
21765
+ constructor(bytes2) {
21766
+ _assertClass(bytes2, RegId);
21767
+ var ptr0 = bytes2.__destroy_into_raw();
21768
21768
  const ret3 = wasm$1.aloc_new_typescript(ptr0);
21769
21769
  this.__wbg_ptr = ret3 >>> 0;
21770
21770
  return this;
@@ -28301,8 +28301,8 @@ spurious results.`);
28301
28301
  }
28302
28302
  }
28303
28303
  }
28304
- const bytes3 = await module2.arrayBuffer();
28305
- return await WebAssembly.instantiate(bytes3, imports);
28304
+ const bytes2 = await module2.arrayBuffer();
28305
+ return await WebAssembly.instantiate(bytes2, imports);
28306
28306
  } else {
28307
28307
  const instance = await WebAssembly.instantiate(module2, imports);
28308
28308
  if (instance instanceof WebAssembly.Instance) {
@@ -30707,12 +30707,12 @@ spurious results.`);
30707
30707
  createDebug.skips = [];
30708
30708
  createDebug.formatters = {};
30709
30709
  function selectColor(namespace) {
30710
- var hash4 = 0;
30710
+ var hash3 = 0;
30711
30711
  for (var i = 0; i < namespace.length; i++) {
30712
- hash4 = (hash4 << 5) - hash4 + namespace.charCodeAt(i);
30713
- hash4 |= 0;
30712
+ hash3 = (hash3 << 5) - hash3 + namespace.charCodeAt(i);
30713
+ hash3 |= 0;
30714
30714
  }
30715
- return createDebug.colors[Math.abs(hash4) % createDebug.colors.length];
30715
+ return createDebug.colors[Math.abs(hash3) % createDebug.colors.length];
30716
30716
  }
30717
30717
  createDebug.selectColor = selectColor;
30718
30718
  function createDebug(namespace) {
@@ -31614,11 +31614,11 @@ spurious results.`);
31614
31614
  if (lengths.length > 0 && !lengths.includes(b.length))
31615
31615
  throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
31616
31616
  }
31617
- function hash(hash4) {
31618
- if (typeof hash4 !== "function" || typeof hash4.create !== "function")
31617
+ function hash(hash3) {
31618
+ if (typeof hash3 !== "function" || typeof hash3.create !== "function")
31619
31619
  throw new Error("Hash should be wrapped by utils.wrapConstructor");
31620
- number(hash4.outputLen);
31621
- number(hash4.blockLen);
31620
+ number(hash3.outputLen);
31621
+ number(hash3.blockLen);
31622
31622
  }
31623
31623
  function exists(instance, checkFinished = true) {
31624
31624
  if (instance.destroyed)
@@ -31713,25 +31713,25 @@ spurious results.`);
31713
31713
  }
31714
31714
 
31715
31715
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/_sha2.js
31716
- function setBigUint64(view, byteOffset, value, isLE3) {
31716
+ function setBigUint64(view, byteOffset, value, isLE2) {
31717
31717
  if (typeof view.setBigUint64 === "function")
31718
- return view.setBigUint64(byteOffset, value, isLE3);
31718
+ return view.setBigUint64(byteOffset, value, isLE2);
31719
31719
  const _32n2 = BigInt(32);
31720
31720
  const _u32_max = BigInt(4294967295);
31721
31721
  const wh = Number(value >> _32n2 & _u32_max);
31722
31722
  const wl = Number(value & _u32_max);
31723
- const h = isLE3 ? 4 : 0;
31724
- const l = isLE3 ? 0 : 4;
31725
- view.setUint32(byteOffset + h, wh, isLE3);
31726
- view.setUint32(byteOffset + l, wl, isLE3);
31723
+ const h = isLE2 ? 4 : 0;
31724
+ const l = isLE2 ? 0 : 4;
31725
+ view.setUint32(byteOffset + h, wh, isLE2);
31726
+ view.setUint32(byteOffset + l, wl, isLE2);
31727
31727
  }
31728
31728
  var SHA2 = class extends Hash {
31729
- constructor(blockLen, outputLen, padOffset, isLE3) {
31729
+ constructor(blockLen, outputLen, padOffset, isLE2) {
31730
31730
  super();
31731
31731
  this.blockLen = blockLen;
31732
31732
  this.outputLen = outputLen;
31733
31733
  this.padOffset = padOffset;
31734
- this.isLE = isLE3;
31734
+ this.isLE = isLE2;
31735
31735
  this.finished = false;
31736
31736
  this.length = 0;
31737
31737
  this.pos = 0;
@@ -31768,7 +31768,7 @@ spurious results.`);
31768
31768
  exists(this);
31769
31769
  output(out, this);
31770
31770
  this.finished = true;
31771
- const { buffer, view, blockLen, isLE: isLE3 } = this;
31771
+ const { buffer, view, blockLen, isLE: isLE2 } = this;
31772
31772
  let { pos } = this;
31773
31773
  buffer[pos++] = 128;
31774
31774
  this.buffer.subarray(pos).fill(0);
@@ -31778,7 +31778,7 @@ spurious results.`);
31778
31778
  }
31779
31779
  for (let i = pos; i < blockLen; i++)
31780
31780
  buffer[i] = 0;
31781
- setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE3);
31781
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE2);
31782
31782
  this.process(view, 0);
31783
31783
  const oview = createView(out);
31784
31784
  const len = this.outputLen;
@@ -31789,7 +31789,7 @@ spurious results.`);
31789
31789
  if (outLen > state.length)
31790
31790
  throw new Error("_sha2: outputLen bigger than state");
31791
31791
  for (let i = 0; i < outLen; i++)
31792
- oview.setUint32(4 * i, state[i], isLE3);
31792
+ oview.setUint32(4 * i, state[i], isLE2);
31793
31793
  }
31794
31794
  digest() {
31795
31795
  const { buffer, outputLen } = this;
@@ -31966,24 +31966,24 @@ spurious results.`);
31966
31966
 
31967
31967
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/hmac.js
31968
31968
  var HMAC = class extends Hash {
31969
- constructor(hash4, _key) {
31969
+ constructor(hash3, _key) {
31970
31970
  super();
31971
31971
  this.finished = false;
31972
31972
  this.destroyed = false;
31973
- hash(hash4);
31973
+ hash(hash3);
31974
31974
  const key = toBytes(_key);
31975
- this.iHash = hash4.create();
31975
+ this.iHash = hash3.create();
31976
31976
  if (typeof this.iHash.update !== "function")
31977
31977
  throw new Error("Expected instance of class which extends utils.Hash");
31978
31978
  this.blockLen = this.iHash.blockLen;
31979
31979
  this.outputLen = this.iHash.outputLen;
31980
31980
  const blockLen = this.blockLen;
31981
31981
  const pad3 = new Uint8Array(blockLen);
31982
- pad3.set(key.length > blockLen ? hash4.create().update(key).digest() : key);
31982
+ pad3.set(key.length > blockLen ? hash3.create().update(key).digest() : key);
31983
31983
  for (let i = 0; i < pad3.length; i++)
31984
31984
  pad3[i] ^= 54;
31985
31985
  this.iHash.update(pad3);
31986
- this.oHash = hash4.create();
31986
+ this.oHash = hash3.create();
31987
31987
  for (let i = 0; i < pad3.length; i++)
31988
31988
  pad3[i] ^= 54 ^ 92;
31989
31989
  this.oHash.update(pad3);
@@ -32026,12 +32026,12 @@ spurious results.`);
32026
32026
  this.iHash.destroy();
32027
32027
  }
32028
32028
  };
32029
- var hmac = (hash4, key, message) => new HMAC(hash4, key).update(message).digest();
32030
- hmac.create = (hash4, key) => new HMAC(hash4, key);
32029
+ var hmac = (hash3, key, message) => new HMAC(hash3, key).update(message).digest();
32030
+ hmac.create = (hash3, key) => new HMAC(hash3, key);
32031
32031
 
32032
32032
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/pbkdf2.js
32033
- function pbkdf2Init(hash4, _password, _salt, _opts) {
32034
- hash(hash4);
32033
+ function pbkdf2Init(hash3, _password, _salt, _opts) {
32034
+ hash(hash3);
32035
32035
  const opts = checkOpts({ dkLen: 32, asyncTick: 10 }, _opts);
32036
32036
  const { c, dkLen, asyncTick } = opts;
32037
32037
  number(c);
@@ -32042,7 +32042,7 @@ spurious results.`);
32042
32042
  const password = toBytes(_password);
32043
32043
  const salt = toBytes(_salt);
32044
32044
  const DK = new Uint8Array(dkLen);
32045
- const PRF = hmac.create(hash4, password);
32045
+ const PRF = hmac.create(hash3, password);
32046
32046
  const PRFSalt = PRF._cloneInto().update(salt);
32047
32047
  return { c, dkLen, asyncTick, DK, PRF, PRFSalt };
32048
32048
  }
@@ -32054,8 +32054,8 @@ spurious results.`);
32054
32054
  u.fill(0);
32055
32055
  return DK;
32056
32056
  }
32057
- function pbkdf2(hash4, password, salt, opts) {
32058
- const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash4, password, salt, opts);
32057
+ function pbkdf2(hash3, password, salt, opts) {
32058
+ const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash3, password, salt, opts);
32059
32059
  let prfW;
32060
32060
  const arr = new Uint8Array(4);
32061
32061
  const view = createView(arr);
@@ -32382,9 +32382,9 @@ spurious results.`);
32382
32382
  throw new Error("XOF is not possible for this instance");
32383
32383
  return this.writeInto(out);
32384
32384
  }
32385
- xof(bytes3) {
32386
- number(bytes3);
32387
- return this.xofInto(new Uint8Array(bytes3));
32385
+ xof(bytes2) {
32386
+ number(bytes2);
32387
+ return this.xofInto(new Uint8Array(bytes2));
32388
32388
  }
32389
32389
  digestInto(out) {
32390
32390
  output(out, this);
@@ -32520,7 +32520,6 @@ This unreleased fuel-core build may include features and updates not yet support
32520
32520
  ErrorCode2["PARSE_FAILED"] = "parse-failed";
32521
32521
  ErrorCode2["ENCODE_ERROR"] = "encode-error";
32522
32522
  ErrorCode2["DECODE_ERROR"] = "decode-error";
32523
- ErrorCode2["INVALID_CREDENTIALS"] = "invalid-credentials";
32524
32523
  ErrorCode2["ENV_DEPENDENCY_MISSING"] = "env-dependency-missing";
32525
32524
  ErrorCode2["INVALID_TTL"] = "invalid-ttl";
32526
32525
  ErrorCode2["INVALID_INPUT_PARAMETERS"] = "invalid-input-parameters";
@@ -32531,6 +32530,8 @@ This unreleased fuel-core build may include features and updates not yet support
32531
32530
  ErrorCode2["MISSING_REQUIRED_PARAMETER"] = "missing-required-parameter";
32532
32531
  ErrorCode2["INVALID_REQUEST"] = "invalid-request";
32533
32532
  ErrorCode2["INVALID_TRANSFER_AMOUNT"] = "invalid-transfer-amount";
32533
+ ErrorCode2["INVALID_CREDENTIALS"] = "invalid-credentials";
32534
+ ErrorCode2["HASHER_LOCKED"] = "hasher-locked";
32534
32535
  ErrorCode2["GAS_PRICE_TOO_LOW"] = "gas-price-too-low";
32535
32536
  ErrorCode2["GAS_LIMIT_TOO_LOW"] = "gas-limit-too-low";
32536
32537
  ErrorCode2["MAX_FEE_TOO_LOW"] = "max-fee-too-low";
@@ -32598,6 +32599,226 @@ This unreleased fuel-core build may include features and updates not yet support
32598
32599
  var FuelError = _FuelError;
32599
32600
  __publicField2(FuelError, "CODES", ErrorCode);
32600
32601
 
32602
+ // ../math/dist/index.mjs
32603
+ var import_bn = __toESM(require_bn(), 1);
32604
+ var DEFAULT_PRECISION = 9;
32605
+ var DEFAULT_MIN_PRECISION = 3;
32606
+ var DEFAULT_DECIMAL_UNITS = 9;
32607
+ function toFixed(value, options) {
32608
+ const { precision = DEFAULT_PRECISION, minPrecision = DEFAULT_MIN_PRECISION } = options || {};
32609
+ const [valueUnits = "0", valueDecimals = "0"] = String(value || "0.0").split(".");
32610
+ const groupRegex = /(\d)(?=(\d{3})+\b)/g;
32611
+ const units = valueUnits.replace(groupRegex, "$1,");
32612
+ let decimals = valueDecimals.slice(0, precision);
32613
+ if (minPrecision < precision) {
32614
+ const trimmedDecimal = decimals.match(/.*[1-9]{1}/);
32615
+ const lastNonZeroIndex = trimmedDecimal?.[0].length || 0;
32616
+ const keepChars = Math.max(minPrecision, lastNonZeroIndex);
32617
+ decimals = decimals.slice(0, keepChars);
32618
+ }
32619
+ const decimalPortion = decimals ? `.${decimals}` : "";
32620
+ return `${units}${decimalPortion}`;
32621
+ }
32622
+ var BN = class extends import_bn.default {
32623
+ MAX_U64 = "0xFFFFFFFFFFFFFFFF";
32624
+ constructor(value, base, endian) {
32625
+ let bnValue = value;
32626
+ let bnBase = base;
32627
+ if (BN.isBN(value)) {
32628
+ bnValue = value.toArray();
32629
+ } else if (typeof value === "string" && value.slice(0, 2) === "0x") {
32630
+ bnValue = value.substring(2);
32631
+ bnBase = base || "hex";
32632
+ }
32633
+ super(bnValue == null ? 0 : bnValue, bnBase, endian);
32634
+ }
32635
+ // ANCHOR: HELPERS
32636
+ // make sure we always include `0x` in hex strings
32637
+ toString(base, length) {
32638
+ const output2 = super.toString(base, length);
32639
+ if (base === 16 || base === "hex") {
32640
+ return `0x${output2}`;
32641
+ }
32642
+ return output2;
32643
+ }
32644
+ toHex(bytesPadding) {
32645
+ const bytes2 = bytesPadding || 0;
32646
+ const bytesLength = bytes2 * 2;
32647
+ if (this.isNeg()) {
32648
+ throw new FuelError(ErrorCode.CONVERTING_FAILED, "Cannot convert negative value to hex.");
32649
+ }
32650
+ if (bytesPadding && this.byteLength() > bytesPadding) {
32651
+ throw new FuelError(
32652
+ ErrorCode.CONVERTING_FAILED,
32653
+ `Provided value ${this} is too large. It should fit within ${bytesPadding} bytes.`
32654
+ );
32655
+ }
32656
+ return this.toString(16, bytesLength);
32657
+ }
32658
+ toBytes(bytesPadding) {
32659
+ if (this.isNeg()) {
32660
+ throw new FuelError(ErrorCode.CONVERTING_FAILED, "Cannot convert negative value to bytes.");
32661
+ }
32662
+ return Uint8Array.from(this.toArray(void 0, bytesPadding));
32663
+ }
32664
+ toJSON() {
32665
+ return this.toString(16);
32666
+ }
32667
+ valueOf() {
32668
+ return this.toString();
32669
+ }
32670
+ format(options) {
32671
+ const {
32672
+ units = DEFAULT_DECIMAL_UNITS,
32673
+ precision = DEFAULT_PRECISION,
32674
+ minPrecision = DEFAULT_MIN_PRECISION
32675
+ } = options || {};
32676
+ const formattedUnits = this.formatUnits(units);
32677
+ const formattedFixed = toFixed(formattedUnits, { precision, minPrecision });
32678
+ if (!parseFloat(formattedFixed)) {
32679
+ const [, originalDecimals = "0"] = formattedUnits.split(".");
32680
+ const firstNonZero = originalDecimals.match(/[1-9]/);
32681
+ if (firstNonZero && firstNonZero.index && firstNonZero.index + 1 > precision) {
32682
+ const [valueUnits = "0"] = formattedFixed.split(".");
32683
+ return `${valueUnits}.${originalDecimals.slice(0, firstNonZero.index + 1)}`;
32684
+ }
32685
+ }
32686
+ return formattedFixed;
32687
+ }
32688
+ formatUnits(units = DEFAULT_DECIMAL_UNITS) {
32689
+ const valueUnits = this.toString().slice(0, units * -1);
32690
+ const valueDecimals = this.toString().slice(units * -1);
32691
+ const length = valueDecimals.length;
32692
+ const defaultDecimals = Array.from({ length: units - length }).fill("0").join("");
32693
+ const integerPortion = valueUnits ? `${valueUnits}.` : "0.";
32694
+ return `${integerPortion}${defaultDecimals}${valueDecimals}`;
32695
+ }
32696
+ // END ANCHOR: HELPERS
32697
+ // ANCHOR: OVERRIDES to accept better inputs
32698
+ add(v) {
32699
+ return this.caller(v, "add");
32700
+ }
32701
+ pow(v) {
32702
+ return this.caller(v, "pow");
32703
+ }
32704
+ sub(v) {
32705
+ return this.caller(v, "sub");
32706
+ }
32707
+ div(v) {
32708
+ return this.caller(v, "div");
32709
+ }
32710
+ mul(v) {
32711
+ return this.caller(v, "mul");
32712
+ }
32713
+ mod(v) {
32714
+ return this.caller(v, "mod");
32715
+ }
32716
+ divRound(v) {
32717
+ return this.caller(v, "divRound");
32718
+ }
32719
+ lt(v) {
32720
+ return this.caller(v, "lt");
32721
+ }
32722
+ lte(v) {
32723
+ return this.caller(v, "lte");
32724
+ }
32725
+ gt(v) {
32726
+ return this.caller(v, "gt");
32727
+ }
32728
+ gte(v) {
32729
+ return this.caller(v, "gte");
32730
+ }
32731
+ eq(v) {
32732
+ return this.caller(v, "eq");
32733
+ }
32734
+ cmp(v) {
32735
+ return this.caller(v, "cmp");
32736
+ }
32737
+ // END ANCHOR: OVERRIDES to accept better inputs
32738
+ // ANCHOR: OVERRIDES to output our BN type
32739
+ sqr() {
32740
+ return new BN(super.sqr().toArray());
32741
+ }
32742
+ neg() {
32743
+ return new BN(super.neg().toArray());
32744
+ }
32745
+ abs() {
32746
+ return new BN(super.abs().toArray());
32747
+ }
32748
+ toTwos(width) {
32749
+ return new BN(super.toTwos(width).toArray());
32750
+ }
32751
+ fromTwos(width) {
32752
+ return new BN(super.fromTwos(width).toArray());
32753
+ }
32754
+ // END ANCHOR: OVERRIDES to output our BN type
32755
+ // ANCHOR: OVERRIDES to avoid losing references
32756
+ caller(v, methodName) {
32757
+ const output2 = super[methodName](new BN(v));
32758
+ if (BN.isBN(output2)) {
32759
+ return new BN(output2.toArray());
32760
+ }
32761
+ if (typeof output2 === "boolean") {
32762
+ return output2;
32763
+ }
32764
+ return output2;
32765
+ }
32766
+ clone() {
32767
+ return new BN(this.toArray());
32768
+ }
32769
+ mulTo(num, out) {
32770
+ const output2 = new import_bn.default(this.toArray()).mulTo(num, out);
32771
+ return new BN(output2.toArray());
32772
+ }
32773
+ egcd(p) {
32774
+ const { a, b, gcd } = new import_bn.default(this.toArray()).egcd(p);
32775
+ return {
32776
+ a: new BN(a.toArray()),
32777
+ b: new BN(b.toArray()),
32778
+ gcd: new BN(gcd.toArray())
32779
+ };
32780
+ }
32781
+ divmod(num, mode, positive) {
32782
+ const { div, mod: mod2 } = new import_bn.default(this.toArray()).divmod(new BN(num), mode, positive);
32783
+ return {
32784
+ div: new BN(div?.toArray()),
32785
+ mod: new BN(mod2?.toArray())
32786
+ };
32787
+ }
32788
+ maxU64() {
32789
+ return this.gte(this.MAX_U64) ? new BN(this.MAX_U64) : this;
32790
+ }
32791
+ normalizeZeroToOne() {
32792
+ return this.isZero() ? new BN(1) : this;
32793
+ }
32794
+ // END ANCHOR: OVERRIDES to avoid losing references
32795
+ };
32796
+ var bn = (value, base, endian) => new BN(value, base, endian);
32797
+ bn.parseUnits = (value, units = DEFAULT_DECIMAL_UNITS) => {
32798
+ const valueToParse = value === "." ? "0." : value;
32799
+ const [valueUnits = "0", valueDecimals = "0"] = valueToParse.split(".");
32800
+ const length = valueDecimals.length;
32801
+ if (length > units) {
32802
+ throw new FuelError(
32803
+ ErrorCode.CONVERTING_FAILED,
32804
+ `Decimal can't have more than ${units} digits.`
32805
+ );
32806
+ }
32807
+ const decimals = Array.from({ length: units }).fill("0");
32808
+ decimals.splice(0, length, valueDecimals);
32809
+ const amount = `${valueUnits.replaceAll(",", "")}${decimals.join("")}`;
32810
+ return bn(amount);
32811
+ };
32812
+ function toNumber(value) {
32813
+ return bn(value).toNumber();
32814
+ }
32815
+ function toHex(value, bytesPadding) {
32816
+ return bn(value).toHex(bytesPadding);
32817
+ }
32818
+ function toBytes2(value, bytesPadding) {
32819
+ return bn(value).toBytes(bytesPadding);
32820
+ }
32821
+
32601
32822
  // ../utils/dist/index.mjs
32602
32823
  var __defProp3 = Object.defineProperty;
32603
32824
  var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -32605,9 +32826,12 @@ This unreleased fuel-core build may include features and updates not yet support
32605
32826
  __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
32606
32827
  return value;
32607
32828
  };
32608
- var arrayify = (value) => {
32829
+ var arrayify = (value, name, copy = true) => {
32609
32830
  if (value instanceof Uint8Array) {
32610
- return new Uint8Array(value);
32831
+ if (copy) {
32832
+ return new Uint8Array(value);
32833
+ }
32834
+ return value;
32611
32835
  }
32612
32836
  if (typeof value === "string" && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) {
32613
32837
  const result = new Uint8Array((value.length - 2) / 2);
@@ -32618,7 +32842,7 @@ This unreleased fuel-core build may include features and updates not yet support
32618
32842
  }
32619
32843
  return result;
32620
32844
  }
32621
- throw new FuelError(ErrorCode.PARSE_FAILED, "invalid BytesLike value");
32845
+ throw new FuelError(ErrorCode.INVALID_DATA, `invalid data - ${name || ""}`);
32622
32846
  };
32623
32847
  var concatBytes2 = (arrays) => {
32624
32848
  const byteArrays = arrays.map((array) => {
@@ -32636,15 +32860,15 @@ This unreleased fuel-core build may include features and updates not yet support
32636
32860
  return concatenated;
32637
32861
  };
32638
32862
  var concat = (arrays) => {
32639
- const bytes3 = arrays.map((v) => arrayify(v));
32640
- return concatBytes2(bytes3);
32863
+ const bytes2 = arrays.map((v) => arrayify(v));
32864
+ return concatBytes2(bytes2);
32641
32865
  };
32642
32866
  var HexCharacters = "0123456789abcdef";
32643
32867
  function hexlify(data) {
32644
- const bytes3 = arrayify(data);
32868
+ const bytes2 = arrayify(data);
32645
32869
  let result = "0x";
32646
- for (let i = 0; i < bytes3.length; i++) {
32647
- const v = bytes3[i];
32870
+ for (let i = 0; i < bytes2.length; i++) {
32871
+ const v = bytes2[i];
32648
32872
  result += HexCharacters[(v & 240) >> 4] + HexCharacters[v & 15];
32649
32873
  }
32650
32874
  return result;
@@ -32709,6 +32933,13 @@ This unreleased fuel-core build may include features and updates not yet support
32709
32933
  };
32710
32934
  var DateTime = _DateTime;
32711
32935
  __publicField3(DateTime, "TAI64_NULL", "");
32936
+ function sleep(time) {
32937
+ return new Promise((resolve) => {
32938
+ setTimeout(() => {
32939
+ resolve(true);
32940
+ }, time);
32941
+ });
32942
+ }
32712
32943
  var chainConfig_default = {
32713
32944
  chain_name: "local_testnet",
32714
32945
  consensus_parameters: {
@@ -33463,689 +33694,95 @@ This unreleased fuel-core build may include features and updates not yet support
33463
33694
  da_block_height: 0
33464
33695
  };
33465
33696
  var defaultSnapshotConfigs = {
33466
- chainConfigJson: chainConfig_default,
33467
- metadataJson: metadata_default,
33468
- stateConfigJson: stateConfig_default
33697
+ chainConfig: chainConfig_default,
33698
+ metadata: metadata_default,
33699
+ stateConfig: stateConfig_default
33469
33700
  };
33470
33701
  var defaultConsensusKey = "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298";
33471
33702
  function isDefined(value) {
33472
33703
  return value !== void 0;
33473
33704
  }
33474
-
33475
- // ../crypto/dist/index.mjs
33476
- var import_crypto7 = __toESM(__require("crypto"), 1);
33477
-
33478
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
33479
- var version = "6.7.1";
33480
-
33481
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/properties.js
33482
- function checkType(value, type3, name) {
33483
- const types = type3.split("|").map((t) => t.trim());
33484
- for (let i = 0; i < types.length; i++) {
33485
- switch (type3) {
33486
- case "any":
33487
- return;
33488
- case "bigint":
33489
- case "boolean":
33490
- case "number":
33491
- case "string":
33492
- if (typeof value === type3) {
33493
- return;
33494
- }
33495
- }
33496
- }
33497
- const error = new Error(`invalid value for type ${type3}`);
33498
- error.code = "INVALID_ARGUMENT";
33499
- error.argument = `value.${name}`;
33500
- error.value = value;
33501
- throw error;
33502
- }
33503
- function defineProperties(target, values, types) {
33504
- for (let key in values) {
33505
- let value = values[key];
33506
- const type3 = types ? types[key] : null;
33507
- if (type3) {
33508
- checkType(value, type3, key);
33509
- }
33510
- Object.defineProperty(target, key, { enumerable: true, value, writable: false });
33511
- }
33512
- }
33513
-
33514
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/errors.js
33515
- function stringify(value) {
33516
- if (value == null) {
33517
- return "null";
33518
- }
33519
- if (Array.isArray(value)) {
33520
- return "[ " + value.map(stringify).join(", ") + " ]";
33521
- }
33522
- if (value instanceof Uint8Array) {
33523
- const HEX = "0123456789abcdef";
33524
- let result = "0x";
33525
- for (let i = 0; i < value.length; i++) {
33526
- result += HEX[value[i] >> 4];
33527
- result += HEX[value[i] & 15];
33528
- }
33529
- return result;
33530
- }
33531
- if (typeof value === "object" && typeof value.toJSON === "function") {
33532
- return stringify(value.toJSON());
33533
- }
33534
- switch (typeof value) {
33535
- case "boolean":
33536
- case "symbol":
33537
- return value.toString();
33538
- case "bigint":
33539
- return BigInt(value).toString();
33540
- case "number":
33541
- return value.toString();
33542
- case "string":
33543
- return JSON.stringify(value);
33544
- case "object": {
33545
- const keys = Object.keys(value);
33546
- keys.sort();
33547
- return "{ " + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(", ") + " }";
33548
- }
33549
- }
33550
- return `[ COULD NOT SERIALIZE ]`;
33551
- }
33552
- function makeError(message, code, info) {
33553
- {
33554
- const details = [];
33555
- if (info) {
33556
- if ("message" in info || "code" in info || "name" in info) {
33557
- throw new Error(`value will overwrite populated values: ${stringify(info)}`);
33558
- }
33559
- for (const key in info) {
33560
- const value = info[key];
33561
- details.push(key + "=" + stringify(value));
33562
- }
33563
- }
33564
- details.push(`code=${code}`);
33565
- details.push(`version=${version}`);
33566
- if (details.length) {
33567
- message += " (" + details.join(", ") + ")";
33568
- }
33569
- }
33570
- let error;
33571
- switch (code) {
33572
- case "INVALID_ARGUMENT":
33573
- error = new TypeError(message);
33574
- break;
33575
- case "NUMERIC_FAULT":
33576
- case "BUFFER_OVERRUN":
33577
- error = new RangeError(message);
33578
- break;
33579
- default:
33580
- error = new Error(message);
33581
- }
33582
- defineProperties(error, { code });
33583
- if (info) {
33584
- Object.assign(error, info);
33585
- }
33586
- return error;
33587
- }
33588
- function assert(check, message, code, info) {
33589
- if (!check) {
33590
- throw makeError(message, code, info);
33591
- }
33592
- }
33593
- function assertArgument(check, message, name, value) {
33594
- assert(check, message, "INVALID_ARGUMENT", { argument: name, value });
33595
- }
33596
- var _normalizeForms = ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
33597
- try {
33598
- if ("test".normalize(form) !== "test") {
33599
- throw new Error("bad");
33600
- }
33601
- ;
33602
- if (form === "NFD") {
33603
- const check = String.fromCharCode(233).normalize("NFD");
33604
- const expected = String.fromCharCode(101, 769);
33605
- if (check !== expected) {
33606
- throw new Error("broken");
33607
- }
33608
- }
33609
- accum.push(form);
33610
- } catch (error) {
33611
- }
33612
- return accum;
33613
- }, []);
33614
- function assertNormalize(form) {
33615
- assert(_normalizeForms.indexOf(form) >= 0, "platform missing String.prototype.normalize", "UNSUPPORTED_OPERATION", {
33616
- operation: "String.prototype.normalize",
33617
- info: { form }
33618
- });
33619
- }
33620
-
33621
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/data.js
33622
- function _getBytes(value, name, copy) {
33623
- if (value instanceof Uint8Array) {
33624
- if (copy) {
33625
- return new Uint8Array(value);
33626
- }
33627
- return value;
33628
- }
33629
- if (typeof value === "string" && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) {
33630
- const result = new Uint8Array((value.length - 2) / 2);
33631
- let offset = 2;
33632
- for (let i = 0; i < result.length; i++) {
33633
- result[i] = parseInt(value.substring(offset, offset + 2), 16);
33634
- offset += 2;
33635
- }
33636
- return result;
33637
- }
33638
- assertArgument(false, "invalid BytesLike value", name || "value", value);
33639
- }
33640
- function getBytes(value, name) {
33641
- return _getBytes(value, name, false);
33642
- }
33643
- var HexCharacters2 = "0123456789abcdef";
33644
- function hexlify2(data) {
33645
- const bytes3 = getBytes(data);
33646
- let result = "0x";
33647
- for (let i = 0; i < bytes3.length; i++) {
33648
- const v = bytes3[i];
33649
- result += HexCharacters2[(v & 240) >> 4] + HexCharacters2[v & 15];
33650
- }
33651
- return result;
33652
- }
33653
- function dataSlice(data, start, end) {
33654
- const bytes3 = getBytes(data);
33655
- if (end != null && end > bytes3.length) {
33656
- assert(false, "cannot slice beyond data bounds", "BUFFER_OVERRUN", {
33657
- buffer: bytes3,
33658
- length: bytes3.length,
33659
- offset: end
33660
- });
33661
- }
33662
- return hexlify2(bytes3.slice(start == null ? 0 : start, end == null ? bytes3.length : end));
33663
- }
33664
-
33665
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/maths.js
33666
- var BN_0 = BigInt(0);
33667
- var BN_1 = BigInt(1);
33668
- var maxValue = 9007199254740991;
33669
- function getBigInt(value, name) {
33670
- switch (typeof value) {
33671
- case "bigint":
33672
- return value;
33673
- case "number":
33674
- assertArgument(Number.isInteger(value), "underflow", name || "value", value);
33675
- assertArgument(value >= -maxValue && value <= maxValue, "overflow", name || "value", value);
33676
- return BigInt(value);
33677
- case "string":
33678
- try {
33679
- if (value === "") {
33680
- throw new Error("empty string");
33681
- }
33682
- if (value[0] === "-" && value[1] !== "-") {
33683
- return -BigInt(value.substring(1));
33684
- }
33685
- return BigInt(value);
33686
- } catch (e) {
33687
- assertArgument(false, `invalid BigNumberish string: ${e.message}`, name || "value", value);
33688
- }
33689
- }
33690
- assertArgument(false, "invalid BigNumberish value", name || "value", value);
33691
- }
33692
- function getUint(value, name) {
33693
- const result = getBigInt(value, name);
33694
- assert(result >= BN_0, "unsigned value cannot be negative", "NUMERIC_FAULT", {
33695
- fault: "overflow",
33696
- operation: "getUint",
33697
- value
33698
- });
33699
- return result;
33700
- }
33701
- var Nibbles = "0123456789abcdef";
33702
- function toBigInt(value) {
33703
- if (value instanceof Uint8Array) {
33704
- let result = "0x0";
33705
- for (const v of value) {
33706
- result += Nibbles[v >> 4];
33707
- result += Nibbles[v & 15];
33708
- }
33709
- return BigInt(result);
33710
- }
33711
- return getBigInt(value);
33712
- }
33713
- function getNumber(value, name) {
33714
- switch (typeof value) {
33715
- case "bigint":
33716
- assertArgument(value >= -maxValue && value <= maxValue, "overflow", name || "value", value);
33717
- return Number(value);
33718
- case "number":
33719
- assertArgument(Number.isInteger(value), "underflow", name || "value", value);
33720
- assertArgument(value >= -maxValue && value <= maxValue, "overflow", name || "value", value);
33721
- return value;
33722
- case "string":
33723
- try {
33724
- if (value === "") {
33725
- throw new Error("empty string");
33726
- }
33727
- return getNumber(BigInt(value), name);
33728
- } catch (e) {
33729
- assertArgument(false, `invalid numeric string: ${e.message}`, name || "value", value);
33730
- }
33731
- }
33732
- assertArgument(false, "invalid numeric value", name || "value", value);
33733
- }
33734
- function toBeHex(_value, _width) {
33735
- const value = getUint(_value, "value");
33736
- let result = value.toString(16);
33737
- if (_width == null) {
33738
- if (result.length % 2) {
33739
- result = "0" + result;
33740
- }
33741
- } else {
33742
- const width = getNumber(_width, "width");
33743
- assert(width * 2 >= result.length, `value exceeds width (${width} bits)`, "NUMERIC_FAULT", {
33744
- operation: "toBeHex",
33745
- fault: "overflow",
33746
- value: _value
33747
- });
33748
- while (result.length < width * 2) {
33749
- result = "0" + result;
33750
- }
33751
- }
33752
- return "0x" + result;
33753
- }
33754
-
33755
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/base58.js
33705
+ var BN_0 = bn(0);
33706
+ var BN_58 = bn(58);
33756
33707
  var Alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
33757
33708
  var Lookup = null;
33758
33709
  function getAlpha(letter) {
33759
33710
  if (Lookup == null) {
33760
33711
  Lookup = {};
33761
33712
  for (let i = 0; i < Alphabet.length; i++) {
33762
- Lookup[Alphabet[i]] = BigInt(i);
33713
+ Lookup[Alphabet[i]] = bn(i);
33763
33714
  }
33764
33715
  }
33765
33716
  const result = Lookup[letter];
33766
- assertArgument(result != null, `invalid base58 value`, "letter", letter);
33767
- return result;
33717
+ if (result == null) {
33718
+ throw new FuelError(ErrorCode.INVALID_DATA, `invalid base58 value ${letter}`);
33719
+ }
33720
+ return bn(result);
33768
33721
  }
33769
- var BN_02 = BigInt(0);
33770
- var BN_58 = BigInt(58);
33771
33722
  function encodeBase58(_value) {
33772
- let value = toBigInt(getBytes(_value));
33723
+ const bytes2 = arrayify(_value);
33724
+ let value = bn(bytes2);
33773
33725
  let result = "";
33774
- while (value) {
33775
- result = Alphabet[Number(value % BN_58)] + result;
33776
- value /= BN_58;
33726
+ while (value.gt(BN_0)) {
33727
+ result = Alphabet[Number(value.mod(BN_58))] + result;
33728
+ value = value.div(BN_58);
33729
+ }
33730
+ for (let i = 0; i < bytes2.length; i++) {
33731
+ if (bytes2[i]) {
33732
+ break;
33733
+ }
33734
+ result = Alphabet[0] + result;
33777
33735
  }
33778
33736
  return result;
33779
33737
  }
33780
33738
  function decodeBase58(value) {
33781
- let result = BN_02;
33739
+ let result = BN_0;
33782
33740
  for (let i = 0; i < value.length; i++) {
33783
- result *= BN_58;
33784
- result += getAlpha(value[i]);
33741
+ result = result.mul(BN_58);
33742
+ result = result.add(getAlpha(value[i].toString()));
33785
33743
  }
33786
33744
  return result;
33787
33745
  }
33788
-
33789
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/utf8.js
33790
- function errorFunc(reason, offset, bytes3, output3, badCodepoint) {
33791
- assertArgument(false, `invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes3);
33792
- }
33793
- function ignoreFunc(reason, offset, bytes3, output3, badCodepoint) {
33794
- if (reason === "BAD_PREFIX" || reason === "UNEXPECTED_CONTINUE") {
33795
- let i = 0;
33796
- for (let o = offset + 1; o < bytes3.length; o++) {
33797
- if (bytes3[o] >> 6 !== 2) {
33798
- break;
33799
- }
33800
- i++;
33801
- }
33802
- return i;
33803
- }
33804
- if (reason === "OVERRUN") {
33805
- return bytes3.length - offset - 1;
33806
- }
33807
- return 0;
33808
- }
33809
- function replaceFunc(reason, offset, bytes3, output3, badCodepoint) {
33810
- if (reason === "OVERLONG") {
33811
- assertArgument(typeof badCodepoint === "number", "invalid bad code point for replacement", "badCodepoint", badCodepoint);
33812
- output3.push(badCodepoint);
33813
- return 0;
33814
- }
33815
- output3.push(65533);
33816
- return ignoreFunc(reason, offset, bytes3, output3, badCodepoint);
33817
- }
33818
- var Utf8ErrorFuncs = Object.freeze({
33819
- error: errorFunc,
33820
- ignore: ignoreFunc,
33821
- replace: replaceFunc
33822
- });
33823
- function getUtf8CodePoints(_bytes, onError) {
33824
- if (onError == null) {
33825
- onError = Utf8ErrorFuncs.error;
33826
- }
33827
- const bytes3 = getBytes(_bytes, "bytes");
33828
- const result = [];
33829
- let i = 0;
33830
- while (i < bytes3.length) {
33831
- const c = bytes3[i++];
33832
- if (c >> 7 === 0) {
33833
- result.push(c);
33834
- continue;
33835
- }
33836
- let extraLength = null;
33837
- let overlongMask = null;
33838
- if ((c & 224) === 192) {
33839
- extraLength = 1;
33840
- overlongMask = 127;
33841
- } else if ((c & 240) === 224) {
33842
- extraLength = 2;
33843
- overlongMask = 2047;
33844
- } else if ((c & 248) === 240) {
33845
- extraLength = 3;
33846
- overlongMask = 65535;
33847
- } else {
33848
- if ((c & 192) === 128) {
33849
- i += onError("UNEXPECTED_CONTINUE", i - 1, bytes3, result);
33850
- } else {
33851
- i += onError("BAD_PREFIX", i - 1, bytes3, result);
33852
- }
33853
- continue;
33854
- }
33855
- if (i - 1 + extraLength >= bytes3.length) {
33856
- i += onError("OVERRUN", i - 1, bytes3, result);
33857
- continue;
33858
- }
33859
- let res = c & (1 << 8 - extraLength - 1) - 1;
33860
- for (let j = 0; j < extraLength; j++) {
33861
- let nextChar = bytes3[i];
33862
- if ((nextChar & 192) != 128) {
33863
- i += onError("MISSING_CONTINUE", i, bytes3, result);
33864
- res = null;
33865
- break;
33866
- }
33867
- ;
33868
- res = res << 6 | nextChar & 63;
33869
- i++;
33870
- }
33871
- if (res === null) {
33872
- continue;
33873
- }
33874
- if (res > 1114111) {
33875
- i += onError("OUT_OF_RANGE", i - 1 - extraLength, bytes3, result, res);
33876
- continue;
33877
- }
33878
- if (res >= 55296 && res <= 57343) {
33879
- i += onError("UTF16_SURROGATE", i - 1 - extraLength, bytes3, result, res);
33880
- continue;
33881
- }
33882
- if (res <= overlongMask) {
33883
- i += onError("OVERLONG", i - 1 - extraLength, bytes3, result, res);
33884
- continue;
33885
- }
33886
- result.push(res);
33887
- }
33888
- return result;
33889
- }
33890
- function toUtf8Bytes(str, form) {
33891
- if (form != null) {
33892
- assertNormalize(form);
33893
- str = str.normalize(form);
33894
- }
33895
- let result = [];
33896
- for (let i = 0; i < str.length; i++) {
33897
- const c = str.charCodeAt(i);
33898
- if (c < 128) {
33899
- result.push(c);
33900
- } else if (c < 2048) {
33901
- result.push(c >> 6 | 192);
33902
- result.push(c & 63 | 128);
33903
- } else if ((c & 64512) == 55296) {
33904
- i++;
33905
- const c2 = str.charCodeAt(i);
33906
- assertArgument(i < str.length && (c2 & 64512) === 56320, "invalid surrogate pair", "str", str);
33907
- const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
33908
- result.push(pair >> 18 | 240);
33909
- result.push(pair >> 12 & 63 | 128);
33910
- result.push(pair >> 6 & 63 | 128);
33911
- result.push(pair & 63 | 128);
33912
- } else {
33913
- result.push(c >> 12 | 224);
33914
- result.push(c >> 6 & 63 | 128);
33915
- result.push(c & 63 | 128);
33916
- }
33917
- }
33918
- return new Uint8Array(result);
33919
- }
33920
- function _toUtf8String(codePoints) {
33921
- return codePoints.map((codePoint) => {
33922
- if (codePoint <= 65535) {
33923
- return String.fromCharCode(codePoint);
33924
- }
33925
- codePoint -= 65536;
33926
- return String.fromCharCode((codePoint >> 10 & 1023) + 55296, (codePoint & 1023) + 56320);
33927
- }).join("");
33928
- }
33929
- function toUtf8String(bytes3, onError) {
33930
- return _toUtf8String(getUtf8CodePoints(bytes3, onError));
33931
- }
33932
-
33933
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/crypto.js
33934
- var import_crypto2 = __require("crypto");
33935
-
33936
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/hmac.js
33937
- var locked = false;
33938
- var _computeHmac = function(algorithm, key, data) {
33939
- return (0, import_crypto2.createHmac)(algorithm, key).update(data).digest();
33940
- };
33941
- var __computeHmac = _computeHmac;
33942
- function computeHmac(algorithm, _key, _data) {
33943
- const key = getBytes(_key, "key");
33944
- const data = getBytes(_data, "data");
33945
- return hexlify2(__computeHmac(algorithm, key, data));
33946
- }
33947
- computeHmac._ = _computeHmac;
33948
- computeHmac.lock = function() {
33949
- locked = true;
33950
- };
33951
- computeHmac.register = function(func) {
33952
- if (locked) {
33953
- throw new Error("computeHmac is locked");
33954
- }
33955
- __computeHmac = func;
33956
- };
33957
- Object.freeze(computeHmac);
33958
-
33959
- // ../../node_modules/.pnpm/@noble+hashes@1.1.2/node_modules/@noble/hashes/esm/_assert.js
33960
- function number2(n) {
33961
- if (!Number.isSafeInteger(n) || n < 0)
33962
- throw new Error(`Wrong positive integer: ${n}`);
33963
- }
33964
- function bool(b) {
33965
- if (typeof b !== "boolean")
33966
- throw new Error(`Expected boolean, not ${b}`);
33967
- }
33968
- function bytes2(b, ...lengths) {
33969
- if (!(b instanceof Uint8Array))
33970
- throw new TypeError("Expected Uint8Array");
33971
- if (lengths.length > 0 && !lengths.includes(b.length))
33972
- throw new TypeError(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
33973
- }
33974
- function hash2(hash4) {
33975
- if (typeof hash4 !== "function" || typeof hash4.create !== "function")
33976
- throw new Error("Hash should be wrapped by utils.wrapConstructor");
33977
- number2(hash4.outputLen);
33978
- number2(hash4.blockLen);
33979
- }
33980
- function exists2(instance, checkFinished = true) {
33981
- if (instance.destroyed)
33982
- throw new Error("Hash instance has been destroyed");
33983
- if (checkFinished && instance.finished)
33984
- throw new Error("Hash#digest() has already been called");
33985
- }
33986
- function output2(out, instance) {
33987
- bytes2(out);
33988
- const min = instance.outputLen;
33989
- if (out.length < min) {
33990
- throw new Error(`digestInto() expects output buffer of length at least ${min}`);
33991
- }
33992
- }
33993
- var assert2 = {
33994
- number: number2,
33995
- bool,
33996
- bytes: bytes2,
33997
- hash: hash2,
33998
- exists: exists2,
33999
- output: output2
34000
- };
34001
- var assert_default = assert2;
34002
-
34003
- // ../../node_modules/.pnpm/@noble+hashes@1.1.2/node_modules/@noble/hashes/esm/utils.js
34004
- var createView2 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
34005
- var isLE2 = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
34006
- if (!isLE2)
34007
- throw new Error("Non little-endian hardware is not supported");
34008
- var hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, "0"));
34009
- function utf8ToBytes2(str) {
34010
- if (typeof str !== "string") {
34011
- throw new TypeError(`utf8ToBytes expected string, got ${typeof str}`);
34012
- }
34013
- return new TextEncoder().encode(str);
34014
- }
34015
- function toBytes2(data) {
34016
- if (typeof data === "string")
34017
- data = utf8ToBytes2(data);
34018
- if (!(data instanceof Uint8Array))
34019
- throw new TypeError(`Expected input type is Uint8Array (got ${typeof data})`);
34020
- return data;
34021
- }
34022
- var Hash2 = class {
34023
- // Safe version that clones internal state
34024
- clone() {
34025
- return this._cloneInto();
33746
+ function dataSlice(data, start, end) {
33747
+ const bytes2 = arrayify(data);
33748
+ if (end != null && end > bytes2.length) {
33749
+ throw new FuelError(ErrorCode.INVALID_DATA, "cannot slice beyond data bounds");
34026
33750
  }
34027
- };
34028
- function wrapConstructor2(hashConstructor) {
34029
- const hashC = (message) => hashConstructor().update(toBytes2(message)).digest();
34030
- const tmp = hashConstructor();
34031
- hashC.outputLen = tmp.outputLen;
34032
- hashC.blockLen = tmp.blockLen;
34033
- hashC.create = () => hashConstructor();
34034
- return hashC;
33751
+ return hexlify(bytes2.slice(start == null ? 0 : start, end == null ? bytes2.length : end));
34035
33752
  }
34036
33753
 
34037
- // ../../node_modules/.pnpm/@noble+hashes@1.1.2/node_modules/@noble/hashes/esm/_sha2.js
34038
- function setBigUint642(view, byteOffset, value, isLE3) {
34039
- if (typeof view.setBigUint64 === "function")
34040
- return view.setBigUint64(byteOffset, value, isLE3);
34041
- const _32n2 = BigInt(32);
34042
- const _u32_max = BigInt(4294967295);
34043
- const wh = Number(value >> _32n2 & _u32_max);
34044
- const wl = Number(value & _u32_max);
34045
- const h = isLE3 ? 4 : 0;
34046
- const l = isLE3 ? 0 : 4;
34047
- view.setUint32(byteOffset + h, wh, isLE3);
34048
- view.setUint32(byteOffset + l, wl, isLE3);
34049
- }
34050
- var SHA22 = class extends Hash2 {
34051
- constructor(blockLen, outputLen, padOffset, isLE3) {
34052
- super();
34053
- this.blockLen = blockLen;
34054
- this.outputLen = outputLen;
34055
- this.padOffset = padOffset;
34056
- this.isLE = isLE3;
34057
- this.finished = false;
34058
- this.length = 0;
34059
- this.pos = 0;
34060
- this.destroyed = false;
34061
- this.buffer = new Uint8Array(blockLen);
34062
- this.view = createView2(this.buffer);
34063
- }
34064
- update(data) {
34065
- assert_default.exists(this);
34066
- const { view, buffer, blockLen } = this;
34067
- data = toBytes2(data);
34068
- const len = data.length;
34069
- for (let pos = 0; pos < len; ) {
34070
- const take = Math.min(blockLen - this.pos, len - pos);
34071
- if (take === blockLen) {
34072
- const dataView = createView2(data);
34073
- for (; blockLen <= len - pos; pos += blockLen)
34074
- this.process(dataView, pos);
34075
- continue;
34076
- }
34077
- buffer.set(data.subarray(pos, pos + take), this.pos);
34078
- this.pos += take;
34079
- pos += take;
34080
- if (this.pos === blockLen) {
34081
- this.process(view, 0);
34082
- this.pos = 0;
34083
- }
34084
- }
34085
- this.length += data.length;
34086
- this.roundClean();
34087
- return this;
34088
- }
34089
- digestInto(out) {
34090
- assert_default.exists(this);
34091
- assert_default.output(out, this);
34092
- this.finished = true;
34093
- const { buffer, view, blockLen, isLE: isLE3 } = this;
34094
- let { pos } = this;
34095
- buffer[pos++] = 128;
34096
- this.buffer.subarray(pos).fill(0);
34097
- if (this.padOffset > blockLen - pos) {
34098
- this.process(view, 0);
34099
- pos = 0;
34100
- }
34101
- for (let i = pos; i < blockLen; i++)
34102
- buffer[i] = 0;
34103
- setBigUint642(view, blockLen - 8, BigInt(this.length * 8), isLE3);
34104
- this.process(view, 0);
34105
- const oview = createView2(out);
34106
- this.get().forEach((v, i) => oview.setUint32(4 * i, v, isLE3));
34107
- }
34108
- digest() {
34109
- const { buffer, outputLen } = this;
34110
- this.digestInto(buffer);
34111
- const res = buffer.slice(0, outputLen);
34112
- this.destroy();
34113
- return res;
34114
- }
34115
- _cloneInto(to) {
34116
- to || (to = new this.constructor());
34117
- to.set(...this.get());
34118
- const { blockLen, buffer, length, finished, destroyed, pos } = this;
34119
- to.length = length;
34120
- to.pos = pos;
34121
- to.finished = finished;
34122
- to.destroyed = destroyed;
34123
- if (length % blockLen)
34124
- to.buffer.set(buffer);
34125
- return to;
34126
- }
34127
- };
34128
-
34129
- // ../../node_modules/.pnpm/@noble+hashes@1.1.2/node_modules/@noble/hashes/esm/ripemd160.js
34130
- var Rho = new Uint8Array([7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8]);
34131
- var Id = Uint8Array.from({ length: 16 }, (_, i) => i);
34132
- var Pi = Id.map((i) => (9 * i + 5) % 16);
33754
+ // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/ripemd160.js
33755
+ var Rho = /* @__PURE__ */ new Uint8Array([7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8]);
33756
+ var Id = /* @__PURE__ */ Uint8Array.from({ length: 16 }, (_, i) => i);
33757
+ var Pi = /* @__PURE__ */ Id.map((i) => (9 * i + 5) % 16);
34133
33758
  var idxL = [Id];
34134
33759
  var idxR = [Pi];
34135
33760
  for (let i = 0; i < 4; i++)
34136
33761
  for (let j of [idxL, idxR])
34137
33762
  j.push(j[i].map((k) => Rho[k]));
34138
- var shifts = [
33763
+ var shifts = /* @__PURE__ */ [
34139
33764
  [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
34140
33765
  [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
34141
33766
  [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
34142
33767
  [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
34143
33768
  [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
34144
33769
  ].map((i) => new Uint8Array(i));
34145
- var shiftsL = idxL.map((idx, i) => idx.map((j) => shifts[i][j]));
34146
- var shiftsR = idxR.map((idx, i) => idx.map((j) => shifts[i][j]));
34147
- var Kl = new Uint32Array([0, 1518500249, 1859775393, 2400959708, 2840853838]);
34148
- var Kr = new Uint32Array([1352829926, 1548603684, 1836072691, 2053994217, 0]);
33770
+ var shiftsL = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts[i][j]));
33771
+ var shiftsR = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts[i][j]));
33772
+ var Kl = /* @__PURE__ */ new Uint32Array([
33773
+ 0,
33774
+ 1518500249,
33775
+ 1859775393,
33776
+ 2400959708,
33777
+ 2840853838
33778
+ ]);
33779
+ var Kr = /* @__PURE__ */ new Uint32Array([
33780
+ 1352829926,
33781
+ 1548603684,
33782
+ 1836072691,
33783
+ 2053994217,
33784
+ 0
33785
+ ]);
34149
33786
  var rotl2 = (word, shift) => word << shift | word >>> 32 - shift;
34150
33787
  function f(group, x, y, z) {
34151
33788
  if (group === 0)
@@ -34159,8 +33796,8 @@ This unreleased fuel-core build may include features and updates not yet support
34159
33796
  else
34160
33797
  return x ^ (y | ~z);
34161
33798
  }
34162
- var BUF = new Uint32Array(16);
34163
- var RIPEMD160 = class extends SHA22 {
33799
+ var BUF = /* @__PURE__ */ new Uint32Array(16);
33800
+ var RIPEMD160 = class extends SHA2 {
34164
33801
  constructor() {
34165
33802
  super(64, 20, 8, true);
34166
33803
  this.h0 = 1732584193 | 0;
@@ -34209,65 +33846,60 @@ This unreleased fuel-core build may include features and updates not yet support
34209
33846
  this.set(0, 0, 0, 0, 0);
34210
33847
  }
34211
33848
  };
34212
- var ripemd160 = wrapConstructor2(() => new RIPEMD160());
33849
+ var ripemd160 = /* @__PURE__ */ wrapConstructor(() => new RIPEMD160());
34213
33850
 
34214
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/ripemd160.js
34215
- var locked2 = false;
34216
- var _ripemd160 = function(data) {
34217
- return ripemd160(data);
33851
+ // ../crypto/dist/index.mjs
33852
+ var import_crypto2 = __toESM(__require("crypto"), 1);
33853
+ var import_crypto3 = __require("crypto");
33854
+ var import_crypto4 = __toESM(__require("crypto"), 1);
33855
+ var import_crypto5 = __toESM(__require("crypto"), 1);
33856
+ var import_crypto6 = __require("crypto");
33857
+ var scrypt2 = (params) => {
33858
+ const { password, salt, n, p, r, dklen } = params;
33859
+ const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
33860
+ return derivedKey;
34218
33861
  };
34219
- var __ripemd160 = _ripemd160;
33862
+ var keccak256 = (data) => keccak_256(data);
33863
+ var locked = false;
33864
+ var helper = (data) => ripemd160(data);
33865
+ var ripemd = helper;
34220
33866
  function ripemd1602(_data) {
34221
- const data = getBytes(_data, "data");
34222
- return hexlify2(__ripemd160(data));
33867
+ const data = arrayify(_data, "data");
33868
+ return ripemd(data);
34223
33869
  }
34224
- ripemd1602._ = _ripemd160;
34225
- ripemd1602.lock = function() {
34226
- locked2 = true;
33870
+ ripemd1602._ = helper;
33871
+ ripemd1602.lock = () => {
33872
+ locked = true;
34227
33873
  };
34228
- ripemd1602.register = function(func) {
34229
- if (locked2) {
34230
- throw new TypeError("ripemd160 is locked");
33874
+ ripemd1602.register = (func) => {
33875
+ if (locked) {
33876
+ throw new FuelError(ErrorCode.HASHER_LOCKED, "ripemd160 is locked");
34231
33877
  }
34232
- __ripemd160 = func;
33878
+ ripemd = func;
34233
33879
  };
34234
33880
  Object.freeze(ripemd1602);
34235
-
34236
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/pbkdf2.js
34237
- var locked3 = false;
34238
- var _pbkdf2 = function(password, salt, iterations, keylen, algo) {
34239
- return (0, import_crypto2.pbkdf2Sync)(password, salt, iterations, keylen, algo);
34240
- };
34241
- var __pbkdf2 = _pbkdf2;
33881
+ var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
33882
+ var locked2 = false;
33883
+ var PBKDF2 = (password, salt, iterations, keylen, algo) => (0, import_crypto3.pbkdf2Sync)(password, salt, iterations, keylen, algo);
33884
+ var pBkdf2 = PBKDF2;
34242
33885
  function pbkdf22(_password, _salt, iterations, keylen, algo) {
34243
- const password = getBytes(_password, "password");
34244
- const salt = getBytes(_salt, "salt");
34245
- return hexlify2(__pbkdf2(password, salt, iterations, keylen, algo));
33886
+ const password = arrayify(_password, "password");
33887
+ const salt = arrayify(_salt, "salt");
33888
+ return hexlify(pBkdf2(password, salt, iterations, keylen, algo));
34246
33889
  }
34247
- pbkdf22._ = _pbkdf2;
34248
- pbkdf22.lock = function() {
34249
- locked3 = true;
33890
+ pbkdf22._ = PBKDF2;
33891
+ pbkdf22.lock = () => {
33892
+ locked2 = true;
34250
33893
  };
34251
- pbkdf22.register = function(func) {
34252
- if (locked3) {
34253
- throw new Error("pbkdf2 is locked");
33894
+ pbkdf22.register = (func) => {
33895
+ if (locked2) {
33896
+ throw new FuelError(ErrorCode.HASHER_LOCKED, "pbkdf2 is locked");
34254
33897
  }
34255
- __pbkdf2 = func;
33898
+ pBkdf2 = func;
34256
33899
  };
34257
33900
  Object.freeze(pbkdf22);
34258
-
34259
- // ../crypto/dist/index.mjs
34260
- var import_crypto8 = __toESM(__require("crypto"), 1);
34261
- var import_crypto9 = __toESM(__require("crypto"), 1);
34262
- var scrypt3 = (params) => {
34263
- const { password, salt, n, p, r, dklen } = params;
34264
- const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
34265
- return derivedKey;
34266
- };
34267
- var keccak2562 = (data) => keccak_256(data);
34268
- var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
34269
- var randomBytes4 = (length) => {
34270
- const randomValues = Uint8Array.from(import_crypto8.default.randomBytes(length));
33901
+ var randomBytes2 = (length) => {
33902
+ const randomValues = Uint8Array.from(import_crypto4.default.randomBytes(length));
34271
33903
  return randomValues;
34272
33904
  };
34273
33905
  var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
@@ -34278,11 +33910,11 @@ This unreleased fuel-core build may include features and updates not yet support
34278
33910
  return arrayify(key);
34279
33911
  };
34280
33912
  var encrypt = async (password, data) => {
34281
- const iv = randomBytes4(16);
34282
- const salt = randomBytes4(32);
33913
+ const iv = randomBytes2(16);
33914
+ const salt = randomBytes2(32);
34283
33915
  const secret = keyFromPassword(password, salt);
34284
33916
  const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
34285
- const cipher = await import_crypto7.default.createCipheriv(ALGORITHM, secret, iv);
33917
+ const cipher = await import_crypto2.default.createCipheriv(ALGORITHM, secret, iv);
34286
33918
  let cipherData = cipher.update(dataBuffer);
34287
33919
  cipherData = Buffer.concat([cipherData, cipher.final()]);
34288
33920
  return {
@@ -34296,7 +33928,7 @@ This unreleased fuel-core build may include features and updates not yet support
34296
33928
  const salt = bufferFromString(keystore.salt);
34297
33929
  const secret = keyFromPassword(password, salt);
34298
33930
  const encryptedText = bufferFromString(keystore.data);
34299
- const decipher = await import_crypto7.default.createDecipheriv(ALGORITHM, secret, iv);
33931
+ const decipher = await import_crypto2.default.createDecipheriv(ALGORITHM, secret, iv);
34300
33932
  const decrypted = decipher.update(encryptedText);
34301
33933
  const deBuff = Buffer.concat([decrypted, decipher.final()]);
34302
33934
  const decryptedData = Buffer.from(deBuff).toString("utf-8");
@@ -34307,26 +33939,48 @@ This unreleased fuel-core build may include features and updates not yet support
34307
33939
  }
34308
33940
  };
34309
33941
  async function encryptJsonWalletData(data, key, iv) {
34310
- const cipher = await import_crypto9.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
33942
+ const cipher = await import_crypto5.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
34311
33943
  const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
34312
33944
  return new Uint8Array(encrypted);
34313
33945
  }
34314
33946
  async function decryptJsonWalletData(data, key, iv) {
34315
- const decipher = import_crypto9.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
33947
+ const decipher = import_crypto5.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
34316
33948
  const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
34317
33949
  return new Uint8Array(decrypted);
34318
33950
  }
33951
+ var locked3 = false;
33952
+ var COMPUTEHMAC = (algorithm, key, data) => (0, import_crypto6.createHmac)(algorithm, key).update(data).digest();
33953
+ var computeHMAC = COMPUTEHMAC;
33954
+ function computeHmac(algorithm, _key, _data) {
33955
+ const key = arrayify(_key, "key");
33956
+ const data = arrayify(_data, "data");
33957
+ return hexlify(computeHMAC(algorithm, key, data));
33958
+ }
33959
+ computeHmac._ = COMPUTEHMAC;
33960
+ computeHmac.lock = () => {
33961
+ locked3 = true;
33962
+ };
33963
+ computeHmac.register = (func) => {
33964
+ if (locked3) {
33965
+ throw new FuelError(ErrorCode.HASHER_LOCKED, "computeHmac is locked");
33966
+ }
33967
+ computeHMAC = func;
33968
+ };
33969
+ Object.freeze(computeHmac);
34319
33970
  var api = {
34320
33971
  bufferFromString,
34321
33972
  stringFromBuffer,
34322
33973
  decrypt,
34323
33974
  encrypt,
34324
33975
  keyFromPassword,
34325
- randomBytes: randomBytes4,
34326
- scrypt: scrypt3,
34327
- keccak256: keccak2562,
33976
+ randomBytes: randomBytes2,
33977
+ scrypt: scrypt2,
33978
+ keccak256,
34328
33979
  decryptJsonWalletData,
34329
- encryptJsonWalletData
33980
+ encryptJsonWalletData,
33981
+ computeHmac,
33982
+ pbkdf2: pbkdf22,
33983
+ ripemd160: ripemd1602
34330
33984
  };
34331
33985
  var node_default = api;
34332
33986
  var {
@@ -34337,17 +33991,20 @@ This unreleased fuel-core build may include features and updates not yet support
34337
33991
  randomBytes: randomBytes22,
34338
33992
  stringFromBuffer: stringFromBuffer2,
34339
33993
  scrypt: scrypt22,
34340
- keccak256: keccak25622,
33994
+ keccak256: keccak2562,
34341
33995
  decryptJsonWalletData: decryptJsonWalletData2,
34342
- encryptJsonWalletData: encryptJsonWalletData2
33996
+ encryptJsonWalletData: encryptJsonWalletData2,
33997
+ computeHmac: computeHmac2,
33998
+ pbkdf2: pbkdf222,
33999
+ ripemd160: ripemd16022
34343
34000
  } = node_default;
34344
34001
 
34345
34002
  // ../hasher/dist/index.mjs
34346
- function sha2563(data) {
34003
+ function sha2562(data) {
34347
34004
  return hexlify(sha256(arrayify(data)));
34348
34005
  }
34349
- function hash3(data) {
34350
- return sha2563(data);
34006
+ function hash2(data) {
34007
+ return sha2562(data);
34351
34008
  }
34352
34009
  function uint64ToBytesBE(value) {
34353
34010
  const bigIntValue = BigInt(value);
@@ -34357,7 +34014,7 @@ This unreleased fuel-core build may include features and updates not yet support
34357
34014
  return new Uint8Array(dataView.buffer);
34358
34015
  }
34359
34016
  function hashMessage(msg) {
34360
- return hash3(bufferFromString2(msg, "utf-8"));
34017
+ return hash2(bufferFromString2(msg, "utf-8"));
34361
34018
  }
34362
34019
 
34363
34020
  // ../interfaces/dist/index.mjs
@@ -34421,7 +34078,7 @@ This unreleased fuel-core build may include features and updates not yet support
34421
34078
  };
34422
34079
  var getRandomB256 = () => hexlify(randomBytes22(32));
34423
34080
  var clearFirst12BytesFromB256 = (b256) => {
34424
- let bytes3;
34081
+ let bytes2;
34425
34082
  try {
34426
34083
  if (!isB256(b256)) {
34427
34084
  throw new FuelError(
@@ -34429,15 +34086,15 @@ This unreleased fuel-core build may include features and updates not yet support
34429
34086
  `Invalid Bech32 Address: ${b256}.`
34430
34087
  );
34431
34088
  }
34432
- bytes3 = getBytesFromBech32(toBech32(b256));
34433
- bytes3 = hexlify(bytes3.fill(0, 0, 12));
34089
+ bytes2 = getBytesFromBech32(toBech32(b256));
34090
+ bytes2 = hexlify(bytes2.fill(0, 0, 12));
34434
34091
  } catch (error) {
34435
34092
  throw new FuelError(
34436
34093
  FuelError.CODES.PARSE_FAILED,
34437
34094
  `Cannot generate EVM Address B256 from: ${b256}.`
34438
34095
  );
34439
34096
  }
34440
- return bytes3;
34097
+ return bytes2;
34441
34098
  };
34442
34099
  var padFirst12BytesOfEvmAddress = (address) => {
34443
34100
  if (!isEvmAddress(address)) {
@@ -34646,226 +34303,6 @@ This unreleased fuel-core build may include features and updates not yet support
34646
34303
  }
34647
34304
  };
34648
34305
 
34649
- // ../math/dist/index.mjs
34650
- var import_bn = __toESM(require_bn(), 1);
34651
- var DEFAULT_PRECISION = 9;
34652
- var DEFAULT_MIN_PRECISION = 3;
34653
- var DEFAULT_DECIMAL_UNITS = 9;
34654
- function toFixed(value, options) {
34655
- const { precision = DEFAULT_PRECISION, minPrecision = DEFAULT_MIN_PRECISION } = options || {};
34656
- const [valueUnits = "0", valueDecimals = "0"] = String(value || "0.0").split(".");
34657
- const groupRegex = /(\d)(?=(\d{3})+\b)/g;
34658
- const units = valueUnits.replace(groupRegex, "$1,");
34659
- let decimals = valueDecimals.slice(0, precision);
34660
- if (minPrecision < precision) {
34661
- const trimmedDecimal = decimals.match(/.*[1-9]{1}/);
34662
- const lastNonZeroIndex = trimmedDecimal?.[0].length || 0;
34663
- const keepChars = Math.max(minPrecision, lastNonZeroIndex);
34664
- decimals = decimals.slice(0, keepChars);
34665
- }
34666
- const decimalPortion = decimals ? `.${decimals}` : "";
34667
- return `${units}${decimalPortion}`;
34668
- }
34669
- var BN = class extends import_bn.default {
34670
- MAX_U64 = "0xFFFFFFFFFFFFFFFF";
34671
- constructor(value, base, endian) {
34672
- let bnValue = value;
34673
- let bnBase = base;
34674
- if (BN.isBN(value)) {
34675
- bnValue = value.toArray();
34676
- } else if (typeof value === "string" && value.slice(0, 2) === "0x") {
34677
- bnValue = value.substring(2);
34678
- bnBase = base || "hex";
34679
- }
34680
- super(bnValue == null ? 0 : bnValue, bnBase, endian);
34681
- }
34682
- // ANCHOR: HELPERS
34683
- // make sure we always include `0x` in hex strings
34684
- toString(base, length) {
34685
- const output3 = super.toString(base, length);
34686
- if (base === 16 || base === "hex") {
34687
- return `0x${output3}`;
34688
- }
34689
- return output3;
34690
- }
34691
- toHex(bytesPadding) {
34692
- const bytes3 = bytesPadding || 0;
34693
- const bytesLength = bytes3 * 2;
34694
- if (this.isNeg()) {
34695
- throw new FuelError(ErrorCode.CONVERTING_FAILED, "Cannot convert negative value to hex.");
34696
- }
34697
- if (bytesPadding && this.byteLength() > bytesPadding) {
34698
- throw new FuelError(
34699
- ErrorCode.CONVERTING_FAILED,
34700
- `Provided value ${this} is too large. It should fit within ${bytesPadding} bytes.`
34701
- );
34702
- }
34703
- return this.toString(16, bytesLength);
34704
- }
34705
- toBytes(bytesPadding) {
34706
- if (this.isNeg()) {
34707
- throw new FuelError(ErrorCode.CONVERTING_FAILED, "Cannot convert negative value to bytes.");
34708
- }
34709
- return Uint8Array.from(this.toArray(void 0, bytesPadding));
34710
- }
34711
- toJSON() {
34712
- return this.toString(16);
34713
- }
34714
- valueOf() {
34715
- return this.toString();
34716
- }
34717
- format(options) {
34718
- const {
34719
- units = DEFAULT_DECIMAL_UNITS,
34720
- precision = DEFAULT_PRECISION,
34721
- minPrecision = DEFAULT_MIN_PRECISION
34722
- } = options || {};
34723
- const formattedUnits = this.formatUnits(units);
34724
- const formattedFixed = toFixed(formattedUnits, { precision, minPrecision });
34725
- if (!parseFloat(formattedFixed)) {
34726
- const [, originalDecimals = "0"] = formattedUnits.split(".");
34727
- const firstNonZero = originalDecimals.match(/[1-9]/);
34728
- if (firstNonZero && firstNonZero.index && firstNonZero.index + 1 > precision) {
34729
- const [valueUnits = "0"] = formattedFixed.split(".");
34730
- return `${valueUnits}.${originalDecimals.slice(0, firstNonZero.index + 1)}`;
34731
- }
34732
- }
34733
- return formattedFixed;
34734
- }
34735
- formatUnits(units = DEFAULT_DECIMAL_UNITS) {
34736
- const valueUnits = this.toString().slice(0, units * -1);
34737
- const valueDecimals = this.toString().slice(units * -1);
34738
- const length = valueDecimals.length;
34739
- const defaultDecimals = Array.from({ length: units - length }).fill("0").join("");
34740
- const integerPortion = valueUnits ? `${valueUnits}.` : "0.";
34741
- return `${integerPortion}${defaultDecimals}${valueDecimals}`;
34742
- }
34743
- // END ANCHOR: HELPERS
34744
- // ANCHOR: OVERRIDES to accept better inputs
34745
- add(v) {
34746
- return this.caller(v, "add");
34747
- }
34748
- pow(v) {
34749
- return this.caller(v, "pow");
34750
- }
34751
- sub(v) {
34752
- return this.caller(v, "sub");
34753
- }
34754
- div(v) {
34755
- return this.caller(v, "div");
34756
- }
34757
- mul(v) {
34758
- return this.caller(v, "mul");
34759
- }
34760
- mod(v) {
34761
- return this.caller(v, "mod");
34762
- }
34763
- divRound(v) {
34764
- return this.caller(v, "divRound");
34765
- }
34766
- lt(v) {
34767
- return this.caller(v, "lt");
34768
- }
34769
- lte(v) {
34770
- return this.caller(v, "lte");
34771
- }
34772
- gt(v) {
34773
- return this.caller(v, "gt");
34774
- }
34775
- gte(v) {
34776
- return this.caller(v, "gte");
34777
- }
34778
- eq(v) {
34779
- return this.caller(v, "eq");
34780
- }
34781
- cmp(v) {
34782
- return this.caller(v, "cmp");
34783
- }
34784
- // END ANCHOR: OVERRIDES to accept better inputs
34785
- // ANCHOR: OVERRIDES to output our BN type
34786
- sqr() {
34787
- return new BN(super.sqr().toArray());
34788
- }
34789
- neg() {
34790
- return new BN(super.neg().toArray());
34791
- }
34792
- abs() {
34793
- return new BN(super.abs().toArray());
34794
- }
34795
- toTwos(width) {
34796
- return new BN(super.toTwos(width).toArray());
34797
- }
34798
- fromTwos(width) {
34799
- return new BN(super.fromTwos(width).toArray());
34800
- }
34801
- // END ANCHOR: OVERRIDES to output our BN type
34802
- // ANCHOR: OVERRIDES to avoid losing references
34803
- caller(v, methodName) {
34804
- const output3 = super[methodName](new BN(v));
34805
- if (BN.isBN(output3)) {
34806
- return new BN(output3.toArray());
34807
- }
34808
- if (typeof output3 === "boolean") {
34809
- return output3;
34810
- }
34811
- return output3;
34812
- }
34813
- clone() {
34814
- return new BN(this.toArray());
34815
- }
34816
- mulTo(num, out) {
34817
- const output3 = new import_bn.default(this.toArray()).mulTo(num, out);
34818
- return new BN(output3.toArray());
34819
- }
34820
- egcd(p) {
34821
- const { a, b, gcd } = new import_bn.default(this.toArray()).egcd(p);
34822
- return {
34823
- a: new BN(a.toArray()),
34824
- b: new BN(b.toArray()),
34825
- gcd: new BN(gcd.toArray())
34826
- };
34827
- }
34828
- divmod(num, mode, positive) {
34829
- const { div, mod: mod2 } = new import_bn.default(this.toArray()).divmod(new BN(num), mode, positive);
34830
- return {
34831
- div: new BN(div?.toArray()),
34832
- mod: new BN(mod2?.toArray())
34833
- };
34834
- }
34835
- maxU64() {
34836
- return this.gte(this.MAX_U64) ? new BN(this.MAX_U64) : this;
34837
- }
34838
- normalizeZeroToOne() {
34839
- return this.isZero() ? new BN(1) : this;
34840
- }
34841
- // END ANCHOR: OVERRIDES to avoid losing references
34842
- };
34843
- var bn = (value, base, endian) => new BN(value, base, endian);
34844
- bn.parseUnits = (value, units = DEFAULT_DECIMAL_UNITS) => {
34845
- const valueToParse = value === "." ? "0." : value;
34846
- const [valueUnits = "0", valueDecimals = "0"] = valueToParse.split(".");
34847
- const length = valueDecimals.length;
34848
- if (length > units) {
34849
- throw new FuelError(
34850
- ErrorCode.CONVERTING_FAILED,
34851
- `Decimal can't have more than ${units} digits.`
34852
- );
34853
- }
34854
- const decimals = Array.from({ length: units }).fill("0");
34855
- decimals.splice(0, length, valueDecimals);
34856
- const amount = `${valueUnits.replaceAll(",", "")}${decimals.join("")}`;
34857
- return bn(amount);
34858
- };
34859
- function toNumber2(value) {
34860
- return bn(value).toNumber();
34861
- }
34862
- function toHex(value, bytesPadding) {
34863
- return bn(value).toHex(bytesPadding);
34864
- }
34865
- function toBytes3(value, bytesPadding) {
34866
- return bn(value).toBytes(bytesPadding);
34867
- }
34868
-
34869
34306
  // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
34870
34307
  function _isPlaceholder(a) {
34871
34308
  return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
@@ -34882,11 +34319,72 @@ This unreleased fuel-core build may include features and updates not yet support
34882
34319
  };
34883
34320
  }
34884
34321
 
34322
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry2.js
34323
+ function _curry2(fn) {
34324
+ return function f2(a, b) {
34325
+ switch (arguments.length) {
34326
+ case 0:
34327
+ return f2;
34328
+ case 1:
34329
+ return _isPlaceholder(a) ? f2 : _curry1(function(_b) {
34330
+ return fn(a, _b);
34331
+ });
34332
+ default:
34333
+ return _isPlaceholder(a) && _isPlaceholder(b) ? f2 : _isPlaceholder(a) ? _curry1(function(_a) {
34334
+ return fn(_a, b);
34335
+ }) : _isPlaceholder(b) ? _curry1(function(_b) {
34336
+ return fn(a, _b);
34337
+ }) : fn(a, b);
34338
+ }
34339
+ };
34340
+ }
34341
+
34342
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry3.js
34343
+ function _curry3(fn) {
34344
+ return function f3(a, b, c) {
34345
+ switch (arguments.length) {
34346
+ case 0:
34347
+ return f3;
34348
+ case 1:
34349
+ return _isPlaceholder(a) ? f3 : _curry2(function(_b, _c) {
34350
+ return fn(a, _b, _c);
34351
+ });
34352
+ case 2:
34353
+ return _isPlaceholder(a) && _isPlaceholder(b) ? f3 : _isPlaceholder(a) ? _curry2(function(_a, _c) {
34354
+ return fn(_a, b, _c);
34355
+ }) : _isPlaceholder(b) ? _curry2(function(_b, _c) {
34356
+ return fn(a, _b, _c);
34357
+ }) : _curry1(function(_c) {
34358
+ return fn(a, b, _c);
34359
+ });
34360
+ default:
34361
+ return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3 : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function(_a, _b) {
34362
+ return fn(_a, _b, c);
34363
+ }) : _isPlaceholder(a) && _isPlaceholder(c) ? _curry2(function(_a, _c) {
34364
+ return fn(_a, b, _c);
34365
+ }) : _isPlaceholder(b) && _isPlaceholder(c) ? _curry2(function(_b, _c) {
34366
+ return fn(a, _b, _c);
34367
+ }) : _isPlaceholder(a) ? _curry1(function(_a) {
34368
+ return fn(_a, b, c);
34369
+ }) : _isPlaceholder(b) ? _curry1(function(_b) {
34370
+ return fn(a, _b, c);
34371
+ }) : _isPlaceholder(c) ? _curry1(function(_c) {
34372
+ return fn(a, b, _c);
34373
+ }) : fn(a, b, c);
34374
+ }
34375
+ };
34376
+ }
34377
+
34885
34378
  // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
34886
34379
  var isArray_default = Array.isArray || function _isArray(val) {
34887
34380
  return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
34888
34381
  };
34889
34382
 
34383
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_has.js
34384
+ function _has(prop, obj) {
34385
+ return Object.prototype.hasOwnProperty.call(obj, prop);
34386
+ }
34387
+
34890
34388
  // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
34891
34389
  var type = /* @__PURE__ */ _curry1(function type2(val) {
34892
34390
  return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
@@ -34903,6 +34401,11 @@ This unreleased fuel-core build may include features and updates not yet support
34903
34401
  return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
34904
34402
  };
34905
34403
 
34404
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isObject.js
34405
+ function _isObject(x) {
34406
+ return Object.prototype.toString.call(x) === "[object Object]";
34407
+ }
34408
+
34906
34409
  // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
34907
34410
  var isInteger_default = Number.isInteger || function _isInteger(n) {
34908
34411
  return n << 0 === n;
@@ -35016,6 +34519,46 @@ This unreleased fuel-core build may include features and updates not yet support
35016
34519
  });
35017
34520
  var clone_default = clone;
35018
34521
 
34522
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/mergeWithKey.js
34523
+ var mergeWithKey = /* @__PURE__ */ _curry3(function mergeWithKey2(fn, l, r) {
34524
+ var result = {};
34525
+ var k;
34526
+ l = l || {};
34527
+ r = r || {};
34528
+ for (k in l) {
34529
+ if (_has(k, l)) {
34530
+ result[k] = _has(k, r) ? fn(k, l[k], r[k]) : l[k];
34531
+ }
34532
+ }
34533
+ for (k in r) {
34534
+ if (_has(k, r) && !_has(k, result)) {
34535
+ result[k] = r[k];
34536
+ }
34537
+ }
34538
+ return result;
34539
+ });
34540
+ var mergeWithKey_default = mergeWithKey;
34541
+
34542
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/mergeDeepWithKey.js
34543
+ var mergeDeepWithKey = /* @__PURE__ */ _curry3(function mergeDeepWithKey2(fn, lObj, rObj) {
34544
+ return mergeWithKey_default(function(k, lVal, rVal) {
34545
+ if (_isObject(lVal) && _isObject(rVal)) {
34546
+ return mergeDeepWithKey2(fn, lVal, rVal);
34547
+ } else {
34548
+ return fn(k, lVal, rVal);
34549
+ }
34550
+ }, lObj, rObj);
34551
+ });
34552
+ var mergeDeepWithKey_default = mergeDeepWithKey;
34553
+
34554
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/mergeDeepRight.js
34555
+ var mergeDeepRight = /* @__PURE__ */ _curry2(function mergeDeepRight2(lObj, rObj) {
34556
+ return mergeDeepWithKey_default(function(k, lVal, rVal) {
34557
+ return rVal;
34558
+ }, lObj, rObj);
34559
+ });
34560
+ var mergeDeepRight_default = mergeDeepRight;
34561
+
35019
34562
  // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
35020
34563
  var hasProtoTrim = typeof String.prototype.trim === "function";
35021
34564
 
@@ -35052,6 +34595,316 @@ This unreleased fuel-core build may include features and updates not yet support
35052
34595
  return coinQuantities;
35053
34596
  };
35054
34597
 
34598
+ // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
34599
+ var version = "6.7.1";
34600
+
34601
+ // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/properties.js
34602
+ function checkType(value, type3, name) {
34603
+ const types = type3.split("|").map((t) => t.trim());
34604
+ for (let i = 0; i < types.length; i++) {
34605
+ switch (type3) {
34606
+ case "any":
34607
+ return;
34608
+ case "bigint":
34609
+ case "boolean":
34610
+ case "number":
34611
+ case "string":
34612
+ if (typeof value === type3) {
34613
+ return;
34614
+ }
34615
+ }
34616
+ }
34617
+ const error = new Error(`invalid value for type ${type3}`);
34618
+ error.code = "INVALID_ARGUMENT";
34619
+ error.argument = `value.${name}`;
34620
+ error.value = value;
34621
+ throw error;
34622
+ }
34623
+ function defineProperties(target, values, types) {
34624
+ for (let key in values) {
34625
+ let value = values[key];
34626
+ const type3 = types ? types[key] : null;
34627
+ if (type3) {
34628
+ checkType(value, type3, key);
34629
+ }
34630
+ Object.defineProperty(target, key, { enumerable: true, value, writable: false });
34631
+ }
34632
+ }
34633
+
34634
+ // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/errors.js
34635
+ function stringify(value) {
34636
+ if (value == null) {
34637
+ return "null";
34638
+ }
34639
+ if (Array.isArray(value)) {
34640
+ return "[ " + value.map(stringify).join(", ") + " ]";
34641
+ }
34642
+ if (value instanceof Uint8Array) {
34643
+ const HEX = "0123456789abcdef";
34644
+ let result = "0x";
34645
+ for (let i = 0; i < value.length; i++) {
34646
+ result += HEX[value[i] >> 4];
34647
+ result += HEX[value[i] & 15];
34648
+ }
34649
+ return result;
34650
+ }
34651
+ if (typeof value === "object" && typeof value.toJSON === "function") {
34652
+ return stringify(value.toJSON());
34653
+ }
34654
+ switch (typeof value) {
34655
+ case "boolean":
34656
+ case "symbol":
34657
+ return value.toString();
34658
+ case "bigint":
34659
+ return BigInt(value).toString();
34660
+ case "number":
34661
+ return value.toString();
34662
+ case "string":
34663
+ return JSON.stringify(value);
34664
+ case "object": {
34665
+ const keys = Object.keys(value);
34666
+ keys.sort();
34667
+ return "{ " + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(", ") + " }";
34668
+ }
34669
+ }
34670
+ return `[ COULD NOT SERIALIZE ]`;
34671
+ }
34672
+ function makeError(message, code, info) {
34673
+ {
34674
+ const details = [];
34675
+ if (info) {
34676
+ if ("message" in info || "code" in info || "name" in info) {
34677
+ throw new Error(`value will overwrite populated values: ${stringify(info)}`);
34678
+ }
34679
+ for (const key in info) {
34680
+ const value = info[key];
34681
+ details.push(key + "=" + stringify(value));
34682
+ }
34683
+ }
34684
+ details.push(`code=${code}`);
34685
+ details.push(`version=${version}`);
34686
+ if (details.length) {
34687
+ message += " (" + details.join(", ") + ")";
34688
+ }
34689
+ }
34690
+ let error;
34691
+ switch (code) {
34692
+ case "INVALID_ARGUMENT":
34693
+ error = new TypeError(message);
34694
+ break;
34695
+ case "NUMERIC_FAULT":
34696
+ case "BUFFER_OVERRUN":
34697
+ error = new RangeError(message);
34698
+ break;
34699
+ default:
34700
+ error = new Error(message);
34701
+ }
34702
+ defineProperties(error, { code });
34703
+ if (info) {
34704
+ Object.assign(error, info);
34705
+ }
34706
+ return error;
34707
+ }
34708
+ function assert(check, message, code, info) {
34709
+ if (!check) {
34710
+ throw makeError(message, code, info);
34711
+ }
34712
+ }
34713
+ function assertArgument(check, message, name, value) {
34714
+ assert(check, message, "INVALID_ARGUMENT", { argument: name, value });
34715
+ }
34716
+ var _normalizeForms = ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
34717
+ try {
34718
+ if ("test".normalize(form) !== "test") {
34719
+ throw new Error("bad");
34720
+ }
34721
+ ;
34722
+ if (form === "NFD") {
34723
+ const check = String.fromCharCode(233).normalize("NFD");
34724
+ const expected = String.fromCharCode(101, 769);
34725
+ if (check !== expected) {
34726
+ throw new Error("broken");
34727
+ }
34728
+ }
34729
+ accum.push(form);
34730
+ } catch (error) {
34731
+ }
34732
+ return accum;
34733
+ }, []);
34734
+ function assertNormalize(form) {
34735
+ assert(_normalizeForms.indexOf(form) >= 0, "platform missing String.prototype.normalize", "UNSUPPORTED_OPERATION", {
34736
+ operation: "String.prototype.normalize",
34737
+ info: { form }
34738
+ });
34739
+ }
34740
+
34741
+ // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/data.js
34742
+ function _getBytes(value, name, copy) {
34743
+ if (value instanceof Uint8Array) {
34744
+ if (copy) {
34745
+ return new Uint8Array(value);
34746
+ }
34747
+ return value;
34748
+ }
34749
+ if (typeof value === "string" && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) {
34750
+ const result = new Uint8Array((value.length - 2) / 2);
34751
+ let offset = 2;
34752
+ for (let i = 0; i < result.length; i++) {
34753
+ result[i] = parseInt(value.substring(offset, offset + 2), 16);
34754
+ offset += 2;
34755
+ }
34756
+ return result;
34757
+ }
34758
+ assertArgument(false, "invalid BytesLike value", name || "value", value);
34759
+ }
34760
+ function getBytes(value, name) {
34761
+ return _getBytes(value, name, false);
34762
+ }
34763
+
34764
+ // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/utf8.js
34765
+ function errorFunc(reason, offset, bytes2, output2, badCodepoint) {
34766
+ assertArgument(false, `invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes2);
34767
+ }
34768
+ function ignoreFunc(reason, offset, bytes2, output2, badCodepoint) {
34769
+ if (reason === "BAD_PREFIX" || reason === "UNEXPECTED_CONTINUE") {
34770
+ let i = 0;
34771
+ for (let o = offset + 1; o < bytes2.length; o++) {
34772
+ if (bytes2[o] >> 6 !== 2) {
34773
+ break;
34774
+ }
34775
+ i++;
34776
+ }
34777
+ return i;
34778
+ }
34779
+ if (reason === "OVERRUN") {
34780
+ return bytes2.length - offset - 1;
34781
+ }
34782
+ return 0;
34783
+ }
34784
+ function replaceFunc(reason, offset, bytes2, output2, badCodepoint) {
34785
+ if (reason === "OVERLONG") {
34786
+ assertArgument(typeof badCodepoint === "number", "invalid bad code point for replacement", "badCodepoint", badCodepoint);
34787
+ output2.push(badCodepoint);
34788
+ return 0;
34789
+ }
34790
+ output2.push(65533);
34791
+ return ignoreFunc(reason, offset, bytes2, output2, badCodepoint);
34792
+ }
34793
+ var Utf8ErrorFuncs = Object.freeze({
34794
+ error: errorFunc,
34795
+ ignore: ignoreFunc,
34796
+ replace: replaceFunc
34797
+ });
34798
+ function getUtf8CodePoints(_bytes, onError) {
34799
+ if (onError == null) {
34800
+ onError = Utf8ErrorFuncs.error;
34801
+ }
34802
+ const bytes2 = getBytes(_bytes, "bytes");
34803
+ const result = [];
34804
+ let i = 0;
34805
+ while (i < bytes2.length) {
34806
+ const c = bytes2[i++];
34807
+ if (c >> 7 === 0) {
34808
+ result.push(c);
34809
+ continue;
34810
+ }
34811
+ let extraLength = null;
34812
+ let overlongMask = null;
34813
+ if ((c & 224) === 192) {
34814
+ extraLength = 1;
34815
+ overlongMask = 127;
34816
+ } else if ((c & 240) === 224) {
34817
+ extraLength = 2;
34818
+ overlongMask = 2047;
34819
+ } else if ((c & 248) === 240) {
34820
+ extraLength = 3;
34821
+ overlongMask = 65535;
34822
+ } else {
34823
+ if ((c & 192) === 128) {
34824
+ i += onError("UNEXPECTED_CONTINUE", i - 1, bytes2, result);
34825
+ } else {
34826
+ i += onError("BAD_PREFIX", i - 1, bytes2, result);
34827
+ }
34828
+ continue;
34829
+ }
34830
+ if (i - 1 + extraLength >= bytes2.length) {
34831
+ i += onError("OVERRUN", i - 1, bytes2, result);
34832
+ continue;
34833
+ }
34834
+ let res = c & (1 << 8 - extraLength - 1) - 1;
34835
+ for (let j = 0; j < extraLength; j++) {
34836
+ let nextChar = bytes2[i];
34837
+ if ((nextChar & 192) != 128) {
34838
+ i += onError("MISSING_CONTINUE", i, bytes2, result);
34839
+ res = null;
34840
+ break;
34841
+ }
34842
+ ;
34843
+ res = res << 6 | nextChar & 63;
34844
+ i++;
34845
+ }
34846
+ if (res === null) {
34847
+ continue;
34848
+ }
34849
+ if (res > 1114111) {
34850
+ i += onError("OUT_OF_RANGE", i - 1 - extraLength, bytes2, result, res);
34851
+ continue;
34852
+ }
34853
+ if (res >= 55296 && res <= 57343) {
34854
+ i += onError("UTF16_SURROGATE", i - 1 - extraLength, bytes2, result, res);
34855
+ continue;
34856
+ }
34857
+ if (res <= overlongMask) {
34858
+ i += onError("OVERLONG", i - 1 - extraLength, bytes2, result, res);
34859
+ continue;
34860
+ }
34861
+ result.push(res);
34862
+ }
34863
+ return result;
34864
+ }
34865
+ function toUtf8Bytes(str, form) {
34866
+ if (form != null) {
34867
+ assertNormalize(form);
34868
+ str = str.normalize(form);
34869
+ }
34870
+ let result = [];
34871
+ for (let i = 0; i < str.length; i++) {
34872
+ const c = str.charCodeAt(i);
34873
+ if (c < 128) {
34874
+ result.push(c);
34875
+ } else if (c < 2048) {
34876
+ result.push(c >> 6 | 192);
34877
+ result.push(c & 63 | 128);
34878
+ } else if ((c & 64512) == 55296) {
34879
+ i++;
34880
+ const c2 = str.charCodeAt(i);
34881
+ assertArgument(i < str.length && (c2 & 64512) === 56320, "invalid surrogate pair", "str", str);
34882
+ const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
34883
+ result.push(pair >> 18 | 240);
34884
+ result.push(pair >> 12 & 63 | 128);
34885
+ result.push(pair >> 6 & 63 | 128);
34886
+ result.push(pair & 63 | 128);
34887
+ } else {
34888
+ result.push(c >> 12 | 224);
34889
+ result.push(c >> 6 & 63 | 128);
34890
+ result.push(c & 63 | 128);
34891
+ }
34892
+ }
34893
+ return new Uint8Array(result);
34894
+ }
34895
+ function _toUtf8String(codePoints) {
34896
+ return codePoints.map((codePoint) => {
34897
+ if (codePoint <= 65535) {
34898
+ return String.fromCharCode(codePoint);
34899
+ }
34900
+ codePoint -= 65536;
34901
+ return String.fromCharCode((codePoint >> 10 & 1023) + 55296, (codePoint & 1023) + 56320);
34902
+ }).join("");
34903
+ }
34904
+ function toUtf8String(bytes2, onError) {
34905
+ return _toUtf8String(getUtf8CodePoints(bytes2, onError));
34906
+ }
34907
+
35055
34908
  // ../abi-coder/dist/index.mjs
35056
34909
  var __defProp4 = Object.defineProperty;
35057
34910
  var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -35157,24 +35010,24 @@ This unreleased fuel-core build may include features and updates not yet support
35157
35010
  super("bigNumber", baseType, encodedLengths[baseType]);
35158
35011
  }
35159
35012
  encode(value) {
35160
- let bytes3;
35013
+ let bytes2;
35161
35014
  try {
35162
- bytes3 = toBytes3(value, this.encodedLength);
35015
+ bytes2 = toBytes2(value, this.encodedLength);
35163
35016
  } catch (error) {
35164
35017
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.type}.`);
35165
35018
  }
35166
- return bytes3;
35019
+ return bytes2;
35167
35020
  }
35168
35021
  decode(data, offset) {
35169
35022
  if (data.length < this.encodedLength) {
35170
35023
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} data size.`);
35171
35024
  }
35172
- let bytes3 = data.slice(offset, offset + this.encodedLength);
35173
- bytes3 = bytes3.slice(0, this.encodedLength);
35174
- if (bytes3.length !== this.encodedLength) {
35025
+ let bytes2 = data.slice(offset, offset + this.encodedLength);
35026
+ bytes2 = bytes2.slice(0, this.encodedLength);
35027
+ if (bytes2.length !== this.encodedLength) {
35175
35028
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} byte data size.`);
35176
35029
  }
35177
- return [bn(bytes3), offset + this.encodedLength];
35030
+ return [bn(bytes2), offset + this.encodedLength];
35178
35031
  }
35179
35032
  };
35180
35033
  var VEC_PROPERTY_SPACE = 3;
@@ -35317,15 +35170,15 @@ This unreleased fuel-core build may include features and updates not yet support
35317
35170
  if (data.length < this.encodedLength) {
35318
35171
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid b256 data size.`);
35319
35172
  }
35320
- let bytes3 = data.slice(offset, offset + this.encodedLength);
35321
- const decoded = bn(bytes3);
35173
+ let bytes2 = data.slice(offset, offset + this.encodedLength);
35174
+ const decoded = bn(bytes2);
35322
35175
  if (decoded.isZero()) {
35323
- bytes3 = new Uint8Array(32);
35176
+ bytes2 = new Uint8Array(32);
35324
35177
  }
35325
- if (bytes3.length !== this.encodedLength) {
35178
+ if (bytes2.length !== this.encodedLength) {
35326
35179
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid b256 byte data size.`);
35327
35180
  }
35328
- return [toHex(bytes3, 32), offset + 32];
35181
+ return [toHex(bytes2, 32), offset + 32];
35329
35182
  }
35330
35183
  };
35331
35184
  var B512Coder = class extends Coder {
@@ -35348,15 +35201,15 @@ This unreleased fuel-core build may include features and updates not yet support
35348
35201
  if (data.length < this.encodedLength) {
35349
35202
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid b512 data size.`);
35350
35203
  }
35351
- let bytes3 = data.slice(offset, offset + this.encodedLength);
35352
- const decoded = bn(bytes3);
35204
+ let bytes2 = data.slice(offset, offset + this.encodedLength);
35205
+ const decoded = bn(bytes2);
35353
35206
  if (decoded.isZero()) {
35354
- bytes3 = new Uint8Array(64);
35207
+ bytes2 = new Uint8Array(64);
35355
35208
  }
35356
- if (bytes3.length !== this.encodedLength) {
35209
+ if (bytes2.length !== this.encodedLength) {
35357
35210
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid b512 byte data size.`);
35358
35211
  }
35359
- return [toHex(bytes3, this.encodedLength), offset + this.encodedLength];
35212
+ return [toHex(bytes2, this.encodedLength), offset + this.encodedLength];
35360
35213
  }
35361
35214
  };
35362
35215
  var BooleanCoder = class extends Coder {
@@ -35376,23 +35229,23 @@ This unreleased fuel-core build may include features and updates not yet support
35376
35229
  if (!isTrueBool) {
35377
35230
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid boolean value.`);
35378
35231
  }
35379
- const output3 = toBytes3(value ? 1 : 0, this.paddingLength);
35232
+ const output2 = toBytes2(value ? 1 : 0, this.paddingLength);
35380
35233
  if (this.options.isRightPadded) {
35381
- return output3.reverse();
35234
+ return output2.reverse();
35382
35235
  }
35383
- return output3;
35236
+ return output2;
35384
35237
  }
35385
35238
  decode(data, offset) {
35386
35239
  if (data.length < this.paddingLength) {
35387
35240
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean data size.`);
35388
35241
  }
35389
- let bytes3;
35242
+ let bytes2;
35390
35243
  if (this.options.isRightPadded) {
35391
- bytes3 = data.slice(offset, offset + 1);
35244
+ bytes2 = data.slice(offset, offset + 1);
35392
35245
  } else {
35393
- bytes3 = data.slice(offset, offset + this.paddingLength);
35246
+ bytes2 = data.slice(offset, offset + this.paddingLength);
35394
35247
  }
35395
- const decodedValue = bn(bytes3);
35248
+ const decodedValue = bn(bytes2);
35396
35249
  if (decodedValue.isZero()) {
35397
35250
  return [false, offset + this.paddingLength];
35398
35251
  }
@@ -35499,7 +35352,7 @@ This unreleased fuel-core build may include features and updates not yet support
35499
35352
  let newOffset = offset;
35500
35353
  let decoded;
35501
35354
  [decoded, newOffset] = new BigNumberCoder("u64").decode(data, newOffset);
35502
- const caseIndex = toNumber2(decoded);
35355
+ const caseIndex = toNumber(decoded);
35503
35356
  const caseKey = Object.keys(this.coders)[caseIndex];
35504
35357
  if (!caseKey) {
35505
35358
  throw new FuelError(
@@ -35535,9 +35388,9 @@ This unreleased fuel-core build may include features and updates not yet support
35535
35388
  const [decoded, newOffset] = super.decode(data, offset);
35536
35389
  return [this.toOption(decoded), newOffset];
35537
35390
  }
35538
- toOption(output3) {
35539
- if (output3 && "Some" in output3) {
35540
- return output3.Some;
35391
+ toOption(output2) {
35392
+ if (output2 && "Some" in output2) {
35393
+ return output2.Some;
35541
35394
  }
35542
35395
  return void 0;
35543
35396
  }
@@ -35572,30 +35425,30 @@ This unreleased fuel-core build may include features and updates not yet support
35572
35425
  this.options = options;
35573
35426
  }
35574
35427
  encode(value) {
35575
- let bytes3;
35428
+ let bytes2;
35576
35429
  try {
35577
- bytes3 = toBytes3(value);
35430
+ bytes2 = toBytes2(value);
35578
35431
  } catch (error) {
35579
35432
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}.`);
35580
35433
  }
35581
- if (bytes3.length > this.length) {
35434
+ if (bytes2.length > this.length) {
35582
35435
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}, too many bytes.`);
35583
35436
  }
35584
- const output3 = toBytes3(bytes3, this.paddingLength);
35437
+ const output2 = toBytes2(bytes2, this.paddingLength);
35585
35438
  if (this.baseType !== "u8") {
35586
- return output3;
35439
+ return output2;
35587
35440
  }
35588
- return this.options.isRightPadded ? output3.reverse() : output3;
35441
+ return this.options.isRightPadded ? output2.reverse() : output2;
35589
35442
  }
35590
35443
  decodeU8(data, offset) {
35591
- let bytes3;
35444
+ let bytes2;
35592
35445
  if (this.options.isRightPadded) {
35593
- bytes3 = data.slice(offset, offset + 1);
35446
+ bytes2 = data.slice(offset, offset + 1);
35594
35447
  } else {
35595
- bytes3 = data.slice(offset, offset + this.paddingLength);
35596
- bytes3 = bytes3.slice(this.paddingLength - this.length, this.paddingLength);
35448
+ bytes2 = data.slice(offset, offset + this.paddingLength);
35449
+ bytes2 = bytes2.slice(this.paddingLength - this.length, this.paddingLength);
35597
35450
  }
35598
- return [toNumber2(bytes3), offset + this.paddingLength];
35451
+ return [toNumber(bytes2), offset + this.paddingLength];
35599
35452
  }
35600
35453
  decode(data, offset) {
35601
35454
  if (data.length < this.paddingLength) {
@@ -35604,12 +35457,12 @@ This unreleased fuel-core build may include features and updates not yet support
35604
35457
  if (this.baseType === "u8") {
35605
35458
  return this.decodeU8(data, offset);
35606
35459
  }
35607
- let bytes3 = data.slice(offset, offset + this.paddingLength);
35608
- bytes3 = bytes3.slice(8 - this.length, 8);
35609
- if (bytes3.length !== this.paddingLength - (this.paddingLength - this.length)) {
35460
+ let bytes2 = data.slice(offset, offset + this.paddingLength);
35461
+ bytes2 = bytes2.slice(8 - this.length, 8);
35462
+ if (bytes2.length !== this.paddingLength - (this.paddingLength - this.length)) {
35610
35463
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number byte data size.`);
35611
35464
  }
35612
- return [toNumber2(bytes3), offset + 8];
35465
+ return [toNumber(bytes2), offset + 8];
35613
35466
  }
35614
35467
  };
35615
35468
  var RawSliceCoder = class extends Coder {
@@ -35707,11 +35560,11 @@ This unreleased fuel-core build may include features and updates not yet support
35707
35560
  if (data.length < this.encodedLength) {
35708
35561
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string data size.`);
35709
35562
  }
35710
- const bytes3 = data.slice(offset, offset + this.length);
35711
- if (bytes3.length !== this.length) {
35563
+ const bytes2 = data.slice(offset, offset + this.length);
35564
+ if (bytes2.length !== this.length) {
35712
35565
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string byte data size.`);
35713
35566
  }
35714
- const value = toUtf8String(bytes3);
35567
+ const value = toUtf8String(bytes2);
35715
35568
  const padding = this.#paddingLength;
35716
35569
  return [value, offset + this.length + padding];
35717
35570
  }
@@ -36122,17 +35975,17 @@ This unreleased fuel-core build may include features and updates not yet support
36122
35975
  if (!isTrueBool) {
36123
35976
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid boolean value.`);
36124
35977
  }
36125
- return toBytes3(value ? 1 : 0, this.encodedLength);
35978
+ return toBytes2(value ? 1 : 0, this.encodedLength);
36126
35979
  }
36127
35980
  decode(data, offset) {
36128
35981
  if (data.length < this.encodedLength) {
36129
35982
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean data size.`);
36130
35983
  }
36131
- const bytes3 = bn(data.slice(offset, offset + this.encodedLength));
36132
- if (bytes3.isZero()) {
35984
+ const bytes2 = bn(data.slice(offset, offset + this.encodedLength));
35985
+ if (bytes2.isZero()) {
36133
35986
  return [false, offset + this.encodedLength];
36134
35987
  }
36135
- if (!bytes3.eq(bn(1))) {
35988
+ if (!bytes2.eq(bn(1))) {
36136
35989
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean value.`);
36137
35990
  }
36138
35991
  return [true, offset + this.encodedLength];
@@ -36143,9 +35996,9 @@ This unreleased fuel-core build may include features and updates not yet support
36143
35996
  super("struct", "struct Bytes", WORD_SIZE);
36144
35997
  }
36145
35998
  encode(value) {
36146
- const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
36147
- const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
36148
- return new Uint8Array([...lengthBytes, ...bytes3]);
35999
+ const bytes2 = value instanceof Uint8Array ? value : new Uint8Array(value);
36000
+ const lengthBytes = new BigNumberCoder("u64").encode(bytes2.length);
36001
+ return new Uint8Array([...lengthBytes, ...bytes2]);
36149
36002
  }
36150
36003
  decode(data, offset) {
36151
36004
  if (data.length < WORD_SIZE) {
@@ -36214,7 +36067,7 @@ This unreleased fuel-core build may include features and updates not yet support
36214
36067
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid enum data size.`);
36215
36068
  }
36216
36069
  const caseBytes = new BigNumberCoder("u64").decode(data, offset)[0];
36217
- const caseIndex = toNumber2(caseBytes);
36070
+ const caseIndex = toNumber(caseBytes);
36218
36071
  const caseKey = Object.keys(this.coders)[caseIndex];
36219
36072
  if (!caseKey) {
36220
36073
  throw new FuelError(
@@ -36253,26 +36106,26 @@ This unreleased fuel-core build may include features and updates not yet support
36253
36106
  this.length = length;
36254
36107
  }
36255
36108
  encode(value) {
36256
- let bytes3;
36109
+ let bytes2;
36257
36110
  try {
36258
- bytes3 = toBytes3(value);
36111
+ bytes2 = toBytes2(value);
36259
36112
  } catch (error) {
36260
36113
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}.`);
36261
36114
  }
36262
- if (bytes3.length > this.length) {
36115
+ if (bytes2.length > this.length) {
36263
36116
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}, too many bytes.`);
36264
36117
  }
36265
- return toBytes3(bytes3, this.length);
36118
+ return toBytes2(bytes2, this.length);
36266
36119
  }
36267
36120
  decode(data, offset) {
36268
36121
  if (data.length < this.encodedLength) {
36269
36122
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number data size.`);
36270
36123
  }
36271
- const bytes3 = data.slice(offset, offset + this.length);
36272
- if (bytes3.length !== this.encodedLength) {
36124
+ const bytes2 = data.slice(offset, offset + this.length);
36125
+ if (bytes2.length !== this.encodedLength) {
36273
36126
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number byte data size.`);
36274
36127
  }
36275
- return [toNumber2(bytes3), offset + this.length];
36128
+ return [toNumber(bytes2), offset + this.length];
36276
36129
  }
36277
36130
  };
36278
36131
  var OptionCoder2 = class extends EnumCoder2 {
@@ -36290,9 +36143,9 @@ This unreleased fuel-core build may include features and updates not yet support
36290
36143
  const [decoded, newOffset] = super.decode(data, offset);
36291
36144
  return [this.toOption(decoded), newOffset];
36292
36145
  }
36293
- toOption(output3) {
36294
- if (output3 && "Some" in output3) {
36295
- return output3.Some;
36146
+ toOption(output2) {
36147
+ if (output2 && "Some" in output2) {
36148
+ return output2.Some;
36296
36149
  }
36297
36150
  return void 0;
36298
36151
  }
@@ -36306,9 +36159,9 @@ This unreleased fuel-core build may include features and updates not yet support
36306
36159
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
36307
36160
  }
36308
36161
  const internalCoder = new ArrayCoder(new NumberCoder2("u8"), value.length);
36309
- const bytes3 = internalCoder.encode(value);
36310
- const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
36311
- return new Uint8Array([...lengthBytes, ...bytes3]);
36162
+ const bytes2 = internalCoder.encode(value);
36163
+ const lengthBytes = new BigNumberCoder("u64").encode(bytes2.length);
36164
+ return new Uint8Array([...lengthBytes, ...bytes2]);
36312
36165
  }
36313
36166
  decode(data, offset) {
36314
36167
  if (data.length < this.encodedLength) {
@@ -36331,9 +36184,9 @@ This unreleased fuel-core build may include features and updates not yet support
36331
36184
  super("struct", "struct String", WORD_SIZE);
36332
36185
  }
36333
36186
  encode(value) {
36334
- const bytes3 = toUtf8Bytes(value);
36187
+ const bytes2 = toUtf8Bytes(value);
36335
36188
  const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36336
- return new Uint8Array([...lengthBytes, ...bytes3]);
36189
+ return new Uint8Array([...lengthBytes, ...bytes2]);
36337
36190
  }
36338
36191
  decode(data, offset) {
36339
36192
  if (data.length < this.encodedLength) {
@@ -36355,9 +36208,9 @@ This unreleased fuel-core build may include features and updates not yet support
36355
36208
  super("strSlice", "str", WORD_SIZE);
36356
36209
  }
36357
36210
  encode(value) {
36358
- const bytes3 = toUtf8Bytes(value);
36211
+ const bytes2 = toUtf8Bytes(value);
36359
36212
  const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36360
- return new Uint8Array([...lengthBytes, ...bytes3]);
36213
+ return new Uint8Array([...lengthBytes, ...bytes2]);
36361
36214
  }
36362
36215
  decode(data, offset) {
36363
36216
  if (data.length < this.encodedLength) {
@@ -36366,11 +36219,11 @@ This unreleased fuel-core build may include features and updates not yet support
36366
36219
  const offsetAndLength = offset + WORD_SIZE;
36367
36220
  const lengthBytes = data.slice(offset, offsetAndLength);
36368
36221
  const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
36369
- const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
36370
- if (bytes3.length !== length) {
36222
+ const bytes2 = data.slice(offsetAndLength, offsetAndLength + length);
36223
+ if (bytes2.length !== length) {
36371
36224
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
36372
36225
  }
36373
- return [toUtf8String(bytes3), offsetAndLength + length];
36226
+ return [toUtf8String(bytes2), offsetAndLength + length];
36374
36227
  }
36375
36228
  };
36376
36229
  __publicField4(StrSliceCoder, "memorySize", 1);
@@ -36388,11 +36241,11 @@ This unreleased fuel-core build may include features and updates not yet support
36388
36241
  if (data.length < this.encodedLength) {
36389
36242
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string data size.`);
36390
36243
  }
36391
- const bytes3 = data.slice(offset, offset + this.encodedLength);
36392
- if (bytes3.length !== this.encodedLength) {
36244
+ const bytes2 = data.slice(offset, offset + this.encodedLength);
36245
+ if (bytes2.length !== this.encodedLength) {
36393
36246
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string byte data size.`);
36394
36247
  }
36395
- return [toUtf8String(bytes3), offset + this.encodedLength];
36248
+ return [toUtf8String(bytes2), offset + this.encodedLength];
36396
36249
  }
36397
36250
  };
36398
36251
  var StructCoder2 = class extends Coder {
@@ -36472,12 +36325,19 @@ This unreleased fuel-core build may include features and updates not yet support
36472
36325
  this.#isOptionVec = this.coder instanceof OptionCoder2;
36473
36326
  }
36474
36327
  encode(value) {
36475
- if (!Array.isArray(value)) {
36476
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
36328
+ if (!Array.isArray(value) && !isUint8Array(value)) {
36329
+ throw new FuelError(
36330
+ ErrorCode.ENCODE_ERROR,
36331
+ `Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.`
36332
+ );
36477
36333
  }
36478
- const bytes3 = value.map((v) => this.coder.encode(v));
36479
- const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36480
- return new Uint8Array([...lengthBytes, ...concatBytes2(bytes3)]);
36334
+ const lengthCoder = new BigNumberCoder("u64");
36335
+ if (isUint8Array(value)) {
36336
+ return new Uint8Array([...lengthCoder.encode(value.length), ...value]);
36337
+ }
36338
+ const bytes2 = value.map((v) => this.coder.encode(v));
36339
+ const lengthBytes = lengthCoder.encode(value.length);
36340
+ return new Uint8Array([...lengthBytes, ...concatBytes2(bytes2)]);
36481
36341
  }
36482
36342
  decode(data, offset) {
36483
36343
  if (!this.#isOptionVec && (data.length < this.encodedLength || data.length > MAX_BYTES)) {
@@ -36640,7 +36500,7 @@ This unreleased fuel-core build may include features and updates not yet support
36640
36500
  return `${fn.name}(${inputsSignatures.join(",")})`;
36641
36501
  }
36642
36502
  static getFunctionSelector(functionSignature) {
36643
- const hashedFunctionSignature = sha2563(bufferFromString2(functionSignature, "utf-8"));
36503
+ const hashedFunctionSignature = sha2562(bufferFromString2(functionSignature, "utf-8"));
36644
36504
  return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
36645
36505
  }
36646
36506
  #isInputDataPointer() {
@@ -36703,10 +36563,10 @@ This unreleased fuel-core build may include features and updates not yet support
36703
36563
  throw new FuelError(ErrorCode.ABI_TYPES_AND_VALUES_MISMATCH, errorMsg);
36704
36564
  }
36705
36565
  decodeArguments(data) {
36706
- const bytes3 = arrayify(data);
36566
+ const bytes2 = arrayify(data);
36707
36567
  const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
36708
36568
  if (nonEmptyInputs.length === 0) {
36709
- if (bytes3.length === 0) {
36569
+ if (bytes2.length === 0) {
36710
36570
  return void 0;
36711
36571
  }
36712
36572
  throw new FuelError(
@@ -36715,12 +36575,12 @@ This unreleased fuel-core build may include features and updates not yet support
36715
36575
  count: {
36716
36576
  types: this.jsonFn.inputs.length,
36717
36577
  nonEmptyInputs: nonEmptyInputs.length,
36718
- values: bytes3.length
36578
+ values: bytes2.length
36719
36579
  },
36720
36580
  value: {
36721
36581
  args: this.jsonFn.inputs,
36722
36582
  nonEmptyInputs,
36723
- values: bytes3
36583
+ values: bytes2
36724
36584
  }
36725
36585
  })}`
36726
36586
  );
@@ -36728,7 +36588,7 @@ This unreleased fuel-core build may include features and updates not yet support
36728
36588
  const result = nonEmptyInputs.reduce(
36729
36589
  (obj, input) => {
36730
36590
  const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
36731
- const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
36591
+ const [decodedValue, decodedValueByteSize] = coder.decode(bytes2, obj.offset);
36732
36592
  return {
36733
36593
  decoded: [...obj.decoded, decodedValue],
36734
36594
  offset: obj.offset + decodedValueByteSize
@@ -36743,11 +36603,11 @@ This unreleased fuel-core build may include features and updates not yet support
36743
36603
  if (outputAbiType.type === "()") {
36744
36604
  return [void 0, 0];
36745
36605
  }
36746
- const bytes3 = arrayify(data);
36606
+ const bytes2 = arrayify(data);
36747
36607
  const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
36748
36608
  encoding: this.encoding
36749
36609
  });
36750
- return coder.decode(bytes3, 0);
36610
+ return coder.decode(bytes2, 0);
36751
36611
  }
36752
36612
  /**
36753
36613
  * Checks if the function is read-only i.e. it only reads from storage, does not write to it.
@@ -37008,12 +36868,12 @@ This unreleased fuel-core build may include features and updates not yet support
37008
36868
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
37009
36869
  parts.push(new BigNumberCoder("u64").encode(value.amount));
37010
36870
  parts.push(arrayify(value.data || "0x"));
37011
- return sha2563(concat(parts));
36871
+ return sha2562(concat(parts));
37012
36872
  }
37013
36873
  static encodeData(messageData) {
37014
- const bytes3 = arrayify(messageData || "0x");
37015
- const dataLength2 = bytes3.length;
37016
- return new ByteArrayCoder(dataLength2).encode(bytes3);
36874
+ const bytes2 = arrayify(messageData || "0x");
36875
+ const dataLength2 = bytes2.length;
36876
+ return new ByteArrayCoder(dataLength2).encode(bytes2);
37017
36877
  }
37018
36878
  encode(value) {
37019
36879
  const parts = [];
@@ -37035,9 +36895,9 @@ This unreleased fuel-core build may include features and updates not yet support
37035
36895
  return concat(parts);
37036
36896
  }
37037
36897
  static decodeData(messageData) {
37038
- const bytes3 = arrayify(messageData);
37039
- const dataLength2 = bytes3.length;
37040
- const [data] = new ByteArrayCoder(dataLength2).decode(bytes3, 0);
36898
+ const bytes2 = arrayify(messageData);
36899
+ const dataLength2 = bytes2.length;
36900
+ const [data] = new ByteArrayCoder(dataLength2).decode(bytes2, 0);
37041
36901
  return arrayify(data);
37042
36902
  }
37043
36903
  decode(data, offset) {
@@ -37474,7 +37334,7 @@ This unreleased fuel-core build may include features and updates not yet support
37474
37334
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
37475
37335
  parts.push(new BigNumberCoder("u64").encode(value.amount));
37476
37336
  parts.push(arrayify(value.data || "0x"));
37477
- return sha2563(concat(parts));
37337
+ return sha2562(concat(parts));
37478
37338
  }
37479
37339
  encode(value) {
37480
37340
  const parts = [];
@@ -37521,7 +37381,7 @@ This unreleased fuel-core build may include features and updates not yet support
37521
37381
  var getMintedAssetId = (contractId, subId) => {
37522
37382
  const contractIdBytes = arrayify(contractId);
37523
37383
  const subIdBytes = arrayify(subId);
37524
- return sha2563(concat([contractIdBytes, subIdBytes]));
37384
+ return sha2562(concat([contractIdBytes, subIdBytes]));
37525
37385
  };
37526
37386
  var ReceiptMintCoder = class extends Coder {
37527
37387
  constructor() {
@@ -38135,7 +37995,7 @@ This unreleased fuel-core build may include features and updates not yet support
38135
37995
  numberToBytesLE: () => numberToBytesLE,
38136
37996
  numberToHexUnpadded: () => numberToHexUnpadded,
38137
37997
  numberToVarBytesBE: () => numberToVarBytesBE,
38138
- utf8ToBytes: () => utf8ToBytes3,
37998
+ utf8ToBytes: () => utf8ToBytes2,
38139
37999
  validateObject: () => validateObject
38140
38000
  });
38141
38001
  var _0n2 = BigInt(0);
@@ -38144,13 +38004,13 @@ This unreleased fuel-core build may include features and updates not yet support
38144
38004
  function isBytes3(a) {
38145
38005
  return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
38146
38006
  }
38147
- var hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
38148
- function bytesToHex(bytes3) {
38149
- if (!isBytes3(bytes3))
38007
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
38008
+ function bytesToHex(bytes2) {
38009
+ if (!isBytes3(bytes2))
38150
38010
  throw new Error("Uint8Array expected");
38151
38011
  let hex = "";
38152
- for (let i = 0; i < bytes3.length; i++) {
38153
- hex += hexes2[bytes3[i]];
38012
+ for (let i = 0; i < bytes2.length; i++) {
38013
+ hex += hexes[bytes2[i]];
38154
38014
  }
38155
38015
  return hex;
38156
38016
  }
@@ -38192,13 +38052,13 @@ This unreleased fuel-core build may include features and updates not yet support
38192
38052
  }
38193
38053
  return array;
38194
38054
  }
38195
- function bytesToNumberBE(bytes3) {
38196
- return hexToNumber(bytesToHex(bytes3));
38055
+ function bytesToNumberBE(bytes2) {
38056
+ return hexToNumber(bytesToHex(bytes2));
38197
38057
  }
38198
- function bytesToNumberLE(bytes3) {
38199
- if (!isBytes3(bytes3))
38058
+ function bytesToNumberLE(bytes2) {
38059
+ if (!isBytes3(bytes2))
38200
38060
  throw new Error("Uint8Array expected");
38201
- return hexToNumber(bytesToHex(Uint8Array.from(bytes3).reverse()));
38061
+ return hexToNumber(bytesToHex(Uint8Array.from(bytes2).reverse()));
38202
38062
  }
38203
38063
  function numberToBytesBE(n, len) {
38204
38064
  return hexToBytes(n.toString(16).padStart(len * 2, "0"));
@@ -38252,7 +38112,7 @@ This unreleased fuel-core build may include features and updates not yet support
38252
38112
  diff |= a[i] ^ b[i];
38253
38113
  return diff === 0;
38254
38114
  }
38255
- function utf8ToBytes3(str) {
38115
+ function utf8ToBytes2(str) {
38256
38116
  if (typeof str !== "string")
38257
38117
  throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
38258
38118
  return new Uint8Array(new TextEncoder().encode(str));
@@ -38571,19 +38431,19 @@ This unreleased fuel-core build may include features and updates not yet support
38571
38431
  return "GraphQLError";
38572
38432
  }
38573
38433
  toString() {
38574
- let output3 = this.message;
38434
+ let output2 = this.message;
38575
38435
  if (this.nodes) {
38576
38436
  for (const node of this.nodes) {
38577
38437
  if (node.loc) {
38578
- output3 += "\n\n" + printLocation(node.loc);
38438
+ output2 += "\n\n" + printLocation(node.loc);
38579
38439
  }
38580
38440
  }
38581
38441
  } else if (this.source && this.locations) {
38582
38442
  for (const location of this.locations) {
38583
- output3 += "\n\n" + printSourceLocation(this.source, location);
38443
+ output2 += "\n\n" + printSourceLocation(this.source, location);
38584
38444
  }
38585
38445
  }
38586
- return output3;
38446
+ return output2;
38587
38447
  }
38588
38448
  toJSON() {
38589
38449
  const formattedError = {
@@ -42597,13 +42457,13 @@ ${MessageCoinFragmentDoc}`;
42597
42457
  return {
42598
42458
  type: InputType.Coin,
42599
42459
  txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
42600
- outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
42460
+ outputIndex: toNumber(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
42601
42461
  owner: hexlify(value.owner),
42602
42462
  amount: bn(value.amount),
42603
42463
  assetId: hexlify(value.assetId),
42604
42464
  txPointer: {
42605
- blockHeight: toNumber2(arrayify(value.txPointer).slice(0, 8)),
42606
- txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
42465
+ blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
42466
+ txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
42607
42467
  },
42608
42468
  witnessIndex: value.witnessIndex,
42609
42469
  predicateGasUsed: bn(value.predicateGasUsed),
@@ -42621,8 +42481,8 @@ ${MessageCoinFragmentDoc}`;
42621
42481
  balanceRoot: ZeroBytes32,
42622
42482
  stateRoot: ZeroBytes32,
42623
42483
  txPointer: {
42624
- blockHeight: toNumber2(arrayify(value.txPointer).slice(0, 8)),
42625
- txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
42484
+ blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
42485
+ txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
42626
42486
  },
42627
42487
  contractID: hexlify(value.contractId)
42628
42488
  };
@@ -43094,15 +42954,6 @@ ${MessageCoinFragmentDoc}`;
43094
42954
  return normalize2(clone_default(root));
43095
42955
  }
43096
42956
 
43097
- // src/providers/utils/sleep.ts
43098
- function sleep(time) {
43099
- return new Promise((resolve) => {
43100
- setTimeout(() => {
43101
- resolve(true);
43102
- }, time);
43103
- });
43104
- }
43105
-
43106
42957
  // src/providers/utils/extract-tx-error.ts
43107
42958
  var assemblePanicError = (status) => {
43108
42959
  let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
@@ -43322,8 +43173,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43322
43173
  *
43323
43174
  * Pushes an output to the list without any side effects and returns the index
43324
43175
  */
43325
- pushOutput(output3) {
43326
- this.outputs.push(output3);
43176
+ pushOutput(output2) {
43177
+ this.outputs.push(output2);
43327
43178
  return this.outputs.length - 1;
43328
43179
  }
43329
43180
  /**
@@ -43407,7 +43258,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43407
43258
  */
43408
43259
  getCoinOutputs() {
43409
43260
  return this.outputs.filter(
43410
- (output3) => output3.type === OutputType.Coin
43261
+ (output2) => output2.type === OutputType.Coin
43411
43262
  );
43412
43263
  }
43413
43264
  /**
@@ -43417,7 +43268,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43417
43268
  */
43418
43269
  getChangeOutputs() {
43419
43270
  return this.outputs.filter(
43420
- (output3) => output3.type === OutputType.Change
43271
+ (output2) => output2.type === OutputType.Change
43421
43272
  );
43422
43273
  }
43423
43274
  /**
@@ -43565,7 +43416,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43565
43416
  */
43566
43417
  addChangeOutput(to, assetId) {
43567
43418
  const changeOutput = this.getChangeOutputs().find(
43568
- (output3) => hexlify(output3.assetId) === assetId
43419
+ (output2) => hexlify(output2.assetId) === assetId
43569
43420
  );
43570
43421
  if (!changeOutput) {
43571
43422
  this.pushOutput({
@@ -43763,8 +43614,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43763
43614
  return inputClone;
43764
43615
  }
43765
43616
  });
43766
- transaction.outputs = transaction.outputs.map((output3) => {
43767
- const outputClone = clone_default(output3);
43617
+ transaction.outputs = transaction.outputs.map((output2) => {
43618
+ const outputClone = clone_default(output2);
43768
43619
  switch (outputClone.type) {
43769
43620
  case OutputType.Contract: {
43770
43621
  outputClone.balanceRoot = ZeroBytes32;
@@ -43789,7 +43640,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43789
43640
  transaction.witnesses = [];
43790
43641
  const chainIdBytes = uint64ToBytesBE(chainId);
43791
43642
  const concatenatedData = concat([chainIdBytes, new TransactionCoder().encode(transaction)]);
43792
- return sha2563(concatenatedData);
43643
+ return sha2562(concatenatedData);
43793
43644
  }
43794
43645
 
43795
43646
  // src/providers/transaction-request/storage-slot.ts
@@ -43866,7 +43717,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43866
43717
  */
43867
43718
  getContractCreatedOutputs() {
43868
43719
  return this.outputs.filter(
43869
- (output3) => output3.type === OutputType.ContractCreated
43720
+ (output2) => output2.type === OutputType.ContractCreated
43870
43721
  );
43871
43722
  }
43872
43723
  /**
@@ -43992,7 +43843,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43992
43843
  */
43993
43844
  getContractOutputs() {
43994
43845
  return this.outputs.filter(
43995
- (output3) => output3.type === OutputType.Contract
43846
+ (output2) => output2.type === OutputType.Contract
43996
43847
  );
43997
43848
  }
43998
43849
  /**
@@ -44002,7 +43853,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44002
43853
  */
44003
43854
  getVariableOutputs() {
44004
43855
  return this.outputs.filter(
44005
- (output3) => output3.type === OutputType.Variable
43856
+ (output2) => output2.type === OutputType.Variable
44006
43857
  );
44007
43858
  }
44008
43859
  /**
@@ -44428,8 +44279,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44428
44279
  }) {
44429
44280
  const contractCallReceipts = getReceiptsCall(receipts);
44430
44281
  const contractOutputs = getOutputsContract(outputs);
44431
- const contractCallOperations = contractOutputs.reduce((prevOutputCallOps, output3) => {
44432
- const contractInput = getInputContractFromIndex(inputs, output3.inputIndex);
44282
+ const contractCallOperations = contractOutputs.reduce((prevOutputCallOps, output2) => {
44283
+ const contractInput = getInputContractFromIndex(inputs, output2.inputIndex);
44433
44284
  if (contractInput) {
44434
44285
  const newCallOps = contractCallReceipts.reduce((prevContractCallOps, receipt) => {
44435
44286
  if (receipt.to === contractInput.contractID) {
@@ -44483,7 +44334,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44483
44334
  let { from: fromAddress } = receipt;
44484
44335
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
44485
44336
  if (ZeroBytes32 === fromAddress) {
44486
- const change = changeOutputs.find((output3) => output3.assetId === assetId);
44337
+ const change = changeOutputs.find((output2) => output2.assetId === assetId);
44487
44338
  fromAddress = change?.to || fromAddress;
44488
44339
  }
44489
44340
  const fromType = contractInputs.some((input) => input.contractID === fromAddress) ? 0 /* contract */ : 1 /* account */;
@@ -44514,8 +44365,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44514
44365
  const coinOutputs = getOutputsCoin(outputs);
44515
44366
  const contractInputs = getInputsContract(inputs);
44516
44367
  const changeOutputs = getOutputsChange(outputs);
44517
- coinOutputs.forEach((output3) => {
44518
- const { amount, assetId, to } = output3;
44368
+ coinOutputs.forEach((output2) => {
44369
+ const { amount, assetId, to } = output2;
44519
44370
  const changeOutput = changeOutputs.find((change) => change.assetId === assetId);
44520
44371
  if (changeOutput) {
44521
44372
  operations = addOperation(operations, {
@@ -44553,7 +44404,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44553
44404
  }
44554
44405
  function getPayProducerOperations(outputs) {
44555
44406
  const coinOutputs = getOutputsCoin(outputs);
44556
- const payProducerOperations = coinOutputs.reduce((prev, output3) => {
44407
+ const payProducerOperations = coinOutputs.reduce((prev, output2) => {
44557
44408
  const operations = addOperation(prev, {
44558
44409
  name: "Pay network fee to block producer" /* payBlockProducer */,
44559
44410
  from: {
@@ -44562,12 +44413,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44562
44413
  },
44563
44414
  to: {
44564
44415
  type: 1 /* account */,
44565
- address: output3.to.toString()
44416
+ address: output2.to.toString()
44566
44417
  },
44567
44418
  assetsSent: [
44568
44419
  {
44569
- assetId: output3.assetId.toString(),
44570
- amount: output3.amount
44420
+ assetId: output2.assetId.toString(),
44421
+ amount: output2.amount
44571
44422
  }
44572
44423
  ]
44573
44424
  });
@@ -46784,11 +46635,11 @@ Supported fuel-core version: ${supportedVersion}.`
46784
46635
  }
46785
46636
  return res;
46786
46637
  }
46787
- function invert(number3, modulo) {
46788
- if (number3 === _0n3 || modulo <= _0n3) {
46789
- throw new Error(`invert: expected positive integers, got n=${number3} mod=${modulo}`);
46638
+ function invert(number2, modulo) {
46639
+ if (number2 === _0n3 || modulo <= _0n3) {
46640
+ throw new Error(`invert: expected positive integers, got n=${number2} mod=${modulo}`);
46790
46641
  }
46791
- let a = mod(number3, modulo);
46642
+ let a = mod(number2, modulo);
46792
46643
  let b = modulo;
46793
46644
  let x = _0n3, y = _1n3, u = _1n3, v = _0n3;
46794
46645
  while (a !== _0n3) {
@@ -46943,7 +46794,7 @@ Supported fuel-core version: ${supportedVersion}.`
46943
46794
  const nByteLength = Math.ceil(_nBitLength / 8);
46944
46795
  return { nBitLength: _nBitLength, nByteLength };
46945
46796
  }
46946
- function Field(ORDER, bitLen2, isLE3 = false, redef = {}) {
46797
+ function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
46947
46798
  if (ORDER <= _0n3)
46948
46799
  throw new Error(`Expected Field ORDER > 0, got ${ORDER}`);
46949
46800
  const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen2);
@@ -46984,11 +46835,11 @@ Supported fuel-core version: ${supportedVersion}.`
46984
46835
  // TODO: do we really need constant cmov?
46985
46836
  // We don't have const-time bigints anyway, so probably will be not very useful
46986
46837
  cmov: (a, b, c) => c ? b : a,
46987
- toBytes: (num) => isLE3 ? numberToBytesLE(num, BYTES) : numberToBytesBE(num, BYTES),
46988
- fromBytes: (bytes3) => {
46989
- if (bytes3.length !== BYTES)
46990
- throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes3.length}`);
46991
- return isLE3 ? bytesToNumberLE(bytes3) : bytesToNumberBE(bytes3);
46838
+ toBytes: (num) => isLE2 ? numberToBytesLE(num, BYTES) : numberToBytesBE(num, BYTES),
46839
+ fromBytes: (bytes2) => {
46840
+ if (bytes2.length !== BYTES)
46841
+ throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes2.length}`);
46842
+ return isLE2 ? bytesToNumberLE(bytes2) : bytesToNumberBE(bytes2);
46992
46843
  }
46993
46844
  });
46994
46845
  return Object.freeze(f2);
@@ -47003,15 +46854,15 @@ Supported fuel-core version: ${supportedVersion}.`
47003
46854
  const length = getFieldBytesLength(fieldOrder);
47004
46855
  return length + Math.ceil(length / 2);
47005
46856
  }
47006
- function mapHashToField(key, fieldOrder, isLE3 = false) {
46857
+ function mapHashToField(key, fieldOrder, isLE2 = false) {
47007
46858
  const len = key.length;
47008
46859
  const fieldLen = getFieldBytesLength(fieldOrder);
47009
46860
  const minLen = getMinHashLength(fieldOrder);
47010
46861
  if (len < 16 || len < minLen || len > 1024)
47011
46862
  throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`);
47012
- const num = isLE3 ? bytesToNumberBE(key) : bytesToNumberLE(key);
46863
+ const num = isLE2 ? bytesToNumberBE(key) : bytesToNumberLE(key);
47013
46864
  const reduced = mod(num, fieldOrder - _1n3) + _1n3;
47014
- return isLE3 ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
46865
+ return isLE2 ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
47015
46866
  }
47016
46867
 
47017
46868
  // ../../node_modules/.pnpm/@noble+curves@1.3.0/node_modules/@noble/curves/esm/abstract/curve.js
@@ -47219,12 +47070,12 @@ Supported fuel-core version: ${supportedVersion}.`
47219
47070
  function weierstrassPoints(opts) {
47220
47071
  const CURVE = validatePointOpts(opts);
47221
47072
  const { Fp: Fp2 } = CURVE;
47222
- const toBytes4 = CURVE.toBytes || ((_c, point, _isCompressed) => {
47073
+ const toBytes3 = CURVE.toBytes || ((_c, point, _isCompressed) => {
47223
47074
  const a = point.toAffine();
47224
47075
  return concatBytes3(Uint8Array.from([4]), Fp2.toBytes(a.x), Fp2.toBytes(a.y));
47225
47076
  });
47226
- const fromBytes = CURVE.fromBytes || ((bytes3) => {
47227
- const tail = bytes3.subarray(1);
47077
+ const fromBytes = CURVE.fromBytes || ((bytes2) => {
47078
+ const tail = bytes2.subarray(1);
47228
47079
  const x = Fp2.fromBytes(tail.subarray(0, Fp2.BYTES));
47229
47080
  const y = Fp2.fromBytes(tail.subarray(Fp2.BYTES, 2 * Fp2.BYTES));
47230
47081
  return { x, y };
@@ -47587,7 +47438,7 @@ Supported fuel-core version: ${supportedVersion}.`
47587
47438
  }
47588
47439
  toRawBytes(isCompressed = true) {
47589
47440
  this.assertValidity();
47590
- return toBytes4(Point2, this, isCompressed);
47441
+ return toBytes3(Point2, this, isCompressed);
47591
47442
  }
47592
47443
  toHex(isCompressed = true) {
47593
47444
  return bytesToHex(this.toRawBytes(isCompressed));
@@ -47644,10 +47495,10 @@ Supported fuel-core version: ${supportedVersion}.`
47644
47495
  return cat(Uint8Array.from([4]), x, Fp2.toBytes(a.y));
47645
47496
  }
47646
47497
  },
47647
- fromBytes(bytes3) {
47648
- const len = bytes3.length;
47649
- const head = bytes3[0];
47650
- const tail = bytes3.subarray(1);
47498
+ fromBytes(bytes2) {
47499
+ const len = bytes2.length;
47500
+ const head = bytes2[0];
47501
+ const tail = bytes2.subarray(1);
47651
47502
  if (len === compressedLen && (head === 2 || head === 3)) {
47652
47503
  const x = bytesToNumberBE(tail);
47653
47504
  if (!isValidFieldElement(x))
@@ -47669,15 +47520,15 @@ Supported fuel-core version: ${supportedVersion}.`
47669
47520
  }
47670
47521
  });
47671
47522
  const numToNByteStr = (num) => bytesToHex(numberToBytesBE(num, CURVE.nByteLength));
47672
- function isBiggerThanHalfOrder(number3) {
47523
+ function isBiggerThanHalfOrder(number2) {
47673
47524
  const HALF = CURVE_ORDER >> _1n5;
47674
- return number3 > HALF;
47525
+ return number2 > HALF;
47675
47526
  }
47676
47527
  function normalizeS(s) {
47677
47528
  return isBiggerThanHalfOrder(s) ? modN(-s) : s;
47678
47529
  }
47679
47530
  const slcNum = (b, from, to) => bytesToNumberBE(b.slice(from, to));
47680
- class Signature2 {
47531
+ class Signature {
47681
47532
  constructor(r, s, recovery) {
47682
47533
  this.r = r;
47683
47534
  this.s = s;
@@ -47688,13 +47539,13 @@ Supported fuel-core version: ${supportedVersion}.`
47688
47539
  static fromCompact(hex) {
47689
47540
  const l = CURVE.nByteLength;
47690
47541
  hex = ensureBytes("compactSignature", hex, l * 2);
47691
- return new Signature2(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));
47542
+ return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));
47692
47543
  }
47693
47544
  // DER encoded ECDSA signature
47694
47545
  // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
47695
47546
  static fromDER(hex) {
47696
47547
  const { r, s } = DER.toSig(ensureBytes("DER", hex));
47697
- return new Signature2(r, s);
47548
+ return new Signature(r, s);
47698
47549
  }
47699
47550
  assertValidity() {
47700
47551
  if (!isWithinCurveOrder(this.r))
@@ -47703,7 +47554,7 @@ Supported fuel-core version: ${supportedVersion}.`
47703
47554
  throw new Error("s must be 0 < s < CURVE.n");
47704
47555
  }
47705
47556
  addRecoveryBit(recovery) {
47706
- return new Signature2(this.r, this.s, recovery);
47557
+ return new Signature(this.r, this.s, recovery);
47707
47558
  }
47708
47559
  recoverPublicKey(msgHash) {
47709
47560
  const { r, s, recovery: rec } = this;
@@ -47729,7 +47580,7 @@ Supported fuel-core version: ${supportedVersion}.`
47729
47580
  return isBiggerThanHalfOrder(this.s);
47730
47581
  }
47731
47582
  normalizeS() {
47732
- return this.hasHighS() ? new Signature2(this.r, modN(-this.s), this.recovery) : this;
47583
+ return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this;
47733
47584
  }
47734
47585
  // DER-encoded
47735
47586
  toDERRawBytes() {
@@ -47801,13 +47652,13 @@ Supported fuel-core version: ${supportedVersion}.`
47801
47652
  const b = Point2.fromHex(publicB);
47802
47653
  return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
47803
47654
  }
47804
- const bits2int = CURVE.bits2int || function(bytes3) {
47805
- const num = bytesToNumberBE(bytes3);
47806
- const delta = bytes3.length * 8 - CURVE.nBitLength;
47655
+ const bits2int = CURVE.bits2int || function(bytes2) {
47656
+ const num = bytesToNumberBE(bytes2);
47657
+ const delta = bytes2.length * 8 - CURVE.nBitLength;
47807
47658
  return delta > 0 ? num >> BigInt(delta) : num;
47808
47659
  };
47809
- const bits2int_modN = CURVE.bits2int_modN || function(bytes3) {
47810
- return modN(bits2int(bytes3));
47660
+ const bits2int_modN = CURVE.bits2int_modN || function(bytes2) {
47661
+ return modN(bits2int(bytes2));
47811
47662
  };
47812
47663
  const ORDER_MASK = bitMask(CURVE.nBitLength);
47813
47664
  function int2octets(num) {
@@ -47820,18 +47671,18 @@ Supported fuel-core version: ${supportedVersion}.`
47820
47671
  function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
47821
47672
  if (["recovered", "canonical"].some((k) => k in opts))
47822
47673
  throw new Error("sign() legacy options not supported");
47823
- const { hash: hash4, randomBytes: randomBytes5 } = CURVE;
47674
+ const { hash: hash3, randomBytes: randomBytes3 } = CURVE;
47824
47675
  let { lowS, prehash, extraEntropy: ent } = opts;
47825
47676
  if (lowS == null)
47826
47677
  lowS = true;
47827
47678
  msgHash = ensureBytes("msgHash", msgHash);
47828
47679
  if (prehash)
47829
- msgHash = ensureBytes("prehashed msgHash", hash4(msgHash));
47680
+ msgHash = ensureBytes("prehashed msgHash", hash3(msgHash));
47830
47681
  const h1int = bits2int_modN(msgHash);
47831
47682
  const d = normPrivateKeyToScalar(privateKey);
47832
47683
  const seedArgs = [int2octets(d), int2octets(h1int)];
47833
47684
  if (ent != null) {
47834
- const e = ent === true ? randomBytes5(Fp2.BYTES) : ent;
47685
+ const e = ent === true ? randomBytes3(Fp2.BYTES) : ent;
47835
47686
  seedArgs.push(ensureBytes("extraEntropy", e));
47836
47687
  }
47837
47688
  const seed = concatBytes3(...seedArgs);
@@ -47854,7 +47705,7 @@ Supported fuel-core version: ${supportedVersion}.`
47854
47705
  normS = normalizeS(s);
47855
47706
  recovery ^= 1;
47856
47707
  }
47857
- return new Signature2(r, normS, recovery);
47708
+ return new Signature(r, normS, recovery);
47858
47709
  }
47859
47710
  return { seed, k2sig };
47860
47711
  }
@@ -47879,15 +47730,15 @@ Supported fuel-core version: ${supportedVersion}.`
47879
47730
  try {
47880
47731
  if (typeof sg === "string" || isBytes3(sg)) {
47881
47732
  try {
47882
- _sig = Signature2.fromDER(sg);
47733
+ _sig = Signature.fromDER(sg);
47883
47734
  } catch (derError) {
47884
47735
  if (!(derError instanceof DER.Err))
47885
47736
  throw derError;
47886
- _sig = Signature2.fromCompact(sg);
47737
+ _sig = Signature.fromCompact(sg);
47887
47738
  }
47888
47739
  } else if (typeof sg === "object" && typeof sg.r === "bigint" && typeof sg.s === "bigint") {
47889
47740
  const { r: r2, s: s2 } = sg;
47890
- _sig = new Signature2(r2, s2);
47741
+ _sig = new Signature(r2, s2);
47891
47742
  } else {
47892
47743
  throw new Error("PARSE");
47893
47744
  }
@@ -47919,21 +47770,21 @@ Supported fuel-core version: ${supportedVersion}.`
47919
47770
  sign,
47920
47771
  verify,
47921
47772
  ProjectivePoint: Point2,
47922
- Signature: Signature2,
47773
+ Signature,
47923
47774
  utils
47924
47775
  };
47925
47776
  }
47926
47777
 
47927
47778
  // ../../node_modules/.pnpm/@noble+curves@1.3.0/node_modules/@noble/curves/esm/_shortw_utils.js
47928
- function getHash(hash4) {
47779
+ function getHash(hash3) {
47929
47780
  return {
47930
- hash: hash4,
47931
- hmac: (key, ...msgs) => hmac(hash4, key, concatBytes(...msgs)),
47781
+ hash: hash3,
47782
+ hmac: (key, ...msgs) => hmac(hash3, key, concatBytes(...msgs)),
47932
47783
  randomBytes
47933
47784
  };
47934
47785
  }
47935
47786
  function createCurve(curveDef, defHash) {
47936
- const create = (hash4) => weierstrass({ ...curveDef, ...getHash(hash4) });
47787
+ const create = (hash3) => weierstrass({ ...curveDef, ...getHash(hash3) });
47937
47788
  return Object.freeze({ ...create(defHash), create });
47938
47789
  }
47939
47790
 
@@ -48035,7 +47886,7 @@ Supported fuel-core version: ${supportedVersion}.`
48035
47886
  privateKey = `0x${privateKey}`;
48036
47887
  }
48037
47888
  }
48038
- const privateKeyBytes = toBytes3(privateKey, 32);
47889
+ const privateKeyBytes = toBytes2(privateKey, 32);
48039
47890
  this.privateKey = hexlify(privateKeyBytes);
48040
47891
  this.publicKey = hexlify(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
48041
47892
  this.compressedPublicKey = hexlify(secp256k1.getPublicKey(privateKeyBytes, true));
@@ -48053,8 +47904,8 @@ Supported fuel-core version: ${supportedVersion}.`
48053
47904
  */
48054
47905
  sign(data) {
48055
47906
  const signature = secp256k1.sign(arrayify(data), arrayify(this.privateKey));
48056
- const r = toBytes3(`0x${signature.r.toString(16)}`, 32);
48057
- const s = toBytes3(`0x${signature.s.toString(16)}`, 32);
47907
+ const r = toBytes2(`0x${signature.r.toString(16)}`, 32);
47908
+ const s = toBytes2(`0x${signature.s.toString(16)}`, 32);
48058
47909
  s[0] |= (signature.recovery || 0) << 7;
48059
47910
  return hexlify(concat([r, s]));
48060
47911
  }
@@ -48106,7 +47957,7 @@ Supported fuel-core version: ${supportedVersion}.`
48106
47957
  * @returns random 32-byte hashed
48107
47958
  */
48108
47959
  static generatePrivateKey(entropy) {
48109
- return entropy ? hash3(concat([randomBytes22(32), arrayify(entropy)])) : randomBytes22(32);
47960
+ return entropy ? hash2(concat([randomBytes22(32), arrayify(entropy)])) : randomBytes22(32);
48110
47961
  }
48111
47962
  /**
48112
47963
  * Extended publicKey from a compact publicKey
@@ -48121,12 +47972,12 @@ Supported fuel-core version: ${supportedVersion}.`
48121
47972
  };
48122
47973
 
48123
47974
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
48124
- var import_crypto15 = __toESM(__require("crypto"));
47975
+ var import_crypto12 = __toESM(__require("crypto"));
48125
47976
  var rnds8Pool = new Uint8Array(256);
48126
47977
  var poolPtr = rnds8Pool.length;
48127
47978
  function rng() {
48128
47979
  if (poolPtr > rnds8Pool.length - 16) {
48129
- import_crypto15.default.randomFillSync(rnds8Pool);
47980
+ import_crypto12.default.randomFillSync(rnds8Pool);
48130
47981
  poolPtr = 0;
48131
47982
  }
48132
47983
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
@@ -48142,9 +47993,9 @@ Supported fuel-core version: ${supportedVersion}.`
48142
47993
  }
48143
47994
 
48144
47995
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
48145
- var import_crypto16 = __toESM(__require("crypto"));
47996
+ var import_crypto13 = __toESM(__require("crypto"));
48146
47997
  var native_default = {
48147
- randomUUID: import_crypto16.default.randomUUID
47998
+ randomUUID: import_crypto13.default.randomUUID
48148
47999
  };
48149
48000
 
48150
48001
  // ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
@@ -48194,7 +48045,7 @@ Supported fuel-core version: ${supportedVersion}.`
48194
48045
  const iv = randomBytes22(DEFAULT_IV_SIZE);
48195
48046
  const ciphertext = await encryptJsonWalletData2(privateKeyBuffer, key, iv);
48196
48047
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
48197
- const macHashUint8Array = keccak25622(data);
48048
+ const macHashUint8Array = keccak2562(data);
48198
48049
  const mac = stringFromBuffer2(macHashUint8Array, "hex");
48199
48050
  const keystore = {
48200
48051
  id: v4_default(),
@@ -48240,7 +48091,7 @@ Supported fuel-core version: ${supportedVersion}.`
48240
48091
  dklen
48241
48092
  });
48242
48093
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
48243
- const macHashUint8Array = keccak25622(data);
48094
+ const macHashUint8Array = keccak2562(data);
48244
48095
  const macHash = stringFromBuffer2(macHashUint8Array, "hex");
48245
48096
  if (mac !== macHash) {
48246
48097
  throw new FuelError(
@@ -50484,7 +50335,7 @@ Supported fuel-core version: ${supportedVersion}.`
50484
50335
  }
50485
50336
  }
50486
50337
  const checksumBits = entropy.length / 4;
50487
- const checksum = arrayify(sha2563(entropy))[0] & getUpperMask(checksumBits);
50338
+ const checksum = arrayify(sha2562(entropy))[0] & getUpperMask(checksumBits);
50488
50339
  indices[indices.length - 1] <<= checksumBits;
50489
50340
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
50490
50341
  return indices;
@@ -50511,7 +50362,7 @@ Supported fuel-core version: ${supportedVersion}.`
50511
50362
  const entropyBits = 32 * words.length / 3;
50512
50363
  const checksumBits = words.length / 3;
50513
50364
  const checksumMask = getUpperMask(checksumBits);
50514
- const checksum = arrayify(sha2563(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
50365
+ const checksum = arrayify(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
50515
50366
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
50516
50367
  throw new FuelError(
50517
50368
  ErrorCode.INVALID_CHECKSUM,
@@ -50608,7 +50459,7 @@ Supported fuel-core version: ${supportedVersion}.`
50608
50459
  assertMnemonic(getWords(phrase));
50609
50460
  const phraseBytes = toUtf8Bytes2(getPhrase(phrase));
50610
50461
  const salt = toUtf8Bytes2(`mnemonic${passphrase}`);
50611
- return pbkdf22(phraseBytes, salt, 2048, 64, "sha512");
50462
+ return pbkdf222(phraseBytes, salt, 2048, 64, "sha512");
50612
50463
  }
50613
50464
  /**
50614
50465
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -50670,7 +50521,7 @@ Supported fuel-core version: ${supportedVersion}.`
50670
50521
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
50671
50522
  );
50672
50523
  }
50673
- return arrayify(computeHmac("sha512", MasterSecret, seedArray));
50524
+ return arrayify(computeHmac2("sha512", MasterSecret, seedArray));
50674
50525
  }
50675
50526
  /**
50676
50527
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -50695,7 +50546,7 @@ Supported fuel-core version: ${supportedVersion}.`
50695
50546
  chainCode,
50696
50547
  concat(["0x00", privateKey])
50697
50548
  ]);
50698
- const checksum = dataSlice(sha2563(sha2563(extendedKey)), 0, 4);
50549
+ const checksum = dataSlice(sha2562(sha2562(extendedKey)), 0, 4);
50699
50550
  return encodeBase58(concat([extendedKey, checksum]));
50700
50551
  }
50701
50552
  /**
@@ -50711,7 +50562,7 @@ Supported fuel-core version: ${supportedVersion}.`
50711
50562
  * @returns A randomly generated mnemonic
50712
50563
  */
50713
50564
  static generate(size = 32, extraEntropy = "") {
50714
- const entropy = extraEntropy ? sha2563(concat([randomBytes22(size), arrayify(extraEntropy)])) : randomBytes22(size);
50565
+ const entropy = extraEntropy ? sha2562(concat([randomBytes22(size), arrayify(extraEntropy)])) : randomBytes22(size);
50715
50566
  return Mnemonic.entropyToMnemonic(entropy);
50716
50567
  }
50717
50568
  };
@@ -50724,7 +50575,7 @@ Supported fuel-core version: ${supportedVersion}.`
50724
50575
  var TestnetPRV2 = hexlify("0x04358394");
50725
50576
  var TestnetPUB = hexlify("0x043587cf");
50726
50577
  function base58check(data) {
50727
- return encodeBase58(concat([data, dataSlice(sha2563(sha2563(data)), 0, 4)]));
50578
+ return encodeBase58(concat([data, dataSlice(sha2562(sha2562(data)), 0, 4)]));
50728
50579
  }
50729
50580
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
50730
50581
  if (isPublic) {
@@ -50780,7 +50631,7 @@ Supported fuel-core version: ${supportedVersion}.`
50780
50631
  this.publicKey = hexlify(config.publicKey);
50781
50632
  }
50782
50633
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
50783
- this.fingerprint = dataSlice(ripemd1602(sha2563(this.publicKey)), 0, 4);
50634
+ this.fingerprint = dataSlice(ripemd16022(sha2562(this.publicKey)), 0, 4);
50784
50635
  this.depth = config.depth || this.depth;
50785
50636
  this.index = config.index || this.index;
50786
50637
  this.chainCode = config.chainCode;
@@ -50811,10 +50662,10 @@ Supported fuel-core version: ${supportedVersion}.`
50811
50662
  } else {
50812
50663
  data.set(arrayify(this.publicKey));
50813
50664
  }
50814
- data.set(toBytes3(index, 4), 33);
50815
- const bytes3 = arrayify(computeHmac("sha512", chainCode, data));
50816
- const IL = bytes3.slice(0, 32);
50817
- const IR = bytes3.slice(32);
50665
+ data.set(toBytes2(index, 4), 33);
50666
+ const bytes2 = arrayify(computeHmac2("sha512", chainCode, data));
50667
+ const IL = bytes2.slice(0, 32);
50668
+ const IR = bytes2.slice(32);
50818
50669
  if (privateKey) {
50819
50670
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
50820
50671
  const ki = bn(IL).add(privateKey).mod(N).toBytes(32);
@@ -50883,27 +50734,27 @@ Supported fuel-core version: ${supportedVersion}.`
50883
50734
  });
50884
50735
  }
50885
50736
  static fromExtendedKey(extendedKey) {
50886
- const decoded = toBeHex(decodeBase58(extendedKey));
50887
- const bytes3 = arrayify(decoded);
50888
- const validChecksum = base58check(bytes3.slice(0, 78)) === extendedKey;
50889
- if (bytes3.length !== 82 || !isValidExtendedKey(bytes3)) {
50737
+ const decoded = hexlify(toBytes2(decodeBase58(extendedKey)));
50738
+ const bytes2 = arrayify(decoded);
50739
+ const validChecksum = base58check(bytes2.slice(0, 78)) === extendedKey;
50740
+ if (bytes2.length !== 82 || !isValidExtendedKey(bytes2)) {
50890
50741
  throw new FuelError(ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
50891
50742
  }
50892
50743
  if (!validChecksum) {
50893
50744
  throw new FuelError(ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
50894
50745
  }
50895
- const depth = bytes3[4];
50896
- const parentFingerprint = hexlify(bytes3.slice(5, 9));
50897
- const index = parseInt(hexlify(bytes3.slice(9, 13)).substring(2), 16);
50898
- const chainCode = hexlify(bytes3.slice(13, 45));
50899
- const key = bytes3.slice(45, 78);
50746
+ const depth = bytes2[4];
50747
+ const parentFingerprint = hexlify(bytes2.slice(5, 9));
50748
+ const index = parseInt(hexlify(bytes2.slice(9, 13)).substring(2), 16);
50749
+ const chainCode = hexlify(bytes2.slice(13, 45));
50750
+ const key = bytes2.slice(45, 78);
50900
50751
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
50901
50752
  throw new FuelError(
50902
50753
  ErrorCode.HD_WALLET_ERROR,
50903
50754
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
50904
50755
  );
50905
50756
  }
50906
- if (isPublicExtendedKey(bytes3)) {
50757
+ if (isPublicExtendedKey(bytes2)) {
50907
50758
  if (key[0] !== 3) {
50908
50759
  throw new FuelError(ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
50909
50760
  }
@@ -51127,7 +50978,7 @@ Supported fuel-core version: ${supportedVersion}.`
51127
50978
 
51128
50979
  // src/test-utils/launchNode.ts
51129
50980
  var import_child_process = __require("child_process");
51130
- var import_crypto21 = __require("crypto");
50981
+ var import_crypto19 = __require("crypto");
51131
50982
  var import_fs2 = __require("fs");
51132
50983
  var import_os = __toESM(__require("os"));
51133
50984
  var import_path8 = __toESM(__require("path"));
@@ -51164,6 +51015,40 @@ Supported fuel-core version: ${supportedVersion}.`
51164
51015
  }
51165
51016
  }
51166
51017
  };
51018
+ function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
51019
+ const defaultCoins = defaultSnapshotConfigs.stateConfig.coins.map((coin) => ({
51020
+ ...coin,
51021
+ amount: "18446744073709551615"
51022
+ }));
51023
+ const defaultMessages = defaultSnapshotConfigs.stateConfig.messages.map((message) => ({
51024
+ ...message,
51025
+ amount: "18446744073709551615"
51026
+ }));
51027
+ const coins = defaultCoins.concat(stateConfig.coins.map((coin) => ({ ...coin, amount: coin.amount.toString() }))).filter((coin, index, self2) => self2.findIndex((c) => c.tx_id === coin.tx_id) === index);
51028
+ const messages = defaultMessages.concat(stateConfig.messages.map((msg) => ({ ...msg, amount: msg.amount.toString() }))).filter((msg, index, self2) => self2.findIndex((m) => m.nonce === msg.nonce) === index);
51029
+ if (!process.env.GENESIS_SECRET) {
51030
+ const pk = Signer.generatePrivateKey();
51031
+ const signer = new Signer(pk);
51032
+ process.env.GENESIS_SECRET = hexlify(pk);
51033
+ coins.push({
51034
+ tx_id: hexlify(randomBytes22(UTXO_ID_LEN)),
51035
+ owner: signer.address.toHexString(),
51036
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
51037
+ amount: "18446744073709551615",
51038
+ asset_id: chainConfig.consensus_parameters.V1.base_asset_id,
51039
+ output_index: 0,
51040
+ tx_pointer_block_height: 0,
51041
+ tx_pointer_tx_idx: 0
51042
+ });
51043
+ }
51044
+ const json = JSON.stringify({
51045
+ ...stateConfig,
51046
+ coins,
51047
+ messages
51048
+ });
51049
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
51050
+ return json.replace(regexMakeNumber, "$1$2");
51051
+ }
51167
51052
  var launchNode = async ({
51168
51053
  ip,
51169
51054
  port,
@@ -51171,7 +51056,8 @@ Supported fuel-core version: ${supportedVersion}.`
51171
51056
  useSystemFuelCore = false,
51172
51057
  loggingEnabled = true,
51173
51058
  debugEnabled = false,
51174
- basePath
51059
+ basePath,
51060
+ snapshotConfig = defaultSnapshotConfigs
51175
51061
  }) => (
51176
51062
  // eslint-disable-next-line no-async-promise-executor
51177
51063
  new Promise(async (resolve, reject) => {
@@ -51199,57 +51085,24 @@ Supported fuel-core version: ${supportedVersion}.`
51199
51085
  })).toString();
51200
51086
  let snapshotDirToUse;
51201
51087
  const prefix = basePath || import_os.default.tmpdir();
51202
- const suffix = basePath ? "" : (0, import_crypto21.randomUUID)();
51203
- const tempDirPath = import_path8.default.join(prefix, ".fuels", suffix, "snapshotDir");
51088
+ const suffix = basePath ? "" : (0, import_crypto19.randomUUID)();
51089
+ const tempDir = import_path8.default.join(prefix, ".fuels", suffix, "snapshotDir");
51204
51090
  if (snapshotDir) {
51205
51091
  snapshotDirToUse = snapshotDir;
51206
51092
  } else {
51207
- if (!(0, import_fs2.existsSync)(tempDirPath)) {
51208
- (0, import_fs2.mkdirSync)(tempDirPath, { recursive: true });
51209
- }
51210
- let { stateConfigJson } = defaultSnapshotConfigs;
51211
- const { chainConfigJson, metadataJson } = defaultSnapshotConfigs;
51212
- stateConfigJson = {
51213
- ...stateConfigJson,
51214
- coins: [
51215
- ...stateConfigJson.coins.map((coin) => ({
51216
- ...coin,
51217
- amount: "18446744073709551615"
51218
- }))
51219
- ],
51220
- messages: stateConfigJson.messages.map((message) => ({
51221
- ...message,
51222
- amount: "18446744073709551615"
51223
- }))
51224
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
51225
- };
51226
- if (!process.env.GENESIS_SECRET) {
51227
- const pk = Signer.generatePrivateKey();
51228
- const signer = new Signer(pk);
51229
- process.env.GENESIS_SECRET = hexlify(pk);
51230
- stateConfigJson.coins.push({
51231
- tx_id: hexlify(randomBytes22(UTXO_ID_LEN)),
51232
- owner: signer.address.toHexString(),
51233
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
51234
- amount: "18446744073709551615",
51235
- asset_id: chainConfigJson.consensus_parameters.V1.base_asset_id,
51236
- output_index: 0,
51237
- tx_pointer_block_height: 0,
51238
- tx_pointer_tx_idx: 0
51239
- });
51240
- }
51241
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
51242
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
51243
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
51244
- const chainConfigWritePath = import_path8.default.join(tempDirPath, "chainConfig.json");
51245
- const stateConfigWritePath = import_path8.default.join(tempDirPath, "stateConfig.json");
51246
- const metadataWritePath = import_path8.default.join(tempDirPath, "metadata.json");
51247
- const stateTransitionWritePath = import_path8.default.join(tempDirPath, "state_transition_bytecode.wasm");
51248
- (0, import_fs2.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
51249
- (0, import_fs2.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
51250
- (0, import_fs2.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
51251
- (0, import_fs2.writeFileSync)(stateTransitionWritePath, JSON.stringify(""));
51252
- snapshotDirToUse = tempDirPath;
51093
+ if (!(0, import_fs2.existsSync)(tempDir)) {
51094
+ (0, import_fs2.mkdirSync)(tempDir, { recursive: true });
51095
+ }
51096
+ const { metadata } = snapshotConfig;
51097
+ const metadataPath = import_path8.default.join(tempDir, "metadata.json");
51098
+ const chainConfigPath = import_path8.default.join(tempDir, metadata.chain_config);
51099
+ const stateConfigPath = import_path8.default.join(tempDir, metadata.table_encoding.Json.filepath);
51100
+ const stateTransitionPath = import_path8.default.join(tempDir, "state_transition_bytecode.wasm");
51101
+ (0, import_fs2.writeFileSync)(chainConfigPath, JSON.stringify(snapshotConfig.chainConfig), "utf8");
51102
+ (0, import_fs2.writeFileSync)(stateConfigPath, getFinalStateConfigJSON(snapshotConfig), "utf8");
51103
+ (0, import_fs2.writeFileSync)(metadataPath, JSON.stringify(metadata), "utf8");
51104
+ (0, import_fs2.writeFileSync)(stateTransitionPath, JSON.stringify(""));
51105
+ snapshotDirToUse = tempDir;
51253
51106
  }
51254
51107
  const child = (0, import_child_process.spawn)(
51255
51108
  command,
@@ -51257,7 +51110,7 @@ Supported fuel-core version: ${supportedVersion}.`
51257
51110
  "run",
51258
51111
  ["--ip", ipToUse],
51259
51112
  ["--port", portToUse],
51260
- useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
51113
+ useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDir],
51261
51114
  ["--min-gas-price", "1"],
51262
51115
  poaInstant ? ["--poa-instant", "true"] : [],
51263
51116
  ["--consensus-key", consensusKey],
@@ -51279,23 +51132,28 @@ Supported fuel-core version: ${supportedVersion}.`
51279
51132
  }
51280
51133
  const cleanupConfig = {
51281
51134
  child,
51282
- configPath: tempDirPath,
51135
+ configPath: tempDir,
51283
51136
  killFn: import_tree_kill.default,
51284
51137
  state: {
51285
51138
  isDead: false
51286
51139
  }
51287
51140
  };
51288
51141
  child.stderr.on("data", (chunk) => {
51289
- if (chunk.indexOf(graphQLStartSubstring) !== -1) {
51142
+ const text = typeof chunk === "string" ? chunk : chunk.toString();
51143
+ if (text.indexOf(graphQLStartSubstring) !== -1) {
51144
+ const rows = text.split("\n");
51145
+ const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
51146
+ const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
51290
51147
  resolve({
51291
51148
  cleanup: () => killNode(cleanupConfig),
51292
- ip: ipToUse,
51293
- port: portToUse,
51149
+ ip: realIp,
51150
+ port: realPort,
51151
+ url: `http://${realIp}:${realPort}/v1/graphql`,
51294
51152
  snapshotDir: snapshotDirToUse
51295
51153
  });
51296
51154
  }
51297
- if (/error/i.test(chunk)) {
51298
- reject(chunk.toString());
51155
+ if (/error/i.test(text)) {
51156
+ reject(text.toString());
51299
51157
  }
51300
51158
  });
51301
51159
  process.on("exit", () => killNode(cleanupConfig));
@@ -51328,6 +51186,215 @@ Supported fuel-core version: ${supportedVersion}.`
51328
51186
  };
51329
51187
  return { wallets, stop: cleanup, provider };
51330
51188
  };
51189
+
51190
+ // src/test-utils/asset-id.ts
51191
+ var _AssetId = class {
51192
+ constructor(value) {
51193
+ this.value = value;
51194
+ }
51195
+ static random() {
51196
+ return new _AssetId(hexlify(randomBytes22(32)));
51197
+ }
51198
+ };
51199
+ var AssetId = _AssetId;
51200
+ __publicField(AssetId, "A", new _AssetId(
51201
+ "0x0101010101010101010101010101010101010101010101010101010101010101"
51202
+ ));
51203
+ __publicField(AssetId, "B", new _AssetId(
51204
+ "0x0202020202020202020202020202020202020202020202020202020202020202"
51205
+ ));
51206
+
51207
+ // src/test-utils/wallet-config.ts
51208
+ var WalletConfig = class {
51209
+ initialState;
51210
+ options;
51211
+ wallets;
51212
+ generateWallets = () => {
51213
+ const generatedWallets = [];
51214
+ for (let index = 1; index <= this.options.count; index++) {
51215
+ generatedWallets.push(new WalletUnlocked(randomBytes22(32)));
51216
+ }
51217
+ return generatedWallets;
51218
+ };
51219
+ constructor(baseAssetId, config) {
51220
+ const BASE_ASSET_ID = baseAssetId.startsWith("0x") ? baseAssetId : `0x${baseAssetId}`;
51221
+ WalletConfig.guard(config);
51222
+ this.options = config;
51223
+ const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
51224
+ this.wallets = this.generateWallets();
51225
+ this.initialState = {
51226
+ messages: WalletConfig.createMessages(this.wallets, messages),
51227
+ coins: WalletConfig.createCoins(
51228
+ this.wallets,
51229
+ BASE_ASSET_ID,
51230
+ assets2,
51231
+ coinsPerAsset,
51232
+ amountPerCoin
51233
+ )
51234
+ };
51235
+ }
51236
+ apply(snapshotConfig) {
51237
+ return {
51238
+ ...snapshotConfig,
51239
+ stateConfig: {
51240
+ ...snapshotConfig?.stateConfig ?? defaultSnapshotConfigs.stateConfig,
51241
+ coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
51242
+ messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
51243
+ }
51244
+ };
51245
+ }
51246
+ static createMessages(wallets, messages) {
51247
+ return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
51248
+ }
51249
+ static createCoins(wallets, baseAssetId, assets2, coinsPerAsset, amountPerCoin) {
51250
+ const coins = [];
51251
+ let assetIds = [baseAssetId];
51252
+ if (Array.isArray(assets2)) {
51253
+ assetIds = assetIds.concat(assets2.map((a) => a.value));
51254
+ } else {
51255
+ for (let index = 0; index < assets2 - 1; index++) {
51256
+ assetIds.push(AssetId.random().value);
51257
+ }
51258
+ }
51259
+ wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
51260
+ assetIds.forEach((assetId) => {
51261
+ for (let index = 0; index < coinsPerAsset; index++) {
51262
+ coins.push({
51263
+ amount: amountPerCoin,
51264
+ asset_id: assetId,
51265
+ owner: walletAddress,
51266
+ tx_pointer_block_height: 0,
51267
+ tx_pointer_tx_idx: 0,
51268
+ output_index: 0,
51269
+ tx_id: hexlify(randomBytes22(32))
51270
+ });
51271
+ }
51272
+ });
51273
+ });
51274
+ return coins;
51275
+ }
51276
+ static guard({
51277
+ count: wallets,
51278
+ assets: assets2,
51279
+ coinsPerAsset,
51280
+ amountPerCoin
51281
+ }) {
51282
+ if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
51283
+ throw new FuelError(
51284
+ FuelError.CODES.INVALID_INPUT_PARAMETERS,
51285
+ "Number of wallets must be greater than zero."
51286
+ );
51287
+ }
51288
+ if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
51289
+ throw new FuelError(
51290
+ FuelError.CODES.INVALID_INPUT_PARAMETERS,
51291
+ "Number of assets per wallet must be greater than zero."
51292
+ );
51293
+ }
51294
+ if (coinsPerAsset <= 0) {
51295
+ throw new FuelError(
51296
+ FuelError.CODES.INVALID_INPUT_PARAMETERS,
51297
+ "Number of coins per asset must be greater than zero."
51298
+ );
51299
+ }
51300
+ if (amountPerCoin <= 0) {
51301
+ throw new FuelError(
51302
+ FuelError.CODES.INVALID_INPUT_PARAMETERS,
51303
+ "Amount per coin must be greater than zero."
51304
+ );
51305
+ }
51306
+ }
51307
+ };
51308
+
51309
+ // src/test-utils/setup-test-provider-and-wallets.ts
51310
+ var defaultWalletConfigOptions = {
51311
+ count: 2,
51312
+ assets: [AssetId.A, AssetId.B],
51313
+ coinsPerAsset: 1,
51314
+ amountPerCoin: 1e10,
51315
+ messages: []
51316
+ };
51317
+ async function setupTestProviderAndWallets({
51318
+ walletConfig: walletConfigOptions = {},
51319
+ providerOptions,
51320
+ nodeOptions = {}
51321
+ } = {}) {
51322
+ Symbol.dispose ??= Symbol("Symbol.dispose");
51323
+ const walletConfig = new WalletConfig(
51324
+ nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ?? defaultSnapshotConfigs.chainConfig.consensus_parameters.V1.base_asset_id,
51325
+ {
51326
+ ...defaultWalletConfigOptions,
51327
+ ...walletConfigOptions
51328
+ }
51329
+ );
51330
+ const { cleanup, url } = await launchNode({
51331
+ loggingEnabled: false,
51332
+ ...nodeOptions,
51333
+ snapshotConfig: mergeDeepRight_default(
51334
+ defaultSnapshotConfigs,
51335
+ walletConfig.apply(nodeOptions?.snapshotConfig)
51336
+ ),
51337
+ port: "0"
51338
+ });
51339
+ let provider;
51340
+ try {
51341
+ provider = await Provider.create(url, providerOptions);
51342
+ } catch (err) {
51343
+ cleanup();
51344
+ throw err;
51345
+ }
51346
+ const wallets = walletConfig.wallets;
51347
+ wallets.forEach((wallet) => {
51348
+ wallet.connect(provider);
51349
+ });
51350
+ return {
51351
+ provider,
51352
+ wallets,
51353
+ cleanup,
51354
+ [Symbol.dispose]: cleanup
51355
+ };
51356
+ }
51357
+
51358
+ // src/test-utils/test-message.ts
51359
+ var TestMessage = class {
51360
+ sender;
51361
+ recipient;
51362
+ nonce;
51363
+ amount;
51364
+ data;
51365
+ da_height;
51366
+ /**
51367
+ * A helper class to create messages for testing purposes.
51368
+ *
51369
+ * Used in tandem with `WalletConfig`.
51370
+ * It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
51371
+ */
51372
+ constructor({
51373
+ sender = Address.fromRandom(),
51374
+ recipient = Address.fromRandom(),
51375
+ nonce = hexlify(randomBytes22(32)),
51376
+ amount = 1e6,
51377
+ data = "02",
51378
+ da_height = 0
51379
+ } = {}) {
51380
+ this.sender = sender;
51381
+ this.recipient = recipient;
51382
+ this.nonce = nonce;
51383
+ this.amount = amount;
51384
+ this.data = data;
51385
+ this.da_height = da_height;
51386
+ }
51387
+ toChainMessage(recipient) {
51388
+ return {
51389
+ sender: this.sender.toB256(),
51390
+ recipient: recipient?.toB256() ?? this.recipient.toB256(),
51391
+ nonce: this.nonce,
51392
+ amount: bn(this.amount).toNumber(),
51393
+ data: this.data,
51394
+ da_height: this.da_height
51395
+ };
51396
+ }
51397
+ };
51331
51398
  })();
51332
51399
  /*! Bundled license information:
51333
51400
 
@@ -51350,9 +51417,6 @@ mime-types/index.js:
51350
51417
  @noble/hashes/esm/utils.js:
51351
51418
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
51352
51419
 
51353
- @noble/hashes/esm/utils.js:
51354
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
51355
-
51356
51420
  @noble/curves/esm/abstract/utils.js:
51357
51421
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
51358
51422