@fuel-ts/account 0.0.0-rc-2021-20240411154255 → 0.0.0-rc-2037-20240411163513

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.

Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +563 -841
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +565 -825
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +400 -659
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +329 -911
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +1 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/message.d.ts +1 -6
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +30 -37
  29. package/dist/providers/provider.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +5 -6
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +0 -3
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +2 -8
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/test-utils/launchNode.d.ts.map +1 -1
  47. package/dist/test-utils.global.js +1047 -1557
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +543 -800
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +394 -651
  52. package/dist/test-utils.mjs.map +1 -1
  53. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  54. package/package.json +17 -17
@@ -289,7 +289,7 @@
289
289
  }
290
290
  return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
291
291
  };
292
- BN2.max = function max(left, right) {
292
+ BN2.max = function max2(left, right) {
293
293
  if (left.cmp(right) > 0)
294
294
  return left;
295
295
  return right;
@@ -5113,7 +5113,7 @@
5113
5113
  function isBlob(obj) {
5114
5114
  return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
5115
5115
  }
5116
- function clone3(instance) {
5116
+ function clone(instance) {
5117
5117
  let p1, p2;
5118
5118
  let body = instance.body;
5119
5119
  if (instance.bodyUsed) {
@@ -6047,7 +6047,7 @@
6047
6047
  * @return Response
6048
6048
  */
6049
6049
  clone() {
6050
- return new Response2(clone3(this), {
6050
+ return new Response2(clone(this), {
6051
6051
  url: this.url,
6052
6052
  status: this.status,
6053
6053
  statusText: this.statusText,
@@ -6097,7 +6097,7 @@
6097
6097
  if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
6098
6098
  throw new TypeError("Request with GET/HEAD method cannot have body");
6099
6099
  }
6100
- let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone3(input) : null;
6100
+ let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
6101
6101
  Body.call(this, inputBody, {
6102
6102
  timeout: init.timeout || input.timeout || 0,
6103
6103
  size: init.size || input.size || 0
@@ -28952,8 +28952,8 @@ spurious results.`);
28952
28952
  // ../versions/dist/index.mjs
28953
28953
  function getBuiltinVersions() {
28954
28954
  return {
28955
- FORC: "0.51.1",
28956
- FUEL_CORE: "0.24.2",
28955
+ FORC: "0.49.3",
28956
+ FUEL_CORE: "0.22.1",
28957
28957
  FUELS: "0.79.0"
28958
28958
  };
28959
28959
  }
@@ -29245,7 +29245,7 @@ This unreleased fuel-core build may include features and updates not yet support
29245
29245
  __publicField3(DateTime, "TAI64_NULL", "");
29246
29246
 
29247
29247
  // ../crypto/dist/index.mjs
29248
- var import_crypto9 = __toESM(__require("crypto"), 1);
29248
+ var import_crypto8 = __toESM(__require("crypto"), 1);
29249
29249
 
29250
29250
  // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
29251
29251
  var version = "6.7.1";
@@ -30317,27 +30317,6 @@ This unreleased fuel-core build may include features and updates not yet support
30317
30317
  };
30318
30318
  Object.freeze(pbkdf22);
30319
30319
 
30320
- // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
30321
- var locked5 = false;
30322
- var _randomBytes = function(length) {
30323
- return new Uint8Array((0, import_crypto2.randomBytes)(length));
30324
- };
30325
- var __randomBytes = _randomBytes;
30326
- function randomBytes3(length) {
30327
- return __randomBytes(length);
30328
- }
30329
- randomBytes3._ = _randomBytes;
30330
- randomBytes3.lock = function() {
30331
- locked5 = true;
30332
- };
30333
- randomBytes3.register = function(func) {
30334
- if (locked5) {
30335
- throw new Error("randomBytes is locked");
30336
- }
30337
- __randomBytes = func;
30338
- };
30339
- Object.freeze(randomBytes3);
30340
-
30341
30320
  // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
30342
30321
  var BN_03 = BigInt(0);
30343
30322
  var BN_36 = BigInt(36);
@@ -30922,8 +30901,8 @@ This unreleased fuel-core build may include features and updates not yet support
30922
30901
  }
30923
30902
 
30924
30903
  // ../crypto/dist/index.mjs
30904
+ var import_crypto9 = __toESM(__require("crypto"), 1);
30925
30905
  var import_crypto10 = __toESM(__require("crypto"), 1);
30926
- var import_crypto11 = __toESM(__require("crypto"), 1);
30927
30906
  var scrypt3 = (params) => {
30928
30907
  const { password, salt, n, p, r, dklen } = params;
30929
30908
  const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
@@ -30932,7 +30911,7 @@ This unreleased fuel-core build may include features and updates not yet support
30932
30911
  var keccak2562 = (data) => keccak_256(data);
30933
30912
  var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
30934
30913
  var randomBytes4 = (length) => {
30935
- const randomValues = Uint8Array.from(import_crypto10.default.randomBytes(length));
30914
+ const randomValues = Uint8Array.from(import_crypto9.default.randomBytes(length));
30936
30915
  return randomValues;
30937
30916
  };
30938
30917
  var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
@@ -30947,7 +30926,7 @@ This unreleased fuel-core build may include features and updates not yet support
30947
30926
  const salt = randomBytes4(32);
30948
30927
  const secret = keyFromPassword(password, salt);
30949
30928
  const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
30950
- const cipher = await import_crypto9.default.createCipheriv(ALGORITHM, secret, iv);
30929
+ const cipher = await import_crypto8.default.createCipheriv(ALGORITHM, secret, iv);
30951
30930
  let cipherData = cipher.update(dataBuffer);
30952
30931
  cipherData = Buffer.concat([cipherData, cipher.final()]);
30953
30932
  return {
@@ -30961,7 +30940,7 @@ This unreleased fuel-core build may include features and updates not yet support
30961
30940
  const salt = bufferFromString(keystore.salt);
30962
30941
  const secret = keyFromPassword(password, salt);
30963
30942
  const encryptedText = bufferFromString(keystore.data);
30964
- const decipher = await import_crypto9.default.createDecipheriv(ALGORITHM, secret, iv);
30943
+ const decipher = await import_crypto8.default.createDecipheriv(ALGORITHM, secret, iv);
30965
30944
  const decrypted = decipher.update(encryptedText);
30966
30945
  const deBuff = Buffer.concat([decrypted, decipher.final()]);
30967
30946
  const decryptedData = Buffer.from(deBuff).toString("utf-8");
@@ -30972,12 +30951,12 @@ This unreleased fuel-core build may include features and updates not yet support
30972
30951
  }
30973
30952
  };
30974
30953
  async function encryptJsonWalletData(data, key, iv) {
30975
- const cipher = await import_crypto11.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30954
+ const cipher = await import_crypto10.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30976
30955
  const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
30977
30956
  return new Uint8Array(encrypted);
30978
30957
  }
30979
30958
  async function decryptJsonWalletData(data, key, iv) {
30980
- const decipher = import_crypto11.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30959
+ const decipher = import_crypto10.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30981
30960
  const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
30982
30961
  return new Uint8Array(decrypted);
30983
30962
  }
@@ -31516,182 +31495,32 @@ This unreleased fuel-core build may include features and updates not yet support
31516
31495
  function toBytes3(value, bytesPadding) {
31517
31496
  return bn(value).toBytes(bytesPadding);
31518
31497
  }
31519
-
31520
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
31521
- function _isPlaceholder(a) {
31522
- return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
31523
- }
31524
-
31525
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
31526
- function _curry1(fn) {
31527
- return function f1(a) {
31528
- if (arguments.length === 0 || _isPlaceholder(a)) {
31529
- return f1;
31530
- } else {
31531
- return fn.apply(this, arguments);
31532
- }
31533
- };
31498
+ function max(...numbers) {
31499
+ return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
31534
31500
  }
31535
31501
 
31536
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
31537
- var isArray_default = Array.isArray || function _isArray(val) {
31538
- return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
31539
- };
31540
-
31541
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
31542
- var type = /* @__PURE__ */ _curry1(function type2(val) {
31543
- return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
31544
- });
31545
- var type_default = type;
31546
-
31547
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
31548
- var pad = function pad2(n) {
31549
- return (n < 10 ? "0" : "") + n;
31550
- };
31551
- var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
31552
- return d.toISOString();
31553
- } : function _toISOString3(d) {
31554
- return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
31555
- };
31556
-
31557
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
31558
- var isInteger_default = Number.isInteger || function _isInteger(n) {
31559
- return n << 0 === n;
31560
- };
31561
-
31562
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
31563
- function _cloneRegExp(pattern) {
31564
- return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
31565
- }
31566
-
31567
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
31568
- function _clone(value, deep, map) {
31569
- map || (map = new _ObjectMap());
31570
- if (_isPrimitive(value)) {
31571
- return value;
31572
- }
31573
- var copy = function copy2(copiedValue) {
31574
- var cachedCopy = map.get(value);
31575
- if (cachedCopy) {
31576
- return cachedCopy;
31577
- }
31578
- map.set(value, copiedValue);
31579
- for (var key in value) {
31580
- if (Object.prototype.hasOwnProperty.call(value, key)) {
31581
- copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
31582
- }
31583
- }
31584
- return copiedValue;
31585
- };
31586
- switch (type_default(value)) {
31587
- case "Object":
31588
- return copy(Object.create(Object.getPrototypeOf(value)));
31589
- case "Array":
31590
- return copy([]);
31591
- case "Date":
31592
- return new Date(value.valueOf());
31593
- case "RegExp":
31594
- return _cloneRegExp(value);
31595
- case "Int8Array":
31596
- case "Uint8Array":
31597
- case "Uint8ClampedArray":
31598
- case "Int16Array":
31599
- case "Uint16Array":
31600
- case "Int32Array":
31601
- case "Uint32Array":
31602
- case "Float32Array":
31603
- case "Float64Array":
31604
- case "BigInt64Array":
31605
- case "BigUint64Array":
31606
- return value.slice();
31607
- default:
31608
- return value;
31609
- }
31610
- }
31611
- function _isPrimitive(param) {
31612
- var type3 = typeof param;
31613
- return param == null || type3 != "object" && type3 != "function";
31614
- }
31615
- var _ObjectMap = /* @__PURE__ */ function() {
31616
- function _ObjectMap2() {
31617
- this.map = {};
31618
- this.length = 0;
31619
- }
31620
- _ObjectMap2.prototype.set = function(key, value) {
31621
- const hashedKey = this.hash(key);
31622
- let bucket = this.map[hashedKey];
31623
- if (!bucket) {
31624
- this.map[hashedKey] = bucket = [];
31625
- }
31626
- bucket.push([key, value]);
31627
- this.length += 1;
31628
- };
31629
- _ObjectMap2.prototype.hash = function(key) {
31630
- let hashedKey = [];
31631
- for (var value in key) {
31632
- hashedKey.push(Object.prototype.toString.call(key[value]));
31633
- }
31634
- return hashedKey.join();
31635
- };
31636
- _ObjectMap2.prototype.get = function(key) {
31637
- if (this.length <= 180) {
31638
- for (const p in this.map) {
31639
- const bucket2 = this.map[p];
31640
- for (let i = 0; i < bucket2.length; i += 1) {
31641
- const element = bucket2[i];
31642
- if (element[0] === key) {
31643
- return element[1];
31644
- }
31645
- }
31646
- }
31647
- return;
31648
- }
31649
- const hashedKey = this.hash(key);
31650
- const bucket = this.map[hashedKey];
31651
- if (!bucket) {
31652
- return;
31653
- }
31654
- for (let i = 0; i < bucket.length; i += 1) {
31655
- const element = bucket[i];
31656
- if (element[0] === key) {
31657
- return element[1];
31658
- }
31659
- }
31660
- };
31661
- return _ObjectMap2;
31662
- }();
31663
-
31664
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
31665
- var clone = /* @__PURE__ */ _curry1(function clone2(value) {
31666
- return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
31667
- });
31668
- var clone_default = clone;
31669
-
31670
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
31671
- var hasProtoTrim = typeof String.prototype.trim === "function";
31672
-
31673
31502
  // src/providers/coin-quantity.ts
31674
31503
  var coinQuantityfy = (coinQuantityLike) => {
31675
31504
  let assetId;
31676
31505
  let amount;
31677
- let max;
31506
+ let max2;
31678
31507
  if (Array.isArray(coinQuantityLike)) {
31679
31508
  amount = coinQuantityLike[0];
31680
31509
  assetId = coinQuantityLike[1] ?? BaseAssetId;
31681
- max = coinQuantityLike[2] ?? void 0;
31510
+ max2 = coinQuantityLike[2] ?? void 0;
31682
31511
  } else {
31683
31512
  amount = coinQuantityLike.amount;
31684
31513
  assetId = coinQuantityLike.assetId ?? BaseAssetId;
31685
- max = coinQuantityLike.max ?? void 0;
31514
+ max2 = coinQuantityLike.max ?? void 0;
31686
31515
  }
31687
31516
  const bnAmount = bn(amount);
31688
31517
  return {
31689
31518
  assetId: hexlify(assetId),
31690
31519
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
31691
- max: max ? bn(max) : void 0
31520
+ max: max2 ? bn(max2) : void 0
31692
31521
  };
31693
31522
  };
31694
- var addAmountToCoinQuantities = (params) => {
31523
+ var addAmountToAsset = (params) => {
31695
31524
  const { amount, assetId } = params;
31696
31525
  const coinQuantities = [...params.coinQuantities];
31697
31526
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -31776,6 +31605,7 @@ This unreleased fuel-core build may include features and updates not yet support
31776
31605
  var ENCODING_V1 = "1";
31777
31606
  var WORD_SIZE = 8;
31778
31607
  var BYTES_32 = 32;
31608
+ var UTXO_ID_LEN = BYTES_32 + 1;
31779
31609
  var ASSET_ID_LEN = BYTES_32;
31780
31610
  var ADDRESS_LEN = BYTES_32;
31781
31611
  var NONCE_LEN = BYTES_32;
@@ -31783,9 +31613,9 @@ This unreleased fuel-core build may include features and updates not yet support
31783
31613
  var TX_POINTER_LEN = WORD_SIZE * 2;
31784
31614
  var MAX_BYTES = 2 ** 32 - 1;
31785
31615
  var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
31786
- ASSET_ID_LEN + // Base asset ID
31616
+ WORD_SIZE + // Tx size
31787
31617
  // Asset ID/Balance coin input pairs
31788
- maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
31618
+ maxInputs * (ASSET_ID_LEN + WORD_SIZE);
31789
31619
  var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
31790
31620
  WORD_SIZE + // Gas limit
31791
31621
  WORD_SIZE + // Script size
@@ -31803,6 +31633,7 @@ This unreleased fuel-core build may include features and updates not yet support
31803
31633
  ASSET_ID_LEN + // Asset id
31804
31634
  TX_POINTER_LEN + // TxPointer
31805
31635
  WORD_SIZE + // Witnesses index
31636
+ WORD_SIZE + // Maturity
31806
31637
  WORD_SIZE + // Predicate size
31807
31638
  WORD_SIZE + // Predicate data size
31808
31639
  WORD_SIZE;
@@ -32124,7 +31955,7 @@ This unreleased fuel-core build may include features and updates not yet support
32124
31955
  constructor(name, coders) {
32125
31956
  const caseIndexCoder = new BigNumberCoder("u64");
32126
31957
  const encodedValueSize = Object.values(coders).reduce(
32127
- (max, coder) => Math.max(max, coder.encodedLength),
31958
+ (max2, coder) => Math.max(max2, coder.encodedLength),
32128
31959
  0
32129
31960
  );
32130
31961
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -32828,7 +32659,7 @@ This unreleased fuel-core build may include features and updates not yet support
32828
32659
  constructor(name, coders) {
32829
32660
  const caseIndexCoder = new BigNumberCoder("u64");
32830
32661
  const encodedValueSize = Object.values(coders).reduce(
32831
- (max, coder) => Math.max(max, coder.encodedLength),
32662
+ (max2, coder) => Math.max(max2, coder.encodedLength),
32832
32663
  0
32833
32664
  );
32834
32665
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -33540,19 +33371,18 @@ This unreleased fuel-core build may include features and updates not yet support
33540
33371
  encode(value) {
33541
33372
  const parts = [];
33542
33373
  parts.push(new B256Coder().encode(value.txID));
33543
- parts.push(new NumberCoder("u16").encode(value.outputIndex));
33374
+ parts.push(new NumberCoder("u8").encode(value.outputIndex));
33544
33375
  parts.push(new B256Coder().encode(value.owner));
33545
33376
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33546
33377
  parts.push(new B256Coder().encode(value.assetId));
33547
33378
  parts.push(new TxPointerCoder().encode(value.txPointer));
33548
- parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33379
+ parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33380
+ parts.push(new NumberCoder("u32").encode(value.maturity));
33549
33381
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33550
- parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33551
- parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33552
- parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33553
- parts.push(
33554
- new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33555
- );
33382
+ parts.push(new NumberCoder("u32").encode(value.predicateLength));
33383
+ parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
33384
+ parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33385
+ parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33556
33386
  return concat(parts);
33557
33387
  }
33558
33388
  decode(data, offset) {
@@ -33560,7 +33390,7 @@ This unreleased fuel-core build may include features and updates not yet support
33560
33390
  let o = offset;
33561
33391
  [decoded, o] = new B256Coder().decode(data, o);
33562
33392
  const txID = decoded;
33563
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33393
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33564
33394
  const outputIndex = decoded;
33565
33395
  [decoded, o] = new B256Coder().decode(data, o);
33566
33396
  const owner = decoded;
@@ -33570,17 +33400,19 @@ This unreleased fuel-core build may include features and updates not yet support
33570
33400
  const assetId = decoded;
33571
33401
  [decoded, o] = new TxPointerCoder().decode(data, o);
33572
33402
  const txPointer = decoded;
33573
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33403
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33574
33404
  const witnessIndex = Number(decoded);
33405
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33406
+ const maturity = decoded;
33575
33407
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33576
33408
  const predicateGasUsed = decoded;
33577
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33409
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33578
33410
  const predicateLength = decoded;
33579
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33411
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33580
33412
  const predicateDataLength = decoded;
33581
- [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33413
+ [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33582
33414
  const predicate = decoded;
33583
- [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33415
+ [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33584
33416
  const predicateData = decoded;
33585
33417
  return [
33586
33418
  {
@@ -33592,6 +33424,7 @@ This unreleased fuel-core build may include features and updates not yet support
33592
33424
  assetId,
33593
33425
  txPointer,
33594
33426
  witnessIndex,
33427
+ maturity,
33595
33428
  predicateGasUsed,
33596
33429
  predicateLength,
33597
33430
  predicateDataLength,
@@ -33609,7 +33442,7 @@ This unreleased fuel-core build may include features and updates not yet support
33609
33442
  encode(value) {
33610
33443
  const parts = [];
33611
33444
  parts.push(new B256Coder().encode(value.txID));
33612
- parts.push(new NumberCoder("u16").encode(value.outputIndex));
33445
+ parts.push(new NumberCoder("u8").encode(value.outputIndex));
33613
33446
  parts.push(new B256Coder().encode(value.balanceRoot));
33614
33447
  parts.push(new B256Coder().encode(value.stateRoot));
33615
33448
  parts.push(new TxPointerCoder().encode(value.txPointer));
@@ -33621,7 +33454,7 @@ This unreleased fuel-core build may include features and updates not yet support
33621
33454
  let o = offset;
33622
33455
  [decoded, o] = new B256Coder().decode(data, o);
33623
33456
  const txID = decoded;
33624
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33457
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33625
33458
  const outputIndex = decoded;
33626
33459
  [decoded, o] = new B256Coder().decode(data, o);
33627
33460
  const balanceRoot = decoded;
@@ -33670,16 +33503,14 @@ This unreleased fuel-core build may include features and updates not yet support
33670
33503
  parts.push(new ByteArrayCoder(32).encode(value.recipient));
33671
33504
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33672
33505
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
33673
- parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33506
+ parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33674
33507
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33675
- parts.push(new BigNumberCoder("u64").encode(data.length));
33676
- parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33677
- parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33508
+ parts.push(new NumberCoder("u32").encode(data.length));
33509
+ parts.push(new NumberCoder("u32").encode(value.predicateLength));
33510
+ parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
33678
33511
  parts.push(new ByteArrayCoder(data.length).encode(data));
33679
- parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33680
- parts.push(
33681
- new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33682
- );
33512
+ parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33513
+ parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33683
33514
  return concat(parts);
33684
33515
  }
33685
33516
  static decodeData(messageData) {
@@ -33699,21 +33530,21 @@ This unreleased fuel-core build may include features and updates not yet support
33699
33530
  const amount = decoded;
33700
33531
  [decoded, o] = new B256Coder().decode(data, o);
33701
33532
  const nonce = decoded;
33702
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33533
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33703
33534
  const witnessIndex = Number(decoded);
33704
33535
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33705
33536
  const predicateGasUsed = decoded;
33706
33537
  [decoded, o] = new NumberCoder("u32").decode(data, o);
33707
33538
  const dataLength2 = decoded;
33708
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33539
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33709
33540
  const predicateLength = decoded;
33710
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33541
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33711
33542
  const predicateDataLength = decoded;
33712
33543
  [decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
33713
33544
  const messageData = decoded;
33714
- [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33545
+ [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33715
33546
  const predicate = decoded;
33716
- [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33547
+ [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33717
33548
  const predicateData = decoded;
33718
33549
  return [
33719
33550
  {
@@ -34025,7 +33856,7 @@ This unreleased fuel-core build may include features and updates not yet support
34025
33856
  }
34026
33857
  };
34027
33858
  var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
34028
- PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
33859
+ PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
34029
33860
  PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
34030
33861
  PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
34031
33862
  PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
@@ -34073,9 +33904,9 @@ This unreleased fuel-core build may include features and updates not yet support
34073
33904
  let o = offset;
34074
33905
  const policies = [];
34075
33906
  if (policyTypes & 1) {
34076
- const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
33907
+ const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
34077
33908
  o = nextOffset;
34078
- policies.push({ type: 1, data: tip });
33909
+ policies.push({ type: 1, data: gasPrice });
34079
33910
  }
34080
33911
  if (policyTypes & 2) {
34081
33912
  const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
@@ -34307,15 +34138,15 @@ This unreleased fuel-core build may include features and updates not yet support
34307
34138
  encode(value) {
34308
34139
  const parts = [];
34309
34140
  parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
34310
- parts.push(new B256Coder().encode(value.receiptsRoot));
34311
- parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
34312
- parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
34141
+ parts.push(new NumberCoder("u32").encode(value.scriptLength));
34142
+ parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
34313
34143
  parts.push(new NumberCoder("u32").encode(value.policyTypes));
34314
- parts.push(new NumberCoder("u16").encode(value.inputsCount));
34315
- parts.push(new NumberCoder("u16").encode(value.outputsCount));
34316
- parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34317
- parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
34318
- parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
34144
+ parts.push(new NumberCoder("u8").encode(value.inputsCount));
34145
+ parts.push(new NumberCoder("u8").encode(value.outputsCount));
34146
+ parts.push(new NumberCoder("u8").encode(value.witnessesCount));
34147
+ parts.push(new B256Coder().encode(value.receiptsRoot));
34148
+ parts.push(new ByteArrayCoder(value.scriptLength).encode(value.script));
34149
+ parts.push(new ByteArrayCoder(value.scriptDataLength).encode(value.scriptData));
34319
34150
  parts.push(new PoliciesCoder().encode(value.policies));
34320
34151
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34321
34152
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
@@ -34327,23 +34158,23 @@ This unreleased fuel-core build may include features and updates not yet support
34327
34158
  let o = offset;
34328
34159
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34329
34160
  const scriptGasLimit = decoded;
34330
- [decoded, o] = new B256Coder().decode(data, o);
34331
- const receiptsRoot = decoded;
34332
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34161
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
34333
34162
  const scriptLength = decoded;
34334
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34163
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
34335
34164
  const scriptDataLength = decoded;
34336
34165
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34337
34166
  const policyTypes = decoded;
34338
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34167
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34339
34168
  const inputsCount = decoded;
34340
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34169
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34341
34170
  const outputsCount = decoded;
34342
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34171
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34343
34172
  const witnessesCount = decoded;
34344
- [decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
34173
+ [decoded, o] = new B256Coder().decode(data, o);
34174
+ const receiptsRoot = decoded;
34175
+ [decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
34345
34176
  const script = decoded;
34346
- [decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
34177
+ [decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
34347
34178
  const scriptData = decoded;
34348
34179
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34349
34180
  const policies = decoded;
@@ -34381,19 +34212,18 @@ This unreleased fuel-core build may include features and updates not yet support
34381
34212
  }
34382
34213
  encode(value) {
34383
34214
  const parts = [];
34384
- parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
34385
- parts.push(new B256Coder().encode(value.salt));
34386
- parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
34215
+ parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
34216
+ parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
34387
34217
  parts.push(new NumberCoder("u32").encode(value.policyTypes));
34388
- parts.push(new NumberCoder("u16").encode(value.inputsCount));
34389
- parts.push(new NumberCoder("u16").encode(value.outputsCount));
34390
- parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34218
+ parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
34219
+ parts.push(new NumberCoder("u8").encode(value.inputsCount));
34220
+ parts.push(new NumberCoder("u8").encode(value.outputsCount));
34221
+ parts.push(new NumberCoder("u8").encode(value.witnessesCount));
34222
+ parts.push(new B256Coder().encode(value.salt));
34223
+ parts.push(new PoliciesCoder().encode(value.policies));
34391
34224
  parts.push(
34392
- new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
34393
- value.storageSlots
34394
- )
34225
+ new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
34395
34226
  );
34396
- parts.push(new PoliciesCoder().encode(value.policies));
34397
34227
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34398
34228
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
34399
34229
  parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
@@ -34402,27 +34232,26 @@ This unreleased fuel-core build may include features and updates not yet support
34402
34232
  decode(data, offset) {
34403
34233
  let decoded;
34404
34234
  let o = offset;
34405
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34235
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
34236
+ const bytecodeLength = decoded;
34237
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34406
34238
  const bytecodeWitnessIndex = decoded;
34407
- [decoded, o] = new B256Coder().decode(data, o);
34408
- const salt = decoded;
34409
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34410
- const storageSlotsCount = decoded;
34411
34239
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34412
34240
  const policyTypes = decoded;
34413
34241
  [decoded, o] = new NumberCoder("u16").decode(data, o);
34242
+ const storageSlotsCount = decoded;
34243
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34414
34244
  const inputsCount = decoded;
34415
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34245
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34416
34246
  const outputsCount = decoded;
34417
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34247
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34418
34248
  const witnessesCount = decoded;
34419
- [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
34420
- data,
34421
- o
34422
- );
34423
- const storageSlots = decoded;
34249
+ [decoded, o] = new B256Coder().decode(data, o);
34250
+ const salt = decoded;
34424
34251
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34425
34252
  const policies = decoded;
34253
+ [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
34254
+ const storageSlots = decoded;
34426
34255
  [decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
34427
34256
  const inputs = decoded;
34428
34257
  [decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
@@ -34432,6 +34261,7 @@ This unreleased fuel-core build may include features and updates not yet support
34432
34261
  return [
34433
34262
  {
34434
34263
  type: 1,
34264
+ bytecodeLength,
34435
34265
  bytecodeWitnessIndex,
34436
34266
  policyTypes,
34437
34267
  storageSlotsCount,
@@ -34460,7 +34290,6 @@ This unreleased fuel-core build may include features and updates not yet support
34460
34290
  parts.push(new OutputContractCoder().encode(value.outputContract));
34461
34291
  parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
34462
34292
  parts.push(new B256Coder().encode(value.mintAssetId));
34463
- parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
34464
34293
  return concat(parts);
34465
34294
  }
34466
34295
  decode(data, offset) {
@@ -34476,8 +34305,6 @@ This unreleased fuel-core build may include features and updates not yet support
34476
34305
  const mintAmount = decoded;
34477
34306
  [decoded, o] = new B256Coder().decode(data, o);
34478
34307
  const mintAssetId = decoded;
34479
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34480
- const gasPrice = decoded;
34481
34308
  return [
34482
34309
  {
34483
34310
  type: 2,
@@ -34485,8 +34312,7 @@ This unreleased fuel-core build may include features and updates not yet support
34485
34312
  inputContract,
34486
34313
  outputContract,
34487
34314
  mintAmount,
34488
- mintAssetId,
34489
- gasPrice
34315
+ mintAssetId
34490
34316
  },
34491
34317
  o
34492
34318
  ];
@@ -34793,6 +34619,159 @@ This unreleased fuel-core build may include features and updates not yet support
34793
34619
  // src/providers/provider.ts
34794
34620
  var import_graphql_request = __toESM(require_dist2());
34795
34621
 
34622
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
34623
+ function _isPlaceholder(a) {
34624
+ return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
34625
+ }
34626
+
34627
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
34628
+ function _curry1(fn) {
34629
+ return function f1(a) {
34630
+ if (arguments.length === 0 || _isPlaceholder(a)) {
34631
+ return f1;
34632
+ } else {
34633
+ return fn.apply(this, arguments);
34634
+ }
34635
+ };
34636
+ }
34637
+
34638
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
34639
+ var isArray_default = Array.isArray || function _isArray(val) {
34640
+ return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
34641
+ };
34642
+
34643
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
34644
+ var type = /* @__PURE__ */ _curry1(function type2(val) {
34645
+ return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
34646
+ });
34647
+ var type_default = type;
34648
+
34649
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
34650
+ var pad = function pad2(n) {
34651
+ return (n < 10 ? "0" : "") + n;
34652
+ };
34653
+ var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
34654
+ return d.toISOString();
34655
+ } : function _toISOString3(d) {
34656
+ return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
34657
+ };
34658
+
34659
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
34660
+ var isInteger_default = Number.isInteger || function _isInteger(n) {
34661
+ return n << 0 === n;
34662
+ };
34663
+
34664
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
34665
+ function _cloneRegExp(pattern) {
34666
+ return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
34667
+ }
34668
+
34669
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
34670
+ function _clone(value, deep, map) {
34671
+ map || (map = new _ObjectMap());
34672
+ if (_isPrimitive(value)) {
34673
+ return value;
34674
+ }
34675
+ var copy = function copy2(copiedValue) {
34676
+ var cachedCopy = map.get(value);
34677
+ if (cachedCopy) {
34678
+ return cachedCopy;
34679
+ }
34680
+ map.set(value, copiedValue);
34681
+ for (var key in value) {
34682
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
34683
+ copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
34684
+ }
34685
+ }
34686
+ return copiedValue;
34687
+ };
34688
+ switch (type_default(value)) {
34689
+ case "Object":
34690
+ return copy(Object.create(Object.getPrototypeOf(value)));
34691
+ case "Array":
34692
+ return copy([]);
34693
+ case "Date":
34694
+ return new Date(value.valueOf());
34695
+ case "RegExp":
34696
+ return _cloneRegExp(value);
34697
+ case "Int8Array":
34698
+ case "Uint8Array":
34699
+ case "Uint8ClampedArray":
34700
+ case "Int16Array":
34701
+ case "Uint16Array":
34702
+ case "Int32Array":
34703
+ case "Uint32Array":
34704
+ case "Float32Array":
34705
+ case "Float64Array":
34706
+ case "BigInt64Array":
34707
+ case "BigUint64Array":
34708
+ return value.slice();
34709
+ default:
34710
+ return value;
34711
+ }
34712
+ }
34713
+ function _isPrimitive(param) {
34714
+ var type3 = typeof param;
34715
+ return param == null || type3 != "object" && type3 != "function";
34716
+ }
34717
+ var _ObjectMap = /* @__PURE__ */ function() {
34718
+ function _ObjectMap2() {
34719
+ this.map = {};
34720
+ this.length = 0;
34721
+ }
34722
+ _ObjectMap2.prototype.set = function(key, value) {
34723
+ const hashedKey = this.hash(key);
34724
+ let bucket = this.map[hashedKey];
34725
+ if (!bucket) {
34726
+ this.map[hashedKey] = bucket = [];
34727
+ }
34728
+ bucket.push([key, value]);
34729
+ this.length += 1;
34730
+ };
34731
+ _ObjectMap2.prototype.hash = function(key) {
34732
+ let hashedKey = [];
34733
+ for (var value in key) {
34734
+ hashedKey.push(Object.prototype.toString.call(key[value]));
34735
+ }
34736
+ return hashedKey.join();
34737
+ };
34738
+ _ObjectMap2.prototype.get = function(key) {
34739
+ if (this.length <= 180) {
34740
+ for (const p in this.map) {
34741
+ const bucket2 = this.map[p];
34742
+ for (let i = 0; i < bucket2.length; i += 1) {
34743
+ const element = bucket2[i];
34744
+ if (element[0] === key) {
34745
+ return element[1];
34746
+ }
34747
+ }
34748
+ }
34749
+ return;
34750
+ }
34751
+ const hashedKey = this.hash(key);
34752
+ const bucket = this.map[hashedKey];
34753
+ if (!bucket) {
34754
+ return;
34755
+ }
34756
+ for (let i = 0; i < bucket.length; i += 1) {
34757
+ const element = bucket[i];
34758
+ if (element[0] === key) {
34759
+ return element[1];
34760
+ }
34761
+ }
34762
+ };
34763
+ return _ObjectMap2;
34764
+ }();
34765
+
34766
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
34767
+ var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
34768
+ return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
34769
+ });
34770
+ var clone_default = clone2;
34771
+
34772
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
34773
+ var hasProtoTrim = typeof String.prototype.trim === "function";
34774
+
34796
34775
  // ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
34797
34776
  var __assign = function() {
34798
34777
  __assign = Object.assign || function __assign2(t) {
@@ -37960,10 +37939,14 @@ spurious results.`);
37960
37939
  // src/providers/__generated__/operations.ts
37961
37940
  var ReceiptFragmentFragmentDoc = lib_default2`
37962
37941
  fragment receiptFragment on Receipt {
37963
- id
37942
+ contract {
37943
+ id
37944
+ }
37964
37945
  pc
37965
37946
  is
37966
- to
37947
+ to {
37948
+ id
37949
+ }
37967
37950
  toAddress
37968
37951
  amount
37969
37952
  assetId
@@ -38001,16 +37984,10 @@ spurious results.`);
38001
37984
  id
38002
37985
  }
38003
37986
  time
38004
- receipts {
38005
- ...receiptFragment
38006
- }
38007
37987
  programState {
38008
37988
  returnType
38009
37989
  data
38010
37990
  }
38011
- receipts {
38012
- ...receiptFragment
38013
- }
38014
37991
  }
38015
37992
  ... on FailureStatus {
38016
37993
  block {
@@ -38018,24 +37995,26 @@ spurious results.`);
38018
37995
  }
38019
37996
  time
38020
37997
  reason
38021
- receipts {
38022
- ...receiptFragment
38023
- }
38024
37998
  }
38025
37999
  ... on SqueezedOutStatus {
38026
38000
  reason
38027
38001
  }
38028
38002
  }
38029
- ${ReceiptFragmentFragmentDoc}`;
38003
+ `;
38030
38004
  var TransactionFragmentFragmentDoc = lib_default2`
38031
38005
  fragment transactionFragment on Transaction {
38032
38006
  id
38033
38007
  rawPayload
38008
+ gasPrice
38009
+ receipts {
38010
+ ...receiptFragment
38011
+ }
38034
38012
  status {
38035
38013
  ...transactionStatusFragment
38036
38014
  }
38037
38015
  }
38038
- ${TransactionStatusFragmentFragmentDoc}`;
38016
+ ${ReceiptFragmentFragmentDoc}
38017
+ ${TransactionStatusFragmentFragmentDoc}`;
38039
38018
  var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
38040
38019
  fragment inputEstimatePredicatesFragment on Input {
38041
38020
  ... on InputCoin {
@@ -38053,46 +38032,6 @@ spurious results.`);
38053
38032
  }
38054
38033
  }
38055
38034
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
38056
- var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
38057
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
38058
- reason
38059
- programState {
38060
- returnType
38061
- data
38062
- }
38063
- }
38064
- `;
38065
- var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
38066
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
38067
- programState {
38068
- returnType
38069
- data
38070
- }
38071
- }
38072
- `;
38073
- var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
38074
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
38075
- ... on DryRunFailureStatus {
38076
- ...dryRunFailureStatusFragment
38077
- }
38078
- ... on DryRunSuccessStatus {
38079
- ...dryRunSuccessStatusFragment
38080
- }
38081
- }
38082
- ${DryRunFailureStatusFragmentFragmentDoc}
38083
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
38084
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
38085
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
38086
- id
38087
- status {
38088
- ...dryRunTransactionStatusFragment
38089
- }
38090
- receipts {
38091
- ...receiptFragment
38092
- }
38093
- }
38094
- ${DryRunTransactionStatusFragmentFragmentDoc}
38095
- ${ReceiptFragmentFragmentDoc}`;
38096
38035
  var CoinFragmentFragmentDoc = lib_default2`
38097
38036
  fragment coinFragment on Coin {
38098
38037
  __typename
@@ -38100,6 +38039,7 @@ ${ReceiptFragmentFragmentDoc}`;
38100
38039
  owner
38101
38040
  amount
38102
38041
  assetId
38042
+ maturity
38103
38043
  blockCreated
38104
38044
  txCreatedIdx
38105
38045
  }
@@ -38138,32 +38078,26 @@ ${ReceiptFragmentFragmentDoc}`;
38138
38078
  messageBlockHeader {
38139
38079
  id
38140
38080
  daHeight
38141
- consensusParametersVersion
38142
- stateTransitionBytecodeVersion
38143
38081
  transactionsCount
38144
- messageReceiptCount
38145
38082
  transactionsRoot
38146
- messageOutboxRoot
38147
- eventInboxRoot
38148
38083
  height
38149
38084
  prevRoot
38150
38085
  time
38151
38086
  applicationHash
38087
+ messageReceiptRoot
38088
+ messageReceiptCount
38152
38089
  }
38153
38090
  commitBlockHeader {
38154
38091
  id
38155
38092
  daHeight
38156
- consensusParametersVersion
38157
- stateTransitionBytecodeVersion
38158
38093
  transactionsCount
38159
- messageReceiptCount
38160
38094
  transactionsRoot
38161
- messageOutboxRoot
38162
- eventInboxRoot
38163
38095
  height
38164
38096
  prevRoot
38165
38097
  time
38166
38098
  applicationHash
38099
+ messageReceiptRoot
38100
+ messageReceiptCount
38167
38101
  }
38168
38102
  sender
38169
38103
  recipient
@@ -38182,8 +38116,8 @@ ${ReceiptFragmentFragmentDoc}`;
38182
38116
  var BlockFragmentFragmentDoc = lib_default2`
38183
38117
  fragment blockFragment on Block {
38184
38118
  id
38185
- height
38186
38119
  header {
38120
+ height
38187
38121
  time
38188
38122
  }
38189
38123
  transactions {
@@ -38241,11 +38175,6 @@ ${ReceiptFragmentFragmentDoc}`;
38241
38175
  `;
38242
38176
  var GasCostsFragmentFragmentDoc = lib_default2`
38243
38177
  fragment GasCostsFragment on GasCosts {
38244
- version {
38245
- ... on Version {
38246
- value
38247
- }
38248
- }
38249
38178
  add
38250
38179
  addi
38251
38180
  aloc
@@ -38258,6 +38187,7 @@ ${ReceiptFragmentFragmentDoc}`;
38258
38187
  cb
38259
38188
  cfei
38260
38189
  cfsi
38190
+ croo
38261
38191
  div
38262
38192
  divi
38263
38193
  ecr1
@@ -38340,9 +38270,6 @@ ${ReceiptFragmentFragmentDoc}`;
38340
38270
  ccp {
38341
38271
  ...DependentCostFragment
38342
38272
  }
38343
- croo {
38344
- ...DependentCostFragment
38345
- }
38346
38273
  csiz {
38347
38274
  ...DependentCostFragment
38348
38275
  }
@@ -38402,11 +38329,6 @@ ${ReceiptFragmentFragmentDoc}`;
38402
38329
  ${DependentCostFragmentFragmentDoc}`;
38403
38330
  var ConsensusParametersFragmentFragmentDoc = lib_default2`
38404
38331
  fragment consensusParametersFragment on ConsensusParameters {
38405
- version {
38406
- ... on Version {
38407
- value
38408
- }
38409
- }
38410
38332
  txParams {
38411
38333
  ...TxParametersFragment
38412
38334
  }
@@ -38466,9 +38388,18 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38466
38388
  fragment nodeInfoFragment on NodeInfo {
38467
38389
  utxoValidation
38468
38390
  vmBacktrace
38391
+ minGasPrice
38469
38392
  maxTx
38470
38393
  maxDepth
38471
38394
  nodeVersion
38395
+ peers {
38396
+ id
38397
+ addresses
38398
+ clientVersion
38399
+ blockHeight
38400
+ lastHeartbeatMs
38401
+ appScore
38402
+ }
38472
38403
  }
38473
38404
  `;
38474
38405
  var GetVersionDocument = lib_default2`
@@ -38503,9 +38434,13 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38503
38434
  query getTransactionWithReceipts($transactionId: TransactionId!) {
38504
38435
  transaction(id: $transactionId) {
38505
38436
  ...transactionFragment
38437
+ receipts {
38438
+ ...receiptFragment
38439
+ }
38506
38440
  }
38507
38441
  }
38508
- ${TransactionFragmentFragmentDoc}`;
38442
+ ${TransactionFragmentFragmentDoc}
38443
+ ${ReceiptFragmentFragmentDoc}`;
38509
38444
  var GetTransactionsDocument = lib_default2`
38510
38445
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
38511
38446
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -38633,20 +38568,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38633
38568
  }
38634
38569
  }
38635
38570
  ${BalanceFragmentFragmentDoc}`;
38636
- var GetLatestGasPriceDocument = lib_default2`
38637
- query getLatestGasPrice {
38638
- latestGasPrice {
38639
- gasPrice
38640
- }
38641
- }
38642
- `;
38643
- var EstimateGasPriceDocument = lib_default2`
38644
- query estimateGasPrice($blockHorizon: U32!) {
38645
- estimateGasPrice(blockHorizon: $blockHorizon) {
38646
- gasPrice
38647
- }
38648
- }
38649
- `;
38650
38571
  var GetBalancesDocument = lib_default2`
38651
38572
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
38652
38573
  balances(
@@ -38701,12 +38622,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38701
38622
  }
38702
38623
  `;
38703
38624
  var DryRunDocument = lib_default2`
38704
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
38705
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
38706
- ...dryRunTransactionExecutionStatusFragment
38625
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
38626
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
38627
+ ...receiptFragment
38707
38628
  }
38708
38629
  }
38709
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
38630
+ ${ReceiptFragmentFragmentDoc}`;
38710
38631
  var SubmitDocument = lib_default2`
38711
38632
  mutation submit($encodedTransaction: HexString!) {
38712
38633
  submit(tx: $encodedTransaction) {
@@ -38789,12 +38710,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38789
38710
  getBalance(variables, options) {
38790
38711
  return requester(GetBalanceDocument, variables, options);
38791
38712
  },
38792
- getLatestGasPrice(variables, options) {
38793
- return requester(GetLatestGasPriceDocument, variables, options);
38794
- },
38795
- estimateGasPrice(variables, options) {
38796
- return requester(EstimateGasPriceDocument, variables, options);
38797
- },
38798
38713
  getBalances(variables, options) {
38799
38714
  return requester(GetBalancesDocument, variables, options);
38800
38715
  },
@@ -38862,14 +38777,11 @@ ${MessageCoinFragmentFragmentDoc}`;
38862
38777
  let data;
38863
38778
  let errors;
38864
38779
  try {
38865
- const sanitizedText = text.replace(/\s/g, "");
38866
- ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
38780
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
38867
38781
  } catch (e) {
38868
38782
  throw new FuelError(
38869
38783
  ErrorCode.STREAM_PARSING_ERROR,
38870
- `Error while parsing stream data response: ${text}
38871
-
38872
- Thrown error: ${e}`
38784
+ `Error while parsing stream data response: ${text}`
38873
38785
  );
38874
38786
  }
38875
38787
  if (Array.isArray(errors)) {
@@ -38962,8 +38874,8 @@ Thrown error: ${e}`
38962
38874
  const predicateData = arrayify(value.predicateData ?? "0x");
38963
38875
  return {
38964
38876
  type: InputType.Coin,
38965
- txID: hexlify(arrayify(value.id).slice(0, 32)),
38966
- outputIndex: toNumber2(arrayify(value.id).slice(32, 34)),
38877
+ txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
38878
+ outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
38967
38879
  owner: hexlify(value.owner),
38968
38880
  amount: bn(value.amount),
38969
38881
  assetId: hexlify(value.assetId),
@@ -38972,9 +38884,10 @@ Thrown error: ${e}`
38972
38884
  txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
38973
38885
  },
38974
38886
  witnessIndex: value.witnessIndex,
38887
+ maturity: value.maturity ?? 0,
38975
38888
  predicateGasUsed: bn(value.predicateGasUsed),
38976
- predicateLength: bn(predicate.length),
38977
- predicateDataLength: bn(predicateData.length),
38889
+ predicateLength: predicate.length,
38890
+ predicateDataLength: predicateData.length,
38978
38891
  predicate: hexlify(predicate),
38979
38892
  predicateData: hexlify(predicateData)
38980
38893
  };
@@ -39005,8 +38918,8 @@ Thrown error: ${e}`
39005
38918
  nonce: hexlify(value.nonce),
39006
38919
  witnessIndex: value.witnessIndex,
39007
38920
  predicateGasUsed: bn(value.predicateGasUsed),
39008
- predicateLength: bn(predicate.length),
39009
- predicateDataLength: bn(predicateData.length),
38921
+ predicateLength: predicate.length,
38922
+ predicateDataLength: predicateData.length,
39010
38923
  predicate: hexlify(predicate),
39011
38924
  predicateData: hexlify(predicateData),
39012
38925
  data: hexlify(data),
@@ -39166,8 +39079,8 @@ Thrown error: ${e}`
39166
39079
  case "CALL" /* Call */: {
39167
39080
  const callReceipt = {
39168
39081
  type: ReceiptType.Call,
39169
- from: hexOrZero(receipt.id || receipt.contractId),
39170
- to: hexOrZero(receipt?.to),
39082
+ from: hexOrZero(receipt.contract?.id),
39083
+ to: hexOrZero(receipt?.to?.id),
39171
39084
  amount: bn(receipt.amount),
39172
39085
  assetId: hexOrZero(receipt.assetId),
39173
39086
  gas: bn(receipt.gas),
@@ -39181,7 +39094,7 @@ Thrown error: ${e}`
39181
39094
  case "RETURN" /* Return */: {
39182
39095
  const returnReceipt = {
39183
39096
  type: ReceiptType.Return,
39184
- id: hexOrZero(receipt.id || receipt.contractId),
39097
+ id: hexOrZero(receipt.contract?.id),
39185
39098
  val: bn(receipt.val),
39186
39099
  pc: bn(receipt.pc),
39187
39100
  is: bn(receipt.is)
@@ -39191,7 +39104,7 @@ Thrown error: ${e}`
39191
39104
  case "RETURN_DATA" /* ReturnData */: {
39192
39105
  const returnDataReceipt = {
39193
39106
  type: ReceiptType.ReturnData,
39194
- id: hexOrZero(receipt.id || receipt.contractId),
39107
+ id: hexOrZero(receipt.contract?.id),
39195
39108
  ptr: bn(receipt.ptr),
39196
39109
  len: bn(receipt.len),
39197
39110
  digest: hexOrZero(receipt.digest),
@@ -39203,7 +39116,7 @@ Thrown error: ${e}`
39203
39116
  case "PANIC" /* Panic */: {
39204
39117
  const panicReceipt = {
39205
39118
  type: ReceiptType.Panic,
39206
- id: hexOrZero(receipt.id),
39119
+ id: hexOrZero(receipt.contract?.id),
39207
39120
  reason: bn(receipt.reason),
39208
39121
  pc: bn(receipt.pc),
39209
39122
  is: bn(receipt.is),
@@ -39214,7 +39127,7 @@ Thrown error: ${e}`
39214
39127
  case "REVERT" /* Revert */: {
39215
39128
  const revertReceipt = {
39216
39129
  type: ReceiptType.Revert,
39217
- id: hexOrZero(receipt.id || receipt.contractId),
39130
+ id: hexOrZero(receipt.contract?.id),
39218
39131
  val: bn(receipt.ra),
39219
39132
  pc: bn(receipt.pc),
39220
39133
  is: bn(receipt.is)
@@ -39224,7 +39137,7 @@ Thrown error: ${e}`
39224
39137
  case "LOG" /* Log */: {
39225
39138
  const logReceipt = {
39226
39139
  type: ReceiptType.Log,
39227
- id: hexOrZero(receipt.id || receipt.contractId),
39140
+ id: hexOrZero(receipt.contract?.id),
39228
39141
  val0: bn(receipt.ra),
39229
39142
  val1: bn(receipt.rb),
39230
39143
  val2: bn(receipt.rc),
@@ -39237,7 +39150,7 @@ Thrown error: ${e}`
39237
39150
  case "LOG_DATA" /* LogData */: {
39238
39151
  const logDataReceipt = {
39239
39152
  type: ReceiptType.LogData,
39240
- id: hexOrZero(receipt.id || receipt.contractId),
39153
+ id: hexOrZero(receipt.contract?.id),
39241
39154
  val0: bn(receipt.ra),
39242
39155
  val1: bn(receipt.rb),
39243
39156
  ptr: bn(receipt.ptr),
@@ -39251,8 +39164,8 @@ Thrown error: ${e}`
39251
39164
  case "TRANSFER" /* Transfer */: {
39252
39165
  const transferReceipt = {
39253
39166
  type: ReceiptType.Transfer,
39254
- from: hexOrZero(receipt.id || receipt.contractId),
39255
- to: hexOrZero(receipt.toAddress || receipt?.to),
39167
+ from: hexOrZero(receipt.contract?.id),
39168
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
39256
39169
  amount: bn(receipt.amount),
39257
39170
  assetId: hexOrZero(receipt.assetId),
39258
39171
  pc: bn(receipt.pc),
@@ -39263,8 +39176,8 @@ Thrown error: ${e}`
39263
39176
  case "TRANSFER_OUT" /* TransferOut */: {
39264
39177
  const transferOutReceipt = {
39265
39178
  type: ReceiptType.TransferOut,
39266
- from: hexOrZero(receipt.id || receipt.contractId),
39267
- to: hexOrZero(receipt.toAddress || receipt.to),
39179
+ from: hexOrZero(receipt.contract?.id),
39180
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
39268
39181
  amount: bn(receipt.amount),
39269
39182
  assetId: hexOrZero(receipt.assetId),
39270
39183
  pc: bn(receipt.pc),
@@ -39307,7 +39220,7 @@ Thrown error: ${e}`
39307
39220
  return receiptMessageOut;
39308
39221
  }
39309
39222
  case "MINT" /* Mint */: {
39310
- const contractId = hexOrZero(receipt.id || receipt.contractId);
39223
+ const contractId = hexOrZero(receipt.contract?.id);
39311
39224
  const subId = hexOrZero(receipt.subId);
39312
39225
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
39313
39226
  const mintReceipt = {
@@ -39322,7 +39235,7 @@ Thrown error: ${e}`
39322
39235
  return mintReceipt;
39323
39236
  }
39324
39237
  case "BURN" /* Burn */: {
39325
- const contractId = hexOrZero(receipt.id || receipt.contractId);
39238
+ const contractId = hexOrZero(receipt.contract?.id);
39326
39239
  const subId = hexOrZero(receipt.subId);
39327
39240
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
39328
39241
  const burnReceipt = {
@@ -39403,6 +39316,7 @@ Thrown error: ${e}`
39403
39316
  };
39404
39317
 
39405
39318
  // src/providers/utils/gas.ts
39319
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
39406
39320
  var getGasUsedFromReceipts = (receipts) => {
39407
39321
  const scriptResult = receipts.filter(
39408
39322
  (receipt) => receipt.type === ReceiptType.ScriptResult
@@ -39423,28 +39337,18 @@ Thrown error: ${e}`
39423
39337
  }
39424
39338
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
39425
39339
  const witnessCache = [];
39426
- const chargeableInputs = inputs.filter((input) => {
39427
- const isCoinOrMessage = "owner" in input || "sender" in input;
39428
- if (isCoinOrMessage) {
39429
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39430
- return true;
39431
- }
39432
- if (!witnessCache.includes(input.witnessIndex)) {
39433
- witnessCache.push(input.witnessIndex);
39434
- return true;
39435
- }
39436
- }
39437
- return false;
39438
- });
39439
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
39440
- const totalGas = chargeableInputs.reduce((total, input) => {
39340
+ const totalGas = inputs.reduce((total, input) => {
39441
39341
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39442
39342
  return total.add(
39443
- vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39343
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39444
39344
  );
39445
39345
  }
39446
- return total.add(gasCosts.ecr1);
39447
- }, bn(0));
39346
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
39347
+ witnessCache.push(input.witnessIndex);
39348
+ return total.add(gasCosts.ecr1);
39349
+ }
39350
+ return total;
39351
+ }, bn());
39448
39352
  return totalGas;
39449
39353
  }
39450
39354
  function getMinGas(params) {
@@ -39456,20 +39360,12 @@ Thrown error: ${e}`
39456
39360
  return minGas;
39457
39361
  }
39458
39362
  function getMaxGas(params) {
39459
- const {
39460
- gasPerByte,
39461
- witnessesLength,
39462
- witnessLimit,
39463
- minGas,
39464
- gasLimit = bn(0),
39465
- maxGasPerTx
39466
- } = params;
39363
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
39467
39364
  let remainingAllowedWitnessGas = bn(0);
39468
39365
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
39469
39366
  remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
39470
39367
  }
39471
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39472
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
39368
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39473
39369
  }
39474
39370
  function calculateMetadataGasForTxCreate({
39475
39371
  gasCosts,
@@ -39491,10 +39387,6 @@ Thrown error: ${e}`
39491
39387
  }) {
39492
39388
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
39493
39389
  }
39494
- var calculateGasFee = (params) => {
39495
- const { gas, gasPrice, priceFactor, tip } = params;
39496
- return gas.mul(gasPrice).div(priceFactor).add(tip);
39497
- };
39498
39390
 
39499
39391
  // src/providers/utils/json.ts
39500
39392
  function normalize2(object) {
@@ -39636,7 +39528,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39636
39528
  // src/providers/transaction-request/transaction-request.ts
39637
39529
  var BaseTransactionRequest = class {
39638
39530
  /** Gas price for transaction */
39639
- tip;
39531
+ gasPrice;
39640
39532
  /** Block until which tx cannot be included */
39641
39533
  maturity;
39642
39534
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -39655,7 +39547,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39655
39547
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
39656
39548
  */
39657
39549
  constructor({
39658
- tip,
39550
+ gasPrice,
39659
39551
  maturity,
39660
39552
  maxFee,
39661
39553
  witnessLimit,
@@ -39663,7 +39555,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39663
39555
  outputs,
39664
39556
  witnesses
39665
39557
  } = {}) {
39666
- this.tip = bn(tip);
39558
+ this.gasPrice = bn(gasPrice);
39667
39559
  this.maturity = maturity ?? 0;
39668
39560
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
39669
39561
  this.maxFee = maxFee ? bn(maxFee) : void 0;
@@ -39674,9 +39566,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39674
39566
  static getPolicyMeta(req) {
39675
39567
  let policyTypes = 0;
39676
39568
  const policies = [];
39677
- if (req.tip) {
39678
- policyTypes += PolicyType.Tip;
39679
- policies.push({ data: req.tip, type: PolicyType.Tip });
39569
+ if (req.gasPrice) {
39570
+ policyTypes += PolicyType.GasPrice;
39571
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
39680
39572
  }
39681
39573
  if (req.witnessLimit) {
39682
39574
  policyTypes += PolicyType.WitnessLimit;
@@ -39864,9 +39756,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39864
39756
  * @param predicateData - Predicate data bytes.
39865
39757
  */
39866
39758
  addCoinInput(coin) {
39867
- const { assetId, owner, amount } = coin;
39759
+ const { assetId, owner, amount, id, predicate } = coin;
39868
39760
  let witnessIndex;
39869
- if (coin.predicate) {
39761
+ if (predicate) {
39870
39762
  witnessIndex = 0;
39871
39763
  } else {
39872
39764
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -39875,13 +39767,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39875
39767
  }
39876
39768
  }
39877
39769
  const input = {
39878
- ...coin,
39770
+ id,
39879
39771
  type: InputType.Coin,
39880
39772
  owner: owner.toB256(),
39881
39773
  amount,
39882
39774
  assetId,
39883
39775
  txPointer: "0x00000000000000000000000000000000",
39884
- witnessIndex
39776
+ witnessIndex,
39777
+ predicate
39885
39778
  };
39886
39779
  this.pushInput(input);
39887
39780
  this.addChangeOutput(owner, assetId);
@@ -39895,10 +39788,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39895
39788
  * @param predicateData - Predicate data bytes.
39896
39789
  */
39897
39790
  addMessageInput(message) {
39898
- const { recipient, sender, amount } = message;
39791
+ const { recipient, sender, amount, predicate, nonce } = message;
39899
39792
  const assetId = BaseAssetId;
39900
39793
  let witnessIndex;
39901
- if (message.predicate) {
39794
+ if (predicate) {
39902
39795
  witnessIndex = 0;
39903
39796
  } else {
39904
39797
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -39907,12 +39800,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39907
39800
  }
39908
39801
  }
39909
39802
  const input = {
39910
- ...message,
39803
+ nonce,
39911
39804
  type: InputType.Message,
39912
39805
  sender: sender.toB256(),
39913
39806
  recipient: recipient.toB256(),
39914
39807
  amount,
39915
- witnessIndex
39808
+ witnessIndex,
39809
+ predicate
39916
39810
  };
39917
39811
  this.pushInput(input);
39918
39812
  this.addChangeOutput(recipient, assetId);
@@ -40022,7 +39916,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40022
39916
  }
40023
39917
  calculateMaxGas(chainInfo, minGas) {
40024
39918
  const { consensusParameters } = chainInfo;
40025
- const { gasPerByte, maxGasPerTx } = consensusParameters;
39919
+ const { gasPerByte } = consensusParameters;
40026
39920
  const witnessesLength = this.toTransaction().witnesses.reduce(
40027
39921
  (acc, wit) => acc + wit.dataLength,
40028
39922
  0
@@ -40031,8 +39925,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40031
39925
  gasPerByte,
40032
39926
  minGas,
40033
39927
  witnessesLength,
40034
- witnessLimit: this.witnessLimit,
40035
- maxGasPerTx
39928
+ witnessLimit: this.witnessLimit
40036
39929
  });
40037
39930
  }
40038
39931
  /**
@@ -40050,20 +39943,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40050
39943
  });
40051
39944
  const updateAssetInput = (assetId, quantity) => {
40052
39945
  const assetInput = findAssetInput(assetId);
40053
- let usedQuantity = quantity;
40054
- if (assetId === BaseAssetId) {
40055
- usedQuantity = bn("1000000000000000000");
40056
- }
40057
39946
  if (assetInput && "assetId" in assetInput) {
40058
- assetInput.id = hexlify(randomBytes3(34));
40059
- assetInput.amount = usedQuantity;
39947
+ assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
39948
+ assetInput.amount = quantity;
40060
39949
  } else {
40061
39950
  this.addResources([
40062
39951
  {
40063
- id: hexlify(randomBytes3(34)),
40064
- amount: usedQuantity,
39952
+ id: hexlify(randomBytes22(UTXO_ID_LEN)),
39953
+ amount: quantity,
40065
39954
  assetId,
40066
39955
  owner: resourcesOwner || Address.fromRandom(),
39956
+ maturity: 0,
40067
39957
  blockCreated: bn(1),
40068
39958
  txCreatedIdx: bn(1)
40069
39959
  }
@@ -40095,7 +39985,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40095
39985
  toJSON() {
40096
39986
  return normalizeJSON(this);
40097
39987
  }
40098
- updatePredicateGasUsed(inputs) {
39988
+ updatePredicateInputs(inputs) {
40099
39989
  this.inputs.forEach((i) => {
40100
39990
  let correspondingInput;
40101
39991
  switch (i.type) {
@@ -40117,15 +40007,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40117
40007
  }
40118
40008
  });
40119
40009
  }
40120
- shiftPredicateData() {
40121
- this.inputs.forEach((input) => {
40122
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
40123
- input.predicateData = input.paddPredicateData(
40124
- BaseTransactionRequest.getPolicyMeta(this).policies.length
40125
- );
40126
- }
40127
- });
40128
- }
40129
40010
  };
40130
40011
 
40131
40012
  // src/providers/transaction-request/hash-transaction.ts
@@ -40259,8 +40140,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40259
40140
  return {
40260
40141
  type: TransactionType.Create,
40261
40142
  ...baseTransaction,
40143
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
40262
40144
  bytecodeWitnessIndex,
40263
- storageSlotsCount: bn(storageSlots.length),
40145
+ storageSlotsCount: storageSlots.length,
40264
40146
  salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
40265
40147
  storageSlots
40266
40148
  };
@@ -40374,8 +40256,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40374
40256
  type: TransactionType.Script,
40375
40257
  scriptGasLimit: this.gasLimit,
40376
40258
  ...super.getBaseTransaction(),
40377
- scriptLength: bn(script.length),
40378
- scriptDataLength: bn(scriptData.length),
40259
+ scriptLength: script.length,
40260
+ scriptDataLength: scriptData.length,
40379
40261
  receiptsRoot: ZeroBytes32,
40380
40262
  script: hexlify(script),
40381
40263
  scriptData: hexlify(scriptData)
@@ -40439,7 +40321,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40439
40321
  }
40440
40322
  calculateMaxGas(chainInfo, minGas) {
40441
40323
  const { consensusParameters } = chainInfo;
40442
- const { gasPerByte, maxGasPerTx } = consensusParameters;
40324
+ const { gasPerByte } = consensusParameters;
40443
40325
  const witnessesLength = this.toTransaction().witnesses.reduce(
40444
40326
  (acc, wit) => acc + wit.dataLength,
40445
40327
  0
@@ -40449,8 +40331,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40449
40331
  minGas,
40450
40332
  witnessesLength,
40451
40333
  witnessLimit: this.witnessLimit,
40452
- gasLimit: this.gasLimit,
40453
- maxGasPerTx
40334
+ gasLimit: this.gasLimit
40454
40335
  });
40455
40336
  }
40456
40337
  /**
@@ -40523,29 +40404,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40523
40404
  }
40524
40405
  }
40525
40406
  };
40526
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
40527
- (acc, input) => {
40528
- if (input.type === InputType.Coin && input.owner === owner) {
40529
- acc.utxos.push(input.id);
40530
- }
40531
- if (input.type === InputType.Message && input.recipient === owner) {
40532
- acc.messages.push(input.nonce);
40533
- }
40534
- return acc;
40535
- },
40536
- {
40537
- utxos: [],
40538
- messages: []
40539
- }
40540
- );
40541
40407
 
40542
40408
  // src/providers/transaction-summary/calculate-transaction-fee.ts
40543
40409
  var calculateTransactionFee = (params) => {
40544
40410
  const {
40545
- gasPrice,
40411
+ gasUsed,
40546
40412
  rawPayload,
40547
- tip,
40548
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
40413
+ consensusParameters: { gasCosts, feeParams }
40549
40414
  } = params;
40550
40415
  const gasPerByte = bn(feeParams.gasPerByte);
40551
40416
  const gasPriceFactor = bn(feeParams.gasPriceFactor);
@@ -40555,7 +40420,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40555
40420
  return {
40556
40421
  fee: bn(0),
40557
40422
  minFee: bn(0),
40558
- maxFee: bn(0)
40423
+ maxFee: bn(0),
40424
+ feeFromGasUsed: bn(0)
40559
40425
  };
40560
40426
  }
40561
40427
  const { type: type3, witnesses, inputs, policies } = transaction;
@@ -40587,6 +40453,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40587
40453
  metadataGas,
40588
40454
  txBytesSize: transactionBytes.length
40589
40455
  });
40456
+ const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
40590
40457
  const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
40591
40458
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
40592
40459
  const maxGas = getMaxGas({
@@ -40594,25 +40461,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40594
40461
  minGas,
40595
40462
  witnessesLength,
40596
40463
  gasLimit,
40597
- witnessLimit,
40598
- maxGasPerTx
40599
- });
40600
- const minFee = calculateGasFee({
40601
- gasPrice,
40602
- gas: minGas,
40603
- priceFactor: gasPriceFactor,
40604
- tip
40605
- });
40606
- const maxFee = calculateGasFee({
40607
- gasPrice,
40608
- gas: maxGas,
40609
- priceFactor: gasPriceFactor,
40610
- tip
40464
+ witnessLimit
40611
40465
  });
40466
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
40467
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
40468
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
40469
+ const fee = minFee.add(feeFromGasUsed);
40612
40470
  return {
40471
+ fee,
40613
40472
  minFee,
40614
40473
  maxFee,
40615
- fee: maxFee
40474
+ feeFromGasUsed
40616
40475
  };
40617
40476
  };
40618
40477
 
@@ -41213,9 +41072,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41213
41072
  gqlTransactionStatus,
41214
41073
  abiMap = {},
41215
41074
  maxInputs,
41216
- gasCosts,
41217
- maxGasPerTx,
41218
- gasPrice
41075
+ gasCosts
41219
41076
  } = params;
41220
41077
  const gasUsed = getGasUsedFromReceipts(receipts);
41221
41078
  const rawPayload = hexlify(transactionBytes);
@@ -41229,14 +41086,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41229
41086
  maxInputs
41230
41087
  });
41231
41088
  const typeName = getTransactionTypeName(transaction.type);
41232
- const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
41233
41089
  const { fee } = calculateTransactionFee({
41234
- gasPrice,
41090
+ gasUsed,
41235
41091
  rawPayload,
41236
- tip,
41237
41092
  consensusParameters: {
41238
41093
  gasCosts,
41239
- maxGasPerTx,
41240
41094
  feeParams: {
41241
41095
  gasPerByte,
41242
41096
  gasPriceFactor
@@ -41372,13 +41226,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41372
41226
  const decodedTransaction = this.decodeTransaction(
41373
41227
  transaction
41374
41228
  );
41375
- let txReceipts = [];
41376
- if (transaction?.status && "receipts" in transaction.status) {
41377
- txReceipts = transaction.status.receipts;
41378
- }
41379
- const receipts = txReceipts.map(processGqlReceipt) || [];
41380
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
41381
- const gasPrice = await this.provider.getLatestGasPrice();
41229
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
41230
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
41382
41231
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
41383
41232
  const transactionSummary = assembleTransactionSummary({
41384
41233
  id: this.id,
@@ -41390,9 +41239,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41390
41239
  gasPriceFactor,
41391
41240
  abiMap: contractsAbiMap,
41392
41241
  maxInputs,
41393
- gasCosts,
41394
- maxGasPerTx,
41395
- gasPrice
41242
+ gasCosts
41396
41243
  });
41397
41244
  return transactionSummary;
41398
41245
  }
@@ -41541,7 +41388,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41541
41388
  gasCosts,
41542
41389
  latestBlock: {
41543
41390
  id: latestBlock.id,
41544
- height: bn(latestBlock.height),
41391
+ height: bn(latestBlock.header.height),
41545
41392
  time: latestBlock.header.time,
41546
41393
  transactions: latestBlock.transactions.map((i) => ({
41547
41394
  id: i.id
@@ -41635,8 +41482,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41635
41482
  * Returns some helpful parameters related to gas fees.
41636
41483
  */
41637
41484
  getGasConfig() {
41485
+ const { minGasPrice } = this.getNode();
41638
41486
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
41639
41487
  return {
41488
+ minGasPrice,
41640
41489
  maxGasPerTx,
41641
41490
  maxGasPerPredicate,
41642
41491
  gasPriceFactor,
@@ -41734,7 +41583,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41734
41583
  */
41735
41584
  async getBlockNumber() {
41736
41585
  const { chain } = await this.operations.getChain();
41737
- return bn(chain.latestBlock.height, 10);
41586
+ return bn(chain.latestBlock.header.height, 10);
41738
41587
  }
41739
41588
  /**
41740
41589
  * Returns the chain information.
@@ -41746,9 +41595,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41746
41595
  const processedNodeInfo = {
41747
41596
  maxDepth: bn(nodeInfo.maxDepth),
41748
41597
  maxTx: bn(nodeInfo.maxTx),
41598
+ minGasPrice: bn(nodeInfo.minGasPrice),
41749
41599
  nodeVersion: nodeInfo.nodeVersion,
41750
41600
  utxoValidation: nodeInfo.utxoValidation,
41751
- vmBacktrace: nodeInfo.vmBacktrace
41601
+ vmBacktrace: nodeInfo.vmBacktrace,
41602
+ peers: nodeInfo.peers
41752
41603
  };
41753
41604
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
41754
41605
  return processedNodeInfo;
@@ -41834,13 +41685,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41834
41685
  return this.estimateTxDependencies(transactionRequest);
41835
41686
  }
41836
41687
  const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41837
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
41838
- encodedTransactions: encodedTransaction,
41688
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
41689
+ encodedTransaction,
41839
41690
  utxoValidation: utxoValidation || false
41840
41691
  });
41841
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
41842
- const receipts = rawReceipts.map(processGqlReceipt);
41843
- return { receipts, dryrunStatus: status };
41692
+ const receipts = gqlReceipts.map(processGqlReceipt);
41693
+ return {
41694
+ receipts
41695
+ };
41844
41696
  }
41845
41697
  /**
41846
41698
  * Verifies whether enough gas is available to complete transaction.
@@ -41879,6 +41731,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41879
41731
  * If there are missing variable outputs,
41880
41732
  * `addVariableOutputs` is called on the transaction.
41881
41733
  *
41734
+ * @privateRemarks
41735
+ * TODO: Investigate support for missing contract IDs
41736
+ * TODO: Add support for missing output messages
41882
41737
  *
41883
41738
  * @param transactionRequest - The transaction request object.
41884
41739
  * @returns A promise.
@@ -41891,19 +41746,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41891
41746
  missingContractIds: []
41892
41747
  };
41893
41748
  }
41749
+ await this.estimatePredicates(transactionRequest);
41894
41750
  let receipts = [];
41895
41751
  const missingContractIds = [];
41896
41752
  let outputVariables = 0;
41897
- let dryrunStatus;
41898
41753
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
41899
- const {
41900
- dryRun: [{ receipts: rawReceipts, status }]
41901
- } = await this.operations.dryRun({
41902
- encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
41754
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
41755
+ encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
41903
41756
  utxoValidation: false
41904
41757
  });
41905
- receipts = rawReceipts.map(processGqlReceipt);
41906
- dryrunStatus = status;
41758
+ receipts = gqlReceipts.map(processGqlReceipt);
41907
41759
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
41908
41760
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
41909
41761
  if (hasMissingOutputs) {
@@ -41913,11 +41765,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41913
41765
  transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
41914
41766
  missingContractIds.push(contractId);
41915
41767
  });
41916
- const { maxFee } = await this.estimateTxGasAndFee({
41917
- transactionRequest,
41918
- optimizeGas: false
41919
- });
41920
- transactionRequest.maxFee = maxFee;
41921
41768
  } else {
41922
41769
  break;
41923
41770
  }
@@ -41925,133 +41772,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41925
41772
  return {
41926
41773
  receipts,
41927
41774
  outputVariables,
41928
- missingContractIds,
41929
- dryrunStatus
41775
+ missingContractIds
41930
41776
  };
41931
41777
  }
41932
41778
  /**
41933
- * Dry runs multiple transactions and checks for missing dependencies in batches.
41934
- *
41935
- * Transactions are dry run in batches. After each dry run, transactions requiring
41936
- * further modifications are identified. The method iteratively updates these transactions
41937
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
41938
- *
41939
- * @param transactionRequests - Array of transaction request objects.
41940
- * @returns A promise that resolves to an array of results for each transaction.
41941
- */
41942
- async estimateMultipleTxDependencies(transactionRequests) {
41943
- const results = transactionRequests.map(() => ({
41944
- receipts: [],
41945
- outputVariables: 0,
41946
- missingContractIds: [],
41947
- dryrunStatus: void 0
41948
- }));
41949
- const allRequests = clone_default(transactionRequests);
41950
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
41951
- allRequests.forEach((req, index) => {
41952
- if (req.type === TransactionType.Script) {
41953
- serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
41954
- }
41955
- });
41956
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
41957
- let attempt = 0;
41958
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
41959
- const encodedTransactions = transactionsToProcess.map(
41960
- (index) => serializedTransactionsMap.get(index)
41961
- );
41962
- const dryRunResults = await this.operations.dryRun({
41963
- encodedTransactions,
41964
- utxoValidation: false
41965
- });
41966
- const nextRoundTransactions = [];
41967
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
41968
- const currentResultIndex = transactionsToProcess[i];
41969
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
41970
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
41971
- results[currentResultIndex].dryrunStatus = status;
41972
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
41973
- results[currentResultIndex].receipts
41974
- );
41975
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
41976
- const requestToProcess = allRequests[currentResultIndex];
41977
- if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
41978
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
41979
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
41980
- missingOutputContractIds.forEach(({ contractId }) => {
41981
- requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
41982
- results[currentResultIndex].missingContractIds.push(contractId);
41983
- });
41984
- const { maxFee } = await this.estimateTxGasAndFee({
41985
- transactionRequest: requestToProcess,
41986
- optimizeGas: false
41987
- });
41988
- requestToProcess.maxFee = maxFee;
41989
- serializedTransactionsMap.set(
41990
- currentResultIndex,
41991
- hexlify(requestToProcess.toTransactionBytes())
41992
- );
41993
- nextRoundTransactions.push(currentResultIndex);
41994
- allRequests[currentResultIndex] = requestToProcess;
41995
- }
41996
- }
41997
- transactionsToProcess = nextRoundTransactions;
41998
- attempt += 1;
41999
- }
42000
- return results;
42001
- }
42002
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
42003
- if (estimateTxDependencies) {
42004
- return this.estimateMultipleTxDependencies(transactionRequests);
42005
- }
42006
- const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
42007
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42008
- encodedTransactions,
42009
- utxoValidation: utxoValidation || false
42010
- });
42011
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
42012
- const receipts = rawReceipts.map(processGqlReceipt);
42013
- return { receipts, dryrunStatus: status };
42014
- });
42015
- return results;
42016
- }
42017
- async estimateTxGasAndFee(params) {
42018
- const { transactionRequest, optimizeGas = true } = params;
42019
- let { gasPrice } = params;
41779
+ * Estimates the transaction gas and fee based on the provided transaction request.
41780
+ * @param transactionRequest - The transaction request object.
41781
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41782
+ */
41783
+ estimateTxGasAndFee(params) {
41784
+ const { transactionRequest } = params;
41785
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
42020
41786
  const chainInfo = this.getChain();
42021
- const { gasPriceFactor } = this.getGasConfig();
41787
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41788
+ transactionRequest.gasPrice = gasPrice;
42022
41789
  const minGas = transactionRequest.calculateMinGas(chainInfo);
42023
- if (!gasPrice) {
42024
- gasPrice = await this.estimateGasPrice(10);
42025
- }
42026
- const minFee = calculateGasFee({
42027
- gasPrice: bn(gasPrice),
42028
- gas: minGas,
42029
- priceFactor: gasPriceFactor,
42030
- tip: transactionRequest.tip
42031
- }).add(1);
42032
- let gasLimit = bn(0);
41790
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42033
41791
  if (transactionRequest.type === TransactionType.Script) {
42034
- gasLimit = transactionRequest.gasLimit;
42035
- if (!optimizeGas) {
41792
+ if (transactionRequest.gasLimit.eq(0)) {
42036
41793
  transactionRequest.gasLimit = minGas;
42037
- gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
42038
- transactionRequest.gasLimit = gasLimit;
41794
+ transactionRequest.gasLimit = maxGasPerTx.sub(
41795
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
41796
+ );
42039
41797
  }
42040
41798
  }
42041
41799
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
42042
- const maxFee = calculateGasFee({
42043
- gasPrice: bn(gasPrice),
42044
- gas: maxGas,
42045
- priceFactor: gasPriceFactor,
42046
- tip: transactionRequest.tip
42047
- }).add(1);
41800
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42048
41801
  return {
42049
41802
  minGas,
42050
41803
  minFee,
42051
41804
  maxGas,
42052
- maxFee,
42053
- gasPrice,
42054
- gasLimit
41805
+ maxFee
42055
41806
  };
42056
41807
  }
42057
41808
  /**
@@ -42069,17 +41820,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42069
41820
  if (estimateTxDependencies) {
42070
41821
  return this.estimateTxDependencies(transactionRequest);
42071
41822
  }
42072
- const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
42073
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42074
- encodedTransactions,
41823
+ const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41824
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
41825
+ encodedTransaction,
42075
41826
  utxoValidation: true
42076
41827
  });
42077
- const callResult = dryRunStatuses.map((dryRunStatus) => {
42078
- const { id, receipts, status } = dryRunStatus;
42079
- const processedReceipts = receipts.map(processGqlReceipt);
42080
- return { id, receipts: processedReceipts, status };
42081
- });
42082
- return { receipts: callResult[0].receipts };
41828
+ const receipts = gqlReceipts.map(processGqlReceipt);
41829
+ return {
41830
+ receipts
41831
+ };
42083
41832
  }
42084
41833
  /**
42085
41834
  * Returns a transaction cost to enable user
@@ -42096,80 +41845,77 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42096
41845
  * @param tolerance - The tolerance to add on top of the gasUsed.
42097
41846
  * @returns A promise that resolves to the transaction cost object.
42098
41847
  */
42099
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
41848
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
41849
+ estimateTxDependencies = true,
41850
+ estimatePredicates = true,
41851
+ resourcesOwner,
41852
+ signatureCallback
41853
+ } = {}) {
42100
41854
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41855
+ const { minGasPrice } = this.getGasConfig();
41856
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
42101
41857
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
42102
41858
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
42103
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
41859
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
42104
41860
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
42105
- txRequestClone.maxFee = bn(0);
42106
41861
  if (isScriptTransaction) {
42107
41862
  txRequestClone.gasLimit = bn(0);
42108
41863
  }
42109
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
42110
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
41864
+ if (estimatePredicates) {
41865
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41866
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
41867
+ }
41868
+ await this.estimatePredicates(txRequestClone);
42111
41869
  }
42112
- const signedRequest = clone_default(txRequestClone);
42113
- let addedSignatures = 0;
42114
41870
  if (signatureCallback && isScriptTransaction) {
42115
- const lengthBefore = signedRequest.witnesses.length;
42116
- await signatureCallback(signedRequest);
42117
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
42118
- }
42119
- await this.estimatePredicates(signedRequest);
42120
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
42121
- transactionRequest: signedRequest,
42122
- optimizeGas: false
41871
+ await signatureCallback(txRequestClone);
41872
+ }
41873
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41874
+ transactionRequest: txRequestClone
42123
41875
  });
42124
- txRequestClone.maxFee = maxFee;
42125
41876
  let receipts = [];
42126
41877
  let missingContractIds = [];
42127
41878
  let outputVariables = 0;
42128
41879
  let gasUsed = bn(0);
42129
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
42130
- if (isScriptTransaction) {
42131
- if (signatureCallback) {
42132
- await signatureCallback(txRequestClone);
42133
- }
42134
- txRequestClone.gasLimit = gasLimit;
41880
+ if (isScriptTransaction && estimateTxDependencies) {
41881
+ txRequestClone.gasPrice = bn(0);
42135
41882
  const result = await this.estimateTxDependencies(txRequestClone);
42136
41883
  receipts = result.receipts;
42137
41884
  outputVariables = result.outputVariables;
42138
41885
  missingContractIds = result.missingContractIds;
42139
- gasUsed = getGasUsedFromReceipts(receipts);
41886
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
42140
41887
  txRequestClone.gasLimit = gasUsed;
42141
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
42142
- transactionRequest: txRequestClone,
42143
- gasPrice
41888
+ txRequestClone.gasPrice = setGasPrice;
41889
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41890
+ transactionRequest: txRequestClone
42144
41891
  }));
42145
41892
  }
42146
41893
  return {
42147
41894
  requiredQuantities: allQuantities,
42148
41895
  receipts,
42149
41896
  gasUsed,
42150
- gasPrice,
41897
+ minGasPrice,
41898
+ gasPrice: setGasPrice,
42151
41899
  minGas,
42152
41900
  maxGas,
42153
41901
  minFee,
42154
41902
  maxFee,
41903
+ estimatedInputs: txRequestClone.inputs,
42155
41904
  outputVariables,
42156
- missingContractIds,
42157
- addedSignatures,
42158
- estimatedPredicates: txRequestClone.inputs
41905
+ missingContractIds
42159
41906
  };
42160
41907
  }
42161
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
41908
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
42162
41909
  const ownerAddress = Address.fromAddressOrString(owner);
42163
41910
  const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
42164
- const transactionCost = await this.getTransactionCost(transactionRequest, {
42165
- quantitiesToContract
42166
- });
41911
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
42167
41912
  transactionRequest.addResources(
42168
41913
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
42169
41914
  );
42170
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
42171
- quantitiesToContract
42172
- });
41915
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
41916
+ transactionRequest,
41917
+ forwardingQuantities
41918
+ );
42173
41919
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
42174
41920
  return {
42175
41921
  resources,
@@ -42193,6 +41939,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42193
41939
  assetId: coin.assetId,
42194
41940
  amount: bn(coin.amount),
42195
41941
  owner: Address.fromAddressOrString(coin.owner),
41942
+ maturity: bn(coin.maturity).toNumber(),
42196
41943
  blockCreated: bn(coin.blockCreated),
42197
41944
  txCreatedIdx: bn(coin.txCreatedIdx)
42198
41945
  }));
@@ -42244,6 +41991,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42244
41991
  amount: bn(coin.amount),
42245
41992
  assetId: coin.assetId,
42246
41993
  owner: Address.fromAddressOrString(coin.owner),
41994
+ maturity: bn(coin.maturity).toNumber(),
42247
41995
  blockCreated: bn(coin.blockCreated),
42248
41996
  txCreatedIdx: bn(coin.txCreatedIdx)
42249
41997
  };
@@ -42276,7 +42024,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42276
42024
  }
42277
42025
  return {
42278
42026
  id: block2.id,
42279
- height: bn(block2.height),
42027
+ height: bn(block2.header.height),
42280
42028
  time: block2.header.time,
42281
42029
  transactionIds: block2.transactions.map((tx) => tx.id)
42282
42030
  };
@@ -42291,7 +42039,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42291
42039
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
42292
42040
  const blocks = fetchedData.edges.map(({ node: block2 }) => ({
42293
42041
  id: block2.id,
42294
- height: bn(block2.height),
42042
+ height: bn(block2.header.height),
42295
42043
  time: block2.header.time,
42296
42044
  transactionIds: block2.transactions.map((tx) => tx.id)
42297
42045
  }));
@@ -42318,7 +42066,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42318
42066
  }
42319
42067
  return {
42320
42068
  id: block2.id,
42321
- height: bn(block2.height, 10),
42069
+ height: bn(block2.header.height, 10),
42322
42070
  time: block2.header.time,
42323
42071
  transactionIds: block2.transactions.map((tx) => tx.id),
42324
42072
  transactions: block2.transactions.map(
@@ -42498,11 +42246,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42498
42246
  prevRoot: messageBlockHeader.prevRoot,
42499
42247
  time: messageBlockHeader.time,
42500
42248
  applicationHash: messageBlockHeader.applicationHash,
42501
- messageReceiptCount: bn(messageBlockHeader.messageReceiptCount),
42502
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
42503
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
42504
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
42505
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
42249
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
42250
+ messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
42506
42251
  },
42507
42252
  commitBlockHeader: {
42508
42253
  id: commitBlockHeader.id,
@@ -42513,11 +42258,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42513
42258
  prevRoot: commitBlockHeader.prevRoot,
42514
42259
  time: commitBlockHeader.time,
42515
42260
  applicationHash: commitBlockHeader.applicationHash,
42516
- messageReceiptCount: bn(commitBlockHeader.messageReceiptCount),
42517
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
42518
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
42519
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
42520
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
42261
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
42262
+ messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
42521
42263
  },
42522
42264
  sender: Address.fromAddressOrString(sender),
42523
42265
  recipient: Address.fromAddressOrString(recipient),
@@ -42526,16 +42268,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42526
42268
  data
42527
42269
  };
42528
42270
  }
42529
- async getLatestGasPrice() {
42530
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
42531
- return bn(latestGasPrice.gasPrice);
42532
- }
42533
- async estimateGasPrice(blockHorizon) {
42534
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
42535
- blockHorizon: String(blockHorizon)
42536
- });
42537
- return bn(estimateGasPrice.gasPrice);
42538
- }
42539
42271
  /**
42540
42272
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
42541
42273
  *
@@ -42596,15 +42328,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42596
42328
  arrayify(gqlTransaction.rawPayload),
42597
42329
  0
42598
42330
  );
42599
- let txReceipts = [];
42600
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42601
- txReceipts = gqlTransaction.status.receipts;
42602
- }
42603
- const receipts = txReceipts.map(processGqlReceipt);
42331
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
42604
42332
  const {
42605
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42333
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42606
42334
  } = provider.getChain();
42607
- const gasPrice = await provider.getLatestGasPrice();
42608
42335
  const transactionInfo = assembleTransactionSummary({
42609
42336
  id: gqlTransaction.id,
42610
42337
  receipts,
@@ -42615,9 +42342,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42615
42342
  gasPriceFactor: bn(gasPriceFactor),
42616
42343
  abiMap,
42617
42344
  maxInputs,
42618
- gasCosts,
42619
- maxGasPerTx,
42620
- gasPrice
42345
+ gasCosts
42621
42346
  });
42622
42347
  return {
42623
42348
  gqlTransaction,
@@ -42627,11 +42352,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42627
42352
  async function getTransactionSummaryFromRequest(params) {
42628
42353
  const { provider, transactionRequest, abiMap } = params;
42629
42354
  const { receipts } = await provider.call(transactionRequest);
42630
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
42355
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
42631
42356
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
42632
42357
  const transaction = transactionRequest.toTransaction();
42633
42358
  const transactionBytes = transactionRequest.toTransactionBytes();
42634
- const gasPrice = await provider.getLatestGasPrice();
42635
42359
  const transactionSummary = assembleTransactionSummary({
42636
42360
  receipts,
42637
42361
  transaction,
@@ -42640,9 +42364,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42640
42364
  gasPerByte,
42641
42365
  gasPriceFactor,
42642
42366
  maxInputs,
42643
- gasCosts,
42644
- maxGasPerTx,
42645
- gasPrice
42367
+ gasCosts
42646
42368
  });
42647
42369
  return transactionSummary;
42648
42370
  }
@@ -42651,18 +42373,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42651
42373
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
42652
42374
  const { edges, pageInfo } = transactionsByOwner;
42653
42375
  const {
42654
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42376
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42655
42377
  } = provider.getChain();
42656
- const gasPrice = await provider.getLatestGasPrice();
42657
42378
  const transactions = edges.map((edge) => {
42658
42379
  const { node: gqlTransaction } = edge;
42659
- const { id, rawPayload, status } = gqlTransaction;
42380
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
42660
42381
  const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
42661
- let txReceipts = [];
42662
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42663
- txReceipts = gqlTransaction.status.receipts;
42664
- }
42665
- const receipts = txReceipts.map(processGqlReceipt);
42382
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
42666
42383
  const transactionSummary = assembleTransactionSummary({
42667
42384
  id,
42668
42385
  receipts,
@@ -42673,9 +42390,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42673
42390
  gasPerByte,
42674
42391
  gasPriceFactor,
42675
42392
  maxInputs,
42676
- gasCosts,
42677
- maxGasPerTx,
42678
- gasPrice
42393
+ gasCosts
42679
42394
  });
42680
42395
  const output3 = {
42681
42396
  gqlTransaction,
@@ -43004,33 +42719,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43004
42719
  * @param fee - The estimated transaction fee.
43005
42720
  * @returns A promise that resolves when the resources are added to the transaction.
43006
42721
  */
43007
- async fund(request, params) {
43008
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
43009
- const txRequest = request;
43010
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
42722
+ async fund(request, coinQuantities, fee) {
42723
+ const updatedQuantities = addAmountToAsset({
43011
42724
  amount: bn(fee),
43012
42725
  assetId: BaseAssetId,
43013
- coinQuantities: requiredQuantities
42726
+ coinQuantities
43014
42727
  });
43015
42728
  const quantitiesDict = {};
43016
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
42729
+ updatedQuantities.forEach(({ amount, assetId }) => {
43017
42730
  quantitiesDict[assetId] = {
43018
42731
  required: amount,
43019
42732
  owned: bn(0)
43020
42733
  };
43021
42734
  });
43022
- txRequest.inputs.forEach((input) => {
42735
+ const cachedUtxos = [];
42736
+ const cachedMessages = [];
42737
+ const owner = this.address.toB256();
42738
+ request.inputs.forEach((input) => {
43023
42739
  const isResource = "amount" in input;
43024
42740
  if (isResource) {
43025
42741
  const isCoin2 = "owner" in input;
43026
42742
  if (isCoin2) {
43027
42743
  const assetId = String(input.assetId);
43028
- if (quantitiesDict[assetId]) {
42744
+ if (input.owner === owner && quantitiesDict[assetId]) {
43029
42745
  const amount = bn(input.amount);
43030
42746
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42747
+ cachedUtxos.push(input.id);
43031
42748
  }
43032
- } else if (input.amount && quantitiesDict[BaseAssetId]) {
42749
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
43033
42750
  quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42751
+ cachedMessages.push(input.nonce);
43034
42752
  }
43035
42753
  }
43036
42754
  });
@@ -43045,23 +42763,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43045
42763
  });
43046
42764
  const needsToBeFunded = missingQuantities.length;
43047
42765
  if (needsToBeFunded) {
43048
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
43049
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
43050
- txRequest.addResources(resources);
43051
- }
43052
- txRequest.shiftPredicateData();
43053
- txRequest.updatePredicateGasUsed(estimatedPredicates);
43054
- const requestToBeReEstimate = clone_default(txRequest);
43055
- if (addedSignatures) {
43056
- Array.from({ length: addedSignatures }).forEach(
43057
- () => requestToBeReEstimate.addEmptyWitness()
43058
- );
42766
+ const resources = await this.getResourcesToSpend(missingQuantities, {
42767
+ messages: cachedMessages,
42768
+ utxos: cachedUtxos
42769
+ });
42770
+ request.addResources(resources);
43059
42771
  }
43060
- const { maxFee } = await this.provider.estimateTxGasAndFee({
43061
- transactionRequest: requestToBeReEstimate
43062
- });
43063
- txRequest.maxFee = maxFee;
43064
- return txRequest;
43065
42772
  }
43066
42773
  /**
43067
42774
  * A helper that creates a transfer transaction request and returns it.
@@ -43069,25 +42776,28 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43069
42776
  * @param destination - The address of the destination.
43070
42777
  * @param amount - The amount of coins to transfer.
43071
42778
  * @param assetId - The asset ID of the coins to transfer.
43072
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
42779
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
43073
42780
  * @returns A promise that resolves to the prepared transaction request.
43074
42781
  */
43075
42782
  async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
43076
- const request = new ScriptTransactionRequest(txParams);
42783
+ const { minGasPrice } = this.provider.getGasConfig();
42784
+ const params = { gasPrice: minGasPrice, ...txParams };
42785
+ const request = new ScriptTransactionRequest(params);
43077
42786
  request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
43078
- const txCost = await this.provider.getTransactionCost(request, {
42787
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
43079
42788
  estimateTxDependencies: true,
43080
42789
  resourcesOwner: this
43081
42790
  });
43082
- if ("gasLimit" in txParams) {
43083
- this.validateGas({
43084
- gasUsed: txCost.gasUsed,
43085
- gasLimit: request.gasLimit
43086
- });
43087
- }
43088
- request.gasLimit = txCost.gasUsed;
43089
- request.maxFee = txCost.maxFee;
43090
- await this.fund(request, txCost);
42791
+ request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
42792
+ request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
42793
+ this.validateGas({
42794
+ gasUsed,
42795
+ gasPrice: request.gasPrice,
42796
+ gasLimit: request.gasLimit,
42797
+ minGasPrice
42798
+ });
42799
+ await this.fund(request, requiredQuantities, maxFee);
42800
+ request.updatePredicateInputs(estimatedInputs);
43091
42801
  return request;
43092
42802
  }
43093
42803
  /**
@@ -43126,30 +42836,31 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43126
42836
  );
43127
42837
  }
43128
42838
  const contractAddress = Address.fromAddressOrString(contractId);
42839
+ const { minGasPrice } = this.provider.getGasConfig();
42840
+ const params = { gasPrice: minGasPrice, ...txParams };
43129
42841
  const { script, scriptData } = await assembleTransferToContractScript({
43130
42842
  hexlifiedContractId: contractAddress.toB256(),
43131
42843
  amountToTransfer: bn(amount),
43132
42844
  assetId
43133
42845
  });
43134
42846
  const request = new ScriptTransactionRequest({
43135
- ...txParams,
42847
+ ...params,
43136
42848
  script,
43137
42849
  scriptData
43138
42850
  });
43139
42851
  request.addContractInputAndOutput(contractAddress);
43140
- const txCost = await this.provider.getTransactionCost(request, {
43141
- resourcesOwner: this,
43142
- quantitiesToContract: [{ amount: bn(amount), assetId: String(assetId) }]
42852
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42853
+ request,
42854
+ [{ amount: bn(amount), assetId: String(assetId) }]
42855
+ );
42856
+ request.gasLimit = bn(params.gasLimit ?? gasUsed);
42857
+ this.validateGas({
42858
+ gasUsed,
42859
+ gasPrice: request.gasPrice,
42860
+ gasLimit: request.gasLimit,
42861
+ minGasPrice
43143
42862
  });
43144
- if (txParams.gasLimit) {
43145
- this.validateGas({
43146
- gasUsed: txCost.gasUsed,
43147
- gasLimit: request.gasLimit
43148
- });
43149
- }
43150
- request.gasLimit = txCost.gasUsed;
43151
- request.maxFee = txCost.maxFee;
43152
- await this.fund(request, txCost);
42863
+ await this.fund(request, requiredQuantities, maxFee);
43153
42864
  return this.sendTransaction(request);
43154
42865
  }
43155
42866
  /**
@@ -43161,6 +42872,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43161
42872
  * @returns A promise that resolves to the transaction response.
43162
42873
  */
43163
42874
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42875
+ const { minGasPrice } = this.provider.getGasConfig();
43164
42876
  const recipientAddress = Address.fromAddressOrString(recipient);
43165
42877
  const recipientDataArray = arrayify(
43166
42878
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -43173,19 +42885,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43173
42885
  ...recipientDataArray,
43174
42886
  ...amountDataArray
43175
42887
  ]);
43176
- const params = { script, ...txParams };
42888
+ const params = { script, gasPrice: minGasPrice, ...txParams };
43177
42889
  const request = new ScriptTransactionRequest(params);
43178
- const quantitiesToContract = [{ amount: bn(amount), assetId: BaseAssetId }];
43179
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
43180
- if (txParams.gasLimit) {
43181
- this.validateGas({
43182
- gasUsed: txCost.gasUsed,
43183
- gasLimit: request.gasLimit
43184
- });
43185
- }
43186
- request.maxFee = txCost.maxFee;
43187
- request.gasLimit = txCost.gasUsed;
43188
- await this.fund(request, txCost);
42890
+ const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42891
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42892
+ request,
42893
+ forwardingQuantities
42894
+ );
42895
+ request.gasLimit = bn(params.gasLimit ?? gasUsed);
42896
+ this.validateGas({
42897
+ gasUsed,
42898
+ gasPrice: request.gasPrice,
42899
+ gasLimit: request.gasLimit,
42900
+ minGasPrice
42901
+ });
42902
+ await this.fund(request, requiredQuantities, maxFee);
43189
42903
  return this.sendTransaction(request);
43190
42904
  }
43191
42905
  async signMessage(message) {
@@ -43243,7 +42957,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43243
42957
  }
43244
42958
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
43245
42959
  }
43246
- validateGas({ gasUsed, gasLimit }) {
42960
+ validateGas({
42961
+ gasUsed,
42962
+ gasPrice,
42963
+ gasLimit,
42964
+ minGasPrice
42965
+ }) {
42966
+ if (minGasPrice.gt(gasPrice)) {
42967
+ throw new FuelError(
42968
+ ErrorCode.GAS_PRICE_TOO_LOW,
42969
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
42970
+ );
42971
+ }
43247
42972
  if (gasUsed.gt(gasLimit)) {
43248
42973
  throw new FuelError(
43249
42974
  ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -44832,7 +44557,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44832
44557
  * @param transactionRequestLike - The transaction request to send.
44833
44558
  * @returns A promise that resolves to the TransactionResponse object.
44834
44559
  */
44835
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
44560
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
44836
44561
  const transactionRequest = transactionRequestify(transactionRequestLike);
44837
44562
  if (estimateTxDependencies) {
44838
44563
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -48110,8 +47835,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48110
47835
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
48111
47836
  request.inputs?.forEach((input) => {
48112
47837
  if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
48113
- input.predicate = hexlify(this.bytes);
48114
- input.predicateData = hexlify(this.getPredicateData(policies.length));
47838
+ input.predicate = this.bytes;
47839
+ input.predicateData = this.getPredicateData(policies.length);
47840
+ input.witnessIndex = 0;
48115
47841
  }
48116
47842
  });
48117
47843
  return request;
@@ -48126,7 +47852,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48126
47852
  * @returns A promise that resolves to the prepared transaction request.
48127
47853
  */
48128
47854
  async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
48129
- return super.createTransfer(destination, amount, assetId, txParams);
47855
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
47856
+ return this.populateTransactionPredicateData(request);
48130
47857
  }
48131
47858
  /**
48132
47859
  * Sends a transaction with the populated predicate data.
@@ -48134,9 +47861,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48134
47861
  * @param transactionRequestLike - The transaction request-like object.
48135
47862
  * @returns A promise that resolves to the transaction response.
48136
47863
  */
48137
- sendTransaction(transactionRequestLike) {
48138
- const transactionRequest = transactionRequestify(transactionRequestLike);
48139
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
47864
+ sendTransaction(transactionRequestLike, options) {
47865
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47866
+ return super.sendTransaction(transactionRequest, options);
48140
47867
  }
48141
47868
  /**
48142
47869
  * Simulates a transaction with the populated predicate data.
@@ -48145,8 +47872,22 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48145
47872
  * @returns A promise that resolves to the call result.
48146
47873
  */
48147
47874
  simulateTransaction(transactionRequestLike) {
48148
- const transactionRequest = transactionRequestify(transactionRequestLike);
48149
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
47875
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47876
+ return super.simulateTransaction(transactionRequest);
47877
+ }
47878
+ /**
47879
+ * Retrieves resources satisfying the spend query for the account.
47880
+ *
47881
+ * @param quantities - IDs of coins to exclude.
47882
+ * @param excludedIds - IDs of resources to be excluded from the query.
47883
+ * @returns A promise that resolves to an array of Resources.
47884
+ */
47885
+ async getResourcesToSpend(quantities, excludedIds) {
47886
+ const resources = await super.getResourcesToSpend(quantities, excludedIds);
47887
+ return resources.map((resource) => ({
47888
+ ...resource,
47889
+ predicate: hexlify(this.bytes)
47890
+ }));
48150
47891
  }
48151
47892
  getPredicateData(policiesLength) {
48152
47893
  if (!this.predicateData.length) {
@@ -48192,25 +47933,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48192
47933
  predicateInterface: abiInterface
48193
47934
  };
48194
47935
  }
48195
- /**
48196
- * Retrieves resources satisfying the spend query for the account.
48197
- *
48198
- * @param quantities - IDs of coins to exclude.
48199
- * @param excludedIds - IDs of resources to be excluded from the query.
48200
- * @returns A promise that resolves to an array of Resources.
48201
- */
48202
- async getResourcesToSpend(quantities, excludedIds) {
48203
- const resources = await this.provider.getResourcesToSpend(
48204
- this.address,
48205
- quantities,
48206
- excludedIds
48207
- );
48208
- return resources.map((resource) => ({
48209
- ...resource,
48210
- predicate: hexlify(this.bytes),
48211
- paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
48212
- }));
48213
- }
48214
47936
  /**
48215
47937
  * Sets the configurable constants for the predicate.
48216
47938
  *