@fuel-ts/account 0.0.0-rc-2034-20240411123358 → 0.0.0-rc-2021-20240411141803

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 +5 -4
  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 +819 -568
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +805 -572
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +639 -407
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -2
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +888 -322
  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 +4 -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 +3 -1
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +37 -30
  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 +8 -25
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +3 -0
  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 +2 -0
  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 +3 -2
  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 +8 -2
  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 +1535 -1067
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +780 -565
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +631 -416
  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 max2(left, right) {
292
+ BN2.max = function max(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 clone(instance) {
5116
+ function clone3(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(clone(this), {
6050
+ return new Response2(clone3(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 ? clone(input) : null;
6100
+ let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone3(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.49.3",
28956
- FUEL_CORE: "0.22.1",
28955
+ FORC: "0.51.1",
28956
+ FUEL_CORE: "0.24.2",
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_crypto8 = __toESM(__require("crypto"), 1);
29248
+ var import_crypto9 = __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,6 +30317,27 @@ 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
+
30320
30341
  // ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
30321
30342
  var BN_03 = BigInt(0);
30322
30343
  var BN_36 = BigInt(36);
@@ -30901,8 +30922,8 @@ This unreleased fuel-core build may include features and updates not yet support
30901
30922
  }
30902
30923
 
30903
30924
  // ../crypto/dist/index.mjs
30904
- var import_crypto9 = __toESM(__require("crypto"), 1);
30905
30925
  var import_crypto10 = __toESM(__require("crypto"), 1);
30926
+ var import_crypto11 = __toESM(__require("crypto"), 1);
30906
30927
  var scrypt3 = (params) => {
30907
30928
  const { password, salt, n, p, r, dklen } = params;
30908
30929
  const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
@@ -30911,7 +30932,7 @@ This unreleased fuel-core build may include features and updates not yet support
30911
30932
  var keccak2562 = (data) => keccak_256(data);
30912
30933
  var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
30913
30934
  var randomBytes4 = (length) => {
30914
- const randomValues = Uint8Array.from(import_crypto9.default.randomBytes(length));
30935
+ const randomValues = Uint8Array.from(import_crypto10.default.randomBytes(length));
30915
30936
  return randomValues;
30916
30937
  };
30917
30938
  var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
@@ -30926,7 +30947,7 @@ This unreleased fuel-core build may include features and updates not yet support
30926
30947
  const salt = randomBytes4(32);
30927
30948
  const secret = keyFromPassword(password, salt);
30928
30949
  const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
30929
- const cipher = await import_crypto8.default.createCipheriv(ALGORITHM, secret, iv);
30950
+ const cipher = await import_crypto9.default.createCipheriv(ALGORITHM, secret, iv);
30930
30951
  let cipherData = cipher.update(dataBuffer);
30931
30952
  cipherData = Buffer.concat([cipherData, cipher.final()]);
30932
30953
  return {
@@ -30940,7 +30961,7 @@ This unreleased fuel-core build may include features and updates not yet support
30940
30961
  const salt = bufferFromString(keystore.salt);
30941
30962
  const secret = keyFromPassword(password, salt);
30942
30963
  const encryptedText = bufferFromString(keystore.data);
30943
- const decipher = await import_crypto8.default.createDecipheriv(ALGORITHM, secret, iv);
30964
+ const decipher = await import_crypto9.default.createDecipheriv(ALGORITHM, secret, iv);
30944
30965
  const decrypted = decipher.update(encryptedText);
30945
30966
  const deBuff = Buffer.concat([decrypted, decipher.final()]);
30946
30967
  const decryptedData = Buffer.from(deBuff).toString("utf-8");
@@ -30951,12 +30972,12 @@ This unreleased fuel-core build may include features and updates not yet support
30951
30972
  }
30952
30973
  };
30953
30974
  async function encryptJsonWalletData(data, key, iv) {
30954
- const cipher = await import_crypto10.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30975
+ const cipher = await import_crypto11.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30955
30976
  const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
30956
30977
  return new Uint8Array(encrypted);
30957
30978
  }
30958
30979
  async function decryptJsonWalletData(data, key, iv) {
30959
- const decipher = import_crypto10.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30980
+ const decipher = import_crypto11.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
30960
30981
  const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
30961
30982
  return new Uint8Array(decrypted);
30962
30983
  }
@@ -31495,32 +31516,182 @@ This unreleased fuel-core build may include features and updates not yet support
31495
31516
  function toBytes3(value, bytesPadding) {
31496
31517
  return bn(value).toBytes(bytesPadding);
31497
31518
  }
31498
- function max(...numbers) {
31499
- return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
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
+ };
31500
31534
  }
31501
31535
 
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
+
31502
31673
  // src/providers/coin-quantity.ts
31503
31674
  var coinQuantityfy = (coinQuantityLike) => {
31504
31675
  let assetId;
31505
31676
  let amount;
31506
- let max2;
31677
+ let max;
31507
31678
  if (Array.isArray(coinQuantityLike)) {
31508
31679
  amount = coinQuantityLike[0];
31509
31680
  assetId = coinQuantityLike[1] ?? BaseAssetId;
31510
- max2 = coinQuantityLike[2] ?? void 0;
31681
+ max = coinQuantityLike[2] ?? void 0;
31511
31682
  } else {
31512
31683
  amount = coinQuantityLike.amount;
31513
31684
  assetId = coinQuantityLike.assetId ?? BaseAssetId;
31514
- max2 = coinQuantityLike.max ?? void 0;
31685
+ max = coinQuantityLike.max ?? void 0;
31515
31686
  }
31516
31687
  const bnAmount = bn(amount);
31517
31688
  return {
31518
31689
  assetId: hexlify(assetId),
31519
31690
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
31520
- max: max2 ? bn(max2) : void 0
31691
+ max: max ? bn(max) : void 0
31521
31692
  };
31522
31693
  };
31523
- var addAmountToAsset = (params) => {
31694
+ var addAmountToCoinQuantities = (params) => {
31524
31695
  const { amount, assetId } = params;
31525
31696
  const coinQuantities = [...params.coinQuantities];
31526
31697
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -31605,7 +31776,6 @@ This unreleased fuel-core build may include features and updates not yet support
31605
31776
  var ENCODING_V1 = "1";
31606
31777
  var WORD_SIZE = 8;
31607
31778
  var BYTES_32 = 32;
31608
- var UTXO_ID_LEN = BYTES_32 + 1;
31609
31779
  var ASSET_ID_LEN = BYTES_32;
31610
31780
  var ADDRESS_LEN = BYTES_32;
31611
31781
  var NONCE_LEN = BYTES_32;
@@ -31613,9 +31783,9 @@ This unreleased fuel-core build may include features and updates not yet support
31613
31783
  var TX_POINTER_LEN = WORD_SIZE * 2;
31614
31784
  var MAX_BYTES = 2 ** 32 - 1;
31615
31785
  var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
31616
- WORD_SIZE + // Tx size
31786
+ ASSET_ID_LEN + // Base asset ID
31617
31787
  // Asset ID/Balance coin input pairs
31618
- maxInputs * (ASSET_ID_LEN + WORD_SIZE);
31788
+ maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
31619
31789
  var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
31620
31790
  WORD_SIZE + // Gas limit
31621
31791
  WORD_SIZE + // Script size
@@ -31633,7 +31803,6 @@ This unreleased fuel-core build may include features and updates not yet support
31633
31803
  ASSET_ID_LEN + // Asset id
31634
31804
  TX_POINTER_LEN + // TxPointer
31635
31805
  WORD_SIZE + // Witnesses index
31636
- WORD_SIZE + // Maturity
31637
31806
  WORD_SIZE + // Predicate size
31638
31807
  WORD_SIZE + // Predicate data size
31639
31808
  WORD_SIZE;
@@ -31955,7 +32124,7 @@ This unreleased fuel-core build may include features and updates not yet support
31955
32124
  constructor(name, coders) {
31956
32125
  const caseIndexCoder = new BigNumberCoder("u64");
31957
32126
  const encodedValueSize = Object.values(coders).reduce(
31958
- (max2, coder) => Math.max(max2, coder.encodedLength),
32127
+ (max, coder) => Math.max(max, coder.encodedLength),
31959
32128
  0
31960
32129
  );
31961
32130
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -32659,7 +32828,7 @@ This unreleased fuel-core build may include features and updates not yet support
32659
32828
  constructor(name, coders) {
32660
32829
  const caseIndexCoder = new BigNumberCoder("u64");
32661
32830
  const encodedValueSize = Object.values(coders).reduce(
32662
- (max2, coder) => Math.max(max2, coder.encodedLength),
32831
+ (max, coder) => Math.max(max, coder.encodedLength),
32663
32832
  0
32664
32833
  );
32665
32834
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -33371,18 +33540,19 @@ This unreleased fuel-core build may include features and updates not yet support
33371
33540
  encode(value) {
33372
33541
  const parts = [];
33373
33542
  parts.push(new B256Coder().encode(value.txID));
33374
- parts.push(new NumberCoder("u8").encode(value.outputIndex));
33543
+ parts.push(new NumberCoder("u16").encode(value.outputIndex));
33375
33544
  parts.push(new B256Coder().encode(value.owner));
33376
33545
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33377
33546
  parts.push(new B256Coder().encode(value.assetId));
33378
33547
  parts.push(new TxPointerCoder().encode(value.txPointer));
33379
- parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33380
- parts.push(new NumberCoder("u32").encode(value.maturity));
33548
+ parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33381
33549
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
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));
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
+ );
33386
33556
  return concat(parts);
33387
33557
  }
33388
33558
  decode(data, offset) {
@@ -33390,7 +33560,7 @@ This unreleased fuel-core build may include features and updates not yet support
33390
33560
  let o = offset;
33391
33561
  [decoded, o] = new B256Coder().decode(data, o);
33392
33562
  const txID = decoded;
33393
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33563
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33394
33564
  const outputIndex = decoded;
33395
33565
  [decoded, o] = new B256Coder().decode(data, o);
33396
33566
  const owner = decoded;
@@ -33400,19 +33570,17 @@ This unreleased fuel-core build may include features and updates not yet support
33400
33570
  const assetId = decoded;
33401
33571
  [decoded, o] = new TxPointerCoder().decode(data, o);
33402
33572
  const txPointer = decoded;
33403
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33573
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33404
33574
  const witnessIndex = Number(decoded);
33405
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33406
- const maturity = decoded;
33407
33575
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33408
33576
  const predicateGasUsed = decoded;
33409
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33577
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33410
33578
  const predicateLength = decoded;
33411
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33579
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33412
33580
  const predicateDataLength = decoded;
33413
- [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33581
+ [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33414
33582
  const predicate = decoded;
33415
- [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33583
+ [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33416
33584
  const predicateData = decoded;
33417
33585
  return [
33418
33586
  {
@@ -33424,7 +33592,6 @@ This unreleased fuel-core build may include features and updates not yet support
33424
33592
  assetId,
33425
33593
  txPointer,
33426
33594
  witnessIndex,
33427
- maturity,
33428
33595
  predicateGasUsed,
33429
33596
  predicateLength,
33430
33597
  predicateDataLength,
@@ -33442,7 +33609,7 @@ This unreleased fuel-core build may include features and updates not yet support
33442
33609
  encode(value) {
33443
33610
  const parts = [];
33444
33611
  parts.push(new B256Coder().encode(value.txID));
33445
- parts.push(new NumberCoder("u8").encode(value.outputIndex));
33612
+ parts.push(new NumberCoder("u16").encode(value.outputIndex));
33446
33613
  parts.push(new B256Coder().encode(value.balanceRoot));
33447
33614
  parts.push(new B256Coder().encode(value.stateRoot));
33448
33615
  parts.push(new TxPointerCoder().encode(value.txPointer));
@@ -33454,7 +33621,7 @@ This unreleased fuel-core build may include features and updates not yet support
33454
33621
  let o = offset;
33455
33622
  [decoded, o] = new B256Coder().decode(data, o);
33456
33623
  const txID = decoded;
33457
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33624
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33458
33625
  const outputIndex = decoded;
33459
33626
  [decoded, o] = new B256Coder().decode(data, o);
33460
33627
  const balanceRoot = decoded;
@@ -33503,14 +33670,16 @@ This unreleased fuel-core build may include features and updates not yet support
33503
33670
  parts.push(new ByteArrayCoder(32).encode(value.recipient));
33504
33671
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33505
33672
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
33506
- parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33673
+ parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33507
33674
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
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));
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));
33511
33678
  parts.push(new ByteArrayCoder(data.length).encode(data));
33512
- parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33513
- parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33679
+ parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33680
+ parts.push(
33681
+ new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33682
+ );
33514
33683
  return concat(parts);
33515
33684
  }
33516
33685
  static decodeData(messageData) {
@@ -33530,21 +33699,21 @@ This unreleased fuel-core build may include features and updates not yet support
33530
33699
  const amount = decoded;
33531
33700
  [decoded, o] = new B256Coder().decode(data, o);
33532
33701
  const nonce = decoded;
33533
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33702
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33534
33703
  const witnessIndex = Number(decoded);
33535
33704
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33536
33705
  const predicateGasUsed = decoded;
33537
33706
  [decoded, o] = new NumberCoder("u32").decode(data, o);
33538
33707
  const dataLength2 = decoded;
33539
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33708
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33540
33709
  const predicateLength = decoded;
33541
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33710
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33542
33711
  const predicateDataLength = decoded;
33543
33712
  [decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
33544
33713
  const messageData = decoded;
33545
- [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33714
+ [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33546
33715
  const predicate = decoded;
33547
- [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33716
+ [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33548
33717
  const predicateData = decoded;
33549
33718
  return [
33550
33719
  {
@@ -33856,7 +34025,7 @@ This unreleased fuel-core build may include features and updates not yet support
33856
34025
  }
33857
34026
  };
33858
34027
  var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
33859
- PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
34028
+ PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
33860
34029
  PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
33861
34030
  PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
33862
34031
  PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
@@ -33904,9 +34073,9 @@ This unreleased fuel-core build may include features and updates not yet support
33904
34073
  let o = offset;
33905
34074
  const policies = [];
33906
34075
  if (policyTypes & 1) {
33907
- const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
34076
+ const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
33908
34077
  o = nextOffset;
33909
- policies.push({ type: 1, data: gasPrice });
34078
+ policies.push({ type: 1, data: tip });
33910
34079
  }
33911
34080
  if (policyTypes & 2) {
33912
34081
  const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
@@ -34138,15 +34307,15 @@ This unreleased fuel-core build may include features and updates not yet support
34138
34307
  encode(value) {
34139
34308
  const parts = [];
34140
34309
  parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
34141
- parts.push(new NumberCoder("u32").encode(value.scriptLength));
34142
- parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
34143
- parts.push(new NumberCoder("u32").encode(value.policyTypes));
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
34310
  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));
34311
+ parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
34312
+ parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
34313
+ 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));
34150
34319
  parts.push(new PoliciesCoder().encode(value.policies));
34151
34320
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34152
34321
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
@@ -34158,23 +34327,23 @@ This unreleased fuel-core build may include features and updates not yet support
34158
34327
  let o = offset;
34159
34328
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34160
34329
  const scriptGasLimit = decoded;
34161
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34330
+ [decoded, o] = new B256Coder().decode(data, o);
34331
+ const receiptsRoot = decoded;
34332
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34162
34333
  const scriptLength = decoded;
34163
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34334
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34164
34335
  const scriptDataLength = decoded;
34165
34336
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34166
34337
  const policyTypes = decoded;
34167
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34338
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34168
34339
  const inputsCount = decoded;
34169
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34340
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34170
34341
  const outputsCount = decoded;
34171
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34342
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34172
34343
  const witnessesCount = decoded;
34173
- [decoded, o] = new B256Coder().decode(data, o);
34174
- const receiptsRoot = decoded;
34175
- [decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
34344
+ [decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
34176
34345
  const script = decoded;
34177
- [decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
34346
+ [decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
34178
34347
  const scriptData = decoded;
34179
34348
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34180
34349
  const policies = decoded;
@@ -34212,18 +34381,19 @@ This unreleased fuel-core build may include features and updates not yet support
34212
34381
  }
34213
34382
  encode(value) {
34214
34383
  const parts = [];
34215
- parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
34216
- parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
34217
- parts.push(new NumberCoder("u32").encode(value.policyTypes));
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));
34384
+ parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
34222
34385
  parts.push(new B256Coder().encode(value.salt));
34223
- parts.push(new PoliciesCoder().encode(value.policies));
34386
+ parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
34387
+ 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));
34224
34391
  parts.push(
34225
- new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
34392
+ new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
34393
+ value.storageSlots
34394
+ )
34226
34395
  );
34396
+ parts.push(new PoliciesCoder().encode(value.policies));
34227
34397
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34228
34398
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
34229
34399
  parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
@@ -34232,26 +34402,27 @@ This unreleased fuel-core build may include features and updates not yet support
34232
34402
  decode(data, offset) {
34233
34403
  let decoded;
34234
34404
  let o = offset;
34235
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34236
- const bytecodeLength = decoded;
34237
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34405
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34238
34406
  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;
34239
34411
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34240
34412
  const policyTypes = decoded;
34241
34413
  [decoded, o] = new NumberCoder("u16").decode(data, o);
34242
- const storageSlotsCount = decoded;
34243
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34244
34414
  const inputsCount = decoded;
34245
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34415
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34246
34416
  const outputsCount = decoded;
34247
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34417
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34248
34418
  const witnessesCount = decoded;
34249
- [decoded, o] = new B256Coder().decode(data, o);
34250
- const salt = decoded;
34419
+ [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
34420
+ data,
34421
+ o
34422
+ );
34423
+ const storageSlots = decoded;
34251
34424
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34252
34425
  const policies = decoded;
34253
- [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
34254
- const storageSlots = decoded;
34255
34426
  [decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
34256
34427
  const inputs = decoded;
34257
34428
  [decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
@@ -34261,7 +34432,6 @@ This unreleased fuel-core build may include features and updates not yet support
34261
34432
  return [
34262
34433
  {
34263
34434
  type: 1,
34264
- bytecodeLength,
34265
34435
  bytecodeWitnessIndex,
34266
34436
  policyTypes,
34267
34437
  storageSlotsCount,
@@ -34290,6 +34460,7 @@ This unreleased fuel-core build may include features and updates not yet support
34290
34460
  parts.push(new OutputContractCoder().encode(value.outputContract));
34291
34461
  parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
34292
34462
  parts.push(new B256Coder().encode(value.mintAssetId));
34463
+ parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
34293
34464
  return concat(parts);
34294
34465
  }
34295
34466
  decode(data, offset) {
@@ -34305,6 +34476,8 @@ This unreleased fuel-core build may include features and updates not yet support
34305
34476
  const mintAmount = decoded;
34306
34477
  [decoded, o] = new B256Coder().decode(data, o);
34307
34478
  const mintAssetId = decoded;
34479
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34480
+ const gasPrice = decoded;
34308
34481
  return [
34309
34482
  {
34310
34483
  type: 2,
@@ -34312,7 +34485,8 @@ This unreleased fuel-core build may include features and updates not yet support
34312
34485
  inputContract,
34313
34486
  outputContract,
34314
34487
  mintAmount,
34315
- mintAssetId
34488
+ mintAssetId,
34489
+ gasPrice
34316
34490
  },
34317
34491
  o
34318
34492
  ];
@@ -34619,159 +34793,6 @@ This unreleased fuel-core build may include features and updates not yet support
34619
34793
  // src/providers/provider.ts
34620
34794
  var import_graphql_request = __toESM(require_dist2());
34621
34795
 
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
-
34775
34796
  // ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
34776
34797
  var __assign = function() {
34777
34798
  __assign = Object.assign || function __assign2(t) {
@@ -37939,14 +37960,10 @@ spurious results.`);
37939
37960
  // src/providers/__generated__/operations.ts
37940
37961
  var ReceiptFragmentFragmentDoc = lib_default2`
37941
37962
  fragment receiptFragment on Receipt {
37942
- contract {
37943
- id
37944
- }
37963
+ id
37945
37964
  pc
37946
37965
  is
37947
- to {
37948
- id
37949
- }
37966
+ to
37950
37967
  toAddress
37951
37968
  amount
37952
37969
  assetId
@@ -37984,10 +38001,16 @@ spurious results.`);
37984
38001
  id
37985
38002
  }
37986
38003
  time
38004
+ receipts {
38005
+ ...receiptFragment
38006
+ }
37987
38007
  programState {
37988
38008
  returnType
37989
38009
  data
37990
38010
  }
38011
+ receipts {
38012
+ ...receiptFragment
38013
+ }
37991
38014
  }
37992
38015
  ... on FailureStatus {
37993
38016
  block {
@@ -37995,26 +38018,24 @@ spurious results.`);
37995
38018
  }
37996
38019
  time
37997
38020
  reason
38021
+ receipts {
38022
+ ...receiptFragment
38023
+ }
37998
38024
  }
37999
38025
  ... on SqueezedOutStatus {
38000
38026
  reason
38001
38027
  }
38002
38028
  }
38003
- `;
38029
+ ${ReceiptFragmentFragmentDoc}`;
38004
38030
  var TransactionFragmentFragmentDoc = lib_default2`
38005
38031
  fragment transactionFragment on Transaction {
38006
38032
  id
38007
38033
  rawPayload
38008
- gasPrice
38009
- receipts {
38010
- ...receiptFragment
38011
- }
38012
38034
  status {
38013
38035
  ...transactionStatusFragment
38014
38036
  }
38015
38037
  }
38016
- ${ReceiptFragmentFragmentDoc}
38017
- ${TransactionStatusFragmentFragmentDoc}`;
38038
+ ${TransactionStatusFragmentFragmentDoc}`;
38018
38039
  var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
38019
38040
  fragment inputEstimatePredicatesFragment on Input {
38020
38041
  ... on InputCoin {
@@ -38032,6 +38053,46 @@ ${TransactionStatusFragmentFragmentDoc}`;
38032
38053
  }
38033
38054
  }
38034
38055
  ${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}`;
38035
38096
  var CoinFragmentFragmentDoc = lib_default2`
38036
38097
  fragment coinFragment on Coin {
38037
38098
  __typename
@@ -38039,7 +38100,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38039
38100
  owner
38040
38101
  amount
38041
38102
  assetId
38042
- maturity
38043
38103
  blockCreated
38044
38104
  txCreatedIdx
38045
38105
  }
@@ -38084,7 +38144,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38084
38144
  prevRoot
38085
38145
  time
38086
38146
  applicationHash
38087
- messageReceiptRoot
38088
38147
  messageReceiptCount
38089
38148
  }
38090
38149
  commitBlockHeader {
@@ -38096,7 +38155,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38096
38155
  prevRoot
38097
38156
  time
38098
38157
  applicationHash
38099
- messageReceiptRoot
38100
38158
  messageReceiptCount
38101
38159
  }
38102
38160
  sender
@@ -38116,8 +38174,8 @@ ${TransactionStatusFragmentFragmentDoc}`;
38116
38174
  var BlockFragmentFragmentDoc = lib_default2`
38117
38175
  fragment blockFragment on Block {
38118
38176
  id
38177
+ height
38119
38178
  header {
38120
- height
38121
38179
  time
38122
38180
  }
38123
38181
  transactions {
@@ -38175,6 +38233,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
38175
38233
  `;
38176
38234
  var GasCostsFragmentFragmentDoc = lib_default2`
38177
38235
  fragment GasCostsFragment on GasCosts {
38236
+ version {
38237
+ ... on Version {
38238
+ value
38239
+ }
38240
+ }
38178
38241
  add
38179
38242
  addi
38180
38243
  aloc
@@ -38187,7 +38250,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38187
38250
  cb
38188
38251
  cfei
38189
38252
  cfsi
38190
- croo
38191
38253
  div
38192
38254
  divi
38193
38255
  ecr1
@@ -38270,6 +38332,9 @@ ${TransactionStatusFragmentFragmentDoc}`;
38270
38332
  ccp {
38271
38333
  ...DependentCostFragment
38272
38334
  }
38335
+ croo {
38336
+ ...DependentCostFragment
38337
+ }
38273
38338
  csiz {
38274
38339
  ...DependentCostFragment
38275
38340
  }
@@ -38329,6 +38394,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
38329
38394
  ${DependentCostFragmentFragmentDoc}`;
38330
38395
  var ConsensusParametersFragmentFragmentDoc = lib_default2`
38331
38396
  fragment consensusParametersFragment on ConsensusParameters {
38397
+ version {
38398
+ ... on Version {
38399
+ value
38400
+ }
38401
+ }
38332
38402
  txParams {
38333
38403
  ...TxParametersFragment
38334
38404
  }
@@ -38388,18 +38458,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38388
38458
  fragment nodeInfoFragment on NodeInfo {
38389
38459
  utxoValidation
38390
38460
  vmBacktrace
38391
- minGasPrice
38392
38461
  maxTx
38393
38462
  maxDepth
38394
38463
  nodeVersion
38395
- peers {
38396
- id
38397
- addresses
38398
- clientVersion
38399
- blockHeight
38400
- lastHeartbeatMs
38401
- appScore
38402
- }
38403
38464
  }
38404
38465
  `;
38405
38466
  var GetVersionDocument = lib_default2`
@@ -38434,13 +38495,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38434
38495
  query getTransactionWithReceipts($transactionId: TransactionId!) {
38435
38496
  transaction(id: $transactionId) {
38436
38497
  ...transactionFragment
38437
- receipts {
38438
- ...receiptFragment
38439
- }
38440
38498
  }
38441
38499
  }
38442
- ${TransactionFragmentFragmentDoc}
38443
- ${ReceiptFragmentFragmentDoc}`;
38500
+ ${TransactionFragmentFragmentDoc}`;
38444
38501
  var GetTransactionsDocument = lib_default2`
38445
38502
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
38446
38503
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -38568,6 +38625,20 @@ ${MessageCoinFragmentFragmentDoc}`;
38568
38625
  }
38569
38626
  }
38570
38627
  ${BalanceFragmentFragmentDoc}`;
38628
+ var GetLatestGasPriceDocument = lib_default2`
38629
+ query getLatestGasPrice {
38630
+ latestGasPrice {
38631
+ gasPrice
38632
+ }
38633
+ }
38634
+ `;
38635
+ var EstimateGasPriceDocument = lib_default2`
38636
+ query estimateGasPrice($blockHorizon: U32!) {
38637
+ estimateGasPrice(blockHorizon: $blockHorizon) {
38638
+ gasPrice
38639
+ }
38640
+ }
38641
+ `;
38571
38642
  var GetBalancesDocument = lib_default2`
38572
38643
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
38573
38644
  balances(
@@ -38622,12 +38693,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38622
38693
  }
38623
38694
  `;
38624
38695
  var DryRunDocument = lib_default2`
38625
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
38626
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
38627
- ...receiptFragment
38696
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
38697
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
38698
+ ...dryRunTransactionExecutionStatusFragment
38628
38699
  }
38629
38700
  }
38630
- ${ReceiptFragmentFragmentDoc}`;
38701
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
38631
38702
  var SubmitDocument = lib_default2`
38632
38703
  mutation submit($encodedTransaction: HexString!) {
38633
38704
  submit(tx: $encodedTransaction) {
@@ -38710,6 +38781,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38710
38781
  getBalance(variables, options) {
38711
38782
  return requester(GetBalanceDocument, variables, options);
38712
38783
  },
38784
+ getLatestGasPrice(variables, options) {
38785
+ return requester(GetLatestGasPriceDocument, variables, options);
38786
+ },
38787
+ estimateGasPrice(variables, options) {
38788
+ return requester(EstimateGasPriceDocument, variables, options);
38789
+ },
38713
38790
  getBalances(variables, options) {
38714
38791
  return requester(GetBalancesDocument, variables, options);
38715
38792
  },
@@ -38777,11 +38854,14 @@ ${MessageCoinFragmentFragmentDoc}`;
38777
38854
  let data;
38778
38855
  let errors;
38779
38856
  try {
38780
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
38857
+ const sanitizedText = text.replace(/\s/g, "");
38858
+ ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
38781
38859
  } catch (e) {
38782
38860
  throw new FuelError(
38783
38861
  ErrorCode.STREAM_PARSING_ERROR,
38784
- `Error while parsing stream data response: ${text}`
38862
+ `Error while parsing stream data response: ${text}
38863
+
38864
+ Thrown error: ${e}`
38785
38865
  );
38786
38866
  }
38787
38867
  if (Array.isArray(errors)) {
@@ -38874,8 +38954,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38874
38954
  const predicateData = arrayify(value.predicateData ?? "0x");
38875
38955
  return {
38876
38956
  type: InputType.Coin,
38877
- txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
38878
- outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
38957
+ txID: hexlify(arrayify(value.id).slice(0, 32)),
38958
+ outputIndex: toNumber2(arrayify(value.id).slice(32, 34)),
38879
38959
  owner: hexlify(value.owner),
38880
38960
  amount: bn(value.amount),
38881
38961
  assetId: hexlify(value.assetId),
@@ -38884,10 +38964,9 @@ ${MessageCoinFragmentFragmentDoc}`;
38884
38964
  txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
38885
38965
  },
38886
38966
  witnessIndex: value.witnessIndex,
38887
- maturity: value.maturity ?? 0,
38888
38967
  predicateGasUsed: bn(value.predicateGasUsed),
38889
- predicateLength: predicate.length,
38890
- predicateDataLength: predicateData.length,
38968
+ predicateLength: bn(predicate.length),
38969
+ predicateDataLength: bn(predicateData.length),
38891
38970
  predicate: hexlify(predicate),
38892
38971
  predicateData: hexlify(predicateData)
38893
38972
  };
@@ -38918,8 +38997,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38918
38997
  nonce: hexlify(value.nonce),
38919
38998
  witnessIndex: value.witnessIndex,
38920
38999
  predicateGasUsed: bn(value.predicateGasUsed),
38921
- predicateLength: predicate.length,
38922
- predicateDataLength: predicateData.length,
39000
+ predicateLength: bn(predicate.length),
39001
+ predicateDataLength: bn(predicateData.length),
38923
39002
  predicate: hexlify(predicate),
38924
39003
  predicateData: hexlify(predicateData),
38925
39004
  data: hexlify(data),
@@ -39079,8 +39158,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39079
39158
  case "CALL" /* Call */: {
39080
39159
  const callReceipt = {
39081
39160
  type: ReceiptType.Call,
39082
- from: hexOrZero(receipt.contract?.id),
39083
- to: hexOrZero(receipt?.to?.id),
39161
+ from: hexOrZero(receipt.id || receipt.contractId),
39162
+ to: hexOrZero(receipt?.to),
39084
39163
  amount: bn(receipt.amount),
39085
39164
  assetId: hexOrZero(receipt.assetId),
39086
39165
  gas: bn(receipt.gas),
@@ -39094,7 +39173,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39094
39173
  case "RETURN" /* Return */: {
39095
39174
  const returnReceipt = {
39096
39175
  type: ReceiptType.Return,
39097
- id: hexOrZero(receipt.contract?.id),
39176
+ id: hexOrZero(receipt.id || receipt.contractId),
39098
39177
  val: bn(receipt.val),
39099
39178
  pc: bn(receipt.pc),
39100
39179
  is: bn(receipt.is)
@@ -39104,7 +39183,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39104
39183
  case "RETURN_DATA" /* ReturnData */: {
39105
39184
  const returnDataReceipt = {
39106
39185
  type: ReceiptType.ReturnData,
39107
- id: hexOrZero(receipt.contract?.id),
39186
+ id: hexOrZero(receipt.id || receipt.contractId),
39108
39187
  ptr: bn(receipt.ptr),
39109
39188
  len: bn(receipt.len),
39110
39189
  digest: hexOrZero(receipt.digest),
@@ -39116,7 +39195,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39116
39195
  case "PANIC" /* Panic */: {
39117
39196
  const panicReceipt = {
39118
39197
  type: ReceiptType.Panic,
39119
- id: hexOrZero(receipt.contract?.id),
39198
+ id: hexOrZero(receipt.id),
39120
39199
  reason: bn(receipt.reason),
39121
39200
  pc: bn(receipt.pc),
39122
39201
  is: bn(receipt.is),
@@ -39127,7 +39206,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39127
39206
  case "REVERT" /* Revert */: {
39128
39207
  const revertReceipt = {
39129
39208
  type: ReceiptType.Revert,
39130
- id: hexOrZero(receipt.contract?.id),
39209
+ id: hexOrZero(receipt.id || receipt.contractId),
39131
39210
  val: bn(receipt.ra),
39132
39211
  pc: bn(receipt.pc),
39133
39212
  is: bn(receipt.is)
@@ -39137,7 +39216,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39137
39216
  case "LOG" /* Log */: {
39138
39217
  const logReceipt = {
39139
39218
  type: ReceiptType.Log,
39140
- id: hexOrZero(receipt.contract?.id),
39219
+ id: hexOrZero(receipt.id || receipt.contractId),
39141
39220
  val0: bn(receipt.ra),
39142
39221
  val1: bn(receipt.rb),
39143
39222
  val2: bn(receipt.rc),
@@ -39150,7 +39229,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39150
39229
  case "LOG_DATA" /* LogData */: {
39151
39230
  const logDataReceipt = {
39152
39231
  type: ReceiptType.LogData,
39153
- id: hexOrZero(receipt.contract?.id),
39232
+ id: hexOrZero(receipt.id || receipt.contractId),
39154
39233
  val0: bn(receipt.ra),
39155
39234
  val1: bn(receipt.rb),
39156
39235
  ptr: bn(receipt.ptr),
@@ -39164,8 +39243,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39164
39243
  case "TRANSFER" /* Transfer */: {
39165
39244
  const transferReceipt = {
39166
39245
  type: ReceiptType.Transfer,
39167
- from: hexOrZero(receipt.contract?.id),
39168
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
39246
+ from: hexOrZero(receipt.id || receipt.contractId),
39247
+ to: hexOrZero(receipt.toAddress || receipt?.to),
39169
39248
  amount: bn(receipt.amount),
39170
39249
  assetId: hexOrZero(receipt.assetId),
39171
39250
  pc: bn(receipt.pc),
@@ -39176,8 +39255,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39176
39255
  case "TRANSFER_OUT" /* TransferOut */: {
39177
39256
  const transferOutReceipt = {
39178
39257
  type: ReceiptType.TransferOut,
39179
- from: hexOrZero(receipt.contract?.id),
39180
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
39258
+ from: hexOrZero(receipt.id || receipt.contractId),
39259
+ to: hexOrZero(receipt.toAddress || receipt.to),
39181
39260
  amount: bn(receipt.amount),
39182
39261
  assetId: hexOrZero(receipt.assetId),
39183
39262
  pc: bn(receipt.pc),
@@ -39220,7 +39299,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39220
39299
  return receiptMessageOut;
39221
39300
  }
39222
39301
  case "MINT" /* Mint */: {
39223
- const contractId = hexOrZero(receipt.contract?.id);
39302
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
39224
39303
  const subId = hexOrZero(receipt.subId);
39225
39304
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
39226
39305
  const mintReceipt = {
@@ -39235,7 +39314,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39235
39314
  return mintReceipt;
39236
39315
  }
39237
39316
  case "BURN" /* Burn */: {
39238
- const contractId = hexOrZero(receipt.contract?.id);
39317
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
39239
39318
  const subId = hexOrZero(receipt.subId);
39240
39319
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
39241
39320
  const burnReceipt = {
@@ -39316,7 +39395,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39316
39395
  };
39317
39396
 
39318
39397
  // src/providers/utils/gas.ts
39319
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
39320
39398
  var getGasUsedFromReceipts = (receipts) => {
39321
39399
  const scriptResult = receipts.filter(
39322
39400
  (receipt) => receipt.type === ReceiptType.ScriptResult
@@ -39337,18 +39415,28 @@ ${MessageCoinFragmentFragmentDoc}`;
39337
39415
  }
39338
39416
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
39339
39417
  const witnessCache = [];
39340
- const totalGas = inputs.reduce((total, input) => {
39418
+ const chargeableInputs = inputs.filter((input) => {
39419
+ const isCoinOrMessage = "owner" in input || "sender" in input;
39420
+ if (isCoinOrMessage) {
39421
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39422
+ return true;
39423
+ }
39424
+ if (!witnessCache.includes(input.witnessIndex)) {
39425
+ witnessCache.push(input.witnessIndex);
39426
+ return true;
39427
+ }
39428
+ }
39429
+ return false;
39430
+ });
39431
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
39432
+ const totalGas = chargeableInputs.reduce((total, input) => {
39341
39433
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39342
39434
  return total.add(
39343
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39435
+ vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39344
39436
  );
39345
39437
  }
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());
39438
+ return total.add(gasCosts.ecr1);
39439
+ }, bn(0));
39352
39440
  return totalGas;
39353
39441
  }
39354
39442
  function getMinGas(params) {
@@ -39360,12 +39448,20 @@ ${MessageCoinFragmentFragmentDoc}`;
39360
39448
  return minGas;
39361
39449
  }
39362
39450
  function getMaxGas(params) {
39363
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
39451
+ const {
39452
+ gasPerByte,
39453
+ witnessesLength,
39454
+ witnessLimit,
39455
+ minGas,
39456
+ gasLimit = bn(0),
39457
+ maxGasPerTx
39458
+ } = params;
39364
39459
  let remainingAllowedWitnessGas = bn(0);
39365
39460
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
39366
39461
  remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
39367
39462
  }
39368
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39463
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39464
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
39369
39465
  }
39370
39466
  function calculateMetadataGasForTxCreate({
39371
39467
  gasCosts,
@@ -39387,6 +39483,10 @@ ${MessageCoinFragmentFragmentDoc}`;
39387
39483
  }) {
39388
39484
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
39389
39485
  }
39486
+ var calculateGasFee = (params) => {
39487
+ const { gas, gasPrice, priceFactor, tip } = params;
39488
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
39489
+ };
39390
39490
 
39391
39491
  // src/providers/utils/json.ts
39392
39492
  function normalize2(object) {
@@ -39528,7 +39628,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39528
39628
  // src/providers/transaction-request/transaction-request.ts
39529
39629
  var BaseTransactionRequest = class {
39530
39630
  /** Gas price for transaction */
39531
- gasPrice;
39631
+ tip;
39532
39632
  /** Block until which tx cannot be included */
39533
39633
  maturity;
39534
39634
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -39547,7 +39647,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39547
39647
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
39548
39648
  */
39549
39649
  constructor({
39550
- gasPrice,
39650
+ tip,
39551
39651
  maturity,
39552
39652
  maxFee,
39553
39653
  witnessLimit,
@@ -39555,7 +39655,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39555
39655
  outputs,
39556
39656
  witnesses
39557
39657
  } = {}) {
39558
- this.gasPrice = bn(gasPrice);
39658
+ this.tip = bn(tip);
39559
39659
  this.maturity = maturity ?? 0;
39560
39660
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
39561
39661
  this.maxFee = maxFee ? bn(maxFee) : void 0;
@@ -39566,9 +39666,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39566
39666
  static getPolicyMeta(req) {
39567
39667
  let policyTypes = 0;
39568
39668
  const policies = [];
39569
- if (req.gasPrice) {
39570
- policyTypes += PolicyType.GasPrice;
39571
- policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
39669
+ if (req.tip) {
39670
+ policyTypes += PolicyType.Tip;
39671
+ policies.push({ data: req.tip, type: PolicyType.Tip });
39572
39672
  }
39573
39673
  if (req.witnessLimit) {
39574
39674
  policyTypes += PolicyType.WitnessLimit;
@@ -39755,10 +39855,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39755
39855
  * @param predicate - Predicate bytes.
39756
39856
  * @param predicateData - Predicate data bytes.
39757
39857
  */
39758
- addCoinInput(coin, predicate) {
39858
+ addCoinInput(coin) {
39759
39859
  const { assetId, owner, amount } = coin;
39760
39860
  let witnessIndex;
39761
- if (predicate) {
39861
+ if (coin.predicate) {
39762
39862
  witnessIndex = 0;
39763
39863
  } else {
39764
39864
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -39773,8 +39873,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39773
39873
  amount,
39774
39874
  assetId,
39775
39875
  txPointer: "0x00000000000000000000000000000000",
39776
- witnessIndex,
39777
- predicate: predicate?.bytes
39876
+ witnessIndex
39778
39877
  };
39779
39878
  this.pushInput(input);
39780
39879
  this.addChangeOutput(owner, assetId);
@@ -39787,11 +39886,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39787
39886
  * @param predicate - Predicate bytes.
39788
39887
  * @param predicateData - Predicate data bytes.
39789
39888
  */
39790
- addMessageInput(message, predicate) {
39889
+ addMessageInput(message) {
39791
39890
  const { recipient, sender, amount } = message;
39792
39891
  const assetId = BaseAssetId;
39793
39892
  let witnessIndex;
39794
- if (predicate) {
39893
+ if (message.predicate) {
39795
39894
  witnessIndex = 0;
39796
39895
  } else {
39797
39896
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -39805,8 +39904,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39805
39904
  sender: sender.toB256(),
39806
39905
  recipient: recipient.toB256(),
39807
39906
  amount,
39808
- witnessIndex,
39809
- predicate: predicate?.bytes
39907
+ witnessIndex
39810
39908
  };
39811
39909
  this.pushInput(input);
39812
39910
  this.addChangeOutput(recipient, assetId);
@@ -39837,32 +39935,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39837
39935
  resources.forEach((resource) => this.addResource(resource));
39838
39936
  return this;
39839
39937
  }
39840
- /**
39841
- * Adds multiple resources to the transaction by adding coin/message inputs and change
39842
- * outputs from the related assetIds.
39843
- *
39844
- * @param resources - The resources to add.
39845
- * @returns This transaction.
39846
- */
39847
- addPredicateResource(resource, predicate) {
39848
- if (isCoin(resource)) {
39849
- this.addCoinInput(resource, predicate);
39850
- } else {
39851
- this.addMessageInput(resource, predicate);
39852
- }
39853
- return this;
39854
- }
39855
- /**
39856
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
39857
- * from the related assetIds.
39858
- *
39859
- * @param resources - The resources to add.
39860
- * @returns This transaction.
39861
- */
39862
- addPredicateResources(resources, predicate) {
39863
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
39864
- return this;
39865
- }
39866
39938
  /**
39867
39939
  * Adds a coin output to the transaction.
39868
39940
  *
@@ -39942,7 +40014,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39942
40014
  }
39943
40015
  calculateMaxGas(chainInfo, minGas) {
39944
40016
  const { consensusParameters } = chainInfo;
39945
- const { gasPerByte } = consensusParameters;
40017
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
39946
40018
  const witnessesLength = this.toTransaction().witnesses.reduce(
39947
40019
  (acc, wit) => acc + wit.dataLength,
39948
40020
  0
@@ -39951,7 +40023,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39951
40023
  gasPerByte,
39952
40024
  minGas,
39953
40025
  witnessesLength,
39954
- witnessLimit: this.witnessLimit
40026
+ witnessLimit: this.witnessLimit,
40027
+ maxGasPerTx
39955
40028
  });
39956
40029
  }
39957
40030
  /**
@@ -39969,17 +40042,20 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39969
40042
  });
39970
40043
  const updateAssetInput = (assetId, quantity) => {
39971
40044
  const assetInput = findAssetInput(assetId);
40045
+ let usedQuantity = quantity;
40046
+ if (assetId === BaseAssetId) {
40047
+ usedQuantity = bn("1000000000000000000");
40048
+ }
39972
40049
  if (assetInput && "assetId" in assetInput) {
39973
- assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
39974
- assetInput.amount = quantity;
40050
+ assetInput.id = hexlify(randomBytes3(34));
40051
+ assetInput.amount = usedQuantity;
39975
40052
  } else {
39976
40053
  this.addResources([
39977
40054
  {
39978
- id: hexlify(randomBytes22(UTXO_ID_LEN)),
39979
- amount: quantity,
40055
+ id: hexlify(randomBytes3(34)),
40056
+ amount: usedQuantity,
39980
40057
  assetId,
39981
40058
  owner: resourcesOwner || Address.fromRandom(),
39982
- maturity: 0,
39983
40059
  blockCreated: bn(1),
39984
40060
  txCreatedIdx: bn(1)
39985
40061
  }
@@ -40011,7 +40087,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40011
40087
  toJSON() {
40012
40088
  return normalizeJSON(this);
40013
40089
  }
40014
- updatePredicateInputs(inputs) {
40090
+ updatePredicateGasUsed(inputs) {
40015
40091
  this.inputs.forEach((i) => {
40016
40092
  let correspondingInput;
40017
40093
  switch (i.type) {
@@ -40033,6 +40109,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40033
40109
  }
40034
40110
  });
40035
40111
  }
40112
+ shiftPredicateData() {
40113
+ this.inputs.forEach((input) => {
40114
+ if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
40115
+ input.predicateData = input.paddPredicateData(
40116
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
40117
+ );
40118
+ }
40119
+ });
40120
+ }
40036
40121
  };
40037
40122
 
40038
40123
  // src/providers/transaction-request/hash-transaction.ts
@@ -40166,9 +40251,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40166
40251
  return {
40167
40252
  type: TransactionType.Create,
40168
40253
  ...baseTransaction,
40169
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
40170
40254
  bytecodeWitnessIndex,
40171
- storageSlotsCount: storageSlots.length,
40255
+ storageSlotsCount: bn(storageSlots.length),
40172
40256
  salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
40173
40257
  storageSlots
40174
40258
  };
@@ -40282,8 +40366,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40282
40366
  type: TransactionType.Script,
40283
40367
  scriptGasLimit: this.gasLimit,
40284
40368
  ...super.getBaseTransaction(),
40285
- scriptLength: script.length,
40286
- scriptDataLength: scriptData.length,
40369
+ scriptLength: bn(script.length),
40370
+ scriptDataLength: bn(scriptData.length),
40287
40371
  receiptsRoot: ZeroBytes32,
40288
40372
  script: hexlify(script),
40289
40373
  scriptData: hexlify(scriptData)
@@ -40347,7 +40431,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40347
40431
  }
40348
40432
  calculateMaxGas(chainInfo, minGas) {
40349
40433
  const { consensusParameters } = chainInfo;
40350
- const { gasPerByte } = consensusParameters;
40434
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
40351
40435
  const witnessesLength = this.toTransaction().witnesses.reduce(
40352
40436
  (acc, wit) => acc + wit.dataLength,
40353
40437
  0
@@ -40357,7 +40441,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40357
40441
  minGas,
40358
40442
  witnessesLength,
40359
40443
  witnessLimit: this.witnessLimit,
40360
- gasLimit: this.gasLimit
40444
+ gasLimit: this.gasLimit,
40445
+ maxGasPerTx
40361
40446
  });
40362
40447
  }
40363
40448
  /**
@@ -40430,13 +40515,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40430
40515
  }
40431
40516
  }
40432
40517
  };
40518
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
40519
+ (acc, input) => {
40520
+ if (input.type === InputType.Coin && input.owner === owner) {
40521
+ acc.utxos.push(input.id);
40522
+ }
40523
+ if (input.type === InputType.Message && input.recipient === owner) {
40524
+ acc.messages.push(input.nonce);
40525
+ }
40526
+ return acc;
40527
+ },
40528
+ {
40529
+ utxos: [],
40530
+ messages: []
40531
+ }
40532
+ );
40433
40533
 
40434
40534
  // src/providers/transaction-summary/calculate-transaction-fee.ts
40435
40535
  var calculateTransactionFee = (params) => {
40436
40536
  const {
40437
- gasUsed,
40537
+ gasPrice,
40438
40538
  rawPayload,
40439
- consensusParameters: { gasCosts, feeParams }
40539
+ tip,
40540
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
40440
40541
  } = params;
40441
40542
  const gasPerByte = bn(feeParams.gasPerByte);
40442
40543
  const gasPriceFactor = bn(feeParams.gasPriceFactor);
@@ -40446,8 +40547,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40446
40547
  return {
40447
40548
  fee: bn(0),
40448
40549
  minFee: bn(0),
40449
- maxFee: bn(0),
40450
- feeFromGasUsed: bn(0)
40550
+ maxFee: bn(0)
40451
40551
  };
40452
40552
  }
40453
40553
  const { type: type3, witnesses, inputs, policies } = transaction;
@@ -40479,7 +40579,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40479
40579
  metadataGas,
40480
40580
  txBytesSize: transactionBytes.length
40481
40581
  });
40482
- const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
40483
40582
  const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
40484
40583
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
40485
40584
  const maxGas = getMaxGas({
@@ -40487,17 +40586,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40487
40586
  minGas,
40488
40587
  witnessesLength,
40489
40588
  gasLimit,
40490
- witnessLimit
40589
+ witnessLimit,
40590
+ maxGasPerTx
40591
+ });
40592
+ const minFee = calculateGasFee({
40593
+ gasPrice,
40594
+ gas: minGas,
40595
+ priceFactor: gasPriceFactor,
40596
+ tip
40597
+ });
40598
+ const maxFee = calculateGasFee({
40599
+ gasPrice,
40600
+ gas: maxGas,
40601
+ priceFactor: gasPriceFactor,
40602
+ tip
40491
40603
  });
40492
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
40493
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
40494
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
40495
- const fee = minFee.add(feeFromGasUsed);
40496
40604
  return {
40497
- fee,
40498
40605
  minFee,
40499
40606
  maxFee,
40500
- feeFromGasUsed
40607
+ fee: maxFee
40501
40608
  };
40502
40609
  };
40503
40610
 
@@ -41098,7 +41205,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41098
41205
  gqlTransactionStatus,
41099
41206
  abiMap = {},
41100
41207
  maxInputs,
41101
- gasCosts
41208
+ gasCosts,
41209
+ maxGasPerTx,
41210
+ gasPrice
41102
41211
  } = params;
41103
41212
  const gasUsed = getGasUsedFromReceipts(receipts);
41104
41213
  const rawPayload = hexlify(transactionBytes);
@@ -41112,11 +41221,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41112
41221
  maxInputs
41113
41222
  });
41114
41223
  const typeName = getTransactionTypeName(transaction.type);
41224
+ const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
41115
41225
  const { fee } = calculateTransactionFee({
41116
- gasUsed,
41226
+ gasPrice,
41117
41227
  rawPayload,
41228
+ tip,
41118
41229
  consensusParameters: {
41119
41230
  gasCosts,
41231
+ maxGasPerTx,
41120
41232
  feeParams: {
41121
41233
  gasPerByte,
41122
41234
  gasPriceFactor
@@ -41252,8 +41364,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41252
41364
  const decodedTransaction = this.decodeTransaction(
41253
41365
  transaction
41254
41366
  );
41255
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
41256
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
41367
+ let txReceipts = [];
41368
+ if (transaction?.status && "receipts" in transaction.status) {
41369
+ txReceipts = transaction.status.receipts;
41370
+ }
41371
+ const receipts = txReceipts.map(processGqlReceipt) || [];
41372
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
41373
+ const gasPrice = await this.provider.getLatestGasPrice();
41257
41374
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
41258
41375
  const transactionSummary = assembleTransactionSummary({
41259
41376
  id: this.id,
@@ -41265,7 +41382,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41265
41382
  gasPriceFactor,
41266
41383
  abiMap: contractsAbiMap,
41267
41384
  maxInputs,
41268
- gasCosts
41385
+ gasCosts,
41386
+ maxGasPerTx,
41387
+ gasPrice
41269
41388
  });
41270
41389
  return transactionSummary;
41271
41390
  }
@@ -41414,7 +41533,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41414
41533
  gasCosts,
41415
41534
  latestBlock: {
41416
41535
  id: latestBlock.id,
41417
- height: bn(latestBlock.header.height),
41536
+ height: bn(latestBlock.height),
41418
41537
  time: latestBlock.header.time,
41419
41538
  transactions: latestBlock.transactions.map((i) => ({
41420
41539
  id: i.id
@@ -41508,10 +41627,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41508
41627
  * Returns some helpful parameters related to gas fees.
41509
41628
  */
41510
41629
  getGasConfig() {
41511
- const { minGasPrice } = this.getNode();
41512
41630
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
41513
41631
  return {
41514
- minGasPrice,
41515
41632
  maxGasPerTx,
41516
41633
  maxGasPerPredicate,
41517
41634
  gasPriceFactor,
@@ -41609,7 +41726,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41609
41726
  */
41610
41727
  async getBlockNumber() {
41611
41728
  const { chain } = await this.operations.getChain();
41612
- return bn(chain.latestBlock.header.height, 10);
41729
+ return bn(chain.latestBlock.height, 10);
41613
41730
  }
41614
41731
  /**
41615
41732
  * Returns the chain information.
@@ -41621,11 +41738,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41621
41738
  const processedNodeInfo = {
41622
41739
  maxDepth: bn(nodeInfo.maxDepth),
41623
41740
  maxTx: bn(nodeInfo.maxTx),
41624
- minGasPrice: bn(nodeInfo.minGasPrice),
41625
41741
  nodeVersion: nodeInfo.nodeVersion,
41626
41742
  utxoValidation: nodeInfo.utxoValidation,
41627
- vmBacktrace: nodeInfo.vmBacktrace,
41628
- peers: nodeInfo.peers
41743
+ vmBacktrace: nodeInfo.vmBacktrace
41629
41744
  };
41630
41745
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
41631
41746
  return processedNodeInfo;
@@ -41711,14 +41826,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41711
41826
  return this.estimateTxDependencies(transactionRequest);
41712
41827
  }
41713
41828
  const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41714
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41715
- encodedTransaction,
41829
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
41830
+ encodedTransactions: encodedTransaction,
41716
41831
  utxoValidation: utxoValidation || false
41717
41832
  });
41718
- const receipts = gqlReceipts.map(processGqlReceipt);
41719
- return {
41720
- receipts
41721
- };
41833
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
41834
+ const receipts = rawReceipts.map(processGqlReceipt);
41835
+ return { receipts, dryrunStatus: status };
41722
41836
  }
41723
41837
  /**
41724
41838
  * Verifies whether enough gas is available to complete transaction.
@@ -41757,9 +41871,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41757
41871
  * If there are missing variable outputs,
41758
41872
  * `addVariableOutputs` is called on the transaction.
41759
41873
  *
41760
- * @privateRemarks
41761
- * TODO: Investigate support for missing contract IDs
41762
- * TODO: Add support for missing output messages
41763
41874
  *
41764
41875
  * @param transactionRequest - The transaction request object.
41765
41876
  * @returns A promise.
@@ -41772,16 +41883,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41772
41883
  missingContractIds: []
41773
41884
  };
41774
41885
  }
41775
- await this.estimatePredicates(transactionRequest);
41776
41886
  let receipts = [];
41777
41887
  const missingContractIds = [];
41778
41888
  let outputVariables = 0;
41889
+ let dryrunStatus;
41779
41890
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
41780
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41781
- encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
41891
+ const {
41892
+ dryRun: [{ receipts: rawReceipts, status }]
41893
+ } = await this.operations.dryRun({
41894
+ encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
41782
41895
  utxoValidation: false
41783
41896
  });
41784
- receipts = gqlReceipts.map(processGqlReceipt);
41897
+ receipts = rawReceipts.map(processGqlReceipt);
41898
+ dryrunStatus = status;
41785
41899
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
41786
41900
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
41787
41901
  if (hasMissingOutputs) {
@@ -41791,6 +41905,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41791
41905
  transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
41792
41906
  missingContractIds.push(contractId);
41793
41907
  });
41908
+ const { maxFee } = await this.estimateTxGasAndFee({
41909
+ transactionRequest,
41910
+ optimizeGas: false
41911
+ });
41912
+ transactionRequest.maxFee = maxFee;
41794
41913
  } else {
41795
41914
  break;
41796
41915
  }
@@ -41798,37 +41917,133 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41798
41917
  return {
41799
41918
  receipts,
41800
41919
  outputVariables,
41801
- missingContractIds
41920
+ missingContractIds,
41921
+ dryrunStatus
41802
41922
  };
41803
41923
  }
41804
41924
  /**
41805
- * Estimates the transaction gas and fee based on the provided transaction request.
41806
- * @param transactionRequest - The transaction request object.
41807
- * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41808
- */
41809
- estimateTxGasAndFee(params) {
41810
- const { transactionRequest } = params;
41811
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
41925
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
41926
+ *
41927
+ * Transactions are dry run in batches. After each dry run, transactions requiring
41928
+ * further modifications are identified. The method iteratively updates these transactions
41929
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
41930
+ *
41931
+ * @param transactionRequests - Array of transaction request objects.
41932
+ * @returns A promise that resolves to an array of results for each transaction.
41933
+ */
41934
+ async estimateMultipleTxDependencies(transactionRequests) {
41935
+ const results = transactionRequests.map(() => ({
41936
+ receipts: [],
41937
+ outputVariables: 0,
41938
+ missingContractIds: [],
41939
+ dryrunStatus: void 0
41940
+ }));
41941
+ const allRequests = clone_default(transactionRequests);
41942
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
41943
+ allRequests.forEach((req, index) => {
41944
+ if (req.type === TransactionType.Script) {
41945
+ serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
41946
+ }
41947
+ });
41948
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
41949
+ let attempt = 0;
41950
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
41951
+ const encodedTransactions = transactionsToProcess.map(
41952
+ (index) => serializedTransactionsMap.get(index)
41953
+ );
41954
+ const dryRunResults = await this.operations.dryRun({
41955
+ encodedTransactions,
41956
+ utxoValidation: false
41957
+ });
41958
+ const nextRoundTransactions = [];
41959
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
41960
+ const currentResultIndex = transactionsToProcess[i];
41961
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
41962
+ results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
41963
+ results[currentResultIndex].dryrunStatus = status;
41964
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
41965
+ results[currentResultIndex].receipts
41966
+ );
41967
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
41968
+ const requestToProcess = allRequests[currentResultIndex];
41969
+ if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
41970
+ results[currentResultIndex].outputVariables += missingOutputVariables.length;
41971
+ requestToProcess.addVariableOutputs(missingOutputVariables.length);
41972
+ missingOutputContractIds.forEach(({ contractId }) => {
41973
+ requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
41974
+ results[currentResultIndex].missingContractIds.push(contractId);
41975
+ });
41976
+ const { maxFee } = await this.estimateTxGasAndFee({
41977
+ transactionRequest: requestToProcess,
41978
+ optimizeGas: false
41979
+ });
41980
+ requestToProcess.maxFee = maxFee;
41981
+ serializedTransactionsMap.set(
41982
+ currentResultIndex,
41983
+ hexlify(requestToProcess.toTransactionBytes())
41984
+ );
41985
+ nextRoundTransactions.push(currentResultIndex);
41986
+ allRequests[currentResultIndex] = requestToProcess;
41987
+ }
41988
+ }
41989
+ transactionsToProcess = nextRoundTransactions;
41990
+ attempt += 1;
41991
+ }
41992
+ return results;
41993
+ }
41994
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
41995
+ if (estimateTxDependencies) {
41996
+ return this.estimateMultipleTxDependencies(transactionRequests);
41997
+ }
41998
+ const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
41999
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42000
+ encodedTransactions,
42001
+ utxoValidation: utxoValidation || false
42002
+ });
42003
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
42004
+ const receipts = rawReceipts.map(processGqlReceipt);
42005
+ return { receipts, dryrunStatus: status };
42006
+ });
42007
+ return results;
42008
+ }
42009
+ async estimateTxGasAndFee(params) {
42010
+ const { transactionRequest, optimizeGas = true } = params;
42011
+ let { gasPrice } = params;
41812
42012
  const chainInfo = this.getChain();
41813
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41814
- transactionRequest.gasPrice = gasPrice;
42013
+ const { gasPriceFactor } = this.getGasConfig();
41815
42014
  const minGas = transactionRequest.calculateMinGas(chainInfo);
41816
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42015
+ if (!gasPrice) {
42016
+ gasPrice = await this.estimateGasPrice(10);
42017
+ }
42018
+ const minFee = calculateGasFee({
42019
+ gasPrice: bn(gasPrice),
42020
+ gas: minGas,
42021
+ priceFactor: gasPriceFactor,
42022
+ tip: transactionRequest.tip
42023
+ }).add(1);
42024
+ let gasLimit = bn(0);
41817
42025
  if (transactionRequest.type === TransactionType.Script) {
41818
- if (transactionRequest.gasLimit.eq(0)) {
42026
+ gasLimit = transactionRequest.gasLimit;
42027
+ if (!optimizeGas) {
41819
42028
  transactionRequest.gasLimit = minGas;
41820
- transactionRequest.gasLimit = maxGasPerTx.sub(
41821
- transactionRequest.calculateMaxGas(chainInfo, minGas)
41822
- );
42029
+ gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
42030
+ transactionRequest.gasLimit = gasLimit;
41823
42031
  }
41824
42032
  }
41825
42033
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41826
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42034
+ const maxFee = calculateGasFee({
42035
+ gasPrice: bn(gasPrice),
42036
+ gas: maxGas,
42037
+ priceFactor: gasPriceFactor,
42038
+ tip: transactionRequest.tip
42039
+ }).add(1);
41827
42040
  return {
41828
42041
  minGas,
41829
42042
  minFee,
41830
42043
  maxGas,
41831
- maxFee
42044
+ maxFee,
42045
+ gasPrice,
42046
+ gasLimit
41832
42047
  };
41833
42048
  }
41834
42049
  /**
@@ -41846,15 +42061,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41846
42061
  if (estimateTxDependencies) {
41847
42062
  return this.estimateTxDependencies(transactionRequest);
41848
42063
  }
41849
- const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41850
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41851
- encodedTransaction,
42064
+ const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
42065
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42066
+ encodedTransactions,
41852
42067
  utxoValidation: true
41853
42068
  });
41854
- const receipts = gqlReceipts.map(processGqlReceipt);
41855
- return {
41856
- receipts
41857
- };
42069
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
42070
+ const { id, receipts, status } = dryRunStatus;
42071
+ const processedReceipts = receipts.map(processGqlReceipt);
42072
+ return { id, receipts: processedReceipts, status };
42073
+ });
42074
+ return { receipts: callResult[0].receipts };
41858
42075
  }
41859
42076
  /**
41860
42077
  * Returns a transaction cost to enable user
@@ -41871,77 +42088,80 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41871
42088
  * @param tolerance - The tolerance to add on top of the gasUsed.
41872
42089
  * @returns A promise that resolves to the transaction cost object.
41873
42090
  */
41874
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
41875
- estimateTxDependencies = true,
41876
- estimatePredicates = true,
41877
- resourcesOwner,
41878
- signatureCallback
41879
- } = {}) {
42091
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
41880
42092
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41881
- const { minGasPrice } = this.getGasConfig();
41882
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41883
42093
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41884
42094
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41885
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
42095
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
41886
42096
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
42097
+ txRequestClone.maxFee = bn(0);
41887
42098
  if (isScriptTransaction) {
41888
42099
  txRequestClone.gasLimit = bn(0);
41889
42100
  }
41890
- if (estimatePredicates) {
41891
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41892
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
41893
- }
41894
- await this.estimatePredicates(txRequestClone);
42101
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
42102
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
41895
42103
  }
42104
+ const signedRequest = clone_default(txRequestClone);
42105
+ let addedSignatures = 0;
41896
42106
  if (signatureCallback && isScriptTransaction) {
41897
- await signatureCallback(txRequestClone);
41898
- }
41899
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41900
- transactionRequest: txRequestClone
42107
+ const lengthBefore = signedRequest.witnesses.length;
42108
+ await signatureCallback(signedRequest);
42109
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
42110
+ }
42111
+ await this.estimatePredicates(signedRequest);
42112
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
42113
+ transactionRequest: signedRequest,
42114
+ optimizeGas: false
41901
42115
  });
42116
+ txRequestClone.maxFee = maxFee;
41902
42117
  let receipts = [];
41903
42118
  let missingContractIds = [];
41904
42119
  let outputVariables = 0;
41905
42120
  let gasUsed = bn(0);
41906
- if (isScriptTransaction && estimateTxDependencies) {
41907
- txRequestClone.gasPrice = bn(0);
42121
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
42122
+ if (isScriptTransaction) {
42123
+ if (signatureCallback) {
42124
+ await signatureCallback(txRequestClone);
42125
+ }
42126
+ txRequestClone.gasLimit = gasLimit;
41908
42127
  const result = await this.estimateTxDependencies(txRequestClone);
41909
42128
  receipts = result.receipts;
41910
42129
  outputVariables = result.outputVariables;
41911
42130
  missingContractIds = result.missingContractIds;
41912
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
42131
+ gasUsed = getGasUsedFromReceipts(receipts);
41913
42132
  txRequestClone.gasLimit = gasUsed;
41914
- txRequestClone.gasPrice = setGasPrice;
41915
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41916
- transactionRequest: txRequestClone
42133
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
42134
+ transactionRequest: txRequestClone,
42135
+ gasPrice
41917
42136
  }));
41918
42137
  }
41919
42138
  return {
41920
42139
  requiredQuantities: allQuantities,
41921
42140
  receipts,
41922
42141
  gasUsed,
41923
- minGasPrice,
41924
- gasPrice: setGasPrice,
42142
+ gasPrice,
41925
42143
  minGas,
41926
42144
  maxGas,
41927
42145
  minFee,
41928
42146
  maxFee,
41929
- estimatedInputs: txRequestClone.inputs,
41930
42147
  outputVariables,
41931
- missingContractIds
42148
+ missingContractIds,
42149
+ addedSignatures,
42150
+ estimatedPredicates: txRequestClone.inputs
41932
42151
  };
41933
42152
  }
41934
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
42153
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
41935
42154
  const ownerAddress = Address.fromAddressOrString(owner);
41936
42155
  const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
41937
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
42156
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
42157
+ quantitiesToContract
42158
+ });
41938
42159
  transactionRequest.addResources(
41939
42160
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
41940
42161
  );
41941
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
41942
- transactionRequest,
41943
- forwardingQuantities
41944
- );
42162
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
42163
+ quantitiesToContract
42164
+ });
41945
42165
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
41946
42166
  return {
41947
42167
  resources,
@@ -41965,7 +42185,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41965
42185
  assetId: coin.assetId,
41966
42186
  amount: bn(coin.amount),
41967
42187
  owner: Address.fromAddressOrString(coin.owner),
41968
- maturity: bn(coin.maturity).toNumber(),
41969
42188
  blockCreated: bn(coin.blockCreated),
41970
42189
  txCreatedIdx: bn(coin.txCreatedIdx)
41971
42190
  }));
@@ -42017,7 +42236,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42017
42236
  amount: bn(coin.amount),
42018
42237
  assetId: coin.assetId,
42019
42238
  owner: Address.fromAddressOrString(coin.owner),
42020
- maturity: bn(coin.maturity).toNumber(),
42021
42239
  blockCreated: bn(coin.blockCreated),
42022
42240
  txCreatedIdx: bn(coin.txCreatedIdx)
42023
42241
  };
@@ -42050,7 +42268,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42050
42268
  }
42051
42269
  return {
42052
42270
  id: block2.id,
42053
- height: bn(block2.header.height),
42271
+ height: bn(block2.height),
42054
42272
  time: block2.header.time,
42055
42273
  transactionIds: block2.transactions.map((tx) => tx.id)
42056
42274
  };
@@ -42065,7 +42283,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42065
42283
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
42066
42284
  const blocks = fetchedData.edges.map(({ node: block2 }) => ({
42067
42285
  id: block2.id,
42068
- height: bn(block2.header.height),
42286
+ height: bn(block2.height),
42069
42287
  time: block2.header.time,
42070
42288
  transactionIds: block2.transactions.map((tx) => tx.id)
42071
42289
  }));
@@ -42092,7 +42310,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42092
42310
  }
42093
42311
  return {
42094
42312
  id: block2.id,
42095
- height: bn(block2.header.height, 10),
42313
+ height: bn(block2.height, 10),
42096
42314
  time: block2.header.time,
42097
42315
  transactionIds: block2.transactions.map((tx) => tx.id),
42098
42316
  transactions: block2.transactions.map(
@@ -42272,7 +42490,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42272
42490
  prevRoot: messageBlockHeader.prevRoot,
42273
42491
  time: messageBlockHeader.time,
42274
42492
  applicationHash: messageBlockHeader.applicationHash,
42275
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
42276
42493
  messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
42277
42494
  },
42278
42495
  commitBlockHeader: {
@@ -42284,7 +42501,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42284
42501
  prevRoot: commitBlockHeader.prevRoot,
42285
42502
  time: commitBlockHeader.time,
42286
42503
  applicationHash: commitBlockHeader.applicationHash,
42287
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
42288
42504
  messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
42289
42505
  },
42290
42506
  sender: Address.fromAddressOrString(sender),
@@ -42294,6 +42510,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42294
42510
  data
42295
42511
  };
42296
42512
  }
42513
+ async getLatestGasPrice() {
42514
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
42515
+ return bn(latestGasPrice.gasPrice);
42516
+ }
42517
+ async estimateGasPrice(blockHorizon) {
42518
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
42519
+ blockHorizon: String(blockHorizon)
42520
+ });
42521
+ return bn(estimateGasPrice.gasPrice);
42522
+ }
42297
42523
  /**
42298
42524
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
42299
42525
  *
@@ -42354,10 +42580,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42354
42580
  arrayify(gqlTransaction.rawPayload),
42355
42581
  0
42356
42582
  );
42357
- const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
42583
+ let txReceipts = [];
42584
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42585
+ txReceipts = gqlTransaction.status.receipts;
42586
+ }
42587
+ const receipts = txReceipts.map(processGqlReceipt);
42358
42588
  const {
42359
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42589
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42360
42590
  } = provider.getChain();
42591
+ const gasPrice = await provider.getLatestGasPrice();
42361
42592
  const transactionInfo = assembleTransactionSummary({
42362
42593
  id: gqlTransaction.id,
42363
42594
  receipts,
@@ -42368,7 +42599,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42368
42599
  gasPriceFactor: bn(gasPriceFactor),
42369
42600
  abiMap,
42370
42601
  maxInputs,
42371
- gasCosts
42602
+ gasCosts,
42603
+ maxGasPerTx,
42604
+ gasPrice
42372
42605
  });
42373
42606
  return {
42374
42607
  gqlTransaction,
@@ -42378,10 +42611,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42378
42611
  async function getTransactionSummaryFromRequest(params) {
42379
42612
  const { provider, transactionRequest, abiMap } = params;
42380
42613
  const { receipts } = await provider.call(transactionRequest);
42381
- const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
42614
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
42382
42615
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
42383
42616
  const transaction = transactionRequest.toTransaction();
42384
42617
  const transactionBytes = transactionRequest.toTransactionBytes();
42618
+ const gasPrice = await provider.getLatestGasPrice();
42385
42619
  const transactionSummary = assembleTransactionSummary({
42386
42620
  receipts,
42387
42621
  transaction,
@@ -42390,7 +42624,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42390
42624
  gasPerByte,
42391
42625
  gasPriceFactor,
42392
42626
  maxInputs,
42393
- gasCosts
42627
+ gasCosts,
42628
+ maxGasPerTx,
42629
+ gasPrice
42394
42630
  });
42395
42631
  return transactionSummary;
42396
42632
  }
@@ -42399,13 +42635,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42399
42635
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
42400
42636
  const { edges, pageInfo } = transactionsByOwner;
42401
42637
  const {
42402
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42638
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42403
42639
  } = provider.getChain();
42640
+ const gasPrice = await provider.getLatestGasPrice();
42404
42641
  const transactions = edges.map((edge) => {
42405
42642
  const { node: gqlTransaction } = edge;
42406
- const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
42643
+ const { id, rawPayload, status } = gqlTransaction;
42407
42644
  const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
42408
- const receipts = gqlReceipts?.map(processGqlReceipt) || [];
42645
+ let txReceipts = [];
42646
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42647
+ txReceipts = gqlTransaction.status.receipts;
42648
+ }
42649
+ const receipts = txReceipts.map(processGqlReceipt);
42409
42650
  const transactionSummary = assembleTransactionSummary({
42410
42651
  id,
42411
42652
  receipts,
@@ -42416,7 +42657,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42416
42657
  gasPerByte,
42417
42658
  gasPriceFactor,
42418
42659
  maxInputs,
42419
- gasCosts
42660
+ gasCosts,
42661
+ maxGasPerTx,
42662
+ gasPrice
42420
42663
  });
42421
42664
  const output3 = {
42422
42665
  gqlTransaction,
@@ -42745,36 +42988,33 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42745
42988
  * @param fee - The estimated transaction fee.
42746
42989
  * @returns A promise that resolves when the resources are added to the transaction.
42747
42990
  */
42748
- async fund(request, coinQuantities, fee) {
42749
- const updatedQuantities = addAmountToAsset({
42991
+ async fund(request, params) {
42992
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
42993
+ const txRequest = request;
42994
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
42750
42995
  amount: bn(fee),
42751
42996
  assetId: BaseAssetId,
42752
- coinQuantities
42997
+ coinQuantities: requiredQuantities
42753
42998
  });
42754
42999
  const quantitiesDict = {};
42755
- updatedQuantities.forEach(({ amount, assetId }) => {
43000
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
42756
43001
  quantitiesDict[assetId] = {
42757
43002
  required: amount,
42758
43003
  owned: bn(0)
42759
43004
  };
42760
43005
  });
42761
- const cachedUtxos = [];
42762
- const cachedMessages = [];
42763
- const owner = this.address.toB256();
42764
- request.inputs.forEach((input) => {
43006
+ txRequest.inputs.forEach((input) => {
42765
43007
  const isResource = "amount" in input;
42766
43008
  if (isResource) {
42767
43009
  const isCoin2 = "owner" in input;
42768
43010
  if (isCoin2) {
42769
43011
  const assetId = String(input.assetId);
42770
- if (input.owner === owner && quantitiesDict[assetId]) {
43012
+ if (quantitiesDict[assetId]) {
42771
43013
  const amount = bn(input.amount);
42772
43014
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42773
- cachedUtxos.push(input.id);
42774
43015
  }
42775
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
43016
+ } else if (input.amount && quantitiesDict[BaseAssetId]) {
42776
43017
  quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42777
- cachedMessages.push(input.nonce);
42778
43018
  }
42779
43019
  }
42780
43020
  });
@@ -42789,12 +43029,23 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42789
43029
  });
42790
43030
  const needsToBeFunded = missingQuantities.length;
42791
43031
  if (needsToBeFunded) {
42792
- const resources = await this.getResourcesToSpend(missingQuantities, {
42793
- messages: cachedMessages,
42794
- utxos: cachedUtxos
42795
- });
42796
- request.addResources(resources);
43032
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
43033
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
43034
+ txRequest.addResources(resources);
43035
+ }
43036
+ txRequest.shiftPredicateData();
43037
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
43038
+ const requestToBeReEstimate = clone_default(txRequest);
43039
+ if (addedSignatures) {
43040
+ Array.from({ length: addedSignatures }).forEach(
43041
+ () => requestToBeReEstimate.addEmptyWitness()
43042
+ );
42797
43043
  }
43044
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
43045
+ transactionRequest: requestToBeReEstimate
43046
+ });
43047
+ txRequest.maxFee = maxFee;
43048
+ return txRequest;
42798
43049
  }
42799
43050
  /**
42800
43051
  * A helper that creates a transfer transaction request and returns it.
@@ -42802,28 +43053,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42802
43053
  * @param destination - The address of the destination.
42803
43054
  * @param amount - The amount of coins to transfer.
42804
43055
  * @param assetId - The asset ID of the coins to transfer.
42805
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
43056
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
42806
43057
  * @returns A promise that resolves to the prepared transaction request.
42807
43058
  */
42808
43059
  async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42809
- const { minGasPrice } = this.provider.getGasConfig();
42810
- const params = { gasPrice: minGasPrice, ...txParams };
42811
- const request = new ScriptTransactionRequest(params);
43060
+ const request = new ScriptTransactionRequest(txParams);
42812
43061
  request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42813
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
43062
+ const txCost = await this.provider.getTransactionCost(request, {
42814
43063
  estimateTxDependencies: true,
42815
43064
  resourcesOwner: this
42816
43065
  });
42817
- request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
42818
- request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
42819
- this.validateGas({
42820
- gasUsed,
42821
- gasPrice: request.gasPrice,
42822
- gasLimit: request.gasLimit,
42823
- minGasPrice
42824
- });
42825
- await this.fund(request, requiredQuantities, maxFee);
42826
- request.updatePredicateInputs(estimatedInputs);
43066
+ if ("gasLimit" in txParams) {
43067
+ this.validateGas({
43068
+ gasUsed: txCost.gasUsed,
43069
+ gasLimit: request.gasLimit
43070
+ });
43071
+ }
43072
+ request.gasLimit = txCost.gasUsed;
43073
+ request.maxFee = txCost.maxFee;
43074
+ await this.fund(request, txCost);
42827
43075
  return request;
42828
43076
  }
42829
43077
  /**
@@ -42862,31 +43110,30 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42862
43110
  );
42863
43111
  }
42864
43112
  const contractAddress = Address.fromAddressOrString(contractId);
42865
- const { minGasPrice } = this.provider.getGasConfig();
42866
- const params = { gasPrice: minGasPrice, ...txParams };
42867
43113
  const { script, scriptData } = await assembleTransferToContractScript({
42868
43114
  hexlifiedContractId: contractAddress.toB256(),
42869
43115
  amountToTransfer: bn(amount),
42870
43116
  assetId
42871
43117
  });
42872
43118
  const request = new ScriptTransactionRequest({
42873
- ...params,
43119
+ ...txParams,
42874
43120
  script,
42875
43121
  scriptData
42876
43122
  });
42877
43123
  request.addContractInputAndOutput(contractAddress);
42878
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42879
- request,
42880
- [{ amount: bn(amount), assetId: String(assetId) }]
42881
- );
42882
- request.gasLimit = bn(params.gasLimit ?? gasUsed);
42883
- this.validateGas({
42884
- gasUsed,
42885
- gasPrice: request.gasPrice,
42886
- gasLimit: request.gasLimit,
42887
- minGasPrice
43124
+ const txCost = await this.provider.getTransactionCost(request, {
43125
+ resourcesOwner: this,
43126
+ quantitiesToContract: [{ amount: bn(amount), assetId: String(assetId) }]
42888
43127
  });
42889
- await this.fund(request, requiredQuantities, maxFee);
43128
+ if (txParams.gasLimit) {
43129
+ this.validateGas({
43130
+ gasUsed: txCost.gasUsed,
43131
+ gasLimit: request.gasLimit
43132
+ });
43133
+ }
43134
+ request.gasLimit = txCost.gasUsed;
43135
+ request.maxFee = txCost.maxFee;
43136
+ await this.fund(request, txCost);
42890
43137
  return this.sendTransaction(request);
42891
43138
  }
42892
43139
  /**
@@ -42898,7 +43145,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42898
43145
  * @returns A promise that resolves to the transaction response.
42899
43146
  */
42900
43147
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42901
- const { minGasPrice } = this.provider.getGasConfig();
42902
43148
  const recipientAddress = Address.fromAddressOrString(recipient);
42903
43149
  const recipientDataArray = arrayify(
42904
43150
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42911,21 +43157,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42911
43157
  ...recipientDataArray,
42912
43158
  ...amountDataArray
42913
43159
  ]);
42914
- const params = { script, gasPrice: minGasPrice, ...txParams };
43160
+ const params = { script, ...txParams };
42915
43161
  const request = new ScriptTransactionRequest(params);
42916
- const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42917
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42918
- request,
42919
- forwardingQuantities
42920
- );
42921
- request.gasLimit = bn(params.gasLimit ?? gasUsed);
42922
- this.validateGas({
42923
- gasUsed,
42924
- gasPrice: request.gasPrice,
42925
- gasLimit: request.gasLimit,
42926
- minGasPrice
42927
- });
42928
- await this.fund(request, requiredQuantities, maxFee);
43162
+ const quantitiesToContract = [{ amount: bn(amount), assetId: BaseAssetId }];
43163
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
43164
+ if (txParams.gasLimit) {
43165
+ this.validateGas({
43166
+ gasUsed: txCost.gasUsed,
43167
+ gasLimit: request.gasLimit
43168
+ });
43169
+ }
43170
+ request.maxFee = txCost.maxFee;
43171
+ request.gasLimit = txCost.gasUsed;
43172
+ await this.fund(request, txCost);
42929
43173
  return this.sendTransaction(request);
42930
43174
  }
42931
43175
  async signMessage(message) {
@@ -42983,18 +43227,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42983
43227
  }
42984
43228
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
42985
43229
  }
42986
- validateGas({
42987
- gasUsed,
42988
- gasPrice,
42989
- gasLimit,
42990
- minGasPrice
42991
- }) {
42992
- if (minGasPrice.gt(gasPrice)) {
42993
- throw new FuelError(
42994
- ErrorCode.GAS_PRICE_TOO_LOW,
42995
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
42996
- );
42997
- }
43230
+ validateGas({ gasUsed, gasLimit }) {
42998
43231
  if (gasUsed.gt(gasLimit)) {
42999
43232
  throw new FuelError(
43000
43233
  ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -44583,7 +44816,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44583
44816
  * @param transactionRequestLike - The transaction request to send.
44584
44817
  * @returns A promise that resolves to the TransactionResponse object.
44585
44818
  */
44586
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
44819
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
44587
44820
  const transactionRequest = transactionRequestify(transactionRequestLike);
44588
44821
  if (estimateTxDependencies) {
44589
44822
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -47861,8 +48094,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47861
48094
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
47862
48095
  request.inputs?.forEach((input) => {
47863
48096
  if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
47864
- input.predicate = this.bytes;
47865
- input.predicateData = this.getPredicateData(policies.length);
48097
+ input.predicate = hexlify(this.bytes);
48098
+ input.predicateData = hexlify(this.getPredicateData(policies.length));
47866
48099
  }
47867
48100
  });
47868
48101
  return request;
@@ -47877,8 +48110,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47877
48110
  * @returns A promise that resolves to the prepared transaction request.
47878
48111
  */
47879
48112
  async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47880
- const request = await super.createTransfer(destination, amount, assetId, txParams);
47881
- return this.populateTransactionPredicateData(request);
48113
+ return super.createTransfer(destination, amount, assetId, txParams);
47882
48114
  }
47883
48115
  /**
47884
48116
  * Sends a transaction with the populated predicate data.
@@ -47886,9 +48118,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47886
48118
  * @param transactionRequestLike - The transaction request-like object.
47887
48119
  * @returns A promise that resolves to the transaction response.
47888
48120
  */
47889
- sendTransaction(transactionRequestLike, options) {
47890
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47891
- return super.sendTransaction(transactionRequest, options);
48121
+ sendTransaction(transactionRequestLike) {
48122
+ const transactionRequest = transactionRequestify(transactionRequestLike);
48123
+ return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
47892
48124
  }
47893
48125
  /**
47894
48126
  * Simulates a transaction with the populated predicate data.
@@ -47897,8 +48129,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47897
48129
  * @returns A promise that resolves to the call result.
47898
48130
  */
47899
48131
  simulateTransaction(transactionRequestLike) {
47900
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47901
- return super.simulateTransaction(transactionRequest);
48132
+ const transactionRequest = transactionRequestify(transactionRequestLike);
48133
+ return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
47902
48134
  }
47903
48135
  getPredicateData(policiesLength) {
47904
48136
  if (!this.predicateData.length) {
@@ -47944,6 +48176,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47944
48176
  predicateInterface: abiInterface
47945
48177
  };
47946
48178
  }
48179
+ /**
48180
+ * Retrieves resources satisfying the spend query for the account.
48181
+ *
48182
+ * @param quantities - IDs of coins to exclude.
48183
+ * @param excludedIds - IDs of resources to be excluded from the query.
48184
+ * @returns A promise that resolves to an array of Resources.
48185
+ */
48186
+ async getResourcesToSpend(quantities, excludedIds) {
48187
+ const resources = await this.provider.getResourcesToSpend(
48188
+ this.address,
48189
+ quantities,
48190
+ excludedIds
48191
+ );
48192
+ return resources.map((resource) => ({
48193
+ ...resource,
48194
+ predicate: hexlify(this.bytes),
48195
+ paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
48196
+ }));
48197
+ }
47947
48198
  /**
47948
48199
  * Sets the configurable constants for the predicate.
47949
48200
  *