@fuel-ts/account 0.0.0-rc-2034-20240415163000 → 0.0.0-rc-2021-20240415193305

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 +795 -544
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +762 -507
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +642 -388
  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 +906 -324
  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 +7 -1
  27. package/dist/providers/message.d.ts.map +1 -1
  28. package/dist/providers/provider.d.ts +37 -27
  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 +1545 -1056
  48. package/dist/test-utils.global.js.map +1 -1
  49. package/dist/test-utils.js +740 -503
  50. package/dist/test-utils.js.map +1 -1
  51. package/dist/test-utils.mjs +634 -397
  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
@@ -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,9 +28952,9 @@ 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",
28957
- FUELS: "0.79.0"
28955
+ FORC: "0.51.1",
28956
+ FUEL_CORE: "0.24.2",
28957
+ FUELS: "0.80.0"
28958
28958
  };
28959
28959
  }
28960
28960
  function parseVersion(version2) {
@@ -31495,10 +31495,160 @@ This unreleased fuel-core build may include features and updates not yet support
31495
31495
  function toBytes3(value, bytesPadding) {
31496
31496
  return bn(value).toBytes(bytesPadding);
31497
31497
  }
31498
- function max(...numbers) {
31499
- return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
31498
+
31499
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
31500
+ function _isPlaceholder(a) {
31501
+ return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
31502
+ }
31503
+
31504
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
31505
+ function _curry1(fn) {
31506
+ return function f1(a) {
31507
+ if (arguments.length === 0 || _isPlaceholder(a)) {
31508
+ return f1;
31509
+ } else {
31510
+ return fn.apply(this, arguments);
31511
+ }
31512
+ };
31513
+ }
31514
+
31515
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
31516
+ var isArray_default = Array.isArray || function _isArray(val) {
31517
+ return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
31518
+ };
31519
+
31520
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
31521
+ var type = /* @__PURE__ */ _curry1(function type2(val) {
31522
+ return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
31523
+ });
31524
+ var type_default = type;
31525
+
31526
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
31527
+ var pad = function pad2(n) {
31528
+ return (n < 10 ? "0" : "") + n;
31529
+ };
31530
+ var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
31531
+ return d.toISOString();
31532
+ } : function _toISOString3(d) {
31533
+ 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";
31534
+ };
31535
+
31536
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
31537
+ var isInteger_default = Number.isInteger || function _isInteger(n) {
31538
+ return n << 0 === n;
31539
+ };
31540
+
31541
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
31542
+ function _cloneRegExp(pattern) {
31543
+ 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" : ""));
31500
31544
  }
31501
31545
 
31546
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
31547
+ function _clone(value, deep, map) {
31548
+ map || (map = new _ObjectMap());
31549
+ if (_isPrimitive(value)) {
31550
+ return value;
31551
+ }
31552
+ var copy = function copy2(copiedValue) {
31553
+ var cachedCopy = map.get(value);
31554
+ if (cachedCopy) {
31555
+ return cachedCopy;
31556
+ }
31557
+ map.set(value, copiedValue);
31558
+ for (var key in value) {
31559
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
31560
+ copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
31561
+ }
31562
+ }
31563
+ return copiedValue;
31564
+ };
31565
+ switch (type_default(value)) {
31566
+ case "Object":
31567
+ return copy(Object.create(Object.getPrototypeOf(value)));
31568
+ case "Array":
31569
+ return copy([]);
31570
+ case "Date":
31571
+ return new Date(value.valueOf());
31572
+ case "RegExp":
31573
+ return _cloneRegExp(value);
31574
+ case "Int8Array":
31575
+ case "Uint8Array":
31576
+ case "Uint8ClampedArray":
31577
+ case "Int16Array":
31578
+ case "Uint16Array":
31579
+ case "Int32Array":
31580
+ case "Uint32Array":
31581
+ case "Float32Array":
31582
+ case "Float64Array":
31583
+ case "BigInt64Array":
31584
+ case "BigUint64Array":
31585
+ return value.slice();
31586
+ default:
31587
+ return value;
31588
+ }
31589
+ }
31590
+ function _isPrimitive(param) {
31591
+ var type3 = typeof param;
31592
+ return param == null || type3 != "object" && type3 != "function";
31593
+ }
31594
+ var _ObjectMap = /* @__PURE__ */ function() {
31595
+ function _ObjectMap2() {
31596
+ this.map = {};
31597
+ this.length = 0;
31598
+ }
31599
+ _ObjectMap2.prototype.set = function(key, value) {
31600
+ const hashedKey = this.hash(key);
31601
+ let bucket = this.map[hashedKey];
31602
+ if (!bucket) {
31603
+ this.map[hashedKey] = bucket = [];
31604
+ }
31605
+ bucket.push([key, value]);
31606
+ this.length += 1;
31607
+ };
31608
+ _ObjectMap2.prototype.hash = function(key) {
31609
+ let hashedKey = [];
31610
+ for (var value in key) {
31611
+ hashedKey.push(Object.prototype.toString.call(key[value]));
31612
+ }
31613
+ return hashedKey.join();
31614
+ };
31615
+ _ObjectMap2.prototype.get = function(key) {
31616
+ if (this.length <= 180) {
31617
+ for (const p in this.map) {
31618
+ const bucket2 = this.map[p];
31619
+ for (let i = 0; i < bucket2.length; i += 1) {
31620
+ const element = bucket2[i];
31621
+ if (element[0] === key) {
31622
+ return element[1];
31623
+ }
31624
+ }
31625
+ }
31626
+ return;
31627
+ }
31628
+ const hashedKey = this.hash(key);
31629
+ const bucket = this.map[hashedKey];
31630
+ if (!bucket) {
31631
+ return;
31632
+ }
31633
+ for (let i = 0; i < bucket.length; i += 1) {
31634
+ const element = bucket[i];
31635
+ if (element[0] === key) {
31636
+ return element[1];
31637
+ }
31638
+ }
31639
+ };
31640
+ return _ObjectMap2;
31641
+ }();
31642
+
31643
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
31644
+ var clone = /* @__PURE__ */ _curry1(function clone2(value) {
31645
+ return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
31646
+ });
31647
+ var clone_default = clone;
31648
+
31649
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
31650
+ var hasProtoTrim = typeof String.prototype.trim === "function";
31651
+
31502
31652
  // src/providers/coin-quantity.ts
31503
31653
  var coinQuantityfy = (coinQuantityLike) => {
31504
31654
  let assetId;
@@ -31520,7 +31670,7 @@ This unreleased fuel-core build may include features and updates not yet support
31520
31670
  max: max2 ? bn(max2) : void 0
31521
31671
  };
31522
31672
  };
31523
- var addAmountToAsset = (params) => {
31673
+ var addAmountToCoinQuantities = (params) => {
31524
31674
  const { amount, assetId } = params;
31525
31675
  const coinQuantities = [...params.coinQuantities];
31526
31676
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -31605,7 +31755,7 @@ This unreleased fuel-core build may include features and updates not yet support
31605
31755
  var ENCODING_V1 = "1";
31606
31756
  var WORD_SIZE = 8;
31607
31757
  var BYTES_32 = 32;
31608
- var UTXO_ID_LEN = BYTES_32 + 1;
31758
+ var UTXO_ID_LEN = BYTES_32 + 2;
31609
31759
  var ASSET_ID_LEN = BYTES_32;
31610
31760
  var ADDRESS_LEN = BYTES_32;
31611
31761
  var NONCE_LEN = BYTES_32;
@@ -31613,9 +31763,9 @@ This unreleased fuel-core build may include features and updates not yet support
31613
31763
  var TX_POINTER_LEN = WORD_SIZE * 2;
31614
31764
  var MAX_BYTES = 2 ** 32 - 1;
31615
31765
  var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
31616
- WORD_SIZE + // Tx size
31766
+ ASSET_ID_LEN + // Base asset ID
31617
31767
  // Asset ID/Balance coin input pairs
31618
- maxInputs * (ASSET_ID_LEN + WORD_SIZE);
31768
+ maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
31619
31769
  var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
31620
31770
  WORD_SIZE + // Gas limit
31621
31771
  WORD_SIZE + // Script size
@@ -31633,7 +31783,6 @@ This unreleased fuel-core build may include features and updates not yet support
31633
31783
  ASSET_ID_LEN + // Asset id
31634
31784
  TX_POINTER_LEN + // TxPointer
31635
31785
  WORD_SIZE + // Witnesses index
31636
- WORD_SIZE + // Maturity
31637
31786
  WORD_SIZE + // Predicate size
31638
31787
  WORD_SIZE + // Predicate data size
31639
31788
  WORD_SIZE;
@@ -33371,18 +33520,19 @@ This unreleased fuel-core build may include features and updates not yet support
33371
33520
  encode(value) {
33372
33521
  const parts = [];
33373
33522
  parts.push(new B256Coder().encode(value.txID));
33374
- parts.push(new NumberCoder("u8").encode(value.outputIndex));
33523
+ parts.push(new NumberCoder("u16").encode(value.outputIndex));
33375
33524
  parts.push(new B256Coder().encode(value.owner));
33376
33525
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33377
33526
  parts.push(new B256Coder().encode(value.assetId));
33378
33527
  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));
33528
+ parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33381
33529
  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));
33530
+ parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33531
+ parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33532
+ parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33533
+ parts.push(
33534
+ new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33535
+ );
33386
33536
  return concat(parts);
33387
33537
  }
33388
33538
  decode(data, offset) {
@@ -33390,7 +33540,7 @@ This unreleased fuel-core build may include features and updates not yet support
33390
33540
  let o = offset;
33391
33541
  [decoded, o] = new B256Coder().decode(data, o);
33392
33542
  const txID = decoded;
33393
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33543
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33394
33544
  const outputIndex = decoded;
33395
33545
  [decoded, o] = new B256Coder().decode(data, o);
33396
33546
  const owner = decoded;
@@ -33400,19 +33550,17 @@ This unreleased fuel-core build may include features and updates not yet support
33400
33550
  const assetId = decoded;
33401
33551
  [decoded, o] = new TxPointerCoder().decode(data, o);
33402
33552
  const txPointer = decoded;
33403
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33553
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33404
33554
  const witnessIndex = Number(decoded);
33405
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33406
- const maturity = decoded;
33407
33555
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33408
33556
  const predicateGasUsed = decoded;
33409
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33557
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33410
33558
  const predicateLength = decoded;
33411
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33559
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33412
33560
  const predicateDataLength = decoded;
33413
- [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33561
+ [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33414
33562
  const predicate = decoded;
33415
- [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33563
+ [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33416
33564
  const predicateData = decoded;
33417
33565
  return [
33418
33566
  {
@@ -33424,7 +33572,6 @@ This unreleased fuel-core build may include features and updates not yet support
33424
33572
  assetId,
33425
33573
  txPointer,
33426
33574
  witnessIndex,
33427
- maturity,
33428
33575
  predicateGasUsed,
33429
33576
  predicateLength,
33430
33577
  predicateDataLength,
@@ -33442,7 +33589,7 @@ This unreleased fuel-core build may include features and updates not yet support
33442
33589
  encode(value) {
33443
33590
  const parts = [];
33444
33591
  parts.push(new B256Coder().encode(value.txID));
33445
- parts.push(new NumberCoder("u8").encode(value.outputIndex));
33592
+ parts.push(new NumberCoder("u16").encode(value.outputIndex));
33446
33593
  parts.push(new B256Coder().encode(value.balanceRoot));
33447
33594
  parts.push(new B256Coder().encode(value.stateRoot));
33448
33595
  parts.push(new TxPointerCoder().encode(value.txPointer));
@@ -33454,7 +33601,7 @@ This unreleased fuel-core build may include features and updates not yet support
33454
33601
  let o = offset;
33455
33602
  [decoded, o] = new B256Coder().decode(data, o);
33456
33603
  const txID = decoded;
33457
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33604
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33458
33605
  const outputIndex = decoded;
33459
33606
  [decoded, o] = new B256Coder().decode(data, o);
33460
33607
  const balanceRoot = decoded;
@@ -33503,14 +33650,16 @@ This unreleased fuel-core build may include features and updates not yet support
33503
33650
  parts.push(new ByteArrayCoder(32).encode(value.recipient));
33504
33651
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33505
33652
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
33506
- parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33653
+ parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33507
33654
  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));
33655
+ parts.push(new BigNumberCoder("u64").encode(data.length));
33656
+ parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33657
+ parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33511
33658
  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));
33659
+ parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33660
+ parts.push(
33661
+ new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33662
+ );
33514
33663
  return concat(parts);
33515
33664
  }
33516
33665
  static decodeData(messageData) {
@@ -33530,21 +33679,21 @@ This unreleased fuel-core build may include features and updates not yet support
33530
33679
  const amount = decoded;
33531
33680
  [decoded, o] = new B256Coder().decode(data, o);
33532
33681
  const nonce = decoded;
33533
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33682
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33534
33683
  const witnessIndex = Number(decoded);
33535
33684
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33536
33685
  const predicateGasUsed = decoded;
33537
33686
  [decoded, o] = new NumberCoder("u32").decode(data, o);
33538
33687
  const dataLength2 = decoded;
33539
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33688
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33540
33689
  const predicateLength = decoded;
33541
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33690
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33542
33691
  const predicateDataLength = decoded;
33543
33692
  [decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
33544
33693
  const messageData = decoded;
33545
- [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33694
+ [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33546
33695
  const predicate = decoded;
33547
- [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33696
+ [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33548
33697
  const predicateData = decoded;
33549
33698
  return [
33550
33699
  {
@@ -33856,7 +34005,7 @@ This unreleased fuel-core build may include features and updates not yet support
33856
34005
  }
33857
34006
  };
33858
34007
  var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
33859
- PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
34008
+ PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
33860
34009
  PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
33861
34010
  PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
33862
34011
  PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
@@ -33904,9 +34053,9 @@ This unreleased fuel-core build may include features and updates not yet support
33904
34053
  let o = offset;
33905
34054
  const policies = [];
33906
34055
  if (policyTypes & 1) {
33907
- const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
34056
+ const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
33908
34057
  o = nextOffset;
33909
- policies.push({ type: 1, data: gasPrice });
34058
+ policies.push({ type: 1, data: tip });
33910
34059
  }
33911
34060
  if (policyTypes & 2) {
33912
34061
  const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
@@ -34138,15 +34287,15 @@ This unreleased fuel-core build may include features and updates not yet support
34138
34287
  encode(value) {
34139
34288
  const parts = [];
34140
34289
  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
34290
  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));
34291
+ parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
34292
+ parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
34293
+ parts.push(new NumberCoder("u32").encode(value.policyTypes));
34294
+ parts.push(new NumberCoder("u16").encode(value.inputsCount));
34295
+ parts.push(new NumberCoder("u16").encode(value.outputsCount));
34296
+ parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34297
+ parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
34298
+ parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
34150
34299
  parts.push(new PoliciesCoder().encode(value.policies));
34151
34300
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34152
34301
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
@@ -34158,23 +34307,23 @@ This unreleased fuel-core build may include features and updates not yet support
34158
34307
  let o = offset;
34159
34308
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34160
34309
  const scriptGasLimit = decoded;
34161
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34310
+ [decoded, o] = new B256Coder().decode(data, o);
34311
+ const receiptsRoot = decoded;
34312
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34162
34313
  const scriptLength = decoded;
34163
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34314
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34164
34315
  const scriptDataLength = decoded;
34165
34316
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34166
34317
  const policyTypes = decoded;
34167
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34318
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34168
34319
  const inputsCount = decoded;
34169
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34320
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34170
34321
  const outputsCount = decoded;
34171
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34322
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34172
34323
  const witnessesCount = decoded;
34173
- [decoded, o] = new B256Coder().decode(data, o);
34174
- const receiptsRoot = decoded;
34175
- [decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
34324
+ [decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
34176
34325
  const script = decoded;
34177
- [decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
34326
+ [decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
34178
34327
  const scriptData = decoded;
34179
34328
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34180
34329
  const policies = decoded;
@@ -34212,18 +34361,19 @@ This unreleased fuel-core build may include features and updates not yet support
34212
34361
  }
34213
34362
  encode(value) {
34214
34363
  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));
34364
+ parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
34222
34365
  parts.push(new B256Coder().encode(value.salt));
34223
- parts.push(new PoliciesCoder().encode(value.policies));
34366
+ parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
34367
+ parts.push(new NumberCoder("u32").encode(value.policyTypes));
34368
+ parts.push(new NumberCoder("u16").encode(value.inputsCount));
34369
+ parts.push(new NumberCoder("u16").encode(value.outputsCount));
34370
+ parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34224
34371
  parts.push(
34225
- new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
34372
+ new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
34373
+ value.storageSlots
34374
+ )
34226
34375
  );
34376
+ parts.push(new PoliciesCoder().encode(value.policies));
34227
34377
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34228
34378
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
34229
34379
  parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
@@ -34232,26 +34382,27 @@ This unreleased fuel-core build may include features and updates not yet support
34232
34382
  decode(data, offset) {
34233
34383
  let decoded;
34234
34384
  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);
34385
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34238
34386
  const bytecodeWitnessIndex = decoded;
34387
+ [decoded, o] = new B256Coder().decode(data, o);
34388
+ const salt = decoded;
34389
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34390
+ const storageSlotsCount = decoded;
34239
34391
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34240
34392
  const policyTypes = decoded;
34241
34393
  [decoded, o] = new NumberCoder("u16").decode(data, o);
34242
- const storageSlotsCount = decoded;
34243
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34244
34394
  const inputsCount = decoded;
34245
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34395
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34246
34396
  const outputsCount = decoded;
34247
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34397
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34248
34398
  const witnessesCount = decoded;
34249
- [decoded, o] = new B256Coder().decode(data, o);
34250
- const salt = decoded;
34399
+ [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
34400
+ data,
34401
+ o
34402
+ );
34403
+ const storageSlots = decoded;
34251
34404
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34252
34405
  const policies = decoded;
34253
- [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
34254
- const storageSlots = decoded;
34255
34406
  [decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
34256
34407
  const inputs = decoded;
34257
34408
  [decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
@@ -34261,7 +34412,6 @@ This unreleased fuel-core build may include features and updates not yet support
34261
34412
  return [
34262
34413
  {
34263
34414
  type: 1,
34264
- bytecodeLength,
34265
34415
  bytecodeWitnessIndex,
34266
34416
  policyTypes,
34267
34417
  storageSlotsCount,
@@ -34290,6 +34440,7 @@ This unreleased fuel-core build may include features and updates not yet support
34290
34440
  parts.push(new OutputContractCoder().encode(value.outputContract));
34291
34441
  parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
34292
34442
  parts.push(new B256Coder().encode(value.mintAssetId));
34443
+ parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
34293
34444
  return concat(parts);
34294
34445
  }
34295
34446
  decode(data, offset) {
@@ -34305,6 +34456,8 @@ This unreleased fuel-core build may include features and updates not yet support
34305
34456
  const mintAmount = decoded;
34306
34457
  [decoded, o] = new B256Coder().decode(data, o);
34307
34458
  const mintAssetId = decoded;
34459
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34460
+ const gasPrice = decoded;
34308
34461
  return [
34309
34462
  {
34310
34463
  type: 2,
@@ -34312,7 +34465,8 @@ This unreleased fuel-core build may include features and updates not yet support
34312
34465
  inputContract,
34313
34466
  outputContract,
34314
34467
  mintAmount,
34315
- mintAssetId
34468
+ mintAssetId,
34469
+ gasPrice
34316
34470
  },
34317
34471
  o
34318
34472
  ];
@@ -34619,159 +34773,6 @@ This unreleased fuel-core build may include features and updates not yet support
34619
34773
  // src/providers/provider.ts
34620
34774
  var import_graphql_request = __toESM(require_dist2());
34621
34775
 
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
34776
  // ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
34776
34777
  var __assign = function() {
34777
34778
  __assign = Object.assign || function __assign2(t) {
@@ -37939,14 +37940,10 @@ spurious results.`);
37939
37940
  // src/providers/__generated__/operations.ts
37940
37941
  var ReceiptFragmentFragmentDoc = lib_default2`
37941
37942
  fragment receiptFragment on Receipt {
37942
- contract {
37943
- id
37944
- }
37943
+ id
37945
37944
  pc
37946
37945
  is
37947
- to {
37948
- id
37949
- }
37946
+ to
37950
37947
  toAddress
37951
37948
  amount
37952
37949
  assetId
@@ -37984,10 +37981,16 @@ spurious results.`);
37984
37981
  id
37985
37982
  }
37986
37983
  time
37984
+ receipts {
37985
+ ...receiptFragment
37986
+ }
37987
37987
  programState {
37988
37988
  returnType
37989
37989
  data
37990
37990
  }
37991
+ receipts {
37992
+ ...receiptFragment
37993
+ }
37991
37994
  }
37992
37995
  ... on FailureStatus {
37993
37996
  block {
@@ -37995,26 +37998,24 @@ spurious results.`);
37995
37998
  }
37996
37999
  time
37997
38000
  reason
38001
+ receipts {
38002
+ ...receiptFragment
38003
+ }
37998
38004
  }
37999
38005
  ... on SqueezedOutStatus {
38000
38006
  reason
38001
38007
  }
38002
38008
  }
38003
- `;
38009
+ ${ReceiptFragmentFragmentDoc}`;
38004
38010
  var TransactionFragmentFragmentDoc = lib_default2`
38005
38011
  fragment transactionFragment on Transaction {
38006
38012
  id
38007
38013
  rawPayload
38008
- gasPrice
38009
- receipts {
38010
- ...receiptFragment
38011
- }
38012
38014
  status {
38013
38015
  ...transactionStatusFragment
38014
38016
  }
38015
38017
  }
38016
- ${ReceiptFragmentFragmentDoc}
38017
- ${TransactionStatusFragmentFragmentDoc}`;
38018
+ ${TransactionStatusFragmentFragmentDoc}`;
38018
38019
  var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
38019
38020
  fragment inputEstimatePredicatesFragment on Input {
38020
38021
  ... on InputCoin {
@@ -38032,6 +38033,46 @@ ${TransactionStatusFragmentFragmentDoc}`;
38032
38033
  }
38033
38034
  }
38034
38035
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
38036
+ var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
38037
+ fragment dryRunFailureStatusFragment on DryRunFailureStatus {
38038
+ reason
38039
+ programState {
38040
+ returnType
38041
+ data
38042
+ }
38043
+ }
38044
+ `;
38045
+ var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
38046
+ fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
38047
+ programState {
38048
+ returnType
38049
+ data
38050
+ }
38051
+ }
38052
+ `;
38053
+ var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
38054
+ fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
38055
+ ... on DryRunFailureStatus {
38056
+ ...dryRunFailureStatusFragment
38057
+ }
38058
+ ... on DryRunSuccessStatus {
38059
+ ...dryRunSuccessStatusFragment
38060
+ }
38061
+ }
38062
+ ${DryRunFailureStatusFragmentFragmentDoc}
38063
+ ${DryRunSuccessStatusFragmentFragmentDoc}`;
38064
+ var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
38065
+ fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
38066
+ id
38067
+ status {
38068
+ ...dryRunTransactionStatusFragment
38069
+ }
38070
+ receipts {
38071
+ ...receiptFragment
38072
+ }
38073
+ }
38074
+ ${DryRunTransactionStatusFragmentFragmentDoc}
38075
+ ${ReceiptFragmentFragmentDoc}`;
38035
38076
  var CoinFragmentFragmentDoc = lib_default2`
38036
38077
  fragment coinFragment on Coin {
38037
38078
  __typename
@@ -38039,7 +38080,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38039
38080
  owner
38040
38081
  amount
38041
38082
  assetId
38042
- maturity
38043
38083
  blockCreated
38044
38084
  txCreatedIdx
38045
38085
  }
@@ -38078,26 +38118,32 @@ ${TransactionStatusFragmentFragmentDoc}`;
38078
38118
  messageBlockHeader {
38079
38119
  id
38080
38120
  daHeight
38121
+ consensusParametersVersion
38122
+ stateTransitionBytecodeVersion
38081
38123
  transactionsCount
38124
+ messageReceiptCount
38082
38125
  transactionsRoot
38126
+ messageOutboxRoot
38127
+ eventInboxRoot
38083
38128
  height
38084
38129
  prevRoot
38085
38130
  time
38086
38131
  applicationHash
38087
- messageReceiptRoot
38088
- messageReceiptCount
38089
38132
  }
38090
38133
  commitBlockHeader {
38091
38134
  id
38092
38135
  daHeight
38136
+ consensusParametersVersion
38137
+ stateTransitionBytecodeVersion
38093
38138
  transactionsCount
38139
+ messageReceiptCount
38094
38140
  transactionsRoot
38141
+ messageOutboxRoot
38142
+ eventInboxRoot
38095
38143
  height
38096
38144
  prevRoot
38097
38145
  time
38098
38146
  applicationHash
38099
- messageReceiptRoot
38100
- messageReceiptCount
38101
38147
  }
38102
38148
  sender
38103
38149
  recipient
@@ -38116,8 +38162,8 @@ ${TransactionStatusFragmentFragmentDoc}`;
38116
38162
  var BlockFragmentFragmentDoc = lib_default2`
38117
38163
  fragment blockFragment on Block {
38118
38164
  id
38165
+ height
38119
38166
  header {
38120
- height
38121
38167
  time
38122
38168
  }
38123
38169
  transactions {
@@ -38175,6 +38221,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
38175
38221
  `;
38176
38222
  var GasCostsFragmentFragmentDoc = lib_default2`
38177
38223
  fragment GasCostsFragment on GasCosts {
38224
+ version {
38225
+ ... on Version {
38226
+ value
38227
+ }
38228
+ }
38178
38229
  add
38179
38230
  addi
38180
38231
  aloc
@@ -38187,7 +38238,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38187
38238
  cb
38188
38239
  cfei
38189
38240
  cfsi
38190
- croo
38191
38241
  div
38192
38242
  divi
38193
38243
  ecr1
@@ -38270,6 +38320,9 @@ ${TransactionStatusFragmentFragmentDoc}`;
38270
38320
  ccp {
38271
38321
  ...DependentCostFragment
38272
38322
  }
38323
+ croo {
38324
+ ...DependentCostFragment
38325
+ }
38273
38326
  csiz {
38274
38327
  ...DependentCostFragment
38275
38328
  }
@@ -38329,6 +38382,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
38329
38382
  ${DependentCostFragmentFragmentDoc}`;
38330
38383
  var ConsensusParametersFragmentFragmentDoc = lib_default2`
38331
38384
  fragment consensusParametersFragment on ConsensusParameters {
38385
+ version {
38386
+ ... on Version {
38387
+ value
38388
+ }
38389
+ }
38332
38390
  txParams {
38333
38391
  ...TxParametersFragment
38334
38392
  }
@@ -38388,18 +38446,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38388
38446
  fragment nodeInfoFragment on NodeInfo {
38389
38447
  utxoValidation
38390
38448
  vmBacktrace
38391
- minGasPrice
38392
38449
  maxTx
38393
38450
  maxDepth
38394
38451
  nodeVersion
38395
- peers {
38396
- id
38397
- addresses
38398
- clientVersion
38399
- blockHeight
38400
- lastHeartbeatMs
38401
- appScore
38402
- }
38403
38452
  }
38404
38453
  `;
38405
38454
  var GetVersionDocument = lib_default2`
@@ -38434,13 +38483,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38434
38483
  query getTransactionWithReceipts($transactionId: TransactionId!) {
38435
38484
  transaction(id: $transactionId) {
38436
38485
  ...transactionFragment
38437
- receipts {
38438
- ...receiptFragment
38439
- }
38440
38486
  }
38441
38487
  }
38442
- ${TransactionFragmentFragmentDoc}
38443
- ${ReceiptFragmentFragmentDoc}`;
38488
+ ${TransactionFragmentFragmentDoc}`;
38444
38489
  var GetTransactionsDocument = lib_default2`
38445
38490
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
38446
38491
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -38568,6 +38613,20 @@ ${MessageCoinFragmentFragmentDoc}`;
38568
38613
  }
38569
38614
  }
38570
38615
  ${BalanceFragmentFragmentDoc}`;
38616
+ var GetLatestGasPriceDocument = lib_default2`
38617
+ query getLatestGasPrice {
38618
+ latestGasPrice {
38619
+ gasPrice
38620
+ }
38621
+ }
38622
+ `;
38623
+ var EstimateGasPriceDocument = lib_default2`
38624
+ query estimateGasPrice($blockHorizon: U32!) {
38625
+ estimateGasPrice(blockHorizon: $blockHorizon) {
38626
+ gasPrice
38627
+ }
38628
+ }
38629
+ `;
38571
38630
  var GetBalancesDocument = lib_default2`
38572
38631
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
38573
38632
  balances(
@@ -38622,12 +38681,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38622
38681
  }
38623
38682
  `;
38624
38683
  var DryRunDocument = lib_default2`
38625
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
38626
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
38627
- ...receiptFragment
38684
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
38685
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
38686
+ ...dryRunTransactionExecutionStatusFragment
38628
38687
  }
38629
38688
  }
38630
- ${ReceiptFragmentFragmentDoc}`;
38689
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
38631
38690
  var SubmitDocument = lib_default2`
38632
38691
  mutation submit($encodedTransaction: HexString!) {
38633
38692
  submit(tx: $encodedTransaction) {
@@ -38710,6 +38769,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38710
38769
  getBalance(variables, options) {
38711
38770
  return requester(GetBalanceDocument, variables, options);
38712
38771
  },
38772
+ getLatestGasPrice(variables, options) {
38773
+ return requester(GetLatestGasPriceDocument, variables, options);
38774
+ },
38775
+ estimateGasPrice(variables, options) {
38776
+ return requester(EstimateGasPriceDocument, variables, options);
38777
+ },
38713
38778
  getBalances(variables, options) {
38714
38779
  return requester(GetBalancesDocument, variables, options);
38715
38780
  },
@@ -38777,11 +38842,14 @@ ${MessageCoinFragmentFragmentDoc}`;
38777
38842
  let data;
38778
38843
  let errors;
38779
38844
  try {
38780
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
38845
+ const sanitizedText = text.replace(/\s/g, "");
38846
+ ({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
38781
38847
  } catch (e) {
38782
38848
  throw new FuelError(
38783
38849
  ErrorCode.STREAM_PARSING_ERROR,
38784
- `Error while parsing stream data response: ${text}`
38850
+ `Error while parsing stream data response: ${text}
38851
+
38852
+ Thrown error: ${e}`
38785
38853
  );
38786
38854
  }
38787
38855
  if (Array.isArray(errors)) {
@@ -38884,10 +38952,9 @@ ${MessageCoinFragmentFragmentDoc}`;
38884
38952
  txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
38885
38953
  },
38886
38954
  witnessIndex: value.witnessIndex,
38887
- maturity: value.maturity ?? 0,
38888
38955
  predicateGasUsed: bn(value.predicateGasUsed),
38889
- predicateLength: predicate.length,
38890
- predicateDataLength: predicateData.length,
38956
+ predicateLength: bn(predicate.length),
38957
+ predicateDataLength: bn(predicateData.length),
38891
38958
  predicate: hexlify(predicate),
38892
38959
  predicateData: hexlify(predicateData)
38893
38960
  };
@@ -38918,8 +38985,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38918
38985
  nonce: hexlify(value.nonce),
38919
38986
  witnessIndex: value.witnessIndex,
38920
38987
  predicateGasUsed: bn(value.predicateGasUsed),
38921
- predicateLength: predicate.length,
38922
- predicateDataLength: predicateData.length,
38988
+ predicateLength: bn(predicate.length),
38989
+ predicateDataLength: bn(predicateData.length),
38923
38990
  predicate: hexlify(predicate),
38924
38991
  predicateData: hexlify(predicateData),
38925
38992
  data: hexlify(data),
@@ -39079,8 +39146,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39079
39146
  case "CALL" /* Call */: {
39080
39147
  const callReceipt = {
39081
39148
  type: ReceiptType.Call,
39082
- from: hexOrZero(receipt.contract?.id),
39083
- to: hexOrZero(receipt?.to?.id),
39149
+ from: hexOrZero(receipt.id || receipt.contractId),
39150
+ to: hexOrZero(receipt?.to),
39084
39151
  amount: bn(receipt.amount),
39085
39152
  assetId: hexOrZero(receipt.assetId),
39086
39153
  gas: bn(receipt.gas),
@@ -39094,7 +39161,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39094
39161
  case "RETURN" /* Return */: {
39095
39162
  const returnReceipt = {
39096
39163
  type: ReceiptType.Return,
39097
- id: hexOrZero(receipt.contract?.id),
39164
+ id: hexOrZero(receipt.id || receipt.contractId),
39098
39165
  val: bn(receipt.val),
39099
39166
  pc: bn(receipt.pc),
39100
39167
  is: bn(receipt.is)
@@ -39104,7 +39171,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39104
39171
  case "RETURN_DATA" /* ReturnData */: {
39105
39172
  const returnDataReceipt = {
39106
39173
  type: ReceiptType.ReturnData,
39107
- id: hexOrZero(receipt.contract?.id),
39174
+ id: hexOrZero(receipt.id || receipt.contractId),
39108
39175
  ptr: bn(receipt.ptr),
39109
39176
  len: bn(receipt.len),
39110
39177
  digest: hexOrZero(receipt.digest),
@@ -39116,7 +39183,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39116
39183
  case "PANIC" /* Panic */: {
39117
39184
  const panicReceipt = {
39118
39185
  type: ReceiptType.Panic,
39119
- id: hexOrZero(receipt.contract?.id),
39186
+ id: hexOrZero(receipt.id),
39120
39187
  reason: bn(receipt.reason),
39121
39188
  pc: bn(receipt.pc),
39122
39189
  is: bn(receipt.is),
@@ -39127,7 +39194,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39127
39194
  case "REVERT" /* Revert */: {
39128
39195
  const revertReceipt = {
39129
39196
  type: ReceiptType.Revert,
39130
- id: hexOrZero(receipt.contract?.id),
39197
+ id: hexOrZero(receipt.id || receipt.contractId),
39131
39198
  val: bn(receipt.ra),
39132
39199
  pc: bn(receipt.pc),
39133
39200
  is: bn(receipt.is)
@@ -39137,7 +39204,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39137
39204
  case "LOG" /* Log */: {
39138
39205
  const logReceipt = {
39139
39206
  type: ReceiptType.Log,
39140
- id: hexOrZero(receipt.contract?.id),
39207
+ id: hexOrZero(receipt.id || receipt.contractId),
39141
39208
  val0: bn(receipt.ra),
39142
39209
  val1: bn(receipt.rb),
39143
39210
  val2: bn(receipt.rc),
@@ -39150,7 +39217,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39150
39217
  case "LOG_DATA" /* LogData */: {
39151
39218
  const logDataReceipt = {
39152
39219
  type: ReceiptType.LogData,
39153
- id: hexOrZero(receipt.contract?.id),
39220
+ id: hexOrZero(receipt.id || receipt.contractId),
39154
39221
  val0: bn(receipt.ra),
39155
39222
  val1: bn(receipt.rb),
39156
39223
  ptr: bn(receipt.ptr),
@@ -39164,8 +39231,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39164
39231
  case "TRANSFER" /* Transfer */: {
39165
39232
  const transferReceipt = {
39166
39233
  type: ReceiptType.Transfer,
39167
- from: hexOrZero(receipt.contract?.id),
39168
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
39234
+ from: hexOrZero(receipt.id || receipt.contractId),
39235
+ to: hexOrZero(receipt.toAddress || receipt?.to),
39169
39236
  amount: bn(receipt.amount),
39170
39237
  assetId: hexOrZero(receipt.assetId),
39171
39238
  pc: bn(receipt.pc),
@@ -39176,8 +39243,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39176
39243
  case "TRANSFER_OUT" /* TransferOut */: {
39177
39244
  const transferOutReceipt = {
39178
39245
  type: ReceiptType.TransferOut,
39179
- from: hexOrZero(receipt.contract?.id),
39180
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
39246
+ from: hexOrZero(receipt.id || receipt.contractId),
39247
+ to: hexOrZero(receipt.toAddress || receipt.to),
39181
39248
  amount: bn(receipt.amount),
39182
39249
  assetId: hexOrZero(receipt.assetId),
39183
39250
  pc: bn(receipt.pc),
@@ -39220,7 +39287,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39220
39287
  return receiptMessageOut;
39221
39288
  }
39222
39289
  case "MINT" /* Mint */: {
39223
- const contractId = hexOrZero(receipt.contract?.id);
39290
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
39224
39291
  const subId = hexOrZero(receipt.subId);
39225
39292
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
39226
39293
  const mintReceipt = {
@@ -39235,7 +39302,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39235
39302
  return mintReceipt;
39236
39303
  }
39237
39304
  case "BURN" /* Burn */: {
39238
- const contractId = hexOrZero(receipt.contract?.id);
39305
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
39239
39306
  const subId = hexOrZero(receipt.subId);
39240
39307
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
39241
39308
  const burnReceipt = {
@@ -39316,7 +39383,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39316
39383
  };
39317
39384
 
39318
39385
  // src/providers/utils/gas.ts
39319
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
39320
39386
  var getGasUsedFromReceipts = (receipts) => {
39321
39387
  const scriptResult = receipts.filter(
39322
39388
  (receipt) => receipt.type === ReceiptType.ScriptResult
@@ -39337,18 +39403,28 @@ ${MessageCoinFragmentFragmentDoc}`;
39337
39403
  }
39338
39404
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
39339
39405
  const witnessCache = [];
39340
- const totalGas = inputs.reduce((total, input) => {
39406
+ const chargeableInputs = inputs.filter((input) => {
39407
+ const isCoinOrMessage = "owner" in input || "sender" in input;
39408
+ if (isCoinOrMessage) {
39409
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39410
+ return true;
39411
+ }
39412
+ if (!witnessCache.includes(input.witnessIndex)) {
39413
+ witnessCache.push(input.witnessIndex);
39414
+ return true;
39415
+ }
39416
+ }
39417
+ return false;
39418
+ });
39419
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
39420
+ const totalGas = chargeableInputs.reduce((total, input) => {
39341
39421
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39342
39422
  return total.add(
39343
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39423
+ vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39344
39424
  );
39345
39425
  }
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());
39426
+ return total.add(gasCosts.ecr1);
39427
+ }, bn(0));
39352
39428
  return totalGas;
39353
39429
  }
39354
39430
  function getMinGas(params) {
@@ -39360,12 +39436,20 @@ ${MessageCoinFragmentFragmentDoc}`;
39360
39436
  return minGas;
39361
39437
  }
39362
39438
  function getMaxGas(params) {
39363
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
39439
+ const {
39440
+ gasPerByte,
39441
+ witnessesLength,
39442
+ witnessLimit,
39443
+ minGas,
39444
+ gasLimit = bn(0),
39445
+ maxGasPerTx
39446
+ } = params;
39364
39447
  let remainingAllowedWitnessGas = bn(0);
39365
39448
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
39366
39449
  remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
39367
39450
  }
39368
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39451
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39452
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
39369
39453
  }
39370
39454
  function calculateMetadataGasForTxCreate({
39371
39455
  gasCosts,
@@ -39387,6 +39471,10 @@ ${MessageCoinFragmentFragmentDoc}`;
39387
39471
  }) {
39388
39472
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
39389
39473
  }
39474
+ var calculateGasFee = (params) => {
39475
+ const { gas, gasPrice, priceFactor, tip } = params;
39476
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
39477
+ };
39390
39478
 
39391
39479
  // src/providers/utils/json.ts
39392
39480
  function normalize2(object) {
@@ -39528,7 +39616,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39528
39616
  // src/providers/transaction-request/transaction-request.ts
39529
39617
  var BaseTransactionRequest = class {
39530
39618
  /** Gas price for transaction */
39531
- gasPrice;
39619
+ tip;
39532
39620
  /** Block until which tx cannot be included */
39533
39621
  maturity;
39534
39622
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -39547,7 +39635,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39547
39635
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
39548
39636
  */
39549
39637
  constructor({
39550
- gasPrice,
39638
+ tip,
39551
39639
  maturity,
39552
39640
  maxFee,
39553
39641
  witnessLimit,
@@ -39555,7 +39643,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39555
39643
  outputs,
39556
39644
  witnesses
39557
39645
  } = {}) {
39558
- this.gasPrice = bn(gasPrice);
39646
+ this.tip = bn(tip);
39559
39647
  this.maturity = maturity ?? 0;
39560
39648
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
39561
39649
  this.maxFee = maxFee ? bn(maxFee) : void 0;
@@ -39566,9 +39654,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39566
39654
  static getPolicyMeta(req) {
39567
39655
  let policyTypes = 0;
39568
39656
  const policies = [];
39569
- if (req.gasPrice) {
39570
- policyTypes += PolicyType.GasPrice;
39571
- policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
39657
+ if (req.tip) {
39658
+ policyTypes += PolicyType.Tip;
39659
+ policies.push({ data: req.tip, type: PolicyType.Tip });
39572
39660
  }
39573
39661
  if (req.witnessLimit) {
39574
39662
  policyTypes += PolicyType.WitnessLimit;
@@ -39755,10 +39843,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39755
39843
  * @param predicate - Predicate bytes.
39756
39844
  * @param predicateData - Predicate data bytes.
39757
39845
  */
39758
- addCoinInput(coin, predicate) {
39846
+ addCoinInput(coin) {
39759
39847
  const { assetId, owner, amount } = coin;
39760
39848
  let witnessIndex;
39761
- if (predicate) {
39849
+ if (coin.predicate) {
39762
39850
  witnessIndex = 0;
39763
39851
  } else {
39764
39852
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -39773,8 +39861,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39773
39861
  amount,
39774
39862
  assetId,
39775
39863
  txPointer: "0x00000000000000000000000000000000",
39776
- witnessIndex,
39777
- predicate: predicate?.bytes
39864
+ witnessIndex
39778
39865
  };
39779
39866
  this.pushInput(input);
39780
39867
  this.addChangeOutput(owner, assetId);
@@ -39787,11 +39874,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39787
39874
  * @param predicate - Predicate bytes.
39788
39875
  * @param predicateData - Predicate data bytes.
39789
39876
  */
39790
- addMessageInput(message, predicate) {
39877
+ addMessageInput(message) {
39791
39878
  const { recipient, sender, amount } = message;
39792
39879
  const assetId = BaseAssetId;
39793
39880
  let witnessIndex;
39794
- if (predicate) {
39881
+ if (message.predicate) {
39795
39882
  witnessIndex = 0;
39796
39883
  } else {
39797
39884
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -39805,8 +39892,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39805
39892
  sender: sender.toB256(),
39806
39893
  recipient: recipient.toB256(),
39807
39894
  amount,
39808
- witnessIndex,
39809
- predicate: predicate?.bytes
39895
+ witnessIndex
39810
39896
  };
39811
39897
  this.pushInput(input);
39812
39898
  this.addChangeOutput(recipient, assetId);
@@ -39837,32 +39923,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39837
39923
  resources.forEach((resource) => this.addResource(resource));
39838
39924
  return this;
39839
39925
  }
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
39926
  /**
39867
39927
  * Adds a coin output to the transaction.
39868
39928
  *
@@ -39942,7 +40002,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39942
40002
  }
39943
40003
  calculateMaxGas(chainInfo, minGas) {
39944
40004
  const { consensusParameters } = chainInfo;
39945
- const { gasPerByte } = consensusParameters;
40005
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
39946
40006
  const witnessesLength = this.toTransaction().witnesses.reduce(
39947
40007
  (acc, wit) => acc + wit.dataLength,
39948
40008
  0
@@ -39951,7 +40011,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39951
40011
  gasPerByte,
39952
40012
  minGas,
39953
40013
  witnessesLength,
39954
- witnessLimit: this.witnessLimit
40014
+ witnessLimit: this.witnessLimit,
40015
+ maxGasPerTx
39955
40016
  });
39956
40017
  }
39957
40018
  /**
@@ -39969,17 +40030,20 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39969
40030
  });
39970
40031
  const updateAssetInput = (assetId, quantity) => {
39971
40032
  const assetInput = findAssetInput(assetId);
40033
+ let usedQuantity = quantity;
40034
+ if (assetId === BaseAssetId) {
40035
+ usedQuantity = bn("1000000000000000000");
40036
+ }
39972
40037
  if (assetInput && "assetId" in assetInput) {
39973
40038
  assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
39974
- assetInput.amount = quantity;
40039
+ assetInput.amount = usedQuantity;
39975
40040
  } else {
39976
40041
  this.addResources([
39977
40042
  {
39978
40043
  id: hexlify(randomBytes22(UTXO_ID_LEN)),
39979
- amount: quantity,
40044
+ amount: usedQuantity,
39980
40045
  assetId,
39981
40046
  owner: resourcesOwner || Address.fromRandom(),
39982
- maturity: 0,
39983
40047
  blockCreated: bn(1),
39984
40048
  txCreatedIdx: bn(1)
39985
40049
  }
@@ -40011,7 +40075,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40011
40075
  toJSON() {
40012
40076
  return normalizeJSON(this);
40013
40077
  }
40014
- updatePredicateInputs(inputs) {
40078
+ updatePredicateGasUsed(inputs) {
40015
40079
  this.inputs.forEach((i) => {
40016
40080
  let correspondingInput;
40017
40081
  switch (i.type) {
@@ -40033,6 +40097,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40033
40097
  }
40034
40098
  });
40035
40099
  }
40100
+ shiftPredicateData() {
40101
+ this.inputs.forEach((input) => {
40102
+ if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
40103
+ input.predicateData = input.paddPredicateData(
40104
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
40105
+ );
40106
+ }
40107
+ });
40108
+ }
40036
40109
  };
40037
40110
 
40038
40111
  // src/providers/transaction-request/hash-transaction.ts
@@ -40166,9 +40239,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40166
40239
  return {
40167
40240
  type: TransactionType.Create,
40168
40241
  ...baseTransaction,
40169
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
40170
40242
  bytecodeWitnessIndex,
40171
- storageSlotsCount: storageSlots.length,
40243
+ storageSlotsCount: bn(storageSlots.length),
40172
40244
  salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
40173
40245
  storageSlots
40174
40246
  };
@@ -40282,8 +40354,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40282
40354
  type: TransactionType.Script,
40283
40355
  scriptGasLimit: this.gasLimit,
40284
40356
  ...super.getBaseTransaction(),
40285
- scriptLength: script.length,
40286
- scriptDataLength: scriptData.length,
40357
+ scriptLength: bn(script.length),
40358
+ scriptDataLength: bn(scriptData.length),
40287
40359
  receiptsRoot: ZeroBytes32,
40288
40360
  script: hexlify(script),
40289
40361
  scriptData: hexlify(scriptData)
@@ -40347,7 +40419,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40347
40419
  }
40348
40420
  calculateMaxGas(chainInfo, minGas) {
40349
40421
  const { consensusParameters } = chainInfo;
40350
- const { gasPerByte } = consensusParameters;
40422
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
40351
40423
  const witnessesLength = this.toTransaction().witnesses.reduce(
40352
40424
  (acc, wit) => acc + wit.dataLength,
40353
40425
  0
@@ -40357,7 +40429,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40357
40429
  minGas,
40358
40430
  witnessesLength,
40359
40431
  witnessLimit: this.witnessLimit,
40360
- gasLimit: this.gasLimit
40432
+ gasLimit: this.gasLimit,
40433
+ maxGasPerTx
40361
40434
  });
40362
40435
  }
40363
40436
  /**
@@ -40430,13 +40503,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40430
40503
  }
40431
40504
  }
40432
40505
  };
40506
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
40507
+ (acc, input) => {
40508
+ if (input.type === InputType.Coin && input.owner === owner) {
40509
+ acc.utxos.push(input.id);
40510
+ }
40511
+ if (input.type === InputType.Message && input.recipient === owner) {
40512
+ acc.messages.push(input.nonce);
40513
+ }
40514
+ return acc;
40515
+ },
40516
+ {
40517
+ utxos: [],
40518
+ messages: []
40519
+ }
40520
+ );
40433
40521
 
40434
40522
  // src/providers/transaction-summary/calculate-transaction-fee.ts
40435
40523
  var calculateTransactionFee = (params) => {
40436
40524
  const {
40437
- gasUsed,
40525
+ gasPrice,
40438
40526
  rawPayload,
40439
- consensusParameters: { gasCosts, feeParams }
40527
+ tip,
40528
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
40440
40529
  } = params;
40441
40530
  const gasPerByte = bn(feeParams.gasPerByte);
40442
40531
  const gasPriceFactor = bn(feeParams.gasPriceFactor);
@@ -40446,8 +40535,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40446
40535
  return {
40447
40536
  fee: bn(0),
40448
40537
  minFee: bn(0),
40449
- maxFee: bn(0),
40450
- feeFromGasUsed: bn(0)
40538
+ maxFee: bn(0)
40451
40539
  };
40452
40540
  }
40453
40541
  const { type: type3, witnesses, inputs, policies } = transaction;
@@ -40479,7 +40567,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40479
40567
  metadataGas,
40480
40568
  txBytesSize: transactionBytes.length
40481
40569
  });
40482
- const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
40483
40570
  const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
40484
40571
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
40485
40572
  const maxGas = getMaxGas({
@@ -40487,17 +40574,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40487
40574
  minGas,
40488
40575
  witnessesLength,
40489
40576
  gasLimit,
40490
- witnessLimit
40577
+ witnessLimit,
40578
+ maxGasPerTx
40579
+ });
40580
+ const minFee = calculateGasFee({
40581
+ gasPrice,
40582
+ gas: minGas,
40583
+ priceFactor: gasPriceFactor,
40584
+ tip
40585
+ });
40586
+ const maxFee = calculateGasFee({
40587
+ gasPrice,
40588
+ gas: maxGas,
40589
+ priceFactor: gasPriceFactor,
40590
+ tip
40491
40591
  });
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
40592
  return {
40497
- fee,
40498
40593
  minFee,
40499
40594
  maxFee,
40500
- feeFromGasUsed
40595
+ fee: maxFee
40501
40596
  };
40502
40597
  };
40503
40598
 
@@ -41098,7 +41193,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41098
41193
  gqlTransactionStatus,
41099
41194
  abiMap = {},
41100
41195
  maxInputs,
41101
- gasCosts
41196
+ gasCosts,
41197
+ maxGasPerTx,
41198
+ gasPrice
41102
41199
  } = params;
41103
41200
  const gasUsed = getGasUsedFromReceipts(receipts);
41104
41201
  const rawPayload = hexlify(transactionBytes);
@@ -41112,11 +41209,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41112
41209
  maxInputs
41113
41210
  });
41114
41211
  const typeName = getTransactionTypeName(transaction.type);
41212
+ const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
41115
41213
  const { fee } = calculateTransactionFee({
41116
- gasUsed,
41214
+ gasPrice,
41117
41215
  rawPayload,
41216
+ tip,
41118
41217
  consensusParameters: {
41119
41218
  gasCosts,
41219
+ maxGasPerTx,
41120
41220
  feeParams: {
41121
41221
  gasPerByte,
41122
41222
  gasPriceFactor
@@ -41252,8 +41352,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41252
41352
  const decodedTransaction = this.decodeTransaction(
41253
41353
  transaction
41254
41354
  );
41255
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
41256
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
41355
+ let txReceipts = [];
41356
+ if (transaction?.status && "receipts" in transaction.status) {
41357
+ txReceipts = transaction.status.receipts;
41358
+ }
41359
+ const receipts = txReceipts.map(processGqlReceipt) || [];
41360
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
41361
+ const gasPrice = await this.provider.getLatestGasPrice();
41257
41362
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
41258
41363
  const transactionSummary = assembleTransactionSummary({
41259
41364
  id: this.id,
@@ -41265,7 +41370,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41265
41370
  gasPriceFactor,
41266
41371
  abiMap: contractsAbiMap,
41267
41372
  maxInputs,
41268
- gasCosts
41373
+ gasCosts,
41374
+ maxGasPerTx,
41375
+ gasPrice
41269
41376
  });
41270
41377
  return transactionSummary;
41271
41378
  }
@@ -41414,7 +41521,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41414
41521
  gasCosts,
41415
41522
  latestBlock: {
41416
41523
  id: latestBlock.id,
41417
- height: bn(latestBlock.header.height),
41524
+ height: bn(latestBlock.height),
41418
41525
  time: latestBlock.header.time,
41419
41526
  transactions: latestBlock.transactions.map((i) => ({
41420
41527
  id: i.id
@@ -41508,10 +41615,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41508
41615
  * Returns some helpful parameters related to gas fees.
41509
41616
  */
41510
41617
  getGasConfig() {
41511
- const { minGasPrice } = this.getNode();
41512
41618
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
41513
41619
  return {
41514
- minGasPrice,
41515
41620
  maxGasPerTx,
41516
41621
  maxGasPerPredicate,
41517
41622
  gasPriceFactor,
@@ -41609,7 +41714,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41609
41714
  */
41610
41715
  async getBlockNumber() {
41611
41716
  const { chain } = await this.operations.getChain();
41612
- return bn(chain.latestBlock.header.height, 10);
41717
+ return bn(chain.latestBlock.height, 10);
41613
41718
  }
41614
41719
  /**
41615
41720
  * Returns the chain information.
@@ -41621,11 +41726,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41621
41726
  const processedNodeInfo = {
41622
41727
  maxDepth: bn(nodeInfo.maxDepth),
41623
41728
  maxTx: bn(nodeInfo.maxTx),
41624
- minGasPrice: bn(nodeInfo.minGasPrice),
41625
41729
  nodeVersion: nodeInfo.nodeVersion,
41626
41730
  utxoValidation: nodeInfo.utxoValidation,
41627
- vmBacktrace: nodeInfo.vmBacktrace,
41628
- peers: nodeInfo.peers
41731
+ vmBacktrace: nodeInfo.vmBacktrace
41629
41732
  };
41630
41733
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
41631
41734
  return processedNodeInfo;
@@ -41711,14 +41814,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41711
41814
  return this.estimateTxDependencies(transactionRequest);
41712
41815
  }
41713
41816
  const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41714
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41715
- encodedTransaction,
41817
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
41818
+ encodedTransactions: encodedTransaction,
41716
41819
  utxoValidation: utxoValidation || false
41717
41820
  });
41718
- const receipts = gqlReceipts.map(processGqlReceipt);
41719
- return {
41720
- receipts
41721
- };
41821
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
41822
+ const receipts = rawReceipts.map(processGqlReceipt);
41823
+ return { receipts, dryrunStatus: status };
41722
41824
  }
41723
41825
  /**
41724
41826
  * Verifies whether enough gas is available to complete transaction.
@@ -41757,9 +41859,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41757
41859
  * If there are missing variable outputs,
41758
41860
  * `addVariableOutputs` is called on the transaction.
41759
41861
  *
41760
- * @privateRemarks
41761
- * TODO: Investigate support for missing contract IDs
41762
- * TODO: Add support for missing output messages
41763
41862
  *
41764
41863
  * @param transactionRequest - The transaction request object.
41765
41864
  * @returns A promise.
@@ -41772,16 +41871,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41772
41871
  missingContractIds: []
41773
41872
  };
41774
41873
  }
41775
- await this.estimatePredicates(transactionRequest);
41776
41874
  let receipts = [];
41777
41875
  const missingContractIds = [];
41778
41876
  let outputVariables = 0;
41877
+ let dryrunStatus;
41779
41878
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
41780
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41781
- encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
41879
+ const {
41880
+ dryRun: [{ receipts: rawReceipts, status }]
41881
+ } = await this.operations.dryRun({
41882
+ encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
41782
41883
  utxoValidation: false
41783
41884
  });
41784
- receipts = gqlReceipts.map(processGqlReceipt);
41885
+ receipts = rawReceipts.map(processGqlReceipt);
41886
+ dryrunStatus = status;
41785
41887
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
41786
41888
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
41787
41889
  if (hasMissingOutputs) {
@@ -41791,6 +41893,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41791
41893
  transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
41792
41894
  missingContractIds.push(contractId);
41793
41895
  });
41896
+ const { maxFee } = await this.estimateTxGasAndFee({
41897
+ transactionRequest
41898
+ });
41899
+ transactionRequest.maxFee = maxFee;
41794
41900
  } else {
41795
41901
  break;
41796
41902
  }
@@ -41798,37 +41904,139 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41798
41904
  return {
41799
41905
  receipts,
41800
41906
  outputVariables,
41801
- missingContractIds
41907
+ missingContractIds,
41908
+ dryrunStatus
41802
41909
  };
41803
41910
  }
41911
+ /**
41912
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
41913
+ *
41914
+ * Transactions are dry run in batches. After each dry run, transactions requiring
41915
+ * further modifications are identified. The method iteratively updates these transactions
41916
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
41917
+ *
41918
+ * @param transactionRequests - Array of transaction request objects.
41919
+ * @returns A promise that resolves to an array of results for each transaction.
41920
+ */
41921
+ async estimateMultipleTxDependencies(transactionRequests) {
41922
+ const results = transactionRequests.map(() => ({
41923
+ receipts: [],
41924
+ outputVariables: 0,
41925
+ missingContractIds: [],
41926
+ dryrunStatus: void 0
41927
+ }));
41928
+ const allRequests = clone_default(transactionRequests);
41929
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
41930
+ allRequests.forEach((req, index) => {
41931
+ if (req.type === TransactionType.Script) {
41932
+ serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
41933
+ }
41934
+ });
41935
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
41936
+ let attempt = 0;
41937
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
41938
+ const encodedTransactions = transactionsToProcess.map(
41939
+ (index) => serializedTransactionsMap.get(index)
41940
+ );
41941
+ const dryRunResults = await this.operations.dryRun({
41942
+ encodedTransactions,
41943
+ utxoValidation: false
41944
+ });
41945
+ const nextRoundTransactions = [];
41946
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
41947
+ const currentResultIndex = transactionsToProcess[i];
41948
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
41949
+ results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
41950
+ results[currentResultIndex].dryrunStatus = status;
41951
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
41952
+ results[currentResultIndex].receipts
41953
+ );
41954
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
41955
+ const requestToProcess = allRequests[currentResultIndex];
41956
+ if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
41957
+ results[currentResultIndex].outputVariables += missingOutputVariables.length;
41958
+ requestToProcess.addVariableOutputs(missingOutputVariables.length);
41959
+ missingOutputContractIds.forEach(({ contractId }) => {
41960
+ requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
41961
+ results[currentResultIndex].missingContractIds.push(contractId);
41962
+ });
41963
+ const { maxFee } = await this.estimateTxGasAndFee({
41964
+ transactionRequest: requestToProcess
41965
+ });
41966
+ requestToProcess.maxFee = maxFee;
41967
+ serializedTransactionsMap.set(
41968
+ currentResultIndex,
41969
+ hexlify(requestToProcess.toTransactionBytes())
41970
+ );
41971
+ nextRoundTransactions.push(currentResultIndex);
41972
+ allRequests[currentResultIndex] = requestToProcess;
41973
+ }
41974
+ }
41975
+ transactionsToProcess = nextRoundTransactions;
41976
+ attempt += 1;
41977
+ }
41978
+ return results;
41979
+ }
41980
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
41981
+ if (estimateTxDependencies) {
41982
+ return this.estimateMultipleTxDependencies(transactionRequests);
41983
+ }
41984
+ const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
41985
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
41986
+ encodedTransactions,
41987
+ utxoValidation: utxoValidation || false
41988
+ });
41989
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
41990
+ const receipts = rawReceipts.map(processGqlReceipt);
41991
+ return { receipts, dryrunStatus: status };
41992
+ });
41993
+ return results;
41994
+ }
41804
41995
  /**
41805
41996
  * Estimates the transaction gas and fee based on the provided transaction request.
41806
41997
  * @param transactionRequest - The transaction request object.
41807
41998
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41808
41999
  */
41809
- estimateTxGasAndFee(params) {
42000
+ async estimateTxGasAndFee(params) {
41810
42001
  const { transactionRequest } = params;
41811
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
42002
+ let { gasPrice } = params;
41812
42003
  const chainInfo = this.getChain();
41813
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41814
- transactionRequest.gasPrice = gasPrice;
42004
+ const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
41815
42005
  const minGas = transactionRequest.calculateMinGas(chainInfo);
41816
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42006
+ if (!gasPrice) {
42007
+ gasPrice = await this.estimateGasPrice(10);
42008
+ }
42009
+ const minFee = calculateGasFee({
42010
+ gasPrice: bn(gasPrice),
42011
+ gas: minGas,
42012
+ priceFactor: gasPriceFactor,
42013
+ tip: transactionRequest.tip
42014
+ }).add(1);
42015
+ let gasLimit = bn(0);
41817
42016
  if (transactionRequest.type === TransactionType.Script) {
42017
+ gasLimit = transactionRequest.gasLimit;
41818
42018
  if (transactionRequest.gasLimit.eq(0)) {
41819
42019
  transactionRequest.gasLimit = minGas;
41820
42020
  transactionRequest.gasLimit = maxGasPerTx.sub(
41821
42021
  transactionRequest.calculateMaxGas(chainInfo, minGas)
41822
42022
  );
42023
+ gasLimit = transactionRequest.gasLimit;
41823
42024
  }
41824
42025
  }
41825
42026
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41826
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42027
+ const maxFee = calculateGasFee({
42028
+ gasPrice: bn(gasPrice),
42029
+ gas: maxGas,
42030
+ priceFactor: gasPriceFactor,
42031
+ tip: transactionRequest.tip
42032
+ }).add(1);
41827
42033
  return {
41828
42034
  minGas,
41829
42035
  minFee,
41830
42036
  maxGas,
41831
- maxFee
42037
+ maxFee,
42038
+ gasPrice,
42039
+ gasLimit
41832
42040
  };
41833
42041
  }
41834
42042
  /**
@@ -41846,15 +42054,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41846
42054
  if (estimateTxDependencies) {
41847
42055
  return this.estimateTxDependencies(transactionRequest);
41848
42056
  }
41849
- const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41850
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41851
- encodedTransaction,
42057
+ const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
42058
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42059
+ encodedTransactions,
41852
42060
  utxoValidation: true
41853
42061
  });
41854
- const receipts = gqlReceipts.map(processGqlReceipt);
41855
- return {
41856
- receipts
41857
- };
42062
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
42063
+ const { id, receipts, status } = dryRunStatus;
42064
+ const processedReceipts = receipts.map(processGqlReceipt);
42065
+ return { id, receipts: processedReceipts, status };
42066
+ });
42067
+ return { receipts: callResult[0].receipts };
41858
42068
  }
41859
42069
  /**
41860
42070
  * Returns a transaction cost to enable user
@@ -41871,77 +42081,79 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41871
42081
  * @param tolerance - The tolerance to add on top of the gasUsed.
41872
42082
  * @returns A promise that resolves to the transaction cost object.
41873
42083
  */
41874
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
41875
- estimateTxDependencies = true,
41876
- estimatePredicates = true,
41877
- resourcesOwner,
41878
- signatureCallback
41879
- } = {}) {
42084
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
41880
42085
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41881
- const { minGasPrice } = this.getGasConfig();
41882
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41883
42086
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41884
42087
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41885
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
42088
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
41886
42089
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
42090
+ txRequestClone.maxFee = bn(0);
41887
42091
  if (isScriptTransaction) {
41888
42092
  txRequestClone.gasLimit = bn(0);
41889
42093
  }
41890
- if (estimatePredicates) {
41891
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41892
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
41893
- }
41894
- await this.estimatePredicates(txRequestClone);
42094
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
42095
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
41895
42096
  }
42097
+ const signedRequest = clone_default(txRequestClone);
42098
+ let addedSignatures = 0;
41896
42099
  if (signatureCallback && isScriptTransaction) {
41897
- await signatureCallback(txRequestClone);
42100
+ const lengthBefore = signedRequest.witnesses.length;
42101
+ await signatureCallback(signedRequest);
42102
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
41898
42103
  }
41899
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41900
- transactionRequest: txRequestClone
42104
+ await this.estimatePredicates(signedRequest);
42105
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
42106
+ transactionRequest: signedRequest
41901
42107
  });
41902
42108
  let receipts = [];
41903
42109
  let missingContractIds = [];
41904
42110
  let outputVariables = 0;
41905
42111
  let gasUsed = bn(0);
41906
- if (isScriptTransaction && estimateTxDependencies) {
41907
- txRequestClone.gasPrice = bn(0);
42112
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
42113
+ txRequestClone.maxFee = maxFee;
42114
+ if (isScriptTransaction) {
42115
+ txRequestClone.gasLimit = gasLimit;
42116
+ if (signatureCallback) {
42117
+ await signatureCallback(txRequestClone);
42118
+ }
41908
42119
  const result = await this.estimateTxDependencies(txRequestClone);
41909
42120
  receipts = result.receipts;
41910
42121
  outputVariables = result.outputVariables;
41911
42122
  missingContractIds = result.missingContractIds;
41912
42123
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41913
42124
  txRequestClone.gasLimit = gasUsed;
41914
- txRequestClone.gasPrice = setGasPrice;
41915
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41916
- transactionRequest: txRequestClone
42125
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
42126
+ transactionRequest: txRequestClone,
42127
+ gasPrice
41917
42128
  }));
41918
42129
  }
41919
42130
  return {
41920
42131
  requiredQuantities: allQuantities,
41921
42132
  receipts,
41922
42133
  gasUsed,
41923
- minGasPrice,
41924
- gasPrice: setGasPrice,
42134
+ gasPrice,
41925
42135
  minGas,
41926
42136
  maxGas,
41927
42137
  minFee,
41928
42138
  maxFee,
41929
- estimatedInputs: txRequestClone.inputs,
41930
42139
  outputVariables,
41931
- missingContractIds
42140
+ missingContractIds,
42141
+ addedSignatures,
42142
+ estimatedPredicates: txRequestClone.inputs
41932
42143
  };
41933
42144
  }
41934
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
42145
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
41935
42146
  const ownerAddress = Address.fromAddressOrString(owner);
41936
42147
  const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
41937
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
42148
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
42149
+ quantitiesToContract
42150
+ });
41938
42151
  transactionRequest.addResources(
41939
42152
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
41940
42153
  );
41941
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
41942
- transactionRequest,
41943
- forwardingQuantities
41944
- );
42154
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
42155
+ quantitiesToContract
42156
+ });
41945
42157
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
41946
42158
  return {
41947
42159
  resources,
@@ -41965,7 +42177,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41965
42177
  assetId: coin.assetId,
41966
42178
  amount: bn(coin.amount),
41967
42179
  owner: Address.fromAddressOrString(coin.owner),
41968
- maturity: bn(coin.maturity).toNumber(),
41969
42180
  blockCreated: bn(coin.blockCreated),
41970
42181
  txCreatedIdx: bn(coin.txCreatedIdx)
41971
42182
  }));
@@ -42017,7 +42228,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42017
42228
  amount: bn(coin.amount),
42018
42229
  assetId: coin.assetId,
42019
42230
  owner: Address.fromAddressOrString(coin.owner),
42020
- maturity: bn(coin.maturity).toNumber(),
42021
42231
  blockCreated: bn(coin.blockCreated),
42022
42232
  txCreatedIdx: bn(coin.txCreatedIdx)
42023
42233
  };
@@ -42050,7 +42260,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42050
42260
  }
42051
42261
  return {
42052
42262
  id: block2.id,
42053
- height: bn(block2.header.height),
42263
+ height: bn(block2.height),
42054
42264
  time: block2.header.time,
42055
42265
  transactionIds: block2.transactions.map((tx) => tx.id)
42056
42266
  };
@@ -42065,7 +42275,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42065
42275
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
42066
42276
  const blocks = fetchedData.edges.map(({ node: block2 }) => ({
42067
42277
  id: block2.id,
42068
- height: bn(block2.header.height),
42278
+ height: bn(block2.height),
42069
42279
  time: block2.header.time,
42070
42280
  transactionIds: block2.transactions.map((tx) => tx.id)
42071
42281
  }));
@@ -42092,7 +42302,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42092
42302
  }
42093
42303
  return {
42094
42304
  id: block2.id,
42095
- height: bn(block2.header.height, 10),
42305
+ height: bn(block2.height, 10),
42096
42306
  time: block2.header.time,
42097
42307
  transactionIds: block2.transactions.map((tx) => tx.id),
42098
42308
  transactions: block2.transactions.map(
@@ -42272,8 +42482,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42272
42482
  prevRoot: messageBlockHeader.prevRoot,
42273
42483
  time: messageBlockHeader.time,
42274
42484
  applicationHash: messageBlockHeader.applicationHash,
42275
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
42276
- messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
42485
+ messageReceiptCount: bn(messageBlockHeader.messageReceiptCount),
42486
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
42487
+ consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
42488
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
42489
+ stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
42277
42490
  },
42278
42491
  commitBlockHeader: {
42279
42492
  id: commitBlockHeader.id,
@@ -42284,8 +42497,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42284
42497
  prevRoot: commitBlockHeader.prevRoot,
42285
42498
  time: commitBlockHeader.time,
42286
42499
  applicationHash: commitBlockHeader.applicationHash,
42287
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
42288
- messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
42500
+ messageReceiptCount: bn(commitBlockHeader.messageReceiptCount),
42501
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
42502
+ consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
42503
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
42504
+ stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
42289
42505
  },
42290
42506
  sender: Address.fromAddressOrString(sender),
42291
42507
  recipient: Address.fromAddressOrString(recipient),
@@ -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
  *