@fuel-ts/account 0.0.0-rc-2037-20240423134048 → 0.0.0-rc-2021-20240423134551

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 (66) 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 +829 -600
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +857 -637
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +680 -455
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +11 -18
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +822 -328
  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 +2 -1
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +6 -1
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +37 -27
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/index.d.ts +0 -1
  31. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/input.d.ts +2 -2
  33. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/transaction-request.d.ts +6 -7
  36. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  37. package/dist/providers/transaction-request/utils.d.ts +3 -0
  38. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  39. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
  41. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
  43. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  44. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  45. package/dist/providers/utils/gas.d.ts +8 -2
  46. package/dist/providers/utils/gas.d.ts.map +1 -1
  47. package/dist/test-utils/index.d.ts +0 -1
  48. package/dist/test-utils/index.d.ts.map +1 -1
  49. package/dist/test-utils/launchNode.d.ts.map +1 -1
  50. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  51. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  52. package/dist/test-utils.global.js +1545 -1076
  53. package/dist/test-utils.global.js.map +1 -1
  54. package/dist/test-utils.js +837 -612
  55. package/dist/test-utils.js.map +1 -1
  56. package/dist/test-utils.mjs +674 -446
  57. package/dist/test-utils.mjs.map +1 -1
  58. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  59. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  60. package/package.json +16 -16
  61. package/dist/providers/transaction-request/helpers.d.ts +0 -10
  62. package/dist/providers/transaction-request/helpers.d.ts.map +0 -1
  63. package/dist/test-utils/resources.d.ts +0 -4
  64. package/dist/test-utils/resources.d.ts.map +0 -1
  65. package/dist/test-utils/transactionRequest.d.ts +0 -5
  66. package/dist/test-utils/transactionRequest.d.ts.map +0 -1
@@ -289,7 +289,7 @@
289
289
  }
290
290
  return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
291
291
  };
292
- BN2.max = function max2(left, right) {
292
+ BN2.max = function max(left, right) {
293
293
  if (left.cmp(right) > 0)
294
294
  return left;
295
295
  return right;
@@ -5113,7 +5113,7 @@
5113
5113
  function isBlob(obj) {
5114
5114
  return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
5115
5115
  }
5116
- function clone(instance) {
5116
+ function clone3(instance) {
5117
5117
  let p1, p2;
5118
5118
  let body = instance.body;
5119
5119
  if (instance.bodyUsed) {
@@ -6047,7 +6047,7 @@
6047
6047
  * @return Response
6048
6048
  */
6049
6049
  clone() {
6050
- return new Response2(clone(this), {
6050
+ return new Response2(clone3(this), {
6051
6051
  url: this.url,
6052
6052
  status: this.status,
6053
6053
  statusText: this.statusText,
@@ -6097,7 +6097,7 @@
6097
6097
  if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
6098
6098
  throw new TypeError("Request with GET/HEAD method cannot have body");
6099
6099
  }
6100
- let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
6100
+ let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone3(input) : null;
6101
6101
  Body.call(this, inputBody, {
6102
6102
  timeout: init.timeout || input.timeout || 0,
6103
6103
  size: init.size || input.size || 0
@@ -28952,8 +28952,8 @@ spurious results.`);
28952
28952
  // ../versions/dist/index.mjs
28953
28953
  function getBuiltinVersions() {
28954
28954
  return {
28955
- FORC: "0.49.3",
28956
- FUEL_CORE: "0.22.1",
28955
+ FORC: "0.51.1",
28956
+ FUEL_CORE: "0.24.2",
28957
28957
  FUELS: "0.81.0"
28958
28958
  };
28959
28959
  }
@@ -31495,32 +31495,182 @@ 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" : ""));
31544
+ }
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
+ }
31500
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";
31501
31651
 
31502
31652
  // src/providers/coin-quantity.ts
31503
31653
  var coinQuantityfy = (coinQuantityLike) => {
31504
31654
  let assetId;
31505
31655
  let amount;
31506
- let max2;
31656
+ let max;
31507
31657
  if (Array.isArray(coinQuantityLike)) {
31508
31658
  amount = coinQuantityLike[0];
31509
31659
  assetId = coinQuantityLike[1] ?? BaseAssetId;
31510
- max2 = coinQuantityLike[2] ?? void 0;
31660
+ max = coinQuantityLike[2] ?? void 0;
31511
31661
  } else {
31512
31662
  amount = coinQuantityLike.amount;
31513
31663
  assetId = coinQuantityLike.assetId ?? BaseAssetId;
31514
- max2 = coinQuantityLike.max ?? void 0;
31664
+ max = coinQuantityLike.max ?? void 0;
31515
31665
  }
31516
31666
  const bnAmount = bn(amount);
31517
31667
  return {
31518
31668
  assetId: hexlify(assetId),
31519
31669
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
31520
- max: max2 ? bn(max2) : void 0
31670
+ max: max ? bn(max) : 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;
@@ -31955,7 +32104,7 @@ This unreleased fuel-core build may include features and updates not yet support
31955
32104
  constructor(name, coders) {
31956
32105
  const caseIndexCoder = new BigNumberCoder("u64");
31957
32106
  const encodedValueSize = Object.values(coders).reduce(
31958
- (max2, coder) => Math.max(max2, coder.encodedLength),
32107
+ (max, coder) => Math.max(max, coder.encodedLength),
31959
32108
  0
31960
32109
  );
31961
32110
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -32673,7 +32822,7 @@ This unreleased fuel-core build may include features and updates not yet support
32673
32822
  constructor(name, coders) {
32674
32823
  const caseIndexCoder = new BigNumberCoder("u64");
32675
32824
  const encodedValueSize = Object.values(coders).reduce(
32676
- (max2, coder) => Math.max(max2, coder.encodedLength),
32825
+ (max, coder) => Math.max(max, coder.encodedLength),
32677
32826
  0
32678
32827
  );
32679
32828
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -33387,18 +33536,19 @@ This unreleased fuel-core build may include features and updates not yet support
33387
33536
  encode(value) {
33388
33537
  const parts = [];
33389
33538
  parts.push(new B256Coder().encode(value.txID));
33390
- parts.push(new NumberCoder("u8").encode(value.outputIndex));
33539
+ parts.push(new NumberCoder("u16").encode(value.outputIndex));
33391
33540
  parts.push(new B256Coder().encode(value.owner));
33392
33541
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33393
33542
  parts.push(new B256Coder().encode(value.assetId));
33394
33543
  parts.push(new TxPointerCoder().encode(value.txPointer));
33395
- parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33396
- parts.push(new NumberCoder("u32").encode(value.maturity));
33544
+ parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33397
33545
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33398
- parts.push(new NumberCoder("u32").encode(value.predicateLength));
33399
- parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
33400
- parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33401
- parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33546
+ parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33547
+ parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33548
+ parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33549
+ parts.push(
33550
+ new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33551
+ );
33402
33552
  return concat(parts);
33403
33553
  }
33404
33554
  decode(data, offset) {
@@ -33406,7 +33556,7 @@ This unreleased fuel-core build may include features and updates not yet support
33406
33556
  let o = offset;
33407
33557
  [decoded, o] = new B256Coder().decode(data, o);
33408
33558
  const txID = decoded;
33409
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33559
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33410
33560
  const outputIndex = decoded;
33411
33561
  [decoded, o] = new B256Coder().decode(data, o);
33412
33562
  const owner = decoded;
@@ -33416,19 +33566,17 @@ This unreleased fuel-core build may include features and updates not yet support
33416
33566
  const assetId = decoded;
33417
33567
  [decoded, o] = new TxPointerCoder().decode(data, o);
33418
33568
  const txPointer = decoded;
33419
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33569
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33420
33570
  const witnessIndex = Number(decoded);
33421
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33422
- const maturity = decoded;
33423
33571
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33424
33572
  const predicateGasUsed = decoded;
33425
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33573
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33426
33574
  const predicateLength = decoded;
33427
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33575
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33428
33576
  const predicateDataLength = decoded;
33429
- [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33577
+ [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33430
33578
  const predicate = decoded;
33431
- [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33579
+ [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33432
33580
  const predicateData = decoded;
33433
33581
  return [
33434
33582
  {
@@ -33440,7 +33588,6 @@ This unreleased fuel-core build may include features and updates not yet support
33440
33588
  assetId,
33441
33589
  txPointer,
33442
33590
  witnessIndex,
33443
- maturity,
33444
33591
  predicateGasUsed,
33445
33592
  predicateLength,
33446
33593
  predicateDataLength,
@@ -33458,7 +33605,7 @@ This unreleased fuel-core build may include features and updates not yet support
33458
33605
  encode(value) {
33459
33606
  const parts = [];
33460
33607
  parts.push(new B256Coder().encode(value.txID));
33461
- parts.push(new NumberCoder("u8").encode(value.outputIndex));
33608
+ parts.push(new NumberCoder("u16").encode(value.outputIndex));
33462
33609
  parts.push(new B256Coder().encode(value.balanceRoot));
33463
33610
  parts.push(new B256Coder().encode(value.stateRoot));
33464
33611
  parts.push(new TxPointerCoder().encode(value.txPointer));
@@ -33470,7 +33617,7 @@ This unreleased fuel-core build may include features and updates not yet support
33470
33617
  let o = offset;
33471
33618
  [decoded, o] = new B256Coder().decode(data, o);
33472
33619
  const txID = decoded;
33473
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33620
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33474
33621
  const outputIndex = decoded;
33475
33622
  [decoded, o] = new B256Coder().decode(data, o);
33476
33623
  const balanceRoot = decoded;
@@ -33519,14 +33666,16 @@ This unreleased fuel-core build may include features and updates not yet support
33519
33666
  parts.push(new ByteArrayCoder(32).encode(value.recipient));
33520
33667
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33521
33668
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
33522
- parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33669
+ parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33523
33670
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33524
- parts.push(new NumberCoder("u32").encode(data.length));
33525
- parts.push(new NumberCoder("u32").encode(value.predicateLength));
33526
- parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
33671
+ parts.push(new BigNumberCoder("u64").encode(data.length));
33672
+ parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33673
+ parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33527
33674
  parts.push(new ByteArrayCoder(data.length).encode(data));
33528
- parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33529
- parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33675
+ parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33676
+ parts.push(
33677
+ new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33678
+ );
33530
33679
  return concat(parts);
33531
33680
  }
33532
33681
  static decodeData(messageData) {
@@ -33546,21 +33695,21 @@ This unreleased fuel-core build may include features and updates not yet support
33546
33695
  const amount = decoded;
33547
33696
  [decoded, o] = new B256Coder().decode(data, o);
33548
33697
  const nonce = decoded;
33549
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33698
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33550
33699
  const witnessIndex = Number(decoded);
33551
33700
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33552
33701
  const predicateGasUsed = decoded;
33553
33702
  [decoded, o] = new NumberCoder("u32").decode(data, o);
33554
33703
  const dataLength2 = decoded;
33555
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33704
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33556
33705
  const predicateLength = decoded;
33557
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33706
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33558
33707
  const predicateDataLength = decoded;
33559
33708
  [decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
33560
33709
  const messageData = decoded;
33561
- [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33710
+ [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33562
33711
  const predicate = decoded;
33563
- [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33712
+ [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33564
33713
  const predicateData = decoded;
33565
33714
  return [
33566
33715
  {
@@ -33872,7 +34021,7 @@ This unreleased fuel-core build may include features and updates not yet support
33872
34021
  }
33873
34022
  };
33874
34023
  var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
33875
- PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
34024
+ PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
33876
34025
  PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
33877
34026
  PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
33878
34027
  PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
@@ -33920,9 +34069,9 @@ This unreleased fuel-core build may include features and updates not yet support
33920
34069
  let o = offset;
33921
34070
  const policies = [];
33922
34071
  if (policyTypes & 1) {
33923
- const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
34072
+ const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
33924
34073
  o = nextOffset;
33925
- policies.push({ type: 1, data: gasPrice });
34074
+ policies.push({ type: 1, data: tip });
33926
34075
  }
33927
34076
  if (policyTypes & 2) {
33928
34077
  const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
@@ -34154,15 +34303,15 @@ This unreleased fuel-core build may include features and updates not yet support
34154
34303
  encode(value) {
34155
34304
  const parts = [];
34156
34305
  parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
34157
- parts.push(new NumberCoder("u32").encode(value.scriptLength));
34158
- parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
34159
- parts.push(new NumberCoder("u32").encode(value.policyTypes));
34160
- parts.push(new NumberCoder("u8").encode(value.inputsCount));
34161
- parts.push(new NumberCoder("u8").encode(value.outputsCount));
34162
- parts.push(new NumberCoder("u8").encode(value.witnessesCount));
34163
34306
  parts.push(new B256Coder().encode(value.receiptsRoot));
34164
- parts.push(new ByteArrayCoder(value.scriptLength).encode(value.script));
34165
- parts.push(new ByteArrayCoder(value.scriptDataLength).encode(value.scriptData));
34307
+ parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
34308
+ parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
34309
+ parts.push(new NumberCoder("u32").encode(value.policyTypes));
34310
+ parts.push(new NumberCoder("u16").encode(value.inputsCount));
34311
+ parts.push(new NumberCoder("u16").encode(value.outputsCount));
34312
+ parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34313
+ parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
34314
+ parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
34166
34315
  parts.push(new PoliciesCoder().encode(value.policies));
34167
34316
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34168
34317
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
@@ -34174,23 +34323,23 @@ This unreleased fuel-core build may include features and updates not yet support
34174
34323
  let o = offset;
34175
34324
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34176
34325
  const scriptGasLimit = decoded;
34177
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34326
+ [decoded, o] = new B256Coder().decode(data, o);
34327
+ const receiptsRoot = decoded;
34328
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34178
34329
  const scriptLength = decoded;
34179
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34330
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34180
34331
  const scriptDataLength = decoded;
34181
34332
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34182
34333
  const policyTypes = decoded;
34183
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34334
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34184
34335
  const inputsCount = decoded;
34185
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34336
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34186
34337
  const outputsCount = decoded;
34187
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34338
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34188
34339
  const witnessesCount = decoded;
34189
- [decoded, o] = new B256Coder().decode(data, o);
34190
- const receiptsRoot = decoded;
34191
- [decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
34340
+ [decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
34192
34341
  const script = decoded;
34193
- [decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
34342
+ [decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
34194
34343
  const scriptData = decoded;
34195
34344
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34196
34345
  const policies = decoded;
@@ -34228,18 +34377,19 @@ This unreleased fuel-core build may include features and updates not yet support
34228
34377
  }
34229
34378
  encode(value) {
34230
34379
  const parts = [];
34231
- parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
34232
- parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
34233
- parts.push(new NumberCoder("u32").encode(value.policyTypes));
34234
- parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
34235
- parts.push(new NumberCoder("u8").encode(value.inputsCount));
34236
- parts.push(new NumberCoder("u8").encode(value.outputsCount));
34237
- parts.push(new NumberCoder("u8").encode(value.witnessesCount));
34380
+ parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
34238
34381
  parts.push(new B256Coder().encode(value.salt));
34239
- parts.push(new PoliciesCoder().encode(value.policies));
34382
+ parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
34383
+ parts.push(new NumberCoder("u32").encode(value.policyTypes));
34384
+ parts.push(new NumberCoder("u16").encode(value.inputsCount));
34385
+ parts.push(new NumberCoder("u16").encode(value.outputsCount));
34386
+ parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34240
34387
  parts.push(
34241
- new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
34388
+ new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
34389
+ value.storageSlots
34390
+ )
34242
34391
  );
34392
+ parts.push(new PoliciesCoder().encode(value.policies));
34243
34393
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34244
34394
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
34245
34395
  parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
@@ -34248,26 +34398,27 @@ This unreleased fuel-core build may include features and updates not yet support
34248
34398
  decode(data, offset) {
34249
34399
  let decoded;
34250
34400
  let o = offset;
34251
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34252
- const bytecodeLength = decoded;
34253
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34401
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34254
34402
  const bytecodeWitnessIndex = decoded;
34403
+ [decoded, o] = new B256Coder().decode(data, o);
34404
+ const salt = decoded;
34405
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34406
+ const storageSlotsCount = decoded;
34255
34407
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34256
34408
  const policyTypes = decoded;
34257
34409
  [decoded, o] = new NumberCoder("u16").decode(data, o);
34258
- const storageSlotsCount = decoded;
34259
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34260
34410
  const inputsCount = decoded;
34261
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34411
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34262
34412
  const outputsCount = decoded;
34263
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34413
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34264
34414
  const witnessesCount = decoded;
34265
- [decoded, o] = new B256Coder().decode(data, o);
34266
- const salt = decoded;
34415
+ [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
34416
+ data,
34417
+ o
34418
+ );
34419
+ const storageSlots = decoded;
34267
34420
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34268
34421
  const policies = decoded;
34269
- [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
34270
- const storageSlots = decoded;
34271
34422
  [decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
34272
34423
  const inputs = decoded;
34273
34424
  [decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
@@ -34277,7 +34428,6 @@ This unreleased fuel-core build may include features and updates not yet support
34277
34428
  return [
34278
34429
  {
34279
34430
  type: 1,
34280
- bytecodeLength,
34281
34431
  bytecodeWitnessIndex,
34282
34432
  policyTypes,
34283
34433
  storageSlotsCount,
@@ -34306,6 +34456,7 @@ This unreleased fuel-core build may include features and updates not yet support
34306
34456
  parts.push(new OutputContractCoder().encode(value.outputContract));
34307
34457
  parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
34308
34458
  parts.push(new B256Coder().encode(value.mintAssetId));
34459
+ parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
34309
34460
  return concat(parts);
34310
34461
  }
34311
34462
  decode(data, offset) {
@@ -34321,6 +34472,8 @@ This unreleased fuel-core build may include features and updates not yet support
34321
34472
  const mintAmount = decoded;
34322
34473
  [decoded, o] = new B256Coder().decode(data, o);
34323
34474
  const mintAssetId = decoded;
34475
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34476
+ const gasPrice = decoded;
34324
34477
  return [
34325
34478
  {
34326
34479
  type: 2,
@@ -34328,7 +34481,8 @@ This unreleased fuel-core build may include features and updates not yet support
34328
34481
  inputContract,
34329
34482
  outputContract,
34330
34483
  mintAmount,
34331
- mintAssetId
34484
+ mintAssetId,
34485
+ gasPrice
34332
34486
  },
34333
34487
  o
34334
34488
  ];
@@ -34635,159 +34789,6 @@ This unreleased fuel-core build may include features and updates not yet support
34635
34789
  // src/providers/provider.ts
34636
34790
  var import_graphql_request = __toESM(require_dist2());
34637
34791
 
34638
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
34639
- function _isPlaceholder(a) {
34640
- return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
34641
- }
34642
-
34643
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
34644
- function _curry1(fn) {
34645
- return function f1(a) {
34646
- if (arguments.length === 0 || _isPlaceholder(a)) {
34647
- return f1;
34648
- } else {
34649
- return fn.apply(this, arguments);
34650
- }
34651
- };
34652
- }
34653
-
34654
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
34655
- var isArray_default = Array.isArray || function _isArray(val) {
34656
- return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
34657
- };
34658
-
34659
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
34660
- var type = /* @__PURE__ */ _curry1(function type2(val) {
34661
- return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
34662
- });
34663
- var type_default = type;
34664
-
34665
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
34666
- var pad = function pad2(n) {
34667
- return (n < 10 ? "0" : "") + n;
34668
- };
34669
- var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
34670
- return d.toISOString();
34671
- } : function _toISOString3(d) {
34672
- 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";
34673
- };
34674
-
34675
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
34676
- var isInteger_default = Number.isInteger || function _isInteger(n) {
34677
- return n << 0 === n;
34678
- };
34679
-
34680
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
34681
- function _cloneRegExp(pattern) {
34682
- 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" : ""));
34683
- }
34684
-
34685
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
34686
- function _clone(value, deep, map) {
34687
- map || (map = new _ObjectMap());
34688
- if (_isPrimitive(value)) {
34689
- return value;
34690
- }
34691
- var copy = function copy2(copiedValue) {
34692
- var cachedCopy = map.get(value);
34693
- if (cachedCopy) {
34694
- return cachedCopy;
34695
- }
34696
- map.set(value, copiedValue);
34697
- for (var key in value) {
34698
- if (Object.prototype.hasOwnProperty.call(value, key)) {
34699
- copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
34700
- }
34701
- }
34702
- return copiedValue;
34703
- };
34704
- switch (type_default(value)) {
34705
- case "Object":
34706
- return copy(Object.create(Object.getPrototypeOf(value)));
34707
- case "Array":
34708
- return copy([]);
34709
- case "Date":
34710
- return new Date(value.valueOf());
34711
- case "RegExp":
34712
- return _cloneRegExp(value);
34713
- case "Int8Array":
34714
- case "Uint8Array":
34715
- case "Uint8ClampedArray":
34716
- case "Int16Array":
34717
- case "Uint16Array":
34718
- case "Int32Array":
34719
- case "Uint32Array":
34720
- case "Float32Array":
34721
- case "Float64Array":
34722
- case "BigInt64Array":
34723
- case "BigUint64Array":
34724
- return value.slice();
34725
- default:
34726
- return value;
34727
- }
34728
- }
34729
- function _isPrimitive(param) {
34730
- var type3 = typeof param;
34731
- return param == null || type3 != "object" && type3 != "function";
34732
- }
34733
- var _ObjectMap = /* @__PURE__ */ function() {
34734
- function _ObjectMap2() {
34735
- this.map = {};
34736
- this.length = 0;
34737
- }
34738
- _ObjectMap2.prototype.set = function(key, value) {
34739
- const hashedKey = this.hash(key);
34740
- let bucket = this.map[hashedKey];
34741
- if (!bucket) {
34742
- this.map[hashedKey] = bucket = [];
34743
- }
34744
- bucket.push([key, value]);
34745
- this.length += 1;
34746
- };
34747
- _ObjectMap2.prototype.hash = function(key) {
34748
- let hashedKey = [];
34749
- for (var value in key) {
34750
- hashedKey.push(Object.prototype.toString.call(key[value]));
34751
- }
34752
- return hashedKey.join();
34753
- };
34754
- _ObjectMap2.prototype.get = function(key) {
34755
- if (this.length <= 180) {
34756
- for (const p in this.map) {
34757
- const bucket2 = this.map[p];
34758
- for (let i = 0; i < bucket2.length; i += 1) {
34759
- const element = bucket2[i];
34760
- if (element[0] === key) {
34761
- return element[1];
34762
- }
34763
- }
34764
- }
34765
- return;
34766
- }
34767
- const hashedKey = this.hash(key);
34768
- const bucket = this.map[hashedKey];
34769
- if (!bucket) {
34770
- return;
34771
- }
34772
- for (let i = 0; i < bucket.length; i += 1) {
34773
- const element = bucket[i];
34774
- if (element[0] === key) {
34775
- return element[1];
34776
- }
34777
- }
34778
- };
34779
- return _ObjectMap2;
34780
- }();
34781
-
34782
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
34783
- var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
34784
- return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
34785
- });
34786
- var clone_default = clone2;
34787
-
34788
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
34789
- var hasProtoTrim = typeof String.prototype.trim === "function";
34790
-
34791
34792
  // ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
34792
34793
  var __assign = function() {
34793
34794
  __assign = Object.assign || function __assign2(t) {
@@ -37953,16 +37954,40 @@ spurious results.`);
37953
37954
  var lib_default2 = gql;
37954
37955
 
37955
37956
  // src/providers/__generated__/operations.ts
37957
+ var TransactionStatusSubscriptionFragmentFragmentDoc = lib_default2`
37958
+ fragment transactionStatusSubscriptionFragment on TransactionStatus {
37959
+ type: __typename
37960
+ ... on SubmittedStatus {
37961
+ time
37962
+ }
37963
+ ... on SuccessStatus {
37964
+ block {
37965
+ id
37966
+ }
37967
+ time
37968
+ programState {
37969
+ returnType
37970
+ data
37971
+ }
37972
+ }
37973
+ ... on FailureStatus {
37974
+ block {
37975
+ id
37976
+ }
37977
+ time
37978
+ reason
37979
+ }
37980
+ ... on SqueezedOutStatus {
37981
+ reason
37982
+ }
37983
+ }
37984
+ `;
37956
37985
  var ReceiptFragmentFragmentDoc = lib_default2`
37957
37986
  fragment receiptFragment on Receipt {
37958
- contract {
37959
- id
37960
- }
37987
+ id
37961
37988
  pc
37962
37989
  is
37963
- to {
37964
- id
37965
- }
37990
+ to
37966
37991
  toAddress
37967
37992
  amount
37968
37993
  assetId
@@ -38000,10 +38025,16 @@ spurious results.`);
38000
38025
  id
38001
38026
  }
38002
38027
  time
38028
+ receipts {
38029
+ ...receiptFragment
38030
+ }
38003
38031
  programState {
38004
38032
  returnType
38005
38033
  data
38006
38034
  }
38035
+ receipts {
38036
+ ...receiptFragment
38037
+ }
38007
38038
  }
38008
38039
  ... on FailureStatus {
38009
38040
  block {
@@ -38011,26 +38042,24 @@ spurious results.`);
38011
38042
  }
38012
38043
  time
38013
38044
  reason
38045
+ receipts {
38046
+ ...receiptFragment
38047
+ }
38014
38048
  }
38015
38049
  ... on SqueezedOutStatus {
38016
38050
  reason
38017
38051
  }
38018
38052
  }
38019
- `;
38053
+ ${ReceiptFragmentFragmentDoc}`;
38020
38054
  var TransactionFragmentFragmentDoc = lib_default2`
38021
38055
  fragment transactionFragment on Transaction {
38022
38056
  id
38023
38057
  rawPayload
38024
- gasPrice
38025
- receipts {
38026
- ...receiptFragment
38027
- }
38028
38058
  status {
38029
38059
  ...transactionStatusFragment
38030
38060
  }
38031
38061
  }
38032
- ${ReceiptFragmentFragmentDoc}
38033
- ${TransactionStatusFragmentFragmentDoc}`;
38062
+ ${TransactionStatusFragmentFragmentDoc}`;
38034
38063
  var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
38035
38064
  fragment inputEstimatePredicatesFragment on Input {
38036
38065
  ... on InputCoin {
@@ -38048,6 +38077,46 @@ ${TransactionStatusFragmentFragmentDoc}`;
38048
38077
  }
38049
38078
  }
38050
38079
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
38080
+ var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
38081
+ fragment dryRunFailureStatusFragment on DryRunFailureStatus {
38082
+ reason
38083
+ programState {
38084
+ returnType
38085
+ data
38086
+ }
38087
+ }
38088
+ `;
38089
+ var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
38090
+ fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
38091
+ programState {
38092
+ returnType
38093
+ data
38094
+ }
38095
+ }
38096
+ `;
38097
+ var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
38098
+ fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
38099
+ ... on DryRunFailureStatus {
38100
+ ...dryRunFailureStatusFragment
38101
+ }
38102
+ ... on DryRunSuccessStatus {
38103
+ ...dryRunSuccessStatusFragment
38104
+ }
38105
+ }
38106
+ ${DryRunFailureStatusFragmentFragmentDoc}
38107
+ ${DryRunSuccessStatusFragmentFragmentDoc}`;
38108
+ var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
38109
+ fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
38110
+ id
38111
+ status {
38112
+ ...dryRunTransactionStatusFragment
38113
+ }
38114
+ receipts {
38115
+ ...receiptFragment
38116
+ }
38117
+ }
38118
+ ${DryRunTransactionStatusFragmentFragmentDoc}
38119
+ ${ReceiptFragmentFragmentDoc}`;
38051
38120
  var CoinFragmentFragmentDoc = lib_default2`
38052
38121
  fragment coinFragment on Coin {
38053
38122
  __typename
@@ -38055,7 +38124,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38055
38124
  owner
38056
38125
  amount
38057
38126
  assetId
38058
- maturity
38059
38127
  blockCreated
38060
38128
  txCreatedIdx
38061
38129
  }
@@ -38094,26 +38162,32 @@ ${TransactionStatusFragmentFragmentDoc}`;
38094
38162
  messageBlockHeader {
38095
38163
  id
38096
38164
  daHeight
38165
+ consensusParametersVersion
38166
+ stateTransitionBytecodeVersion
38097
38167
  transactionsCount
38168
+ messageReceiptCount
38098
38169
  transactionsRoot
38170
+ messageOutboxRoot
38171
+ eventInboxRoot
38099
38172
  height
38100
38173
  prevRoot
38101
38174
  time
38102
38175
  applicationHash
38103
- messageReceiptRoot
38104
- messageReceiptCount
38105
38176
  }
38106
38177
  commitBlockHeader {
38107
38178
  id
38108
38179
  daHeight
38180
+ consensusParametersVersion
38181
+ stateTransitionBytecodeVersion
38109
38182
  transactionsCount
38183
+ messageReceiptCount
38110
38184
  transactionsRoot
38185
+ messageOutboxRoot
38186
+ eventInboxRoot
38111
38187
  height
38112
38188
  prevRoot
38113
38189
  time
38114
38190
  applicationHash
38115
- messageReceiptRoot
38116
- messageReceiptCount
38117
38191
  }
38118
38192
  sender
38119
38193
  recipient
@@ -38132,8 +38206,8 @@ ${TransactionStatusFragmentFragmentDoc}`;
38132
38206
  var BlockFragmentFragmentDoc = lib_default2`
38133
38207
  fragment blockFragment on Block {
38134
38208
  id
38209
+ height
38135
38210
  header {
38136
- height
38137
38211
  time
38138
38212
  }
38139
38213
  transactions {
@@ -38191,6 +38265,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
38191
38265
  `;
38192
38266
  var GasCostsFragmentFragmentDoc = lib_default2`
38193
38267
  fragment GasCostsFragment on GasCosts {
38268
+ version {
38269
+ ... on Version {
38270
+ value
38271
+ }
38272
+ }
38194
38273
  add
38195
38274
  addi
38196
38275
  aloc
@@ -38203,7 +38282,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38203
38282
  cb
38204
38283
  cfei
38205
38284
  cfsi
38206
- croo
38207
38285
  div
38208
38286
  divi
38209
38287
  ecr1
@@ -38286,6 +38364,9 @@ ${TransactionStatusFragmentFragmentDoc}`;
38286
38364
  ccp {
38287
38365
  ...DependentCostFragment
38288
38366
  }
38367
+ croo {
38368
+ ...DependentCostFragment
38369
+ }
38289
38370
  csiz {
38290
38371
  ...DependentCostFragment
38291
38372
  }
@@ -38345,6 +38426,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
38345
38426
  ${DependentCostFragmentFragmentDoc}`;
38346
38427
  var ConsensusParametersFragmentFragmentDoc = lib_default2`
38347
38428
  fragment consensusParametersFragment on ConsensusParameters {
38429
+ version {
38430
+ ... on Version {
38431
+ value
38432
+ }
38433
+ }
38348
38434
  txParams {
38349
38435
  ...TxParametersFragment
38350
38436
  }
@@ -38404,18 +38490,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38404
38490
  fragment nodeInfoFragment on NodeInfo {
38405
38491
  utxoValidation
38406
38492
  vmBacktrace
38407
- minGasPrice
38408
38493
  maxTx
38409
38494
  maxDepth
38410
38495
  nodeVersion
38411
- peers {
38412
- id
38413
- addresses
38414
- clientVersion
38415
- blockHeight
38416
- lastHeartbeatMs
38417
- appScore
38418
- }
38419
38496
  }
38420
38497
  `;
38421
38498
  var GetVersionDocument = lib_default2`
@@ -38450,13 +38527,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38450
38527
  query getTransactionWithReceipts($transactionId: TransactionId!) {
38451
38528
  transaction(id: $transactionId) {
38452
38529
  ...transactionFragment
38453
- receipts {
38454
- ...receiptFragment
38455
- }
38456
38530
  }
38457
38531
  }
38458
- ${TransactionFragmentFragmentDoc}
38459
- ${ReceiptFragmentFragmentDoc}`;
38532
+ ${TransactionFragmentFragmentDoc}`;
38460
38533
  var GetTransactionsDocument = lib_default2`
38461
38534
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
38462
38535
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -38584,6 +38657,20 @@ ${MessageCoinFragmentFragmentDoc}`;
38584
38657
  }
38585
38658
  }
38586
38659
  ${BalanceFragmentFragmentDoc}`;
38660
+ var GetLatestGasPriceDocument = lib_default2`
38661
+ query getLatestGasPrice {
38662
+ latestGasPrice {
38663
+ gasPrice
38664
+ }
38665
+ }
38666
+ `;
38667
+ var EstimateGasPriceDocument = lib_default2`
38668
+ query estimateGasPrice($blockHorizon: U32!) {
38669
+ estimateGasPrice(blockHorizon: $blockHorizon) {
38670
+ gasPrice
38671
+ }
38672
+ }
38673
+ `;
38587
38674
  var GetBalancesDocument = lib_default2`
38588
38675
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
38589
38676
  balances(
@@ -38638,12 +38725,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38638
38725
  }
38639
38726
  `;
38640
38727
  var DryRunDocument = lib_default2`
38641
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
38642
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
38643
- ...receiptFragment
38728
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
38729
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
38730
+ ...dryRunTransactionExecutionStatusFragment
38644
38731
  }
38645
38732
  }
38646
- ${ReceiptFragmentFragmentDoc}`;
38733
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
38647
38734
  var SubmitDocument = lib_default2`
38648
38735
  mutation submit($encodedTransaction: HexString!) {
38649
38736
  submit(tx: $encodedTransaction) {
@@ -38662,17 +38749,17 @@ ${MessageCoinFragmentFragmentDoc}`;
38662
38749
  var SubmitAndAwaitDocument = lib_default2`
38663
38750
  subscription submitAndAwait($encodedTransaction: HexString!) {
38664
38751
  submitAndAwait(tx: $encodedTransaction) {
38665
- ...transactionStatusFragment
38752
+ ...transactionStatusSubscriptionFragment
38666
38753
  }
38667
38754
  }
38668
- ${TransactionStatusFragmentFragmentDoc}`;
38755
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
38669
38756
  var StatusChangeDocument = lib_default2`
38670
38757
  subscription statusChange($transactionId: TransactionId!) {
38671
38758
  statusChange(id: $transactionId) {
38672
- ...transactionStatusFragment
38759
+ ...transactionStatusSubscriptionFragment
38673
38760
  }
38674
38761
  }
38675
- ${TransactionStatusFragmentFragmentDoc}`;
38762
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
38676
38763
  function getSdk(requester) {
38677
38764
  return {
38678
38765
  getVersion(variables, options) {
@@ -38726,6 +38813,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38726
38813
  getBalance(variables, options) {
38727
38814
  return requester(GetBalanceDocument, variables, options);
38728
38815
  },
38816
+ getLatestGasPrice(variables, options) {
38817
+ return requester(GetLatestGasPriceDocument, variables, options);
38818
+ },
38819
+ estimateGasPrice(variables, options) {
38820
+ return requester(EstimateGasPriceDocument, variables, options);
38821
+ },
38729
38822
  getBalances(variables, options) {
38730
38823
  return requester(GetBalancesDocument, variables, options);
38731
38824
  },
@@ -38909,10 +39002,9 @@ ${MessageCoinFragmentFragmentDoc}`;
38909
39002
  txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
38910
39003
  },
38911
39004
  witnessIndex: value.witnessIndex,
38912
- maturity: value.maturity ?? 0,
38913
39005
  predicateGasUsed: bn(value.predicateGasUsed),
38914
- predicateLength: predicate.length,
38915
- predicateDataLength: predicateData.length,
39006
+ predicateLength: bn(predicate.length),
39007
+ predicateDataLength: bn(predicateData.length),
38916
39008
  predicate: hexlify(predicate),
38917
39009
  predicateData: hexlify(predicateData)
38918
39010
  };
@@ -38943,8 +39035,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38943
39035
  nonce: hexlify(value.nonce),
38944
39036
  witnessIndex: value.witnessIndex,
38945
39037
  predicateGasUsed: bn(value.predicateGasUsed),
38946
- predicateLength: predicate.length,
38947
- predicateDataLength: predicateData.length,
39038
+ predicateLength: bn(predicate.length),
39039
+ predicateDataLength: bn(predicateData.length),
38948
39040
  predicate: hexlify(predicate),
38949
39041
  predicateData: hexlify(predicateData),
38950
39042
  data: hexlify(data),
@@ -39104,8 +39196,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39104
39196
  case "CALL" /* Call */: {
39105
39197
  const callReceipt = {
39106
39198
  type: ReceiptType.Call,
39107
- from: hexOrZero(receipt.contract?.id),
39108
- to: hexOrZero(receipt?.to?.id),
39199
+ from: hexOrZero(receipt.id || receipt.contractId),
39200
+ to: hexOrZero(receipt?.to),
39109
39201
  amount: bn(receipt.amount),
39110
39202
  assetId: hexOrZero(receipt.assetId),
39111
39203
  gas: bn(receipt.gas),
@@ -39119,7 +39211,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39119
39211
  case "RETURN" /* Return */: {
39120
39212
  const returnReceipt = {
39121
39213
  type: ReceiptType.Return,
39122
- id: hexOrZero(receipt.contract?.id),
39214
+ id: hexOrZero(receipt.id || receipt.contractId),
39123
39215
  val: bn(receipt.val),
39124
39216
  pc: bn(receipt.pc),
39125
39217
  is: bn(receipt.is)
@@ -39129,7 +39221,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39129
39221
  case "RETURN_DATA" /* ReturnData */: {
39130
39222
  const returnDataReceipt = {
39131
39223
  type: ReceiptType.ReturnData,
39132
- id: hexOrZero(receipt.contract?.id),
39224
+ id: hexOrZero(receipt.id || receipt.contractId),
39133
39225
  ptr: bn(receipt.ptr),
39134
39226
  len: bn(receipt.len),
39135
39227
  digest: hexOrZero(receipt.digest),
@@ -39141,7 +39233,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39141
39233
  case "PANIC" /* Panic */: {
39142
39234
  const panicReceipt = {
39143
39235
  type: ReceiptType.Panic,
39144
- id: hexOrZero(receipt.contract?.id),
39236
+ id: hexOrZero(receipt.id),
39145
39237
  reason: bn(receipt.reason),
39146
39238
  pc: bn(receipt.pc),
39147
39239
  is: bn(receipt.is),
@@ -39152,7 +39244,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39152
39244
  case "REVERT" /* Revert */: {
39153
39245
  const revertReceipt = {
39154
39246
  type: ReceiptType.Revert,
39155
- id: hexOrZero(receipt.contract?.id),
39247
+ id: hexOrZero(receipt.id || receipt.contractId),
39156
39248
  val: bn(receipt.ra),
39157
39249
  pc: bn(receipt.pc),
39158
39250
  is: bn(receipt.is)
@@ -39162,7 +39254,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39162
39254
  case "LOG" /* Log */: {
39163
39255
  const logReceipt = {
39164
39256
  type: ReceiptType.Log,
39165
- id: hexOrZero(receipt.contract?.id),
39257
+ id: hexOrZero(receipt.id || receipt.contractId),
39166
39258
  val0: bn(receipt.ra),
39167
39259
  val1: bn(receipt.rb),
39168
39260
  val2: bn(receipt.rc),
@@ -39175,7 +39267,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39175
39267
  case "LOG_DATA" /* LogData */: {
39176
39268
  const logDataReceipt = {
39177
39269
  type: ReceiptType.LogData,
39178
- id: hexOrZero(receipt.contract?.id),
39270
+ id: hexOrZero(receipt.id || receipt.contractId),
39179
39271
  val0: bn(receipt.ra),
39180
39272
  val1: bn(receipt.rb),
39181
39273
  ptr: bn(receipt.ptr),
@@ -39189,8 +39281,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39189
39281
  case "TRANSFER" /* Transfer */: {
39190
39282
  const transferReceipt = {
39191
39283
  type: ReceiptType.Transfer,
39192
- from: hexOrZero(receipt.contract?.id),
39193
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
39284
+ from: hexOrZero(receipt.id || receipt.contractId),
39285
+ to: hexOrZero(receipt.toAddress || receipt?.to),
39194
39286
  amount: bn(receipt.amount),
39195
39287
  assetId: hexOrZero(receipt.assetId),
39196
39288
  pc: bn(receipt.pc),
@@ -39201,8 +39293,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39201
39293
  case "TRANSFER_OUT" /* TransferOut */: {
39202
39294
  const transferOutReceipt = {
39203
39295
  type: ReceiptType.TransferOut,
39204
- from: hexOrZero(receipt.contract?.id),
39205
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
39296
+ from: hexOrZero(receipt.id || receipt.contractId),
39297
+ to: hexOrZero(receipt.toAddress || receipt.to),
39206
39298
  amount: bn(receipt.amount),
39207
39299
  assetId: hexOrZero(receipt.assetId),
39208
39300
  pc: bn(receipt.pc),
@@ -39245,7 +39337,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39245
39337
  return receiptMessageOut;
39246
39338
  }
39247
39339
  case "MINT" /* Mint */: {
39248
- const contractId = hexOrZero(receipt.contract?.id);
39340
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
39249
39341
  const subId = hexOrZero(receipt.subId);
39250
39342
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
39251
39343
  const mintReceipt = {
@@ -39260,7 +39352,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39260
39352
  return mintReceipt;
39261
39353
  }
39262
39354
  case "BURN" /* Burn */: {
39263
- const contractId = hexOrZero(receipt.contract?.id);
39355
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
39264
39356
  const subId = hexOrZero(receipt.subId);
39265
39357
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
39266
39358
  const burnReceipt = {
@@ -39341,7 +39433,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39341
39433
  };
39342
39434
 
39343
39435
  // src/providers/utils/gas.ts
39344
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
39345
39436
  var getGasUsedFromReceipts = (receipts) => {
39346
39437
  const scriptResult = receipts.filter(
39347
39438
  (receipt) => receipt.type === ReceiptType.ScriptResult
@@ -39362,18 +39453,28 @@ ${MessageCoinFragmentFragmentDoc}`;
39362
39453
  }
39363
39454
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
39364
39455
  const witnessCache = [];
39365
- const totalGas = inputs.reduce((total, input) => {
39456
+ const chargeableInputs = inputs.filter((input) => {
39457
+ const isCoinOrMessage = "owner" in input || "sender" in input;
39458
+ if (isCoinOrMessage) {
39459
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39460
+ return true;
39461
+ }
39462
+ if (!witnessCache.includes(input.witnessIndex)) {
39463
+ witnessCache.push(input.witnessIndex);
39464
+ return true;
39465
+ }
39466
+ }
39467
+ return false;
39468
+ });
39469
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
39470
+ const totalGas = chargeableInputs.reduce((total, input) => {
39366
39471
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39367
39472
  return total.add(
39368
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39473
+ vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39369
39474
  );
39370
39475
  }
39371
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
39372
- witnessCache.push(input.witnessIndex);
39373
- return total.add(gasCosts.ecr1);
39374
- }
39375
- return total;
39376
- }, bn());
39476
+ return total.add(gasCosts.ecr1);
39477
+ }, bn(0));
39377
39478
  return totalGas;
39378
39479
  }
39379
39480
  function getMinGas(params) {
@@ -39385,12 +39486,20 @@ ${MessageCoinFragmentFragmentDoc}`;
39385
39486
  return minGas;
39386
39487
  }
39387
39488
  function getMaxGas(params) {
39388
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
39489
+ const {
39490
+ gasPerByte,
39491
+ witnessesLength,
39492
+ witnessLimit,
39493
+ minGas,
39494
+ gasLimit = bn(0),
39495
+ maxGasPerTx
39496
+ } = params;
39389
39497
  let remainingAllowedWitnessGas = bn(0);
39390
39498
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
39391
39499
  remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
39392
39500
  }
39393
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39501
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39502
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
39394
39503
  }
39395
39504
  function calculateMetadataGasForTxCreate({
39396
39505
  gasCosts,
@@ -39412,6 +39521,10 @@ ${MessageCoinFragmentFragmentDoc}`;
39412
39521
  }) {
39413
39522
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
39414
39523
  }
39524
+ var calculateGasFee = (params) => {
39525
+ const { gas, gasPrice, priceFactor, tip } = params;
39526
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
39527
+ };
39415
39528
 
39416
39529
  // src/providers/utils/json.ts
39417
39530
  function normalize2(object) {
@@ -39541,27 +39654,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39541
39654
  name = "NoWitnessByOwnerError";
39542
39655
  };
39543
39656
 
39544
- // src/providers/transaction-request/helpers.ts
39545
- var isRequestInputCoin = (input) => input.type === InputType.Coin;
39546
- var isRequestInputMessage = (input) => input.type === InputType.Message;
39547
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
39548
- var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
39549
- var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
39550
- var cacheResources = (resources) => resources.reduce(
39551
- (cache2, resource) => {
39552
- if (isCoin(resource)) {
39553
- cache2.utxos.push(resource.id);
39554
- } else {
39555
- cache2.messages.push(resource.nonce);
39556
- }
39557
- return cache2;
39558
- },
39559
- {
39560
- utxos: [],
39561
- messages: []
39562
- }
39563
- );
39564
-
39565
39657
  // src/providers/transaction-request/witness.ts
39566
39658
  var witnessify = (value) => {
39567
39659
  const data = arrayify(value);
@@ -39574,7 +39666,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39574
39666
  // src/providers/transaction-request/transaction-request.ts
39575
39667
  var BaseTransactionRequest = class {
39576
39668
  /** Gas price for transaction */
39577
- gasPrice;
39669
+ tip;
39578
39670
  /** Block until which tx cannot be included */
39579
39671
  maturity;
39580
39672
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -39593,7 +39685,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39593
39685
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
39594
39686
  */
39595
39687
  constructor({
39596
- gasPrice,
39688
+ tip,
39597
39689
  maturity,
39598
39690
  maxFee,
39599
39691
  witnessLimit,
@@ -39601,7 +39693,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39601
39693
  outputs,
39602
39694
  witnesses
39603
39695
  } = {}) {
39604
- this.gasPrice = bn(gasPrice);
39696
+ this.tip = bn(tip);
39605
39697
  this.maturity = maturity ?? 0;
39606
39698
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
39607
39699
  this.maxFee = maxFee ? bn(maxFee) : void 0;
@@ -39612,9 +39704,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39612
39704
  static getPolicyMeta(req) {
39613
39705
  let policyTypes = 0;
39614
39706
  const policies = [];
39615
- if (req.gasPrice) {
39616
- policyTypes += PolicyType.GasPrice;
39617
- policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
39707
+ if (req.tip) {
39708
+ policyTypes += PolicyType.Tip;
39709
+ policies.push({ data: req.tip, type: PolicyType.Tip });
39618
39710
  }
39619
39711
  if (req.witnessLimit) {
39620
39712
  policyTypes += PolicyType.WitnessLimit;
@@ -39802,9 +39894,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39802
39894
  * @param predicateData - Predicate data bytes.
39803
39895
  */
39804
39896
  addCoinInput(coin) {
39805
- const { assetId, owner, amount, id, predicate } = coin;
39897
+ const { assetId, owner, amount } = coin;
39806
39898
  let witnessIndex;
39807
- if (predicate) {
39899
+ if (coin.predicate) {
39808
39900
  witnessIndex = 0;
39809
39901
  } else {
39810
39902
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -39813,14 +39905,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39813
39905
  }
39814
39906
  }
39815
39907
  const input = {
39816
- id,
39908
+ ...coin,
39817
39909
  type: InputType.Coin,
39818
39910
  owner: owner.toB256(),
39819
39911
  amount,
39820
39912
  assetId,
39821
39913
  txPointer: "0x00000000000000000000000000000000",
39822
- witnessIndex,
39823
- predicate
39914
+ witnessIndex
39824
39915
  };
39825
39916
  this.pushInput(input);
39826
39917
  this.addChangeOutput(owner, assetId);
@@ -39834,10 +39925,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39834
39925
  * @param predicateData - Predicate data bytes.
39835
39926
  */
39836
39927
  addMessageInput(message) {
39837
- const { recipient, sender, amount, predicate, nonce } = message;
39928
+ const { recipient, sender, amount } = message;
39838
39929
  const assetId = BaseAssetId;
39839
39930
  let witnessIndex;
39840
- if (predicate) {
39931
+ if (message.predicate) {
39841
39932
  witnessIndex = 0;
39842
39933
  } else {
39843
39934
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -39846,13 +39937,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39846
39937
  }
39847
39938
  }
39848
39939
  const input = {
39849
- nonce,
39940
+ ...message,
39850
39941
  type: InputType.Message,
39851
39942
  sender: sender.toB256(),
39852
39943
  recipient: recipient.toB256(),
39853
39944
  amount,
39854
- witnessIndex,
39855
- predicate
39945
+ witnessIndex
39856
39946
  };
39857
39947
  this.pushInput(input);
39858
39948
  this.addChangeOutput(recipient, assetId);
@@ -39962,7 +40052,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39962
40052
  }
39963
40053
  calculateMaxGas(chainInfo, minGas) {
39964
40054
  const { consensusParameters } = chainInfo;
39965
- const { gasPerByte } = consensusParameters;
40055
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
39966
40056
  const witnessesLength = this.toTransaction().witnesses.reduce(
39967
40057
  (acc, wit) => acc + wit.dataLength,
39968
40058
  0
@@ -39971,7 +40061,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39971
40061
  gasPerByte,
39972
40062
  minGas,
39973
40063
  witnessesLength,
39974
- witnessLimit: this.witnessLimit
40064
+ witnessLimit: this.witnessLimit,
40065
+ maxGasPerTx
39975
40066
  });
39976
40067
  }
39977
40068
  /**
@@ -39989,17 +40080,20 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39989
40080
  });
39990
40081
  const updateAssetInput = (assetId, quantity) => {
39991
40082
  const assetInput = findAssetInput(assetId);
40083
+ let usedQuantity = quantity;
40084
+ if (assetId === BaseAssetId) {
40085
+ usedQuantity = bn("1000000000000000000");
40086
+ }
39992
40087
  if (assetInput && "assetId" in assetInput) {
39993
40088
  assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
39994
- assetInput.amount = quantity;
40089
+ assetInput.amount = usedQuantity;
39995
40090
  } else {
39996
40091
  this.addResources([
39997
40092
  {
39998
40093
  id: hexlify(randomBytes22(UTXO_ID_LEN)),
39999
- amount: quantity,
40094
+ amount: usedQuantity,
40000
40095
  assetId,
40001
40096
  owner: resourcesOwner || Address.fromRandom(),
40002
- maturity: 0,
40003
40097
  blockCreated: bn(1),
40004
40098
  txCreatedIdx: bn(1)
40005
40099
  }
@@ -40031,11 +40125,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40031
40125
  toJSON() {
40032
40126
  return normalizeJSON(this);
40033
40127
  }
40034
- removeWitness(index) {
40035
- this.witnesses.splice(index, 1);
40036
- this.adjustWitnessIndexes(index);
40037
- }
40038
- updatePredicateInputs(inputs) {
40128
+ updatePredicateGasUsed(inputs) {
40039
40129
  this.inputs.forEach((i) => {
40040
40130
  let correspondingInput;
40041
40131
  switch (i.type) {
@@ -40057,10 +40147,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40057
40147
  }
40058
40148
  });
40059
40149
  }
40060
- adjustWitnessIndexes(removedIndex) {
40061
- this.inputs.filter(isRequestInputResource).forEach((input) => {
40062
- if (input.witnessIndex > removedIndex) {
40063
- input.witnessIndex -= 1;
40150
+ shiftPredicateData() {
40151
+ this.inputs.forEach((input) => {
40152
+ if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
40153
+ input.predicateData = input.paddPredicateData(
40154
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
40155
+ );
40064
40156
  }
40065
40157
  });
40066
40158
  }
@@ -40197,9 +40289,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40197
40289
  return {
40198
40290
  type: TransactionType.Create,
40199
40291
  ...baseTransaction,
40200
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
40201
40292
  bytecodeWitnessIndex,
40202
- storageSlotsCount: storageSlots.length,
40293
+ storageSlotsCount: bn(storageSlots.length),
40203
40294
  salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
40204
40295
  storageSlots
40205
40296
  };
@@ -40313,8 +40404,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40313
40404
  type: TransactionType.Script,
40314
40405
  scriptGasLimit: this.gasLimit,
40315
40406
  ...super.getBaseTransaction(),
40316
- scriptLength: script.length,
40317
- scriptDataLength: scriptData.length,
40407
+ scriptLength: bn(script.length),
40408
+ scriptDataLength: bn(scriptData.length),
40318
40409
  receiptsRoot: ZeroBytes32,
40319
40410
  script: hexlify(script),
40320
40411
  scriptData: hexlify(scriptData)
@@ -40378,7 +40469,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40378
40469
  }
40379
40470
  calculateMaxGas(chainInfo, minGas) {
40380
40471
  const { consensusParameters } = chainInfo;
40381
- const { gasPerByte } = consensusParameters;
40472
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
40382
40473
  const witnessesLength = this.toTransaction().witnesses.reduce(
40383
40474
  (acc, wit) => acc + wit.dataLength,
40384
40475
  0
@@ -40388,7 +40479,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40388
40479
  minGas,
40389
40480
  witnessesLength,
40390
40481
  witnessLimit: this.witnessLimit,
40391
- gasLimit: this.gasLimit
40482
+ gasLimit: this.gasLimit,
40483
+ maxGasPerTx
40392
40484
  });
40393
40485
  }
40394
40486
  /**
@@ -40461,13 +40553,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40461
40553
  }
40462
40554
  }
40463
40555
  };
40556
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
40557
+ (acc, input) => {
40558
+ if (input.type === InputType.Coin && input.owner === owner) {
40559
+ acc.utxos.push(input.id);
40560
+ }
40561
+ if (input.type === InputType.Message && input.recipient === owner) {
40562
+ acc.messages.push(input.nonce);
40563
+ }
40564
+ return acc;
40565
+ },
40566
+ {
40567
+ utxos: [],
40568
+ messages: []
40569
+ }
40570
+ );
40464
40571
 
40465
40572
  // src/providers/transaction-summary/calculate-transaction-fee.ts
40466
40573
  var calculateTransactionFee = (params) => {
40467
40574
  const {
40468
- gasUsed,
40575
+ gasPrice,
40469
40576
  rawPayload,
40470
- consensusParameters: { gasCosts, feeParams }
40577
+ tip,
40578
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
40471
40579
  } = params;
40472
40580
  const gasPerByte = bn(feeParams.gasPerByte);
40473
40581
  const gasPriceFactor = bn(feeParams.gasPriceFactor);
@@ -40477,8 +40585,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40477
40585
  return {
40478
40586
  fee: bn(0),
40479
40587
  minFee: bn(0),
40480
- maxFee: bn(0),
40481
- feeFromGasUsed: bn(0)
40588
+ maxFee: bn(0)
40482
40589
  };
40483
40590
  }
40484
40591
  const { type: type3, witnesses, inputs, policies } = transaction;
@@ -40510,7 +40617,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40510
40617
  metadataGas,
40511
40618
  txBytesSize: transactionBytes.length
40512
40619
  });
40513
- const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
40514
40620
  const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
40515
40621
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
40516
40622
  const maxGas = getMaxGas({
@@ -40518,17 +40624,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40518
40624
  minGas,
40519
40625
  witnessesLength,
40520
40626
  gasLimit,
40521
- witnessLimit
40627
+ witnessLimit,
40628
+ maxGasPerTx
40629
+ });
40630
+ const minFee = calculateGasFee({
40631
+ gasPrice,
40632
+ gas: minGas,
40633
+ priceFactor: gasPriceFactor,
40634
+ tip
40635
+ });
40636
+ const maxFee = calculateGasFee({
40637
+ gasPrice,
40638
+ gas: maxGas,
40639
+ priceFactor: gasPriceFactor,
40640
+ tip
40522
40641
  });
40523
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
40524
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
40525
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
40526
- const fee = minFee.add(feeFromGasUsed);
40527
40642
  return {
40528
- fee,
40529
40643
  minFee,
40530
40644
  maxFee,
40531
- feeFromGasUsed
40645
+ fee: maxFee
40532
40646
  };
40533
40647
  };
40534
40648
 
@@ -41129,7 +41243,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41129
41243
  gqlTransactionStatus,
41130
41244
  abiMap = {},
41131
41245
  maxInputs,
41132
- gasCosts
41246
+ gasCosts,
41247
+ maxGasPerTx,
41248
+ gasPrice
41133
41249
  } = params;
41134
41250
  const gasUsed = getGasUsedFromReceipts(receipts);
41135
41251
  const rawPayload = hexlify(transactionBytes);
@@ -41143,11 +41259,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41143
41259
  maxInputs
41144
41260
  });
41145
41261
  const typeName = getTransactionTypeName(transaction.type);
41262
+ const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
41146
41263
  const { fee } = calculateTransactionFee({
41147
- gasUsed,
41264
+ gasPrice,
41148
41265
  rawPayload,
41266
+ tip,
41149
41267
  consensusParameters: {
41150
41268
  gasCosts,
41269
+ maxGasPerTx,
41151
41270
  feeParams: {
41152
41271
  gasPerByte,
41153
41272
  gasPriceFactor
@@ -41283,8 +41402,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41283
41402
  const decodedTransaction = this.decodeTransaction(
41284
41403
  transaction
41285
41404
  );
41286
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
41287
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
41405
+ let txReceipts = [];
41406
+ if (transaction?.status && "receipts" in transaction.status) {
41407
+ txReceipts = transaction.status.receipts;
41408
+ }
41409
+ const receipts = txReceipts.map(processGqlReceipt) || [];
41410
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
41411
+ const gasPrice = await this.provider.getLatestGasPrice();
41288
41412
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
41289
41413
  const transactionSummary = assembleTransactionSummary({
41290
41414
  id: this.id,
@@ -41296,7 +41420,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41296
41420
  gasPriceFactor,
41297
41421
  abiMap: contractsAbiMap,
41298
41422
  maxInputs,
41299
- gasCosts
41423
+ gasCosts,
41424
+ maxGasPerTx,
41425
+ gasPrice
41300
41426
  });
41301
41427
  return transactionSummary;
41302
41428
  }
@@ -41445,7 +41571,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41445
41571
  gasCosts,
41446
41572
  latestBlock: {
41447
41573
  id: latestBlock.id,
41448
- height: bn(latestBlock.header.height),
41574
+ height: bn(latestBlock.height),
41449
41575
  time: latestBlock.header.time,
41450
41576
  transactions: latestBlock.transactions.map((i) => ({
41451
41577
  id: i.id
@@ -41539,10 +41665,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41539
41665
  * Returns some helpful parameters related to gas fees.
41540
41666
  */
41541
41667
  getGasConfig() {
41542
- const { minGasPrice } = this.getNode();
41543
41668
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
41544
41669
  return {
41545
- minGasPrice,
41546
41670
  maxGasPerTx,
41547
41671
  maxGasPerPredicate,
41548
41672
  gasPriceFactor,
@@ -41640,7 +41764,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41640
41764
  */
41641
41765
  async getBlockNumber() {
41642
41766
  const { chain } = await this.operations.getChain();
41643
- return bn(chain.latestBlock.header.height, 10);
41767
+ return bn(chain.latestBlock.height, 10);
41644
41768
  }
41645
41769
  /**
41646
41770
  * Returns the chain information.
@@ -41652,11 +41776,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41652
41776
  const processedNodeInfo = {
41653
41777
  maxDepth: bn(nodeInfo.maxDepth),
41654
41778
  maxTx: bn(nodeInfo.maxTx),
41655
- minGasPrice: bn(nodeInfo.minGasPrice),
41656
41779
  nodeVersion: nodeInfo.nodeVersion,
41657
41780
  utxoValidation: nodeInfo.utxoValidation,
41658
- vmBacktrace: nodeInfo.vmBacktrace,
41659
- peers: nodeInfo.peers
41781
+ vmBacktrace: nodeInfo.vmBacktrace
41660
41782
  };
41661
41783
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
41662
41784
  return processedNodeInfo;
@@ -41742,14 +41864,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41742
41864
  return this.estimateTxDependencies(transactionRequest);
41743
41865
  }
41744
41866
  const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41745
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41746
- encodedTransaction,
41867
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
41868
+ encodedTransactions: encodedTransaction,
41747
41869
  utxoValidation: utxoValidation || false
41748
41870
  });
41749
- const receipts = gqlReceipts.map(processGqlReceipt);
41750
- return {
41751
- receipts
41752
- };
41871
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
41872
+ const receipts = rawReceipts.map(processGqlReceipt);
41873
+ return { receipts, dryrunStatus: status };
41753
41874
  }
41754
41875
  /**
41755
41876
  * Verifies whether enough gas is available to complete transaction.
@@ -41788,9 +41909,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41788
41909
  * If there are missing variable outputs,
41789
41910
  * `addVariableOutputs` is called on the transaction.
41790
41911
  *
41791
- * @privateRemarks
41792
- * TODO: Investigate support for missing contract IDs
41793
- * TODO: Add support for missing output messages
41794
41912
  *
41795
41913
  * @param transactionRequest - The transaction request object.
41796
41914
  * @returns A promise.
@@ -41803,16 +41921,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41803
41921
  missingContractIds: []
41804
41922
  };
41805
41923
  }
41806
- await this.estimatePredicates(transactionRequest);
41807
41924
  let receipts = [];
41808
41925
  const missingContractIds = [];
41809
41926
  let outputVariables = 0;
41927
+ let dryrunStatus;
41810
41928
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
41811
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41812
- encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
41929
+ const {
41930
+ dryRun: [{ receipts: rawReceipts, status }]
41931
+ } = await this.operations.dryRun({
41932
+ encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
41813
41933
  utxoValidation: false
41814
41934
  });
41815
- receipts = gqlReceipts.map(processGqlReceipt);
41935
+ receipts = rawReceipts.map(processGqlReceipt);
41936
+ dryrunStatus = status;
41816
41937
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
41817
41938
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
41818
41939
  if (hasMissingOutputs) {
@@ -41822,6 +41943,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41822
41943
  transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
41823
41944
  missingContractIds.push(contractId);
41824
41945
  });
41946
+ const { maxFee } = await this.estimateTxGasAndFee({
41947
+ transactionRequest
41948
+ });
41949
+ transactionRequest.maxFee = maxFee;
41825
41950
  } else {
41826
41951
  break;
41827
41952
  }
@@ -41829,37 +41954,139 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41829
41954
  return {
41830
41955
  receipts,
41831
41956
  outputVariables,
41832
- missingContractIds
41957
+ missingContractIds,
41958
+ dryrunStatus
41833
41959
  };
41834
41960
  }
41961
+ /**
41962
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
41963
+ *
41964
+ * Transactions are dry run in batches. After each dry run, transactions requiring
41965
+ * further modifications are identified. The method iteratively updates these transactions
41966
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
41967
+ *
41968
+ * @param transactionRequests - Array of transaction request objects.
41969
+ * @returns A promise that resolves to an array of results for each transaction.
41970
+ */
41971
+ async estimateMultipleTxDependencies(transactionRequests) {
41972
+ const results = transactionRequests.map(() => ({
41973
+ receipts: [],
41974
+ outputVariables: 0,
41975
+ missingContractIds: [],
41976
+ dryrunStatus: void 0
41977
+ }));
41978
+ const allRequests = clone_default(transactionRequests);
41979
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
41980
+ allRequests.forEach((req, index) => {
41981
+ if (req.type === TransactionType.Script) {
41982
+ serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
41983
+ }
41984
+ });
41985
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
41986
+ let attempt = 0;
41987
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
41988
+ const encodedTransactions = transactionsToProcess.map(
41989
+ (index) => serializedTransactionsMap.get(index)
41990
+ );
41991
+ const dryRunResults = await this.operations.dryRun({
41992
+ encodedTransactions,
41993
+ utxoValidation: false
41994
+ });
41995
+ const nextRoundTransactions = [];
41996
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
41997
+ const currentResultIndex = transactionsToProcess[i];
41998
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
41999
+ results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
42000
+ results[currentResultIndex].dryrunStatus = status;
42001
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
42002
+ results[currentResultIndex].receipts
42003
+ );
42004
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
42005
+ const requestToProcess = allRequests[currentResultIndex];
42006
+ if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
42007
+ results[currentResultIndex].outputVariables += missingOutputVariables.length;
42008
+ requestToProcess.addVariableOutputs(missingOutputVariables.length);
42009
+ missingOutputContractIds.forEach(({ contractId }) => {
42010
+ requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
42011
+ results[currentResultIndex].missingContractIds.push(contractId);
42012
+ });
42013
+ const { maxFee } = await this.estimateTxGasAndFee({
42014
+ transactionRequest: requestToProcess
42015
+ });
42016
+ requestToProcess.maxFee = maxFee;
42017
+ serializedTransactionsMap.set(
42018
+ currentResultIndex,
42019
+ hexlify(requestToProcess.toTransactionBytes())
42020
+ );
42021
+ nextRoundTransactions.push(currentResultIndex);
42022
+ allRequests[currentResultIndex] = requestToProcess;
42023
+ }
42024
+ }
42025
+ transactionsToProcess = nextRoundTransactions;
42026
+ attempt += 1;
42027
+ }
42028
+ return results;
42029
+ }
42030
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
42031
+ if (estimateTxDependencies) {
42032
+ return this.estimateMultipleTxDependencies(transactionRequests);
42033
+ }
42034
+ const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
42035
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42036
+ encodedTransactions,
42037
+ utxoValidation: utxoValidation || false
42038
+ });
42039
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
42040
+ const receipts = rawReceipts.map(processGqlReceipt);
42041
+ return { receipts, dryrunStatus: status };
42042
+ });
42043
+ return results;
42044
+ }
41835
42045
  /**
41836
42046
  * Estimates the transaction gas and fee based on the provided transaction request.
41837
42047
  * @param transactionRequest - The transaction request object.
41838
42048
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41839
42049
  */
41840
- estimateTxGasAndFee(params) {
42050
+ async estimateTxGasAndFee(params) {
41841
42051
  const { transactionRequest } = params;
41842
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
42052
+ let { gasPrice } = params;
41843
42053
  const chainInfo = this.getChain();
41844
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41845
- transactionRequest.gasPrice = gasPrice;
42054
+ const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
41846
42055
  const minGas = transactionRequest.calculateMinGas(chainInfo);
41847
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42056
+ if (!gasPrice) {
42057
+ gasPrice = await this.estimateGasPrice(10);
42058
+ }
42059
+ const minFee = calculateGasFee({
42060
+ gasPrice: bn(gasPrice),
42061
+ gas: minGas,
42062
+ priceFactor: gasPriceFactor,
42063
+ tip: transactionRequest.tip
42064
+ }).add(1);
42065
+ let gasLimit = bn(0);
41848
42066
  if (transactionRequest.type === TransactionType.Script) {
42067
+ gasLimit = transactionRequest.gasLimit;
41849
42068
  if (transactionRequest.gasLimit.eq(0)) {
41850
42069
  transactionRequest.gasLimit = minGas;
41851
42070
  transactionRequest.gasLimit = maxGasPerTx.sub(
41852
42071
  transactionRequest.calculateMaxGas(chainInfo, minGas)
41853
42072
  );
42073
+ gasLimit = transactionRequest.gasLimit;
41854
42074
  }
41855
42075
  }
41856
42076
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41857
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42077
+ const maxFee = calculateGasFee({
42078
+ gasPrice: bn(gasPrice),
42079
+ gas: maxGas,
42080
+ priceFactor: gasPriceFactor,
42081
+ tip: transactionRequest.tip
42082
+ }).add(1);
41858
42083
  return {
41859
42084
  minGas,
41860
42085
  minFee,
41861
42086
  maxGas,
41862
- maxFee
42087
+ maxFee,
42088
+ gasPrice,
42089
+ gasLimit
41863
42090
  };
41864
42091
  }
41865
42092
  /**
@@ -41877,15 +42104,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41877
42104
  if (estimateTxDependencies) {
41878
42105
  return this.estimateTxDependencies(transactionRequest);
41879
42106
  }
41880
- const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41881
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41882
- encodedTransaction,
42107
+ const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
42108
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42109
+ encodedTransactions,
41883
42110
  utxoValidation: true
41884
42111
  });
41885
- const receipts = gqlReceipts.map(processGqlReceipt);
41886
- return {
41887
- receipts
41888
- };
42112
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
42113
+ const { id, receipts, status } = dryRunStatus;
42114
+ const processedReceipts = receipts.map(processGqlReceipt);
42115
+ return { id, receipts: processedReceipts, status };
42116
+ });
42117
+ return { receipts: callResult[0].receipts };
41889
42118
  }
41890
42119
  /**
41891
42120
  * Returns a transaction cost to enable user
@@ -41902,77 +42131,79 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41902
42131
  * @param tolerance - The tolerance to add on top of the gasUsed.
41903
42132
  * @returns A promise that resolves to the transaction cost object.
41904
42133
  */
41905
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
41906
- estimateTxDependencies = true,
41907
- estimatePredicates = true,
41908
- resourcesOwner,
41909
- signatureCallback
41910
- } = {}) {
42134
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
41911
42135
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41912
- const { minGasPrice } = this.getGasConfig();
41913
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41914
42136
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41915
42137
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41916
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
42138
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
41917
42139
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
42140
+ txRequestClone.maxFee = bn(0);
41918
42141
  if (isScriptTransaction) {
41919
42142
  txRequestClone.gasLimit = bn(0);
41920
42143
  }
41921
- if (estimatePredicates) {
41922
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41923
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
41924
- }
41925
- await this.estimatePredicates(txRequestClone);
42144
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
42145
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
41926
42146
  }
42147
+ const signedRequest = clone_default(txRequestClone);
42148
+ let addedSignatures = 0;
41927
42149
  if (signatureCallback && isScriptTransaction) {
41928
- await signatureCallback(txRequestClone);
42150
+ const lengthBefore = signedRequest.witnesses.length;
42151
+ await signatureCallback(signedRequest);
42152
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
41929
42153
  }
41930
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41931
- transactionRequest: txRequestClone
42154
+ await this.estimatePredicates(signedRequest);
42155
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
42156
+ transactionRequest: signedRequest
41932
42157
  });
41933
42158
  let receipts = [];
41934
42159
  let missingContractIds = [];
41935
42160
  let outputVariables = 0;
41936
42161
  let gasUsed = bn(0);
41937
- if (isScriptTransaction && estimateTxDependencies) {
41938
- txRequestClone.gasPrice = bn(0);
42162
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
42163
+ txRequestClone.maxFee = maxFee;
42164
+ if (isScriptTransaction) {
42165
+ txRequestClone.gasLimit = gasLimit;
42166
+ if (signatureCallback) {
42167
+ await signatureCallback(txRequestClone);
42168
+ }
41939
42169
  const result = await this.estimateTxDependencies(txRequestClone);
41940
42170
  receipts = result.receipts;
41941
42171
  outputVariables = result.outputVariables;
41942
42172
  missingContractIds = result.missingContractIds;
41943
42173
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41944
42174
  txRequestClone.gasLimit = gasUsed;
41945
- txRequestClone.gasPrice = setGasPrice;
41946
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41947
- transactionRequest: txRequestClone
42175
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
42176
+ transactionRequest: txRequestClone,
42177
+ gasPrice
41948
42178
  }));
41949
42179
  }
41950
42180
  return {
41951
42181
  requiredQuantities: allQuantities,
41952
42182
  receipts,
41953
42183
  gasUsed,
41954
- minGasPrice,
41955
- gasPrice: setGasPrice,
42184
+ gasPrice,
41956
42185
  minGas,
41957
42186
  maxGas,
41958
42187
  minFee,
41959
42188
  maxFee,
41960
- estimatedInputs: txRequestClone.inputs,
41961
42189
  outputVariables,
41962
- missingContractIds
42190
+ missingContractIds,
42191
+ addedSignatures,
42192
+ estimatedPredicates: txRequestClone.inputs
41963
42193
  };
41964
42194
  }
41965
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
42195
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
41966
42196
  const ownerAddress = Address.fromAddressOrString(owner);
41967
42197
  const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
41968
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
42198
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
42199
+ quantitiesToContract
42200
+ });
41969
42201
  transactionRequest.addResources(
41970
42202
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
41971
42203
  );
41972
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
41973
- transactionRequest,
41974
- forwardingQuantities
41975
- );
42204
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
42205
+ quantitiesToContract
42206
+ });
41976
42207
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
41977
42208
  return {
41978
42209
  resources,
@@ -41996,7 +42227,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41996
42227
  assetId: coin.assetId,
41997
42228
  amount: bn(coin.amount),
41998
42229
  owner: Address.fromAddressOrString(coin.owner),
41999
- maturity: bn(coin.maturity).toNumber(),
42000
42230
  blockCreated: bn(coin.blockCreated),
42001
42231
  txCreatedIdx: bn(coin.txCreatedIdx)
42002
42232
  }));
@@ -42048,7 +42278,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42048
42278
  amount: bn(coin.amount),
42049
42279
  assetId: coin.assetId,
42050
42280
  owner: Address.fromAddressOrString(coin.owner),
42051
- maturity: bn(coin.maturity).toNumber(),
42052
42281
  blockCreated: bn(coin.blockCreated),
42053
42282
  txCreatedIdx: bn(coin.txCreatedIdx)
42054
42283
  };
@@ -42081,7 +42310,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42081
42310
  }
42082
42311
  return {
42083
42312
  id: block2.id,
42084
- height: bn(block2.header.height),
42313
+ height: bn(block2.height),
42085
42314
  time: block2.header.time,
42086
42315
  transactionIds: block2.transactions.map((tx) => tx.id)
42087
42316
  };
@@ -42096,7 +42325,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42096
42325
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
42097
42326
  const blocks = fetchedData.edges.map(({ node: block2 }) => ({
42098
42327
  id: block2.id,
42099
- height: bn(block2.header.height),
42328
+ height: bn(block2.height),
42100
42329
  time: block2.header.time,
42101
42330
  transactionIds: block2.transactions.map((tx) => tx.id)
42102
42331
  }));
@@ -42123,7 +42352,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42123
42352
  }
42124
42353
  return {
42125
42354
  id: block2.id,
42126
- height: bn(block2.header.height, 10),
42355
+ height: bn(block2.height, 10),
42127
42356
  time: block2.header.time,
42128
42357
  transactionIds: block2.transactions.map((tx) => tx.id),
42129
42358
  transactions: block2.transactions.map(
@@ -42303,8 +42532,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42303
42532
  prevRoot: messageBlockHeader.prevRoot,
42304
42533
  time: messageBlockHeader.time,
42305
42534
  applicationHash: messageBlockHeader.applicationHash,
42306
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
42307
- messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
42535
+ messageReceiptCount: bn(messageBlockHeader.messageReceiptCount),
42536
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
42537
+ consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
42538
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
42539
+ stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
42308
42540
  },
42309
42541
  commitBlockHeader: {
42310
42542
  id: commitBlockHeader.id,
@@ -42315,8 +42547,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42315
42547
  prevRoot: commitBlockHeader.prevRoot,
42316
42548
  time: commitBlockHeader.time,
42317
42549
  applicationHash: commitBlockHeader.applicationHash,
42318
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
42319
- messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
42550
+ messageReceiptCount: bn(commitBlockHeader.messageReceiptCount),
42551
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
42552
+ consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
42553
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
42554
+ stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
42320
42555
  },
42321
42556
  sender: Address.fromAddressOrString(sender),
42322
42557
  recipient: Address.fromAddressOrString(recipient),
@@ -42325,6 +42560,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42325
42560
  data
42326
42561
  };
42327
42562
  }
42563
+ async getLatestGasPrice() {
42564
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
42565
+ return bn(latestGasPrice.gasPrice);
42566
+ }
42567
+ async estimateGasPrice(blockHorizon) {
42568
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
42569
+ blockHorizon: String(blockHorizon)
42570
+ });
42571
+ return bn(estimateGasPrice.gasPrice);
42572
+ }
42328
42573
  /**
42329
42574
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
42330
42575
  *
@@ -42385,10 +42630,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42385
42630
  arrayify(gqlTransaction.rawPayload),
42386
42631
  0
42387
42632
  );
42388
- const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
42633
+ let txReceipts = [];
42634
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42635
+ txReceipts = gqlTransaction.status.receipts;
42636
+ }
42637
+ const receipts = txReceipts.map(processGqlReceipt);
42389
42638
  const {
42390
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42639
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42391
42640
  } = provider.getChain();
42641
+ const gasPrice = await provider.getLatestGasPrice();
42392
42642
  const transactionInfo = assembleTransactionSummary({
42393
42643
  id: gqlTransaction.id,
42394
42644
  receipts,
@@ -42399,7 +42649,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42399
42649
  gasPriceFactor: bn(gasPriceFactor),
42400
42650
  abiMap,
42401
42651
  maxInputs,
42402
- gasCosts
42652
+ gasCosts,
42653
+ maxGasPerTx,
42654
+ gasPrice
42403
42655
  });
42404
42656
  return {
42405
42657
  gqlTransaction,
@@ -42409,10 +42661,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42409
42661
  async function getTransactionSummaryFromRequest(params) {
42410
42662
  const { provider, transactionRequest, abiMap } = params;
42411
42663
  const { receipts } = await provider.call(transactionRequest);
42412
- const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
42664
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
42413
42665
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
42414
42666
  const transaction = transactionRequest.toTransaction();
42415
42667
  const transactionBytes = transactionRequest.toTransactionBytes();
42668
+ const gasPrice = await provider.getLatestGasPrice();
42416
42669
  const transactionSummary = assembleTransactionSummary({
42417
42670
  receipts,
42418
42671
  transaction,
@@ -42421,7 +42674,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42421
42674
  gasPerByte,
42422
42675
  gasPriceFactor,
42423
42676
  maxInputs,
42424
- gasCosts
42677
+ gasCosts,
42678
+ maxGasPerTx,
42679
+ gasPrice
42425
42680
  });
42426
42681
  return transactionSummary;
42427
42682
  }
@@ -42430,13 +42685,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42430
42685
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
42431
42686
  const { edges, pageInfo } = transactionsByOwner;
42432
42687
  const {
42433
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42688
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42434
42689
  } = provider.getChain();
42690
+ const gasPrice = await provider.getLatestGasPrice();
42435
42691
  const transactions = edges.map((edge) => {
42436
42692
  const { node: gqlTransaction } = edge;
42437
- const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
42693
+ const { id, rawPayload, status } = gqlTransaction;
42438
42694
  const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
42439
- const receipts = gqlReceipts?.map(processGqlReceipt) || [];
42695
+ let txReceipts = [];
42696
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42697
+ txReceipts = gqlTransaction.status.receipts;
42698
+ }
42699
+ const receipts = txReceipts.map(processGqlReceipt);
42440
42700
  const transactionSummary = assembleTransactionSummary({
42441
42701
  id,
42442
42702
  receipts,
@@ -42447,7 +42707,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42447
42707
  gasPerByte,
42448
42708
  gasPriceFactor,
42449
42709
  maxInputs,
42450
- gasCosts
42710
+ gasCosts,
42711
+ maxGasPerTx,
42712
+ gasPrice
42451
42713
  });
42452
42714
  const output3 = {
42453
42715
  gqlTransaction,
@@ -42776,36 +43038,33 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42776
43038
  * @param fee - The estimated transaction fee.
42777
43039
  * @returns A promise that resolves when the resources are added to the transaction.
42778
43040
  */
42779
- async fund(request, coinQuantities, fee) {
42780
- const updatedQuantities = addAmountToAsset({
43041
+ async fund(request, params) {
43042
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
43043
+ const txRequest = request;
43044
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
42781
43045
  amount: bn(fee),
42782
43046
  assetId: BaseAssetId,
42783
- coinQuantities
43047
+ coinQuantities: requiredQuantities
42784
43048
  });
42785
43049
  const quantitiesDict = {};
42786
- updatedQuantities.forEach(({ amount, assetId }) => {
43050
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
42787
43051
  quantitiesDict[assetId] = {
42788
43052
  required: amount,
42789
43053
  owned: bn(0)
42790
43054
  };
42791
43055
  });
42792
- const cachedUtxos = [];
42793
- const cachedMessages = [];
42794
- const owner = this.address.toB256();
42795
- request.inputs.forEach((input) => {
43056
+ txRequest.inputs.forEach((input) => {
42796
43057
  const isResource = "amount" in input;
42797
43058
  if (isResource) {
42798
43059
  const isCoin2 = "owner" in input;
42799
43060
  if (isCoin2) {
42800
43061
  const assetId = String(input.assetId);
42801
- if (input.owner === owner && quantitiesDict[assetId]) {
43062
+ if (quantitiesDict[assetId]) {
42802
43063
  const amount = bn(input.amount);
42803
43064
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42804
- cachedUtxos.push(input.id);
42805
43065
  }
42806
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
43066
+ } else if (input.amount && quantitiesDict[BaseAssetId]) {
42807
43067
  quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42808
- cachedMessages.push(input.nonce);
42809
43068
  }
42810
43069
  }
42811
43070
  });
@@ -42820,12 +43079,23 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42820
43079
  });
42821
43080
  const needsToBeFunded = missingQuantities.length;
42822
43081
  if (needsToBeFunded) {
42823
- const resources = await this.getResourcesToSpend(missingQuantities, {
42824
- messages: cachedMessages,
42825
- utxos: cachedUtxos
42826
- });
42827
- request.addResources(resources);
43082
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
43083
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
43084
+ txRequest.addResources(resources);
43085
+ }
43086
+ txRequest.shiftPredicateData();
43087
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
43088
+ const requestToBeReEstimate = clone_default(txRequest);
43089
+ if (addedSignatures) {
43090
+ Array.from({ length: addedSignatures }).forEach(
43091
+ () => requestToBeReEstimate.addEmptyWitness()
43092
+ );
42828
43093
  }
43094
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
43095
+ transactionRequest: requestToBeReEstimate
43096
+ });
43097
+ txRequest.maxFee = maxFee;
43098
+ return txRequest;
42829
43099
  }
42830
43100
  /**
42831
43101
  * A helper that creates a transfer transaction request and returns it.
@@ -42833,28 +43103,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42833
43103
  * @param destination - The address of the destination.
42834
43104
  * @param amount - The amount of coins to transfer.
42835
43105
  * @param assetId - The asset ID of the coins to transfer.
42836
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
43106
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
42837
43107
  * @returns A promise that resolves to the prepared transaction request.
42838
43108
  */
42839
43109
  async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42840
- const { minGasPrice } = this.provider.getGasConfig();
42841
- const params = { gasPrice: minGasPrice, ...txParams };
42842
- const request = new ScriptTransactionRequest(params);
43110
+ const request = new ScriptTransactionRequest(txParams);
42843
43111
  request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42844
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
43112
+ const txCost = await this.provider.getTransactionCost(request, {
42845
43113
  estimateTxDependencies: true,
42846
43114
  resourcesOwner: this
42847
43115
  });
42848
- request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
42849
- request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
42850
- this.validateGas({
42851
- gasUsed,
42852
- gasPrice: request.gasPrice,
42853
- gasLimit: request.gasLimit,
42854
- minGasPrice
42855
- });
42856
- await this.fund(request, requiredQuantities, maxFee);
42857
- request.updatePredicateInputs(estimatedInputs);
43116
+ if ("gasLimit" in txParams) {
43117
+ this.validateGas({
43118
+ gasUsed: txCost.gasUsed,
43119
+ gasLimit: request.gasLimit
43120
+ });
43121
+ }
43122
+ request.gasLimit = txCost.gasUsed;
43123
+ request.maxFee = txCost.maxFee;
43124
+ await this.fund(request, txCost);
42858
43125
  return request;
42859
43126
  }
42860
43127
  /**
@@ -42893,31 +43160,30 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42893
43160
  );
42894
43161
  }
42895
43162
  const contractAddress = Address.fromAddressOrString(contractId);
42896
- const { minGasPrice } = this.provider.getGasConfig();
42897
- const params = { gasPrice: minGasPrice, ...txParams };
42898
43163
  const { script, scriptData } = await assembleTransferToContractScript({
42899
43164
  hexlifiedContractId: contractAddress.toB256(),
42900
43165
  amountToTransfer: bn(amount),
42901
43166
  assetId
42902
43167
  });
42903
43168
  const request = new ScriptTransactionRequest({
42904
- ...params,
43169
+ ...txParams,
42905
43170
  script,
42906
43171
  scriptData
42907
43172
  });
42908
43173
  request.addContractInputAndOutput(contractAddress);
42909
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42910
- request,
42911
- [{ amount: bn(amount), assetId: String(assetId) }]
42912
- );
42913
- request.gasLimit = bn(params.gasLimit ?? gasUsed);
42914
- this.validateGas({
42915
- gasUsed,
42916
- gasPrice: request.gasPrice,
42917
- gasLimit: request.gasLimit,
42918
- minGasPrice
43174
+ const txCost = await this.provider.getTransactionCost(request, {
43175
+ resourcesOwner: this,
43176
+ quantitiesToContract: [{ amount: bn(amount), assetId: String(assetId) }]
42919
43177
  });
42920
- await this.fund(request, requiredQuantities, maxFee);
43178
+ if (txParams.gasLimit) {
43179
+ this.validateGas({
43180
+ gasUsed: txCost.gasUsed,
43181
+ gasLimit: request.gasLimit
43182
+ });
43183
+ }
43184
+ request.gasLimit = txCost.gasUsed;
43185
+ request.maxFee = txCost.maxFee;
43186
+ await this.fund(request, txCost);
42921
43187
  return this.sendTransaction(request);
42922
43188
  }
42923
43189
  /**
@@ -42929,7 +43195,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42929
43195
  * @returns A promise that resolves to the transaction response.
42930
43196
  */
42931
43197
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42932
- const { minGasPrice } = this.provider.getGasConfig();
42933
43198
  const recipientAddress = Address.fromAddressOrString(recipient);
42934
43199
  const recipientDataArray = arrayify(
42935
43200
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42942,21 +43207,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42942
43207
  ...recipientDataArray,
42943
43208
  ...amountDataArray
42944
43209
  ]);
42945
- const params = { script, gasPrice: minGasPrice, ...txParams };
43210
+ const params = { script, ...txParams };
42946
43211
  const request = new ScriptTransactionRequest(params);
42947
- const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42948
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42949
- request,
42950
- forwardingQuantities
42951
- );
42952
- request.gasLimit = bn(params.gasLimit ?? gasUsed);
42953
- this.validateGas({
42954
- gasUsed,
42955
- gasPrice: request.gasPrice,
42956
- gasLimit: request.gasLimit,
42957
- minGasPrice
42958
- });
42959
- await this.fund(request, requiredQuantities, maxFee);
43212
+ const quantitiesToContract = [{ amount: bn(amount), assetId: BaseAssetId }];
43213
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
43214
+ if (txParams.gasLimit) {
43215
+ this.validateGas({
43216
+ gasUsed: txCost.gasUsed,
43217
+ gasLimit: request.gasLimit
43218
+ });
43219
+ }
43220
+ request.maxFee = txCost.maxFee;
43221
+ request.gasLimit = txCost.gasUsed;
43222
+ await this.fund(request, txCost);
42960
43223
  return this.sendTransaction(request);
42961
43224
  }
42962
43225
  async signMessage(message) {
@@ -43014,18 +43277,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43014
43277
  }
43015
43278
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
43016
43279
  }
43017
- validateGas({
43018
- gasUsed,
43019
- gasPrice,
43020
- gasLimit,
43021
- minGasPrice
43022
- }) {
43023
- if (minGasPrice.gt(gasPrice)) {
43024
- throw new FuelError(
43025
- ErrorCode.GAS_PRICE_TOO_LOW,
43026
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
43027
- );
43028
- }
43280
+ validateGas({ gasUsed, gasLimit }) {
43029
43281
  if (gasUsed.gt(gasLimit)) {
43030
43282
  throw new FuelError(
43031
43283
  ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -44614,7 +44866,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44614
44866
  * @param transactionRequestLike - The transaction request to send.
44615
44867
  * @returns A promise that resolves to the TransactionResponse object.
44616
44868
  */
44617
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
44869
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
44618
44870
  const transactionRequest = transactionRequestify(transactionRequestLike);
44619
44871
  if (estimateTxDependencies) {
44620
44872
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -47890,15 +48142,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47890
48142
  populateTransactionPredicateData(transactionRequestLike) {
47891
48143
  const request = transactionRequestify(transactionRequestLike);
47892
48144
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
47893
- const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
47894
- if (placeholderIndex !== -1) {
47895
- request.removeWitness(placeholderIndex);
47896
- }
47897
- request.inputs.filter(isRequestInputResource).forEach((input) => {
47898
- if (isRequestInputResourceFromOwner(input, this.address)) {
47899
- input.predicate = this.bytes;
47900
- input.predicateData = this.getPredicateData(policies.length);
47901
- input.witnessIndex = 0;
48145
+ request.inputs?.forEach((input) => {
48146
+ if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
48147
+ input.predicate = hexlify(this.bytes);
48148
+ input.predicateData = hexlify(this.getPredicateData(policies.length));
47902
48149
  }
47903
48150
  });
47904
48151
  return request;
@@ -47913,8 +48160,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47913
48160
  * @returns A promise that resolves to the prepared transaction request.
47914
48161
  */
47915
48162
  async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47916
- const request = await super.createTransfer(destination, amount, assetId, txParams);
47917
- return this.populateTransactionPredicateData(request);
48163
+ return super.createTransfer(destination, amount, assetId, txParams);
47918
48164
  }
47919
48165
  /**
47920
48166
  * Sends a transaction with the populated predicate data.
@@ -47922,9 +48168,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47922
48168
  * @param transactionRequestLike - The transaction request-like object.
47923
48169
  * @returns A promise that resolves to the transaction response.
47924
48170
  */
47925
- sendTransaction(transactionRequestLike, options) {
47926
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47927
- return super.sendTransaction(transactionRequest, options);
48171
+ sendTransaction(transactionRequestLike) {
48172
+ const transactionRequest = transactionRequestify(transactionRequestLike);
48173
+ return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
47928
48174
  }
47929
48175
  /**
47930
48176
  * Simulates a transaction with the populated predicate data.
@@ -47933,22 +48179,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47933
48179
  * @returns A promise that resolves to the call result.
47934
48180
  */
47935
48181
  simulateTransaction(transactionRequestLike) {
47936
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47937
- return super.simulateTransaction(transactionRequest);
47938
- }
47939
- /**
47940
- * Retrieves resources satisfying the spend query for the account.
47941
- *
47942
- * @param quantities - Coins to retrieve.
47943
- * @param excludedIds - IDs of resources to be excluded from the query.
47944
- * @returns A promise that resolves to an array of Resources.
47945
- */
47946
- async getResourcesToSpend(quantities, excludedIds) {
47947
- const resources = await super.getResourcesToSpend(quantities, excludedIds);
47948
- return resources.map((resource) => ({
47949
- ...resource,
47950
- predicate: hexlify(this.bytes)
47951
- }));
48182
+ const transactionRequest = transactionRequestify(transactionRequestLike);
48183
+ return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
47952
48184
  }
47953
48185
  getPredicateData(policiesLength) {
47954
48186
  if (!this.predicateData.length) {
@@ -47994,6 +48226,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47994
48226
  predicateInterface: abiInterface
47995
48227
  };
47996
48228
  }
48229
+ /**
48230
+ * Retrieves resources satisfying the spend query for the account.
48231
+ *
48232
+ * @param quantities - IDs of coins to exclude.
48233
+ * @param excludedIds - IDs of resources to be excluded from the query.
48234
+ * @returns A promise that resolves to an array of Resources.
48235
+ */
48236
+ async getResourcesToSpend(quantities, excludedIds) {
48237
+ const resources = await this.provider.getResourcesToSpend(
48238
+ this.address,
48239
+ quantities,
48240
+ excludedIds
48241
+ );
48242
+ return resources.map((resource) => ({
48243
+ ...resource,
48244
+ predicate: hexlify(this.bytes),
48245
+ paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
48246
+ }));
48247
+ }
47997
48248
  /**
47998
48249
  * Sets the configurable constants for the predicate.
47999
48250
  *
@@ -48029,28 +48280,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48029
48280
  }
48030
48281
  return mutatedBytes;
48031
48282
  }
48032
- /**
48033
- * Returns the index of the witness placeholder that was added to this predicate.
48034
- * If no witness placeholder was added, it returns -1.
48035
- * @param request - The transaction request.
48036
- * @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
48037
- */
48038
- getIndexFromPlaceholderWitness(request) {
48039
- const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
48040
- let index = -1;
48041
- const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
48042
- if (hasEmptyPredicateInputs) {
48043
- index = hasEmptyPredicateInputs.witnessIndex;
48044
- const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
48045
- if (!allInputsAreEmpty) {
48046
- const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
48047
- if (wasFilledInputAddedFirst) {
48048
- index = -1;
48049
- }
48050
- }
48051
- }
48052
- return index;
48053
- }
48054
48283
  };
48055
48284
 
48056
48285
  // src/connectors/fuel-connector.ts