@fuel-ts/account 0.0.0-rc-1976-20240424110729 → 0.0.0-rc-2021-20240424121206

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 (56) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +5 -4
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +861 -611
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +864 -608
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +706 -451
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +10 -2
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +822 -328
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +3 -3
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +4 -2
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +7 -1
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +37 -34
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  30. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-request/input.d.ts +2 -2
  32. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -1
  34. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/transaction-request.d.ts +8 -32
  36. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  37. package/dist/providers/transaction-request/utils.d.ts +3 -0
  38. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  39. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
  41. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
  43. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  44. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  45. package/dist/providers/utils/gas.d.ts +8 -2
  46. package/dist/providers/utils/gas.d.ts.map +1 -1
  47. package/dist/test-utils/launchNode.d.ts.map +1 -1
  48. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  49. package/dist/test-utils.global.js +1578 -1114
  50. package/dist/test-utils.global.js.map +1 -1
  51. package/dist/test-utils.js +845 -609
  52. package/dist/test-utils.js.map +1 -1
  53. package/dist/test-utils.mjs +699 -463
  54. package/dist/test-utils.mjs.map +1 -1
  55. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  56. 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 max2(left, right) {
292
+ BN2.max = function max(left, right) {
293
293
  if (left.cmp(right) > 0)
294
294
  return left;
295
295
  return right;
@@ -5113,7 +5113,7 @@
5113
5113
  function isBlob(obj) {
5114
5114
  return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
5115
5115
  }
5116
- function clone(instance) {
5116
+ function clone3(instance) {
5117
5117
  let p1, p2;
5118
5118
  let body = instance.body;
5119
5119
  if (instance.bodyUsed) {
@@ -6047,7 +6047,7 @@
6047
6047
  * @return Response
6048
6048
  */
6049
6049
  clone() {
6050
- return new Response2(clone(this), {
6050
+ return new Response2(clone3(this), {
6051
6051
  url: this.url,
6052
6052
  status: this.status,
6053
6053
  statusText: this.statusText,
@@ -6097,7 +6097,7 @@
6097
6097
  if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
6098
6098
  throw new TypeError("Request with GET/HEAD method cannot have body");
6099
6099
  }
6100
- let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
6100
+ let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone3(input) : null;
6101
6101
  Body.call(this, inputBody, {
6102
6102
  timeout: init.timeout || input.timeout || 0,
6103
6103
  size: init.size || input.size || 0
@@ -28952,8 +28952,8 @@ spurious results.`);
28952
28952
  // ../versions/dist/index.mjs
28953
28953
  function getBuiltinVersions() {
28954
28954
  return {
28955
- FORC: "0.49.3",
28956
- FUEL_CORE: "0.22.1",
28955
+ FORC: "0.51.1",
28956
+ FUEL_CORE: "0.24.2",
28957
28957
  FUELS: "0.81.0"
28958
28958
  };
28959
28959
  }
@@ -31272,6 +31272,10 @@ This unreleased fuel-core build may include features and updates not yet support
31272
31272
  }
31273
31273
  };
31274
31274
 
31275
+ // ../address/dist/configs.mjs
31276
+ var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
31277
+ var BaseAssetId = ZeroBytes32;
31278
+
31275
31279
  // ../math/dist/index.mjs
31276
31280
  var import_bn = __toESM(require_bn(), 1);
31277
31281
  var DEFAULT_PRECISION = 9;
@@ -31491,32 +31495,182 @@ This unreleased fuel-core build may include features and updates not yet support
31491
31495
  function toBytes3(value, bytesPadding) {
31492
31496
  return bn(value).toBytes(bytesPadding);
31493
31497
  }
31494
- function max(...numbers) {
31495
- return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
31498
+
31499
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
31500
+ function _isPlaceholder(a) {
31501
+ return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
31502
+ }
31503
+
31504
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
31505
+ function _curry1(fn) {
31506
+ return function f1(a) {
31507
+ if (arguments.length === 0 || _isPlaceholder(a)) {
31508
+ return f1;
31509
+ } else {
31510
+ return fn.apply(this, arguments);
31511
+ }
31512
+ };
31513
+ }
31514
+
31515
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
31516
+ var isArray_default = Array.isArray || function _isArray(val) {
31517
+ return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
31518
+ };
31519
+
31520
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
31521
+ var type = /* @__PURE__ */ _curry1(function type2(val) {
31522
+ return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
31523
+ });
31524
+ var type_default = type;
31525
+
31526
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
31527
+ var pad = function pad2(n) {
31528
+ return (n < 10 ? "0" : "") + n;
31529
+ };
31530
+ var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
31531
+ return d.toISOString();
31532
+ } : function _toISOString3(d) {
31533
+ return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
31534
+ };
31535
+
31536
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
31537
+ var isInteger_default = Number.isInteger || function _isInteger(n) {
31538
+ return n << 0 === n;
31539
+ };
31540
+
31541
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
31542
+ function _cloneRegExp(pattern) {
31543
+ return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
31496
31544
  }
31497
31545
 
31546
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
31547
+ function _clone(value, deep, map) {
31548
+ map || (map = new _ObjectMap());
31549
+ if (_isPrimitive(value)) {
31550
+ return value;
31551
+ }
31552
+ var copy = function copy2(copiedValue) {
31553
+ var cachedCopy = map.get(value);
31554
+ if (cachedCopy) {
31555
+ return cachedCopy;
31556
+ }
31557
+ map.set(value, copiedValue);
31558
+ for (var key in value) {
31559
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
31560
+ copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
31561
+ }
31562
+ }
31563
+ return copiedValue;
31564
+ };
31565
+ switch (type_default(value)) {
31566
+ case "Object":
31567
+ return copy(Object.create(Object.getPrototypeOf(value)));
31568
+ case "Array":
31569
+ return copy([]);
31570
+ case "Date":
31571
+ return new Date(value.valueOf());
31572
+ case "RegExp":
31573
+ return _cloneRegExp(value);
31574
+ case "Int8Array":
31575
+ case "Uint8Array":
31576
+ case "Uint8ClampedArray":
31577
+ case "Int16Array":
31578
+ case "Uint16Array":
31579
+ case "Int32Array":
31580
+ case "Uint32Array":
31581
+ case "Float32Array":
31582
+ case "Float64Array":
31583
+ case "BigInt64Array":
31584
+ case "BigUint64Array":
31585
+ return value.slice();
31586
+ default:
31587
+ return value;
31588
+ }
31589
+ }
31590
+ function _isPrimitive(param) {
31591
+ var type3 = typeof param;
31592
+ return param == null || type3 != "object" && type3 != "function";
31593
+ }
31594
+ var _ObjectMap = /* @__PURE__ */ function() {
31595
+ function _ObjectMap2() {
31596
+ this.map = {};
31597
+ this.length = 0;
31598
+ }
31599
+ _ObjectMap2.prototype.set = function(key, value) {
31600
+ const hashedKey = this.hash(key);
31601
+ let bucket = this.map[hashedKey];
31602
+ if (!bucket) {
31603
+ this.map[hashedKey] = bucket = [];
31604
+ }
31605
+ bucket.push([key, value]);
31606
+ this.length += 1;
31607
+ };
31608
+ _ObjectMap2.prototype.hash = function(key) {
31609
+ let hashedKey = [];
31610
+ for (var value in key) {
31611
+ hashedKey.push(Object.prototype.toString.call(key[value]));
31612
+ }
31613
+ return hashedKey.join();
31614
+ };
31615
+ _ObjectMap2.prototype.get = function(key) {
31616
+ if (this.length <= 180) {
31617
+ for (const p in this.map) {
31618
+ const bucket2 = this.map[p];
31619
+ for (let i = 0; i < bucket2.length; i += 1) {
31620
+ const element = bucket2[i];
31621
+ if (element[0] === key) {
31622
+ return element[1];
31623
+ }
31624
+ }
31625
+ }
31626
+ return;
31627
+ }
31628
+ const hashedKey = this.hash(key);
31629
+ const bucket = this.map[hashedKey];
31630
+ if (!bucket) {
31631
+ return;
31632
+ }
31633
+ for (let i = 0; i < bucket.length; i += 1) {
31634
+ const element = bucket[i];
31635
+ if (element[0] === key) {
31636
+ return element[1];
31637
+ }
31638
+ }
31639
+ };
31640
+ return _ObjectMap2;
31641
+ }();
31642
+
31643
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
31644
+ var clone = /* @__PURE__ */ _curry1(function clone2(value) {
31645
+ return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
31646
+ });
31647
+ var clone_default = clone;
31648
+
31649
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
31650
+ var hasProtoTrim = typeof String.prototype.trim === "function";
31651
+
31498
31652
  // src/providers/coin-quantity.ts
31499
31653
  var coinQuantityfy = (coinQuantityLike) => {
31500
31654
  let assetId;
31501
31655
  let amount;
31502
- let max2;
31656
+ let max;
31503
31657
  if (Array.isArray(coinQuantityLike)) {
31504
31658
  amount = coinQuantityLike[0];
31505
- assetId = coinQuantityLike[1];
31506
- max2 = coinQuantityLike[2];
31659
+ assetId = coinQuantityLike[1] ?? BaseAssetId;
31660
+ max = coinQuantityLike[2] ?? void 0;
31507
31661
  } else {
31508
31662
  amount = coinQuantityLike.amount;
31509
- assetId = coinQuantityLike.assetId;
31510
- max2 = coinQuantityLike.max ?? void 0;
31663
+ assetId = coinQuantityLike.assetId ?? BaseAssetId;
31664
+ max = coinQuantityLike.max ?? void 0;
31511
31665
  }
31512
31666
  const bnAmount = bn(amount);
31513
31667
  return {
31514
31668
  assetId: hexlify(assetId),
31515
31669
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
31516
- max: max2 ? bn(max2) : void 0
31670
+ max: max ? bn(max) : void 0
31517
31671
  };
31518
31672
  };
31519
- var addAmountToAsset = (params) => {
31673
+ var addAmountToCoinQuantities = (params) => {
31520
31674
  const { amount, assetId } = params;
31521
31675
  const coinQuantities = [...params.coinQuantities];
31522
31676
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -31601,7 +31755,7 @@ This unreleased fuel-core build may include features and updates not yet support
31601
31755
  var ENCODING_V1 = "1";
31602
31756
  var WORD_SIZE = 8;
31603
31757
  var BYTES_32 = 32;
31604
- var UTXO_ID_LEN = BYTES_32 + 1;
31758
+ var UTXO_ID_LEN = BYTES_32 + 2;
31605
31759
  var ASSET_ID_LEN = BYTES_32;
31606
31760
  var ADDRESS_LEN = BYTES_32;
31607
31761
  var NONCE_LEN = BYTES_32;
@@ -31609,9 +31763,9 @@ This unreleased fuel-core build may include features and updates not yet support
31609
31763
  var TX_POINTER_LEN = WORD_SIZE * 2;
31610
31764
  var MAX_BYTES = 2 ** 32 - 1;
31611
31765
  var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
31612
- WORD_SIZE + // Tx size
31766
+ ASSET_ID_LEN + // Base asset ID
31613
31767
  // Asset ID/Balance coin input pairs
31614
- maxInputs * (ASSET_ID_LEN + WORD_SIZE);
31768
+ maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
31615
31769
  var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
31616
31770
  WORD_SIZE + // Gas limit
31617
31771
  WORD_SIZE + // Script size
@@ -31629,7 +31783,6 @@ This unreleased fuel-core build may include features and updates not yet support
31629
31783
  ASSET_ID_LEN + // Asset id
31630
31784
  TX_POINTER_LEN + // TxPointer
31631
31785
  WORD_SIZE + // Witnesses index
31632
- WORD_SIZE + // Maturity
31633
31786
  WORD_SIZE + // Predicate size
31634
31787
  WORD_SIZE + // Predicate data size
31635
31788
  WORD_SIZE;
@@ -31951,7 +32104,7 @@ This unreleased fuel-core build may include features and updates not yet support
31951
32104
  constructor(name, coders) {
31952
32105
  const caseIndexCoder = new BigNumberCoder("u64");
31953
32106
  const encodedValueSize = Object.values(coders).reduce(
31954
- (max2, coder) => Math.max(max2, coder.encodedLength),
32107
+ (max, coder) => Math.max(max, coder.encodedLength),
31955
32108
  0
31956
32109
  );
31957
32110
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -32669,7 +32822,7 @@ This unreleased fuel-core build may include features and updates not yet support
32669
32822
  constructor(name, coders) {
32670
32823
  const caseIndexCoder = new BigNumberCoder("u64");
32671
32824
  const encodedValueSize = Object.values(coders).reduce(
32672
- (max2, coder) => Math.max(max2, coder.encodedLength),
32825
+ (max, coder) => Math.max(max, coder.encodedLength),
32673
32826
  0
32674
32827
  );
32675
32828
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -33383,18 +33536,19 @@ This unreleased fuel-core build may include features and updates not yet support
33383
33536
  encode(value) {
33384
33537
  const parts = [];
33385
33538
  parts.push(new B256Coder().encode(value.txID));
33386
- parts.push(new NumberCoder("u8").encode(value.outputIndex));
33539
+ parts.push(new NumberCoder("u16").encode(value.outputIndex));
33387
33540
  parts.push(new B256Coder().encode(value.owner));
33388
33541
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33389
33542
  parts.push(new B256Coder().encode(value.assetId));
33390
33543
  parts.push(new TxPointerCoder().encode(value.txPointer));
33391
- parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33392
- parts.push(new NumberCoder("u32").encode(value.maturity));
33544
+ parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33393
33545
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33394
- parts.push(new NumberCoder("u32").encode(value.predicateLength));
33395
- parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
33396
- parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33397
- parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33546
+ parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33547
+ parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33548
+ parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33549
+ parts.push(
33550
+ new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33551
+ );
33398
33552
  return concat(parts);
33399
33553
  }
33400
33554
  decode(data, offset) {
@@ -33402,7 +33556,7 @@ This unreleased fuel-core build may include features and updates not yet support
33402
33556
  let o = offset;
33403
33557
  [decoded, o] = new B256Coder().decode(data, o);
33404
33558
  const txID = decoded;
33405
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33559
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33406
33560
  const outputIndex = decoded;
33407
33561
  [decoded, o] = new B256Coder().decode(data, o);
33408
33562
  const owner = decoded;
@@ -33412,19 +33566,17 @@ This unreleased fuel-core build may include features and updates not yet support
33412
33566
  const assetId = decoded;
33413
33567
  [decoded, o] = new TxPointerCoder().decode(data, o);
33414
33568
  const txPointer = decoded;
33415
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33569
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33416
33570
  const witnessIndex = Number(decoded);
33417
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33418
- const maturity = decoded;
33419
33571
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33420
33572
  const predicateGasUsed = decoded;
33421
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33573
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33422
33574
  const predicateLength = decoded;
33423
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33575
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33424
33576
  const predicateDataLength = decoded;
33425
- [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33577
+ [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33426
33578
  const predicate = decoded;
33427
- [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33579
+ [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33428
33580
  const predicateData = decoded;
33429
33581
  return [
33430
33582
  {
@@ -33436,7 +33588,6 @@ This unreleased fuel-core build may include features and updates not yet support
33436
33588
  assetId,
33437
33589
  txPointer,
33438
33590
  witnessIndex,
33439
- maturity,
33440
33591
  predicateGasUsed,
33441
33592
  predicateLength,
33442
33593
  predicateDataLength,
@@ -33454,7 +33605,7 @@ This unreleased fuel-core build may include features and updates not yet support
33454
33605
  encode(value) {
33455
33606
  const parts = [];
33456
33607
  parts.push(new B256Coder().encode(value.txID));
33457
- parts.push(new NumberCoder("u8").encode(value.outputIndex));
33608
+ parts.push(new NumberCoder("u16").encode(value.outputIndex));
33458
33609
  parts.push(new B256Coder().encode(value.balanceRoot));
33459
33610
  parts.push(new B256Coder().encode(value.stateRoot));
33460
33611
  parts.push(new TxPointerCoder().encode(value.txPointer));
@@ -33466,7 +33617,7 @@ This unreleased fuel-core build may include features and updates not yet support
33466
33617
  let o = offset;
33467
33618
  [decoded, o] = new B256Coder().decode(data, o);
33468
33619
  const txID = decoded;
33469
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33620
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33470
33621
  const outputIndex = decoded;
33471
33622
  [decoded, o] = new B256Coder().decode(data, o);
33472
33623
  const balanceRoot = decoded;
@@ -33515,14 +33666,16 @@ This unreleased fuel-core build may include features and updates not yet support
33515
33666
  parts.push(new ByteArrayCoder(32).encode(value.recipient));
33516
33667
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33517
33668
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
33518
- parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33669
+ parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33519
33670
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33520
- parts.push(new NumberCoder("u32").encode(data.length));
33521
- parts.push(new NumberCoder("u32").encode(value.predicateLength));
33522
- parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
33671
+ parts.push(new BigNumberCoder("u64").encode(data.length));
33672
+ parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33673
+ parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33523
33674
  parts.push(new ByteArrayCoder(data.length).encode(data));
33524
- parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33525
- parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33675
+ parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33676
+ parts.push(
33677
+ new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33678
+ );
33526
33679
  return concat(parts);
33527
33680
  }
33528
33681
  static decodeData(messageData) {
@@ -33542,21 +33695,21 @@ This unreleased fuel-core build may include features and updates not yet support
33542
33695
  const amount = decoded;
33543
33696
  [decoded, o] = new B256Coder().decode(data, o);
33544
33697
  const nonce = decoded;
33545
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33698
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33546
33699
  const witnessIndex = Number(decoded);
33547
33700
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33548
33701
  const predicateGasUsed = decoded;
33549
33702
  [decoded, o] = new NumberCoder("u32").decode(data, o);
33550
33703
  const dataLength2 = decoded;
33551
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33704
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33552
33705
  const predicateLength = decoded;
33553
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33706
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33554
33707
  const predicateDataLength = decoded;
33555
33708
  [decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
33556
33709
  const messageData = decoded;
33557
- [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33710
+ [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33558
33711
  const predicate = decoded;
33559
- [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33712
+ [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33560
33713
  const predicateData = decoded;
33561
33714
  return [
33562
33715
  {
@@ -33868,7 +34021,7 @@ This unreleased fuel-core build may include features and updates not yet support
33868
34021
  }
33869
34022
  };
33870
34023
  var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
33871
- PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
34024
+ PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
33872
34025
  PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
33873
34026
  PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
33874
34027
  PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
@@ -33916,9 +34069,9 @@ This unreleased fuel-core build may include features and updates not yet support
33916
34069
  let o = offset;
33917
34070
  const policies = [];
33918
34071
  if (policyTypes & 1) {
33919
- const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
34072
+ const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
33920
34073
  o = nextOffset;
33921
- policies.push({ type: 1, data: gasPrice });
34074
+ policies.push({ type: 1, data: tip });
33922
34075
  }
33923
34076
  if (policyTypes & 2) {
33924
34077
  const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
@@ -34150,15 +34303,15 @@ This unreleased fuel-core build may include features and updates not yet support
34150
34303
  encode(value) {
34151
34304
  const parts = [];
34152
34305
  parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
34153
- parts.push(new NumberCoder("u32").encode(value.scriptLength));
34154
- parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
34155
- parts.push(new NumberCoder("u32").encode(value.policyTypes));
34156
- parts.push(new NumberCoder("u8").encode(value.inputsCount));
34157
- parts.push(new NumberCoder("u8").encode(value.outputsCount));
34158
- parts.push(new NumberCoder("u8").encode(value.witnessesCount));
34159
34306
  parts.push(new B256Coder().encode(value.receiptsRoot));
34160
- parts.push(new ByteArrayCoder(value.scriptLength).encode(value.script));
34161
- parts.push(new ByteArrayCoder(value.scriptDataLength).encode(value.scriptData));
34307
+ parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
34308
+ parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
34309
+ parts.push(new NumberCoder("u32").encode(value.policyTypes));
34310
+ parts.push(new NumberCoder("u16").encode(value.inputsCount));
34311
+ parts.push(new NumberCoder("u16").encode(value.outputsCount));
34312
+ parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34313
+ parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
34314
+ parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
34162
34315
  parts.push(new PoliciesCoder().encode(value.policies));
34163
34316
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34164
34317
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
@@ -34170,23 +34323,23 @@ This unreleased fuel-core build may include features and updates not yet support
34170
34323
  let o = offset;
34171
34324
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34172
34325
  const scriptGasLimit = decoded;
34173
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34326
+ [decoded, o] = new B256Coder().decode(data, o);
34327
+ const receiptsRoot = decoded;
34328
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34174
34329
  const scriptLength = decoded;
34175
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34330
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34176
34331
  const scriptDataLength = decoded;
34177
34332
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34178
34333
  const policyTypes = decoded;
34179
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34334
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34180
34335
  const inputsCount = decoded;
34181
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34336
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34182
34337
  const outputsCount = decoded;
34183
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34338
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34184
34339
  const witnessesCount = decoded;
34185
- [decoded, o] = new B256Coder().decode(data, o);
34186
- const receiptsRoot = decoded;
34187
- [decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
34340
+ [decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
34188
34341
  const script = decoded;
34189
- [decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
34342
+ [decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
34190
34343
  const scriptData = decoded;
34191
34344
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34192
34345
  const policies = decoded;
@@ -34224,18 +34377,19 @@ This unreleased fuel-core build may include features and updates not yet support
34224
34377
  }
34225
34378
  encode(value) {
34226
34379
  const parts = [];
34227
- parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
34228
- parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
34229
- parts.push(new NumberCoder("u32").encode(value.policyTypes));
34230
- parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
34231
- parts.push(new NumberCoder("u8").encode(value.inputsCount));
34232
- parts.push(new NumberCoder("u8").encode(value.outputsCount));
34233
- parts.push(new NumberCoder("u8").encode(value.witnessesCount));
34380
+ parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
34234
34381
  parts.push(new B256Coder().encode(value.salt));
34235
- parts.push(new PoliciesCoder().encode(value.policies));
34382
+ parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
34383
+ parts.push(new NumberCoder("u32").encode(value.policyTypes));
34384
+ parts.push(new NumberCoder("u16").encode(value.inputsCount));
34385
+ parts.push(new NumberCoder("u16").encode(value.outputsCount));
34386
+ parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34236
34387
  parts.push(
34237
- new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
34388
+ new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
34389
+ value.storageSlots
34390
+ )
34238
34391
  );
34392
+ parts.push(new PoliciesCoder().encode(value.policies));
34239
34393
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34240
34394
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
34241
34395
  parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
@@ -34244,26 +34398,27 @@ This unreleased fuel-core build may include features and updates not yet support
34244
34398
  decode(data, offset) {
34245
34399
  let decoded;
34246
34400
  let o = offset;
34247
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34248
- const bytecodeLength = decoded;
34249
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34401
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34250
34402
  const bytecodeWitnessIndex = decoded;
34403
+ [decoded, o] = new B256Coder().decode(data, o);
34404
+ const salt = decoded;
34405
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34406
+ const storageSlotsCount = decoded;
34251
34407
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34252
34408
  const policyTypes = decoded;
34253
34409
  [decoded, o] = new NumberCoder("u16").decode(data, o);
34254
- const storageSlotsCount = decoded;
34255
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34256
34410
  const inputsCount = decoded;
34257
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34411
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34258
34412
  const outputsCount = decoded;
34259
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34413
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34260
34414
  const witnessesCount = decoded;
34261
- [decoded, o] = new B256Coder().decode(data, o);
34262
- const salt = decoded;
34415
+ [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
34416
+ data,
34417
+ o
34418
+ );
34419
+ const storageSlots = decoded;
34263
34420
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34264
34421
  const policies = decoded;
34265
- [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
34266
- const storageSlots = decoded;
34267
34422
  [decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
34268
34423
  const inputs = decoded;
34269
34424
  [decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
@@ -34273,7 +34428,6 @@ This unreleased fuel-core build may include features and updates not yet support
34273
34428
  return [
34274
34429
  {
34275
34430
  type: 1,
34276
- bytecodeLength,
34277
34431
  bytecodeWitnessIndex,
34278
34432
  policyTypes,
34279
34433
  storageSlotsCount,
@@ -34302,6 +34456,7 @@ This unreleased fuel-core build may include features and updates not yet support
34302
34456
  parts.push(new OutputContractCoder().encode(value.outputContract));
34303
34457
  parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
34304
34458
  parts.push(new B256Coder().encode(value.mintAssetId));
34459
+ parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
34305
34460
  return concat(parts);
34306
34461
  }
34307
34462
  decode(data, offset) {
@@ -34317,6 +34472,8 @@ This unreleased fuel-core build may include features and updates not yet support
34317
34472
  const mintAmount = decoded;
34318
34473
  [decoded, o] = new B256Coder().decode(data, o);
34319
34474
  const mintAssetId = decoded;
34475
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34476
+ const gasPrice = decoded;
34320
34477
  return [
34321
34478
  {
34322
34479
  type: 2,
@@ -34324,7 +34481,8 @@ This unreleased fuel-core build may include features and updates not yet support
34324
34481
  inputContract,
34325
34482
  outputContract,
34326
34483
  mintAmount,
34327
- mintAssetId
34484
+ mintAssetId,
34485
+ gasPrice
34328
34486
  },
34329
34487
  o
34330
34488
  ];
@@ -34631,159 +34789,6 @@ This unreleased fuel-core build may include features and updates not yet support
34631
34789
  // src/providers/provider.ts
34632
34790
  var import_graphql_request = __toESM(require_dist2());
34633
34791
 
34634
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
34635
- function _isPlaceholder(a) {
34636
- return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
34637
- }
34638
-
34639
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
34640
- function _curry1(fn) {
34641
- return function f1(a) {
34642
- if (arguments.length === 0 || _isPlaceholder(a)) {
34643
- return f1;
34644
- } else {
34645
- return fn.apply(this, arguments);
34646
- }
34647
- };
34648
- }
34649
-
34650
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
34651
- var isArray_default = Array.isArray || function _isArray(val) {
34652
- return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
34653
- };
34654
-
34655
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
34656
- var type = /* @__PURE__ */ _curry1(function type2(val) {
34657
- return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
34658
- });
34659
- var type_default = type;
34660
-
34661
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
34662
- var pad = function pad2(n) {
34663
- return (n < 10 ? "0" : "") + n;
34664
- };
34665
- var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
34666
- return d.toISOString();
34667
- } : function _toISOString3(d) {
34668
- 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";
34669
- };
34670
-
34671
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
34672
- var isInteger_default = Number.isInteger || function _isInteger(n) {
34673
- return n << 0 === n;
34674
- };
34675
-
34676
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
34677
- function _cloneRegExp(pattern) {
34678
- 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" : ""));
34679
- }
34680
-
34681
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
34682
- function _clone(value, deep, map) {
34683
- map || (map = new _ObjectMap());
34684
- if (_isPrimitive(value)) {
34685
- return value;
34686
- }
34687
- var copy = function copy2(copiedValue) {
34688
- var cachedCopy = map.get(value);
34689
- if (cachedCopy) {
34690
- return cachedCopy;
34691
- }
34692
- map.set(value, copiedValue);
34693
- for (var key in value) {
34694
- if (Object.prototype.hasOwnProperty.call(value, key)) {
34695
- copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
34696
- }
34697
- }
34698
- return copiedValue;
34699
- };
34700
- switch (type_default(value)) {
34701
- case "Object":
34702
- return copy(Object.create(Object.getPrototypeOf(value)));
34703
- case "Array":
34704
- return copy([]);
34705
- case "Date":
34706
- return new Date(value.valueOf());
34707
- case "RegExp":
34708
- return _cloneRegExp(value);
34709
- case "Int8Array":
34710
- case "Uint8Array":
34711
- case "Uint8ClampedArray":
34712
- case "Int16Array":
34713
- case "Uint16Array":
34714
- case "Int32Array":
34715
- case "Uint32Array":
34716
- case "Float32Array":
34717
- case "Float64Array":
34718
- case "BigInt64Array":
34719
- case "BigUint64Array":
34720
- return value.slice();
34721
- default:
34722
- return value;
34723
- }
34724
- }
34725
- function _isPrimitive(param) {
34726
- var type3 = typeof param;
34727
- return param == null || type3 != "object" && type3 != "function";
34728
- }
34729
- var _ObjectMap = /* @__PURE__ */ function() {
34730
- function _ObjectMap2() {
34731
- this.map = {};
34732
- this.length = 0;
34733
- }
34734
- _ObjectMap2.prototype.set = function(key, value) {
34735
- const hashedKey = this.hash(key);
34736
- let bucket = this.map[hashedKey];
34737
- if (!bucket) {
34738
- this.map[hashedKey] = bucket = [];
34739
- }
34740
- bucket.push([key, value]);
34741
- this.length += 1;
34742
- };
34743
- _ObjectMap2.prototype.hash = function(key) {
34744
- let hashedKey = [];
34745
- for (var value in key) {
34746
- hashedKey.push(Object.prototype.toString.call(key[value]));
34747
- }
34748
- return hashedKey.join();
34749
- };
34750
- _ObjectMap2.prototype.get = function(key) {
34751
- if (this.length <= 180) {
34752
- for (const p in this.map) {
34753
- const bucket2 = this.map[p];
34754
- for (let i = 0; i < bucket2.length; i += 1) {
34755
- const element = bucket2[i];
34756
- if (element[0] === key) {
34757
- return element[1];
34758
- }
34759
- }
34760
- }
34761
- return;
34762
- }
34763
- const hashedKey = this.hash(key);
34764
- const bucket = this.map[hashedKey];
34765
- if (!bucket) {
34766
- return;
34767
- }
34768
- for (let i = 0; i < bucket.length; i += 1) {
34769
- const element = bucket[i];
34770
- if (element[0] === key) {
34771
- return element[1];
34772
- }
34773
- }
34774
- };
34775
- return _ObjectMap2;
34776
- }();
34777
-
34778
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
34779
- var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
34780
- return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
34781
- });
34782
- var clone_default = clone2;
34783
-
34784
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
34785
- var hasProtoTrim = typeof String.prototype.trim === "function";
34786
-
34787
34792
  // ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
34788
34793
  var __assign = function() {
34789
34794
  __assign = Object.assign || function __assign2(t) {
@@ -37949,16 +37954,40 @@ spurious results.`);
37949
37954
  var lib_default2 = gql;
37950
37955
 
37951
37956
  // src/providers/__generated__/operations.ts
37957
+ var TransactionStatusSubscriptionFragmentFragmentDoc = lib_default2`
37958
+ fragment transactionStatusSubscriptionFragment on TransactionStatus {
37959
+ type: __typename
37960
+ ... on SubmittedStatus {
37961
+ time
37962
+ }
37963
+ ... on SuccessStatus {
37964
+ block {
37965
+ id
37966
+ }
37967
+ time
37968
+ programState {
37969
+ returnType
37970
+ data
37971
+ }
37972
+ }
37973
+ ... on FailureStatus {
37974
+ block {
37975
+ id
37976
+ }
37977
+ time
37978
+ reason
37979
+ }
37980
+ ... on SqueezedOutStatus {
37981
+ reason
37982
+ }
37983
+ }
37984
+ `;
37952
37985
  var ReceiptFragmentFragmentDoc = lib_default2`
37953
37986
  fragment receiptFragment on Receipt {
37954
- contract {
37955
- id
37956
- }
37987
+ id
37957
37988
  pc
37958
37989
  is
37959
- to {
37960
- id
37961
- }
37990
+ to
37962
37991
  toAddress
37963
37992
  amount
37964
37993
  assetId
@@ -37996,10 +38025,16 @@ spurious results.`);
37996
38025
  id
37997
38026
  }
37998
38027
  time
38028
+ receipts {
38029
+ ...receiptFragment
38030
+ }
37999
38031
  programState {
38000
38032
  returnType
38001
38033
  data
38002
38034
  }
38035
+ receipts {
38036
+ ...receiptFragment
38037
+ }
38003
38038
  }
38004
38039
  ... on FailureStatus {
38005
38040
  block {
@@ -38007,26 +38042,24 @@ spurious results.`);
38007
38042
  }
38008
38043
  time
38009
38044
  reason
38045
+ receipts {
38046
+ ...receiptFragment
38047
+ }
38010
38048
  }
38011
38049
  ... on SqueezedOutStatus {
38012
38050
  reason
38013
38051
  }
38014
38052
  }
38015
- `;
38053
+ ${ReceiptFragmentFragmentDoc}`;
38016
38054
  var TransactionFragmentFragmentDoc = lib_default2`
38017
38055
  fragment transactionFragment on Transaction {
38018
38056
  id
38019
38057
  rawPayload
38020
- gasPrice
38021
- receipts {
38022
- ...receiptFragment
38023
- }
38024
38058
  status {
38025
38059
  ...transactionStatusFragment
38026
38060
  }
38027
38061
  }
38028
- ${ReceiptFragmentFragmentDoc}
38029
- ${TransactionStatusFragmentFragmentDoc}`;
38062
+ ${TransactionStatusFragmentFragmentDoc}`;
38030
38063
  var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
38031
38064
  fragment inputEstimatePredicatesFragment on Input {
38032
38065
  ... on InputCoin {
@@ -38044,6 +38077,46 @@ ${TransactionStatusFragmentFragmentDoc}`;
38044
38077
  }
38045
38078
  }
38046
38079
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
38080
+ var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
38081
+ fragment dryRunFailureStatusFragment on DryRunFailureStatus {
38082
+ reason
38083
+ programState {
38084
+ returnType
38085
+ data
38086
+ }
38087
+ }
38088
+ `;
38089
+ var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
38090
+ fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
38091
+ programState {
38092
+ returnType
38093
+ data
38094
+ }
38095
+ }
38096
+ `;
38097
+ var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
38098
+ fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
38099
+ ... on DryRunFailureStatus {
38100
+ ...dryRunFailureStatusFragment
38101
+ }
38102
+ ... on DryRunSuccessStatus {
38103
+ ...dryRunSuccessStatusFragment
38104
+ }
38105
+ }
38106
+ ${DryRunFailureStatusFragmentFragmentDoc}
38107
+ ${DryRunSuccessStatusFragmentFragmentDoc}`;
38108
+ var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
38109
+ fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
38110
+ id
38111
+ status {
38112
+ ...dryRunTransactionStatusFragment
38113
+ }
38114
+ receipts {
38115
+ ...receiptFragment
38116
+ }
38117
+ }
38118
+ ${DryRunTransactionStatusFragmentFragmentDoc}
38119
+ ${ReceiptFragmentFragmentDoc}`;
38047
38120
  var CoinFragmentFragmentDoc = lib_default2`
38048
38121
  fragment coinFragment on Coin {
38049
38122
  __typename
@@ -38051,7 +38124,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38051
38124
  owner
38052
38125
  amount
38053
38126
  assetId
38054
- maturity
38055
38127
  blockCreated
38056
38128
  txCreatedIdx
38057
38129
  }
@@ -38090,26 +38162,32 @@ ${TransactionStatusFragmentFragmentDoc}`;
38090
38162
  messageBlockHeader {
38091
38163
  id
38092
38164
  daHeight
38165
+ consensusParametersVersion
38166
+ stateTransitionBytecodeVersion
38093
38167
  transactionsCount
38168
+ messageReceiptCount
38094
38169
  transactionsRoot
38170
+ messageOutboxRoot
38171
+ eventInboxRoot
38095
38172
  height
38096
38173
  prevRoot
38097
38174
  time
38098
38175
  applicationHash
38099
- messageReceiptRoot
38100
- messageReceiptCount
38101
38176
  }
38102
38177
  commitBlockHeader {
38103
38178
  id
38104
38179
  daHeight
38180
+ consensusParametersVersion
38181
+ stateTransitionBytecodeVersion
38105
38182
  transactionsCount
38183
+ messageReceiptCount
38106
38184
  transactionsRoot
38185
+ messageOutboxRoot
38186
+ eventInboxRoot
38107
38187
  height
38108
38188
  prevRoot
38109
38189
  time
38110
38190
  applicationHash
38111
- messageReceiptRoot
38112
- messageReceiptCount
38113
38191
  }
38114
38192
  sender
38115
38193
  recipient
@@ -38128,8 +38206,8 @@ ${TransactionStatusFragmentFragmentDoc}`;
38128
38206
  var BlockFragmentFragmentDoc = lib_default2`
38129
38207
  fragment blockFragment on Block {
38130
38208
  id
38209
+ height
38131
38210
  header {
38132
- height
38133
38211
  time
38134
38212
  }
38135
38213
  transactions {
@@ -38187,6 +38265,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
38187
38265
  `;
38188
38266
  var GasCostsFragmentFragmentDoc = lib_default2`
38189
38267
  fragment GasCostsFragment on GasCosts {
38268
+ version {
38269
+ ... on Version {
38270
+ value
38271
+ }
38272
+ }
38190
38273
  add
38191
38274
  addi
38192
38275
  aloc
@@ -38199,7 +38282,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38199
38282
  cb
38200
38283
  cfei
38201
38284
  cfsi
38202
- croo
38203
38285
  div
38204
38286
  divi
38205
38287
  ecr1
@@ -38282,6 +38364,9 @@ ${TransactionStatusFragmentFragmentDoc}`;
38282
38364
  ccp {
38283
38365
  ...DependentCostFragment
38284
38366
  }
38367
+ croo {
38368
+ ...DependentCostFragment
38369
+ }
38285
38370
  csiz {
38286
38371
  ...DependentCostFragment
38287
38372
  }
@@ -38341,6 +38426,11 @@ ${TransactionStatusFragmentFragmentDoc}`;
38341
38426
  ${DependentCostFragmentFragmentDoc}`;
38342
38427
  var ConsensusParametersFragmentFragmentDoc = lib_default2`
38343
38428
  fragment consensusParametersFragment on ConsensusParameters {
38429
+ version {
38430
+ ... on Version {
38431
+ value
38432
+ }
38433
+ }
38344
38434
  txParams {
38345
38435
  ...TxParametersFragment
38346
38436
  }
@@ -38400,18 +38490,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38400
38490
  fragment nodeInfoFragment on NodeInfo {
38401
38491
  utxoValidation
38402
38492
  vmBacktrace
38403
- minGasPrice
38404
38493
  maxTx
38405
38494
  maxDepth
38406
38495
  nodeVersion
38407
- peers {
38408
- id
38409
- addresses
38410
- clientVersion
38411
- blockHeight
38412
- lastHeartbeatMs
38413
- appScore
38414
- }
38415
38496
  }
38416
38497
  `;
38417
38498
  var GetVersionDocument = lib_default2`
@@ -38446,13 +38527,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38446
38527
  query getTransactionWithReceipts($transactionId: TransactionId!) {
38447
38528
  transaction(id: $transactionId) {
38448
38529
  ...transactionFragment
38449
- receipts {
38450
- ...receiptFragment
38451
- }
38452
38530
  }
38453
38531
  }
38454
- ${TransactionFragmentFragmentDoc}
38455
- ${ReceiptFragmentFragmentDoc}`;
38532
+ ${TransactionFragmentFragmentDoc}`;
38456
38533
  var GetTransactionsDocument = lib_default2`
38457
38534
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
38458
38535
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -38580,6 +38657,20 @@ ${MessageCoinFragmentFragmentDoc}`;
38580
38657
  }
38581
38658
  }
38582
38659
  ${BalanceFragmentFragmentDoc}`;
38660
+ var GetLatestGasPriceDocument = lib_default2`
38661
+ query getLatestGasPrice {
38662
+ latestGasPrice {
38663
+ gasPrice
38664
+ }
38665
+ }
38666
+ `;
38667
+ var EstimateGasPriceDocument = lib_default2`
38668
+ query estimateGasPrice($blockHorizon: U32!) {
38669
+ estimateGasPrice(blockHorizon: $blockHorizon) {
38670
+ gasPrice
38671
+ }
38672
+ }
38673
+ `;
38583
38674
  var GetBalancesDocument = lib_default2`
38584
38675
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
38585
38676
  balances(
@@ -38634,12 +38725,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38634
38725
  }
38635
38726
  `;
38636
38727
  var DryRunDocument = lib_default2`
38637
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
38638
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
38639
- ...receiptFragment
38728
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
38729
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
38730
+ ...dryRunTransactionExecutionStatusFragment
38640
38731
  }
38641
38732
  }
38642
- ${ReceiptFragmentFragmentDoc}`;
38733
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
38643
38734
  var SubmitDocument = lib_default2`
38644
38735
  mutation submit($encodedTransaction: HexString!) {
38645
38736
  submit(tx: $encodedTransaction) {
@@ -38658,17 +38749,17 @@ ${MessageCoinFragmentFragmentDoc}`;
38658
38749
  var SubmitAndAwaitDocument = lib_default2`
38659
38750
  subscription submitAndAwait($encodedTransaction: HexString!) {
38660
38751
  submitAndAwait(tx: $encodedTransaction) {
38661
- ...transactionStatusFragment
38752
+ ...transactionStatusSubscriptionFragment
38662
38753
  }
38663
38754
  }
38664
- ${TransactionStatusFragmentFragmentDoc}`;
38755
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
38665
38756
  var StatusChangeDocument = lib_default2`
38666
38757
  subscription statusChange($transactionId: TransactionId!) {
38667
38758
  statusChange(id: $transactionId) {
38668
- ...transactionStatusFragment
38759
+ ...transactionStatusSubscriptionFragment
38669
38760
  }
38670
38761
  }
38671
- ${TransactionStatusFragmentFragmentDoc}`;
38762
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
38672
38763
  function getSdk(requester) {
38673
38764
  return {
38674
38765
  getVersion(variables, options) {
@@ -38722,6 +38813,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38722
38813
  getBalance(variables, options) {
38723
38814
  return requester(GetBalanceDocument, variables, options);
38724
38815
  },
38816
+ getLatestGasPrice(variables, options) {
38817
+ return requester(GetLatestGasPriceDocument, variables, options);
38818
+ },
38819
+ estimateGasPrice(variables, options) {
38820
+ return requester(EstimateGasPriceDocument, variables, options);
38821
+ },
38725
38822
  getBalances(variables, options) {
38726
38823
  return requester(GetBalancesDocument, variables, options);
38727
38824
  },
@@ -38886,9 +38983,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38886
38983
  }
38887
38984
  };
38888
38985
 
38889
- // ../address/dist/configs.mjs
38890
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
38891
-
38892
38986
  // src/providers/transaction-request/input.ts
38893
38987
  var inputify = (value) => {
38894
38988
  const { type: type3 } = value;
@@ -38908,10 +39002,9 @@ ${MessageCoinFragmentFragmentDoc}`;
38908
39002
  txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
38909
39003
  },
38910
39004
  witnessIndex: value.witnessIndex,
38911
- maturity: value.maturity ?? 0,
38912
39005
  predicateGasUsed: bn(value.predicateGasUsed),
38913
- predicateLength: predicate.length,
38914
- predicateDataLength: predicateData.length,
39006
+ predicateLength: bn(predicate.length),
39007
+ predicateDataLength: bn(predicateData.length),
38915
39008
  predicate: hexlify(predicate),
38916
39009
  predicateData: hexlify(predicateData)
38917
39010
  };
@@ -38942,8 +39035,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38942
39035
  nonce: hexlify(value.nonce),
38943
39036
  witnessIndex: value.witnessIndex,
38944
39037
  predicateGasUsed: bn(value.predicateGasUsed),
38945
- predicateLength: predicate.length,
38946
- predicateDataLength: predicateData.length,
39038
+ predicateLength: bn(predicate.length),
39039
+ predicateDataLength: bn(predicateData.length),
38947
39040
  predicate: hexlify(predicate),
38948
39041
  predicateData: hexlify(predicateData),
38949
39042
  data: hexlify(data),
@@ -39103,8 +39196,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39103
39196
  case "CALL" /* Call */: {
39104
39197
  const callReceipt = {
39105
39198
  type: ReceiptType.Call,
39106
- from: hexOrZero(receipt.contract?.id),
39107
- to: hexOrZero(receipt?.to?.id),
39199
+ from: hexOrZero(receipt.id || receipt.contractId),
39200
+ to: hexOrZero(receipt?.to),
39108
39201
  amount: bn(receipt.amount),
39109
39202
  assetId: hexOrZero(receipt.assetId),
39110
39203
  gas: bn(receipt.gas),
@@ -39118,7 +39211,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39118
39211
  case "RETURN" /* Return */: {
39119
39212
  const returnReceipt = {
39120
39213
  type: ReceiptType.Return,
39121
- id: hexOrZero(receipt.contract?.id),
39214
+ id: hexOrZero(receipt.id || receipt.contractId),
39122
39215
  val: bn(receipt.val),
39123
39216
  pc: bn(receipt.pc),
39124
39217
  is: bn(receipt.is)
@@ -39128,7 +39221,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39128
39221
  case "RETURN_DATA" /* ReturnData */: {
39129
39222
  const returnDataReceipt = {
39130
39223
  type: ReceiptType.ReturnData,
39131
- id: hexOrZero(receipt.contract?.id),
39224
+ id: hexOrZero(receipt.id || receipt.contractId),
39132
39225
  ptr: bn(receipt.ptr),
39133
39226
  len: bn(receipt.len),
39134
39227
  digest: hexOrZero(receipt.digest),
@@ -39140,7 +39233,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39140
39233
  case "PANIC" /* Panic */: {
39141
39234
  const panicReceipt = {
39142
39235
  type: ReceiptType.Panic,
39143
- id: hexOrZero(receipt.contract?.id),
39236
+ id: hexOrZero(receipt.id),
39144
39237
  reason: bn(receipt.reason),
39145
39238
  pc: bn(receipt.pc),
39146
39239
  is: bn(receipt.is),
@@ -39151,7 +39244,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39151
39244
  case "REVERT" /* Revert */: {
39152
39245
  const revertReceipt = {
39153
39246
  type: ReceiptType.Revert,
39154
- id: hexOrZero(receipt.contract?.id),
39247
+ id: hexOrZero(receipt.id || receipt.contractId),
39155
39248
  val: bn(receipt.ra),
39156
39249
  pc: bn(receipt.pc),
39157
39250
  is: bn(receipt.is)
@@ -39161,7 +39254,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39161
39254
  case "LOG" /* Log */: {
39162
39255
  const logReceipt = {
39163
39256
  type: ReceiptType.Log,
39164
- id: hexOrZero(receipt.contract?.id),
39257
+ id: hexOrZero(receipt.id || receipt.contractId),
39165
39258
  val0: bn(receipt.ra),
39166
39259
  val1: bn(receipt.rb),
39167
39260
  val2: bn(receipt.rc),
@@ -39174,7 +39267,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39174
39267
  case "LOG_DATA" /* LogData */: {
39175
39268
  const logDataReceipt = {
39176
39269
  type: ReceiptType.LogData,
39177
- id: hexOrZero(receipt.contract?.id),
39270
+ id: hexOrZero(receipt.id || receipt.contractId),
39178
39271
  val0: bn(receipt.ra),
39179
39272
  val1: bn(receipt.rb),
39180
39273
  ptr: bn(receipt.ptr),
@@ -39188,8 +39281,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39188
39281
  case "TRANSFER" /* Transfer */: {
39189
39282
  const transferReceipt = {
39190
39283
  type: ReceiptType.Transfer,
39191
- from: hexOrZero(receipt.contract?.id),
39192
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
39284
+ from: hexOrZero(receipt.id || receipt.contractId),
39285
+ to: hexOrZero(receipt.toAddress || receipt?.to),
39193
39286
  amount: bn(receipt.amount),
39194
39287
  assetId: hexOrZero(receipt.assetId),
39195
39288
  pc: bn(receipt.pc),
@@ -39200,8 +39293,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39200
39293
  case "TRANSFER_OUT" /* TransferOut */: {
39201
39294
  const transferOutReceipt = {
39202
39295
  type: ReceiptType.TransferOut,
39203
- from: hexOrZero(receipt.contract?.id),
39204
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
39296
+ from: hexOrZero(receipt.id || receipt.contractId),
39297
+ to: hexOrZero(receipt.toAddress || receipt.to),
39205
39298
  amount: bn(receipt.amount),
39206
39299
  assetId: hexOrZero(receipt.assetId),
39207
39300
  pc: bn(receipt.pc),
@@ -39244,7 +39337,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39244
39337
  return receiptMessageOut;
39245
39338
  }
39246
39339
  case "MINT" /* Mint */: {
39247
- const contractId = hexOrZero(receipt.contract?.id);
39340
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
39248
39341
  const subId = hexOrZero(receipt.subId);
39249
39342
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
39250
39343
  const mintReceipt = {
@@ -39259,7 +39352,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39259
39352
  return mintReceipt;
39260
39353
  }
39261
39354
  case "BURN" /* Burn */: {
39262
- const contractId = hexOrZero(receipt.contract?.id);
39355
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
39263
39356
  const subId = hexOrZero(receipt.subId);
39264
39357
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
39265
39358
  const burnReceipt = {
@@ -39340,7 +39433,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39340
39433
  };
39341
39434
 
39342
39435
  // src/providers/utils/gas.ts
39343
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
39344
39436
  var getGasUsedFromReceipts = (receipts) => {
39345
39437
  const scriptResult = receipts.filter(
39346
39438
  (receipt) => receipt.type === ReceiptType.ScriptResult
@@ -39361,18 +39453,28 @@ ${MessageCoinFragmentFragmentDoc}`;
39361
39453
  }
39362
39454
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
39363
39455
  const witnessCache = [];
39364
- const totalGas = inputs.reduce((total, input) => {
39456
+ const chargeableInputs = inputs.filter((input) => {
39457
+ const isCoinOrMessage = "owner" in input || "sender" in input;
39458
+ if (isCoinOrMessage) {
39459
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39460
+ return true;
39461
+ }
39462
+ if (!witnessCache.includes(input.witnessIndex)) {
39463
+ witnessCache.push(input.witnessIndex);
39464
+ return true;
39465
+ }
39466
+ }
39467
+ return false;
39468
+ });
39469
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
39470
+ const totalGas = chargeableInputs.reduce((total, input) => {
39365
39471
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39366
39472
  return total.add(
39367
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39473
+ vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39368
39474
  );
39369
39475
  }
39370
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
39371
- witnessCache.push(input.witnessIndex);
39372
- return total.add(gasCosts.ecr1);
39373
- }
39374
- return total;
39375
- }, bn());
39476
+ return total.add(gasCosts.ecr1);
39477
+ }, bn(0));
39376
39478
  return totalGas;
39377
39479
  }
39378
39480
  function getMinGas(params) {
@@ -39384,12 +39486,20 @@ ${MessageCoinFragmentFragmentDoc}`;
39384
39486
  return minGas;
39385
39487
  }
39386
39488
  function getMaxGas(params) {
39387
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
39489
+ const {
39490
+ gasPerByte,
39491
+ witnessesLength,
39492
+ witnessLimit,
39493
+ minGas,
39494
+ gasLimit = bn(0),
39495
+ maxGasPerTx
39496
+ } = params;
39388
39497
  let remainingAllowedWitnessGas = bn(0);
39389
39498
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
39390
39499
  remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
39391
39500
  }
39392
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39501
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39502
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
39393
39503
  }
39394
39504
  function calculateMetadataGasForTxCreate({
39395
39505
  gasCosts,
@@ -39411,6 +39521,10 @@ ${MessageCoinFragmentFragmentDoc}`;
39411
39521
  }) {
39412
39522
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
39413
39523
  }
39524
+ var calculateGasFee = (params) => {
39525
+ const { gas, gasPrice, priceFactor, tip } = params;
39526
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
39527
+ };
39414
39528
 
39415
39529
  // src/providers/utils/json.ts
39416
39530
  function normalize2(object) {
@@ -39552,7 +39666,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39552
39666
  // src/providers/transaction-request/transaction-request.ts
39553
39667
  var BaseTransactionRequest = class {
39554
39668
  /** Gas price for transaction */
39555
- gasPrice;
39669
+ tip;
39556
39670
  /** Block until which tx cannot be included */
39557
39671
  maturity;
39558
39672
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -39565,38 +39679,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39565
39679
  outputs = [];
39566
39680
  /** List of witnesses */
39567
39681
  witnesses = [];
39568
- /** Base asset ID - should be fetched from the chain */
39569
- baseAssetId;
39570
39682
  /**
39571
39683
  * Constructor for initializing a base transaction request.
39572
39684
  *
39573
39685
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
39574
39686
  */
39575
39687
  constructor({
39576
- gasPrice,
39688
+ tip,
39577
39689
  maturity,
39578
39690
  maxFee,
39579
39691
  witnessLimit,
39580
39692
  inputs,
39581
39693
  outputs,
39582
- witnesses,
39583
- baseAssetId
39584
- }) {
39585
- this.gasPrice = bn(gasPrice);
39694
+ witnesses
39695
+ } = {}) {
39696
+ this.tip = bn(tip);
39586
39697
  this.maturity = maturity ?? 0;
39587
39698
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
39588
39699
  this.maxFee = maxFee ? bn(maxFee) : void 0;
39589
39700
  this.inputs = inputs ?? [];
39590
39701
  this.outputs = outputs ?? [];
39591
39702
  this.witnesses = witnesses ?? [];
39592
- this.baseAssetId = baseAssetId;
39593
39703
  }
39594
39704
  static getPolicyMeta(req) {
39595
39705
  let policyTypes = 0;
39596
39706
  const policies = [];
39597
- if (req.gasPrice) {
39598
- policyTypes += PolicyType.GasPrice;
39599
- policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
39707
+ if (req.tip) {
39708
+ policyTypes += PolicyType.Tip;
39709
+ policies.push({ data: req.tip, type: PolicyType.Tip });
39600
39710
  }
39601
39711
  if (req.witnessLimit) {
39602
39712
  policyTypes += PolicyType.WitnessLimit;
@@ -39780,13 +39890,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39780
39890
  * assetId, if one it was not added yet.
39781
39891
  *
39782
39892
  * @param coin - Coin resource.
39783
- * @param predicate - Predicate bytes.
39784
- * @param predicateData - Predicate data bytes.
39785
39893
  */
39786
- addCoinInput(coin, predicate) {
39894
+ addCoinInput(coin) {
39787
39895
  const { assetId, owner, amount } = coin;
39788
39896
  let witnessIndex;
39789
- if (predicate) {
39897
+ if (coin.predicate) {
39790
39898
  witnessIndex = 0;
39791
39899
  } else {
39792
39900
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -39801,8 +39909,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39801
39909
  amount,
39802
39910
  assetId,
39803
39911
  txPointer: "0x00000000000000000000000000000000",
39804
- witnessIndex,
39805
- predicate: predicate?.bytes
39912
+ witnessIndex
39806
39913
  };
39807
39914
  this.pushInput(input);
39808
39915
  this.addChangeOutput(owner, assetId);
@@ -39812,12 +39919,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39812
39919
  * baseAssetId, if one it was not added yet.
39813
39920
  *
39814
39921
  * @param message - Message resource.
39815
- * @param predicate - Predicate bytes.
39816
39922
  */
39817
- addMessageInput(message, predicate) {
39923
+ addMessageInput(message) {
39818
39924
  const { recipient, sender, amount } = message;
39925
+ const assetId = BaseAssetId;
39819
39926
  let witnessIndex;
39820
- if (predicate) {
39927
+ if (message.predicate) {
39821
39928
  witnessIndex = 0;
39822
39929
  } else {
39823
39930
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -39831,11 +39938,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39831
39938
  sender: sender.toB256(),
39832
39939
  recipient: recipient.toB256(),
39833
39940
  amount,
39834
- witnessIndex,
39835
- predicate: predicate?.bytes
39941
+ witnessIndex
39836
39942
  };
39837
39943
  this.pushInput(input);
39838
- this.addChangeOutput(recipient, this.baseAssetId);
39944
+ this.addChangeOutput(recipient, assetId);
39839
39945
  }
39840
39946
  /**
39841
39947
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39863,32 +39969,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39863
39969
  resources.forEach((resource) => this.addResource(resource));
39864
39970
  return this;
39865
39971
  }
39866
- /**
39867
- * Adds multiple resources to the transaction by adding coin/message inputs and change
39868
- * outputs from the related assetIds.
39869
- *
39870
- * @param resources - The resources to add.
39871
- * @returns This transaction.
39872
- */
39873
- addPredicateResource(resource, predicate) {
39874
- if (isCoin(resource)) {
39875
- this.addCoinInput(resource, predicate);
39876
- } else {
39877
- this.addMessageInput(resource, predicate);
39878
- }
39879
- return this;
39880
- }
39881
- /**
39882
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
39883
- * from the related assetIds.
39884
- *
39885
- * @param resources - The resources to add.
39886
- * @returns This transaction.
39887
- */
39888
- addPredicateResources(resources, predicate) {
39889
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
39890
- return this;
39891
- }
39892
39972
  /**
39893
39973
  * Adds a coin output to the transaction.
39894
39974
  *
@@ -39896,12 +39976,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39896
39976
  * @param amount - Amount of coin.
39897
39977
  * @param assetId - Asset ID of coin.
39898
39978
  */
39899
- addCoinOutput(to, amount, assetId) {
39979
+ addCoinOutput(to, amount, assetId = BaseAssetId) {
39900
39980
  this.pushOutput({
39901
39981
  type: OutputType.Coin,
39902
39982
  to: addressify(to).toB256(),
39903
39983
  amount,
39904
- assetId: assetId ?? this.baseAssetId
39984
+ assetId
39905
39985
  });
39906
39986
  return this;
39907
39987
  }
@@ -39928,7 +40008,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39928
40008
  * @param to - Address of the owner.
39929
40009
  * @param assetId - Asset ID of coin.
39930
40010
  */
39931
- addChangeOutput(to, assetId) {
40011
+ addChangeOutput(to, assetId = BaseAssetId) {
39932
40012
  const changeOutput = this.getChangeOutputs().find(
39933
40013
  (output3) => hexlify(output3.assetId) === assetId
39934
40014
  );
@@ -39936,7 +40016,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39936
40016
  this.pushOutput({
39937
40017
  type: OutputType.Change,
39938
40018
  to: addressify(to).toB256(),
39939
- assetId: assetId ?? this.baseAssetId
40019
+ assetId
39940
40020
  });
39941
40021
  }
39942
40022
  }
@@ -39968,7 +40048,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39968
40048
  }
39969
40049
  calculateMaxGas(chainInfo, minGas) {
39970
40050
  const { consensusParameters } = chainInfo;
39971
- const { gasPerByte } = consensusParameters;
40051
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
39972
40052
  const witnessesLength = this.toTransaction().witnesses.reduce(
39973
40053
  (acc, wit) => acc + wit.dataLength,
39974
40054
  0
@@ -39977,7 +40057,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39977
40057
  gasPerByte,
39978
40058
  minGas,
39979
40059
  witnessesLength,
39980
- witnessLimit: this.witnessLimit
40060
+ witnessLimit: this.witnessLimit,
40061
+ maxGasPerTx
39981
40062
  });
39982
40063
  }
39983
40064
  /**
@@ -39995,24 +40076,27 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39995
40076
  });
39996
40077
  const updateAssetInput = (assetId, quantity) => {
39997
40078
  const assetInput = findAssetInput(assetId);
40079
+ let usedQuantity = quantity;
40080
+ if (assetId === BaseAssetId) {
40081
+ usedQuantity = bn("1000000000000000000");
40082
+ }
39998
40083
  if (assetInput && "assetId" in assetInput) {
39999
40084
  assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
40000
- assetInput.amount = quantity;
40085
+ assetInput.amount = usedQuantity;
40001
40086
  } else {
40002
40087
  this.addResources([
40003
40088
  {
40004
40089
  id: hexlify(randomBytes22(UTXO_ID_LEN)),
40005
- amount: quantity,
40090
+ amount: usedQuantity,
40006
40091
  assetId,
40007
40092
  owner: resourcesOwner || Address.fromRandom(),
40008
- maturity: 0,
40009
40093
  blockCreated: bn(1),
40010
40094
  txCreatedIdx: bn(1)
40011
40095
  }
40012
40096
  ]);
40013
40097
  }
40014
40098
  };
40015
- updateAssetInput(this.baseAssetId, bn(1e11));
40099
+ updateAssetInput(BaseAssetId, bn(1e11));
40016
40100
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
40017
40101
  }
40018
40102
  /**
@@ -40037,7 +40121,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40037
40121
  toJSON() {
40038
40122
  return normalizeJSON(this);
40039
40123
  }
40040
- updatePredicateInputs(inputs) {
40124
+ updatePredicateGasUsed(inputs) {
40041
40125
  this.inputs.forEach((i) => {
40042
40126
  let correspondingInput;
40043
40127
  switch (i.type) {
@@ -40059,6 +40143,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40059
40143
  }
40060
40144
  });
40061
40145
  }
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
+ );
40152
+ }
40153
+ });
40154
+ }
40062
40155
  };
40063
40156
 
40064
40157
  // src/providers/transaction-request/hash-transaction.ts
@@ -40169,7 +40262,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40169
40262
  *
40170
40263
  * @param createTransactionRequestLike - The initial values for the instance
40171
40264
  */
40172
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
40265
+ constructor({
40266
+ bytecodeWitnessIndex,
40267
+ salt,
40268
+ storageSlots,
40269
+ ...rest
40270
+ } = {}) {
40173
40271
  super(rest);
40174
40272
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
40175
40273
  this.salt = hexlify(salt ?? ZeroBytes32);
@@ -40187,9 +40285,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40187
40285
  return {
40188
40286
  type: TransactionType.Create,
40189
40287
  ...baseTransaction,
40190
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
40191
40288
  bytecodeWitnessIndex,
40192
- storageSlotsCount: storageSlots.length,
40289
+ storageSlotsCount: bn(storageSlots.length),
40193
40290
  salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
40194
40291
  storageSlots
40195
40292
  };
@@ -40284,7 +40381,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40284
40381
  *
40285
40382
  * @param scriptTransactionRequestLike - The initial values for the instance.
40286
40383
  */
40287
- constructor({ script, scriptData, gasLimit, ...rest }) {
40384
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
40288
40385
  super(rest);
40289
40386
  this.gasLimit = bn(gasLimit);
40290
40387
  this.script = arrayify(script ?? returnZeroScript.bytes);
@@ -40303,8 +40400,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40303
40400
  type: TransactionType.Script,
40304
40401
  scriptGasLimit: this.gasLimit,
40305
40402
  ...super.getBaseTransaction(),
40306
- scriptLength: script.length,
40307
- scriptDataLength: scriptData.length,
40403
+ scriptLength: bn(script.length),
40404
+ scriptDataLength: bn(scriptData.length),
40308
40405
  receiptsRoot: ZeroBytes32,
40309
40406
  script: hexlify(script),
40310
40407
  scriptData: hexlify(scriptData)
@@ -40368,7 +40465,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40368
40465
  }
40369
40466
  calculateMaxGas(chainInfo, minGas) {
40370
40467
  const { consensusParameters } = chainInfo;
40371
- const { gasPerByte } = consensusParameters;
40468
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
40372
40469
  const witnessesLength = this.toTransaction().witnesses.reduce(
40373
40470
  (acc, wit) => acc + wit.dataLength,
40374
40471
  0
@@ -40378,7 +40475,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40378
40475
  minGas,
40379
40476
  witnessesLength,
40380
40477
  witnessLimit: this.witnessLimit,
40381
- gasLimit: this.gasLimit
40478
+ gasLimit: this.gasLimit,
40479
+ maxGasPerTx
40382
40480
  });
40383
40481
  }
40384
40482
  /**
@@ -40451,13 +40549,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40451
40549
  }
40452
40550
  }
40453
40551
  };
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
+ );
40454
40567
 
40455
40568
  // src/providers/transaction-summary/calculate-transaction-fee.ts
40456
40569
  var calculateTransactionFee = (params) => {
40457
40570
  const {
40458
- gasUsed,
40571
+ gasPrice,
40459
40572
  rawPayload,
40460
- consensusParameters: { gasCosts, feeParams }
40573
+ tip,
40574
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
40461
40575
  } = params;
40462
40576
  const gasPerByte = bn(feeParams.gasPerByte);
40463
40577
  const gasPriceFactor = bn(feeParams.gasPriceFactor);
@@ -40467,8 +40581,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40467
40581
  return {
40468
40582
  fee: bn(0),
40469
40583
  minFee: bn(0),
40470
- maxFee: bn(0),
40471
- feeFromGasUsed: bn(0)
40584
+ maxFee: bn(0)
40472
40585
  };
40473
40586
  }
40474
40587
  const { type: type3, witnesses, inputs, policies } = transaction;
@@ -40500,7 +40613,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40500
40613
  metadataGas,
40501
40614
  txBytesSize: transactionBytes.length
40502
40615
  });
40503
- const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
40504
40616
  const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
40505
40617
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
40506
40618
  const maxGas = getMaxGas({
@@ -40508,17 +40620,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40508
40620
  minGas,
40509
40621
  witnessesLength,
40510
40622
  gasLimit,
40511
- witnessLimit
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
40512
40637
  });
40513
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
40514
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
40515
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
40516
- const fee = minFee.add(feeFromGasUsed);
40517
40638
  return {
40518
- fee,
40519
40639
  minFee,
40520
40640
  maxFee,
40521
- feeFromGasUsed
40641
+ fee: maxFee
40522
40642
  };
40523
40643
  };
40524
40644
 
@@ -41119,7 +41239,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41119
41239
  gqlTransactionStatus,
41120
41240
  abiMap = {},
41121
41241
  maxInputs,
41122
- gasCosts
41242
+ gasCosts,
41243
+ maxGasPerTx,
41244
+ gasPrice
41123
41245
  } = params;
41124
41246
  const gasUsed = getGasUsedFromReceipts(receipts);
41125
41247
  const rawPayload = hexlify(transactionBytes);
@@ -41133,11 +41255,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41133
41255
  maxInputs
41134
41256
  });
41135
41257
  const typeName = getTransactionTypeName(transaction.type);
41258
+ const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
41136
41259
  const { fee } = calculateTransactionFee({
41137
- gasUsed,
41260
+ gasPrice,
41138
41261
  rawPayload,
41262
+ tip,
41139
41263
  consensusParameters: {
41140
41264
  gasCosts,
41265
+ maxGasPerTx,
41141
41266
  feeParams: {
41142
41267
  gasPerByte,
41143
41268
  gasPriceFactor
@@ -41273,8 +41398,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41273
41398
  const decodedTransaction = this.decodeTransaction(
41274
41399
  transaction
41275
41400
  );
41276
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
41277
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
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();
41278
41408
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
41279
41409
  const transactionSummary = assembleTransactionSummary({
41280
41410
  id: this.id,
@@ -41286,7 +41416,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41286
41416
  gasPriceFactor,
41287
41417
  abiMap: contractsAbiMap,
41288
41418
  maxInputs,
41289
- gasCosts
41419
+ gasCosts,
41420
+ maxGasPerTx,
41421
+ gasPrice
41290
41422
  });
41291
41423
  return transactionSummary;
41292
41424
  }
@@ -41430,13 +41562,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41430
41562
  gasPerByte: bn(feeParams.gasPerByte),
41431
41563
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41432
41564
  chainId: bn(consensusParameters.chainId),
41433
- baseAssetId: consensusParameters.baseAssetId,
41434
41565
  gasCosts
41435
41566
  },
41436
41567
  gasCosts,
41437
41568
  latestBlock: {
41438
41569
  id: latestBlock.id,
41439
- height: bn(latestBlock.header.height),
41570
+ height: bn(latestBlock.height),
41440
41571
  time: latestBlock.header.time,
41441
41572
  transactions: latestBlock.transactions.map((i) => ({
41442
41573
  id: i.id
@@ -41530,10 +41661,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41530
41661
  * Returns some helpful parameters related to gas fees.
41531
41662
  */
41532
41663
  getGasConfig() {
41533
- const { minGasPrice } = this.getNode();
41534
41664
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
41535
41665
  return {
41536
- minGasPrice,
41537
41666
  maxGasPerTx,
41538
41667
  maxGasPerPredicate,
41539
41668
  gasPriceFactor,
@@ -41631,7 +41760,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41631
41760
  */
41632
41761
  async getBlockNumber() {
41633
41762
  const { chain } = await this.operations.getChain();
41634
- return bn(chain.latestBlock.header.height, 10);
41763
+ return bn(chain.latestBlock.height, 10);
41635
41764
  }
41636
41765
  /**
41637
41766
  * Returns the chain information.
@@ -41643,11 +41772,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41643
41772
  const processedNodeInfo = {
41644
41773
  maxDepth: bn(nodeInfo.maxDepth),
41645
41774
  maxTx: bn(nodeInfo.maxTx),
41646
- minGasPrice: bn(nodeInfo.minGasPrice),
41647
41775
  nodeVersion: nodeInfo.nodeVersion,
41648
41776
  utxoValidation: nodeInfo.utxoValidation,
41649
- vmBacktrace: nodeInfo.vmBacktrace,
41650
- peers: nodeInfo.peers
41777
+ vmBacktrace: nodeInfo.vmBacktrace
41651
41778
  };
41652
41779
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
41653
41780
  return processedNodeInfo;
@@ -41673,17 +41800,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41673
41800
  } = this.getChain();
41674
41801
  return chainId.toNumber();
41675
41802
  }
41676
- /**
41677
- * Returns the base asset ID
41678
- *
41679
- * @returns A promise that resolves to the base asset ID
41680
- */
41681
- getBaseAssetId() {
41682
- const {
41683
- consensusParameters: { baseAssetId }
41684
- } = this.getChain();
41685
- return baseAssetId;
41686
- }
41687
41803
  /**
41688
41804
  * Submits a transaction to the chain to be executed.
41689
41805
  *
@@ -41744,14 +41860,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41744
41860
  return this.estimateTxDependencies(transactionRequest);
41745
41861
  }
41746
41862
  const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41747
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41748
- encodedTransaction,
41863
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
41864
+ encodedTransactions: encodedTransaction,
41749
41865
  utxoValidation: utxoValidation || false
41750
41866
  });
41751
- const receipts = gqlReceipts.map(processGqlReceipt);
41752
- return {
41753
- receipts
41754
- };
41867
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
41868
+ const receipts = rawReceipts.map(processGqlReceipt);
41869
+ return { receipts, dryrunStatus: status };
41755
41870
  }
41756
41871
  /**
41757
41872
  * Verifies whether enough gas is available to complete transaction.
@@ -41790,9 +41905,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41790
41905
  * If there are missing variable outputs,
41791
41906
  * `addVariableOutputs` is called on the transaction.
41792
41907
  *
41793
- * @privateRemarks
41794
- * TODO: Investigate support for missing contract IDs
41795
- * TODO: Add support for missing output messages
41796
41908
  *
41797
41909
  * @param transactionRequest - The transaction request object.
41798
41910
  * @returns A promise.
@@ -41805,16 +41917,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41805
41917
  missingContractIds: []
41806
41918
  };
41807
41919
  }
41808
- await this.estimatePredicates(transactionRequest);
41809
41920
  let receipts = [];
41810
41921
  const missingContractIds = [];
41811
41922
  let outputVariables = 0;
41923
+ let dryrunStatus;
41812
41924
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
41813
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41814
- encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
41925
+ const {
41926
+ dryRun: [{ receipts: rawReceipts, status }]
41927
+ } = await this.operations.dryRun({
41928
+ encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
41815
41929
  utxoValidation: false
41816
41930
  });
41817
- receipts = gqlReceipts.map(processGqlReceipt);
41931
+ receipts = rawReceipts.map(processGqlReceipt);
41932
+ dryrunStatus = status;
41818
41933
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
41819
41934
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
41820
41935
  if (hasMissingOutputs) {
@@ -41824,6 +41939,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41824
41939
  transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
41825
41940
  missingContractIds.push(contractId);
41826
41941
  });
41942
+ const { maxFee } = await this.estimateTxGasAndFee({
41943
+ transactionRequest
41944
+ });
41945
+ transactionRequest.maxFee = maxFee;
41827
41946
  } else {
41828
41947
  break;
41829
41948
  }
@@ -41831,37 +41950,139 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41831
41950
  return {
41832
41951
  receipts,
41833
41952
  outputVariables,
41834
- missingContractIds
41953
+ missingContractIds,
41954
+ dryrunStatus
41835
41955
  };
41836
41956
  }
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
+ }
41837
42041
  /**
41838
42042
  * Estimates the transaction gas and fee based on the provided transaction request.
41839
42043
  * @param transactionRequest - The transaction request object.
41840
42044
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41841
42045
  */
41842
- estimateTxGasAndFee(params) {
42046
+ async estimateTxGasAndFee(params) {
41843
42047
  const { transactionRequest } = params;
41844
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
42048
+ let { gasPrice } = params;
41845
42049
  const chainInfo = this.getChain();
41846
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41847
- transactionRequest.gasPrice = gasPrice;
42050
+ const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
41848
42051
  const minGas = transactionRequest.calculateMinGas(chainInfo);
41849
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
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);
41850
42062
  if (transactionRequest.type === TransactionType.Script) {
42063
+ gasLimit = transactionRequest.gasLimit;
41851
42064
  if (transactionRequest.gasLimit.eq(0)) {
41852
42065
  transactionRequest.gasLimit = minGas;
41853
42066
  transactionRequest.gasLimit = maxGasPerTx.sub(
41854
42067
  transactionRequest.calculateMaxGas(chainInfo, minGas)
41855
42068
  );
42069
+ gasLimit = transactionRequest.gasLimit;
41856
42070
  }
41857
42071
  }
41858
42072
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41859
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42073
+ const maxFee = calculateGasFee({
42074
+ gasPrice: bn(gasPrice),
42075
+ gas: maxGas,
42076
+ priceFactor: gasPriceFactor,
42077
+ tip: transactionRequest.tip
42078
+ }).add(1);
41860
42079
  return {
41861
42080
  minGas,
41862
42081
  minFee,
41863
42082
  maxGas,
41864
- maxFee
42083
+ maxFee,
42084
+ gasPrice,
42085
+ gasLimit
41865
42086
  };
41866
42087
  }
41867
42088
  /**
@@ -41879,15 +42100,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41879
42100
  if (estimateTxDependencies) {
41880
42101
  return this.estimateTxDependencies(transactionRequest);
41881
42102
  }
41882
- const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41883
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41884
- encodedTransaction,
42103
+ const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
42104
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42105
+ encodedTransactions,
41885
42106
  utxoValidation: true
41886
42107
  });
41887
- const receipts = gqlReceipts.map(processGqlReceipt);
41888
- return {
41889
- receipts
41890
- };
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 };
41891
42114
  }
41892
42115
  /**
41893
42116
  * Returns a transaction cost to enable user
@@ -41904,77 +42127,79 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41904
42127
  * @param tolerance - The tolerance to add on top of the gasUsed.
41905
42128
  * @returns A promise that resolves to the transaction cost object.
41906
42129
  */
41907
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
41908
- estimateTxDependencies = true,
41909
- estimatePredicates = true,
41910
- resourcesOwner,
41911
- signatureCallback
41912
- } = {}) {
42130
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
41913
42131
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41914
- const { minGasPrice } = this.getGasConfig();
41915
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41916
42132
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41917
42133
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41918
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
42134
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
41919
42135
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
42136
+ txRequestClone.maxFee = bn(0);
41920
42137
  if (isScriptTransaction) {
41921
42138
  txRequestClone.gasLimit = bn(0);
41922
42139
  }
41923
- if (estimatePredicates) {
41924
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41925
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
41926
- }
41927
- await this.estimatePredicates(txRequestClone);
42140
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
42141
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
41928
42142
  }
42143
+ const signedRequest = clone_default(txRequestClone);
42144
+ let addedSignatures = 0;
41929
42145
  if (signatureCallback && isScriptTransaction) {
41930
- await signatureCallback(txRequestClone);
42146
+ const lengthBefore = signedRequest.witnesses.length;
42147
+ await signatureCallback(signedRequest);
42148
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
41931
42149
  }
41932
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41933
- transactionRequest: txRequestClone
42150
+ await this.estimatePredicates(signedRequest);
42151
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
42152
+ transactionRequest: signedRequest
41934
42153
  });
41935
42154
  let receipts = [];
41936
42155
  let missingContractIds = [];
41937
42156
  let outputVariables = 0;
41938
42157
  let gasUsed = bn(0);
41939
- if (isScriptTransaction && estimateTxDependencies) {
41940
- txRequestClone.gasPrice = 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
+ }
41941
42165
  const result = await this.estimateTxDependencies(txRequestClone);
41942
42166
  receipts = result.receipts;
41943
42167
  outputVariables = result.outputVariables;
41944
42168
  missingContractIds = result.missingContractIds;
41945
42169
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41946
42170
  txRequestClone.gasLimit = gasUsed;
41947
- txRequestClone.gasPrice = setGasPrice;
41948
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41949
- transactionRequest: txRequestClone
42171
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
42172
+ transactionRequest: txRequestClone,
42173
+ gasPrice
41950
42174
  }));
41951
42175
  }
41952
42176
  return {
41953
42177
  requiredQuantities: allQuantities,
41954
42178
  receipts,
41955
42179
  gasUsed,
41956
- minGasPrice,
41957
- gasPrice: setGasPrice,
42180
+ gasPrice,
41958
42181
  minGas,
41959
42182
  maxGas,
41960
42183
  minFee,
41961
42184
  maxFee,
41962
- estimatedInputs: txRequestClone.inputs,
41963
42185
  outputVariables,
41964
- missingContractIds
42186
+ missingContractIds,
42187
+ addedSignatures,
42188
+ estimatedPredicates: txRequestClone.inputs
41965
42189
  };
41966
42190
  }
41967
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
42191
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
41968
42192
  const ownerAddress = Address.fromAddressOrString(owner);
41969
42193
  const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
41970
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
42194
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
42195
+ quantitiesToContract
42196
+ });
41971
42197
  transactionRequest.addResources(
41972
42198
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
41973
42199
  );
41974
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
41975
- transactionRequest,
41976
- forwardingQuantities
41977
- );
42200
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
42201
+ quantitiesToContract
42202
+ });
41978
42203
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
41979
42204
  return {
41980
42205
  resources,
@@ -41998,7 +42223,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41998
42223
  assetId: coin.assetId,
41999
42224
  amount: bn(coin.amount),
42000
42225
  owner: Address.fromAddressOrString(coin.owner),
42001
- maturity: bn(coin.maturity).toNumber(),
42002
42226
  blockCreated: bn(coin.blockCreated),
42003
42227
  txCreatedIdx: bn(coin.txCreatedIdx)
42004
42228
  }));
@@ -42050,7 +42274,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42050
42274
  amount: bn(coin.amount),
42051
42275
  assetId: coin.assetId,
42052
42276
  owner: Address.fromAddressOrString(coin.owner),
42053
- maturity: bn(coin.maturity).toNumber(),
42054
42277
  blockCreated: bn(coin.blockCreated),
42055
42278
  txCreatedIdx: bn(coin.txCreatedIdx)
42056
42279
  };
@@ -42083,7 +42306,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42083
42306
  }
42084
42307
  return {
42085
42308
  id: block2.id,
42086
- height: bn(block2.header.height),
42309
+ height: bn(block2.height),
42087
42310
  time: block2.header.time,
42088
42311
  transactionIds: block2.transactions.map((tx) => tx.id)
42089
42312
  };
@@ -42098,7 +42321,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42098
42321
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
42099
42322
  const blocks = fetchedData.edges.map(({ node: block2 }) => ({
42100
42323
  id: block2.id,
42101
- height: bn(block2.header.height),
42324
+ height: bn(block2.height),
42102
42325
  time: block2.header.time,
42103
42326
  transactionIds: block2.transactions.map((tx) => tx.id)
42104
42327
  }));
@@ -42125,7 +42348,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42125
42348
  }
42126
42349
  return {
42127
42350
  id: block2.id,
42128
- height: bn(block2.header.height, 10),
42351
+ height: bn(block2.height, 10),
42129
42352
  time: block2.header.time,
42130
42353
  transactionIds: block2.transactions.map((tx) => tx.id),
42131
42354
  transactions: block2.transactions.map(
@@ -42305,8 +42528,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42305
42528
  prevRoot: messageBlockHeader.prevRoot,
42306
42529
  time: messageBlockHeader.time,
42307
42530
  applicationHash: messageBlockHeader.applicationHash,
42308
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
42309
- messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
42531
+ messageReceiptCount: bn(messageBlockHeader.messageReceiptCount),
42532
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
42533
+ consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
42534
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
42535
+ stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
42310
42536
  },
42311
42537
  commitBlockHeader: {
42312
42538
  id: commitBlockHeader.id,
@@ -42317,8 +42543,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42317
42543
  prevRoot: commitBlockHeader.prevRoot,
42318
42544
  time: commitBlockHeader.time,
42319
42545
  applicationHash: commitBlockHeader.applicationHash,
42320
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
42321
- messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
42546
+ messageReceiptCount: bn(commitBlockHeader.messageReceiptCount),
42547
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
42548
+ consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
42549
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
42550
+ stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
42322
42551
  },
42323
42552
  sender: Address.fromAddressOrString(sender),
42324
42553
  recipient: Address.fromAddressOrString(recipient),
@@ -42327,6 +42556,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42327
42556
  data
42328
42557
  };
42329
42558
  }
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
+ }
42330
42569
  /**
42331
42570
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
42332
42571
  *
@@ -42387,10 +42626,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42387
42626
  arrayify(gqlTransaction.rawPayload),
42388
42627
  0
42389
42628
  );
42390
- const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
42629
+ let txReceipts = [];
42630
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42631
+ txReceipts = gqlTransaction.status.receipts;
42632
+ }
42633
+ const receipts = txReceipts.map(processGqlReceipt);
42391
42634
  const {
42392
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42635
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42393
42636
  } = provider.getChain();
42637
+ const gasPrice = await provider.getLatestGasPrice();
42394
42638
  const transactionInfo = assembleTransactionSummary({
42395
42639
  id: gqlTransaction.id,
42396
42640
  receipts,
@@ -42401,7 +42645,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42401
42645
  gasPriceFactor: bn(gasPriceFactor),
42402
42646
  abiMap,
42403
42647
  maxInputs,
42404
- gasCosts
42648
+ gasCosts,
42649
+ maxGasPerTx,
42650
+ gasPrice
42405
42651
  });
42406
42652
  return {
42407
42653
  gqlTransaction,
@@ -42411,10 +42657,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42411
42657
  async function getTransactionSummaryFromRequest(params) {
42412
42658
  const { provider, transactionRequest, abiMap } = params;
42413
42659
  const { receipts } = await provider.call(transactionRequest);
42414
- const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
42660
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
42415
42661
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
42416
42662
  const transaction = transactionRequest.toTransaction();
42417
42663
  const transactionBytes = transactionRequest.toTransactionBytes();
42664
+ const gasPrice = await provider.getLatestGasPrice();
42418
42665
  const transactionSummary = assembleTransactionSummary({
42419
42666
  receipts,
42420
42667
  transaction,
@@ -42423,7 +42670,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42423
42670
  gasPerByte,
42424
42671
  gasPriceFactor,
42425
42672
  maxInputs,
42426
- gasCosts
42673
+ gasCosts,
42674
+ maxGasPerTx,
42675
+ gasPrice
42427
42676
  });
42428
42677
  return transactionSummary;
42429
42678
  }
@@ -42432,13 +42681,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42432
42681
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
42433
42682
  const { edges, pageInfo } = transactionsByOwner;
42434
42683
  const {
42435
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42684
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42436
42685
  } = provider.getChain();
42686
+ const gasPrice = await provider.getLatestGasPrice();
42437
42687
  const transactions = edges.map((edge) => {
42438
42688
  const { node: gqlTransaction } = edge;
42439
- const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
42689
+ const { id, rawPayload, status } = gqlTransaction;
42440
42690
  const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
42441
- const receipts = gqlReceipts?.map(processGqlReceipt) || [];
42691
+ let txReceipts = [];
42692
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42693
+ txReceipts = gqlTransaction.status.receipts;
42694
+ }
42695
+ const receipts = txReceipts.map(processGqlReceipt);
42442
42696
  const transactionSummary = assembleTransactionSummary({
42443
42697
  id,
42444
42698
  receipts,
@@ -42449,7 +42703,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42449
42703
  gasPerByte,
42450
42704
  gasPriceFactor,
42451
42705
  maxInputs,
42452
- gasCosts
42706
+ gasCosts,
42707
+ maxGasPerTx,
42708
+ gasPrice
42453
42709
  });
42454
42710
  const output3 = {
42455
42711
  gqlTransaction,
@@ -42740,9 +42996,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42740
42996
  * @param assetId - The asset ID to check the balance for.
42741
42997
  * @returns A promise that resolves to the balance amount.
42742
42998
  */
42743
- async getBalance(assetId) {
42744
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42745
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42999
+ async getBalance(assetId = BaseAssetId) {
43000
+ const amount = await this.provider.getBalance(this.address, assetId);
42746
43001
  return amount;
42747
43002
  }
42748
43003
  /**
@@ -42779,37 +43034,33 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42779
43034
  * @param fee - The estimated transaction fee.
42780
43035
  * @returns A promise that resolves when the resources are added to the transaction.
42781
43036
  */
42782
- async fund(request, coinQuantities, fee) {
42783
- const baseAssetId = this.provider.getBaseAssetId();
42784
- const updatedQuantities = addAmountToAsset({
43037
+ async fund(request, params) {
43038
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
43039
+ const txRequest = request;
43040
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
42785
43041
  amount: bn(fee),
42786
- assetId: baseAssetId,
42787
- coinQuantities
43042
+ assetId: BaseAssetId,
43043
+ coinQuantities: requiredQuantities
42788
43044
  });
42789
43045
  const quantitiesDict = {};
42790
- updatedQuantities.forEach(({ amount, assetId }) => {
43046
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
42791
43047
  quantitiesDict[assetId] = {
42792
43048
  required: amount,
42793
43049
  owned: bn(0)
42794
43050
  };
42795
43051
  });
42796
- const cachedUtxos = [];
42797
- const cachedMessages = [];
42798
- const owner = this.address.toB256();
42799
- request.inputs.forEach((input) => {
43052
+ txRequest.inputs.forEach((input) => {
42800
43053
  const isResource = "amount" in input;
42801
43054
  if (isResource) {
42802
43055
  const isCoin2 = "owner" in input;
42803
43056
  if (isCoin2) {
42804
43057
  const assetId = String(input.assetId);
42805
- if (input.owner === owner && quantitiesDict[assetId]) {
43058
+ if (quantitiesDict[assetId]) {
42806
43059
  const amount = bn(input.amount);
42807
43060
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42808
- cachedUtxos.push(input.id);
42809
43061
  }
42810
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
42811
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
42812
- cachedMessages.push(input.nonce);
43062
+ } else if (input.amount && quantitiesDict[BaseAssetId]) {
43063
+ quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42813
43064
  }
42814
43065
  }
42815
43066
  });
@@ -42824,12 +43075,23 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42824
43075
  });
42825
43076
  const needsToBeFunded = missingQuantities.length;
42826
43077
  if (needsToBeFunded) {
42827
- const resources = await this.getResourcesToSpend(missingQuantities, {
42828
- messages: cachedMessages,
42829
- utxos: cachedUtxos
42830
- });
42831
- request.addResources(resources);
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
+ );
42832
43089
  }
43090
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
43091
+ transactionRequest: requestToBeReEstimate
43092
+ });
43093
+ txRequest.maxFee = maxFee;
43094
+ return txRequest;
42833
43095
  }
42834
43096
  /**
42835
43097
  * A helper that creates a transfer transaction request and returns it.
@@ -42837,30 +43099,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42837
43099
  * @param destination - The address of the destination.
42838
43100
  * @param amount - The amount of coins to transfer.
42839
43101
  * @param assetId - The asset ID of the coins to transfer.
42840
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
43102
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
42841
43103
  * @returns A promise that resolves to the prepared transaction request.
42842
43104
  */
42843
- async createTransfer(destination, amount, assetId, txParams = {}) {
42844
- const { minGasPrice } = this.provider.getGasConfig();
42845
- const baseAssetId = this.provider.getBaseAssetId();
42846
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42847
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
42848
- const request = new ScriptTransactionRequest(params);
42849
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
42850
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
43105
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
43106
+ const request = new ScriptTransactionRequest(txParams);
43107
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
43108
+ const txCost = await this.provider.getTransactionCost(request, {
42851
43109
  estimateTxDependencies: true,
42852
43110
  resourcesOwner: this
42853
43111
  });
42854
- request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
42855
- request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
42856
- this.validateGas({
42857
- gasUsed,
42858
- gasPrice: request.gasPrice,
42859
- gasLimit: request.gasLimit,
42860
- minGasPrice
42861
- });
42862
- await this.fund(request, requiredQuantities, maxFee);
42863
- request.updatePredicateInputs(estimatedInputs);
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);
42864
43121
  return request;
42865
43122
  }
42866
43123
  /**
@@ -42872,15 +43129,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42872
43129
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
42873
43130
  * @returns A promise that resolves to the transaction response.
42874
43131
  */
42875
- async transfer(destination, amount, assetId, txParams = {}) {
43132
+ async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42876
43133
  if (bn(amount).lte(0)) {
42877
43134
  throw new FuelError(
42878
43135
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42879
43136
  "Transfer amount must be a positive number."
42880
43137
  );
42881
43138
  }
42882
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42883
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
43139
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
42884
43140
  return this.sendTransaction(request, { estimateTxDependencies: false });
42885
43141
  }
42886
43142
  /**
@@ -42892,7 +43148,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42892
43148
  * @param txParams - The optional transaction parameters.
42893
43149
  * @returns A promise that resolves to the transaction response.
42894
43150
  */
42895
- async transferToContract(contractId, amount, assetId, txParams = {}) {
43151
+ async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
42896
43152
  if (bn(amount).lte(0)) {
42897
43153
  throw new FuelError(
42898
43154
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42900,33 +43156,30 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42900
43156
  );
42901
43157
  }
42902
43158
  const contractAddress = Address.fromAddressOrString(contractId);
42903
- const { minGasPrice } = this.provider.getGasConfig();
42904
- const baseAssetId = this.provider.getBaseAssetId();
42905
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42906
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
42907
43159
  const { script, scriptData } = await assembleTransferToContractScript({
42908
43160
  hexlifiedContractId: contractAddress.toB256(),
42909
43161
  amountToTransfer: bn(amount),
42910
- assetId: assetIdToTransfer
43162
+ assetId
42911
43163
  });
42912
43164
  const request = new ScriptTransactionRequest({
42913
- ...params,
43165
+ ...txParams,
42914
43166
  script,
42915
43167
  scriptData
42916
43168
  });
42917
43169
  request.addContractInputAndOutput(contractAddress);
42918
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42919
- request,
42920
- [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42921
- );
42922
- request.gasLimit = bn(params.gasLimit ?? gasUsed);
42923
- this.validateGas({
42924
- gasUsed,
42925
- gasPrice: request.gasPrice,
42926
- gasLimit: request.gasLimit,
42927
- minGasPrice
43170
+ const txCost = await this.provider.getTransactionCost(request, {
43171
+ resourcesOwner: this,
43172
+ quantitiesToContract: [{ amount: bn(amount), assetId: String(assetId) }]
42928
43173
  });
42929
- await this.fund(request, requiredQuantities, maxFee);
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);
42930
43183
  return this.sendTransaction(request);
42931
43184
  }
42932
43185
  /**
@@ -42938,8 +43191,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42938
43191
  * @returns A promise that resolves to the transaction response.
42939
43192
  */
42940
43193
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42941
- const { minGasPrice } = this.provider.getGasConfig();
42942
- const baseAssetId = this.provider.getBaseAssetId();
42943
43194
  const recipientAddress = Address.fromAddressOrString(recipient);
42944
43195
  const recipientDataArray = arrayify(
42945
43196
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42952,26 +43203,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42952
43203
  ...recipientDataArray,
42953
43204
  ...amountDataArray
42954
43205
  ]);
42955
- const params = {
42956
- script,
42957
- gasPrice: minGasPrice,
42958
- baseAssetId,
42959
- ...txParams
42960
- };
43206
+ const params = { script, ...txParams };
42961
43207
  const request = new ScriptTransactionRequest(params);
42962
- const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
42963
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42964
- request,
42965
- forwardingQuantities
42966
- );
42967
- request.gasLimit = bn(params.gasLimit ?? gasUsed);
42968
- this.validateGas({
42969
- gasUsed,
42970
- gasPrice: request.gasPrice,
42971
- gasLimit: request.gasLimit,
42972
- minGasPrice
42973
- });
42974
- await this.fund(request, requiredQuantities, maxFee);
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);
42975
43219
  return this.sendTransaction(request);
42976
43220
  }
42977
43221
  async signMessage(message) {
@@ -43029,18 +43273,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43029
43273
  }
43030
43274
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
43031
43275
  }
43032
- validateGas({
43033
- gasUsed,
43034
- gasPrice,
43035
- gasLimit,
43036
- minGasPrice
43037
- }) {
43038
- if (minGasPrice.gt(gasPrice)) {
43039
- throw new FuelError(
43040
- ErrorCode.GAS_PRICE_TOO_LOW,
43041
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
43042
- );
43043
- }
43276
+ validateGas({ gasUsed, gasLimit }) {
43044
43277
  if (gasUsed.gt(gasLimit)) {
43045
43278
  throw new FuelError(
43046
43279
  ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -44629,7 +44862,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44629
44862
  * @param transactionRequestLike - The transaction request to send.
44630
44863
  * @returns A promise that resolves to the TransactionResponse object.
44631
44864
  */
44632
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
44865
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
44633
44866
  const transactionRequest = transactionRequestify(transactionRequestLike);
44634
44867
  if (estimateTxDependencies) {
44635
44868
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -47907,8 +48140,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47907
48140
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
47908
48141
  request.inputs?.forEach((input) => {
47909
48142
  if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
47910
- input.predicate = this.bytes;
47911
- input.predicateData = this.getPredicateData(policies.length);
48143
+ input.predicate = hexlify(this.bytes);
48144
+ input.predicateData = hexlify(this.getPredicateData(policies.length));
47912
48145
  }
47913
48146
  });
47914
48147
  return request;
@@ -47922,10 +48155,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47922
48155
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47923
48156
  * @returns A promise that resolves to the prepared transaction request.
47924
48157
  */
47925
- async createTransfer(destination, amount, assetId, txParams = {}) {
47926
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
47927
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
47928
- return this.populateTransactionPredicateData(request);
48158
+ async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
48159
+ return super.createTransfer(destination, amount, assetId, txParams);
47929
48160
  }
47930
48161
  /**
47931
48162
  * Sends a transaction with the populated predicate data.
@@ -47933,9 +48164,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47933
48164
  * @param transactionRequestLike - The transaction request-like object.
47934
48165
  * @returns A promise that resolves to the transaction response.
47935
48166
  */
47936
- sendTransaction(transactionRequestLike, options) {
47937
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47938
- return super.sendTransaction(transactionRequest, options);
48167
+ sendTransaction(transactionRequestLike) {
48168
+ const transactionRequest = transactionRequestify(transactionRequestLike);
48169
+ return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
47939
48170
  }
47940
48171
  /**
47941
48172
  * Simulates a transaction with the populated predicate data.
@@ -47944,8 +48175,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47944
48175
  * @returns A promise that resolves to the call result.
47945
48176
  */
47946
48177
  simulateTransaction(transactionRequestLike) {
47947
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47948
- return super.simulateTransaction(transactionRequest);
48178
+ const transactionRequest = transactionRequestify(transactionRequestLike);
48179
+ return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
47949
48180
  }
47950
48181
  getPredicateData(policiesLength) {
47951
48182
  if (!this.predicateData.length) {
@@ -47991,6 +48222,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47991
48222
  predicateInterface: abiInterface
47992
48223
  };
47993
48224
  }
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
+ }
47994
48244
  /**
47995
48245
  * Sets the configurable constants for the predicate.
47996
48246
  *