@fuel-ts/account 0.0.0-rc-2143-20240514195947 → 0.0.0-rc-2238-20240514214137

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.

@@ -73,7 +73,7 @@
73
73
  "../../node_modules/.pnpm/bn.js@5.2.1/node_modules/bn.js/lib/bn.js"(exports, module) {
74
74
  (function(module2, exports2) {
75
75
  "use strict";
76
- function assert3(val, msg) {
76
+ function assert2(val, msg) {
77
77
  if (!val)
78
78
  throw new Error(msg || "Assertion failed");
79
79
  }
@@ -143,7 +143,7 @@
143
143
  if (base === "hex") {
144
144
  base = 16;
145
145
  }
146
- assert3(base === (base | 0) && base >= 2 && base <= 36);
146
+ assert2(base === (base | 0) && base >= 2 && base <= 36);
147
147
  number2 = number2.toString().replace(/\s+/g, "");
148
148
  var start = 0;
149
149
  if (number2[0] === "-") {
@@ -176,7 +176,7 @@
176
176
  ];
177
177
  this.length = 2;
178
178
  } else {
179
- assert3(number2 < 9007199254740992);
179
+ assert2(number2 < 9007199254740992);
180
180
  this.words = [
181
181
  number2 & 67108863,
182
182
  number2 / 67108864 & 67108863,
@@ -189,7 +189,7 @@
189
189
  this._initArray(this.toArray(), base, endian);
190
190
  };
191
191
  BN2.prototype._initArray = function _initArray(number2, base, endian) {
192
- assert3(typeof number2.length === "number");
192
+ assert2(typeof number2.length === "number");
193
193
  if (number2.length <= 0) {
194
194
  this.words = [0];
195
195
  this.length = 1;
@@ -236,7 +236,7 @@
236
236
  } else if (c >= 97 && c <= 102) {
237
237
  return c - 87;
238
238
  } else {
239
- assert3(false, "Invalid character in " + string);
239
+ assert2(false, "Invalid character in " + string);
240
240
  }
241
241
  }
242
242
  function parseHexByte(string, lowerBound, index) {
@@ -297,7 +297,7 @@
297
297
  } else {
298
298
  b = c;
299
299
  }
300
- assert3(c >= 0 && b < mul, "Invalid character");
300
+ assert2(c >= 0 && b < mul, "Invalid character");
301
301
  r += b;
302
302
  }
303
303
  return r;
@@ -557,16 +557,16 @@
557
557
  }
558
558
  return out;
559
559
  }
560
- assert3(false, "Base should be between 2 and 36");
560
+ assert2(false, "Base should be between 2 and 36");
561
561
  };
562
- BN2.prototype.toNumber = function toNumber3() {
562
+ BN2.prototype.toNumber = function toNumber2() {
563
563
  var ret2 = this.words[0];
564
564
  if (this.length === 2) {
565
565
  ret2 += this.words[1] * 67108864;
566
566
  } else if (this.length === 3 && this.words[2] === 1) {
567
567
  ret2 += 4503599627370496 + this.words[1] * 67108864;
568
568
  } else if (this.length > 2) {
569
- assert3(false, "Number can only safely store up to 53 bits");
569
+ assert2(false, "Number can only safely store up to 53 bits");
570
570
  }
571
571
  return this.negative !== 0 ? -ret2 : ret2;
572
572
  };
@@ -591,8 +591,8 @@
591
591
  this._strip();
592
592
  var byteLength = this.byteLength();
593
593
  var reqLength = length || Math.max(1, byteLength);
594
- assert3(byteLength <= reqLength, "byte array longer than desired length");
595
- assert3(reqLength > 0, "Requested array length <= 0");
594
+ assert2(byteLength <= reqLength, "byte array longer than desired length");
595
+ assert2(reqLength > 0, "Requested array length <= 0");
596
596
  var res = allocate(ArrayType, reqLength);
597
597
  var postfix = endian === "le" ? "LE" : "BE";
598
598
  this["_toArrayLike" + postfix](res, byteLength);
@@ -740,13 +740,13 @@
740
740
  BN2.prototype.byteLength = function byteLength() {
741
741
  return Math.ceil(this.bitLength() / 8);
742
742
  };
743
- BN2.prototype.toTwos = function toTwos2(width) {
743
+ BN2.prototype.toTwos = function toTwos(width) {
744
744
  if (this.negative !== 0) {
745
745
  return this.abs().inotn(width).iaddn(1);
746
746
  }
747
747
  return this.clone();
748
748
  };
749
- BN2.prototype.fromTwos = function fromTwos2(width) {
749
+ BN2.prototype.fromTwos = function fromTwos(width) {
750
750
  if (this.testn(width - 1)) {
751
751
  return this.notn(width).iaddn(1).ineg();
752
752
  }
@@ -774,7 +774,7 @@
774
774
  return this._strip();
775
775
  };
776
776
  BN2.prototype.ior = function ior(num) {
777
- assert3((this.negative | num.negative) === 0);
777
+ assert2((this.negative | num.negative) === 0);
778
778
  return this.iuor(num);
779
779
  };
780
780
  BN2.prototype.or = function or(num) {
@@ -801,7 +801,7 @@
801
801
  return this._strip();
802
802
  };
803
803
  BN2.prototype.iand = function iand(num) {
804
- assert3((this.negative | num.negative) === 0);
804
+ assert2((this.negative | num.negative) === 0);
805
805
  return this.iuand(num);
806
806
  };
807
807
  BN2.prototype.and = function and(num) {
@@ -836,7 +836,7 @@
836
836
  return this._strip();
837
837
  };
838
838
  BN2.prototype.ixor = function ixor(num) {
839
- assert3((this.negative | num.negative) === 0);
839
+ assert2((this.negative | num.negative) === 0);
840
840
  return this.iuxor(num);
841
841
  };
842
842
  BN2.prototype.xor = function xor(num) {
@@ -850,7 +850,7 @@
850
850
  return num.clone().iuxor(this);
851
851
  };
852
852
  BN2.prototype.inotn = function inotn(width) {
853
- assert3(typeof width === "number" && width >= 0);
853
+ assert2(typeof width === "number" && width >= 0);
854
854
  var bytesNeeded = Math.ceil(width / 26) | 0;
855
855
  var bitsLeft = width % 26;
856
856
  this._expand(bytesNeeded);
@@ -869,7 +869,7 @@
869
869
  return this.clone().inotn(width);
870
870
  };
871
871
  BN2.prototype.setn = function setn(bit, val) {
872
- assert3(typeof bit === "number" && bit >= 0);
872
+ assert2(typeof bit === "number" && bit >= 0);
873
873
  var off = bit / 26 | 0;
874
874
  var wbit = bit % 26;
875
875
  this._expand(off + 1);
@@ -1735,8 +1735,8 @@
1735
1735
  for (i = 2 * len; i < N; ++i) {
1736
1736
  rws[i] = 0;
1737
1737
  }
1738
- assert3(carry === 0);
1739
- assert3((carry & ~8191) === 0);
1738
+ assert2(carry === 0);
1739
+ assert2((carry & ~8191) === 0);
1740
1740
  };
1741
1741
  FFTM.prototype.stub = function stub(N) {
1742
1742
  var ph = new Array(N);
@@ -1791,8 +1791,8 @@
1791
1791
  var isNegNum = num < 0;
1792
1792
  if (isNegNum)
1793
1793
  num = -num;
1794
- assert3(typeof num === "number");
1795
- assert3(num < 67108864);
1794
+ assert2(typeof num === "number");
1795
+ assert2(num < 67108864);
1796
1796
  var carry = 0;
1797
1797
  for (var i = 0; i < this.length; i++) {
1798
1798
  var w = (this.words[i] | 0) * num;
@@ -1836,7 +1836,7 @@
1836
1836
  return res;
1837
1837
  };
1838
1838
  BN2.prototype.iushln = function iushln(bits) {
1839
- assert3(typeof bits === "number" && bits >= 0);
1839
+ assert2(typeof bits === "number" && bits >= 0);
1840
1840
  var r = bits % 26;
1841
1841
  var s = (bits - r) / 26;
1842
1842
  var carryMask = 67108863 >>> 26 - r << 26 - r;
@@ -1866,11 +1866,11 @@
1866
1866
  return this._strip();
1867
1867
  };
1868
1868
  BN2.prototype.ishln = function ishln(bits) {
1869
- assert3(this.negative === 0);
1869
+ assert2(this.negative === 0);
1870
1870
  return this.iushln(bits);
1871
1871
  };
1872
1872
  BN2.prototype.iushrn = function iushrn(bits, hint, extended) {
1873
- assert3(typeof bits === "number" && bits >= 0);
1873
+ assert2(typeof bits === "number" && bits >= 0);
1874
1874
  var h;
1875
1875
  if (hint) {
1876
1876
  h = (hint - hint % 26) / 26;
@@ -1879,7 +1879,7 @@
1879
1879
  }
1880
1880
  var r = bits % 26;
1881
1881
  var s = Math.min((bits - r) / 26, this.length);
1882
- var mask2 = 67108863 ^ 67108863 >>> r << r;
1882
+ var mask = 67108863 ^ 67108863 >>> r << r;
1883
1883
  var maskedWords = extended;
1884
1884
  h -= s;
1885
1885
  h = Math.max(0, h);
@@ -1903,7 +1903,7 @@
1903
1903
  for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
1904
1904
  var word = this.words[i] | 0;
1905
1905
  this.words[i] = carry << 26 - r | word >>> r;
1906
- carry = word & mask2;
1906
+ carry = word & mask;
1907
1907
  }
1908
1908
  if (maskedWords && carry !== 0) {
1909
1909
  maskedWords.words[maskedWords.length++] = carry;
@@ -1915,7 +1915,7 @@
1915
1915
  return this._strip();
1916
1916
  };
1917
1917
  BN2.prototype.ishrn = function ishrn(bits, hint, extended) {
1918
- assert3(this.negative === 0);
1918
+ assert2(this.negative === 0);
1919
1919
  return this.iushrn(bits, hint, extended);
1920
1920
  };
1921
1921
  BN2.prototype.shln = function shln(bits) {
@@ -1931,7 +1931,7 @@
1931
1931
  return this.clone().iushrn(bits);
1932
1932
  };
1933
1933
  BN2.prototype.testn = function testn(bit) {
1934
- assert3(typeof bit === "number" && bit >= 0);
1934
+ assert2(typeof bit === "number" && bit >= 0);
1935
1935
  var r = bit % 26;
1936
1936
  var s = (bit - r) / 26;
1937
1937
  var q = 1 << r;
@@ -1941,10 +1941,10 @@
1941
1941
  return !!(w & q);
1942
1942
  };
1943
1943
  BN2.prototype.imaskn = function imaskn(bits) {
1944
- assert3(typeof bits === "number" && bits >= 0);
1944
+ assert2(typeof bits === "number" && bits >= 0);
1945
1945
  var r = bits % 26;
1946
1946
  var s = (bits - r) / 26;
1947
- assert3(this.negative === 0, "imaskn works only with positive numbers");
1947
+ assert2(this.negative === 0, "imaskn works only with positive numbers");
1948
1948
  if (this.length <= s) {
1949
1949
  return this;
1950
1950
  }
@@ -1953,8 +1953,8 @@
1953
1953
  }
1954
1954
  this.length = Math.min(s, this.length);
1955
1955
  if (r !== 0) {
1956
- var mask2 = 67108863 ^ 67108863 >>> r << r;
1957
- this.words[this.length - 1] &= mask2;
1956
+ var mask = 67108863 ^ 67108863 >>> r << r;
1957
+ this.words[this.length - 1] &= mask;
1958
1958
  }
1959
1959
  return this._strip();
1960
1960
  };
@@ -1962,8 +1962,8 @@
1962
1962
  return this.clone().imaskn(bits);
1963
1963
  };
1964
1964
  BN2.prototype.iaddn = function iaddn(num) {
1965
- assert3(typeof num === "number");
1966
- assert3(num < 67108864);
1965
+ assert2(typeof num === "number");
1966
+ assert2(num < 67108864);
1967
1967
  if (num < 0)
1968
1968
  return this.isubn(-num);
1969
1969
  if (this.negative !== 0) {
@@ -1993,8 +1993,8 @@
1993
1993
  return this;
1994
1994
  };
1995
1995
  BN2.prototype.isubn = function isubn(num) {
1996
- assert3(typeof num === "number");
1997
- assert3(num < 67108864);
1996
+ assert2(typeof num === "number");
1997
+ assert2(num < 67108864);
1998
1998
  if (num < 0)
1999
1999
  return this.iaddn(-num);
2000
2000
  if (this.negative !== 0) {
@@ -2048,7 +2048,7 @@
2048
2048
  }
2049
2049
  if (carry === 0)
2050
2050
  return this._strip();
2051
- assert3(carry === -1);
2051
+ assert2(carry === -1);
2052
2052
  carry = 0;
2053
2053
  for (i = 0; i < this.length; i++) {
2054
2054
  w = -(this.words[i] | 0) + carry;
@@ -2116,7 +2116,7 @@
2116
2116
  };
2117
2117
  };
2118
2118
  BN2.prototype.divmod = function divmod(num, mode, positive) {
2119
- assert3(!num.isZero());
2119
+ assert2(!num.isZero());
2120
2120
  if (this.isZero()) {
2121
2121
  return {
2122
2122
  div: new BN2(0),
@@ -2214,7 +2214,7 @@
2214
2214
  var isNegNum = num < 0;
2215
2215
  if (isNegNum)
2216
2216
  num = -num;
2217
- assert3(num <= 67108863);
2217
+ assert2(num <= 67108863);
2218
2218
  var p = (1 << 26) % num;
2219
2219
  var acc = 0;
2220
2220
  for (var i = this.length - 1; i >= 0; i--) {
@@ -2229,7 +2229,7 @@
2229
2229
  var isNegNum = num < 0;
2230
2230
  if (isNegNum)
2231
2231
  num = -num;
2232
- assert3(num <= 67108863);
2232
+ assert2(num <= 67108863);
2233
2233
  var carry = 0;
2234
2234
  for (var i = this.length - 1; i >= 0; i--) {
2235
2235
  var w = (this.words[i] | 0) + carry * 67108864;
@@ -2243,8 +2243,8 @@
2243
2243
  return this.clone().idivn(num);
2244
2244
  };
2245
2245
  BN2.prototype.egcd = function egcd(p) {
2246
- assert3(p.negative === 0);
2247
- assert3(!p.isZero());
2246
+ assert2(p.negative === 0);
2247
+ assert2(!p.isZero());
2248
2248
  var x = this;
2249
2249
  var y = p.clone();
2250
2250
  if (x.negative !== 0) {
@@ -2308,8 +2308,8 @@
2308
2308
  };
2309
2309
  };
2310
2310
  BN2.prototype._invmp = function _invmp(p) {
2311
- assert3(p.negative === 0);
2312
- assert3(!p.isZero());
2311
+ assert2(p.negative === 0);
2312
+ assert2(!p.isZero());
2313
2313
  var a = this;
2314
2314
  var b = p.clone();
2315
2315
  if (a.negative !== 0) {
@@ -2407,7 +2407,7 @@
2407
2407
  return this.words[0] & num;
2408
2408
  };
2409
2409
  BN2.prototype.bincn = function bincn(bit) {
2410
- assert3(typeof bit === "number");
2410
+ assert2(typeof bit === "number");
2411
2411
  var r = bit % 26;
2412
2412
  var s = (bit - r) / 26;
2413
2413
  var q = 1 << r;
@@ -2447,7 +2447,7 @@
2447
2447
  if (negative) {
2448
2448
  num = -num;
2449
2449
  }
2450
- assert3(num <= 67108863, "Number is too big");
2450
+ assert2(num <= 67108863, "Number is too big");
2451
2451
  var w = this.words[0] | 0;
2452
2452
  res = w === num ? 0 : w < num ? -1 : 1;
2453
2453
  }
@@ -2519,12 +2519,12 @@
2519
2519
  return new Red(num);
2520
2520
  };
2521
2521
  BN2.prototype.toRed = function toRed(ctx) {
2522
- assert3(!this.red, "Already a number in reduction context");
2523
- assert3(this.negative === 0, "red works only with positives");
2522
+ assert2(!this.red, "Already a number in reduction context");
2523
+ assert2(this.negative === 0, "red works only with positives");
2524
2524
  return ctx.convertTo(this)._forceRed(ctx);
2525
2525
  };
2526
2526
  BN2.prototype.fromRed = function fromRed() {
2527
- assert3(this.red, "fromRed works only with numbers in reduction context");
2527
+ assert2(this.red, "fromRed works only with numbers in reduction context");
2528
2528
  return this.red.convertFrom(this);
2529
2529
  };
2530
2530
  BN2.prototype._forceRed = function _forceRed(ctx) {
@@ -2532,66 +2532,66 @@
2532
2532
  return this;
2533
2533
  };
2534
2534
  BN2.prototype.forceRed = function forceRed(ctx) {
2535
- assert3(!this.red, "Already a number in reduction context");
2535
+ assert2(!this.red, "Already a number in reduction context");
2536
2536
  return this._forceRed(ctx);
2537
2537
  };
2538
2538
  BN2.prototype.redAdd = function redAdd(num) {
2539
- assert3(this.red, "redAdd works only with red numbers");
2539
+ assert2(this.red, "redAdd works only with red numbers");
2540
2540
  return this.red.add(this, num);
2541
2541
  };
2542
2542
  BN2.prototype.redIAdd = function redIAdd(num) {
2543
- assert3(this.red, "redIAdd works only with red numbers");
2543
+ assert2(this.red, "redIAdd works only with red numbers");
2544
2544
  return this.red.iadd(this, num);
2545
2545
  };
2546
2546
  BN2.prototype.redSub = function redSub(num) {
2547
- assert3(this.red, "redSub works only with red numbers");
2547
+ assert2(this.red, "redSub works only with red numbers");
2548
2548
  return this.red.sub(this, num);
2549
2549
  };
2550
2550
  BN2.prototype.redISub = function redISub(num) {
2551
- assert3(this.red, "redISub works only with red numbers");
2551
+ assert2(this.red, "redISub works only with red numbers");
2552
2552
  return this.red.isub(this, num);
2553
2553
  };
2554
2554
  BN2.prototype.redShl = function redShl(num) {
2555
- assert3(this.red, "redShl works only with red numbers");
2555
+ assert2(this.red, "redShl works only with red numbers");
2556
2556
  return this.red.shl(this, num);
2557
2557
  };
2558
2558
  BN2.prototype.redMul = function redMul(num) {
2559
- assert3(this.red, "redMul works only with red numbers");
2559
+ assert2(this.red, "redMul works only with red numbers");
2560
2560
  this.red._verify2(this, num);
2561
2561
  return this.red.mul(this, num);
2562
2562
  };
2563
2563
  BN2.prototype.redIMul = function redIMul(num) {
2564
- assert3(this.red, "redMul works only with red numbers");
2564
+ assert2(this.red, "redMul works only with red numbers");
2565
2565
  this.red._verify2(this, num);
2566
2566
  return this.red.imul(this, num);
2567
2567
  };
2568
2568
  BN2.prototype.redSqr = function redSqr() {
2569
- assert3(this.red, "redSqr works only with red numbers");
2569
+ assert2(this.red, "redSqr works only with red numbers");
2570
2570
  this.red._verify1(this);
2571
2571
  return this.red.sqr(this);
2572
2572
  };
2573
2573
  BN2.prototype.redISqr = function redISqr() {
2574
- assert3(this.red, "redISqr works only with red numbers");
2574
+ assert2(this.red, "redISqr works only with red numbers");
2575
2575
  this.red._verify1(this);
2576
2576
  return this.red.isqr(this);
2577
2577
  };
2578
2578
  BN2.prototype.redSqrt = function redSqrt() {
2579
- assert3(this.red, "redSqrt works only with red numbers");
2579
+ assert2(this.red, "redSqrt works only with red numbers");
2580
2580
  this.red._verify1(this);
2581
2581
  return this.red.sqrt(this);
2582
2582
  };
2583
2583
  BN2.prototype.redInvm = function redInvm() {
2584
- assert3(this.red, "redInvm works only with red numbers");
2584
+ assert2(this.red, "redInvm works only with red numbers");
2585
2585
  this.red._verify1(this);
2586
2586
  return this.red.invm(this);
2587
2587
  };
2588
2588
  BN2.prototype.redNeg = function redNeg() {
2589
- assert3(this.red, "redNeg works only with red numbers");
2589
+ assert2(this.red, "redNeg works only with red numbers");
2590
2590
  this.red._verify1(this);
2591
2591
  return this.red.neg(this);
2592
2592
  };
2593
2593
  BN2.prototype.redPow = function redPow(num) {
2594
- assert3(this.red && !num.red, "redPow(normalNum)");
2594
+ assert2(this.red && !num.red, "redPow(normalNum)");
2595
2595
  this.red._verify1(this);
2596
2596
  return this.red.pow(this, num);
2597
2597
  };
@@ -2652,7 +2652,7 @@
2652
2652
  }
2653
2653
  inherits(K256, MPrime);
2654
2654
  K256.prototype.split = function split2(input, output2) {
2655
- var mask2 = 4194303;
2655
+ var mask = 4194303;
2656
2656
  var outLen = Math.min(input.length, 9);
2657
2657
  for (var i = 0; i < outLen; i++) {
2658
2658
  output2.words[i] = input.words[i];
@@ -2664,10 +2664,10 @@
2664
2664
  return;
2665
2665
  }
2666
2666
  var prev = input.words[9];
2667
- output2.words[output2.length++] = prev & mask2;
2667
+ output2.words[output2.length++] = prev & mask;
2668
2668
  for (i = 10; i < input.length; i++) {
2669
2669
  var next = input.words[i] | 0;
2670
- input.words[i - 10] = (next & mask2) << 4 | prev >>> 22;
2670
+ input.words[i - 10] = (next & mask) << 4 | prev >>> 22;
2671
2671
  prev = next;
2672
2672
  }
2673
2673
  prev >>>= 22;
@@ -2759,18 +2759,18 @@
2759
2759
  this.m = prime.p;
2760
2760
  this.prime = prime;
2761
2761
  } else {
2762
- assert3(m.gtn(1), "modulus must be greater than 1");
2762
+ assert2(m.gtn(1), "modulus must be greater than 1");
2763
2763
  this.m = m;
2764
2764
  this.prime = null;
2765
2765
  }
2766
2766
  }
2767
2767
  Red.prototype._verify1 = function _verify1(a) {
2768
- assert3(a.negative === 0, "red works only with positives");
2769
- assert3(a.red, "red works only with red numbers");
2768
+ assert2(a.negative === 0, "red works only with positives");
2769
+ assert2(a.red, "red works only with red numbers");
2770
2770
  };
2771
2771
  Red.prototype._verify2 = function _verify2(a, b) {
2772
- assert3((a.negative | b.negative) === 0, "red works only with positives");
2773
- assert3(
2772
+ assert2((a.negative | b.negative) === 0, "red works only with positives");
2773
+ assert2(
2774
2774
  a.red && a.red === b.red,
2775
2775
  "red works only with red numbers"
2776
2776
  );
@@ -2841,7 +2841,7 @@
2841
2841
  if (a.isZero())
2842
2842
  return a.clone();
2843
2843
  var mod3 = this.m.andln(3);
2844
- assert3(mod3 % 2 === 1);
2844
+ assert2(mod3 % 2 === 1);
2845
2845
  if (mod3 === 3) {
2846
2846
  var pow3 = this.m.add(new BN2(1)).iushrn(2);
2847
2847
  return this.pow(a, pow3);
@@ -2852,7 +2852,7 @@
2852
2852
  s++;
2853
2853
  q.iushrn(1);
2854
2854
  }
2855
- assert3(!q.isZero());
2855
+ assert2(!q.isZero());
2856
2856
  var one = new BN2(1).toRed(this);
2857
2857
  var nOne = one.redNeg();
2858
2858
  var lpow = this.m.subn(1).iushrn(1);
@@ -2870,7 +2870,7 @@
2870
2870
  for (var i = 0; tmp.cmp(one) !== 0; i++) {
2871
2871
  tmp = tmp.redSqr();
2872
2872
  }
2873
- assert3(i < m);
2873
+ assert2(i < m);
2874
2874
  var b = this.pow(c, new BN2(1).iushln(m - i - 1));
2875
2875
  r = r.redMul(b);
2876
2876
  c = b.redSqr();
@@ -29470,13 +29470,13 @@ spurious results.`);
29470
29470
  // ../versions/dist/index.mjs
29471
29471
  function getBuiltinVersions() {
29472
29472
  return {
29473
- FORC: "0.56.1",
29473
+ FORC: "0.58.0",
29474
29474
  FUEL_CORE: "0.26.0",
29475
29475
  FUELS: "0.85.0"
29476
29476
  };
29477
29477
  }
29478
- function parseVersion(version2) {
29479
- const [major, minor, patch] = version2.split(".").map((v) => parseInt(v, 10));
29478
+ function parseVersion(version) {
29479
+ const [major, minor, patch] = version.split(".").map((v) => parseInt(v, 10));
29480
29480
  return { major, minor, patch };
29481
29481
  }
29482
29482
  function versionDiffs(version1, version2) {
@@ -30036,6 +30036,123 @@ This unreleased fuel-core build may include features and updates not yet support
30036
30036
  }
30037
30037
  return hexlify(bytes2.slice(start == null ? 0 : start, end == null ? bytes2.length : end));
30038
30038
  }
30039
+ function toUtf8Bytes(stri, form = true) {
30040
+ let str = stri;
30041
+ if (form) {
30042
+ str = stri.normalize("NFC");
30043
+ }
30044
+ const result = [];
30045
+ for (let i = 0; i < str.length; i += 1) {
30046
+ const c = str.charCodeAt(i);
30047
+ if (c < 128) {
30048
+ result.push(c);
30049
+ } else if (c < 2048) {
30050
+ result.push(c >> 6 | 192);
30051
+ result.push(c & 63 | 128);
30052
+ } else if ((c & 64512) === 55296) {
30053
+ i += 1;
30054
+ const c2 = str.charCodeAt(i);
30055
+ if (i >= str.length || (c2 & 64512) !== 56320) {
30056
+ throw new FuelError(
30057
+ ErrorCode.INVALID_INPUT_PARAMETERS,
30058
+ "Invalid UTF-8 in the input string."
30059
+ );
30060
+ }
30061
+ const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
30062
+ result.push(pair >> 18 | 240);
30063
+ result.push(pair >> 12 & 63 | 128);
30064
+ result.push(pair >> 6 & 63 | 128);
30065
+ result.push(pair & 63 | 128);
30066
+ } else {
30067
+ result.push(c >> 12 | 224);
30068
+ result.push(c >> 6 & 63 | 128);
30069
+ result.push(c & 63 | 128);
30070
+ }
30071
+ }
30072
+ return new Uint8Array(result);
30073
+ }
30074
+ function onError(reason, offset, bytes2, output2, badCodepoint) {
30075
+ console.log(`invalid codepoint at offset ${offset}; ${reason}, bytes: ${bytes2}`);
30076
+ return offset;
30077
+ }
30078
+ function helper(codePoints) {
30079
+ return codePoints.map((codePoint) => {
30080
+ if (codePoint <= 65535) {
30081
+ return String.fromCharCode(codePoint);
30082
+ }
30083
+ codePoint -= 65536;
30084
+ return String.fromCharCode(
30085
+ (codePoint >> 10 & 1023) + 55296,
30086
+ (codePoint & 1023) + 56320
30087
+ );
30088
+ }).join("");
30089
+ }
30090
+ function getUtf8CodePoints(_bytes) {
30091
+ const bytes2 = arrayify(_bytes, "bytes");
30092
+ const result = [];
30093
+ let i = 0;
30094
+ while (i < bytes2.length) {
30095
+ const c = bytes2[i++];
30096
+ if (c >> 7 === 0) {
30097
+ result.push(c);
30098
+ continue;
30099
+ }
30100
+ let extraLength = null;
30101
+ let overlongMask = null;
30102
+ if ((c & 224) === 192) {
30103
+ extraLength = 1;
30104
+ overlongMask = 127;
30105
+ } else if ((c & 240) === 224) {
30106
+ extraLength = 2;
30107
+ overlongMask = 2047;
30108
+ } else if ((c & 248) === 240) {
30109
+ extraLength = 3;
30110
+ overlongMask = 65535;
30111
+ } else {
30112
+ if ((c & 192) === 128) {
30113
+ i += onError("UNEXPECTED_CONTINUE", i - 1, bytes2, result);
30114
+ } else {
30115
+ i += onError("BAD_PREFIX", i - 1, bytes2, result);
30116
+ }
30117
+ continue;
30118
+ }
30119
+ if (i - 1 + extraLength >= bytes2.length) {
30120
+ i += onError("OVERRUN", i - 1, bytes2, result);
30121
+ continue;
30122
+ }
30123
+ let res = c & (1 << 8 - extraLength - 1) - 1;
30124
+ for (let j = 0; j < extraLength; j++) {
30125
+ const nextChar = bytes2[i];
30126
+ if ((nextChar & 192) !== 128) {
30127
+ i += onError("MISSING_CONTINUE", i, bytes2, result);
30128
+ res = null;
30129
+ break;
30130
+ }
30131
+ res = res << 6 | nextChar & 63;
30132
+ i++;
30133
+ }
30134
+ if (res === null) {
30135
+ continue;
30136
+ }
30137
+ if (res > 1114111) {
30138
+ i += onError("OUT_OF_RANGE", i - 1 - extraLength, bytes2, result, res);
30139
+ continue;
30140
+ }
30141
+ if (res >= 55296 && res <= 57343) {
30142
+ i += onError("UTF16_SURROGATE", i - 1 - extraLength, bytes2, result, res);
30143
+ continue;
30144
+ }
30145
+ if (res <= overlongMask) {
30146
+ i += onError("OVERLONG", i - 1 - extraLength, bytes2, result, res);
30147
+ continue;
30148
+ }
30149
+ result.push(res);
30150
+ }
30151
+ return result;
30152
+ }
30153
+ function toUtf8String(bytes2) {
30154
+ return helper(getUtf8CodePoints(bytes2));
30155
+ }
30039
30156
 
30040
30157
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/ripemd160.js
30041
30158
  var Rho = /* @__PURE__ */ new Uint8Array([7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8]);
@@ -30147,13 +30264,13 @@ This unreleased fuel-core build may include features and updates not yet support
30147
30264
  };
30148
30265
  var keccak256 = (data) => keccak_256(data);
30149
30266
  var locked = false;
30150
- var helper = (data) => ripemd160(data);
30151
- var ripemd = helper;
30267
+ var helper2 = (data) => ripemd160(data);
30268
+ var ripemd = helper2;
30152
30269
  function ripemd1602(_data) {
30153
30270
  const data = arrayify(_data, "data");
30154
30271
  return ripemd(data);
30155
30272
  }
30156
- ripemd1602._ = helper;
30273
+ ripemd1602._ = helper2;
30157
30274
  ripemd1602.lock = () => {
30158
30275
  locked = true;
30159
30276
  };
@@ -30757,316 +30874,6 @@ This unreleased fuel-core build may include features and updates not yet support
30757
30874
  return coinQuantities;
30758
30875
  };
30759
30876
 
30760
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
30761
- var version = "6.7.1";
30762
-
30763
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/properties.js
30764
- function checkType(value, type3, name) {
30765
- const types = type3.split("|").map((t) => t.trim());
30766
- for (let i = 0; i < types.length; i++) {
30767
- switch (type3) {
30768
- case "any":
30769
- return;
30770
- case "bigint":
30771
- case "boolean":
30772
- case "number":
30773
- case "string":
30774
- if (typeof value === type3) {
30775
- return;
30776
- }
30777
- }
30778
- }
30779
- const error = new Error(`invalid value for type ${type3}`);
30780
- error.code = "INVALID_ARGUMENT";
30781
- error.argument = `value.${name}`;
30782
- error.value = value;
30783
- throw error;
30784
- }
30785
- function defineProperties(target, values, types) {
30786
- for (let key in values) {
30787
- let value = values[key];
30788
- const type3 = types ? types[key] : null;
30789
- if (type3) {
30790
- checkType(value, type3, key);
30791
- }
30792
- Object.defineProperty(target, key, { enumerable: true, value, writable: false });
30793
- }
30794
- }
30795
-
30796
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/errors.js
30797
- function stringify(value) {
30798
- if (value == null) {
30799
- return "null";
30800
- }
30801
- if (Array.isArray(value)) {
30802
- return "[ " + value.map(stringify).join(", ") + " ]";
30803
- }
30804
- if (value instanceof Uint8Array) {
30805
- const HEX = "0123456789abcdef";
30806
- let result = "0x";
30807
- for (let i = 0; i < value.length; i++) {
30808
- result += HEX[value[i] >> 4];
30809
- result += HEX[value[i] & 15];
30810
- }
30811
- return result;
30812
- }
30813
- if (typeof value === "object" && typeof value.toJSON === "function") {
30814
- return stringify(value.toJSON());
30815
- }
30816
- switch (typeof value) {
30817
- case "boolean":
30818
- case "symbol":
30819
- return value.toString();
30820
- case "bigint":
30821
- return BigInt(value).toString();
30822
- case "number":
30823
- return value.toString();
30824
- case "string":
30825
- return JSON.stringify(value);
30826
- case "object": {
30827
- const keys = Object.keys(value);
30828
- keys.sort();
30829
- return "{ " + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(", ") + " }";
30830
- }
30831
- }
30832
- return `[ COULD NOT SERIALIZE ]`;
30833
- }
30834
- function makeError(message, code, info) {
30835
- {
30836
- const details = [];
30837
- if (info) {
30838
- if ("message" in info || "code" in info || "name" in info) {
30839
- throw new Error(`value will overwrite populated values: ${stringify(info)}`);
30840
- }
30841
- for (const key in info) {
30842
- const value = info[key];
30843
- details.push(key + "=" + stringify(value));
30844
- }
30845
- }
30846
- details.push(`code=${code}`);
30847
- details.push(`version=${version}`);
30848
- if (details.length) {
30849
- message += " (" + details.join(", ") + ")";
30850
- }
30851
- }
30852
- let error;
30853
- switch (code) {
30854
- case "INVALID_ARGUMENT":
30855
- error = new TypeError(message);
30856
- break;
30857
- case "NUMERIC_FAULT":
30858
- case "BUFFER_OVERRUN":
30859
- error = new RangeError(message);
30860
- break;
30861
- default:
30862
- error = new Error(message);
30863
- }
30864
- defineProperties(error, { code });
30865
- if (info) {
30866
- Object.assign(error, info);
30867
- }
30868
- return error;
30869
- }
30870
- function assert(check, message, code, info) {
30871
- if (!check) {
30872
- throw makeError(message, code, info);
30873
- }
30874
- }
30875
- function assertArgument(check, message, name, value) {
30876
- assert(check, message, "INVALID_ARGUMENT", { argument: name, value });
30877
- }
30878
- var _normalizeForms = ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
30879
- try {
30880
- if ("test".normalize(form) !== "test") {
30881
- throw new Error("bad");
30882
- }
30883
- ;
30884
- if (form === "NFD") {
30885
- const check = String.fromCharCode(233).normalize("NFD");
30886
- const expected = String.fromCharCode(101, 769);
30887
- if (check !== expected) {
30888
- throw new Error("broken");
30889
- }
30890
- }
30891
- accum.push(form);
30892
- } catch (error) {
30893
- }
30894
- return accum;
30895
- }, []);
30896
- function assertNormalize(form) {
30897
- assert(_normalizeForms.indexOf(form) >= 0, "platform missing String.prototype.normalize", "UNSUPPORTED_OPERATION", {
30898
- operation: "String.prototype.normalize",
30899
- info: { form }
30900
- });
30901
- }
30902
-
30903
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/data.js
30904
- function _getBytes(value, name, copy) {
30905
- if (value instanceof Uint8Array) {
30906
- if (copy) {
30907
- return new Uint8Array(value);
30908
- }
30909
- return value;
30910
- }
30911
- if (typeof value === "string" && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) {
30912
- const result = new Uint8Array((value.length - 2) / 2);
30913
- let offset = 2;
30914
- for (let i = 0; i < result.length; i++) {
30915
- result[i] = parseInt(value.substring(offset, offset + 2), 16);
30916
- offset += 2;
30917
- }
30918
- return result;
30919
- }
30920
- assertArgument(false, "invalid BytesLike value", name || "value", value);
30921
- }
30922
- function getBytes(value, name) {
30923
- return _getBytes(value, name, false);
30924
- }
30925
-
30926
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/utils/utf8.js
30927
- function errorFunc(reason, offset, bytes2, output2, badCodepoint) {
30928
- assertArgument(false, `invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes2);
30929
- }
30930
- function ignoreFunc(reason, offset, bytes2, output2, badCodepoint) {
30931
- if (reason === "BAD_PREFIX" || reason === "UNEXPECTED_CONTINUE") {
30932
- let i = 0;
30933
- for (let o = offset + 1; o < bytes2.length; o++) {
30934
- if (bytes2[o] >> 6 !== 2) {
30935
- break;
30936
- }
30937
- i++;
30938
- }
30939
- return i;
30940
- }
30941
- if (reason === "OVERRUN") {
30942
- return bytes2.length - offset - 1;
30943
- }
30944
- return 0;
30945
- }
30946
- function replaceFunc(reason, offset, bytes2, output2, badCodepoint) {
30947
- if (reason === "OVERLONG") {
30948
- assertArgument(typeof badCodepoint === "number", "invalid bad code point for replacement", "badCodepoint", badCodepoint);
30949
- output2.push(badCodepoint);
30950
- return 0;
30951
- }
30952
- output2.push(65533);
30953
- return ignoreFunc(reason, offset, bytes2, output2, badCodepoint);
30954
- }
30955
- var Utf8ErrorFuncs = Object.freeze({
30956
- error: errorFunc,
30957
- ignore: ignoreFunc,
30958
- replace: replaceFunc
30959
- });
30960
- function getUtf8CodePoints(_bytes, onError) {
30961
- if (onError == null) {
30962
- onError = Utf8ErrorFuncs.error;
30963
- }
30964
- const bytes2 = getBytes(_bytes, "bytes");
30965
- const result = [];
30966
- let i = 0;
30967
- while (i < bytes2.length) {
30968
- const c = bytes2[i++];
30969
- if (c >> 7 === 0) {
30970
- result.push(c);
30971
- continue;
30972
- }
30973
- let extraLength = null;
30974
- let overlongMask = null;
30975
- if ((c & 224) === 192) {
30976
- extraLength = 1;
30977
- overlongMask = 127;
30978
- } else if ((c & 240) === 224) {
30979
- extraLength = 2;
30980
- overlongMask = 2047;
30981
- } else if ((c & 248) === 240) {
30982
- extraLength = 3;
30983
- overlongMask = 65535;
30984
- } else {
30985
- if ((c & 192) === 128) {
30986
- i += onError("UNEXPECTED_CONTINUE", i - 1, bytes2, result);
30987
- } else {
30988
- i += onError("BAD_PREFIX", i - 1, bytes2, result);
30989
- }
30990
- continue;
30991
- }
30992
- if (i - 1 + extraLength >= bytes2.length) {
30993
- i += onError("OVERRUN", i - 1, bytes2, result);
30994
- continue;
30995
- }
30996
- let res = c & (1 << 8 - extraLength - 1) - 1;
30997
- for (let j = 0; j < extraLength; j++) {
30998
- let nextChar = bytes2[i];
30999
- if ((nextChar & 192) != 128) {
31000
- i += onError("MISSING_CONTINUE", i, bytes2, result);
31001
- res = null;
31002
- break;
31003
- }
31004
- ;
31005
- res = res << 6 | nextChar & 63;
31006
- i++;
31007
- }
31008
- if (res === null) {
31009
- continue;
31010
- }
31011
- if (res > 1114111) {
31012
- i += onError("OUT_OF_RANGE", i - 1 - extraLength, bytes2, result, res);
31013
- continue;
31014
- }
31015
- if (res >= 55296 && res <= 57343) {
31016
- i += onError("UTF16_SURROGATE", i - 1 - extraLength, bytes2, result, res);
31017
- continue;
31018
- }
31019
- if (res <= overlongMask) {
31020
- i += onError("OVERLONG", i - 1 - extraLength, bytes2, result, res);
31021
- continue;
31022
- }
31023
- result.push(res);
31024
- }
31025
- return result;
31026
- }
31027
- function toUtf8Bytes(str, form) {
31028
- if (form != null) {
31029
- assertNormalize(form);
31030
- str = str.normalize(form);
31031
- }
31032
- let result = [];
31033
- for (let i = 0; i < str.length; i++) {
31034
- const c = str.charCodeAt(i);
31035
- if (c < 128) {
31036
- result.push(c);
31037
- } else if (c < 2048) {
31038
- result.push(c >> 6 | 192);
31039
- result.push(c & 63 | 128);
31040
- } else if ((c & 64512) == 55296) {
31041
- i++;
31042
- const c2 = str.charCodeAt(i);
31043
- assertArgument(i < str.length && (c2 & 64512) === 56320, "invalid surrogate pair", "str", str);
31044
- const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
31045
- result.push(pair >> 18 | 240);
31046
- result.push(pair >> 12 & 63 | 128);
31047
- result.push(pair >> 6 & 63 | 128);
31048
- result.push(pair & 63 | 128);
31049
- } else {
31050
- result.push(c >> 12 | 224);
31051
- result.push(c >> 6 & 63 | 128);
31052
- result.push(c & 63 | 128);
31053
- }
31054
- }
31055
- return new Uint8Array(result);
31056
- }
31057
- function _toUtf8String(codePoints) {
31058
- return codePoints.map((codePoint) => {
31059
- if (codePoint <= 65535) {
31060
- return String.fromCharCode(codePoint);
31061
- }
31062
- codePoint -= 65536;
31063
- return String.fromCharCode((codePoint >> 10 & 1023) + 55296, (codePoint & 1023) + 56320);
31064
- }).join("");
31065
- }
31066
- function toUtf8String(bytes2, onError) {
31067
- return _toUtf8String(getUtf8CodePoints(bytes2, onError));
31068
- }
31069
-
31070
30877
  // ../hasher/dist/index.mjs
31071
30878
  function sha2562(data) {
31072
30879
  return hexlify(sha256(arrayify(data)));
@@ -31092,19 +30899,6 @@ This unreleased fuel-core build may include features and updates not yet support
31092
30899
  __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value);
31093
30900
  return value;
31094
30901
  };
31095
- var __accessCheck2 = (obj, member, msg) => {
31096
- if (!member.has(obj))
31097
- throw TypeError("Cannot " + msg);
31098
- };
31099
- var __privateAdd2 = (obj, member, value) => {
31100
- if (member.has(obj))
31101
- throw TypeError("Cannot add the same private member more than once");
31102
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
31103
- };
31104
- var __privateMethod2 = (obj, member, method) => {
31105
- __accessCheck2(obj, member, "access private method");
31106
- return method;
31107
- };
31108
30902
  var Coder = class {
31109
30903
  name;
31110
30904
  type;
@@ -31136,7 +30930,6 @@ This unreleased fuel-core build may include features and updates not yet support
31136
30930
  var enumRegEx = /^enum (?<name>\w+)$/;
31137
30931
  var tupleRegEx = /^\((?<items>.*)\)$/;
31138
30932
  var genericRegEx = /^generic (?<name>\w+)$/;
31139
- var ENCODING_V0 = "0";
31140
30933
  var ENCODING_V1 = "1";
31141
30934
  var WORD_SIZE = 8;
31142
30935
  var BYTES_32 = 32;
@@ -31147,10 +30940,6 @@ This unreleased fuel-core build may include features and updates not yet support
31147
30940
  var TX_LEN = WORD_SIZE * 4;
31148
30941
  var TX_POINTER_LEN = WORD_SIZE * 2;
31149
30942
  var MAX_BYTES = 2 ** 32 - 1;
31150
- var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
31151
- ASSET_ID_LEN + // Base asset ID
31152
- // Asset ID/Balance coin input pairs
31153
- maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
31154
30943
  var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
31155
30944
  WORD_SIZE + // Gas limit
31156
30945
  WORD_SIZE + // Script size
@@ -31181,125 +30970,6 @@ This unreleased fuel-core build may include features and updates not yet support
31181
30970
  WORD_SIZE + // Predicate size
31182
30971
  WORD_SIZE + // Predicate data size
31183
30972
  WORD_SIZE;
31184
- var encodedLengths = {
31185
- u64: WORD_SIZE,
31186
- u256: WORD_SIZE * 4
31187
- };
31188
- var BigNumberCoder = class extends Coder {
31189
- constructor(baseType) {
31190
- super("bigNumber", baseType, encodedLengths[baseType]);
31191
- }
31192
- encode(value) {
31193
- let bytes2;
31194
- try {
31195
- bytes2 = toBytes2(value, this.encodedLength);
31196
- } catch (error) {
31197
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.type}.`);
31198
- }
31199
- return bytes2;
31200
- }
31201
- decode(data, offset) {
31202
- if (data.length < this.encodedLength) {
31203
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} data size.`);
31204
- }
31205
- let bytes2 = data.slice(offset, offset + this.encodedLength);
31206
- bytes2 = bytes2.slice(0, this.encodedLength);
31207
- if (bytes2.length !== this.encodedLength) {
31208
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} byte data size.`);
31209
- }
31210
- return [bn(bytes2), offset + this.encodedLength];
31211
- }
31212
- };
31213
- var VEC_PROPERTY_SPACE = 3;
31214
- var BASE_VECTOR_OFFSET = VEC_PROPERTY_SPACE * WORD_SIZE;
31215
- var RAW_SLICE_PROPERTY_SPACE = 2;
31216
- var BASE_RAW_SLICE_OFFSET = RAW_SLICE_PROPERTY_SPACE * WORD_SIZE;
31217
- function concatWithDynamicData(items) {
31218
- const topLevelData = {};
31219
- let totalIndex = 0;
31220
- const objects = items.map((item) => {
31221
- const dynamicData = item.dynamicData;
31222
- if (dynamicData) {
31223
- Object.entries(dynamicData).forEach(([pointerIndex, vData]) => {
31224
- topLevelData[parseInt(pointerIndex, 10) + totalIndex] = vData;
31225
- });
31226
- }
31227
- const byteArray = arrayify(item);
31228
- totalIndex += byteArray.byteLength / WORD_SIZE;
31229
- return byteArray;
31230
- });
31231
- const length = objects.reduce((accum, item) => accum + item.length, 0);
31232
- const result = new Uint8Array(length);
31233
- objects.reduce((offset, object) => {
31234
- result.set(object, offset);
31235
- return offset + object.length;
31236
- }, 0);
31237
- if (Object.keys(topLevelData).length) {
31238
- result.dynamicData = topLevelData;
31239
- }
31240
- return result;
31241
- }
31242
- function unpackDynamicData(results, baseOffset, dataOffset) {
31243
- if (!results.dynamicData) {
31244
- return concat([results]);
31245
- }
31246
- let cumulativeDynamicByteLength = 0;
31247
- let updatedResults = results;
31248
- Object.entries(results.dynamicData).forEach(([pointerIndex, vData]) => {
31249
- const pointerOffset = parseInt(pointerIndex, 10) * WORD_SIZE;
31250
- const adjustedValue = new BigNumberCoder("u64").encode(
31251
- dataOffset + baseOffset + cumulativeDynamicByteLength
31252
- );
31253
- updatedResults.set(adjustedValue, pointerOffset);
31254
- const dataToAppend = vData.dynamicData ? (
31255
- // unpack child dynamic data
31256
- unpackDynamicData(
31257
- vData,
31258
- baseOffset,
31259
- dataOffset + vData.byteLength + cumulativeDynamicByteLength
31260
- )
31261
- ) : vData;
31262
- updatedResults = concat([updatedResults, dataToAppend]);
31263
- cumulativeDynamicByteLength += dataToAppend.byteLength;
31264
- });
31265
- return updatedResults;
31266
- }
31267
- var chunkByLength = (data, length = WORD_SIZE) => {
31268
- const chunks = [];
31269
- let offset = 0;
31270
- let chunk = data.slice(offset, offset + length);
31271
- while (chunk.length) {
31272
- chunks.push(chunk);
31273
- offset += length;
31274
- chunk = data.slice(offset, offset + length);
31275
- }
31276
- return chunks;
31277
- };
31278
- var isPointerType = (type3) => {
31279
- switch (type3) {
31280
- case "u8":
31281
- case "u16":
31282
- case "u32":
31283
- case "u64":
31284
- case "bool": {
31285
- return false;
31286
- }
31287
- default: {
31288
- return true;
31289
- }
31290
- }
31291
- };
31292
- var isHeapType = (type3) => type3 === VEC_CODER_TYPE || type3 === BYTES_CODER_TYPE || type3 === STD_STRING_CODER_TYPE;
31293
- var isMultipleOfWordSize = (length) => length % WORD_SIZE === 0;
31294
- var getWordSizePadding = (length) => WORD_SIZE - length % WORD_SIZE;
31295
- var rightPadToWordSize = (encoded) => {
31296
- if (isMultipleOfWordSize(encoded.length)) {
31297
- return encoded;
31298
- }
31299
- const padding = new Uint8Array(WORD_SIZE - encoded.length % WORD_SIZE);
31300
- return concatBytes2([encoded, padding]);
31301
- };
31302
- var isUint8Array = (value) => value instanceof Uint8Array;
31303
30973
  var ArrayCoder = class extends Coder {
31304
30974
  coder;
31305
30975
  length;
@@ -31315,7 +30985,7 @@ This unreleased fuel-core build may include features and updates not yet support
31315
30985
  if (this.length !== value.length) {
31316
30986
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Types/values length mismatch.`);
31317
30987
  }
31318
- return concatWithDynamicData(Array.from(value).map((v) => this.coder.encode(v)));
30988
+ return concat(Array.from(value).map((v) => this.coder.encode(v)));
31319
30989
  }
31320
30990
  decode(data, offset) {
31321
30991
  if (data.length < this.encodedLength || data.length > MAX_BYTES) {
@@ -31392,763 +31062,43 @@ This unreleased fuel-core build may include features and updates not yet support
31392
31062
  return [toHex(bytes2, this.encodedLength), offset + this.encodedLength];
31393
31063
  }
31394
31064
  };
31395
- var BooleanCoder = class extends Coder {
31396
- paddingLength;
31397
- options;
31398
- constructor(options = {
31399
- isSmallBytes: false,
31400
- isRightPadded: false
31401
- }) {
31402
- const paddingLength = options.isSmallBytes ? 1 : 8;
31403
- super("boolean", "boolean", paddingLength);
31404
- this.paddingLength = paddingLength;
31405
- this.options = options;
31406
- }
31407
- encode(value) {
31408
- const isTrueBool = value === true || value === false;
31409
- if (!isTrueBool) {
31410
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid boolean value.`);
31411
- }
31412
- const output2 = toBytes2(value ? 1 : 0, this.paddingLength);
31413
- if (this.options.isRightPadded) {
31414
- return output2.reverse();
31415
- }
31416
- return output2;
31417
- }
31418
- decode(data, offset) {
31419
- if (data.length < this.paddingLength) {
31420
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean data size.`);
31421
- }
31422
- let bytes2;
31423
- if (this.options.isRightPadded) {
31424
- bytes2 = data.slice(offset, offset + 1);
31425
- } else {
31426
- bytes2 = data.slice(offset, offset + this.paddingLength);
31427
- }
31428
- const decodedValue = bn(bytes2);
31429
- if (decodedValue.isZero()) {
31430
- return [false, offset + this.paddingLength];
31431
- }
31432
- if (!decodedValue.eq(bn(1))) {
31433
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean value.`);
31434
- }
31435
- return [true, offset + this.paddingLength];
31436
- }
31437
- };
31438
- var _getPaddedData;
31439
- var getPaddedData_fn;
31440
- var ByteCoder = class extends Coder {
31441
- constructor() {
31442
- super("struct", "struct Bytes", BASE_VECTOR_OFFSET);
31443
- __privateAdd2(this, _getPaddedData);
31444
- }
31445
- encode(value) {
31446
- const parts = [];
31447
- const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
31448
- const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
31449
- pointer.dynamicData = {
31450
- 0: concatWithDynamicData([data])
31451
- };
31452
- parts.push(pointer);
31453
- parts.push(new BigNumberCoder("u64").encode(data.byteLength));
31454
- parts.push(new BigNumberCoder("u64").encode(value.length));
31455
- return concatWithDynamicData(parts);
31456
- }
31457
- decode(data, offset) {
31458
- if (data.length < BASE_VECTOR_OFFSET) {
31459
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid byte data size.`);
31460
- }
31461
- const len = data.slice(16, 24);
31462
- const encodedLength = bn(new BigNumberCoder("u64").decode(len, 0)[0]).toNumber();
31463
- const byteData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + encodedLength);
31464
- if (byteData.length !== encodedLength) {
31465
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid bytes byte data size.`);
31466
- }
31467
- return [byteData, offset + BASE_VECTOR_OFFSET];
31468
- }
31469
- };
31470
- _getPaddedData = /* @__PURE__ */ new WeakSet();
31471
- getPaddedData_fn = function(value) {
31472
- const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
31473
- const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
31474
- if (paddingLength) {
31475
- data.push(new Uint8Array(paddingLength));
31476
- }
31477
- return concat(data);
31478
- };
31479
- __publicField4(ByteCoder, "memorySize", 1);
31480
- var isFullyNativeEnum = (enumCoders) => Object.values(enumCoders).every(
31481
- // @ts-expect-error complicated types
31482
- ({ type: type3, coders }) => type3 === "()" && JSON.stringify(coders) === JSON.stringify([])
31483
- );
31484
- var EnumCoder = class extends Coder {
31485
- name;
31486
- coders;
31487
- #caseIndexCoder;
31488
- #encodedValueSize;
31489
- constructor(name, coders) {
31490
- const caseIndexCoder = new BigNumberCoder("u64");
31491
- const encodedValueSize = Object.values(coders).reduce(
31492
- (max, coder) => Math.max(max, coder.encodedLength),
31493
- 0
31494
- );
31495
- super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
31496
- this.name = name;
31497
- this.coders = coders;
31498
- this.#caseIndexCoder = caseIndexCoder;
31499
- this.#encodedValueSize = encodedValueSize;
31500
- }
31501
- #encodeNativeEnum(value) {
31502
- const valueCoder = this.coders[value];
31503
- const encodedValue = valueCoder.encode([]);
31504
- const caseIndex = Object.keys(this.coders).indexOf(value);
31505
- const padding = new Uint8Array(this.#encodedValueSize - valueCoder.encodedLength);
31506
- return concat([this.#caseIndexCoder.encode(caseIndex), padding, encodedValue]);
31507
- }
31508
- encode(value) {
31509
- if (typeof value === "string" && this.coders[value]) {
31510
- return this.#encodeNativeEnum(value);
31511
- }
31512
- const [caseKey, ...empty] = Object.keys(value);
31513
- if (!caseKey) {
31514
- throw new FuelError(ErrorCode.INVALID_DECODE_VALUE, "A field for the case must be provided.");
31515
- }
31516
- if (empty.length !== 0) {
31517
- throw new FuelError(ErrorCode.INVALID_DECODE_VALUE, "Only one field must be provided.");
31518
- }
31519
- const valueCoder = this.coders[caseKey];
31520
- const caseIndex = Object.keys(this.coders).indexOf(caseKey);
31521
- const encodedValue = valueCoder.encode(value[caseKey]);
31522
- const padding = new Uint8Array(this.#encodedValueSize - valueCoder.encodedLength);
31523
- return concatWithDynamicData([this.#caseIndexCoder.encode(caseIndex), padding, encodedValue]);
31524
- }
31525
- #decodeNativeEnum(caseKey, newOffset) {
31526
- return [caseKey, newOffset];
31527
- }
31528
- decode(data, offset) {
31529
- if (data.length < this.#encodedValueSize) {
31530
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid enum data size.`);
31531
- }
31532
- let newOffset = offset;
31533
- let decoded;
31534
- [decoded, newOffset] = new BigNumberCoder("u64").decode(data, newOffset);
31535
- const caseIndex = toNumber(decoded);
31536
- const caseKey = Object.keys(this.coders)[caseIndex];
31537
- if (!caseKey) {
31538
- throw new FuelError(
31539
- ErrorCode.INVALID_DECODE_VALUE,
31540
- `Invalid caseIndex "${caseIndex}". Valid cases: ${Object.keys(this.coders)}.`
31541
- );
31542
- }
31543
- const valueCoder = this.coders[caseKey];
31544
- const padding = this.#encodedValueSize - valueCoder.encodedLength;
31545
- newOffset += padding;
31546
- [decoded, newOffset] = valueCoder.decode(data, newOffset);
31547
- if (isFullyNativeEnum(this.coders)) {
31548
- return this.#decodeNativeEnum(caseKey, newOffset);
31549
- }
31550
- return [{ [caseKey]: decoded }, newOffset];
31551
- }
31552
- };
31553
- var OptionCoder = class extends EnumCoder {
31554
- encode(value) {
31555
- const result = super.encode(this.toSwayOption(value));
31556
- return result;
31557
- }
31558
- toSwayOption(input) {
31559
- if (input !== void 0) {
31560
- return { Some: input };
31561
- }
31562
- return { None: [] };
31563
- }
31564
- decode(data, offset) {
31565
- if (data.length < this.encodedLength) {
31566
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
31567
- }
31568
- const [decoded, newOffset] = super.decode(data, offset);
31569
- return [this.toOption(decoded), newOffset];
31570
- }
31571
- toOption(output2) {
31572
- if (output2 && "Some" in output2) {
31573
- return output2.Some;
31574
- }
31575
- return void 0;
31576
- }
31065
+ var encodedLengths = {
31066
+ u64: WORD_SIZE,
31067
+ u256: WORD_SIZE * 4
31577
31068
  };
31578
- var NumberCoder = class extends Coder {
31579
- // This is to align the bits to the total bytes
31580
- // See https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/abi.md#unsigned-integers
31581
- length;
31582
- paddingLength;
31583
- baseType;
31584
- options;
31585
- constructor(baseType, options = {
31586
- isSmallBytes: false,
31587
- isRightPadded: false
31588
- }) {
31589
- const paddingLength = options.isSmallBytes && baseType === "u8" ? 1 : 8;
31590
- super("number", baseType, paddingLength);
31591
- this.baseType = baseType;
31592
- switch (baseType) {
31593
- case "u8":
31594
- this.length = 1;
31595
- break;
31596
- case "u16":
31597
- this.length = 2;
31598
- break;
31599
- case "u32":
31600
- default:
31601
- this.length = 4;
31602
- break;
31603
- }
31604
- this.paddingLength = paddingLength;
31605
- this.options = options;
31069
+ var BigNumberCoder = class extends Coder {
31070
+ constructor(baseType) {
31071
+ super("bigNumber", baseType, encodedLengths[baseType]);
31606
31072
  }
31607
31073
  encode(value) {
31608
31074
  let bytes2;
31609
31075
  try {
31610
- bytes2 = toBytes2(value);
31076
+ bytes2 = toBytes2(value, this.encodedLength);
31611
31077
  } catch (error) {
31612
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}.`);
31613
- }
31614
- if (bytes2.length > this.length) {
31615
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}, too many bytes.`);
31616
- }
31617
- const output2 = toBytes2(bytes2, this.paddingLength);
31618
- if (this.baseType !== "u8") {
31619
- return output2;
31620
- }
31621
- return this.options.isRightPadded ? output2.reverse() : output2;
31622
- }
31623
- decodeU8(data, offset) {
31624
- let bytes2;
31625
- if (this.options.isRightPadded) {
31626
- bytes2 = data.slice(offset, offset + 1);
31627
- } else {
31628
- bytes2 = data.slice(offset, offset + this.paddingLength);
31629
- bytes2 = bytes2.slice(this.paddingLength - this.length, this.paddingLength);
31630
- }
31631
- return [toNumber(bytes2), offset + this.paddingLength];
31632
- }
31633
- decode(data, offset) {
31634
- if (data.length < this.paddingLength) {
31635
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number data size.`);
31636
- }
31637
- if (this.baseType === "u8") {
31638
- return this.decodeU8(data, offset);
31639
- }
31640
- let bytes2 = data.slice(offset, offset + this.paddingLength);
31641
- bytes2 = bytes2.slice(8 - this.length, 8);
31642
- if (bytes2.length !== this.paddingLength - (this.paddingLength - this.length)) {
31643
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number byte data size.`);
31644
- }
31645
- return [toNumber(bytes2), offset + 8];
31646
- }
31647
- };
31648
- var RawSliceCoder = class extends Coder {
31649
- constructor() {
31650
- super("raw untyped slice", "raw untyped slice", BASE_RAW_SLICE_OFFSET);
31651
- }
31652
- encode(value) {
31653
- if (!Array.isArray(value)) {
31654
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
31655
- }
31656
- const parts = [];
31657
- const coder = new NumberCoder("u8", { isSmallBytes: true });
31658
- const pointer = new BigNumberCoder("u64").encode(
31659
- BASE_RAW_SLICE_OFFSET
31660
- );
31661
- pointer.dynamicData = {
31662
- 0: concatWithDynamicData(value.map((v) => coder.encode(v)))
31663
- };
31664
- parts.push(pointer);
31665
- parts.push(new BigNumberCoder("u64").encode(value.length));
31666
- return concatWithDynamicData(parts);
31667
- }
31668
- decode(data, offset) {
31669
- const dataBytes = data.slice(offset);
31670
- const internalCoder = new ArrayCoder(
31671
- new NumberCoder("u8", { isSmallBytes: true }),
31672
- dataBytes.length
31673
- );
31674
- const [decodedValue] = internalCoder.decode(dataBytes, 0);
31675
- return [decodedValue, offset + dataBytes.length];
31676
- }
31677
- };
31678
- var _getPaddedData2;
31679
- var getPaddedData_fn2;
31680
- var StdStringCoder = class extends Coder {
31681
- constructor() {
31682
- super("struct", "struct String", 1);
31683
- __privateAdd2(this, _getPaddedData2);
31684
- }
31685
- encode(value) {
31686
- const parts = [];
31687
- const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
31688
- const data = __privateMethod2(this, _getPaddedData2, getPaddedData_fn2).call(this, value);
31689
- pointer.dynamicData = {
31690
- 0: concatWithDynamicData([data])
31691
- };
31692
- parts.push(pointer);
31693
- parts.push(new BigNumberCoder("u64").encode(data.byteLength));
31694
- parts.push(new BigNumberCoder("u64").encode(value.length));
31695
- return concatWithDynamicData(parts);
31696
- }
31697
- decode(data, offset) {
31698
- if (data.length < this.encodedLength) {
31699
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string data size.`);
31700
- }
31701
- const len = data.slice(16, 24);
31702
- const encodedLength = bn(new BigNumberCoder("u64").decode(len, 0)[0]).toNumber();
31703
- const byteData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + encodedLength);
31704
- if (byteData.length !== encodedLength) {
31705
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string byte data size.`);
31706
- }
31707
- const value = toUtf8String(byteData);
31708
- return [value, offset + BASE_VECTOR_OFFSET];
31709
- }
31710
- };
31711
- _getPaddedData2 = /* @__PURE__ */ new WeakSet();
31712
- getPaddedData_fn2 = function(value) {
31713
- const data = [toUtf8Bytes(value)];
31714
- const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
31715
- if (paddingLength) {
31716
- data.push(new Uint8Array(paddingLength));
31717
- }
31718
- return concat(data);
31719
- };
31720
- __publicField4(StdStringCoder, "memorySize", 1);
31721
- var StringCoder = class extends Coder {
31722
- length;
31723
- #paddingLength;
31724
- constructor(length) {
31725
- let paddingLength = (8 - length) % 8;
31726
- paddingLength = paddingLength < 0 ? paddingLength + 8 : paddingLength;
31727
- super("string", `str[${length}]`, length + paddingLength);
31728
- this.length = length;
31729
- this.#paddingLength = paddingLength;
31730
- }
31731
- encode(value) {
31732
- if (this.length !== value.length) {
31733
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Value length mismatch during encode.`);
31734
- }
31735
- const encoded = toUtf8Bytes(value);
31736
- const padding = new Uint8Array(this.#paddingLength);
31737
- return concat([encoded, padding]);
31738
- }
31739
- decode(data, offset) {
31740
- if (data.length < this.encodedLength) {
31741
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string data size.`);
31742
- }
31743
- const bytes2 = data.slice(offset, offset + this.length);
31744
- if (bytes2.length !== this.length) {
31745
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string byte data size.`);
31746
- }
31747
- const value = toUtf8String(bytes2);
31748
- const padding = this.#paddingLength;
31749
- return [value, offset + this.length + padding];
31750
- }
31751
- };
31752
- var StructCoder = class extends Coder {
31753
- name;
31754
- coders;
31755
- constructor(name, coders) {
31756
- const encodedLength = Object.values(coders).reduce(
31757
- (acc, coder) => acc + coder.encodedLength,
31758
- 0
31759
- );
31760
- super("struct", `struct ${name}`, encodedLength);
31761
- this.name = name;
31762
- this.coders = coders;
31763
- }
31764
- encode(value) {
31765
- const encodedFields = Object.keys(this.coders).map((fieldName) => {
31766
- const fieldCoder = this.coders[fieldName];
31767
- const fieldValue = value[fieldName];
31768
- if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
31769
- throw new FuelError(
31770
- ErrorCode.ENCODE_ERROR,
31771
- `Invalid ${this.type}. Field "${fieldName}" not present.`
31772
- );
31773
- }
31774
- const encoded = fieldCoder.encode(fieldValue);
31775
- if (!isMultipleOfWordSize(encoded.length)) {
31776
- return rightPadToWordSize(encoded);
31777
- }
31778
- return encoded;
31779
- });
31780
- return concatWithDynamicData([concatWithDynamicData(encodedFields)]);
31781
- }
31782
- decode(data, offset) {
31783
- if (data.length < this.encodedLength) {
31784
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid struct data size.`);
31785
- }
31786
- let newOffset = offset;
31787
- const decodedValue = Object.keys(this.coders).reduce((obj, fieldName) => {
31788
- const fieldCoder = this.coders[fieldName];
31789
- let decoded;
31790
- [decoded, newOffset] = fieldCoder.decode(data, newOffset);
31791
- if (!isMultipleOfWordSize(newOffset)) {
31792
- newOffset += getWordSizePadding(newOffset);
31793
- }
31794
- obj[fieldName] = decoded;
31795
- return obj;
31796
- }, {});
31797
- return [decodedValue, newOffset];
31798
- }
31799
- };
31800
- var TupleCoder = class extends Coder {
31801
- coders;
31802
- constructor(coders) {
31803
- const encodedLength = coders.reduce((acc, coder) => acc + coder.encodedLength, 0);
31804
- super("tuple", `(${coders.map((coder) => coder.type).join(", ")})`, encodedLength);
31805
- this.coders = coders;
31806
- }
31807
- encode(value) {
31808
- if (this.coders.length !== value.length) {
31809
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Types/values length mismatch.`);
31078
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.type}.`);
31810
31079
  }
31811
- return concatWithDynamicData(
31812
- this.coders.map((coder, i) => {
31813
- const encoded = coder.encode(value[i]);
31814
- if (!isMultipleOfWordSize(encoded.length)) {
31815
- return rightPadToWordSize(encoded);
31816
- }
31817
- return encoded;
31818
- })
31819
- );
31080
+ return bytes2;
31820
31081
  }
31821
31082
  decode(data, offset) {
31822
31083
  if (data.length < this.encodedLength) {
31823
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid tuple data size.`);
31824
- }
31825
- let newOffset = offset;
31826
- const decodedValue = this.coders.map((coder) => {
31827
- let decoded;
31828
- [decoded, newOffset] = coder.decode(data, newOffset);
31829
- if (!isMultipleOfWordSize(newOffset)) {
31830
- newOffset += getWordSizePadding(newOffset);
31831
- }
31832
- return decoded;
31833
- });
31834
- return [decodedValue, newOffset];
31835
- }
31836
- };
31837
- var VecCoder = class extends Coder {
31838
- coder;
31839
- constructor(coder) {
31840
- super("struct", `struct Vec`, coder.encodedLength + BASE_VECTOR_OFFSET);
31841
- this.coder = coder;
31842
- }
31843
- encode(value) {
31844
- if (!Array.isArray(value) && !isUint8Array(value)) {
31845
- throw new FuelError(
31846
- ErrorCode.ENCODE_ERROR,
31847
- `Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.`
31848
- );
31849
- }
31850
- const parts = [];
31851
- const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
31852
- pointer.dynamicData = {
31853
- 0: concatWithDynamicData(Array.from(value).map((v) => this.coder.encode(v)))
31854
- };
31855
- parts.push(pointer);
31856
- parts.push(new BigNumberCoder("u64").encode(value.length));
31857
- parts.push(new BigNumberCoder("u64").encode(value.length));
31858
- return concatWithDynamicData(parts);
31859
- }
31860
- decode(data, offset) {
31861
- if (data.length < BASE_VECTOR_OFFSET || data.length > MAX_BYTES) {
31862
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec data size.`);
31863
- }
31864
- const len = data.slice(16, 24);
31865
- const encodedLength = bn(new BigNumberCoder("u64").decode(len, 0)[0]).toNumber();
31866
- const vectorRawDataLength = encodedLength * this.coder.encodedLength;
31867
- const vectorRawData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + vectorRawDataLength);
31868
- if (vectorRawData.length !== vectorRawDataLength) {
31869
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec byte data size.`);
31870
- }
31871
- return [
31872
- chunkByLength(vectorRawData, this.coder.encodedLength).map(
31873
- (chunk) => this.coder.decode(chunk, 0)[0]
31874
- ),
31875
- offset + BASE_VECTOR_OFFSET
31876
- ];
31877
- }
31878
- };
31879
- var getEncodingVersion = (encoding) => {
31880
- switch (encoding) {
31881
- case void 0:
31882
- case ENCODING_V0:
31883
- return ENCODING_V0;
31884
- case ENCODING_V1:
31885
- return ENCODING_V1;
31886
- default:
31887
- throw new FuelError(
31888
- ErrorCode.UNSUPPORTED_ENCODING_VERSION,
31889
- `Encoding version '${encoding}' is unsupported.`
31890
- );
31891
- }
31892
- };
31893
- var findFunctionByName = (abi, name) => {
31894
- const fn = abi.functions.find((f2) => f2.name === name);
31895
- if (!fn) {
31896
- throw new FuelError(
31897
- ErrorCode.FUNCTION_NOT_FOUND,
31898
- `Function with name '${name}' doesn't exist in the ABI`
31899
- );
31900
- }
31901
- return fn;
31902
- };
31903
- var findTypeById = (abi, typeId) => {
31904
- const type3 = abi.types.find((t) => t.typeId === typeId);
31905
- if (!type3) {
31906
- throw new FuelError(
31907
- ErrorCode.TYPE_NOT_FOUND,
31908
- `Type with typeId '${typeId}' doesn't exist in the ABI.`
31909
- );
31910
- }
31911
- return type3;
31912
- };
31913
- var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
31914
- var findVectorBufferArgument = (components) => {
31915
- const bufferComponent = components.find((c) => c.name === "buf");
31916
- const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
31917
- if (!bufferComponent || !bufferTypeArgument) {
31918
- throw new FuelError(
31919
- ErrorCode.INVALID_COMPONENT,
31920
- `The Vec type provided is missing or has a malformed 'buf' component.`
31921
- );
31922
- }
31923
- return bufferTypeArgument;
31924
- };
31925
- var ResolvedAbiType = class {
31926
- abi;
31927
- name;
31928
- type;
31929
- originalTypeArguments;
31930
- components;
31931
- constructor(abi, argument) {
31932
- this.abi = abi;
31933
- this.name = argument.name;
31934
- const type3 = findTypeById(abi, argument.type);
31935
- this.type = type3.type;
31936
- this.originalTypeArguments = argument.typeArguments;
31937
- this.components = ResolvedAbiType.getResolvedGenericComponents(
31938
- abi,
31939
- argument,
31940
- type3.components,
31941
- type3.typeParameters ?? ResolvedAbiType.getImplicitGenericTypeParameters(abi, type3.components)
31942
- );
31943
- }
31944
- static getResolvedGenericComponents(abi, arg, components, typeParameters) {
31945
- if (components === null) {
31946
- return null;
31947
- }
31948
- if (typeParameters === null || typeParameters.length === 0) {
31949
- return components.map((c) => new ResolvedAbiType(abi, c));
31950
- }
31951
- const typeParametersAndArgsMap = typeParameters.reduce(
31952
- (obj, typeParameter, typeParameterIndex) => {
31953
- const o = { ...obj };
31954
- o[typeParameter] = structuredClone(
31955
- arg.typeArguments?.[typeParameterIndex]
31956
- );
31957
- return o;
31958
- },
31959
- {}
31960
- );
31961
- const resolvedComponents = this.resolveGenericArgTypes(
31962
- abi,
31963
- components,
31964
- typeParametersAndArgsMap
31965
- );
31966
- return resolvedComponents.map((c) => new ResolvedAbiType(abi, c));
31967
- }
31968
- static resolveGenericArgTypes(abi, args, typeParametersAndArgsMap) {
31969
- return args.map((arg) => {
31970
- if (typeParametersAndArgsMap[arg.type] !== void 0) {
31971
- return {
31972
- ...typeParametersAndArgsMap[arg.type],
31973
- name: arg.name
31974
- };
31975
- }
31976
- if (arg.typeArguments) {
31977
- return {
31978
- ...structuredClone(arg),
31979
- typeArguments: this.resolveGenericArgTypes(
31980
- abi,
31981
- arg.typeArguments,
31982
- typeParametersAndArgsMap
31983
- )
31984
- };
31985
- }
31986
- const argType = findTypeById(abi, arg.type);
31987
- const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
31988
- if (implicitTypeParameters && implicitTypeParameters.length > 0) {
31989
- return {
31990
- ...structuredClone(arg),
31991
- typeArguments: implicitTypeParameters.map((itp) => typeParametersAndArgsMap[itp])
31992
- };
31993
- }
31994
- return arg;
31995
- });
31996
- }
31997
- static getImplicitGenericTypeParameters(abi, args, implicitGenericParametersParam) {
31998
- if (!Array.isArray(args)) {
31999
- return null;
32000
- }
32001
- const implicitGenericParameters = implicitGenericParametersParam ?? [];
32002
- args.forEach((a) => {
32003
- const argType = findTypeById(abi, a.type);
32004
- if (genericRegEx.test(argType.type)) {
32005
- implicitGenericParameters.push(argType.typeId);
32006
- return;
32007
- }
32008
- if (!Array.isArray(a.typeArguments)) {
32009
- return;
32010
- }
32011
- this.getImplicitGenericTypeParameters(abi, a.typeArguments, implicitGenericParameters);
32012
- });
32013
- return implicitGenericParameters.length > 0 ? implicitGenericParameters : null;
32014
- }
32015
- getSignature() {
32016
- const prefix = this.getArgSignaturePrefix();
32017
- const content = this.getArgSignatureContent();
32018
- return `${prefix}${content}`;
32019
- }
32020
- getArgSignaturePrefix() {
32021
- const structMatch = structRegEx.test(this.type);
32022
- if (structMatch) {
32023
- return "s";
32024
- }
32025
- const arrayMatch = arrayRegEx.test(this.type);
32026
- if (arrayMatch) {
32027
- return "a";
32028
- }
32029
- const enumMatch = enumRegEx.test(this.type);
32030
- if (enumMatch) {
32031
- return "e";
32032
- }
32033
- return "";
32034
- }
32035
- getArgSignatureContent() {
32036
- if (this.type === "raw untyped ptr") {
32037
- return "rawptr";
32038
- }
32039
- if (this.type === "raw untyped slice") {
32040
- return "rawslice";
32041
- }
32042
- const strMatch = stringRegEx.exec(this.type)?.groups;
32043
- if (strMatch) {
32044
- return `str[${strMatch.length}]`;
32045
- }
32046
- if (this.components === null) {
32047
- return this.type;
32048
- }
32049
- const arrayMatch = arrayRegEx.exec(this.type)?.groups;
32050
- if (arrayMatch) {
32051
- return `[${this.components[0].getSignature()};${arrayMatch.length}]`;
32052
- }
32053
- const typeArgumentsSignature = this.originalTypeArguments !== null ? `<${this.originalTypeArguments.map((a) => new ResolvedAbiType(this.abi, a).getSignature()).join(",")}>` : "";
32054
- const componentsSignature = `(${this.components.map((c) => c.getSignature()).join(",")})`;
32055
- return `${typeArgumentsSignature}${componentsSignature}`;
32056
- }
32057
- };
32058
- function getCoders(components, options) {
32059
- const { getCoder: getCoder3 } = options;
32060
- return components.reduce((obj, component) => {
32061
- const o = obj;
32062
- o[component.name] = getCoder3(component, options);
32063
- return o;
32064
- }, {});
32065
- }
32066
- var getCoder = (resolvedAbiType, options) => {
32067
- switch (resolvedAbiType.type) {
32068
- case U8_CODER_TYPE:
32069
- case U16_CODER_TYPE:
32070
- case U32_CODER_TYPE:
32071
- return new NumberCoder(resolvedAbiType.type, options);
32072
- case U64_CODER_TYPE:
32073
- case RAW_PTR_CODER_TYPE:
32074
- return new BigNumberCoder("u64");
32075
- case U256_CODER_TYPE:
32076
- return new BigNumberCoder("u256");
32077
- case RAW_SLICE_CODER_TYPE:
32078
- return new RawSliceCoder();
32079
- case BOOL_CODER_TYPE:
32080
- return new BooleanCoder(options);
32081
- case B256_CODER_TYPE:
32082
- return new B256Coder();
32083
- case B512_CODER_TYPE:
32084
- return new B512Coder();
32085
- case BYTES_CODER_TYPE:
32086
- return new ByteCoder();
32087
- case STD_STRING_CODER_TYPE:
32088
- return new StdStringCoder();
32089
- default:
32090
- break;
32091
- }
32092
- const stringMatch = stringRegEx.exec(resolvedAbiType.type)?.groups;
32093
- if (stringMatch) {
32094
- const length = parseInt(stringMatch.length, 10);
32095
- return new StringCoder(length);
32096
- }
32097
- const components = resolvedAbiType.components;
32098
- const arrayMatch = arrayRegEx.exec(resolvedAbiType.type)?.groups;
32099
- if (arrayMatch) {
32100
- const length = parseInt(arrayMatch.length, 10);
32101
- const arg = components[0];
32102
- if (!arg) {
32103
- throw new FuelError(
32104
- ErrorCode.INVALID_COMPONENT,
32105
- `The provided Array type is missing an item of 'component'.`
32106
- );
31084
+ throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} data size.`);
32107
31085
  }
32108
- const arrayElementCoder = getCoder(arg, { isSmallBytes: true });
32109
- return new ArrayCoder(arrayElementCoder, length);
32110
- }
32111
- if (resolvedAbiType.type === VEC_CODER_TYPE) {
32112
- const arg = findVectorBufferArgument(components);
32113
- const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
32114
- const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
32115
- return new VecCoder(itemCoder);
32116
- }
32117
- const structMatch = structRegEx.exec(resolvedAbiType.type)?.groups;
32118
- if (structMatch) {
32119
- const coders = getCoders(components, { isRightPadded: true, getCoder });
32120
- return new StructCoder(structMatch.name, coders);
32121
- }
32122
- const enumMatch = enumRegEx.exec(resolvedAbiType.type)?.groups;
32123
- if (enumMatch) {
32124
- const coders = getCoders(components, { getCoder });
32125
- const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
32126
- if (isOptionEnum) {
32127
- return new OptionCoder(enumMatch.name, coders);
31086
+ let bytes2 = data.slice(offset, offset + this.encodedLength);
31087
+ bytes2 = bytes2.slice(0, this.encodedLength);
31088
+ if (bytes2.length !== this.encodedLength) {
31089
+ throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} byte data size.`);
32128
31090
  }
32129
- return new EnumCoder(enumMatch.name, coders);
32130
- }
32131
- const tupleMatch = tupleRegEx.exec(resolvedAbiType.type)?.groups;
32132
- if (tupleMatch) {
32133
- const coders = components.map(
32134
- (component) => getCoder(component, { isRightPadded: true, encoding: ENCODING_V0 })
32135
- );
32136
- return new TupleCoder(coders);
32137
- }
32138
- if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
32139
- throw new FuelError(
32140
- ErrorCode.INVALID_DATA,
32141
- "String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
32142
- );
31091
+ return [bn(bytes2), offset + this.encodedLength];
32143
31092
  }
32144
- throw new FuelError(
32145
- ErrorCode.CODER_NOT_FOUND,
32146
- `Coder not found: ${JSON.stringify(resolvedAbiType)}.`
32147
- );
32148
31093
  };
32149
- var BooleanCoder2 = class extends Coder {
32150
- constructor() {
32151
- super("boolean", "boolean", 1);
31094
+ var BooleanCoder = class extends Coder {
31095
+ options;
31096
+ constructor(options = {
31097
+ padToWordSize: false
31098
+ }) {
31099
+ const encodedLength = options.padToWordSize ? WORD_SIZE : 1;
31100
+ super("boolean", "boolean", encodedLength);
31101
+ this.options = options;
32152
31102
  }
32153
31103
  encode(value) {
32154
31104
  const isTrueBool = value === true || value === false;
@@ -32171,7 +31121,7 @@ This unreleased fuel-core build may include features and updates not yet support
32171
31121
  return [true, offset + this.encodedLength];
32172
31122
  }
32173
31123
  };
32174
- var ByteCoder2 = class extends Coder {
31124
+ var ByteCoder = class extends Coder {
32175
31125
  constructor() {
32176
31126
  super("struct", "struct Bytes", WORD_SIZE);
32177
31127
  }
@@ -32194,12 +31144,12 @@ This unreleased fuel-core build may include features and updates not yet support
32194
31144
  return [dataBytes, offsetAndLength + length];
32195
31145
  }
32196
31146
  };
32197
- __publicField4(ByteCoder2, "memorySize", 1);
32198
- var isFullyNativeEnum2 = (enumCoders) => Object.values(enumCoders).every(
31147
+ __publicField4(ByteCoder, "memorySize", 1);
31148
+ var isFullyNativeEnum = (enumCoders) => Object.values(enumCoders).every(
32199
31149
  // @ts-expect-error complicated types
32200
31150
  ({ type: type3, coders }) => type3 === "()" && JSON.stringify(coders) === JSON.stringify([])
32201
31151
  );
32202
- var EnumCoder2 = class extends Coder {
31152
+ var EnumCoder = class extends Coder {
32203
31153
  name;
32204
31154
  coders;
32205
31155
  #caseIndexCoder;
@@ -32258,7 +31208,7 @@ This unreleased fuel-core build may include features and updates not yet support
32258
31208
  const valueCoder = this.coders[caseKey];
32259
31209
  const offsetAndCase = offset + WORD_SIZE;
32260
31210
  const [decoded, newOffset] = valueCoder.decode(data, offsetAndCase);
32261
- if (isFullyNativeEnum2(this.coders)) {
31211
+ if (isFullyNativeEnum(this.coders)) {
32262
31212
  return this.#decodeNativeEnum(caseKey, newOffset);
32263
31213
  }
32264
31214
  return [{ [caseKey]: decoded }, newOffset];
@@ -32276,14 +31226,16 @@ This unreleased fuel-core build may include features and updates not yet support
32276
31226
  throw new FuelError(ErrorCode.TYPE_NOT_SUPPORTED, `Invalid number type: ${baseType}`);
32277
31227
  }
32278
31228
  };
32279
- var NumberCoder2 = class extends Coder {
32280
- length;
31229
+ var NumberCoder = class extends Coder {
32281
31230
  baseType;
32282
- constructor(baseType) {
32283
- const length = getLength(baseType);
31231
+ options;
31232
+ constructor(baseType, options = {
31233
+ padToWordSize: false
31234
+ }) {
31235
+ const length = options.padToWordSize ? WORD_SIZE : getLength(baseType);
32284
31236
  super("number", baseType, length);
32285
31237
  this.baseType = baseType;
32286
- this.length = length;
31238
+ this.options = options;
32287
31239
  }
32288
31240
  encode(value) {
32289
31241
  let bytes2;
@@ -32292,23 +31244,23 @@ This unreleased fuel-core build may include features and updates not yet support
32292
31244
  } catch (error) {
32293
31245
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}.`);
32294
31246
  }
32295
- if (bytes2.length > this.length) {
31247
+ if (bytes2.length > this.encodedLength) {
32296
31248
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}, too many bytes.`);
32297
31249
  }
32298
- return toBytes2(bytes2, this.length);
31250
+ return toBytes2(bytes2, this.encodedLength);
32299
31251
  }
32300
31252
  decode(data, offset) {
32301
31253
  if (data.length < this.encodedLength) {
32302
31254
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number data size.`);
32303
31255
  }
32304
- const bytes2 = data.slice(offset, offset + this.length);
31256
+ const bytes2 = data.slice(offset, offset + this.encodedLength);
32305
31257
  if (bytes2.length !== this.encodedLength) {
32306
31258
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number byte data size.`);
32307
31259
  }
32308
- return [toNumber(bytes2), offset + this.length];
31260
+ return [toNumber(bytes2), offset + this.encodedLength];
32309
31261
  }
32310
31262
  };
32311
- var OptionCoder2 = class extends EnumCoder2 {
31263
+ var OptionCoder = class extends EnumCoder {
32312
31264
  encode(value) {
32313
31265
  const result = super.encode(this.toSwayOption(value));
32314
31266
  return result;
@@ -32330,7 +31282,7 @@ This unreleased fuel-core build may include features and updates not yet support
32330
31282
  return void 0;
32331
31283
  }
32332
31284
  };
32333
- var RawSliceCoder2 = class extends Coder {
31285
+ var RawSliceCoder = class extends Coder {
32334
31286
  constructor() {
32335
31287
  super("raw untyped slice", "raw untyped slice", WORD_SIZE);
32336
31288
  }
@@ -32338,7 +31290,7 @@ This unreleased fuel-core build may include features and updates not yet support
32338
31290
  if (!Array.isArray(value)) {
32339
31291
  throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
32340
31292
  }
32341
- const internalCoder = new ArrayCoder(new NumberCoder2("u8"), value.length);
31293
+ const internalCoder = new ArrayCoder(new NumberCoder("u8"), value.length);
32342
31294
  const bytes2 = internalCoder.encode(value);
32343
31295
  const lengthBytes = new BigNumberCoder("u64").encode(bytes2.length);
32344
31296
  return new Uint8Array([...lengthBytes, ...bytes2]);
@@ -32354,12 +31306,12 @@ This unreleased fuel-core build may include features and updates not yet support
32354
31306
  if (dataBytes.length !== length) {
32355
31307
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid raw slice byte data size.`);
32356
31308
  }
32357
- const internalCoder = new ArrayCoder(new NumberCoder2("u8"), length);
31309
+ const internalCoder = new ArrayCoder(new NumberCoder("u8"), length);
32358
31310
  const [decodedValue] = internalCoder.decode(dataBytes, 0);
32359
31311
  return [decodedValue, offsetAndLength + length];
32360
31312
  }
32361
31313
  };
32362
- var StdStringCoder2 = class extends Coder {
31314
+ var StdStringCoder = class extends Coder {
32363
31315
  constructor() {
32364
31316
  super("struct", "struct String", WORD_SIZE);
32365
31317
  }
@@ -32382,7 +31334,7 @@ This unreleased fuel-core build may include features and updates not yet support
32382
31334
  return [toUtf8String(dataBytes), offsetAndLength + length];
32383
31335
  }
32384
31336
  };
32385
- __publicField4(StdStringCoder2, "memorySize", 1);
31337
+ __publicField4(StdStringCoder, "memorySize", 1);
32386
31338
  var StrSliceCoder = class extends Coder {
32387
31339
  constructor() {
32388
31340
  super("strSlice", "str", WORD_SIZE);
@@ -32407,7 +31359,7 @@ This unreleased fuel-core build may include features and updates not yet support
32407
31359
  }
32408
31360
  };
32409
31361
  __publicField4(StrSliceCoder, "memorySize", 1);
32410
- var StringCoder2 = class extends Coder {
31362
+ var StringCoder = class extends Coder {
32411
31363
  constructor(length) {
32412
31364
  super("string", `str[${length}]`, length);
32413
31365
  }
@@ -32428,7 +31380,7 @@ This unreleased fuel-core build may include features and updates not yet support
32428
31380
  return [toUtf8String(bytes2), offset + this.encodedLength];
32429
31381
  }
32430
31382
  };
32431
- var StructCoder2 = class extends Coder {
31383
+ var StructCoder = class extends Coder {
32432
31384
  name;
32433
31385
  coders;
32434
31386
  constructor(name, coders) {
@@ -32445,7 +31397,7 @@ This unreleased fuel-core build may include features and updates not yet support
32445
31397
  Object.keys(this.coders).map((fieldName) => {
32446
31398
  const fieldCoder = this.coders[fieldName];
32447
31399
  const fieldValue = value[fieldName];
32448
- if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
31400
+ if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
32449
31401
  throw new FuelError(
32450
31402
  ErrorCode.ENCODE_ERROR,
32451
31403
  `Invalid ${this.type}. Field "${fieldName}" not present.`
@@ -32470,7 +31422,7 @@ This unreleased fuel-core build may include features and updates not yet support
32470
31422
  return [decodedValue, newOffset];
32471
31423
  }
32472
31424
  };
32473
- var TupleCoder2 = class extends Coder {
31425
+ var TupleCoder = class extends Coder {
32474
31426
  coders;
32475
31427
  constructor(coders) {
32476
31428
  const encodedLength = coders.reduce((acc, coder) => acc + coder.encodedLength, 0);
@@ -32496,13 +31448,14 @@ This unreleased fuel-core build may include features and updates not yet support
32496
31448
  return [decodedValue, newOffset];
32497
31449
  }
32498
31450
  };
32499
- var VecCoder2 = class extends Coder {
31451
+ var isUint8Array = (value) => value instanceof Uint8Array;
31452
+ var VecCoder = class extends Coder {
32500
31453
  coder;
32501
31454
  #isOptionVec;
32502
31455
  constructor(coder) {
32503
31456
  super("struct", `struct Vec`, coder.encodedLength + WORD_SIZE);
32504
31457
  this.coder = coder;
32505
- this.#isOptionVec = this.coder instanceof OptionCoder2;
31458
+ this.#isOptionVec = this.coder instanceof OptionCoder;
32506
31459
  }
32507
31460
  encode(value) {
32508
31461
  if (!Array.isArray(value) && !isUint8Array(value)) {
@@ -32526,9 +31479,9 @@ This unreleased fuel-core build may include features and updates not yet support
32526
31479
  const offsetAndLength = offset + WORD_SIZE;
32527
31480
  const lengthBytes = data.slice(offset, offsetAndLength);
32528
31481
  const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
32529
- const dataLength2 = length * this.coder.encodedLength;
32530
- const dataBytes = data.slice(offsetAndLength, offsetAndLength + dataLength2);
32531
- if (!this.#isOptionVec && dataBytes.length !== dataLength2) {
31482
+ const dataLength = length * this.coder.encodedLength;
31483
+ const dataBytes = data.slice(offsetAndLength, offsetAndLength + dataLength);
31484
+ if (!this.#isOptionVec && dataBytes.length !== dataLength) {
32532
31485
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec byte data size.`);
32533
31486
  }
32534
31487
  let newOffset = offsetAndLength;
@@ -32541,29 +31494,214 @@ This unreleased fuel-core build may include features and updates not yet support
32541
31494
  return [chunks, newOffset];
32542
31495
  }
32543
31496
  };
32544
- var getCoder2 = (resolvedAbiType, _options) => {
31497
+ var getEncodingVersion = (encoding) => {
31498
+ switch (encoding) {
31499
+ case void 0:
31500
+ case ENCODING_V1:
31501
+ return ENCODING_V1;
31502
+ default:
31503
+ throw new FuelError(
31504
+ ErrorCode.UNSUPPORTED_ENCODING_VERSION,
31505
+ `Encoding version '${encoding}' is unsupported.`
31506
+ );
31507
+ }
31508
+ };
31509
+ var findFunctionByName = (abi, name) => {
31510
+ const fn = abi.functions.find((f2) => f2.name === name);
31511
+ if (!fn) {
31512
+ throw new FuelError(
31513
+ ErrorCode.FUNCTION_NOT_FOUND,
31514
+ `Function with name '${name}' doesn't exist in the ABI`
31515
+ );
31516
+ }
31517
+ return fn;
31518
+ };
31519
+ var findTypeById = (abi, typeId) => {
31520
+ const type3 = abi.types.find((t) => t.typeId === typeId);
31521
+ if (!type3) {
31522
+ throw new FuelError(
31523
+ ErrorCode.TYPE_NOT_FOUND,
31524
+ `Type with typeId '${typeId}' doesn't exist in the ABI.`
31525
+ );
31526
+ }
31527
+ return type3;
31528
+ };
31529
+ var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
31530
+ var findVectorBufferArgument = (components) => {
31531
+ const bufferComponent = components.find((c) => c.name === "buf");
31532
+ const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
31533
+ if (!bufferComponent || !bufferTypeArgument) {
31534
+ throw new FuelError(
31535
+ ErrorCode.INVALID_COMPONENT,
31536
+ `The Vec type provided is missing or has a malformed 'buf' component.`
31537
+ );
31538
+ }
31539
+ return bufferTypeArgument;
31540
+ };
31541
+ var ResolvedAbiType = class {
31542
+ abi;
31543
+ name;
31544
+ type;
31545
+ originalTypeArguments;
31546
+ components;
31547
+ constructor(abi, argument) {
31548
+ this.abi = abi;
31549
+ this.name = argument.name;
31550
+ const type3 = findTypeById(abi, argument.type);
31551
+ this.type = type3.type;
31552
+ this.originalTypeArguments = argument.typeArguments;
31553
+ this.components = ResolvedAbiType.getResolvedGenericComponents(
31554
+ abi,
31555
+ argument,
31556
+ type3.components,
31557
+ type3.typeParameters ?? ResolvedAbiType.getImplicitGenericTypeParameters(abi, type3.components)
31558
+ );
31559
+ }
31560
+ static getResolvedGenericComponents(abi, arg, components, typeParameters) {
31561
+ if (components === null) {
31562
+ return null;
31563
+ }
31564
+ if (typeParameters === null || typeParameters.length === 0) {
31565
+ return components.map((c) => new ResolvedAbiType(abi, c));
31566
+ }
31567
+ const typeParametersAndArgsMap = typeParameters.reduce(
31568
+ (obj, typeParameter, typeParameterIndex) => {
31569
+ const o = { ...obj };
31570
+ o[typeParameter] = structuredClone(
31571
+ arg.typeArguments?.[typeParameterIndex]
31572
+ );
31573
+ return o;
31574
+ },
31575
+ {}
31576
+ );
31577
+ const resolvedComponents = this.resolveGenericArgTypes(
31578
+ abi,
31579
+ components,
31580
+ typeParametersAndArgsMap
31581
+ );
31582
+ return resolvedComponents.map((c) => new ResolvedAbiType(abi, c));
31583
+ }
31584
+ static resolveGenericArgTypes(abi, args, typeParametersAndArgsMap) {
31585
+ return args.map((arg) => {
31586
+ if (typeParametersAndArgsMap[arg.type] !== void 0) {
31587
+ return {
31588
+ ...typeParametersAndArgsMap[arg.type],
31589
+ name: arg.name
31590
+ };
31591
+ }
31592
+ if (arg.typeArguments) {
31593
+ return {
31594
+ ...structuredClone(arg),
31595
+ typeArguments: this.resolveGenericArgTypes(
31596
+ abi,
31597
+ arg.typeArguments,
31598
+ typeParametersAndArgsMap
31599
+ )
31600
+ };
31601
+ }
31602
+ const argType = findTypeById(abi, arg.type);
31603
+ const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
31604
+ if (implicitTypeParameters && implicitTypeParameters.length > 0) {
31605
+ return {
31606
+ ...structuredClone(arg),
31607
+ typeArguments: implicitTypeParameters.map((itp) => typeParametersAndArgsMap[itp])
31608
+ };
31609
+ }
31610
+ return arg;
31611
+ });
31612
+ }
31613
+ static getImplicitGenericTypeParameters(abi, args, implicitGenericParametersParam) {
31614
+ if (!Array.isArray(args)) {
31615
+ return null;
31616
+ }
31617
+ const implicitGenericParameters = implicitGenericParametersParam ?? [];
31618
+ args.forEach((a) => {
31619
+ const argType = findTypeById(abi, a.type);
31620
+ if (genericRegEx.test(argType.type)) {
31621
+ implicitGenericParameters.push(argType.typeId);
31622
+ return;
31623
+ }
31624
+ if (!Array.isArray(a.typeArguments)) {
31625
+ return;
31626
+ }
31627
+ this.getImplicitGenericTypeParameters(abi, a.typeArguments, implicitGenericParameters);
31628
+ });
31629
+ return implicitGenericParameters.length > 0 ? implicitGenericParameters : null;
31630
+ }
31631
+ getSignature() {
31632
+ const prefix = this.getArgSignaturePrefix();
31633
+ const content = this.getArgSignatureContent();
31634
+ return `${prefix}${content}`;
31635
+ }
31636
+ getArgSignaturePrefix() {
31637
+ const structMatch = structRegEx.test(this.type);
31638
+ if (structMatch) {
31639
+ return "s";
31640
+ }
31641
+ const arrayMatch = arrayRegEx.test(this.type);
31642
+ if (arrayMatch) {
31643
+ return "a";
31644
+ }
31645
+ const enumMatch = enumRegEx.test(this.type);
31646
+ if (enumMatch) {
31647
+ return "e";
31648
+ }
31649
+ return "";
31650
+ }
31651
+ getArgSignatureContent() {
31652
+ if (this.type === "raw untyped ptr") {
31653
+ return "rawptr";
31654
+ }
31655
+ if (this.type === "raw untyped slice") {
31656
+ return "rawslice";
31657
+ }
31658
+ const strMatch = stringRegEx.exec(this.type)?.groups;
31659
+ if (strMatch) {
31660
+ return `str[${strMatch.length}]`;
31661
+ }
31662
+ if (this.components === null) {
31663
+ return this.type;
31664
+ }
31665
+ const arrayMatch = arrayRegEx.exec(this.type)?.groups;
31666
+ if (arrayMatch) {
31667
+ return `[${this.components[0].getSignature()};${arrayMatch.length}]`;
31668
+ }
31669
+ const typeArgumentsSignature = this.originalTypeArguments !== null ? `<${this.originalTypeArguments.map((a) => new ResolvedAbiType(this.abi, a).getSignature()).join(",")}>` : "";
31670
+ const componentsSignature = `(${this.components.map((c) => c.getSignature()).join(",")})`;
31671
+ return `${typeArgumentsSignature}${componentsSignature}`;
31672
+ }
31673
+ };
31674
+ function getCoders(components, options) {
31675
+ const { getCoder: getCoder2 } = options;
31676
+ return components.reduce((obj, component) => {
31677
+ const o = obj;
31678
+ o[component.name] = getCoder2(component, options);
31679
+ return o;
31680
+ }, {});
31681
+ }
31682
+ var getCoder = (resolvedAbiType, _options) => {
32545
31683
  switch (resolvedAbiType.type) {
32546
31684
  case U8_CODER_TYPE:
32547
31685
  case U16_CODER_TYPE:
32548
31686
  case U32_CODER_TYPE:
32549
- return new NumberCoder2(resolvedAbiType.type);
31687
+ return new NumberCoder(resolvedAbiType.type);
32550
31688
  case U64_CODER_TYPE:
32551
31689
  case RAW_PTR_CODER_TYPE:
32552
31690
  return new BigNumberCoder("u64");
32553
31691
  case U256_CODER_TYPE:
32554
31692
  return new BigNumberCoder("u256");
32555
31693
  case RAW_SLICE_CODER_TYPE:
32556
- return new RawSliceCoder2();
31694
+ return new RawSliceCoder();
32557
31695
  case BOOL_CODER_TYPE:
32558
- return new BooleanCoder2();
31696
+ return new BooleanCoder();
32559
31697
  case B256_CODER_TYPE:
32560
31698
  return new B256Coder();
32561
31699
  case B512_CODER_TYPE:
32562
31700
  return new B512Coder();
32563
31701
  case BYTES_CODER_TYPE:
32564
- return new ByteCoder2();
31702
+ return new ByteCoder();
32565
31703
  case STD_STRING_CODER_TYPE:
32566
- return new StdStringCoder2();
31704
+ return new StdStringCoder();
32567
31705
  case STR_SLICE_CODER_TYPE:
32568
31706
  return new StrSliceCoder();
32569
31707
  default:
@@ -32572,7 +31710,7 @@ This unreleased fuel-core build may include features and updates not yet support
32572
31710
  const stringMatch = stringRegEx.exec(resolvedAbiType.type)?.groups;
32573
31711
  if (stringMatch) {
32574
31712
  const length = parseInt(stringMatch.length, 10);
32575
- return new StringCoder2(length);
31713
+ return new StringCoder(length);
32576
31714
  }
32577
31715
  const components = resolvedAbiType.components;
32578
31716
  const arrayMatch = arrayRegEx.exec(resolvedAbiType.type)?.groups;
@@ -32585,46 +31723,42 @@ This unreleased fuel-core build may include features and updates not yet support
32585
31723
  `The provided Array type is missing an item of 'component'.`
32586
31724
  );
32587
31725
  }
32588
- const arrayElementCoder = getCoder2(arg, { isSmallBytes: true });
31726
+ const arrayElementCoder = getCoder(arg);
32589
31727
  return new ArrayCoder(arrayElementCoder, length);
32590
31728
  }
32591
31729
  if (resolvedAbiType.type === VEC_CODER_TYPE) {
32592
31730
  const arg = findVectorBufferArgument(components);
32593
31731
  const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
32594
- const itemCoder = getCoder2(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
32595
- return new VecCoder2(itemCoder);
31732
+ const itemCoder = getCoder(argType, { encoding: ENCODING_V1 });
31733
+ return new VecCoder(itemCoder);
32596
31734
  }
32597
31735
  const structMatch = structRegEx.exec(resolvedAbiType.type)?.groups;
32598
31736
  if (structMatch) {
32599
- const coders = getCoders(components, { isRightPadded: true, getCoder: getCoder2 });
32600
- return new StructCoder2(structMatch.name, coders);
31737
+ const coders = getCoders(components, { getCoder });
31738
+ return new StructCoder(structMatch.name, coders);
32601
31739
  }
32602
31740
  const enumMatch = enumRegEx.exec(resolvedAbiType.type)?.groups;
32603
31741
  if (enumMatch) {
32604
- const coders = getCoders(components, { getCoder: getCoder2 });
31742
+ const coders = getCoders(components, { getCoder });
32605
31743
  const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
32606
31744
  if (isOptionEnum) {
32607
- return new OptionCoder2(enumMatch.name, coders);
31745
+ return new OptionCoder(enumMatch.name, coders);
32608
31746
  }
32609
- return new EnumCoder2(enumMatch.name, coders);
31747
+ return new EnumCoder(enumMatch.name, coders);
32610
31748
  }
32611
31749
  const tupleMatch = tupleRegEx.exec(resolvedAbiType.type)?.groups;
32612
31750
  if (tupleMatch) {
32613
- const coders = components.map(
32614
- (component) => getCoder2(component, { isRightPadded: true, encoding: ENCODING_V0 })
32615
- );
32616
- return new TupleCoder2(coders);
31751
+ const coders = components.map((component) => getCoder(component, { encoding: ENCODING_V1 }));
31752
+ return new TupleCoder(coders);
32617
31753
  }
32618
31754
  throw new FuelError(
32619
31755
  ErrorCode.CODER_NOT_FOUND,
32620
31756
  `Coder not found: ${JSON.stringify(resolvedAbiType)}.`
32621
31757
  );
32622
31758
  };
32623
- function getCoderForEncoding(encoding = ENCODING_V0) {
31759
+ function getCoderForEncoding(encoding = ENCODING_V1) {
32624
31760
  switch (encoding) {
32625
31761
  case ENCODING_V1:
32626
- return getCoder2;
32627
- case ENCODING_V0:
32628
31762
  return getCoder;
32629
31763
  default:
32630
31764
  throw new FuelError(
@@ -32635,7 +31769,7 @@ This unreleased fuel-core build may include features and updates not yet support
32635
31769
  }
32636
31770
  var AbiCoder = class {
32637
31771
  static getCoder(abi, argument, options = {
32638
- isSmallBytes: false
31772
+ padToWordSize: false
32639
31773
  }) {
32640
31774
  const resolvedAbiType = new ResolvedAbiType(abi, argument);
32641
31775
  return getCoderForEncoding(options.encoding)(resolvedAbiType, options);
@@ -32655,8 +31789,6 @@ This unreleased fuel-core build may include features and updates not yet support
32655
31789
  name;
32656
31790
  jsonFn;
32657
31791
  attributes;
32658
- isInputDataPointer;
32659
- outputMetadata;
32660
31792
  jsonAbi;
32661
31793
  constructor(jsonAbi, name) {
32662
31794
  this.jsonAbi = jsonAbi;
@@ -32664,13 +31796,8 @@ This unreleased fuel-core build may include features and updates not yet support
32664
31796
  this.name = name;
32665
31797
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
32666
31798
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
32667
- this.selectorBytes = new StdStringCoder2().encode(name);
31799
+ this.selectorBytes = new StdStringCoder().encode(name);
32668
31800
  this.encoding = getEncodingVersion(jsonAbi.encoding);
32669
- this.isInputDataPointer = this.#isInputDataPointer();
32670
- this.outputMetadata = {
32671
- isHeapType: this.#isOutputDataHeap(),
32672
- encodedLength: this.#getOutputEncodedLength()
32673
- };
32674
31801
  this.attributes = this.jsonFn.attributes ?? [];
32675
31802
  }
32676
31803
  static getSignature(abi, fn) {
@@ -32683,29 +31810,7 @@ This unreleased fuel-core build may include features and updates not yet support
32683
31810
  const hashedFunctionSignature = sha2562(bufferFromString2(functionSignature, "utf-8"));
32684
31811
  return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
32685
31812
  }
32686
- #isInputDataPointer() {
32687
- const inputTypes = this.jsonFn.inputs.map((i) => findTypeById(this.jsonAbi, i.type));
32688
- return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || "");
32689
- }
32690
- #isOutputDataHeap() {
32691
- const outputType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
32692
- return isHeapType(outputType?.type || "");
32693
- }
32694
- #getOutputEncodedLength() {
32695
- try {
32696
- const heapCoder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
32697
- if (heapCoder instanceof VecCoder) {
32698
- return heapCoder.coder.encodedLength;
32699
- }
32700
- if (heapCoder instanceof ByteCoder) {
32701
- return ByteCoder.memorySize;
32702
- }
32703
- return heapCoder.encodedLength;
32704
- } catch (e) {
32705
- return 0;
32706
- }
32707
- }
32708
- encodeArguments(values, offset = 0) {
31813
+ encodeArguments(values) {
32709
31814
  FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi);
32710
31815
  const shallowCopyValues = values.slice();
32711
31816
  const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
@@ -32715,15 +31820,10 @@ This unreleased fuel-core build may include features and updates not yet support
32715
31820
  }
32716
31821
  const coders = nonEmptyInputs.map(
32717
31822
  (t) => AbiCoder.getCoder(this.jsonAbi, t, {
32718
- isRightPadded: nonEmptyInputs.length > 1,
32719
31823
  encoding: this.encoding
32720
31824
  })
32721
31825
  );
32722
- if (this.encoding === ENCODING_V1) {
32723
- return new TupleCoder2(coders).encode(shallowCopyValues);
32724
- }
32725
- const results = new TupleCoder(coders).encode(shallowCopyValues);
32726
- return unpackDynamicData(results, offset, results.byteLength);
31826
+ return new TupleCoder(coders).encode(shallowCopyValues);
32727
31827
  }
32728
31828
  static verifyArgsAndInputsAlign(args, inputs, abi) {
32729
31829
  if (args.length === inputs.length) {
@@ -32832,9 +31932,9 @@ This unreleased fuel-core build may include features and updates not yet support
32832
31932
  const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
32833
31933
  return fragment.decodeArguments(data);
32834
31934
  }
32835
- encodeFunctionData(functionFragment, values, offset = 0) {
31935
+ encodeFunctionData(functionFragment, values) {
32836
31936
  const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
32837
- return fragment.encodeArguments(values, offset);
31937
+ return fragment.encodeArguments(values);
32838
31938
  }
32839
31939
  // Decode the result of a function call
32840
31940
  decodeFunctionResult(functionFragment, data) {
@@ -32862,9 +31962,7 @@ This unreleased fuel-core build may include features and updates not yet support
32862
31962
  );
32863
31963
  }
32864
31964
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
32865
- isRightPadded: true,
32866
- // TODO: Review support for configurables in v1 encoding when it becomes available
32867
- encoding: ENCODING_V0
31965
+ encoding: this.encoding
32868
31966
  });
32869
31967
  }
32870
31968
  getTypeById(typeId) {
@@ -32914,8 +32012,8 @@ This unreleased fuel-core build may include features and updates not yet support
32914
32012
  var TxPointerCoder = class extends StructCoder {
32915
32013
  constructor() {
32916
32014
  super("TxPointer", {
32917
- blockHeight: new NumberCoder("u32"),
32918
- txIndex: new NumberCoder("u16")
32015
+ blockHeight: new NumberCoder("u32", { padToWordSize: true }),
32016
+ txIndex: new NumberCoder("u16", { padToWordSize: true })
32919
32017
  });
32920
32018
  }
32921
32019
  };
@@ -32932,12 +32030,12 @@ This unreleased fuel-core build may include features and updates not yet support
32932
32030
  encode(value) {
32933
32031
  const parts = [];
32934
32032
  parts.push(new B256Coder().encode(value.txID));
32935
- parts.push(new NumberCoder("u16").encode(value.outputIndex));
32033
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.outputIndex));
32936
32034
  parts.push(new B256Coder().encode(value.owner));
32937
32035
  parts.push(new BigNumberCoder("u64").encode(value.amount));
32938
32036
  parts.push(new B256Coder().encode(value.assetId));
32939
32037
  parts.push(new TxPointerCoder().encode(value.txPointer));
32940
- parts.push(new NumberCoder("u16").encode(value.witnessIndex));
32038
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.witnessIndex));
32941
32039
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
32942
32040
  parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
32943
32041
  parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
@@ -32952,7 +32050,7 @@ This unreleased fuel-core build may include features and updates not yet support
32952
32050
  let o = offset;
32953
32051
  [decoded, o] = new B256Coder().decode(data, o);
32954
32052
  const txID = decoded;
32955
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32053
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
32956
32054
  const outputIndex = decoded;
32957
32055
  [decoded, o] = new B256Coder().decode(data, o);
32958
32056
  const owner = decoded;
@@ -32962,7 +32060,7 @@ This unreleased fuel-core build may include features and updates not yet support
32962
32060
  const assetId = decoded;
32963
32061
  [decoded, o] = new TxPointerCoder().decode(data, o);
32964
32062
  const txPointer = decoded;
32965
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32063
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
32966
32064
  const witnessIndex = Number(decoded);
32967
32065
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
32968
32066
  const predicateGasUsed = decoded;
@@ -33001,7 +32099,7 @@ This unreleased fuel-core build may include features and updates not yet support
33001
32099
  encode(value) {
33002
32100
  const parts = [];
33003
32101
  parts.push(new B256Coder().encode(value.txID));
33004
- parts.push(new NumberCoder("u16").encode(value.outputIndex));
32102
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.outputIndex));
33005
32103
  parts.push(new B256Coder().encode(value.balanceRoot));
33006
32104
  parts.push(new B256Coder().encode(value.stateRoot));
33007
32105
  parts.push(new TxPointerCoder().encode(value.txPointer));
@@ -33013,7 +32111,7 @@ This unreleased fuel-core build may include features and updates not yet support
33013
32111
  let o = offset;
33014
32112
  [decoded, o] = new B256Coder().decode(data, o);
33015
32113
  const txID = decoded;
33016
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32114
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33017
32115
  const outputIndex = decoded;
33018
32116
  [decoded, o] = new B256Coder().decode(data, o);
33019
32117
  const balanceRoot = decoded;
@@ -33052,8 +32150,8 @@ This unreleased fuel-core build may include features and updates not yet support
33052
32150
  }
33053
32151
  static encodeData(messageData) {
33054
32152
  const bytes2 = arrayify(messageData || "0x");
33055
- const dataLength2 = bytes2.length;
33056
- return new ByteArrayCoder(dataLength2).encode(bytes2);
32153
+ const dataLength = bytes2.length;
32154
+ return new ByteArrayCoder(dataLength).encode(bytes2);
33057
32155
  }
33058
32156
  encode(value) {
33059
32157
  const parts = [];
@@ -33062,7 +32160,7 @@ This unreleased fuel-core build may include features and updates not yet support
33062
32160
  parts.push(new ByteArrayCoder(32).encode(value.recipient));
33063
32161
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33064
32162
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
33065
- parts.push(new NumberCoder("u16").encode(value.witnessIndex));
32163
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.witnessIndex));
33066
32164
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33067
32165
  parts.push(new BigNumberCoder("u64").encode(data.length));
33068
32166
  parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
@@ -33076,8 +32174,8 @@ This unreleased fuel-core build may include features and updates not yet support
33076
32174
  }
33077
32175
  static decodeData(messageData) {
33078
32176
  const bytes2 = arrayify(messageData);
33079
- const dataLength2 = bytes2.length;
33080
- const [data] = new ByteArrayCoder(dataLength2).decode(bytes2, 0);
32177
+ const dataLength = bytes2.length;
32178
+ const [data] = new ByteArrayCoder(dataLength).decode(bytes2, 0);
33081
32179
  return arrayify(data);
33082
32180
  }
33083
32181
  decode(data, offset) {
@@ -33091,17 +32189,17 @@ This unreleased fuel-core build may include features and updates not yet support
33091
32189
  const amount = decoded;
33092
32190
  [decoded, o] = new B256Coder().decode(data, o);
33093
32191
  const nonce = decoded;
33094
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32192
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33095
32193
  const witnessIndex = Number(decoded);
33096
32194
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33097
32195
  const predicateGasUsed = decoded;
33098
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33099
- const dataLength2 = decoded;
32196
+ [decoded, o] = new NumberCoder("u32", { padToWordSize: true }).decode(data, o);
32197
+ const dataLength = decoded;
33100
32198
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33101
32199
  const predicateLength = decoded;
33102
32200
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33103
32201
  const predicateDataLength = decoded;
33104
- [decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
32202
+ [decoded, o] = new ByteArrayCoder(dataLength).decode(data, o);
33105
32203
  const messageData = decoded;
33106
32204
  [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33107
32205
  const predicate = decoded;
@@ -33116,7 +32214,7 @@ This unreleased fuel-core build may include features and updates not yet support
33116
32214
  witnessIndex,
33117
32215
  nonce,
33118
32216
  predicateGasUsed,
33119
- dataLength: dataLength2,
32217
+ dataLength,
33120
32218
  predicateLength,
33121
32219
  predicateDataLength,
33122
32220
  data: messageData,
@@ -33133,7 +32231,7 @@ This unreleased fuel-core build may include features and updates not yet support
33133
32231
  }
33134
32232
  encode(value) {
33135
32233
  const parts = [];
33136
- parts.push(new NumberCoder("u8").encode(value.type));
32234
+ parts.push(new NumberCoder("u8", { padToWordSize: true }).encode(value.type));
33137
32235
  const { type: type3 } = value;
33138
32236
  switch (type3) {
33139
32237
  case 0: {
@@ -33160,7 +32258,7 @@ This unreleased fuel-core build may include features and updates not yet support
33160
32258
  decode(data, offset) {
33161
32259
  let decoded;
33162
32260
  let o = offset;
33163
- [decoded, o] = new NumberCoder("u8").decode(data, o);
32261
+ [decoded, o] = new NumberCoder("u8", { padToWordSize: true }).decode(data, o);
33164
32262
  const type3 = decoded;
33165
32263
  switch (type3) {
33166
32264
  case 0: {
@@ -33229,7 +32327,7 @@ This unreleased fuel-core build may include features and updates not yet support
33229
32327
  }
33230
32328
  encode(value) {
33231
32329
  const parts = [];
33232
- parts.push(new NumberCoder("u8").encode(value.inputIndex));
32330
+ parts.push(new NumberCoder("u8", { padToWordSize: true }).encode(value.inputIndex));
33233
32331
  parts.push(new B256Coder().encode(value.balanceRoot));
33234
32332
  parts.push(new B256Coder().encode(value.stateRoot));
33235
32333
  return concat(parts);
@@ -33237,7 +32335,7 @@ This unreleased fuel-core build may include features and updates not yet support
33237
32335
  decode(data, offset) {
33238
32336
  let decoded;
33239
32337
  let o = offset;
33240
- [decoded, o] = new NumberCoder("u8").decode(data, o);
32338
+ [decoded, o] = new NumberCoder("u8", { padToWordSize: true }).decode(data, o);
33241
32339
  const inputIndex = decoded;
33242
32340
  [decoded, o] = new B256Coder().decode(data, o);
33243
32341
  const balanceRoot = decoded;
@@ -33349,7 +32447,7 @@ This unreleased fuel-core build may include features and updates not yet support
33349
32447
  }
33350
32448
  encode(value) {
33351
32449
  const parts = [];
33352
- parts.push(new NumberCoder("u8").encode(value.type));
32450
+ parts.push(new NumberCoder("u8", { padToWordSize: true }).encode(value.type));
33353
32451
  const { type: type3 } = value;
33354
32452
  switch (type3) {
33355
32453
  case 0: {
@@ -33384,7 +32482,7 @@ This unreleased fuel-core build may include features and updates not yet support
33384
32482
  decode(data, offset) {
33385
32483
  let decoded;
33386
32484
  let o = offset;
33387
- [decoded, o] = new NumberCoder("u8").decode(data, o);
32485
+ [decoded, o] = new NumberCoder("u8", { padToWordSize: true }).decode(data, o);
33388
32486
  const type3 = decoded;
33389
32487
  switch (type3) {
33390
32488
  case 0: {
@@ -33452,7 +32550,7 @@ This unreleased fuel-core build may include features and updates not yet support
33452
32550
  parts.push(new BigNumberCoder("u64").encode(data));
33453
32551
  break;
33454
32552
  case 4:
33455
- parts.push(new NumberCoder("u32").encode(data));
32553
+ parts.push(new NumberCoder("u32", { padToWordSize: true }).encode(data));
33456
32554
  break;
33457
32555
  default: {
33458
32556
  throw new FuelError(ErrorCode.INVALID_POLICY_TYPE, `Invalid policy type: ${type3}`);
@@ -33475,7 +32573,10 @@ This unreleased fuel-core build may include features and updates not yet support
33475
32573
  policies.push({ type: 2, data: witnessLimit });
33476
32574
  }
33477
32575
  if (policyTypes & 4) {
33478
- const [maturity, nextOffset] = new NumberCoder("u32").decode(data, o);
32576
+ const [maturity, nextOffset] = new NumberCoder("u32", { padToWordSize: true }).decode(
32577
+ data,
32578
+ o
32579
+ );
33479
32580
  o = nextOffset;
33480
32581
  policies.push({ type: 4, data: maturity });
33481
32582
  }
@@ -33522,7 +32623,7 @@ This unreleased fuel-core build may include features and updates not yet support
33522
32623
  parts.push(new B256Coder().encode(value.recipient));
33523
32624
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33524
32625
  parts.push(new B256Coder().encode(value.nonce));
33525
- parts.push(new NumberCoder("u16").encode(value.data.length));
32626
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.data.length));
33526
32627
  parts.push(new B256Coder().encode(value.digest));
33527
32628
  parts.push(new ByteArrayCoder(value.data.length).encode(value.data));
33528
32629
  return concat(parts);
@@ -33538,7 +32639,7 @@ This unreleased fuel-core build may include features and updates not yet support
33538
32639
  const amount = decoded;
33539
32640
  [decoded, o] = new B256Coder().decode(data, o);
33540
32641
  const nonce = decoded;
33541
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32642
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33542
32643
  const len = decoded;
33543
32644
  [decoded, o] = new B256Coder().decode(data, o);
33544
32645
  const digest = decoded;
@@ -33662,11 +32763,11 @@ This unreleased fuel-core build may include features and updates not yet support
33662
32763
  encode(upgradePurposeType) {
33663
32764
  const parts = [];
33664
32765
  const { type: type3 } = upgradePurposeType;
33665
- parts.push(new NumberCoder("u8").encode(type3));
32766
+ parts.push(new NumberCoder("u8", { padToWordSize: true }).encode(type3));
33666
32767
  switch (type3) {
33667
32768
  case 0: {
33668
32769
  const data = upgradePurposeType.data;
33669
- parts.push(new NumberCoder("u16").encode(data.witnessIndex));
32770
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(data.witnessIndex));
33670
32771
  parts.push(new B256Coder().encode(data.checksum));
33671
32772
  break;
33672
32773
  }
@@ -33687,11 +32788,11 @@ This unreleased fuel-core build may include features and updates not yet support
33687
32788
  decode(data, offset) {
33688
32789
  let o = offset;
33689
32790
  let decoded;
33690
- [decoded, o] = new NumberCoder("u8").decode(data, o);
32791
+ [decoded, o] = new NumberCoder("u8", { padToWordSize: true }).decode(data, o);
33691
32792
  const type3 = decoded;
33692
32793
  switch (type3) {
33693
32794
  case 0: {
33694
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32795
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33695
32796
  const witnessIndex = decoded;
33696
32797
  [decoded, o] = new B256Coder().decode(data, o);
33697
32798
  const checksum = decoded;
@@ -33722,20 +32823,20 @@ This unreleased fuel-core build may include features and updates not yet support
33722
32823
  }
33723
32824
  encode(value) {
33724
32825
  const parts = [];
33725
- parts.push(new NumberCoder("u32").encode(value.dataLength));
32826
+ parts.push(new NumberCoder("u32", { padToWordSize: true }).encode(value.dataLength));
33726
32827
  parts.push(new ByteArrayCoder(value.dataLength).encode(value.data));
33727
32828
  return concat(parts);
33728
32829
  }
33729
32830
  decode(data, offset) {
33730
32831
  let decoded;
33731
32832
  let o = offset;
33732
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33733
- const dataLength2 = decoded;
33734
- [decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
32833
+ [decoded, o] = new NumberCoder("u32", { padToWordSize: true }).decode(data, o);
32834
+ const dataLength = decoded;
32835
+ [decoded, o] = new ByteArrayCoder(dataLength).decode(data, o);
33735
32836
  const witnessData = decoded;
33736
32837
  return [
33737
32838
  {
33738
- dataLength: dataLength2,
32839
+ dataLength,
33739
32840
  data: witnessData
33740
32841
  },
33741
32842
  o
@@ -33760,10 +32861,10 @@ This unreleased fuel-core build may include features and updates not yet support
33760
32861
  parts.push(new B256Coder().encode(value.receiptsRoot));
33761
32862
  parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
33762
32863
  parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
33763
- parts.push(new NumberCoder("u32").encode(value.policyTypes));
33764
- parts.push(new NumberCoder("u16").encode(value.inputsCount));
33765
- parts.push(new NumberCoder("u16").encode(value.outputsCount));
33766
- parts.push(new NumberCoder("u16").encode(value.witnessesCount));
32864
+ parts.push(new NumberCoder("u32", { padToWordSize: true }).encode(value.policyTypes));
32865
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.inputsCount));
32866
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.outputsCount));
32867
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.witnessesCount));
33767
32868
  parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
33768
32869
  parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
33769
32870
  parts.push(new PoliciesCoder().encode(value.policies));
@@ -33783,13 +32884,13 @@ This unreleased fuel-core build may include features and updates not yet support
33783
32884
  const scriptLength = decoded;
33784
32885
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33785
32886
  const scriptDataLength = decoded;
33786
- [decoded, o] = new NumberCoder("u32").decode(data, o);
32887
+ [decoded, o] = new NumberCoder("u32", { padToWordSize: true }).decode(data, o);
33787
32888
  const policyTypes = decoded;
33788
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32889
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33789
32890
  const inputsCount = decoded;
33790
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32891
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33791
32892
  const outputsCount = decoded;
33792
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32893
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33793
32894
  const witnessesCount = decoded;
33794
32895
  [decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
33795
32896
  const script = decoded;
@@ -33831,13 +32932,13 @@ This unreleased fuel-core build may include features and updates not yet support
33831
32932
  }
33832
32933
  encode(value) {
33833
32934
  const parts = [];
33834
- parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
32935
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.bytecodeWitnessIndex));
33835
32936
  parts.push(new B256Coder().encode(value.salt));
33836
32937
  parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
33837
- parts.push(new NumberCoder("u32").encode(value.policyTypes));
33838
- parts.push(new NumberCoder("u16").encode(value.inputsCount));
33839
- parts.push(new NumberCoder("u16").encode(value.outputsCount));
33840
- parts.push(new NumberCoder("u16").encode(value.witnessesCount));
32938
+ parts.push(new NumberCoder("u32", { padToWordSize: true }).encode(value.policyTypes));
32939
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.inputsCount));
32940
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.outputsCount));
32941
+ parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.witnessesCount));
33841
32942
  parts.push(
33842
32943
  new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
33843
32944
  value.storageSlots
@@ -33852,19 +32953,19 @@ This unreleased fuel-core build may include features and updates not yet support
33852
32953
  decode(data, offset) {
33853
32954
  let decoded;
33854
32955
  let o = offset;
33855
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32956
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33856
32957
  const bytecodeWitnessIndex = decoded;
33857
32958
  [decoded, o] = new B256Coder().decode(data, o);
33858
32959
  const salt = decoded;
33859
32960
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33860
32961
  const storageSlotsCount = decoded;
33861
- [decoded, o] = new NumberCoder("u32").decode(data, o);
32962
+ [decoded, o] = new NumberCoder("u32", { padToWordSize: true }).decode(data, o);
33862
32963
  const policyTypes = decoded;
33863
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32964
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33864
32965
  const inputsCount = decoded;
33865
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32966
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33866
32967
  const outputsCount = decoded;
33867
- [decoded, o] = new NumberCoder("u16").decode(data, o);
32968
+ [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
33868
32969
  const witnessesCount = decoded;
33869
32970
  [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
33870
32971
  data,
@@ -34078,7 +33179,7 @@ This unreleased fuel-core build may include features and updates not yet support
34078
33179
  }
34079
33180
  encode(value) {
34080
33181
  const parts = [];
34081
- parts.push(new NumberCoder("u8").encode(value.type));
33182
+ parts.push(new NumberCoder("u8", { padToWordSize: true }).encode(value.type));
34082
33183
  const { type: type3 } = value;
34083
33184
  switch (value.type) {
34084
33185
  case 0: {
@@ -34121,7 +33222,7 @@ This unreleased fuel-core build may include features and updates not yet support
34121
33222
  decode(data, offset) {
34122
33223
  let decoded;
34123
33224
  let o = offset;
34124
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33225
+ [decoded, o] = new NumberCoder("u8", { padToWordSize: true }).decode(data, o);
34125
33226
  const type3 = decoded;
34126
33227
  switch (type3) {
34127
33228
  case 0: {
@@ -39220,7 +38321,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39220
38321
  }
39221
38322
  return { errorMessage, reason };
39222
38323
  };
39223
- var stringify2 = (obj) => JSON.stringify(obj, null, 2);
38324
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
39224
38325
  var assembleRevertError = (receipts, logs) => {
39225
38326
  let errorMessage = "The transaction reverted with an unknown reason.";
39226
38327
  const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
@@ -39230,17 +38331,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39230
38331
  switch (reasonHex) {
39231
38332
  case FAILED_REQUIRE_SIGNAL: {
39232
38333
  reason = "require";
39233
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
38334
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
39234
38335
  break;
39235
38336
  }
39236
38337
  case FAILED_ASSERT_EQ_SIGNAL: {
39237
- const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
38338
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
39238
38339
  reason = "assert_eq";
39239
38340
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
39240
38341
  break;
39241
38342
  }
39242
38343
  case FAILED_ASSERT_NE_SIGNAL: {
39243
- const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
38344
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
39244
38345
  reason = "assert_ne";
39245
38346
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
39246
38347
  break;
@@ -39848,15 +38949,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39848
38949
  }
39849
38950
  });
39850
38951
  }
39851
- shiftPredicateData() {
39852
- this.inputs.forEach((input) => {
39853
- if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
39854
- input.predicateData = input.padPredicateData(
39855
- BaseTransactionRequest.getPolicyMeta(this).policies.length
39856
- );
39857
- }
39858
- });
39859
- }
39860
38952
  };
39861
38953
 
39862
38954
  // src/providers/transaction-request/hash-transaction.ts
@@ -40321,37 +39413,27 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40321
39413
  };
40322
39414
 
40323
39415
  // src/providers/transaction-summary/call.ts
40324
- var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
39416
+ var getFunctionCall = ({ abi, receipt }) => {
40325
39417
  const abiInterface = new Interface(abi);
40326
39418
  const callFunctionSelector = receipt.param1.toHex(8);
40327
39419
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
40328
39420
  const inputs = functionFragment.jsonFn.inputs;
40329
- let encodedArgs;
40330
- if (functionFragment.isInputDataPointer) {
40331
- if (rawPayload) {
40332
- const argsOffset = bn(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
40333
- encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
40334
- }
40335
- } else {
40336
- encodedArgs = receipt.param2.toHex();
40337
- }
39421
+ const encodedArgs = receipt.param2.toHex();
40338
39422
  let argumentsProvided;
40339
- if (encodedArgs) {
40340
- const data = functionFragment.decodeArguments(encodedArgs);
40341
- if (data) {
40342
- argumentsProvided = inputs.reduce((prev, input, index) => {
40343
- const value = data[index];
40344
- const name = input.name;
40345
- if (name) {
40346
- return {
40347
- ...prev,
40348
- // reparse to remove bn
40349
- [name]: JSON.parse(JSON.stringify(value))
40350
- };
40351
- }
40352
- return prev;
40353
- }, {});
40354
- }
39423
+ const data = functionFragment.decodeArguments(encodedArgs);
39424
+ if (data) {
39425
+ argumentsProvided = inputs.reduce((prev, input, index) => {
39426
+ const value = data[index];
39427
+ const name = input.name;
39428
+ if (name) {
39429
+ return {
39430
+ ...prev,
39431
+ // reparse to remove bn
39432
+ [name]: JSON.parse(JSON.stringify(value))
39433
+ };
39434
+ }
39435
+ return prev;
39436
+ }, {});
40355
39437
  }
40356
39438
  const call = {
40357
39439
  functionSignature: functionFragment.signature,
@@ -41248,13 +40330,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41248
40330
  gasCosts,
41249
40331
  baseAssetId,
41250
40332
  chainId,
41251
- version: version2
40333
+ version
41252
40334
  } = consensusParameters;
41253
40335
  return {
41254
40336
  name,
41255
40337
  baseChainHeight: bn(daHeight),
41256
40338
  consensusParameters: {
41257
- version: version2,
40339
+ version,
41258
40340
  chainId: bn(chainId),
41259
40341
  baseAssetId,
41260
40342
  feeParameters: {
@@ -42848,7 +41930,6 @@ Supported fuel-core version: ${supportedVersion}.`
42848
41930
  cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
42849
41931
  );
42850
41932
  request.addResources(resources);
42851
- request.shiftPredicateData();
42852
41933
  request.updatePredicateGasUsed(estimatedPredicates);
42853
41934
  const requestToReestimate2 = clone_default(request);
42854
41935
  if (addedSignatures) {
@@ -42880,7 +41961,6 @@ Supported fuel-core version: ${supportedVersion}.`
42880
41961
  }
42881
41962
  fundingAttempts += 1;
42882
41963
  }
42883
- request.shiftPredicateData();
42884
41964
  request.updatePredicateGasUsed(estimatedPredicates);
42885
41965
  const requestToReestimate = clone_default(request);
42886
41966
  if (addedSignatures) {
@@ -43430,12 +42510,12 @@ Supported fuel-core version: ${supportedVersion}.`
43430
42510
  const { windows, windowSize } = opts(W);
43431
42511
  let p = c.ZERO;
43432
42512
  let f2 = c.BASE;
43433
- const mask2 = BigInt(2 ** W - 1);
42513
+ const mask = BigInt(2 ** W - 1);
43434
42514
  const maxNumber = 2 ** W;
43435
42515
  const shiftBy = BigInt(W);
43436
42516
  for (let window2 = 0; window2 < windows; window2++) {
43437
42517
  const offset = window2 * windowSize;
43438
- let wbits = Number(n & mask2);
42518
+ let wbits = Number(n & mask);
43439
42519
  n >>= shiftBy;
43440
42520
  if (wbits > windowSize) {
43441
42521
  wbits -= maxNumber;
@@ -46776,38 +45856,6 @@ Supported fuel-core version: ${supportedVersion}.`
46776
45856
  })(Language || {});
46777
45857
 
46778
45858
  // src/mnemonic/utils.ts
46779
- function toUtf8Bytes2(stri) {
46780
- const str = stri.normalize("NFKD");
46781
- const result = [];
46782
- for (let i = 0; i < str.length; i += 1) {
46783
- const c = str.charCodeAt(i);
46784
- if (c < 128) {
46785
- result.push(c);
46786
- } else if (c < 2048) {
46787
- result.push(c >> 6 | 192);
46788
- result.push(c & 63 | 128);
46789
- } else if ((c & 64512) === 55296) {
46790
- i += 1;
46791
- const c2 = str.charCodeAt(i);
46792
- if (i >= str.length || (c2 & 64512) !== 56320) {
46793
- throw new FuelError(
46794
- ErrorCode.INVALID_INPUT_PARAMETERS,
46795
- "Invalid UTF-8 in the input string."
46796
- );
46797
- }
46798
- const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
46799
- result.push(pair >> 18 | 240);
46800
- result.push(pair >> 12 & 63 | 128);
46801
- result.push(pair >> 6 & 63 | 128);
46802
- result.push(pair & 63 | 128);
46803
- } else {
46804
- result.push(c >> 12 | 224);
46805
- result.push(c >> 6 & 63 | 128);
46806
- result.push(c & 63 | 128);
46807
- }
46808
- }
46809
- return Uint8Array.from(result);
46810
- }
46811
45859
  function getLowerMask(bits) {
46812
45860
  return (1 << bits) - 1;
46813
45861
  }
@@ -46880,7 +45928,7 @@ Supported fuel-core version: ${supportedVersion}.`
46880
45928
  }
46881
45929
 
46882
45930
  // src/mnemonic/mnemonic.ts
46883
- var MasterSecret = toUtf8Bytes2("Bitcoin seed");
45931
+ var MasterSecret = toUtf8Bytes("Bitcoin seed");
46884
45932
  var MainnetPRV = "0x0488ade4";
46885
45933
  var TestnetPRV = "0x04358394";
46886
45934
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
@@ -46964,8 +46012,8 @@ Supported fuel-core version: ${supportedVersion}.`
46964
46012
  */
46965
46013
  static mnemonicToSeed(phrase, passphrase = "") {
46966
46014
  assertMnemonic(getWords(phrase));
46967
- const phraseBytes = toUtf8Bytes2(getPhrase(phrase));
46968
- const salt = toUtf8Bytes2(`mnemonic${passphrase}`);
46015
+ const phraseBytes = toUtf8Bytes(getPhrase(phrase));
46016
+ const salt = toUtf8Bytes(`mnemonic${passphrase}`);
46969
46017
  return pbkdf222(phraseBytes, salt, 2048, 64, "sha512");
46970
46018
  }
46971
46019
  /**
@@ -47593,7 +46641,7 @@ Supported fuel-core version: ${supportedVersion}.`
47593
46641
  wallet_not_unlocked: "The wallet is currently locked.",
47594
46642
  passphrase_not_match: "The provided passphrase did not match the expected value."
47595
46643
  };
47596
- function assert2(condition, message) {
46644
+ function assert(condition, message) {
47597
46645
  if (!condition) {
47598
46646
  throw new FuelError(ErrorCode.WALLET_MANAGER_ERROR, message);
47599
46647
  }
@@ -47636,9 +46684,9 @@ Supported fuel-core version: ${supportedVersion}.`
47636
46684
  * the format of the return depends on the Vault type.
47637
46685
  */
47638
46686
  exportVault(vaultId) {
47639
- assert2(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
46687
+ assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
47640
46688
  const vaultState = __privateGet(this, _vaults).find((_, idx) => idx === vaultId);
47641
- assert2(vaultState, ERROR_MESSAGES.vault_not_found);
46689
+ assert(vaultState, ERROR_MESSAGES.vault_not_found);
47642
46690
  return vaultState.vault.serialize();
47643
46691
  }
47644
46692
  /**
@@ -47667,7 +46715,7 @@ Supported fuel-core version: ${supportedVersion}.`
47667
46715
  const vaultState = __privateGet(this, _vaults).find(
47668
46716
  (vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
47669
46717
  );
47670
- assert2(vaultState, ERROR_MESSAGES.address_not_found);
46718
+ assert(vaultState, ERROR_MESSAGES.address_not_found);
47671
46719
  return vaultState.vault.getWallet(ownerAddress);
47672
46720
  }
47673
46721
  /**
@@ -47675,11 +46723,11 @@ Supported fuel-core version: ${supportedVersion}.`
47675
46723
  */
47676
46724
  exportPrivateKey(address) {
47677
46725
  const ownerAddress = Address.fromAddressOrString(address);
47678
- assert2(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
46726
+ assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
47679
46727
  const vaultState = __privateGet(this, _vaults).find(
47680
46728
  (vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
47681
46729
  );
47682
- assert2(vaultState, ERROR_MESSAGES.address_not_found);
46730
+ assert(vaultState, ERROR_MESSAGES.address_not_found);
47683
46731
  return vaultState.vault.exportAccount(ownerAddress);
47684
46732
  }
47685
46733
  /**
@@ -47689,7 +46737,7 @@ Supported fuel-core version: ${supportedVersion}.`
47689
46737
  async addAccount(options) {
47690
46738
  await this.loadState();
47691
46739
  const vaultState = __privateGet(this, _vaults)[options?.vaultId || 0];
47692
- await assert2(vaultState, ERROR_MESSAGES.vault_not_found);
46740
+ await assert(vaultState, ERROR_MESSAGES.vault_not_found);
47693
46741
  const account = vaultState.vault.addAccount();
47694
46742
  await this.saveState();
47695
46743
  return account;
@@ -47759,7 +46807,7 @@ Supported fuel-core version: ${supportedVersion}.`
47759
46807
  * Retrieve and decrypt WalletManager state from storage
47760
46808
  */
47761
46809
  async loadState() {
47762
- await assert2(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
46810
+ await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
47763
46811
  const data = await this.storage.getItem(this.STORAGE_KEY);
47764
46812
  if (data) {
47765
46813
  const state = await decrypt2(__privateGet(this, _passphrase), JSON.parse(data));
@@ -47770,7 +46818,7 @@ Supported fuel-core version: ${supportedVersion}.`
47770
46818
  * Store encrypted WalletManager state on storage
47771
46819
  */
47772
46820
  async saveState() {
47773
- await assert2(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
46821
+ await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
47774
46822
  const encryptedData = await encrypt2(__privateGet(this, _passphrase), {
47775
46823
  vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
47776
46824
  });
@@ -47782,7 +46830,7 @@ Supported fuel-core version: ${supportedVersion}.`
47782
46830
  */
47783
46831
  getVaultClass(type3) {
47784
46832
  const VaultClass = _WalletManager.Vaults.find((v) => v.type === type3);
47785
- assert2(VaultClass, ERROR_MESSAGES.invalid_vault_type);
46833
+ assert(VaultClass, ERROR_MESSAGES.invalid_vault_type);
47786
46834
  return VaultClass;
47787
46835
  }
47788
46836
  };
@@ -47954,7 +47002,6 @@ Supported fuel-core version: ${supportedVersion}.`
47954
47002
  */
47955
47003
  populateTransactionPredicateData(transactionRequestLike) {
47956
47004
  const request = transactionRequestify(transactionRequestLike);
47957
- const { policies } = BaseTransactionRequest.getPolicyMeta(request);
47958
47005
  const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
47959
47006
  if (placeholderIndex !== -1) {
47960
47007
  request.removeWitness(placeholderIndex);
@@ -47962,7 +47009,7 @@ Supported fuel-core version: ${supportedVersion}.`
47962
47009
  request.inputs.filter(isRequestInputResource).forEach((input) => {
47963
47010
  if (isRequestInputResourceFromOwner(input, this.address)) {
47964
47011
  input.predicate = hexlify(this.bytes);
47965
- input.predicateData = hexlify(this.getPredicateData(policies.length));
47012
+ input.predicateData = hexlify(this.getPredicateData());
47966
47013
  input.witnessIndex = 0;
47967
47014
  }
47968
47015
  });
@@ -47988,17 +47035,12 @@ Supported fuel-core version: ${supportedVersion}.`
47988
47035
  const transactionRequest = transactionRequestify(transactionRequestLike);
47989
47036
  return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
47990
47037
  }
47991
- getPredicateData(policiesLength) {
47038
+ getPredicateData() {
47992
47039
  if (!this.predicateData.length) {
47993
47040
  return new Uint8Array();
47994
47041
  }
47995
47042
  const mainFn = this.interface?.functions.main;
47996
- const paddedCode = new ByteArrayCoder(this.bytes.length).encode(this.bytes);
47997
- const VM_TX_MEMORY = calculateVmTxMemory({
47998
- maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
47999
- });
48000
- const OFFSET = VM_TX_MEMORY + SCRIPT_FIXED_SIZE + INPUT_COIN_FIXED_SIZE + WORD_SIZE + paddedCode.byteLength + policiesLength * WORD_SIZE;
48001
- return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
47043
+ return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
48002
47044
  }
48003
47045
  /**
48004
47046
  * Processes the predicate data and returns the altered bytecode and interface.
@@ -48047,8 +47089,7 @@ Supported fuel-core version: ${supportedVersion}.`
48047
47089
  );
48048
47090
  return resources.map((resource) => ({
48049
47091
  ...resource,
48050
- predicate: hexlify(this.bytes),
48051
- padPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
47092
+ predicate: hexlify(this.bytes)
48052
47093
  }));
48053
47094
  }
48054
47095
  /**