@fuel-ts/account 0.0.0-rc-2021-20240423152230 → 0.0.0-rc-2037-20240423161807

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 +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +604 -829
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +641 -857
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +459 -680
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +18 -11
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +327 -821
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +1 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +1 -6
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +27 -37
  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/helpers.d.ts +10 -0
  31. package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
  32. package/dist/providers/transaction-request/index.d.ts +1 -0
  33. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  34. package/dist/providers/transaction-request/input.d.ts +2 -2
  35. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  37. package/dist/providers/transaction-request/transaction-request.d.ts +11 -6
  38. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  39. package/dist/providers/transaction-request/utils.d.ts +0 -3
  40. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  41. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  43. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  45. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  46. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  47. package/dist/providers/utils/gas.d.ts +2 -8
  48. package/dist/providers/utils/gas.d.ts.map +1 -1
  49. package/dist/test-utils/index.d.ts +1 -0
  50. package/dist/test-utils/index.d.ts.map +1 -1
  51. package/dist/test-utils/launchNode.d.ts.map +1 -1
  52. package/dist/test-utils/resources.d.ts +4 -0
  53. package/dist/test-utils/resources.d.ts.map +1 -0
  54. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  55. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  56. package/dist/test-utils/transactionRequest.d.ts +5 -0
  57. package/dist/test-utils/transactionRequest.d.ts.map +1 -0
  58. package/dist/test-utils.global.js +1082 -1547
  59. package/dist/test-utils.global.js.map +1 -1
  60. package/dist/test-utils.js +618 -839
  61. package/dist/test-utils.js.map +1 -1
  62. package/dist/test-utils.mjs +450 -674
  63. package/dist/test-utils.mjs.map +1 -1
  64. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  65. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  66. package/package.json +16 -16
@@ -289,7 +289,7 @@
289
289
  }
290
290
  return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
291
291
  };
292
- BN2.max = function max(left, right) {
292
+ BN2.max = function max2(left, right) {
293
293
  if (left.cmp(right) > 0)
294
294
  return left;
295
295
  return right;
@@ -5113,7 +5113,7 @@
5113
5113
  function isBlob(obj) {
5114
5114
  return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
5115
5115
  }
5116
- function clone3(instance) {
5116
+ function clone(instance) {
5117
5117
  let p1, p2;
5118
5118
  let body = instance.body;
5119
5119
  if (instance.bodyUsed) {
@@ -6047,7 +6047,7 @@
6047
6047
  * @return Response
6048
6048
  */
6049
6049
  clone() {
6050
- return new Response2(clone3(this), {
6050
+ return new Response2(clone(this), {
6051
6051
  url: this.url,
6052
6052
  status: this.status,
6053
6053
  statusText: this.statusText,
@@ -6097,7 +6097,7 @@
6097
6097
  if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
6098
6098
  throw new TypeError("Request with GET/HEAD method cannot have body");
6099
6099
  }
6100
- let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone3(input) : null;
6100
+ let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
6101
6101
  Body.call(this, inputBody, {
6102
6102
  timeout: init.timeout || input.timeout || 0,
6103
6103
  size: init.size || input.size || 0
@@ -28952,8 +28952,8 @@ spurious results.`);
28952
28952
  // ../versions/dist/index.mjs
28953
28953
  function getBuiltinVersions() {
28954
28954
  return {
28955
- FORC: "0.51.1",
28956
- FUEL_CORE: "0.24.2",
28955
+ FORC: "0.49.3",
28956
+ FUEL_CORE: "0.22.1",
28957
28957
  FUELS: "0.81.0"
28958
28958
  };
28959
28959
  }
@@ -31495,182 +31495,32 @@ 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
-
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
- }
31498
+ function max(...numbers) {
31499
+ return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
31589
31500
  }
31590
- function _isPrimitive(param) {
31591
- var type3 = typeof param;
31592
- return param == null || type3 != "object" && type3 != "function";
31593
- }
31594
- var _ObjectMap = /* @__PURE__ */ function() {
31595
- function _ObjectMap2() {
31596
- this.map = {};
31597
- this.length = 0;
31598
- }
31599
- _ObjectMap2.prototype.set = function(key, value) {
31600
- const hashedKey = this.hash(key);
31601
- let bucket = this.map[hashedKey];
31602
- if (!bucket) {
31603
- this.map[hashedKey] = bucket = [];
31604
- }
31605
- bucket.push([key, value]);
31606
- this.length += 1;
31607
- };
31608
- _ObjectMap2.prototype.hash = function(key) {
31609
- let hashedKey = [];
31610
- for (var value in key) {
31611
- hashedKey.push(Object.prototype.toString.call(key[value]));
31612
- }
31613
- return hashedKey.join();
31614
- };
31615
- _ObjectMap2.prototype.get = function(key) {
31616
- if (this.length <= 180) {
31617
- for (const p in this.map) {
31618
- const bucket2 = this.map[p];
31619
- for (let i = 0; i < bucket2.length; i += 1) {
31620
- const element = bucket2[i];
31621
- if (element[0] === key) {
31622
- return element[1];
31623
- }
31624
- }
31625
- }
31626
- return;
31627
- }
31628
- const hashedKey = this.hash(key);
31629
- const bucket = this.map[hashedKey];
31630
- if (!bucket) {
31631
- return;
31632
- }
31633
- for (let i = 0; i < bucket.length; i += 1) {
31634
- const element = bucket[i];
31635
- if (element[0] === key) {
31636
- return element[1];
31637
- }
31638
- }
31639
- };
31640
- return _ObjectMap2;
31641
- }();
31642
-
31643
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
31644
- var clone = /* @__PURE__ */ _curry1(function clone2(value) {
31645
- return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
31646
- });
31647
- var clone_default = clone;
31648
-
31649
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
31650
- var hasProtoTrim = typeof String.prototype.trim === "function";
31651
31501
 
31652
31502
  // src/providers/coin-quantity.ts
31653
31503
  var coinQuantityfy = (coinQuantityLike) => {
31654
31504
  let assetId;
31655
31505
  let amount;
31656
- let max;
31506
+ let max2;
31657
31507
  if (Array.isArray(coinQuantityLike)) {
31658
31508
  amount = coinQuantityLike[0];
31659
31509
  assetId = coinQuantityLike[1] ?? BaseAssetId;
31660
- max = coinQuantityLike[2] ?? void 0;
31510
+ max2 = coinQuantityLike[2] ?? void 0;
31661
31511
  } else {
31662
31512
  amount = coinQuantityLike.amount;
31663
31513
  assetId = coinQuantityLike.assetId ?? BaseAssetId;
31664
- max = coinQuantityLike.max ?? void 0;
31514
+ max2 = coinQuantityLike.max ?? void 0;
31665
31515
  }
31666
31516
  const bnAmount = bn(amount);
31667
31517
  return {
31668
31518
  assetId: hexlify(assetId),
31669
31519
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
31670
- max: max ? bn(max) : void 0
31520
+ max: max2 ? bn(max2) : void 0
31671
31521
  };
31672
31522
  };
31673
- var addAmountToCoinQuantities = (params) => {
31523
+ var addAmountToAsset = (params) => {
31674
31524
  const { amount, assetId } = params;
31675
31525
  const coinQuantities = [...params.coinQuantities];
31676
31526
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -31755,7 +31605,7 @@ This unreleased fuel-core build may include features and updates not yet support
31755
31605
  var ENCODING_V1 = "1";
31756
31606
  var WORD_SIZE = 8;
31757
31607
  var BYTES_32 = 32;
31758
- var UTXO_ID_LEN = BYTES_32 + 2;
31608
+ var UTXO_ID_LEN = BYTES_32 + 1;
31759
31609
  var ASSET_ID_LEN = BYTES_32;
31760
31610
  var ADDRESS_LEN = BYTES_32;
31761
31611
  var NONCE_LEN = BYTES_32;
@@ -31763,9 +31613,9 @@ This unreleased fuel-core build may include features and updates not yet support
31763
31613
  var TX_POINTER_LEN = WORD_SIZE * 2;
31764
31614
  var MAX_BYTES = 2 ** 32 - 1;
31765
31615
  var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
31766
- ASSET_ID_LEN + // Base asset ID
31616
+ WORD_SIZE + // Tx size
31767
31617
  // Asset ID/Balance coin input pairs
31768
- maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
31618
+ maxInputs * (ASSET_ID_LEN + WORD_SIZE);
31769
31619
  var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
31770
31620
  WORD_SIZE + // Gas limit
31771
31621
  WORD_SIZE + // Script size
@@ -31783,6 +31633,7 @@ This unreleased fuel-core build may include features and updates not yet support
31783
31633
  ASSET_ID_LEN + // Asset id
31784
31634
  TX_POINTER_LEN + // TxPointer
31785
31635
  WORD_SIZE + // Witnesses index
31636
+ WORD_SIZE + // Maturity
31786
31637
  WORD_SIZE + // Predicate size
31787
31638
  WORD_SIZE + // Predicate data size
31788
31639
  WORD_SIZE;
@@ -32104,7 +31955,7 @@ This unreleased fuel-core build may include features and updates not yet support
32104
31955
  constructor(name, coders) {
32105
31956
  const caseIndexCoder = new BigNumberCoder("u64");
32106
31957
  const encodedValueSize = Object.values(coders).reduce(
32107
- (max, coder) => Math.max(max, coder.encodedLength),
31958
+ (max2, coder) => Math.max(max2, coder.encodedLength),
32108
31959
  0
32109
31960
  );
32110
31961
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -32822,7 +32673,7 @@ This unreleased fuel-core build may include features and updates not yet support
32822
32673
  constructor(name, coders) {
32823
32674
  const caseIndexCoder = new BigNumberCoder("u64");
32824
32675
  const encodedValueSize = Object.values(coders).reduce(
32825
- (max, coder) => Math.max(max, coder.encodedLength),
32676
+ (max2, coder) => Math.max(max2, coder.encodedLength),
32826
32677
  0
32827
32678
  );
32828
32679
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -33536,19 +33387,18 @@ This unreleased fuel-core build may include features and updates not yet support
33536
33387
  encode(value) {
33537
33388
  const parts = [];
33538
33389
  parts.push(new B256Coder().encode(value.txID));
33539
- parts.push(new NumberCoder("u16").encode(value.outputIndex));
33390
+ parts.push(new NumberCoder("u8").encode(value.outputIndex));
33540
33391
  parts.push(new B256Coder().encode(value.owner));
33541
33392
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33542
33393
  parts.push(new B256Coder().encode(value.assetId));
33543
33394
  parts.push(new TxPointerCoder().encode(value.txPointer));
33544
- parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33395
+ parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33396
+ parts.push(new NumberCoder("u32").encode(value.maturity));
33545
33397
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
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
- );
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));
33552
33402
  return concat(parts);
33553
33403
  }
33554
33404
  decode(data, offset) {
@@ -33556,7 +33406,7 @@ This unreleased fuel-core build may include features and updates not yet support
33556
33406
  let o = offset;
33557
33407
  [decoded, o] = new B256Coder().decode(data, o);
33558
33408
  const txID = decoded;
33559
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33409
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33560
33410
  const outputIndex = decoded;
33561
33411
  [decoded, o] = new B256Coder().decode(data, o);
33562
33412
  const owner = decoded;
@@ -33566,17 +33416,19 @@ This unreleased fuel-core build may include features and updates not yet support
33566
33416
  const assetId = decoded;
33567
33417
  [decoded, o] = new TxPointerCoder().decode(data, o);
33568
33418
  const txPointer = decoded;
33569
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33419
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33570
33420
  const witnessIndex = Number(decoded);
33421
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33422
+ const maturity = decoded;
33571
33423
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33572
33424
  const predicateGasUsed = decoded;
33573
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33425
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33574
33426
  const predicateLength = decoded;
33575
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33427
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33576
33428
  const predicateDataLength = decoded;
33577
- [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33429
+ [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33578
33430
  const predicate = decoded;
33579
- [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33431
+ [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33580
33432
  const predicateData = decoded;
33581
33433
  return [
33582
33434
  {
@@ -33588,6 +33440,7 @@ This unreleased fuel-core build may include features and updates not yet support
33588
33440
  assetId,
33589
33441
  txPointer,
33590
33442
  witnessIndex,
33443
+ maturity,
33591
33444
  predicateGasUsed,
33592
33445
  predicateLength,
33593
33446
  predicateDataLength,
@@ -33605,7 +33458,7 @@ This unreleased fuel-core build may include features and updates not yet support
33605
33458
  encode(value) {
33606
33459
  const parts = [];
33607
33460
  parts.push(new B256Coder().encode(value.txID));
33608
- parts.push(new NumberCoder("u16").encode(value.outputIndex));
33461
+ parts.push(new NumberCoder("u8").encode(value.outputIndex));
33609
33462
  parts.push(new B256Coder().encode(value.balanceRoot));
33610
33463
  parts.push(new B256Coder().encode(value.stateRoot));
33611
33464
  parts.push(new TxPointerCoder().encode(value.txPointer));
@@ -33617,7 +33470,7 @@ This unreleased fuel-core build may include features and updates not yet support
33617
33470
  let o = offset;
33618
33471
  [decoded, o] = new B256Coder().decode(data, o);
33619
33472
  const txID = decoded;
33620
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33473
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33621
33474
  const outputIndex = decoded;
33622
33475
  [decoded, o] = new B256Coder().decode(data, o);
33623
33476
  const balanceRoot = decoded;
@@ -33666,16 +33519,14 @@ This unreleased fuel-core build may include features and updates not yet support
33666
33519
  parts.push(new ByteArrayCoder(32).encode(value.recipient));
33667
33520
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33668
33521
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
33669
- parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33522
+ parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33670
33523
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
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));
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));
33674
33527
  parts.push(new ByteArrayCoder(data.length).encode(data));
33675
- parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33676
- parts.push(
33677
- new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33678
- );
33528
+ parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33529
+ parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33679
33530
  return concat(parts);
33680
33531
  }
33681
33532
  static decodeData(messageData) {
@@ -33695,21 +33546,21 @@ This unreleased fuel-core build may include features and updates not yet support
33695
33546
  const amount = decoded;
33696
33547
  [decoded, o] = new B256Coder().decode(data, o);
33697
33548
  const nonce = decoded;
33698
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33549
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33699
33550
  const witnessIndex = Number(decoded);
33700
33551
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33701
33552
  const predicateGasUsed = decoded;
33702
33553
  [decoded, o] = new NumberCoder("u32").decode(data, o);
33703
33554
  const dataLength2 = decoded;
33704
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33555
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33705
33556
  const predicateLength = decoded;
33706
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33557
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33707
33558
  const predicateDataLength = decoded;
33708
33559
  [decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
33709
33560
  const messageData = decoded;
33710
- [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33561
+ [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33711
33562
  const predicate = decoded;
33712
- [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33563
+ [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33713
33564
  const predicateData = decoded;
33714
33565
  return [
33715
33566
  {
@@ -34021,7 +33872,7 @@ This unreleased fuel-core build may include features and updates not yet support
34021
33872
  }
34022
33873
  };
34023
33874
  var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
34024
- PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
33875
+ PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
34025
33876
  PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
34026
33877
  PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
34027
33878
  PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
@@ -34069,9 +33920,9 @@ This unreleased fuel-core build may include features and updates not yet support
34069
33920
  let o = offset;
34070
33921
  const policies = [];
34071
33922
  if (policyTypes & 1) {
34072
- const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
33923
+ const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
34073
33924
  o = nextOffset;
34074
- policies.push({ type: 1, data: tip });
33925
+ policies.push({ type: 1, data: gasPrice });
34075
33926
  }
34076
33927
  if (policyTypes & 2) {
34077
33928
  const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
@@ -34303,15 +34154,15 @@ This unreleased fuel-core build may include features and updates not yet support
34303
34154
  encode(value) {
34304
34155
  const parts = [];
34305
34156
  parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
34306
- parts.push(new B256Coder().encode(value.receiptsRoot));
34307
- parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
34308
- parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
34157
+ parts.push(new NumberCoder("u32").encode(value.scriptLength));
34158
+ parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
34309
34159
  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));
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
+ 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));
34315
34166
  parts.push(new PoliciesCoder().encode(value.policies));
34316
34167
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34317
34168
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
@@ -34323,23 +34174,23 @@ This unreleased fuel-core build may include features and updates not yet support
34323
34174
  let o = offset;
34324
34175
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34325
34176
  const scriptGasLimit = decoded;
34326
- [decoded, o] = new B256Coder().decode(data, o);
34327
- const receiptsRoot = decoded;
34328
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34177
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
34329
34178
  const scriptLength = decoded;
34330
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34179
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
34331
34180
  const scriptDataLength = decoded;
34332
34181
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34333
34182
  const policyTypes = decoded;
34334
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34183
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34335
34184
  const inputsCount = decoded;
34336
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34185
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34337
34186
  const outputsCount = decoded;
34338
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34187
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34339
34188
  const witnessesCount = decoded;
34340
- [decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
34189
+ [decoded, o] = new B256Coder().decode(data, o);
34190
+ const receiptsRoot = decoded;
34191
+ [decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
34341
34192
  const script = decoded;
34342
- [decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
34193
+ [decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
34343
34194
  const scriptData = decoded;
34344
34195
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34345
34196
  const policies = decoded;
@@ -34377,19 +34228,18 @@ This unreleased fuel-core build may include features and updates not yet support
34377
34228
  }
34378
34229
  encode(value) {
34379
34230
  const parts = [];
34380
- parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
34381
- parts.push(new B256Coder().encode(value.salt));
34382
- parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
34231
+ parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
34232
+ parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
34383
34233
  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));
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));
34238
+ parts.push(new B256Coder().encode(value.salt));
34239
+ parts.push(new PoliciesCoder().encode(value.policies));
34387
34240
  parts.push(
34388
- new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
34389
- value.storageSlots
34390
- )
34241
+ new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
34391
34242
  );
34392
- parts.push(new PoliciesCoder().encode(value.policies));
34393
34243
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34394
34244
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
34395
34245
  parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
@@ -34398,27 +34248,26 @@ This unreleased fuel-core build may include features and updates not yet support
34398
34248
  decode(data, offset) {
34399
34249
  let decoded;
34400
34250
  let o = offset;
34401
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34251
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
34252
+ const bytecodeLength = decoded;
34253
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34402
34254
  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;
34407
34255
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34408
34256
  const policyTypes = decoded;
34409
34257
  [decoded, o] = new NumberCoder("u16").decode(data, o);
34258
+ const storageSlotsCount = decoded;
34259
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34410
34260
  const inputsCount = decoded;
34411
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34261
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34412
34262
  const outputsCount = decoded;
34413
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34263
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34414
34264
  const witnessesCount = decoded;
34415
- [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
34416
- data,
34417
- o
34418
- );
34419
- const storageSlots = decoded;
34265
+ [decoded, o] = new B256Coder().decode(data, o);
34266
+ const salt = decoded;
34420
34267
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34421
34268
  const policies = decoded;
34269
+ [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
34270
+ const storageSlots = decoded;
34422
34271
  [decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
34423
34272
  const inputs = decoded;
34424
34273
  [decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
@@ -34428,6 +34277,7 @@ This unreleased fuel-core build may include features and updates not yet support
34428
34277
  return [
34429
34278
  {
34430
34279
  type: 1,
34280
+ bytecodeLength,
34431
34281
  bytecodeWitnessIndex,
34432
34282
  policyTypes,
34433
34283
  storageSlotsCount,
@@ -34456,7 +34306,6 @@ This unreleased fuel-core build may include features and updates not yet support
34456
34306
  parts.push(new OutputContractCoder().encode(value.outputContract));
34457
34307
  parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
34458
34308
  parts.push(new B256Coder().encode(value.mintAssetId));
34459
- parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
34460
34309
  return concat(parts);
34461
34310
  }
34462
34311
  decode(data, offset) {
@@ -34472,8 +34321,6 @@ This unreleased fuel-core build may include features and updates not yet support
34472
34321
  const mintAmount = decoded;
34473
34322
  [decoded, o] = new B256Coder().decode(data, o);
34474
34323
  const mintAssetId = decoded;
34475
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34476
- const gasPrice = decoded;
34477
34324
  return [
34478
34325
  {
34479
34326
  type: 2,
@@ -34481,8 +34328,7 @@ This unreleased fuel-core build may include features and updates not yet support
34481
34328
  inputContract,
34482
34329
  outputContract,
34483
34330
  mintAmount,
34484
- mintAssetId,
34485
- gasPrice
34331
+ mintAssetId
34486
34332
  },
34487
34333
  o
34488
34334
  ];
@@ -34789,6 +34635,159 @@ This unreleased fuel-core build may include features and updates not yet support
34789
34635
  // src/providers/provider.ts
34790
34636
  var import_graphql_request = __toESM(require_dist2());
34791
34637
 
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
+
34792
34791
  // ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
34793
34792
  var __assign = function() {
34794
34793
  __assign = Object.assign || function __assign2(t) {
@@ -37954,40 +37953,16 @@ spurious results.`);
37954
37953
  var lib_default2 = gql;
37955
37954
 
37956
37955
  // 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
- `;
37985
37956
  var ReceiptFragmentFragmentDoc = lib_default2`
37986
37957
  fragment receiptFragment on Receipt {
37987
- id
37958
+ contract {
37959
+ id
37960
+ }
37988
37961
  pc
37989
37962
  is
37990
- to
37963
+ to {
37964
+ id
37965
+ }
37991
37966
  toAddress
37992
37967
  amount
37993
37968
  assetId
@@ -38025,16 +38000,10 @@ spurious results.`);
38025
38000
  id
38026
38001
  }
38027
38002
  time
38028
- receipts {
38029
- ...receiptFragment
38030
- }
38031
38003
  programState {
38032
38004
  returnType
38033
38005
  data
38034
38006
  }
38035
- receipts {
38036
- ...receiptFragment
38037
- }
38038
38007
  }
38039
38008
  ... on FailureStatus {
38040
38009
  block {
@@ -38042,24 +38011,26 @@ spurious results.`);
38042
38011
  }
38043
38012
  time
38044
38013
  reason
38045
- receipts {
38046
- ...receiptFragment
38047
- }
38048
38014
  }
38049
38015
  ... on SqueezedOutStatus {
38050
38016
  reason
38051
38017
  }
38052
38018
  }
38053
- ${ReceiptFragmentFragmentDoc}`;
38019
+ `;
38054
38020
  var TransactionFragmentFragmentDoc = lib_default2`
38055
38021
  fragment transactionFragment on Transaction {
38056
38022
  id
38057
38023
  rawPayload
38024
+ gasPrice
38025
+ receipts {
38026
+ ...receiptFragment
38027
+ }
38058
38028
  status {
38059
38029
  ...transactionStatusFragment
38060
38030
  }
38061
38031
  }
38062
- ${TransactionStatusFragmentFragmentDoc}`;
38032
+ ${ReceiptFragmentFragmentDoc}
38033
+ ${TransactionStatusFragmentFragmentDoc}`;
38063
38034
  var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
38064
38035
  fragment inputEstimatePredicatesFragment on Input {
38065
38036
  ... on InputCoin {
@@ -38077,46 +38048,6 @@ spurious results.`);
38077
38048
  }
38078
38049
  }
38079
38050
  ${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}`;
38120
38051
  var CoinFragmentFragmentDoc = lib_default2`
38121
38052
  fragment coinFragment on Coin {
38122
38053
  __typename
@@ -38124,6 +38055,7 @@ ${ReceiptFragmentFragmentDoc}`;
38124
38055
  owner
38125
38056
  amount
38126
38057
  assetId
38058
+ maturity
38127
38059
  blockCreated
38128
38060
  txCreatedIdx
38129
38061
  }
@@ -38162,32 +38094,26 @@ ${ReceiptFragmentFragmentDoc}`;
38162
38094
  messageBlockHeader {
38163
38095
  id
38164
38096
  daHeight
38165
- consensusParametersVersion
38166
- stateTransitionBytecodeVersion
38167
38097
  transactionsCount
38168
- messageReceiptCount
38169
38098
  transactionsRoot
38170
- messageOutboxRoot
38171
- eventInboxRoot
38172
38099
  height
38173
38100
  prevRoot
38174
38101
  time
38175
38102
  applicationHash
38103
+ messageReceiptRoot
38104
+ messageReceiptCount
38176
38105
  }
38177
38106
  commitBlockHeader {
38178
38107
  id
38179
38108
  daHeight
38180
- consensusParametersVersion
38181
- stateTransitionBytecodeVersion
38182
38109
  transactionsCount
38183
- messageReceiptCount
38184
38110
  transactionsRoot
38185
- messageOutboxRoot
38186
- eventInboxRoot
38187
38111
  height
38188
38112
  prevRoot
38189
38113
  time
38190
38114
  applicationHash
38115
+ messageReceiptRoot
38116
+ messageReceiptCount
38191
38117
  }
38192
38118
  sender
38193
38119
  recipient
@@ -38206,8 +38132,8 @@ ${ReceiptFragmentFragmentDoc}`;
38206
38132
  var BlockFragmentFragmentDoc = lib_default2`
38207
38133
  fragment blockFragment on Block {
38208
38134
  id
38209
- height
38210
38135
  header {
38136
+ height
38211
38137
  time
38212
38138
  }
38213
38139
  transactions {
@@ -38265,11 +38191,6 @@ ${ReceiptFragmentFragmentDoc}`;
38265
38191
  `;
38266
38192
  var GasCostsFragmentFragmentDoc = lib_default2`
38267
38193
  fragment GasCostsFragment on GasCosts {
38268
- version {
38269
- ... on Version {
38270
- value
38271
- }
38272
- }
38273
38194
  add
38274
38195
  addi
38275
38196
  aloc
@@ -38282,6 +38203,7 @@ ${ReceiptFragmentFragmentDoc}`;
38282
38203
  cb
38283
38204
  cfei
38284
38205
  cfsi
38206
+ croo
38285
38207
  div
38286
38208
  divi
38287
38209
  ecr1
@@ -38364,9 +38286,6 @@ ${ReceiptFragmentFragmentDoc}`;
38364
38286
  ccp {
38365
38287
  ...DependentCostFragment
38366
38288
  }
38367
- croo {
38368
- ...DependentCostFragment
38369
- }
38370
38289
  csiz {
38371
38290
  ...DependentCostFragment
38372
38291
  }
@@ -38426,11 +38345,6 @@ ${ReceiptFragmentFragmentDoc}`;
38426
38345
  ${DependentCostFragmentFragmentDoc}`;
38427
38346
  var ConsensusParametersFragmentFragmentDoc = lib_default2`
38428
38347
  fragment consensusParametersFragment on ConsensusParameters {
38429
- version {
38430
- ... on Version {
38431
- value
38432
- }
38433
- }
38434
38348
  txParams {
38435
38349
  ...TxParametersFragment
38436
38350
  }
@@ -38490,9 +38404,18 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38490
38404
  fragment nodeInfoFragment on NodeInfo {
38491
38405
  utxoValidation
38492
38406
  vmBacktrace
38407
+ minGasPrice
38493
38408
  maxTx
38494
38409
  maxDepth
38495
38410
  nodeVersion
38411
+ peers {
38412
+ id
38413
+ addresses
38414
+ clientVersion
38415
+ blockHeight
38416
+ lastHeartbeatMs
38417
+ appScore
38418
+ }
38496
38419
  }
38497
38420
  `;
38498
38421
  var GetVersionDocument = lib_default2`
@@ -38527,9 +38450,13 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38527
38450
  query getTransactionWithReceipts($transactionId: TransactionId!) {
38528
38451
  transaction(id: $transactionId) {
38529
38452
  ...transactionFragment
38453
+ receipts {
38454
+ ...receiptFragment
38455
+ }
38530
38456
  }
38531
38457
  }
38532
- ${TransactionFragmentFragmentDoc}`;
38458
+ ${TransactionFragmentFragmentDoc}
38459
+ ${ReceiptFragmentFragmentDoc}`;
38533
38460
  var GetTransactionsDocument = lib_default2`
38534
38461
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
38535
38462
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -38657,20 +38584,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38657
38584
  }
38658
38585
  }
38659
38586
  ${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
- `;
38674
38587
  var GetBalancesDocument = lib_default2`
38675
38588
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
38676
38589
  balances(
@@ -38725,12 +38638,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38725
38638
  }
38726
38639
  `;
38727
38640
  var DryRunDocument = lib_default2`
38728
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
38729
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
38730
- ...dryRunTransactionExecutionStatusFragment
38641
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
38642
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
38643
+ ...receiptFragment
38731
38644
  }
38732
38645
  }
38733
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
38646
+ ${ReceiptFragmentFragmentDoc}`;
38734
38647
  var SubmitDocument = lib_default2`
38735
38648
  mutation submit($encodedTransaction: HexString!) {
38736
38649
  submit(tx: $encodedTransaction) {
@@ -38749,17 +38662,17 @@ ${MessageCoinFragmentFragmentDoc}`;
38749
38662
  var SubmitAndAwaitDocument = lib_default2`
38750
38663
  subscription submitAndAwait($encodedTransaction: HexString!) {
38751
38664
  submitAndAwait(tx: $encodedTransaction) {
38752
- ...transactionStatusSubscriptionFragment
38665
+ ...transactionStatusFragment
38753
38666
  }
38754
38667
  }
38755
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
38668
+ ${TransactionStatusFragmentFragmentDoc}`;
38756
38669
  var StatusChangeDocument = lib_default2`
38757
38670
  subscription statusChange($transactionId: TransactionId!) {
38758
38671
  statusChange(id: $transactionId) {
38759
- ...transactionStatusSubscriptionFragment
38672
+ ...transactionStatusFragment
38760
38673
  }
38761
38674
  }
38762
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
38675
+ ${TransactionStatusFragmentFragmentDoc}`;
38763
38676
  function getSdk(requester) {
38764
38677
  return {
38765
38678
  getVersion(variables, options) {
@@ -38813,12 +38726,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38813
38726
  getBalance(variables, options) {
38814
38727
  return requester(GetBalanceDocument, variables, options);
38815
38728
  },
38816
- getLatestGasPrice(variables, options) {
38817
- return requester(GetLatestGasPriceDocument, variables, options);
38818
- },
38819
- estimateGasPrice(variables, options) {
38820
- return requester(EstimateGasPriceDocument, variables, options);
38821
- },
38822
38729
  getBalances(variables, options) {
38823
38730
  return requester(GetBalancesDocument, variables, options);
38824
38731
  },
@@ -39002,9 +38909,10 @@ ${MessageCoinFragmentFragmentDoc}`;
39002
38909
  txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
39003
38910
  },
39004
38911
  witnessIndex: value.witnessIndex,
38912
+ maturity: value.maturity ?? 0,
39005
38913
  predicateGasUsed: bn(value.predicateGasUsed),
39006
- predicateLength: bn(predicate.length),
39007
- predicateDataLength: bn(predicateData.length),
38914
+ predicateLength: predicate.length,
38915
+ predicateDataLength: predicateData.length,
39008
38916
  predicate: hexlify(predicate),
39009
38917
  predicateData: hexlify(predicateData)
39010
38918
  };
@@ -39035,8 +38943,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39035
38943
  nonce: hexlify(value.nonce),
39036
38944
  witnessIndex: value.witnessIndex,
39037
38945
  predicateGasUsed: bn(value.predicateGasUsed),
39038
- predicateLength: bn(predicate.length),
39039
- predicateDataLength: bn(predicateData.length),
38946
+ predicateLength: predicate.length,
38947
+ predicateDataLength: predicateData.length,
39040
38948
  predicate: hexlify(predicate),
39041
38949
  predicateData: hexlify(predicateData),
39042
38950
  data: hexlify(data),
@@ -39196,8 +39104,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39196
39104
  case "CALL" /* Call */: {
39197
39105
  const callReceipt = {
39198
39106
  type: ReceiptType.Call,
39199
- from: hexOrZero(receipt.id || receipt.contractId),
39200
- to: hexOrZero(receipt?.to),
39107
+ from: hexOrZero(receipt.contract?.id),
39108
+ to: hexOrZero(receipt?.to?.id),
39201
39109
  amount: bn(receipt.amount),
39202
39110
  assetId: hexOrZero(receipt.assetId),
39203
39111
  gas: bn(receipt.gas),
@@ -39211,7 +39119,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39211
39119
  case "RETURN" /* Return */: {
39212
39120
  const returnReceipt = {
39213
39121
  type: ReceiptType.Return,
39214
- id: hexOrZero(receipt.id || receipt.contractId),
39122
+ id: hexOrZero(receipt.contract?.id),
39215
39123
  val: bn(receipt.val),
39216
39124
  pc: bn(receipt.pc),
39217
39125
  is: bn(receipt.is)
@@ -39221,7 +39129,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39221
39129
  case "RETURN_DATA" /* ReturnData */: {
39222
39130
  const returnDataReceipt = {
39223
39131
  type: ReceiptType.ReturnData,
39224
- id: hexOrZero(receipt.id || receipt.contractId),
39132
+ id: hexOrZero(receipt.contract?.id),
39225
39133
  ptr: bn(receipt.ptr),
39226
39134
  len: bn(receipt.len),
39227
39135
  digest: hexOrZero(receipt.digest),
@@ -39233,7 +39141,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39233
39141
  case "PANIC" /* Panic */: {
39234
39142
  const panicReceipt = {
39235
39143
  type: ReceiptType.Panic,
39236
- id: hexOrZero(receipt.id),
39144
+ id: hexOrZero(receipt.contract?.id),
39237
39145
  reason: bn(receipt.reason),
39238
39146
  pc: bn(receipt.pc),
39239
39147
  is: bn(receipt.is),
@@ -39244,7 +39152,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39244
39152
  case "REVERT" /* Revert */: {
39245
39153
  const revertReceipt = {
39246
39154
  type: ReceiptType.Revert,
39247
- id: hexOrZero(receipt.id || receipt.contractId),
39155
+ id: hexOrZero(receipt.contract?.id),
39248
39156
  val: bn(receipt.ra),
39249
39157
  pc: bn(receipt.pc),
39250
39158
  is: bn(receipt.is)
@@ -39254,7 +39162,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39254
39162
  case "LOG" /* Log */: {
39255
39163
  const logReceipt = {
39256
39164
  type: ReceiptType.Log,
39257
- id: hexOrZero(receipt.id || receipt.contractId),
39165
+ id: hexOrZero(receipt.contract?.id),
39258
39166
  val0: bn(receipt.ra),
39259
39167
  val1: bn(receipt.rb),
39260
39168
  val2: bn(receipt.rc),
@@ -39267,7 +39175,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39267
39175
  case "LOG_DATA" /* LogData */: {
39268
39176
  const logDataReceipt = {
39269
39177
  type: ReceiptType.LogData,
39270
- id: hexOrZero(receipt.id || receipt.contractId),
39178
+ id: hexOrZero(receipt.contract?.id),
39271
39179
  val0: bn(receipt.ra),
39272
39180
  val1: bn(receipt.rb),
39273
39181
  ptr: bn(receipt.ptr),
@@ -39281,8 +39189,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39281
39189
  case "TRANSFER" /* Transfer */: {
39282
39190
  const transferReceipt = {
39283
39191
  type: ReceiptType.Transfer,
39284
- from: hexOrZero(receipt.id || receipt.contractId),
39285
- to: hexOrZero(receipt.toAddress || receipt?.to),
39192
+ from: hexOrZero(receipt.contract?.id),
39193
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
39286
39194
  amount: bn(receipt.amount),
39287
39195
  assetId: hexOrZero(receipt.assetId),
39288
39196
  pc: bn(receipt.pc),
@@ -39293,8 +39201,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39293
39201
  case "TRANSFER_OUT" /* TransferOut */: {
39294
39202
  const transferOutReceipt = {
39295
39203
  type: ReceiptType.TransferOut,
39296
- from: hexOrZero(receipt.id || receipt.contractId),
39297
- to: hexOrZero(receipt.toAddress || receipt.to),
39204
+ from: hexOrZero(receipt.contract?.id),
39205
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
39298
39206
  amount: bn(receipt.amount),
39299
39207
  assetId: hexOrZero(receipt.assetId),
39300
39208
  pc: bn(receipt.pc),
@@ -39337,7 +39245,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39337
39245
  return receiptMessageOut;
39338
39246
  }
39339
39247
  case "MINT" /* Mint */: {
39340
- const contractId = hexOrZero(receipt.id || receipt.contractId);
39248
+ const contractId = hexOrZero(receipt.contract?.id);
39341
39249
  const subId = hexOrZero(receipt.subId);
39342
39250
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
39343
39251
  const mintReceipt = {
@@ -39352,7 +39260,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39352
39260
  return mintReceipt;
39353
39261
  }
39354
39262
  case "BURN" /* Burn */: {
39355
- const contractId = hexOrZero(receipt.id || receipt.contractId);
39263
+ const contractId = hexOrZero(receipt.contract?.id);
39356
39264
  const subId = hexOrZero(receipt.subId);
39357
39265
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
39358
39266
  const burnReceipt = {
@@ -39433,6 +39341,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39433
39341
  };
39434
39342
 
39435
39343
  // src/providers/utils/gas.ts
39344
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
39436
39345
  var getGasUsedFromReceipts = (receipts) => {
39437
39346
  const scriptResult = receipts.filter(
39438
39347
  (receipt) => receipt.type === ReceiptType.ScriptResult
@@ -39453,28 +39362,18 @@ ${MessageCoinFragmentFragmentDoc}`;
39453
39362
  }
39454
39363
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
39455
39364
  const witnessCache = [];
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) => {
39365
+ const totalGas = inputs.reduce((total, input) => {
39471
39366
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39472
39367
  return total.add(
39473
- vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39368
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39474
39369
  );
39475
39370
  }
39476
- return total.add(gasCosts.ecr1);
39477
- }, bn(0));
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());
39478
39377
  return totalGas;
39479
39378
  }
39480
39379
  function getMinGas(params) {
@@ -39486,20 +39385,12 @@ ${MessageCoinFragmentFragmentDoc}`;
39486
39385
  return minGas;
39487
39386
  }
39488
39387
  function getMaxGas(params) {
39489
- const {
39490
- gasPerByte,
39491
- witnessesLength,
39492
- witnessLimit,
39493
- minGas,
39494
- gasLimit = bn(0),
39495
- maxGasPerTx
39496
- } = params;
39388
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
39497
39389
  let remainingAllowedWitnessGas = bn(0);
39498
39390
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
39499
39391
  remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
39500
39392
  }
39501
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39502
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
39393
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39503
39394
  }
39504
39395
  function calculateMetadataGasForTxCreate({
39505
39396
  gasCosts,
@@ -39521,10 +39412,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39521
39412
  }) {
39522
39413
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
39523
39414
  }
39524
- var calculateGasFee = (params) => {
39525
- const { gas, gasPrice, priceFactor, tip } = params;
39526
- return gas.mul(gasPrice).div(priceFactor).add(tip);
39527
- };
39528
39415
 
39529
39416
  // src/providers/utils/json.ts
39530
39417
  function normalize2(object) {
@@ -39654,6 +39541,27 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39654
39541
  name = "NoWitnessByOwnerError";
39655
39542
  };
39656
39543
 
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
+
39657
39565
  // src/providers/transaction-request/witness.ts
39658
39566
  var witnessify = (value) => {
39659
39567
  const data = arrayify(value);
@@ -39666,7 +39574,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39666
39574
  // src/providers/transaction-request/transaction-request.ts
39667
39575
  var BaseTransactionRequest = class {
39668
39576
  /** Gas price for transaction */
39669
- tip;
39577
+ gasPrice;
39670
39578
  /** Block until which tx cannot be included */
39671
39579
  maturity;
39672
39580
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -39685,7 +39593,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39685
39593
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
39686
39594
  */
39687
39595
  constructor({
39688
- tip,
39596
+ gasPrice,
39689
39597
  maturity,
39690
39598
  maxFee,
39691
39599
  witnessLimit,
@@ -39693,7 +39601,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39693
39601
  outputs,
39694
39602
  witnesses
39695
39603
  } = {}) {
39696
- this.tip = bn(tip);
39604
+ this.gasPrice = bn(gasPrice);
39697
39605
  this.maturity = maturity ?? 0;
39698
39606
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
39699
39607
  this.maxFee = maxFee ? bn(maxFee) : void 0;
@@ -39704,9 +39612,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39704
39612
  static getPolicyMeta(req) {
39705
39613
  let policyTypes = 0;
39706
39614
  const policies = [];
39707
- if (req.tip) {
39708
- policyTypes += PolicyType.Tip;
39709
- policies.push({ data: req.tip, type: PolicyType.Tip });
39615
+ if (req.gasPrice) {
39616
+ policyTypes += PolicyType.GasPrice;
39617
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
39710
39618
  }
39711
39619
  if (req.witnessLimit) {
39712
39620
  policyTypes += PolicyType.WitnessLimit;
@@ -39890,11 +39798,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39890
39798
  * assetId, if one it was not added yet.
39891
39799
  *
39892
39800
  * @param coin - Coin resource.
39801
+ * @param predicate - Predicate bytes.
39802
+ * @param predicateData - Predicate data bytes.
39893
39803
  */
39894
39804
  addCoinInput(coin) {
39895
- const { assetId, owner, amount } = coin;
39805
+ const { assetId, owner, amount, id, predicate } = coin;
39896
39806
  let witnessIndex;
39897
- if (coin.predicate) {
39807
+ if (predicate) {
39898
39808
  witnessIndex = 0;
39899
39809
  } else {
39900
39810
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -39903,13 +39813,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39903
39813
  }
39904
39814
  }
39905
39815
  const input = {
39906
- ...coin,
39816
+ id,
39907
39817
  type: InputType.Coin,
39908
39818
  owner: owner.toB256(),
39909
39819
  amount,
39910
39820
  assetId,
39911
39821
  txPointer: "0x00000000000000000000000000000000",
39912
- witnessIndex
39822
+ witnessIndex,
39823
+ predicate
39913
39824
  };
39914
39825
  this.pushInput(input);
39915
39826
  this.addChangeOutput(owner, assetId);
@@ -39919,12 +39830,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39919
39830
  * baseAssetId, if one it was not added yet.
39920
39831
  *
39921
39832
  * @param message - Message resource.
39833
+ * @param predicate - Predicate bytes.
39834
+ * @param predicateData - Predicate data bytes.
39922
39835
  */
39923
39836
  addMessageInput(message) {
39924
- const { recipient, sender, amount } = message;
39837
+ const { recipient, sender, amount, predicate, nonce } = message;
39925
39838
  const assetId = BaseAssetId;
39926
39839
  let witnessIndex;
39927
- if (message.predicate) {
39840
+ if (predicate) {
39928
39841
  witnessIndex = 0;
39929
39842
  } else {
39930
39843
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -39933,12 +39846,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39933
39846
  }
39934
39847
  }
39935
39848
  const input = {
39936
- ...message,
39849
+ nonce,
39937
39850
  type: InputType.Message,
39938
39851
  sender: sender.toB256(),
39939
39852
  recipient: recipient.toB256(),
39940
39853
  amount,
39941
- witnessIndex
39854
+ witnessIndex,
39855
+ predicate
39942
39856
  };
39943
39857
  this.pushInput(input);
39944
39858
  this.addChangeOutput(recipient, assetId);
@@ -40048,7 +39962,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40048
39962
  }
40049
39963
  calculateMaxGas(chainInfo, minGas) {
40050
39964
  const { consensusParameters } = chainInfo;
40051
- const { gasPerByte, maxGasPerTx } = consensusParameters;
39965
+ const { gasPerByte } = consensusParameters;
40052
39966
  const witnessesLength = this.toTransaction().witnesses.reduce(
40053
39967
  (acc, wit) => acc + wit.dataLength,
40054
39968
  0
@@ -40057,8 +39971,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40057
39971
  gasPerByte,
40058
39972
  minGas,
40059
39973
  witnessesLength,
40060
- witnessLimit: this.witnessLimit,
40061
- maxGasPerTx
39974
+ witnessLimit: this.witnessLimit
40062
39975
  });
40063
39976
  }
40064
39977
  /**
@@ -40076,20 +39989,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40076
39989
  });
40077
39990
  const updateAssetInput = (assetId, quantity) => {
40078
39991
  const assetInput = findAssetInput(assetId);
40079
- let usedQuantity = quantity;
40080
- if (assetId === BaseAssetId) {
40081
- usedQuantity = bn("1000000000000000000");
40082
- }
40083
39992
  if (assetInput && "assetId" in assetInput) {
40084
39993
  assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
40085
- assetInput.amount = usedQuantity;
39994
+ assetInput.amount = quantity;
40086
39995
  } else {
40087
39996
  this.addResources([
40088
39997
  {
40089
39998
  id: hexlify(randomBytes22(UTXO_ID_LEN)),
40090
- amount: usedQuantity,
39999
+ amount: quantity,
40091
40000
  assetId,
40092
40001
  owner: resourcesOwner || Address.fromRandom(),
40002
+ maturity: 0,
40093
40003
  blockCreated: bn(1),
40094
40004
  txCreatedIdx: bn(1)
40095
40005
  }
@@ -40121,7 +40031,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40121
40031
  toJSON() {
40122
40032
  return normalizeJSON(this);
40123
40033
  }
40124
- updatePredicateGasUsed(inputs) {
40034
+ removeWitness(index) {
40035
+ this.witnesses.splice(index, 1);
40036
+ this.adjustWitnessIndexes(index);
40037
+ }
40038
+ updatePredicateInputs(inputs) {
40125
40039
  this.inputs.forEach((i) => {
40126
40040
  let correspondingInput;
40127
40041
  switch (i.type) {
@@ -40143,12 +40057,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40143
40057
  }
40144
40058
  });
40145
40059
  }
40146
- shiftPredicateData() {
40147
- this.inputs.forEach((input) => {
40148
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
40149
- input.predicateData = input.paddPredicateData(
40150
- BaseTransactionRequest.getPolicyMeta(this).policies.length
40151
- );
40060
+ adjustWitnessIndexes(removedIndex) {
40061
+ this.inputs.filter(isRequestInputResource).forEach((input) => {
40062
+ if (input.witnessIndex > removedIndex) {
40063
+ input.witnessIndex -= 1;
40152
40064
  }
40153
40065
  });
40154
40066
  }
@@ -40285,8 +40197,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40285
40197
  return {
40286
40198
  type: TransactionType.Create,
40287
40199
  ...baseTransaction,
40200
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
40288
40201
  bytecodeWitnessIndex,
40289
- storageSlotsCount: bn(storageSlots.length),
40202
+ storageSlotsCount: storageSlots.length,
40290
40203
  salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
40291
40204
  storageSlots
40292
40205
  };
@@ -40400,8 +40313,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40400
40313
  type: TransactionType.Script,
40401
40314
  scriptGasLimit: this.gasLimit,
40402
40315
  ...super.getBaseTransaction(),
40403
- scriptLength: bn(script.length),
40404
- scriptDataLength: bn(scriptData.length),
40316
+ scriptLength: script.length,
40317
+ scriptDataLength: scriptData.length,
40405
40318
  receiptsRoot: ZeroBytes32,
40406
40319
  script: hexlify(script),
40407
40320
  scriptData: hexlify(scriptData)
@@ -40465,7 +40378,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40465
40378
  }
40466
40379
  calculateMaxGas(chainInfo, minGas) {
40467
40380
  const { consensusParameters } = chainInfo;
40468
- const { gasPerByte, maxGasPerTx } = consensusParameters;
40381
+ const { gasPerByte } = consensusParameters;
40469
40382
  const witnessesLength = this.toTransaction().witnesses.reduce(
40470
40383
  (acc, wit) => acc + wit.dataLength,
40471
40384
  0
@@ -40475,8 +40388,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40475
40388
  minGas,
40476
40389
  witnessesLength,
40477
40390
  witnessLimit: this.witnessLimit,
40478
- gasLimit: this.gasLimit,
40479
- maxGasPerTx
40391
+ gasLimit: this.gasLimit
40480
40392
  });
40481
40393
  }
40482
40394
  /**
@@ -40549,29 +40461,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40549
40461
  }
40550
40462
  }
40551
40463
  };
40552
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
40553
- (acc, input) => {
40554
- if (input.type === InputType.Coin && input.owner === owner) {
40555
- acc.utxos.push(input.id);
40556
- }
40557
- if (input.type === InputType.Message && input.recipient === owner) {
40558
- acc.messages.push(input.nonce);
40559
- }
40560
- return acc;
40561
- },
40562
- {
40563
- utxos: [],
40564
- messages: []
40565
- }
40566
- );
40567
40464
 
40568
40465
  // src/providers/transaction-summary/calculate-transaction-fee.ts
40569
40466
  var calculateTransactionFee = (params) => {
40570
40467
  const {
40571
- gasPrice,
40468
+ gasUsed,
40572
40469
  rawPayload,
40573
- tip,
40574
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
40470
+ consensusParameters: { gasCosts, feeParams }
40575
40471
  } = params;
40576
40472
  const gasPerByte = bn(feeParams.gasPerByte);
40577
40473
  const gasPriceFactor = bn(feeParams.gasPriceFactor);
@@ -40581,7 +40477,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40581
40477
  return {
40582
40478
  fee: bn(0),
40583
40479
  minFee: bn(0),
40584
- maxFee: bn(0)
40480
+ maxFee: bn(0),
40481
+ feeFromGasUsed: bn(0)
40585
40482
  };
40586
40483
  }
40587
40484
  const { type: type3, witnesses, inputs, policies } = transaction;
@@ -40613,6 +40510,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40613
40510
  metadataGas,
40614
40511
  txBytesSize: transactionBytes.length
40615
40512
  });
40513
+ const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
40616
40514
  const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
40617
40515
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
40618
40516
  const maxGas = getMaxGas({
@@ -40620,25 +40518,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40620
40518
  minGas,
40621
40519
  witnessesLength,
40622
40520
  gasLimit,
40623
- witnessLimit,
40624
- maxGasPerTx
40625
- });
40626
- const minFee = calculateGasFee({
40627
- gasPrice,
40628
- gas: minGas,
40629
- priceFactor: gasPriceFactor,
40630
- tip
40631
- });
40632
- const maxFee = calculateGasFee({
40633
- gasPrice,
40634
- gas: maxGas,
40635
- priceFactor: gasPriceFactor,
40636
- tip
40521
+ witnessLimit
40637
40522
  });
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);
40638
40527
  return {
40528
+ fee,
40639
40529
  minFee,
40640
40530
  maxFee,
40641
- fee: maxFee
40531
+ feeFromGasUsed
40642
40532
  };
40643
40533
  };
40644
40534
 
@@ -41239,9 +41129,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41239
41129
  gqlTransactionStatus,
41240
41130
  abiMap = {},
41241
41131
  maxInputs,
41242
- gasCosts,
41243
- maxGasPerTx,
41244
- gasPrice
41132
+ gasCosts
41245
41133
  } = params;
41246
41134
  const gasUsed = getGasUsedFromReceipts(receipts);
41247
41135
  const rawPayload = hexlify(transactionBytes);
@@ -41255,14 +41143,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41255
41143
  maxInputs
41256
41144
  });
41257
41145
  const typeName = getTransactionTypeName(transaction.type);
41258
- const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
41259
41146
  const { fee } = calculateTransactionFee({
41260
- gasPrice,
41147
+ gasUsed,
41261
41148
  rawPayload,
41262
- tip,
41263
41149
  consensusParameters: {
41264
41150
  gasCosts,
41265
- maxGasPerTx,
41266
41151
  feeParams: {
41267
41152
  gasPerByte,
41268
41153
  gasPriceFactor
@@ -41398,13 +41283,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41398
41283
  const decodedTransaction = this.decodeTransaction(
41399
41284
  transaction
41400
41285
  );
41401
- let txReceipts = [];
41402
- if (transaction?.status && "receipts" in transaction.status) {
41403
- txReceipts = transaction.status.receipts;
41404
- }
41405
- const receipts = txReceipts.map(processGqlReceipt) || [];
41406
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
41407
- const gasPrice = await this.provider.getLatestGasPrice();
41286
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
41287
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
41408
41288
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
41409
41289
  const transactionSummary = assembleTransactionSummary({
41410
41290
  id: this.id,
@@ -41416,9 +41296,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41416
41296
  gasPriceFactor,
41417
41297
  abiMap: contractsAbiMap,
41418
41298
  maxInputs,
41419
- gasCosts,
41420
- maxGasPerTx,
41421
- gasPrice
41299
+ gasCosts
41422
41300
  });
41423
41301
  return transactionSummary;
41424
41302
  }
@@ -41567,7 +41445,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41567
41445
  gasCosts,
41568
41446
  latestBlock: {
41569
41447
  id: latestBlock.id,
41570
- height: bn(latestBlock.height),
41448
+ height: bn(latestBlock.header.height),
41571
41449
  time: latestBlock.header.time,
41572
41450
  transactions: latestBlock.transactions.map((i) => ({
41573
41451
  id: i.id
@@ -41661,8 +41539,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41661
41539
  * Returns some helpful parameters related to gas fees.
41662
41540
  */
41663
41541
  getGasConfig() {
41542
+ const { minGasPrice } = this.getNode();
41664
41543
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
41665
41544
  return {
41545
+ minGasPrice,
41666
41546
  maxGasPerTx,
41667
41547
  maxGasPerPredicate,
41668
41548
  gasPriceFactor,
@@ -41760,7 +41640,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41760
41640
  */
41761
41641
  async getBlockNumber() {
41762
41642
  const { chain } = await this.operations.getChain();
41763
- return bn(chain.latestBlock.height, 10);
41643
+ return bn(chain.latestBlock.header.height, 10);
41764
41644
  }
41765
41645
  /**
41766
41646
  * Returns the chain information.
@@ -41772,9 +41652,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41772
41652
  const processedNodeInfo = {
41773
41653
  maxDepth: bn(nodeInfo.maxDepth),
41774
41654
  maxTx: bn(nodeInfo.maxTx),
41655
+ minGasPrice: bn(nodeInfo.minGasPrice),
41775
41656
  nodeVersion: nodeInfo.nodeVersion,
41776
41657
  utxoValidation: nodeInfo.utxoValidation,
41777
- vmBacktrace: nodeInfo.vmBacktrace
41658
+ vmBacktrace: nodeInfo.vmBacktrace,
41659
+ peers: nodeInfo.peers
41778
41660
  };
41779
41661
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
41780
41662
  return processedNodeInfo;
@@ -41860,13 +41742,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41860
41742
  return this.estimateTxDependencies(transactionRequest);
41861
41743
  }
41862
41744
  const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41863
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
41864
- encodedTransactions: encodedTransaction,
41745
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
41746
+ encodedTransaction,
41865
41747
  utxoValidation: utxoValidation || false
41866
41748
  });
41867
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
41868
- const receipts = rawReceipts.map(processGqlReceipt);
41869
- return { receipts, dryrunStatus: status };
41749
+ const receipts = gqlReceipts.map(processGqlReceipt);
41750
+ return {
41751
+ receipts
41752
+ };
41870
41753
  }
41871
41754
  /**
41872
41755
  * Verifies whether enough gas is available to complete transaction.
@@ -41905,6 +41788,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41905
41788
  * If there are missing variable outputs,
41906
41789
  * `addVariableOutputs` is called on the transaction.
41907
41790
  *
41791
+ * @privateRemarks
41792
+ * TODO: Investigate support for missing contract IDs
41793
+ * TODO: Add support for missing output messages
41908
41794
  *
41909
41795
  * @param transactionRequest - The transaction request object.
41910
41796
  * @returns A promise.
@@ -41917,19 +41803,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41917
41803
  missingContractIds: []
41918
41804
  };
41919
41805
  }
41806
+ await this.estimatePredicates(transactionRequest);
41920
41807
  let receipts = [];
41921
41808
  const missingContractIds = [];
41922
41809
  let outputVariables = 0;
41923
- let dryrunStatus;
41924
41810
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
41925
- const {
41926
- dryRun: [{ receipts: rawReceipts, status }]
41927
- } = await this.operations.dryRun({
41928
- encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
41811
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
41812
+ encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
41929
41813
  utxoValidation: false
41930
41814
  });
41931
- receipts = rawReceipts.map(processGqlReceipt);
41932
- dryrunStatus = status;
41815
+ receipts = gqlReceipts.map(processGqlReceipt);
41933
41816
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
41934
41817
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
41935
41818
  if (hasMissingOutputs) {
@@ -41939,10 +41822,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41939
41822
  transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
41940
41823
  missingContractIds.push(contractId);
41941
41824
  });
41942
- const { maxFee } = await this.estimateTxGasAndFee({
41943
- transactionRequest
41944
- });
41945
- transactionRequest.maxFee = maxFee;
41946
41825
  } else {
41947
41826
  break;
41948
41827
  }
@@ -41950,139 +41829,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41950
41829
  return {
41951
41830
  receipts,
41952
41831
  outputVariables,
41953
- missingContractIds,
41954
- dryrunStatus
41832
+ missingContractIds
41955
41833
  };
41956
41834
  }
41957
- /**
41958
- * Dry runs multiple transactions and checks for missing dependencies in batches.
41959
- *
41960
- * Transactions are dry run in batches. After each dry run, transactions requiring
41961
- * further modifications are identified. The method iteratively updates these transactions
41962
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
41963
- *
41964
- * @param transactionRequests - Array of transaction request objects.
41965
- * @returns A promise that resolves to an array of results for each transaction.
41966
- */
41967
- async estimateMultipleTxDependencies(transactionRequests) {
41968
- const results = transactionRequests.map(() => ({
41969
- receipts: [],
41970
- outputVariables: 0,
41971
- missingContractIds: [],
41972
- dryrunStatus: void 0
41973
- }));
41974
- const allRequests = clone_default(transactionRequests);
41975
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
41976
- allRequests.forEach((req, index) => {
41977
- if (req.type === TransactionType.Script) {
41978
- serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
41979
- }
41980
- });
41981
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
41982
- let attempt = 0;
41983
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
41984
- const encodedTransactions = transactionsToProcess.map(
41985
- (index) => serializedTransactionsMap.get(index)
41986
- );
41987
- const dryRunResults = await this.operations.dryRun({
41988
- encodedTransactions,
41989
- utxoValidation: false
41990
- });
41991
- const nextRoundTransactions = [];
41992
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
41993
- const currentResultIndex = transactionsToProcess[i];
41994
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
41995
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
41996
- results[currentResultIndex].dryrunStatus = status;
41997
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
41998
- results[currentResultIndex].receipts
41999
- );
42000
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
42001
- const requestToProcess = allRequests[currentResultIndex];
42002
- if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
42003
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
42004
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
42005
- missingOutputContractIds.forEach(({ contractId }) => {
42006
- requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
42007
- results[currentResultIndex].missingContractIds.push(contractId);
42008
- });
42009
- const { maxFee } = await this.estimateTxGasAndFee({
42010
- transactionRequest: requestToProcess
42011
- });
42012
- requestToProcess.maxFee = maxFee;
42013
- serializedTransactionsMap.set(
42014
- currentResultIndex,
42015
- hexlify(requestToProcess.toTransactionBytes())
42016
- );
42017
- nextRoundTransactions.push(currentResultIndex);
42018
- allRequests[currentResultIndex] = requestToProcess;
42019
- }
42020
- }
42021
- transactionsToProcess = nextRoundTransactions;
42022
- attempt += 1;
42023
- }
42024
- return results;
42025
- }
42026
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
42027
- if (estimateTxDependencies) {
42028
- return this.estimateMultipleTxDependencies(transactionRequests);
42029
- }
42030
- const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
42031
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42032
- encodedTransactions,
42033
- utxoValidation: utxoValidation || false
42034
- });
42035
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
42036
- const receipts = rawReceipts.map(processGqlReceipt);
42037
- return { receipts, dryrunStatus: status };
42038
- });
42039
- return results;
42040
- }
42041
41835
  /**
42042
41836
  * Estimates the transaction gas and fee based on the provided transaction request.
42043
41837
  * @param transactionRequest - The transaction request object.
42044
41838
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
42045
41839
  */
42046
- async estimateTxGasAndFee(params) {
41840
+ estimateTxGasAndFee(params) {
42047
41841
  const { transactionRequest } = params;
42048
- let { gasPrice } = params;
41842
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
42049
41843
  const chainInfo = this.getChain();
42050
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
41844
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41845
+ transactionRequest.gasPrice = gasPrice;
42051
41846
  const minGas = transactionRequest.calculateMinGas(chainInfo);
42052
- if (!gasPrice) {
42053
- gasPrice = await this.estimateGasPrice(10);
42054
- }
42055
- const minFee = calculateGasFee({
42056
- gasPrice: bn(gasPrice),
42057
- gas: minGas,
42058
- priceFactor: gasPriceFactor,
42059
- tip: transactionRequest.tip
42060
- }).add(1);
42061
- let gasLimit = bn(0);
41847
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42062
41848
  if (transactionRequest.type === TransactionType.Script) {
42063
- gasLimit = transactionRequest.gasLimit;
42064
41849
  if (transactionRequest.gasLimit.eq(0)) {
42065
41850
  transactionRequest.gasLimit = minGas;
42066
41851
  transactionRequest.gasLimit = maxGasPerTx.sub(
42067
41852
  transactionRequest.calculateMaxGas(chainInfo, minGas)
42068
41853
  );
42069
- gasLimit = transactionRequest.gasLimit;
42070
41854
  }
42071
41855
  }
42072
41856
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
42073
- const maxFee = calculateGasFee({
42074
- gasPrice: bn(gasPrice),
42075
- gas: maxGas,
42076
- priceFactor: gasPriceFactor,
42077
- tip: transactionRequest.tip
42078
- }).add(1);
41857
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42079
41858
  return {
42080
41859
  minGas,
42081
41860
  minFee,
42082
41861
  maxGas,
42083
- maxFee,
42084
- gasPrice,
42085
- gasLimit
41862
+ maxFee
42086
41863
  };
42087
41864
  }
42088
41865
  /**
@@ -42100,17 +41877,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42100
41877
  if (estimateTxDependencies) {
42101
41878
  return this.estimateTxDependencies(transactionRequest);
42102
41879
  }
42103
- const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
42104
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42105
- encodedTransactions,
41880
+ const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41881
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
41882
+ encodedTransaction,
42106
41883
  utxoValidation: true
42107
41884
  });
42108
- const callResult = dryRunStatuses.map((dryRunStatus) => {
42109
- const { id, receipts, status } = dryRunStatus;
42110
- const processedReceipts = receipts.map(processGqlReceipt);
42111
- return { id, receipts: processedReceipts, status };
42112
- });
42113
- return { receipts: callResult[0].receipts };
41885
+ const receipts = gqlReceipts.map(processGqlReceipt);
41886
+ return {
41887
+ receipts
41888
+ };
42114
41889
  }
42115
41890
  /**
42116
41891
  * Returns a transaction cost to enable user
@@ -42127,79 +41902,77 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42127
41902
  * @param tolerance - The tolerance to add on top of the gasUsed.
42128
41903
  * @returns A promise that resolves to the transaction cost object.
42129
41904
  */
42130
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
41905
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
41906
+ estimateTxDependencies = true,
41907
+ estimatePredicates = true,
41908
+ resourcesOwner,
41909
+ signatureCallback
41910
+ } = {}) {
42131
41911
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41912
+ const { minGasPrice } = this.getGasConfig();
41913
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
42132
41914
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
42133
41915
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
42134
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
41916
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
42135
41917
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
42136
- txRequestClone.maxFee = bn(0);
42137
41918
  if (isScriptTransaction) {
42138
41919
  txRequestClone.gasLimit = bn(0);
42139
41920
  }
42140
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
42141
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
41921
+ if (estimatePredicates) {
41922
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41923
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
41924
+ }
41925
+ await this.estimatePredicates(txRequestClone);
42142
41926
  }
42143
- const signedRequest = clone_default(txRequestClone);
42144
- let addedSignatures = 0;
42145
41927
  if (signatureCallback && isScriptTransaction) {
42146
- const lengthBefore = signedRequest.witnesses.length;
42147
- await signatureCallback(signedRequest);
42148
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
41928
+ await signatureCallback(txRequestClone);
42149
41929
  }
42150
- await this.estimatePredicates(signedRequest);
42151
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
42152
- transactionRequest: signedRequest
41930
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41931
+ transactionRequest: txRequestClone
42153
41932
  });
42154
41933
  let receipts = [];
42155
41934
  let missingContractIds = [];
42156
41935
  let outputVariables = 0;
42157
41936
  let gasUsed = bn(0);
42158
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
42159
- txRequestClone.maxFee = maxFee;
42160
- if (isScriptTransaction) {
42161
- txRequestClone.gasLimit = gasLimit;
42162
- if (signatureCallback) {
42163
- await signatureCallback(txRequestClone);
42164
- }
41937
+ if (isScriptTransaction && estimateTxDependencies) {
41938
+ txRequestClone.gasPrice = bn(0);
42165
41939
  const result = await this.estimateTxDependencies(txRequestClone);
42166
41940
  receipts = result.receipts;
42167
41941
  outputVariables = result.outputVariables;
42168
41942
  missingContractIds = result.missingContractIds;
42169
41943
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
42170
41944
  txRequestClone.gasLimit = gasUsed;
42171
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
42172
- transactionRequest: txRequestClone,
42173
- gasPrice
41945
+ txRequestClone.gasPrice = setGasPrice;
41946
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41947
+ transactionRequest: txRequestClone
42174
41948
  }));
42175
41949
  }
42176
41950
  return {
42177
41951
  requiredQuantities: allQuantities,
42178
41952
  receipts,
42179
41953
  gasUsed,
42180
- gasPrice,
41954
+ minGasPrice,
41955
+ gasPrice: setGasPrice,
42181
41956
  minGas,
42182
41957
  maxGas,
42183
41958
  minFee,
42184
41959
  maxFee,
41960
+ estimatedInputs: txRequestClone.inputs,
42185
41961
  outputVariables,
42186
- missingContractIds,
42187
- addedSignatures,
42188
- estimatedPredicates: txRequestClone.inputs
41962
+ missingContractIds
42189
41963
  };
42190
41964
  }
42191
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
41965
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
42192
41966
  const ownerAddress = Address.fromAddressOrString(owner);
42193
41967
  const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
42194
- const transactionCost = await this.getTransactionCost(transactionRequest, {
42195
- quantitiesToContract
42196
- });
41968
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
42197
41969
  transactionRequest.addResources(
42198
41970
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
42199
41971
  );
42200
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
42201
- quantitiesToContract
42202
- });
41972
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
41973
+ transactionRequest,
41974
+ forwardingQuantities
41975
+ );
42203
41976
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
42204
41977
  return {
42205
41978
  resources,
@@ -42223,6 +41996,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42223
41996
  assetId: coin.assetId,
42224
41997
  amount: bn(coin.amount),
42225
41998
  owner: Address.fromAddressOrString(coin.owner),
41999
+ maturity: bn(coin.maturity).toNumber(),
42226
42000
  blockCreated: bn(coin.blockCreated),
42227
42001
  txCreatedIdx: bn(coin.txCreatedIdx)
42228
42002
  }));
@@ -42274,6 +42048,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42274
42048
  amount: bn(coin.amount),
42275
42049
  assetId: coin.assetId,
42276
42050
  owner: Address.fromAddressOrString(coin.owner),
42051
+ maturity: bn(coin.maturity).toNumber(),
42277
42052
  blockCreated: bn(coin.blockCreated),
42278
42053
  txCreatedIdx: bn(coin.txCreatedIdx)
42279
42054
  };
@@ -42306,7 +42081,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42306
42081
  }
42307
42082
  return {
42308
42083
  id: block2.id,
42309
- height: bn(block2.height),
42084
+ height: bn(block2.header.height),
42310
42085
  time: block2.header.time,
42311
42086
  transactionIds: block2.transactions.map((tx) => tx.id)
42312
42087
  };
@@ -42321,7 +42096,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42321
42096
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
42322
42097
  const blocks = fetchedData.edges.map(({ node: block2 }) => ({
42323
42098
  id: block2.id,
42324
- height: bn(block2.height),
42099
+ height: bn(block2.header.height),
42325
42100
  time: block2.header.time,
42326
42101
  transactionIds: block2.transactions.map((tx) => tx.id)
42327
42102
  }));
@@ -42348,7 +42123,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42348
42123
  }
42349
42124
  return {
42350
42125
  id: block2.id,
42351
- height: bn(block2.height, 10),
42126
+ height: bn(block2.header.height, 10),
42352
42127
  time: block2.header.time,
42353
42128
  transactionIds: block2.transactions.map((tx) => tx.id),
42354
42129
  transactions: block2.transactions.map(
@@ -42528,11 +42303,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42528
42303
  prevRoot: messageBlockHeader.prevRoot,
42529
42304
  time: messageBlockHeader.time,
42530
42305
  applicationHash: messageBlockHeader.applicationHash,
42531
- messageReceiptCount: bn(messageBlockHeader.messageReceiptCount),
42532
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
42533
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
42534
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
42535
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
42306
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
42307
+ messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
42536
42308
  },
42537
42309
  commitBlockHeader: {
42538
42310
  id: commitBlockHeader.id,
@@ -42543,11 +42315,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42543
42315
  prevRoot: commitBlockHeader.prevRoot,
42544
42316
  time: commitBlockHeader.time,
42545
42317
  applicationHash: commitBlockHeader.applicationHash,
42546
- messageReceiptCount: bn(commitBlockHeader.messageReceiptCount),
42547
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
42548
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
42549
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
42550
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
42318
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
42319
+ messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
42551
42320
  },
42552
42321
  sender: Address.fromAddressOrString(sender),
42553
42322
  recipient: Address.fromAddressOrString(recipient),
@@ -42556,16 +42325,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42556
42325
  data
42557
42326
  };
42558
42327
  }
42559
- async getLatestGasPrice() {
42560
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
42561
- return bn(latestGasPrice.gasPrice);
42562
- }
42563
- async estimateGasPrice(blockHorizon) {
42564
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
42565
- blockHorizon: String(blockHorizon)
42566
- });
42567
- return bn(estimateGasPrice.gasPrice);
42568
- }
42569
42328
  /**
42570
42329
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
42571
42330
  *
@@ -42626,15 +42385,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42626
42385
  arrayify(gqlTransaction.rawPayload),
42627
42386
  0
42628
42387
  );
42629
- let txReceipts = [];
42630
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42631
- txReceipts = gqlTransaction.status.receipts;
42632
- }
42633
- const receipts = txReceipts.map(processGqlReceipt);
42388
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
42634
42389
  const {
42635
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42390
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42636
42391
  } = provider.getChain();
42637
- const gasPrice = await provider.getLatestGasPrice();
42638
42392
  const transactionInfo = assembleTransactionSummary({
42639
42393
  id: gqlTransaction.id,
42640
42394
  receipts,
@@ -42645,9 +42399,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42645
42399
  gasPriceFactor: bn(gasPriceFactor),
42646
42400
  abiMap,
42647
42401
  maxInputs,
42648
- gasCosts,
42649
- maxGasPerTx,
42650
- gasPrice
42402
+ gasCosts
42651
42403
  });
42652
42404
  return {
42653
42405
  gqlTransaction,
@@ -42657,11 +42409,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42657
42409
  async function getTransactionSummaryFromRequest(params) {
42658
42410
  const { provider, transactionRequest, abiMap } = params;
42659
42411
  const { receipts } = await provider.call(transactionRequest);
42660
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
42412
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
42661
42413
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
42662
42414
  const transaction = transactionRequest.toTransaction();
42663
42415
  const transactionBytes = transactionRequest.toTransactionBytes();
42664
- const gasPrice = await provider.getLatestGasPrice();
42665
42416
  const transactionSummary = assembleTransactionSummary({
42666
42417
  receipts,
42667
42418
  transaction,
@@ -42670,9 +42421,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42670
42421
  gasPerByte,
42671
42422
  gasPriceFactor,
42672
42423
  maxInputs,
42673
- gasCosts,
42674
- maxGasPerTx,
42675
- gasPrice
42424
+ gasCosts
42676
42425
  });
42677
42426
  return transactionSummary;
42678
42427
  }
@@ -42681,18 +42430,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42681
42430
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
42682
42431
  const { edges, pageInfo } = transactionsByOwner;
42683
42432
  const {
42684
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42433
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42685
42434
  } = provider.getChain();
42686
- const gasPrice = await provider.getLatestGasPrice();
42687
42435
  const transactions = edges.map((edge) => {
42688
42436
  const { node: gqlTransaction } = edge;
42689
- const { id, rawPayload, status } = gqlTransaction;
42437
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
42690
42438
  const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
42691
- let txReceipts = [];
42692
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42693
- txReceipts = gqlTransaction.status.receipts;
42694
- }
42695
- const receipts = txReceipts.map(processGqlReceipt);
42439
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
42696
42440
  const transactionSummary = assembleTransactionSummary({
42697
42441
  id,
42698
42442
  receipts,
@@ -42703,9 +42447,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42703
42447
  gasPerByte,
42704
42448
  gasPriceFactor,
42705
42449
  maxInputs,
42706
- gasCosts,
42707
- maxGasPerTx,
42708
- gasPrice
42450
+ gasCosts
42709
42451
  });
42710
42452
  const output3 = {
42711
42453
  gqlTransaction,
@@ -43034,33 +42776,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43034
42776
  * @param fee - The estimated transaction fee.
43035
42777
  * @returns A promise that resolves when the resources are added to the transaction.
43036
42778
  */
43037
- async fund(request, params) {
43038
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
43039
- const txRequest = request;
43040
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
42779
+ async fund(request, coinQuantities, fee) {
42780
+ const updatedQuantities = addAmountToAsset({
43041
42781
  amount: bn(fee),
43042
42782
  assetId: BaseAssetId,
43043
- coinQuantities: requiredQuantities
42783
+ coinQuantities
43044
42784
  });
43045
42785
  const quantitiesDict = {};
43046
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
42786
+ updatedQuantities.forEach(({ amount, assetId }) => {
43047
42787
  quantitiesDict[assetId] = {
43048
42788
  required: amount,
43049
42789
  owned: bn(0)
43050
42790
  };
43051
42791
  });
43052
- txRequest.inputs.forEach((input) => {
42792
+ const cachedUtxos = [];
42793
+ const cachedMessages = [];
42794
+ const owner = this.address.toB256();
42795
+ request.inputs.forEach((input) => {
43053
42796
  const isResource = "amount" in input;
43054
42797
  if (isResource) {
43055
42798
  const isCoin2 = "owner" in input;
43056
42799
  if (isCoin2) {
43057
42800
  const assetId = String(input.assetId);
43058
- if (quantitiesDict[assetId]) {
42801
+ if (input.owner === owner && quantitiesDict[assetId]) {
43059
42802
  const amount = bn(input.amount);
43060
42803
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42804
+ cachedUtxos.push(input.id);
43061
42805
  }
43062
- } else if (input.amount && quantitiesDict[BaseAssetId]) {
42806
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
43063
42807
  quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42808
+ cachedMessages.push(input.nonce);
43064
42809
  }
43065
42810
  }
43066
42811
  });
@@ -43075,23 +42820,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43075
42820
  });
43076
42821
  const needsToBeFunded = missingQuantities.length;
43077
42822
  if (needsToBeFunded) {
43078
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
43079
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
43080
- txRequest.addResources(resources);
43081
- }
43082
- txRequest.shiftPredicateData();
43083
- txRequest.updatePredicateGasUsed(estimatedPredicates);
43084
- const requestToBeReEstimate = clone_default(txRequest);
43085
- if (addedSignatures) {
43086
- Array.from({ length: addedSignatures }).forEach(
43087
- () => requestToBeReEstimate.addEmptyWitness()
43088
- );
42823
+ const resources = await this.getResourcesToSpend(missingQuantities, {
42824
+ messages: cachedMessages,
42825
+ utxos: cachedUtxos
42826
+ });
42827
+ request.addResources(resources);
43089
42828
  }
43090
- const { maxFee } = await this.provider.estimateTxGasAndFee({
43091
- transactionRequest: requestToBeReEstimate
43092
- });
43093
- txRequest.maxFee = maxFee;
43094
- return txRequest;
43095
42829
  }
43096
42830
  /**
43097
42831
  * A helper that creates a transfer transaction request and returns it.
@@ -43099,25 +42833,28 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43099
42833
  * @param destination - The address of the destination.
43100
42834
  * @param amount - The amount of coins to transfer.
43101
42835
  * @param assetId - The asset ID of the coins to transfer.
43102
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
42836
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
43103
42837
  * @returns A promise that resolves to the prepared transaction request.
43104
42838
  */
43105
42839
  async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
43106
- const request = new ScriptTransactionRequest(txParams);
42840
+ const { minGasPrice } = this.provider.getGasConfig();
42841
+ const params = { gasPrice: minGasPrice, ...txParams };
42842
+ const request = new ScriptTransactionRequest(params);
43107
42843
  request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
43108
- const txCost = await this.provider.getTransactionCost(request, {
42844
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
43109
42845
  estimateTxDependencies: true,
43110
42846
  resourcesOwner: this
43111
42847
  });
43112
- if ("gasLimit" in txParams) {
43113
- this.validateGas({
43114
- gasUsed: txCost.gasUsed,
43115
- gasLimit: request.gasLimit
43116
- });
43117
- }
43118
- request.gasLimit = txCost.gasUsed;
43119
- request.maxFee = txCost.maxFee;
43120
- await this.fund(request, txCost);
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);
43121
42858
  return request;
43122
42859
  }
43123
42860
  /**
@@ -43156,30 +42893,31 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43156
42893
  );
43157
42894
  }
43158
42895
  const contractAddress = Address.fromAddressOrString(contractId);
42896
+ const { minGasPrice } = this.provider.getGasConfig();
42897
+ const params = { gasPrice: minGasPrice, ...txParams };
43159
42898
  const { script, scriptData } = await assembleTransferToContractScript({
43160
42899
  hexlifiedContractId: contractAddress.toB256(),
43161
42900
  amountToTransfer: bn(amount),
43162
42901
  assetId
43163
42902
  });
43164
42903
  const request = new ScriptTransactionRequest({
43165
- ...txParams,
42904
+ ...params,
43166
42905
  script,
43167
42906
  scriptData
43168
42907
  });
43169
42908
  request.addContractInputAndOutput(contractAddress);
43170
- const txCost = await this.provider.getTransactionCost(request, {
43171
- resourcesOwner: this,
43172
- quantitiesToContract: [{ amount: bn(amount), assetId: String(assetId) }]
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
43173
42919
  });
43174
- if (txParams.gasLimit) {
43175
- this.validateGas({
43176
- gasUsed: txCost.gasUsed,
43177
- gasLimit: request.gasLimit
43178
- });
43179
- }
43180
- request.gasLimit = txCost.gasUsed;
43181
- request.maxFee = txCost.maxFee;
43182
- await this.fund(request, txCost);
42920
+ await this.fund(request, requiredQuantities, maxFee);
43183
42921
  return this.sendTransaction(request);
43184
42922
  }
43185
42923
  /**
@@ -43191,6 +42929,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43191
42929
  * @returns A promise that resolves to the transaction response.
43192
42930
  */
43193
42931
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42932
+ const { minGasPrice } = this.provider.getGasConfig();
43194
42933
  const recipientAddress = Address.fromAddressOrString(recipient);
43195
42934
  const recipientDataArray = arrayify(
43196
42935
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -43203,19 +42942,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43203
42942
  ...recipientDataArray,
43204
42943
  ...amountDataArray
43205
42944
  ]);
43206
- const params = { script, ...txParams };
42945
+ const params = { script, gasPrice: minGasPrice, ...txParams };
43207
42946
  const request = new ScriptTransactionRequest(params);
43208
- const quantitiesToContract = [{ amount: bn(amount), assetId: BaseAssetId }];
43209
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
43210
- if (txParams.gasLimit) {
43211
- this.validateGas({
43212
- gasUsed: txCost.gasUsed,
43213
- gasLimit: request.gasLimit
43214
- });
43215
- }
43216
- request.maxFee = txCost.maxFee;
43217
- request.gasLimit = txCost.gasUsed;
43218
- await this.fund(request, txCost);
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);
43219
42960
  return this.sendTransaction(request);
43220
42961
  }
43221
42962
  async signMessage(message) {
@@ -43273,7 +43014,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43273
43014
  }
43274
43015
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
43275
43016
  }
43276
- validateGas({ gasUsed, gasLimit }) {
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
+ }
43277
43029
  if (gasUsed.gt(gasLimit)) {
43278
43030
  throw new FuelError(
43279
43031
  ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -44862,7 +44614,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44862
44614
  * @param transactionRequestLike - The transaction request to send.
44863
44615
  * @returns A promise that resolves to the TransactionResponse object.
44864
44616
  */
44865
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
44617
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
44866
44618
  const transactionRequest = transactionRequestify(transactionRequestLike);
44867
44619
  if (estimateTxDependencies) {
44868
44620
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -48138,10 +47890,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48138
47890
  populateTransactionPredicateData(transactionRequestLike) {
48139
47891
  const request = transactionRequestify(transactionRequestLike);
48140
47892
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
48141
- request.inputs?.forEach((input) => {
48142
- if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
48143
- input.predicate = hexlify(this.bytes);
48144
- input.predicateData = hexlify(this.getPredicateData(policies.length));
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
47902
  }
48146
47903
  });
48147
47904
  return request;
@@ -48156,7 +47913,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48156
47913
  * @returns A promise that resolves to the prepared transaction request.
48157
47914
  */
48158
47915
  async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
48159
- return super.createTransfer(destination, amount, assetId, txParams);
47916
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
47917
+ return this.populateTransactionPredicateData(request);
48160
47918
  }
48161
47919
  /**
48162
47920
  * Sends a transaction with the populated predicate data.
@@ -48164,9 +47922,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48164
47922
  * @param transactionRequestLike - The transaction request-like object.
48165
47923
  * @returns A promise that resolves to the transaction response.
48166
47924
  */
48167
- sendTransaction(transactionRequestLike) {
48168
- const transactionRequest = transactionRequestify(transactionRequestLike);
48169
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
47925
+ sendTransaction(transactionRequestLike, options) {
47926
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47927
+ return super.sendTransaction(transactionRequest, options);
48170
47928
  }
48171
47929
  /**
48172
47930
  * Simulates a transaction with the populated predicate data.
@@ -48175,8 +47933,22 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48175
47933
  * @returns A promise that resolves to the call result.
48176
47934
  */
48177
47935
  simulateTransaction(transactionRequestLike) {
48178
- const transactionRequest = transactionRequestify(transactionRequestLike);
48179
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
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
+ }));
48180
47952
  }
48181
47953
  getPredicateData(policiesLength) {
48182
47954
  if (!this.predicateData.length) {
@@ -48222,25 +47994,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48222
47994
  predicateInterface: abiInterface
48223
47995
  };
48224
47996
  }
48225
- /**
48226
- * Retrieves resources satisfying the spend query for the account.
48227
- *
48228
- * @param quantities - IDs of coins to exclude.
48229
- * @param excludedIds - IDs of resources to be excluded from the query.
48230
- * @returns A promise that resolves to an array of Resources.
48231
- */
48232
- async getResourcesToSpend(quantities, excludedIds) {
48233
- const resources = await this.provider.getResourcesToSpend(
48234
- this.address,
48235
- quantities,
48236
- excludedIds
48237
- );
48238
- return resources.map((resource) => ({
48239
- ...resource,
48240
- predicate: hexlify(this.bytes),
48241
- paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
48242
- }));
48243
- }
48244
47997
  /**
48245
47998
  * Sets the configurable constants for the predicate.
48246
47999
  *
@@ -48276,6 +48029,28 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48276
48029
  }
48277
48030
  return mutatedBytes;
48278
48031
  }
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
+ }
48279
48054
  };
48280
48055
 
48281
48056
  // src/connectors/fuel-connector.ts