@fuel-ts/account 0.81.0 → 0.83.0

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 (57) hide show
  1. package/README.md +3 -3
  2. package/dist/account.d.ts +7 -6
  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 +890 -619
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +853 -604
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +696 -448
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +12 -24
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +810 -359
  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 +44 -27
  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.map +1 -1
  34. package/dist/providers/transaction-request/transaction-request.d.ts +13 -33
  35. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  36. package/dist/providers/transaction-request/utils.d.ts +3 -0
  37. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  38. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
  40. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
  42. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  43. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  44. package/dist/providers/utils/gas.d.ts +8 -2
  45. package/dist/providers/utils/gas.d.ts.map +1 -1
  46. package/dist/providers/utils/merge-quantities.d.ts +1 -1
  47. package/dist/providers/utils/merge-quantities.d.ts.map +1 -1
  48. package/dist/test-utils/launchNode.d.ts +1 -1
  49. package/dist/test-utils/launchNode.d.ts.map +1 -1
  50. package/dist/test-utils.global.js +1615 -1114
  51. package/dist/test-utils.global.js.map +1 -1
  52. package/dist/test-utils.js +841 -596
  53. package/dist/test-utils.js.map +1 -1
  54. package/dist/test-utils.mjs +696 -451
  55. package/dist/test-utils.mjs.map +1 -1
  56. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  57. 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,9 +28952,9 @@ spurious results.`);
28952
28952
  // ../versions/dist/index.mjs
28953
28953
  function getBuiltinVersions() {
28954
28954
  return {
28955
- FORC: "0.49.3",
28956
- FUEL_CORE: "0.22.1",
28957
- FUELS: "0.81.0"
28955
+ FORC: "0.56.0",
28956
+ FUEL_CORE: "0.24.3",
28957
+ FUELS: "0.83.0"
28958
28958
  };
28959
28959
  }
28960
28960
  function parseVersion(version2) {
@@ -29053,6 +29053,7 @@ This unreleased fuel-core build may include features and updates not yet support
29053
29053
  ErrorCode2["INVALID_TRANSFER_AMOUNT"] = "invalid-transfer-amount";
29054
29054
  ErrorCode2["GAS_PRICE_TOO_LOW"] = "gas-price-too-low";
29055
29055
  ErrorCode2["GAS_LIMIT_TOO_LOW"] = "gas-limit-too-low";
29056
+ ErrorCode2["MAX_FEE_TOO_LOW"] = "max-fee-too-low";
29056
29057
  ErrorCode2["TRANSACTION_NOT_FOUND"] = "transaction-not-found";
29057
29058
  ErrorCode2["TRANSACTION_FAILED"] = "transaction-failed";
29058
29059
  ErrorCode2["INVALID_CONFIGURABLE_CONSTANTS"] = "invalid-configurable-constants";
@@ -29243,6 +29244,9 @@ This unreleased fuel-core build may include features and updates not yet support
29243
29244
  };
29244
29245
  var DateTime = _DateTime;
29245
29246
  __publicField3(DateTime, "TAI64_NULL", "");
29247
+ function isDefined(value) {
29248
+ return value !== void 0;
29249
+ }
29246
29250
 
29247
29251
  // ../crypto/dist/index.mjs
29248
29252
  var import_crypto8 = __toESM(__require("crypto"), 1);
@@ -31144,7 +31148,7 @@ This unreleased fuel-core build may include features and updates not yet support
31144
31148
  toEvmAddress() {
31145
31149
  const b256Address = toB256(this.bech32Address);
31146
31150
  return {
31147
- value: clearFirst12BytesFromB256(b256Address)
31151
+ bits: clearFirst12BytesFromB256(b256Address)
31148
31152
  };
31149
31153
  }
31150
31154
  /**
@@ -31154,7 +31158,7 @@ This unreleased fuel-core build may include features and updates not yet support
31154
31158
  */
31155
31159
  toAssetId() {
31156
31160
  return {
31157
- value: this.toB256()
31161
+ bits: this.toB256()
31158
31162
  };
31159
31163
  }
31160
31164
  /**
@@ -31272,10 +31276,6 @@ This unreleased fuel-core build may include features and updates not yet support
31272
31276
  }
31273
31277
  };
31274
31278
 
31275
- // ../address/dist/configs.mjs
31276
- var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
31277
- var BaseAssetId = ZeroBytes32;
31278
-
31279
31279
  // ../math/dist/index.mjs
31280
31280
  var import_bn = __toESM(require_bn(), 1);
31281
31281
  var DEFAULT_PRECISION = 9;
@@ -31495,32 +31495,182 @@ This unreleased fuel-core build may include features and updates not yet support
31495
31495
  function toBytes3(value, bytesPadding) {
31496
31496
  return bn(value).toBytes(bytesPadding);
31497
31497
  }
31498
- function max(...numbers) {
31499
- return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
31498
+
31499
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
31500
+ function _isPlaceholder(a) {
31501
+ return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
31502
+ }
31503
+
31504
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
31505
+ function _curry1(fn) {
31506
+ return function f1(a) {
31507
+ if (arguments.length === 0 || _isPlaceholder(a)) {
31508
+ return f1;
31509
+ } else {
31510
+ return fn.apply(this, arguments);
31511
+ }
31512
+ };
31513
+ }
31514
+
31515
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
31516
+ var isArray_default = Array.isArray || function _isArray(val) {
31517
+ return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
31518
+ };
31519
+
31520
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
31521
+ var type = /* @__PURE__ */ _curry1(function type2(val) {
31522
+ return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
31523
+ });
31524
+ var type_default = type;
31525
+
31526
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
31527
+ var pad = function pad2(n) {
31528
+ return (n < 10 ? "0" : "") + n;
31529
+ };
31530
+ var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
31531
+ return d.toISOString();
31532
+ } : function _toISOString3(d) {
31533
+ return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
31534
+ };
31535
+
31536
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
31537
+ var isInteger_default = Number.isInteger || function _isInteger(n) {
31538
+ return n << 0 === n;
31539
+ };
31540
+
31541
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
31542
+ function _cloneRegExp(pattern) {
31543
+ return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
31544
+ }
31545
+
31546
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
31547
+ function _clone(value, deep, map) {
31548
+ map || (map = new _ObjectMap());
31549
+ if (_isPrimitive(value)) {
31550
+ return value;
31551
+ }
31552
+ var copy = function copy2(copiedValue) {
31553
+ var cachedCopy = map.get(value);
31554
+ if (cachedCopy) {
31555
+ return cachedCopy;
31556
+ }
31557
+ map.set(value, copiedValue);
31558
+ for (var key in value) {
31559
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
31560
+ copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
31561
+ }
31562
+ }
31563
+ return copiedValue;
31564
+ };
31565
+ switch (type_default(value)) {
31566
+ case "Object":
31567
+ return copy(Object.create(Object.getPrototypeOf(value)));
31568
+ case "Array":
31569
+ return copy([]);
31570
+ case "Date":
31571
+ return new Date(value.valueOf());
31572
+ case "RegExp":
31573
+ return _cloneRegExp(value);
31574
+ case "Int8Array":
31575
+ case "Uint8Array":
31576
+ case "Uint8ClampedArray":
31577
+ case "Int16Array":
31578
+ case "Uint16Array":
31579
+ case "Int32Array":
31580
+ case "Uint32Array":
31581
+ case "Float32Array":
31582
+ case "Float64Array":
31583
+ case "BigInt64Array":
31584
+ case "BigUint64Array":
31585
+ return value.slice();
31586
+ default:
31587
+ return value;
31588
+ }
31589
+ }
31590
+ function _isPrimitive(param) {
31591
+ var type3 = typeof param;
31592
+ return param == null || type3 != "object" && type3 != "function";
31500
31593
  }
31594
+ var _ObjectMap = /* @__PURE__ */ function() {
31595
+ function _ObjectMap2() {
31596
+ this.map = {};
31597
+ this.length = 0;
31598
+ }
31599
+ _ObjectMap2.prototype.set = function(key, value) {
31600
+ const hashedKey = this.hash(key);
31601
+ let bucket = this.map[hashedKey];
31602
+ if (!bucket) {
31603
+ this.map[hashedKey] = bucket = [];
31604
+ }
31605
+ bucket.push([key, value]);
31606
+ this.length += 1;
31607
+ };
31608
+ _ObjectMap2.prototype.hash = function(key) {
31609
+ let hashedKey = [];
31610
+ for (var value in key) {
31611
+ hashedKey.push(Object.prototype.toString.call(key[value]));
31612
+ }
31613
+ return hashedKey.join();
31614
+ };
31615
+ _ObjectMap2.prototype.get = function(key) {
31616
+ if (this.length <= 180) {
31617
+ for (const p in this.map) {
31618
+ const bucket2 = this.map[p];
31619
+ for (let i = 0; i < bucket2.length; i += 1) {
31620
+ const element = bucket2[i];
31621
+ if (element[0] === key) {
31622
+ return element[1];
31623
+ }
31624
+ }
31625
+ }
31626
+ return;
31627
+ }
31628
+ const hashedKey = this.hash(key);
31629
+ const bucket = this.map[hashedKey];
31630
+ if (!bucket) {
31631
+ return;
31632
+ }
31633
+ for (let i = 0; i < bucket.length; i += 1) {
31634
+ const element = bucket[i];
31635
+ if (element[0] === key) {
31636
+ return element[1];
31637
+ }
31638
+ }
31639
+ };
31640
+ return _ObjectMap2;
31641
+ }();
31642
+
31643
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
31644
+ var clone = /* @__PURE__ */ _curry1(function clone2(value) {
31645
+ return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
31646
+ });
31647
+ var clone_default = clone;
31648
+
31649
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
31650
+ var hasProtoTrim = typeof String.prototype.trim === "function";
31501
31651
 
31502
31652
  // src/providers/coin-quantity.ts
31503
31653
  var coinQuantityfy = (coinQuantityLike) => {
31504
31654
  let assetId;
31505
31655
  let amount;
31506
- let max2;
31656
+ let max;
31507
31657
  if (Array.isArray(coinQuantityLike)) {
31508
31658
  amount = coinQuantityLike[0];
31509
- assetId = coinQuantityLike[1] ?? BaseAssetId;
31510
- max2 = coinQuantityLike[2] ?? void 0;
31659
+ assetId = coinQuantityLike[1];
31660
+ max = coinQuantityLike[2] ?? void 0;
31511
31661
  } else {
31512
31662
  amount = coinQuantityLike.amount;
31513
- assetId = coinQuantityLike.assetId ?? BaseAssetId;
31514
- max2 = coinQuantityLike.max ?? void 0;
31663
+ assetId = coinQuantityLike.assetId;
31664
+ max = coinQuantityLike.max ?? void 0;
31515
31665
  }
31516
31666
  const bnAmount = bn(amount);
31517
31667
  return {
31518
31668
  assetId: hexlify(assetId),
31519
31669
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
31520
- max: max2 ? bn(max2) : void 0
31670
+ max: max ? bn(max) : void 0
31521
31671
  };
31522
31672
  };
31523
- var addAmountToAsset = (params) => {
31673
+ var addAmountToCoinQuantities = (params) => {
31524
31674
  const { amount, assetId } = params;
31525
31675
  const coinQuantities = [...params.coinQuantities];
31526
31676
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -31605,7 +31755,7 @@ This unreleased fuel-core build may include features and updates not yet support
31605
31755
  var ENCODING_V1 = "1";
31606
31756
  var WORD_SIZE = 8;
31607
31757
  var BYTES_32 = 32;
31608
- var UTXO_ID_LEN = BYTES_32 + 1;
31758
+ var UTXO_ID_LEN = BYTES_32 + 2;
31609
31759
  var ASSET_ID_LEN = BYTES_32;
31610
31760
  var ADDRESS_LEN = BYTES_32;
31611
31761
  var NONCE_LEN = BYTES_32;
@@ -31613,9 +31763,9 @@ This unreleased fuel-core build may include features and updates not yet support
31613
31763
  var TX_POINTER_LEN = WORD_SIZE * 2;
31614
31764
  var MAX_BYTES = 2 ** 32 - 1;
31615
31765
  var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
31616
- WORD_SIZE + // Tx size
31766
+ ASSET_ID_LEN + // Base asset ID
31617
31767
  // Asset ID/Balance coin input pairs
31618
- maxInputs * (ASSET_ID_LEN + WORD_SIZE);
31768
+ maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
31619
31769
  var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
31620
31770
  WORD_SIZE + // Gas limit
31621
31771
  WORD_SIZE + // Script size
@@ -31633,7 +31783,6 @@ This unreleased fuel-core build may include features and updates not yet support
31633
31783
  ASSET_ID_LEN + // Asset id
31634
31784
  TX_POINTER_LEN + // TxPointer
31635
31785
  WORD_SIZE + // Witnesses index
31636
- WORD_SIZE + // Maturity
31637
31786
  WORD_SIZE + // Predicate size
31638
31787
  WORD_SIZE + // Predicate data size
31639
31788
  WORD_SIZE;
@@ -31955,7 +32104,7 @@ This unreleased fuel-core build may include features and updates not yet support
31955
32104
  constructor(name, coders) {
31956
32105
  const caseIndexCoder = new BigNumberCoder("u64");
31957
32106
  const encodedValueSize = Object.values(coders).reduce(
31958
- (max2, coder) => Math.max(max2, coder.encodedLength),
32107
+ (max, coder) => Math.max(max, coder.encodedLength),
31959
32108
  0
31960
32109
  );
31961
32110
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -32342,6 +32491,20 @@ This unreleased fuel-core build may include features and updates not yet support
32342
32491
  ];
32343
32492
  }
32344
32493
  };
32494
+ var getEncodingVersion = (encoding) => {
32495
+ switch (encoding) {
32496
+ case void 0:
32497
+ case ENCODING_V0:
32498
+ return ENCODING_V0;
32499
+ case ENCODING_V1:
32500
+ return ENCODING_V1;
32501
+ default:
32502
+ throw new FuelError(
32503
+ ErrorCode.UNSUPPORTED_ENCODING_VERSION,
32504
+ `Encoding version '${encoding}' is unsupported.`
32505
+ );
32506
+ }
32507
+ };
32345
32508
  var findFunctionByName = (abi, name) => {
32346
32509
  const fn = abi.functions.find((f2) => f2.name === name);
32347
32510
  if (!fn) {
@@ -32659,7 +32822,7 @@ This unreleased fuel-core build may include features and updates not yet support
32659
32822
  constructor(name, coders) {
32660
32823
  const caseIndexCoder = new BigNumberCoder("u64");
32661
32824
  const encodedValueSize = Object.values(coders).reduce(
32662
- (max2, coder) => Math.max(max2, coder.encodedLength),
32825
+ (max, coder) => Math.max(max, coder.encodedLength),
32663
32826
  0
32664
32827
  );
32665
32828
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -32950,9 +33113,11 @@ This unreleased fuel-core build may include features and updates not yet support
32950
33113
  };
32951
33114
  var VecCoder2 = class extends Coder {
32952
33115
  coder;
33116
+ #isOptionVec;
32953
33117
  constructor(coder) {
32954
33118
  super("struct", `struct Vec`, coder.encodedLength + WORD_SIZE);
32955
33119
  this.coder = coder;
33120
+ this.#isOptionVec = this.coder instanceof OptionCoder2;
32956
33121
  }
32957
33122
  encode(value) {
32958
33123
  if (!Array.isArray(value)) {
@@ -32963,7 +33128,7 @@ This unreleased fuel-core build may include features and updates not yet support
32963
33128
  return new Uint8Array([...lengthBytes, ...concatBytes2(bytes3)]);
32964
33129
  }
32965
33130
  decode(data, offset) {
32966
- if (data.length < this.encodedLength || data.length > MAX_BYTES) {
33131
+ if (!this.#isOptionVec && (data.length < this.encodedLength || data.length > MAX_BYTES)) {
32967
33132
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec data size.`);
32968
33133
  }
32969
33134
  const offsetAndLength = offset + WORD_SIZE;
@@ -32971,15 +33136,17 @@ This unreleased fuel-core build may include features and updates not yet support
32971
33136
  const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
32972
33137
  const dataLength2 = length * this.coder.encodedLength;
32973
33138
  const dataBytes = data.slice(offsetAndLength, offsetAndLength + dataLength2);
32974
- if (dataBytes.length !== dataLength2) {
33139
+ if (!this.#isOptionVec && dataBytes.length !== dataLength2) {
32975
33140
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec byte data size.`);
32976
33141
  }
32977
- return [
32978
- chunkByLength(dataBytes, this.coder.encodedLength).map(
32979
- (chunk) => this.coder.decode(chunk, 0)[0]
32980
- ),
32981
- offsetAndLength + dataLength2
32982
- ];
33142
+ let newOffset = offsetAndLength;
33143
+ const chunks = [];
33144
+ for (let i = 0; i < length; i++) {
33145
+ const [decoded, optionOffset] = this.coder.decode(data, newOffset);
33146
+ chunks.push(decoded);
33147
+ newOffset = optionOffset;
33148
+ }
33149
+ return [chunks, newOffset];
32983
33150
  }
32984
33151
  };
32985
33152
  var getCoder2 = (resolvedAbiType, _options) => {
@@ -33106,7 +33273,7 @@ This unreleased fuel-core build may include features and updates not yet support
33106
33273
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
33107
33274
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
33108
33275
  this.selectorBytes = new StdStringCoder2().encode(name);
33109
- this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
33276
+ this.encoding = getEncodingVersion(jsonAbi.encoding);
33110
33277
  this.isInputDataPointer = this.#isInputDataPointer();
33111
33278
  this.outputMetadata = {
33112
33279
  isHeapType: this.#isOutputDataHeap(),
@@ -33244,8 +33411,10 @@ This unreleased fuel-core build may include features and updates not yet support
33244
33411
  functions;
33245
33412
  configurables;
33246
33413
  jsonAbi;
33414
+ encoding;
33247
33415
  constructor(jsonAbi) {
33248
33416
  this.jsonAbi = jsonAbi;
33417
+ this.encoding = getEncodingVersion(jsonAbi.encoding);
33249
33418
  this.functions = Object.fromEntries(
33250
33419
  this.jsonAbi.functions.map((x) => [x.name, new FunctionFragment(this.jsonAbi, x.name)])
33251
33420
  );
@@ -33289,7 +33458,7 @@ This unreleased fuel-core build may include features and updates not yet support
33289
33458
  );
33290
33459
  }
33291
33460
  return AbiCoder.decode(this.jsonAbi, loggedType.loggedType, arrayify(data), 0, {
33292
- encoding: this.jsonAbi.encoding
33461
+ encoding: this.encoding
33293
33462
  });
33294
33463
  }
33295
33464
  encodeConfigurable(name, value) {
@@ -33371,18 +33540,19 @@ This unreleased fuel-core build may include features and updates not yet support
33371
33540
  encode(value) {
33372
33541
  const parts = [];
33373
33542
  parts.push(new B256Coder().encode(value.txID));
33374
- parts.push(new NumberCoder("u8").encode(value.outputIndex));
33543
+ parts.push(new NumberCoder("u16").encode(value.outputIndex));
33375
33544
  parts.push(new B256Coder().encode(value.owner));
33376
33545
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33377
33546
  parts.push(new B256Coder().encode(value.assetId));
33378
33547
  parts.push(new TxPointerCoder().encode(value.txPointer));
33379
- parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33380
- parts.push(new NumberCoder("u32").encode(value.maturity));
33548
+ parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33381
33549
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33382
- parts.push(new NumberCoder("u32").encode(value.predicateLength));
33383
- parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
33384
- parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33385
- parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33550
+ parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33551
+ parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33552
+ parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33553
+ parts.push(
33554
+ new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33555
+ );
33386
33556
  return concat(parts);
33387
33557
  }
33388
33558
  decode(data, offset) {
@@ -33390,7 +33560,7 @@ This unreleased fuel-core build may include features and updates not yet support
33390
33560
  let o = offset;
33391
33561
  [decoded, o] = new B256Coder().decode(data, o);
33392
33562
  const txID = decoded;
33393
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33563
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33394
33564
  const outputIndex = decoded;
33395
33565
  [decoded, o] = new B256Coder().decode(data, o);
33396
33566
  const owner = decoded;
@@ -33400,19 +33570,17 @@ This unreleased fuel-core build may include features and updates not yet support
33400
33570
  const assetId = decoded;
33401
33571
  [decoded, o] = new TxPointerCoder().decode(data, o);
33402
33572
  const txPointer = decoded;
33403
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33573
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33404
33574
  const witnessIndex = Number(decoded);
33405
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33406
- const maturity = decoded;
33407
33575
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33408
33576
  const predicateGasUsed = decoded;
33409
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33577
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33410
33578
  const predicateLength = decoded;
33411
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33579
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33412
33580
  const predicateDataLength = decoded;
33413
- [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33581
+ [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33414
33582
  const predicate = decoded;
33415
- [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33583
+ [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33416
33584
  const predicateData = decoded;
33417
33585
  return [
33418
33586
  {
@@ -33424,7 +33592,6 @@ This unreleased fuel-core build may include features and updates not yet support
33424
33592
  assetId,
33425
33593
  txPointer,
33426
33594
  witnessIndex,
33427
- maturity,
33428
33595
  predicateGasUsed,
33429
33596
  predicateLength,
33430
33597
  predicateDataLength,
@@ -33442,7 +33609,7 @@ This unreleased fuel-core build may include features and updates not yet support
33442
33609
  encode(value) {
33443
33610
  const parts = [];
33444
33611
  parts.push(new B256Coder().encode(value.txID));
33445
- parts.push(new NumberCoder("u8").encode(value.outputIndex));
33612
+ parts.push(new NumberCoder("u16").encode(value.outputIndex));
33446
33613
  parts.push(new B256Coder().encode(value.balanceRoot));
33447
33614
  parts.push(new B256Coder().encode(value.stateRoot));
33448
33615
  parts.push(new TxPointerCoder().encode(value.txPointer));
@@ -33454,7 +33621,7 @@ This unreleased fuel-core build may include features and updates not yet support
33454
33621
  let o = offset;
33455
33622
  [decoded, o] = new B256Coder().decode(data, o);
33456
33623
  const txID = decoded;
33457
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33624
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33458
33625
  const outputIndex = decoded;
33459
33626
  [decoded, o] = new B256Coder().decode(data, o);
33460
33627
  const balanceRoot = decoded;
@@ -33503,14 +33670,16 @@ This unreleased fuel-core build may include features and updates not yet support
33503
33670
  parts.push(new ByteArrayCoder(32).encode(value.recipient));
33504
33671
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33505
33672
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
33506
- parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33673
+ parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33507
33674
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33508
- parts.push(new NumberCoder("u32").encode(data.length));
33509
- parts.push(new NumberCoder("u32").encode(value.predicateLength));
33510
- parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
33675
+ parts.push(new BigNumberCoder("u64").encode(data.length));
33676
+ parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33677
+ parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33511
33678
  parts.push(new ByteArrayCoder(data.length).encode(data));
33512
- parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33513
- parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33679
+ parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33680
+ parts.push(
33681
+ new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33682
+ );
33514
33683
  return concat(parts);
33515
33684
  }
33516
33685
  static decodeData(messageData) {
@@ -33530,21 +33699,21 @@ This unreleased fuel-core build may include features and updates not yet support
33530
33699
  const amount = decoded;
33531
33700
  [decoded, o] = new B256Coder().decode(data, o);
33532
33701
  const nonce = decoded;
33533
- [decoded, o] = new NumberCoder("u8").decode(data, o);
33702
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
33534
33703
  const witnessIndex = Number(decoded);
33535
33704
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33536
33705
  const predicateGasUsed = decoded;
33537
33706
  [decoded, o] = new NumberCoder("u32").decode(data, o);
33538
33707
  const dataLength2 = decoded;
33539
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33708
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33540
33709
  const predicateLength = decoded;
33541
- [decoded, o] = new NumberCoder("u32").decode(data, o);
33710
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33542
33711
  const predicateDataLength = decoded;
33543
33712
  [decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
33544
33713
  const messageData = decoded;
33545
- [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33714
+ [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33546
33715
  const predicate = decoded;
33547
- [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33716
+ [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33548
33717
  const predicateData = decoded;
33549
33718
  return [
33550
33719
  {
@@ -33856,7 +34025,7 @@ This unreleased fuel-core build may include features and updates not yet support
33856
34025
  }
33857
34026
  };
33858
34027
  var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
33859
- PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
34028
+ PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
33860
34029
  PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
33861
34030
  PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
33862
34031
  PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
@@ -33904,9 +34073,9 @@ This unreleased fuel-core build may include features and updates not yet support
33904
34073
  let o = offset;
33905
34074
  const policies = [];
33906
34075
  if (policyTypes & 1) {
33907
- const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
34076
+ const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
33908
34077
  o = nextOffset;
33909
- policies.push({ type: 1, data: gasPrice });
34078
+ policies.push({ type: 1, data: tip });
33910
34079
  }
33911
34080
  if (policyTypes & 2) {
33912
34081
  const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
@@ -34138,15 +34307,15 @@ This unreleased fuel-core build may include features and updates not yet support
34138
34307
  encode(value) {
34139
34308
  const parts = [];
34140
34309
  parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
34141
- parts.push(new NumberCoder("u32").encode(value.scriptLength));
34142
- parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
34143
- parts.push(new NumberCoder("u32").encode(value.policyTypes));
34144
- parts.push(new NumberCoder("u8").encode(value.inputsCount));
34145
- parts.push(new NumberCoder("u8").encode(value.outputsCount));
34146
- parts.push(new NumberCoder("u8").encode(value.witnessesCount));
34147
34310
  parts.push(new B256Coder().encode(value.receiptsRoot));
34148
- parts.push(new ByteArrayCoder(value.scriptLength).encode(value.script));
34149
- parts.push(new ByteArrayCoder(value.scriptDataLength).encode(value.scriptData));
34311
+ parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
34312
+ parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
34313
+ parts.push(new NumberCoder("u32").encode(value.policyTypes));
34314
+ parts.push(new NumberCoder("u16").encode(value.inputsCount));
34315
+ parts.push(new NumberCoder("u16").encode(value.outputsCount));
34316
+ parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34317
+ parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
34318
+ parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
34150
34319
  parts.push(new PoliciesCoder().encode(value.policies));
34151
34320
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34152
34321
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
@@ -34158,23 +34327,23 @@ This unreleased fuel-core build may include features and updates not yet support
34158
34327
  let o = offset;
34159
34328
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34160
34329
  const scriptGasLimit = decoded;
34161
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34330
+ [decoded, o] = new B256Coder().decode(data, o);
34331
+ const receiptsRoot = decoded;
34332
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34162
34333
  const scriptLength = decoded;
34163
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34334
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34164
34335
  const scriptDataLength = decoded;
34165
34336
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34166
34337
  const policyTypes = decoded;
34167
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34338
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34168
34339
  const inputsCount = decoded;
34169
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34340
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34170
34341
  const outputsCount = decoded;
34171
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34342
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34172
34343
  const witnessesCount = decoded;
34173
- [decoded, o] = new B256Coder().decode(data, o);
34174
- const receiptsRoot = decoded;
34175
- [decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
34344
+ [decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
34176
34345
  const script = decoded;
34177
- [decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
34346
+ [decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
34178
34347
  const scriptData = decoded;
34179
34348
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34180
34349
  const policies = decoded;
@@ -34212,18 +34381,19 @@ This unreleased fuel-core build may include features and updates not yet support
34212
34381
  }
34213
34382
  encode(value) {
34214
34383
  const parts = [];
34215
- parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
34216
- parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
34217
- parts.push(new NumberCoder("u32").encode(value.policyTypes));
34218
- parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
34219
- parts.push(new NumberCoder("u8").encode(value.inputsCount));
34220
- parts.push(new NumberCoder("u8").encode(value.outputsCount));
34221
- parts.push(new NumberCoder("u8").encode(value.witnessesCount));
34384
+ parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
34222
34385
  parts.push(new B256Coder().encode(value.salt));
34223
- parts.push(new PoliciesCoder().encode(value.policies));
34386
+ parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
34387
+ parts.push(new NumberCoder("u32").encode(value.policyTypes));
34388
+ parts.push(new NumberCoder("u16").encode(value.inputsCount));
34389
+ parts.push(new NumberCoder("u16").encode(value.outputsCount));
34390
+ parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34224
34391
  parts.push(
34225
- new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
34392
+ new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
34393
+ value.storageSlots
34394
+ )
34226
34395
  );
34396
+ parts.push(new PoliciesCoder().encode(value.policies));
34227
34397
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34228
34398
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
34229
34399
  parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
@@ -34232,26 +34402,27 @@ This unreleased fuel-core build may include features and updates not yet support
34232
34402
  decode(data, offset) {
34233
34403
  let decoded;
34234
34404
  let o = offset;
34235
- [decoded, o] = new NumberCoder("u32").decode(data, o);
34236
- const bytecodeLength = decoded;
34237
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34405
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34238
34406
  const bytecodeWitnessIndex = decoded;
34407
+ [decoded, o] = new B256Coder().decode(data, o);
34408
+ const salt = decoded;
34409
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34410
+ const storageSlotsCount = decoded;
34239
34411
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34240
34412
  const policyTypes = decoded;
34241
34413
  [decoded, o] = new NumberCoder("u16").decode(data, o);
34242
- const storageSlotsCount = decoded;
34243
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34244
34414
  const inputsCount = decoded;
34245
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34415
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34246
34416
  const outputsCount = decoded;
34247
- [decoded, o] = new NumberCoder("u8").decode(data, o);
34417
+ [decoded, o] = new NumberCoder("u16").decode(data, o);
34248
34418
  const witnessesCount = decoded;
34249
- [decoded, o] = new B256Coder().decode(data, o);
34250
- const salt = decoded;
34419
+ [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
34420
+ data,
34421
+ o
34422
+ );
34423
+ const storageSlots = decoded;
34251
34424
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34252
34425
  const policies = decoded;
34253
- [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
34254
- const storageSlots = decoded;
34255
34426
  [decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
34256
34427
  const inputs = decoded;
34257
34428
  [decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
@@ -34261,7 +34432,6 @@ This unreleased fuel-core build may include features and updates not yet support
34261
34432
  return [
34262
34433
  {
34263
34434
  type: 1,
34264
- bytecodeLength,
34265
34435
  bytecodeWitnessIndex,
34266
34436
  policyTypes,
34267
34437
  storageSlotsCount,
@@ -34290,6 +34460,7 @@ This unreleased fuel-core build may include features and updates not yet support
34290
34460
  parts.push(new OutputContractCoder().encode(value.outputContract));
34291
34461
  parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
34292
34462
  parts.push(new B256Coder().encode(value.mintAssetId));
34463
+ parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
34293
34464
  return concat(parts);
34294
34465
  }
34295
34466
  decode(data, offset) {
@@ -34305,6 +34476,8 @@ This unreleased fuel-core build may include features and updates not yet support
34305
34476
  const mintAmount = decoded;
34306
34477
  [decoded, o] = new B256Coder().decode(data, o);
34307
34478
  const mintAssetId = decoded;
34479
+ [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34480
+ const gasPrice = decoded;
34308
34481
  return [
34309
34482
  {
34310
34483
  type: 2,
@@ -34312,7 +34485,8 @@ This unreleased fuel-core build may include features and updates not yet support
34312
34485
  inputContract,
34313
34486
  outputContract,
34314
34487
  mintAmount,
34315
- mintAssetId
34488
+ mintAssetId,
34489
+ gasPrice
34316
34490
  },
34317
34491
  o
34318
34492
  ];
@@ -34619,159 +34793,6 @@ This unreleased fuel-core build may include features and updates not yet support
34619
34793
  // src/providers/provider.ts
34620
34794
  var import_graphql_request = __toESM(require_dist2());
34621
34795
 
34622
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
34623
- function _isPlaceholder(a) {
34624
- return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
34625
- }
34626
-
34627
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
34628
- function _curry1(fn) {
34629
- return function f1(a) {
34630
- if (arguments.length === 0 || _isPlaceholder(a)) {
34631
- return f1;
34632
- } else {
34633
- return fn.apply(this, arguments);
34634
- }
34635
- };
34636
- }
34637
-
34638
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
34639
- var isArray_default = Array.isArray || function _isArray(val) {
34640
- return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
34641
- };
34642
-
34643
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
34644
- var type = /* @__PURE__ */ _curry1(function type2(val) {
34645
- return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
34646
- });
34647
- var type_default = type;
34648
-
34649
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
34650
- var pad = function pad2(n) {
34651
- return (n < 10 ? "0" : "") + n;
34652
- };
34653
- var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
34654
- return d.toISOString();
34655
- } : function _toISOString3(d) {
34656
- return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
34657
- };
34658
-
34659
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
34660
- var isInteger_default = Number.isInteger || function _isInteger(n) {
34661
- return n << 0 === n;
34662
- };
34663
-
34664
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
34665
- function _cloneRegExp(pattern) {
34666
- return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
34667
- }
34668
-
34669
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
34670
- function _clone(value, deep, map) {
34671
- map || (map = new _ObjectMap());
34672
- if (_isPrimitive(value)) {
34673
- return value;
34674
- }
34675
- var copy = function copy2(copiedValue) {
34676
- var cachedCopy = map.get(value);
34677
- if (cachedCopy) {
34678
- return cachedCopy;
34679
- }
34680
- map.set(value, copiedValue);
34681
- for (var key in value) {
34682
- if (Object.prototype.hasOwnProperty.call(value, key)) {
34683
- copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
34684
- }
34685
- }
34686
- return copiedValue;
34687
- };
34688
- switch (type_default(value)) {
34689
- case "Object":
34690
- return copy(Object.create(Object.getPrototypeOf(value)));
34691
- case "Array":
34692
- return copy([]);
34693
- case "Date":
34694
- return new Date(value.valueOf());
34695
- case "RegExp":
34696
- return _cloneRegExp(value);
34697
- case "Int8Array":
34698
- case "Uint8Array":
34699
- case "Uint8ClampedArray":
34700
- case "Int16Array":
34701
- case "Uint16Array":
34702
- case "Int32Array":
34703
- case "Uint32Array":
34704
- case "Float32Array":
34705
- case "Float64Array":
34706
- case "BigInt64Array":
34707
- case "BigUint64Array":
34708
- return value.slice();
34709
- default:
34710
- return value;
34711
- }
34712
- }
34713
- function _isPrimitive(param) {
34714
- var type3 = typeof param;
34715
- return param == null || type3 != "object" && type3 != "function";
34716
- }
34717
- var _ObjectMap = /* @__PURE__ */ function() {
34718
- function _ObjectMap2() {
34719
- this.map = {};
34720
- this.length = 0;
34721
- }
34722
- _ObjectMap2.prototype.set = function(key, value) {
34723
- const hashedKey = this.hash(key);
34724
- let bucket = this.map[hashedKey];
34725
- if (!bucket) {
34726
- this.map[hashedKey] = bucket = [];
34727
- }
34728
- bucket.push([key, value]);
34729
- this.length += 1;
34730
- };
34731
- _ObjectMap2.prototype.hash = function(key) {
34732
- let hashedKey = [];
34733
- for (var value in key) {
34734
- hashedKey.push(Object.prototype.toString.call(key[value]));
34735
- }
34736
- return hashedKey.join();
34737
- };
34738
- _ObjectMap2.prototype.get = function(key) {
34739
- if (this.length <= 180) {
34740
- for (const p in this.map) {
34741
- const bucket2 = this.map[p];
34742
- for (let i = 0; i < bucket2.length; i += 1) {
34743
- const element = bucket2[i];
34744
- if (element[0] === key) {
34745
- return element[1];
34746
- }
34747
- }
34748
- }
34749
- return;
34750
- }
34751
- const hashedKey = this.hash(key);
34752
- const bucket = this.map[hashedKey];
34753
- if (!bucket) {
34754
- return;
34755
- }
34756
- for (let i = 0; i < bucket.length; i += 1) {
34757
- const element = bucket[i];
34758
- if (element[0] === key) {
34759
- return element[1];
34760
- }
34761
- }
34762
- };
34763
- return _ObjectMap2;
34764
- }();
34765
-
34766
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
34767
- var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
34768
- return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
34769
- });
34770
- var clone_default = clone2;
34771
-
34772
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
34773
- var hasProtoTrim = typeof String.prototype.trim === "function";
34774
-
34775
34796
  // ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
34776
34797
  var __assign = function() {
34777
34798
  __assign = Object.assign || function __assign2(t) {
@@ -37937,16 +37958,20 @@ spurious results.`);
37937
37958
  var lib_default2 = gql;
37938
37959
 
37939
37960
  // src/providers/__generated__/operations.ts
37961
+ var TransactionStatusSubscriptionFragmentFragmentDoc = lib_default2`
37962
+ fragment transactionStatusSubscriptionFragment on TransactionStatus {
37963
+ type: __typename
37964
+ ... on SqueezedOutStatus {
37965
+ reason
37966
+ }
37967
+ }
37968
+ `;
37940
37969
  var ReceiptFragmentFragmentDoc = lib_default2`
37941
37970
  fragment receiptFragment on Receipt {
37942
- contract {
37943
- id
37944
- }
37971
+ id
37945
37972
  pc
37946
37973
  is
37947
- to {
37948
- id
37949
- }
37974
+ to
37950
37975
  toAddress
37951
37976
  amount
37952
37977
  assetId
@@ -37984,10 +38009,16 @@ spurious results.`);
37984
38009
  id
37985
38010
  }
37986
38011
  time
38012
+ receipts {
38013
+ ...receiptFragment
38014
+ }
37987
38015
  programState {
37988
38016
  returnType
37989
38017
  data
37990
38018
  }
38019
+ receipts {
38020
+ ...receiptFragment
38021
+ }
37991
38022
  }
37992
38023
  ... on FailureStatus {
37993
38024
  block {
@@ -37995,26 +38026,24 @@ spurious results.`);
37995
38026
  }
37996
38027
  time
37997
38028
  reason
38029
+ receipts {
38030
+ ...receiptFragment
38031
+ }
37998
38032
  }
37999
38033
  ... on SqueezedOutStatus {
38000
38034
  reason
38001
38035
  }
38002
38036
  }
38003
- `;
38037
+ ${ReceiptFragmentFragmentDoc}`;
38004
38038
  var TransactionFragmentFragmentDoc = lib_default2`
38005
38039
  fragment transactionFragment on Transaction {
38006
38040
  id
38007
38041
  rawPayload
38008
- gasPrice
38009
- receipts {
38010
- ...receiptFragment
38011
- }
38012
38042
  status {
38013
38043
  ...transactionStatusFragment
38014
38044
  }
38015
38045
  }
38016
- ${ReceiptFragmentFragmentDoc}
38017
- ${TransactionStatusFragmentFragmentDoc}`;
38046
+ ${TransactionStatusFragmentFragmentDoc}`;
38018
38047
  var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
38019
38048
  fragment inputEstimatePredicatesFragment on Input {
38020
38049
  ... on InputCoin {
@@ -38032,6 +38061,46 @@ ${TransactionStatusFragmentFragmentDoc}`;
38032
38061
  }
38033
38062
  }
38034
38063
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
38064
+ var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
38065
+ fragment dryRunFailureStatusFragment on DryRunFailureStatus {
38066
+ reason
38067
+ programState {
38068
+ returnType
38069
+ data
38070
+ }
38071
+ }
38072
+ `;
38073
+ var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
38074
+ fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
38075
+ programState {
38076
+ returnType
38077
+ data
38078
+ }
38079
+ }
38080
+ `;
38081
+ var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
38082
+ fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
38083
+ ... on DryRunFailureStatus {
38084
+ ...dryRunFailureStatusFragment
38085
+ }
38086
+ ... on DryRunSuccessStatus {
38087
+ ...dryRunSuccessStatusFragment
38088
+ }
38089
+ }
38090
+ ${DryRunFailureStatusFragmentFragmentDoc}
38091
+ ${DryRunSuccessStatusFragmentFragmentDoc}`;
38092
+ var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
38093
+ fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
38094
+ id
38095
+ status {
38096
+ ...dryRunTransactionStatusFragment
38097
+ }
38098
+ receipts {
38099
+ ...receiptFragment
38100
+ }
38101
+ }
38102
+ ${DryRunTransactionStatusFragmentFragmentDoc}
38103
+ ${ReceiptFragmentFragmentDoc}`;
38035
38104
  var CoinFragmentFragmentDoc = lib_default2`
38036
38105
  fragment coinFragment on Coin {
38037
38106
  __typename
@@ -38039,7 +38108,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38039
38108
  owner
38040
38109
  amount
38041
38110
  assetId
38042
- maturity
38043
38111
  blockCreated
38044
38112
  txCreatedIdx
38045
38113
  }
@@ -38078,26 +38146,32 @@ ${TransactionStatusFragmentFragmentDoc}`;
38078
38146
  messageBlockHeader {
38079
38147
  id
38080
38148
  daHeight
38149
+ consensusParametersVersion
38150
+ stateTransitionBytecodeVersion
38081
38151
  transactionsCount
38152
+ messageReceiptCount
38082
38153
  transactionsRoot
38154
+ messageOutboxRoot
38155
+ eventInboxRoot
38083
38156
  height
38084
38157
  prevRoot
38085
38158
  time
38086
38159
  applicationHash
38087
- messageReceiptRoot
38088
- messageReceiptCount
38089
38160
  }
38090
38161
  commitBlockHeader {
38091
38162
  id
38092
38163
  daHeight
38164
+ consensusParametersVersion
38165
+ stateTransitionBytecodeVersion
38093
38166
  transactionsCount
38167
+ messageReceiptCount
38094
38168
  transactionsRoot
38169
+ messageOutboxRoot
38170
+ eventInboxRoot
38095
38171
  height
38096
38172
  prevRoot
38097
38173
  time
38098
38174
  applicationHash
38099
- messageReceiptRoot
38100
- messageReceiptCount
38101
38175
  }
38102
38176
  sender
38103
38177
  recipient
@@ -38116,8 +38190,8 @@ ${TransactionStatusFragmentFragmentDoc}`;
38116
38190
  var BlockFragmentFragmentDoc = lib_default2`
38117
38191
  fragment blockFragment on Block {
38118
38192
  id
38193
+ height
38119
38194
  header {
38120
- height
38121
38195
  time
38122
38196
  }
38123
38197
  transactions {
@@ -38127,6 +38201,7 @@ ${TransactionStatusFragmentFragmentDoc}`;
38127
38201
  `;
38128
38202
  var TxParametersFragmentFragmentDoc = lib_default2`
38129
38203
  fragment TxParametersFragment on TxParameters {
38204
+ version
38130
38205
  maxInputs
38131
38206
  maxOutputs
38132
38207
  maxWitnesses
@@ -38136,6 +38211,7 @@ ${TransactionStatusFragmentFragmentDoc}`;
38136
38211
  `;
38137
38212
  var PredicateParametersFragmentFragmentDoc = lib_default2`
38138
38213
  fragment PredicateParametersFragment on PredicateParameters {
38214
+ version
38139
38215
  maxPredicateLength
38140
38216
  maxPredicateDataLength
38141
38217
  maxGasPerPredicate
@@ -38144,18 +38220,21 @@ ${TransactionStatusFragmentFragmentDoc}`;
38144
38220
  `;
38145
38221
  var ScriptParametersFragmentFragmentDoc = lib_default2`
38146
38222
  fragment ScriptParametersFragment on ScriptParameters {
38223
+ version
38147
38224
  maxScriptLength
38148
38225
  maxScriptDataLength
38149
38226
  }
38150
38227
  `;
38151
38228
  var ContractParametersFragmentFragmentDoc = lib_default2`
38152
38229
  fragment ContractParametersFragment on ContractParameters {
38230
+ version
38153
38231
  contractMaxSize
38154
38232
  maxStorageSlots
38155
38233
  }
38156
38234
  `;
38157
38235
  var FeeParametersFragmentFragmentDoc = lib_default2`
38158
38236
  fragment FeeParametersFragment on FeeParameters {
38237
+ version
38159
38238
  gasPriceFactor
38160
38239
  gasPerByte
38161
38240
  }
@@ -38175,6 +38254,7 @@ ${TransactionStatusFragmentFragmentDoc}`;
38175
38254
  `;
38176
38255
  var GasCostsFragmentFragmentDoc = lib_default2`
38177
38256
  fragment GasCostsFragment on GasCosts {
38257
+ version
38178
38258
  add
38179
38259
  addi
38180
38260
  aloc
@@ -38187,7 +38267,6 @@ ${TransactionStatusFragmentFragmentDoc}`;
38187
38267
  cb
38188
38268
  cfei
38189
38269
  cfsi
38190
- croo
38191
38270
  div
38192
38271
  divi
38193
38272
  ecr1
@@ -38270,6 +38349,9 @@ ${TransactionStatusFragmentFragmentDoc}`;
38270
38349
  ccp {
38271
38350
  ...DependentCostFragment
38272
38351
  }
38352
+ croo {
38353
+ ...DependentCostFragment
38354
+ }
38273
38355
  csiz {
38274
38356
  ...DependentCostFragment
38275
38357
  }
@@ -38329,6 +38411,7 @@ ${TransactionStatusFragmentFragmentDoc}`;
38329
38411
  ${DependentCostFragmentFragmentDoc}`;
38330
38412
  var ConsensusParametersFragmentFragmentDoc = lib_default2`
38331
38413
  fragment consensusParametersFragment on ConsensusParameters {
38414
+ version
38332
38415
  txParams {
38333
38416
  ...TxParametersFragment
38334
38417
  }
@@ -38388,18 +38471,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38388
38471
  fragment nodeInfoFragment on NodeInfo {
38389
38472
  utxoValidation
38390
38473
  vmBacktrace
38391
- minGasPrice
38392
38474
  maxTx
38393
38475
  maxDepth
38394
38476
  nodeVersion
38395
- peers {
38396
- id
38397
- addresses
38398
- clientVersion
38399
- blockHeight
38400
- lastHeartbeatMs
38401
- appScore
38402
- }
38403
38477
  }
38404
38478
  `;
38405
38479
  var GetVersionDocument = lib_default2`
@@ -38434,13 +38508,9 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38434
38508
  query getTransactionWithReceipts($transactionId: TransactionId!) {
38435
38509
  transaction(id: $transactionId) {
38436
38510
  ...transactionFragment
38437
- receipts {
38438
- ...receiptFragment
38439
- }
38440
38511
  }
38441
38512
  }
38442
- ${TransactionFragmentFragmentDoc}
38443
- ${ReceiptFragmentFragmentDoc}`;
38513
+ ${TransactionFragmentFragmentDoc}`;
38444
38514
  var GetTransactionsDocument = lib_default2`
38445
38515
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
38446
38516
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -38568,6 +38638,20 @@ ${MessageCoinFragmentFragmentDoc}`;
38568
38638
  }
38569
38639
  }
38570
38640
  ${BalanceFragmentFragmentDoc}`;
38641
+ var GetLatestGasPriceDocument = lib_default2`
38642
+ query getLatestGasPrice {
38643
+ latestGasPrice {
38644
+ gasPrice
38645
+ }
38646
+ }
38647
+ `;
38648
+ var EstimateGasPriceDocument = lib_default2`
38649
+ query estimateGasPrice($blockHorizon: U32!) {
38650
+ estimateGasPrice(blockHorizon: $blockHorizon) {
38651
+ gasPrice
38652
+ }
38653
+ }
38654
+ `;
38571
38655
  var GetBalancesDocument = lib_default2`
38572
38656
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
38573
38657
  balances(
@@ -38622,12 +38706,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38622
38706
  }
38623
38707
  `;
38624
38708
  var DryRunDocument = lib_default2`
38625
- mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
38626
- dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
38627
- ...receiptFragment
38709
+ mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
38710
+ dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
38711
+ ...dryRunTransactionExecutionStatusFragment
38628
38712
  }
38629
38713
  }
38630
- ${ReceiptFragmentFragmentDoc}`;
38714
+ ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
38631
38715
  var SubmitDocument = lib_default2`
38632
38716
  mutation submit($encodedTransaction: HexString!) {
38633
38717
  submit(tx: $encodedTransaction) {
@@ -38646,17 +38730,17 @@ ${MessageCoinFragmentFragmentDoc}`;
38646
38730
  var SubmitAndAwaitDocument = lib_default2`
38647
38731
  subscription submitAndAwait($encodedTransaction: HexString!) {
38648
38732
  submitAndAwait(tx: $encodedTransaction) {
38649
- ...transactionStatusFragment
38733
+ ...transactionStatusSubscriptionFragment
38650
38734
  }
38651
38735
  }
38652
- ${TransactionStatusFragmentFragmentDoc}`;
38736
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
38653
38737
  var StatusChangeDocument = lib_default2`
38654
38738
  subscription statusChange($transactionId: TransactionId!) {
38655
38739
  statusChange(id: $transactionId) {
38656
- ...transactionStatusFragment
38740
+ ...transactionStatusSubscriptionFragment
38657
38741
  }
38658
38742
  }
38659
- ${TransactionStatusFragmentFragmentDoc}`;
38743
+ ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
38660
38744
  function getSdk(requester) {
38661
38745
  return {
38662
38746
  getVersion(variables, options) {
@@ -38710,6 +38794,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38710
38794
  getBalance(variables, options) {
38711
38795
  return requester(GetBalanceDocument, variables, options);
38712
38796
  },
38797
+ getLatestGasPrice(variables, options) {
38798
+ return requester(GetLatestGasPriceDocument, variables, options);
38799
+ },
38800
+ estimateGasPrice(variables, options) {
38801
+ return requester(EstimateGasPriceDocument, variables, options);
38802
+ },
38713
38803
  getBalances(variables, options) {
38714
38804
  return requester(GetBalancesDocument, variables, options);
38715
38805
  },
@@ -38874,6 +38964,9 @@ ${MessageCoinFragmentFragmentDoc}`;
38874
38964
  }
38875
38965
  };
38876
38966
 
38967
+ // ../address/dist/configs.mjs
38968
+ var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
38969
+
38877
38970
  // src/providers/transaction-request/input.ts
38878
38971
  var inputify = (value) => {
38879
38972
  const { type: type3 } = value;
@@ -38893,10 +38986,9 @@ ${MessageCoinFragmentFragmentDoc}`;
38893
38986
  txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
38894
38987
  },
38895
38988
  witnessIndex: value.witnessIndex,
38896
- maturity: value.maturity ?? 0,
38897
38989
  predicateGasUsed: bn(value.predicateGasUsed),
38898
- predicateLength: predicate.length,
38899
- predicateDataLength: predicateData.length,
38990
+ predicateLength: bn(predicate.length),
38991
+ predicateDataLength: bn(predicateData.length),
38900
38992
  predicate: hexlify(predicate),
38901
38993
  predicateData: hexlify(predicateData)
38902
38994
  };
@@ -38927,8 +39019,8 @@ ${MessageCoinFragmentFragmentDoc}`;
38927
39019
  nonce: hexlify(value.nonce),
38928
39020
  witnessIndex: value.witnessIndex,
38929
39021
  predicateGasUsed: bn(value.predicateGasUsed),
38930
- predicateLength: predicate.length,
38931
- predicateDataLength: predicateData.length,
39022
+ predicateLength: bn(predicate.length),
39023
+ predicateDataLength: bn(predicateData.length),
38932
39024
  predicate: hexlify(predicate),
38933
39025
  predicateData: hexlify(predicateData),
38934
39026
  data: hexlify(data),
@@ -39088,8 +39180,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39088
39180
  case "CALL" /* Call */: {
39089
39181
  const callReceipt = {
39090
39182
  type: ReceiptType.Call,
39091
- from: hexOrZero(receipt.contract?.id),
39092
- to: hexOrZero(receipt?.to?.id),
39183
+ from: hexOrZero(receipt.id || receipt.contractId),
39184
+ to: hexOrZero(receipt?.to),
39093
39185
  amount: bn(receipt.amount),
39094
39186
  assetId: hexOrZero(receipt.assetId),
39095
39187
  gas: bn(receipt.gas),
@@ -39103,7 +39195,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39103
39195
  case "RETURN" /* Return */: {
39104
39196
  const returnReceipt = {
39105
39197
  type: ReceiptType.Return,
39106
- id: hexOrZero(receipt.contract?.id),
39198
+ id: hexOrZero(receipt.id || receipt.contractId),
39107
39199
  val: bn(receipt.val),
39108
39200
  pc: bn(receipt.pc),
39109
39201
  is: bn(receipt.is)
@@ -39113,7 +39205,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39113
39205
  case "RETURN_DATA" /* ReturnData */: {
39114
39206
  const returnDataReceipt = {
39115
39207
  type: ReceiptType.ReturnData,
39116
- id: hexOrZero(receipt.contract?.id),
39208
+ id: hexOrZero(receipt.id || receipt.contractId),
39117
39209
  ptr: bn(receipt.ptr),
39118
39210
  len: bn(receipt.len),
39119
39211
  digest: hexOrZero(receipt.digest),
@@ -39125,7 +39217,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39125
39217
  case "PANIC" /* Panic */: {
39126
39218
  const panicReceipt = {
39127
39219
  type: ReceiptType.Panic,
39128
- id: hexOrZero(receipt.contract?.id),
39220
+ id: hexOrZero(receipt.id),
39129
39221
  reason: bn(receipt.reason),
39130
39222
  pc: bn(receipt.pc),
39131
39223
  is: bn(receipt.is),
@@ -39136,7 +39228,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39136
39228
  case "REVERT" /* Revert */: {
39137
39229
  const revertReceipt = {
39138
39230
  type: ReceiptType.Revert,
39139
- id: hexOrZero(receipt.contract?.id),
39231
+ id: hexOrZero(receipt.id || receipt.contractId),
39140
39232
  val: bn(receipt.ra),
39141
39233
  pc: bn(receipt.pc),
39142
39234
  is: bn(receipt.is)
@@ -39146,7 +39238,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39146
39238
  case "LOG" /* Log */: {
39147
39239
  const logReceipt = {
39148
39240
  type: ReceiptType.Log,
39149
- id: hexOrZero(receipt.contract?.id),
39241
+ id: hexOrZero(receipt.id || receipt.contractId),
39150
39242
  val0: bn(receipt.ra),
39151
39243
  val1: bn(receipt.rb),
39152
39244
  val2: bn(receipt.rc),
@@ -39159,7 +39251,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39159
39251
  case "LOG_DATA" /* LogData */: {
39160
39252
  const logDataReceipt = {
39161
39253
  type: ReceiptType.LogData,
39162
- id: hexOrZero(receipt.contract?.id),
39254
+ id: hexOrZero(receipt.id || receipt.contractId),
39163
39255
  val0: bn(receipt.ra),
39164
39256
  val1: bn(receipt.rb),
39165
39257
  ptr: bn(receipt.ptr),
@@ -39173,8 +39265,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39173
39265
  case "TRANSFER" /* Transfer */: {
39174
39266
  const transferReceipt = {
39175
39267
  type: ReceiptType.Transfer,
39176
- from: hexOrZero(receipt.contract?.id),
39177
- to: hexOrZero(receipt.toAddress || receipt?.to?.id),
39268
+ from: hexOrZero(receipt.id || receipt.contractId),
39269
+ to: hexOrZero(receipt.toAddress || receipt?.to),
39178
39270
  amount: bn(receipt.amount),
39179
39271
  assetId: hexOrZero(receipt.assetId),
39180
39272
  pc: bn(receipt.pc),
@@ -39185,8 +39277,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39185
39277
  case "TRANSFER_OUT" /* TransferOut */: {
39186
39278
  const transferOutReceipt = {
39187
39279
  type: ReceiptType.TransferOut,
39188
- from: hexOrZero(receipt.contract?.id),
39189
- to: hexOrZero(receipt.toAddress || receipt.to?.id),
39280
+ from: hexOrZero(receipt.id || receipt.contractId),
39281
+ to: hexOrZero(receipt.toAddress || receipt.to),
39190
39282
  amount: bn(receipt.amount),
39191
39283
  assetId: hexOrZero(receipt.assetId),
39192
39284
  pc: bn(receipt.pc),
@@ -39229,7 +39321,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39229
39321
  return receiptMessageOut;
39230
39322
  }
39231
39323
  case "MINT" /* Mint */: {
39232
- const contractId = hexOrZero(receipt.contract?.id);
39324
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
39233
39325
  const subId = hexOrZero(receipt.subId);
39234
39326
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
39235
39327
  const mintReceipt = {
@@ -39244,7 +39336,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39244
39336
  return mintReceipt;
39245
39337
  }
39246
39338
  case "BURN" /* Burn */: {
39247
- const contractId = hexOrZero(receipt.contract?.id);
39339
+ const contractId = hexOrZero(receipt.id || receipt.contractId);
39248
39340
  const subId = hexOrZero(receipt.subId);
39249
39341
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
39250
39342
  const burnReceipt = {
@@ -39325,7 +39417,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39325
39417
  };
39326
39418
 
39327
39419
  // src/providers/utils/gas.ts
39328
- var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
39329
39420
  var getGasUsedFromReceipts = (receipts) => {
39330
39421
  const scriptResult = receipts.filter(
39331
39422
  (receipt) => receipt.type === ReceiptType.ScriptResult
@@ -39346,18 +39437,28 @@ ${MessageCoinFragmentFragmentDoc}`;
39346
39437
  }
39347
39438
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
39348
39439
  const witnessCache = [];
39349
- const totalGas = inputs.reduce((total, input) => {
39440
+ const chargeableInputs = inputs.filter((input) => {
39441
+ const isCoinOrMessage = "owner" in input || "sender" in input;
39442
+ if (isCoinOrMessage) {
39443
+ if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39444
+ return true;
39445
+ }
39446
+ if (!witnessCache.includes(input.witnessIndex)) {
39447
+ witnessCache.push(input.witnessIndex);
39448
+ return true;
39449
+ }
39450
+ }
39451
+ return false;
39452
+ });
39453
+ const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
39454
+ const totalGas = chargeableInputs.reduce((total, input) => {
39350
39455
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39351
39456
  return total.add(
39352
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39457
+ vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39353
39458
  );
39354
39459
  }
39355
- if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
39356
- witnessCache.push(input.witnessIndex);
39357
- return total.add(gasCosts.ecr1);
39358
- }
39359
- return total;
39360
- }, bn());
39460
+ return total.add(gasCosts.ecr1);
39461
+ }, bn(0));
39361
39462
  return totalGas;
39362
39463
  }
39363
39464
  function getMinGas(params) {
@@ -39369,12 +39470,20 @@ ${MessageCoinFragmentFragmentDoc}`;
39369
39470
  return minGas;
39370
39471
  }
39371
39472
  function getMaxGas(params) {
39372
- const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
39473
+ const {
39474
+ gasPerByte,
39475
+ witnessesLength,
39476
+ witnessLimit,
39477
+ minGas,
39478
+ gasLimit = bn(0),
39479
+ maxGasPerTx
39480
+ } = params;
39373
39481
  let remainingAllowedWitnessGas = bn(0);
39374
39482
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
39375
39483
  remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
39376
39484
  }
39377
- return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39485
+ const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39486
+ return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
39378
39487
  }
39379
39488
  function calculateMetadataGasForTxCreate({
39380
39489
  gasCosts,
@@ -39396,6 +39505,10 @@ ${MessageCoinFragmentFragmentDoc}`;
39396
39505
  }) {
39397
39506
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
39398
39507
  }
39508
+ var calculateGasFee = (params) => {
39509
+ const { gas, gasPrice, priceFactor, tip } = params;
39510
+ return gas.mul(gasPrice).div(priceFactor).add(tip);
39511
+ };
39399
39512
 
39400
39513
  // src/providers/utils/json.ts
39401
39514
  function normalize2(object) {
@@ -39537,7 +39650,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39537
39650
  // src/providers/transaction-request/transaction-request.ts
39538
39651
  var BaseTransactionRequest = class {
39539
39652
  /** Gas price for transaction */
39540
- gasPrice;
39653
+ tip;
39541
39654
  /** Block until which tx cannot be included */
39542
39655
  maturity;
39543
39656
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -39556,7 +39669,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39556
39669
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
39557
39670
  */
39558
39671
  constructor({
39559
- gasPrice,
39672
+ tip,
39560
39673
  maturity,
39561
39674
  maxFee,
39562
39675
  witnessLimit,
@@ -39564,7 +39677,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39564
39677
  outputs,
39565
39678
  witnesses
39566
39679
  } = {}) {
39567
- this.gasPrice = bn(gasPrice);
39680
+ this.tip = bn(tip);
39568
39681
  this.maturity = maturity ?? 0;
39569
39682
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
39570
39683
  this.maxFee = maxFee ? bn(maxFee) : void 0;
@@ -39575,9 +39688,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39575
39688
  static getPolicyMeta(req) {
39576
39689
  let policyTypes = 0;
39577
39690
  const policies = [];
39578
- if (req.gasPrice) {
39579
- policyTypes += PolicyType.GasPrice;
39580
- policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
39691
+ if (req.tip) {
39692
+ policyTypes += PolicyType.Tip;
39693
+ policies.push({ data: req.tip, type: PolicyType.Tip });
39581
39694
  }
39582
39695
  if (req.witnessLimit) {
39583
39696
  policyTypes += PolicyType.WitnessLimit;
@@ -39761,13 +39874,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39761
39874
  * assetId, if one it was not added yet.
39762
39875
  *
39763
39876
  * @param coin - Coin resource.
39764
- * @param predicate - Predicate bytes.
39765
- * @param predicateData - Predicate data bytes.
39766
39877
  */
39767
- addCoinInput(coin, predicate) {
39878
+ addCoinInput(coin) {
39768
39879
  const { assetId, owner, amount } = coin;
39769
39880
  let witnessIndex;
39770
- if (predicate) {
39881
+ if (coin.predicate) {
39771
39882
  witnessIndex = 0;
39772
39883
  } else {
39773
39884
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -39782,25 +39893,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39782
39893
  amount,
39783
39894
  assetId,
39784
39895
  txPointer: "0x00000000000000000000000000000000",
39785
- witnessIndex,
39786
- predicate: predicate?.bytes
39896
+ witnessIndex
39787
39897
  };
39788
39898
  this.pushInput(input);
39789
39899
  this.addChangeOutput(owner, assetId);
39790
39900
  }
39791
39901
  /**
39792
39902
  * Adds a single message input to the transaction and a change output for the
39793
- * baseAssetId, if one it was not added yet.
39903
+ * asset against the message
39794
39904
  *
39795
39905
  * @param message - Message resource.
39796
- * @param predicate - Predicate bytes.
39797
- * @param predicateData - Predicate data bytes.
39798
39906
  */
39799
- addMessageInput(message, predicate) {
39800
- const { recipient, sender, amount } = message;
39801
- const assetId = BaseAssetId;
39907
+ addMessageInput(message) {
39908
+ const { recipient, sender, amount, assetId } = message;
39802
39909
  let witnessIndex;
39803
- if (predicate) {
39910
+ if (message.predicate) {
39804
39911
  witnessIndex = 0;
39805
39912
  } else {
39806
39913
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -39814,8 +39921,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39814
39921
  sender: sender.toB256(),
39815
39922
  recipient: recipient.toB256(),
39816
39923
  amount,
39817
- witnessIndex,
39818
- predicate: predicate?.bytes
39924
+ witnessIndex
39819
39925
  };
39820
39926
  this.pushInput(input);
39821
39927
  this.addChangeOutput(recipient, assetId);
@@ -39846,32 +39952,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39846
39952
  resources.forEach((resource) => this.addResource(resource));
39847
39953
  return this;
39848
39954
  }
39849
- /**
39850
- * Adds multiple resources to the transaction by adding coin/message inputs and change
39851
- * outputs from the related assetIds.
39852
- *
39853
- * @param resources - The resources to add.
39854
- * @returns This transaction.
39855
- */
39856
- addPredicateResource(resource, predicate) {
39857
- if (isCoin(resource)) {
39858
- this.addCoinInput(resource, predicate);
39859
- } else {
39860
- this.addMessageInput(resource, predicate);
39861
- }
39862
- return this;
39863
- }
39864
- /**
39865
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
39866
- * from the related assetIds.
39867
- *
39868
- * @param resources - The resources to add.
39869
- * @returns This transaction.
39870
- */
39871
- addPredicateResources(resources, predicate) {
39872
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
39873
- return this;
39874
- }
39875
39955
  /**
39876
39956
  * Adds a coin output to the transaction.
39877
39957
  *
@@ -39879,7 +39959,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39879
39959
  * @param amount - Amount of coin.
39880
39960
  * @param assetId - Asset ID of coin.
39881
39961
  */
39882
- addCoinOutput(to, amount, assetId = BaseAssetId) {
39962
+ addCoinOutput(to, amount, assetId) {
39883
39963
  this.pushOutput({
39884
39964
  type: OutputType.Coin,
39885
39965
  to: addressify(to).toB256(),
@@ -39911,7 +39991,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39911
39991
  * @param to - Address of the owner.
39912
39992
  * @param assetId - Asset ID of coin.
39913
39993
  */
39914
- addChangeOutput(to, assetId = BaseAssetId) {
39994
+ addChangeOutput(to, assetId) {
39915
39995
  const changeOutput = this.getChangeOutputs().find(
39916
39996
  (output3) => hexlify(output3.assetId) === assetId
39917
39997
  );
@@ -39951,7 +40031,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39951
40031
  }
39952
40032
  calculateMaxGas(chainInfo, minGas) {
39953
40033
  const { consensusParameters } = chainInfo;
39954
- const { gasPerByte } = consensusParameters;
40034
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
39955
40035
  const witnessesLength = this.toTransaction().witnesses.reduce(
39956
40036
  (acc, wit) => acc + wit.dataLength,
39957
40037
  0
@@ -39960,7 +40040,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39960
40040
  gasPerByte,
39961
40041
  minGas,
39962
40042
  witnessesLength,
39963
- witnessLimit: this.witnessLimit
40043
+ witnessLimit: this.witnessLimit,
40044
+ maxGasPerTx
39964
40045
  });
39965
40046
  }
39966
40047
  /**
@@ -39968,8 +40049,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39968
40049
  * quantities array.
39969
40050
  *
39970
40051
  * @param quantities - CoinQuantity Array.
40052
+ * @param baseAssetId - The base asset to fund the transaction.
39971
40053
  */
39972
- fundWithFakeUtxos(quantities, resourcesOwner) {
40054
+ fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
39973
40055
  const findAssetInput = (assetId) => this.inputs.find((input) => {
39974
40056
  if ("assetId" in input) {
39975
40057
  return input.assetId === assetId;
@@ -39978,24 +40060,27 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39978
40060
  });
39979
40061
  const updateAssetInput = (assetId, quantity) => {
39980
40062
  const assetInput = findAssetInput(assetId);
40063
+ let usedQuantity = quantity;
40064
+ if (assetId === baseAssetId) {
40065
+ usedQuantity = bn("1000000000000000000");
40066
+ }
39981
40067
  if (assetInput && "assetId" in assetInput) {
39982
40068
  assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
39983
- assetInput.amount = quantity;
40069
+ assetInput.amount = usedQuantity;
39984
40070
  } else {
39985
40071
  this.addResources([
39986
40072
  {
39987
40073
  id: hexlify(randomBytes22(UTXO_ID_LEN)),
39988
- amount: quantity,
40074
+ amount: usedQuantity,
39989
40075
  assetId,
39990
40076
  owner: resourcesOwner || Address.fromRandom(),
39991
- maturity: 0,
39992
40077
  blockCreated: bn(1),
39993
40078
  txCreatedIdx: bn(1)
39994
40079
  }
39995
40080
  ]);
39996
40081
  }
39997
40082
  };
39998
- updateAssetInput(BaseAssetId, bn(1e11));
40083
+ updateAssetInput(baseAssetId, bn(1e11));
39999
40084
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
40000
40085
  }
40001
40086
  /**
@@ -40020,7 +40105,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40020
40105
  toJSON() {
40021
40106
  return normalizeJSON(this);
40022
40107
  }
40023
- updatePredicateInputs(inputs) {
40108
+ updatePredicateGasUsed(inputs) {
40024
40109
  this.inputs.forEach((i) => {
40025
40110
  let correspondingInput;
40026
40111
  switch (i.type) {
@@ -40042,6 +40127,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40042
40127
  }
40043
40128
  });
40044
40129
  }
40130
+ shiftPredicateData() {
40131
+ this.inputs.forEach((input) => {
40132
+ if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
40133
+ input.predicateData = input.padPredicateData(
40134
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
40135
+ );
40136
+ }
40137
+ });
40138
+ }
40045
40139
  };
40046
40140
 
40047
40141
  // src/providers/transaction-request/hash-transaction.ts
@@ -40152,12 +40246,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40152
40246
  *
40153
40247
  * @param createTransactionRequestLike - The initial values for the instance
40154
40248
  */
40155
- constructor({
40156
- bytecodeWitnessIndex,
40157
- salt,
40158
- storageSlots,
40159
- ...rest
40160
- } = {}) {
40249
+ constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
40161
40250
  super(rest);
40162
40251
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
40163
40252
  this.salt = hexlify(salt ?? ZeroBytes32);
@@ -40175,9 +40264,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40175
40264
  return {
40176
40265
  type: TransactionType.Create,
40177
40266
  ...baseTransaction,
40178
- bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
40179
40267
  bytecodeWitnessIndex,
40180
- storageSlotsCount: storageSlots.length,
40268
+ storageSlotsCount: bn(storageSlots.length),
40181
40269
  salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
40182
40270
  storageSlots
40183
40271
  };
@@ -40291,8 +40379,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40291
40379
  type: TransactionType.Script,
40292
40380
  scriptGasLimit: this.gasLimit,
40293
40381
  ...super.getBaseTransaction(),
40294
- scriptLength: script.length,
40295
- scriptDataLength: scriptData.length,
40382
+ scriptLength: bn(script.length),
40383
+ scriptDataLength: bn(scriptData.length),
40296
40384
  receiptsRoot: ZeroBytes32,
40297
40385
  script: hexlify(script),
40298
40386
  scriptData: hexlify(scriptData)
@@ -40356,7 +40444,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40356
40444
  }
40357
40445
  calculateMaxGas(chainInfo, minGas) {
40358
40446
  const { consensusParameters } = chainInfo;
40359
- const { gasPerByte } = consensusParameters;
40447
+ const { gasPerByte, maxGasPerTx } = consensusParameters;
40360
40448
  const witnessesLength = this.toTransaction().witnesses.reduce(
40361
40449
  (acc, wit) => acc + wit.dataLength,
40362
40450
  0
@@ -40366,7 +40454,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40366
40454
  minGas,
40367
40455
  witnessesLength,
40368
40456
  witnessLimit: this.witnessLimit,
40369
- gasLimit: this.gasLimit
40457
+ gasLimit: this.gasLimit,
40458
+ maxGasPerTx
40370
40459
  });
40371
40460
  }
40372
40461
  /**
@@ -40439,13 +40528,29 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40439
40528
  }
40440
40529
  }
40441
40530
  };
40531
+ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
40532
+ (acc, input) => {
40533
+ if (input.type === InputType.Coin && input.owner === owner) {
40534
+ acc.utxos.push(input.id);
40535
+ }
40536
+ if (input.type === InputType.Message && input.recipient === owner) {
40537
+ acc.messages.push(input.nonce);
40538
+ }
40539
+ return acc;
40540
+ },
40541
+ {
40542
+ utxos: [],
40543
+ messages: []
40544
+ }
40545
+ );
40442
40546
 
40443
40547
  // src/providers/transaction-summary/calculate-transaction-fee.ts
40444
40548
  var calculateTransactionFee = (params) => {
40445
40549
  const {
40446
- gasUsed,
40550
+ gasPrice,
40447
40551
  rawPayload,
40448
- consensusParameters: { gasCosts, feeParams }
40552
+ tip,
40553
+ consensusParameters: { gasCosts, feeParams, maxGasPerTx }
40449
40554
  } = params;
40450
40555
  const gasPerByte = bn(feeParams.gasPerByte);
40451
40556
  const gasPriceFactor = bn(feeParams.gasPriceFactor);
@@ -40455,8 +40560,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40455
40560
  return {
40456
40561
  fee: bn(0),
40457
40562
  minFee: bn(0),
40458
- maxFee: bn(0),
40459
- feeFromGasUsed: bn(0)
40563
+ maxFee: bn(0)
40460
40564
  };
40461
40565
  }
40462
40566
  const { type: type3, witnesses, inputs, policies } = transaction;
@@ -40488,7 +40592,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40488
40592
  metadataGas,
40489
40593
  txBytesSize: transactionBytes.length
40490
40594
  });
40491
- const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
40492
40595
  const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
40493
40596
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
40494
40597
  const maxGas = getMaxGas({
@@ -40496,17 +40599,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40496
40599
  minGas,
40497
40600
  witnessesLength,
40498
40601
  gasLimit,
40499
- witnessLimit
40602
+ witnessLimit,
40603
+ maxGasPerTx
40604
+ });
40605
+ const minFee = calculateGasFee({
40606
+ gasPrice,
40607
+ gas: minGas,
40608
+ priceFactor: gasPriceFactor,
40609
+ tip
40610
+ });
40611
+ const maxFee = calculateGasFee({
40612
+ gasPrice,
40613
+ gas: maxGas,
40614
+ priceFactor: gasPriceFactor,
40615
+ tip
40500
40616
  });
40501
- const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
40502
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
40503
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
40504
- const fee = minFee.add(feeFromGasUsed);
40505
40617
  return {
40506
- fee,
40507
40618
  minFee,
40508
40619
  maxFee,
40509
- feeFromGasUsed
40620
+ fee: maxFee
40510
40621
  };
40511
40622
  };
40512
40623
 
@@ -41107,7 +41218,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41107
41218
  gqlTransactionStatus,
41108
41219
  abiMap = {},
41109
41220
  maxInputs,
41110
- gasCosts
41221
+ gasCosts,
41222
+ maxGasPerTx,
41223
+ gasPrice
41111
41224
  } = params;
41112
41225
  const gasUsed = getGasUsedFromReceipts(receipts);
41113
41226
  const rawPayload = hexlify(transactionBytes);
@@ -41121,11 +41234,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41121
41234
  maxInputs
41122
41235
  });
41123
41236
  const typeName = getTransactionTypeName(transaction.type);
41237
+ const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
41124
41238
  const { fee } = calculateTransactionFee({
41125
- gasUsed,
41239
+ gasPrice,
41126
41240
  rawPayload,
41241
+ tip,
41127
41242
  consensusParameters: {
41128
41243
  gasCosts,
41244
+ maxGasPerTx,
41129
41245
  feeParams: {
41130
41246
  gasPerByte,
41131
41247
  gasPriceFactor
@@ -41261,8 +41377,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41261
41377
  const decodedTransaction = this.decodeTransaction(
41262
41378
  transaction
41263
41379
  );
41264
- const receipts = transaction.receipts?.map(processGqlReceipt) || [];
41265
- const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
41380
+ let txReceipts = [];
41381
+ if (transaction?.status && "receipts" in transaction.status) {
41382
+ txReceipts = transaction.status.receipts;
41383
+ }
41384
+ const receipts = txReceipts.map(processGqlReceipt) || [];
41385
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
41386
+ const gasPrice = await this.provider.getLatestGasPrice();
41266
41387
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
41267
41388
  const transactionSummary = assembleTransactionSummary({
41268
41389
  id: this.id,
@@ -41274,7 +41395,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41274
41395
  gasPriceFactor,
41275
41396
  abiMap: contractsAbiMap,
41276
41397
  maxInputs,
41277
- gasCosts
41398
+ gasCosts,
41399
+ maxGasPerTx,
41400
+ gasPrice
41278
41401
  });
41279
41402
  return transactionSummary;
41280
41403
  }
@@ -41380,7 +41503,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41380
41503
  }
41381
41504
 
41382
41505
  // src/providers/utils/merge-quantities.ts
41383
- var mergeQuantities = (arr1, arr2) => {
41506
+ var mergeQuantities = (...coinQuantities) => {
41384
41507
  const resultMap = {};
41385
41508
  function addToMap({ amount, assetId }) {
41386
41509
  if (resultMap[assetId]) {
@@ -41389,8 +41512,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41389
41512
  resultMap[assetId] = amount;
41390
41513
  }
41391
41514
  }
41392
- arr1.forEach(addToMap);
41393
- arr2.forEach(addToMap);
41515
+ coinQuantities.forEach((arr) => arr.forEach(addToMap));
41394
41516
  return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
41395
41517
  };
41396
41518
 
@@ -41418,12 +41540,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41418
41540
  gasPerByte: bn(feeParams.gasPerByte),
41419
41541
  maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
41420
41542
  chainId: bn(consensusParameters.chainId),
41543
+ baseAssetId: consensusParameters.baseAssetId,
41421
41544
  gasCosts
41422
41545
  },
41423
41546
  gasCosts,
41424
41547
  latestBlock: {
41425
41548
  id: latestBlock.id,
41426
- height: bn(latestBlock.header.height),
41549
+ height: bn(latestBlock.height),
41427
41550
  time: latestBlock.header.time,
41428
41551
  transactions: latestBlock.transactions.map((i) => ({
41429
41552
  id: i.id
@@ -41517,10 +41640,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41517
41640
  * Returns some helpful parameters related to gas fees.
41518
41641
  */
41519
41642
  getGasConfig() {
41520
- const { minGasPrice } = this.getNode();
41521
41643
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
41522
41644
  return {
41523
- minGasPrice,
41524
41645
  maxGasPerTx,
41525
41646
  maxGasPerPredicate,
41526
41647
  gasPriceFactor,
@@ -41618,7 +41739,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41618
41739
  */
41619
41740
  async getBlockNumber() {
41620
41741
  const { chain } = await this.operations.getChain();
41621
- return bn(chain.latestBlock.header.height, 10);
41742
+ return bn(chain.latestBlock.height, 10);
41622
41743
  }
41623
41744
  /**
41624
41745
  * Returns the chain information.
@@ -41630,11 +41751,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41630
41751
  const processedNodeInfo = {
41631
41752
  maxDepth: bn(nodeInfo.maxDepth),
41632
41753
  maxTx: bn(nodeInfo.maxTx),
41633
- minGasPrice: bn(nodeInfo.minGasPrice),
41634
41754
  nodeVersion: nodeInfo.nodeVersion,
41635
41755
  utxoValidation: nodeInfo.utxoValidation,
41636
- vmBacktrace: nodeInfo.vmBacktrace,
41637
- peers: nodeInfo.peers
41756
+ vmBacktrace: nodeInfo.vmBacktrace
41638
41757
  };
41639
41758
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
41640
41759
  return processedNodeInfo;
@@ -41660,6 +41779,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41660
41779
  } = this.getChain();
41661
41780
  return chainId.toNumber();
41662
41781
  }
41782
+ /**
41783
+ * Returns the base asset ID for the current provider network
41784
+ *
41785
+ * @returns the base asset ID
41786
+ */
41787
+ getBaseAssetId() {
41788
+ const {
41789
+ consensusParameters: { baseAssetId }
41790
+ } = this.getChain();
41791
+ return baseAssetId;
41792
+ }
41663
41793
  /**
41664
41794
  * Submits a transaction to the chain to be executed.
41665
41795
  *
@@ -41720,14 +41850,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41720
41850
  return this.estimateTxDependencies(transactionRequest);
41721
41851
  }
41722
41852
  const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41723
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41724
- encodedTransaction,
41853
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
41854
+ encodedTransactions: encodedTransaction,
41725
41855
  utxoValidation: utxoValidation || false
41726
41856
  });
41727
- const receipts = gqlReceipts.map(processGqlReceipt);
41728
- return {
41729
- receipts
41730
- };
41857
+ const [{ receipts: rawReceipts, status }] = dryRunStatuses;
41858
+ const receipts = rawReceipts.map(processGqlReceipt);
41859
+ return { receipts, dryrunStatus: status };
41731
41860
  }
41732
41861
  /**
41733
41862
  * Verifies whether enough gas is available to complete transaction.
@@ -41766,9 +41895,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41766
41895
  * If there are missing variable outputs,
41767
41896
  * `addVariableOutputs` is called on the transaction.
41768
41897
  *
41769
- * @privateRemarks
41770
- * TODO: Investigate support for missing contract IDs
41771
- * TODO: Add support for missing output messages
41772
41898
  *
41773
41899
  * @param transactionRequest - The transaction request object.
41774
41900
  * @returns A promise.
@@ -41781,16 +41907,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41781
41907
  missingContractIds: []
41782
41908
  };
41783
41909
  }
41784
- await this.estimatePredicates(transactionRequest);
41785
41910
  let receipts = [];
41786
41911
  const missingContractIds = [];
41787
41912
  let outputVariables = 0;
41913
+ let dryrunStatus;
41788
41914
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
41789
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41790
- encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
41915
+ const {
41916
+ dryRun: [{ receipts: rawReceipts, status }]
41917
+ } = await this.operations.dryRun({
41918
+ encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
41791
41919
  utxoValidation: false
41792
41920
  });
41793
- receipts = gqlReceipts.map(processGqlReceipt);
41921
+ receipts = rawReceipts.map(processGqlReceipt);
41922
+ dryrunStatus = status;
41794
41923
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
41795
41924
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
41796
41925
  if (hasMissingOutputs) {
@@ -41800,6 +41929,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41800
41929
  transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
41801
41930
  missingContractIds.push(contractId);
41802
41931
  });
41932
+ const { maxFee } = await this.estimateTxGasAndFee({
41933
+ transactionRequest
41934
+ });
41935
+ transactionRequest.maxFee = maxFee;
41803
41936
  } else {
41804
41937
  break;
41805
41938
  }
@@ -41807,37 +41940,136 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41807
41940
  return {
41808
41941
  receipts,
41809
41942
  outputVariables,
41810
- missingContractIds
41943
+ missingContractIds,
41944
+ dryrunStatus
41811
41945
  };
41812
41946
  }
41947
+ /**
41948
+ * Dry runs multiple transactions and checks for missing dependencies in batches.
41949
+ *
41950
+ * Transactions are dry run in batches. After each dry run, transactions requiring
41951
+ * further modifications are identified. The method iteratively updates these transactions
41952
+ * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
41953
+ *
41954
+ * @param transactionRequests - Array of transaction request objects.
41955
+ * @returns A promise that resolves to an array of results for each transaction.
41956
+ */
41957
+ async estimateMultipleTxDependencies(transactionRequests) {
41958
+ const results = transactionRequests.map(() => ({
41959
+ receipts: [],
41960
+ outputVariables: 0,
41961
+ missingContractIds: [],
41962
+ dryrunStatus: void 0
41963
+ }));
41964
+ const allRequests = clone_default(transactionRequests);
41965
+ const serializedTransactionsMap = /* @__PURE__ */ new Map();
41966
+ allRequests.forEach((req, index) => {
41967
+ if (req.type === TransactionType.Script) {
41968
+ serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
41969
+ }
41970
+ });
41971
+ let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
41972
+ let attempt = 0;
41973
+ while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
41974
+ const encodedTransactions = transactionsToProcess.map(
41975
+ (index) => serializedTransactionsMap.get(index)
41976
+ );
41977
+ const dryRunResults = await this.operations.dryRun({
41978
+ encodedTransactions,
41979
+ utxoValidation: false
41980
+ });
41981
+ const nextRoundTransactions = [];
41982
+ for (let i = 0; i < dryRunResults.dryRun.length; i++) {
41983
+ const requestIdx = transactionsToProcess[i];
41984
+ const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
41985
+ const result = results[requestIdx];
41986
+ result.receipts = rawReceipts.map(processGqlReceipt);
41987
+ result.dryrunStatus = status;
41988
+ const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
41989
+ result.receipts
41990
+ );
41991
+ const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
41992
+ const request = allRequests[requestIdx];
41993
+ if (hasMissingOutputs && request?.type === TransactionType.Script) {
41994
+ result.outputVariables += missingOutputVariables.length;
41995
+ request.addVariableOutputs(missingOutputVariables.length);
41996
+ missingOutputContractIds.forEach(({ contractId }) => {
41997
+ request.addContractInputAndOutput(Address.fromString(contractId));
41998
+ result.missingContractIds.push(contractId);
41999
+ });
42000
+ const { maxFee } = await this.estimateTxGasAndFee({
42001
+ transactionRequest: request
42002
+ });
42003
+ request.maxFee = maxFee;
42004
+ serializedTransactionsMap.set(requestIdx, hexlify(request.toTransactionBytes()));
42005
+ nextRoundTransactions.push(requestIdx);
42006
+ }
42007
+ }
42008
+ transactionsToProcess = nextRoundTransactions;
42009
+ attempt += 1;
42010
+ }
42011
+ return results;
42012
+ }
42013
+ async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
42014
+ if (estimateTxDependencies) {
42015
+ return this.estimateMultipleTxDependencies(transactionRequests);
42016
+ }
42017
+ const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
42018
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42019
+ encodedTransactions,
42020
+ utxoValidation: utxoValidation || false
42021
+ });
42022
+ const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
42023
+ const receipts = rawReceipts.map(processGqlReceipt);
42024
+ return { receipts, dryrunStatus: status };
42025
+ });
42026
+ return results;
42027
+ }
41813
42028
  /**
41814
42029
  * Estimates the transaction gas and fee based on the provided transaction request.
41815
42030
  * @param transactionRequest - The transaction request object.
41816
42031
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
41817
42032
  */
41818
- estimateTxGasAndFee(params) {
42033
+ async estimateTxGasAndFee(params) {
41819
42034
  const { transactionRequest } = params;
41820
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
42035
+ let { gasPrice } = params;
41821
42036
  const chainInfo = this.getChain();
41822
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41823
- transactionRequest.gasPrice = gasPrice;
42037
+ const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
41824
42038
  const minGas = transactionRequest.calculateMinGas(chainInfo);
41825
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42039
+ if (!gasPrice) {
42040
+ gasPrice = await this.estimateGasPrice(10);
42041
+ }
42042
+ const minFee = calculateGasFee({
42043
+ gasPrice: bn(gasPrice),
42044
+ gas: minGas,
42045
+ priceFactor: gasPriceFactor,
42046
+ tip: transactionRequest.tip
42047
+ }).add(1);
42048
+ let gasLimit = bn(0);
41826
42049
  if (transactionRequest.type === TransactionType.Script) {
42050
+ gasLimit = transactionRequest.gasLimit;
41827
42051
  if (transactionRequest.gasLimit.eq(0)) {
41828
42052
  transactionRequest.gasLimit = minGas;
41829
42053
  transactionRequest.gasLimit = maxGasPerTx.sub(
41830
42054
  transactionRequest.calculateMaxGas(chainInfo, minGas)
41831
42055
  );
42056
+ gasLimit = transactionRequest.gasLimit;
41832
42057
  }
41833
42058
  }
41834
42059
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
41835
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42060
+ const maxFee = calculateGasFee({
42061
+ gasPrice: bn(gasPrice),
42062
+ gas: maxGas,
42063
+ priceFactor: gasPriceFactor,
42064
+ tip: transactionRequest.tip
42065
+ }).add(1);
41836
42066
  return {
41837
42067
  minGas,
41838
42068
  minFee,
41839
42069
  maxGas,
41840
- maxFee
42070
+ maxFee,
42071
+ gasPrice,
42072
+ gasLimit
41841
42073
  };
41842
42074
  }
41843
42075
  /**
@@ -41855,15 +42087,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41855
42087
  if (estimateTxDependencies) {
41856
42088
  return this.estimateTxDependencies(transactionRequest);
41857
42089
  }
41858
- const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41859
- const { dryRun: gqlReceipts } = await this.operations.dryRun({
41860
- encodedTransaction,
42090
+ const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
42091
+ const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42092
+ encodedTransactions,
41861
42093
  utxoValidation: true
41862
42094
  });
41863
- const receipts = gqlReceipts.map(processGqlReceipt);
41864
- return {
41865
- receipts
41866
- };
42095
+ const callResult = dryRunStatuses.map((dryRunStatus) => {
42096
+ const { id, receipts, status } = dryRunStatus;
42097
+ const processedReceipts = receipts.map(processGqlReceipt);
42098
+ return { id, receipts: processedReceipts, status };
42099
+ });
42100
+ return { receipts: callResult[0].receipts };
41867
42101
  }
41868
42102
  /**
41869
42103
  * Returns a transaction cost to enable user
@@ -41880,77 +42114,80 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41880
42114
  * @param tolerance - The tolerance to add on top of the gasUsed.
41881
42115
  * @returns A promise that resolves to the transaction cost object.
41882
42116
  */
41883
- async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
41884
- estimateTxDependencies = true,
41885
- estimatePredicates = true,
41886
- resourcesOwner,
41887
- signatureCallback
41888
- } = {}) {
42117
+ async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
41889
42118
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41890
- const { minGasPrice } = this.getGasConfig();
41891
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
41892
42119
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
42120
+ const baseAssetId = this.getBaseAssetId();
41893
42121
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41894
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
41895
- txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
42122
+ const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
42123
+ txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
42124
+ txRequestClone.maxFee = bn(0);
41896
42125
  if (isScriptTransaction) {
41897
42126
  txRequestClone.gasLimit = bn(0);
41898
42127
  }
41899
- if (estimatePredicates) {
41900
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41901
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
41902
- }
41903
- await this.estimatePredicates(txRequestClone);
42128
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
42129
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
41904
42130
  }
42131
+ const signedRequest = clone_default(txRequestClone);
42132
+ let addedSignatures = 0;
41905
42133
  if (signatureCallback && isScriptTransaction) {
41906
- await signatureCallback(txRequestClone);
42134
+ const lengthBefore = signedRequest.witnesses.length;
42135
+ await signatureCallback(signedRequest);
42136
+ addedSignatures = signedRequest.witnesses.length - lengthBefore;
41907
42137
  }
41908
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41909
- transactionRequest: txRequestClone
42138
+ await this.estimatePredicates(signedRequest);
42139
+ let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
42140
+ transactionRequest: signedRequest
41910
42141
  });
41911
42142
  let receipts = [];
41912
42143
  let missingContractIds = [];
41913
42144
  let outputVariables = 0;
41914
42145
  let gasUsed = bn(0);
41915
- if (isScriptTransaction && estimateTxDependencies) {
41916
- txRequestClone.gasPrice = bn(0);
42146
+ txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
42147
+ txRequestClone.maxFee = maxFee;
42148
+ if (isScriptTransaction) {
42149
+ txRequestClone.gasLimit = gasLimit;
42150
+ if (signatureCallback) {
42151
+ await signatureCallback(txRequestClone);
42152
+ }
41917
42153
  const result = await this.estimateTxDependencies(txRequestClone);
41918
42154
  receipts = result.receipts;
41919
42155
  outputVariables = result.outputVariables;
41920
42156
  missingContractIds = result.missingContractIds;
41921
42157
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41922
42158
  txRequestClone.gasLimit = gasUsed;
41923
- txRequestClone.gasPrice = setGasPrice;
41924
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41925
- transactionRequest: txRequestClone
42159
+ ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
42160
+ transactionRequest: txRequestClone,
42161
+ gasPrice
41926
42162
  }));
41927
42163
  }
41928
42164
  return {
41929
42165
  requiredQuantities: allQuantities,
41930
42166
  receipts,
41931
42167
  gasUsed,
41932
- minGasPrice,
41933
- gasPrice: setGasPrice,
42168
+ gasPrice,
41934
42169
  minGas,
41935
42170
  maxGas,
41936
42171
  minFee,
41937
42172
  maxFee,
41938
- estimatedInputs: txRequestClone.inputs,
41939
42173
  outputVariables,
41940
- missingContractIds
42174
+ missingContractIds,
42175
+ addedSignatures,
42176
+ estimatedPredicates: txRequestClone.inputs
41941
42177
  };
41942
42178
  }
41943
- async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
42179
+ async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
41944
42180
  const ownerAddress = Address.fromAddressOrString(owner);
41945
42181
  const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
41946
- const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
42182
+ const transactionCost = await this.getTransactionCost(transactionRequest, {
42183
+ quantitiesToContract
42184
+ });
41947
42185
  transactionRequest.addResources(
41948
42186
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
41949
42187
  );
41950
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(
41951
- transactionRequest,
41952
- forwardingQuantities
41953
- );
42188
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
42189
+ quantitiesToContract
42190
+ });
41954
42191
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
41955
42192
  return {
41956
42193
  resources,
@@ -41974,7 +42211,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41974
42211
  assetId: coin.assetId,
41975
42212
  amount: bn(coin.amount),
41976
42213
  owner: Address.fromAddressOrString(coin.owner),
41977
- maturity: bn(coin.maturity).toNumber(),
41978
42214
  blockCreated: bn(coin.blockCreated),
41979
42215
  txCreatedIdx: bn(coin.txCreatedIdx)
41980
42216
  }));
@@ -42026,7 +42262,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42026
42262
  amount: bn(coin.amount),
42027
42263
  assetId: coin.assetId,
42028
42264
  owner: Address.fromAddressOrString(coin.owner),
42029
- maturity: bn(coin.maturity).toNumber(),
42030
42265
  blockCreated: bn(coin.blockCreated),
42031
42266
  txCreatedIdx: bn(coin.txCreatedIdx)
42032
42267
  };
@@ -42059,7 +42294,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42059
42294
  }
42060
42295
  return {
42061
42296
  id: block2.id,
42062
- height: bn(block2.header.height),
42297
+ height: bn(block2.height),
42063
42298
  time: block2.header.time,
42064
42299
  transactionIds: block2.transactions.map((tx) => tx.id)
42065
42300
  };
@@ -42074,7 +42309,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42074
42309
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
42075
42310
  const blocks = fetchedData.edges.map(({ node: block2 }) => ({
42076
42311
  id: block2.id,
42077
- height: bn(block2.header.height),
42312
+ height: bn(block2.height),
42078
42313
  time: block2.header.time,
42079
42314
  transactionIds: block2.transactions.map((tx) => tx.id)
42080
42315
  }));
@@ -42101,7 +42336,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42101
42336
  }
42102
42337
  return {
42103
42338
  id: block2.id,
42104
- height: bn(block2.header.height, 10),
42339
+ height: bn(block2.height, 10),
42105
42340
  time: block2.header.time,
42106
42341
  transactionIds: block2.transactions.map((tx) => tx.id),
42107
42342
  transactions: block2.transactions.map(
@@ -42281,8 +42516,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42281
42516
  prevRoot: messageBlockHeader.prevRoot,
42282
42517
  time: messageBlockHeader.time,
42283
42518
  applicationHash: messageBlockHeader.applicationHash,
42284
- messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
42285
- messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
42519
+ messageReceiptCount: bn(messageBlockHeader.messageReceiptCount),
42520
+ messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
42521
+ consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
42522
+ eventInboxRoot: messageBlockHeader.eventInboxRoot,
42523
+ stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
42286
42524
  },
42287
42525
  commitBlockHeader: {
42288
42526
  id: commitBlockHeader.id,
@@ -42293,8 +42531,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42293
42531
  prevRoot: commitBlockHeader.prevRoot,
42294
42532
  time: commitBlockHeader.time,
42295
42533
  applicationHash: commitBlockHeader.applicationHash,
42296
- messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
42297
- messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
42534
+ messageReceiptCount: bn(commitBlockHeader.messageReceiptCount),
42535
+ messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
42536
+ consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
42537
+ eventInboxRoot: commitBlockHeader.eventInboxRoot,
42538
+ stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
42298
42539
  },
42299
42540
  sender: Address.fromAddressOrString(sender),
42300
42541
  recipient: Address.fromAddressOrString(recipient),
@@ -42303,6 +42544,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42303
42544
  data
42304
42545
  };
42305
42546
  }
42547
+ async getLatestGasPrice() {
42548
+ const { latestGasPrice } = await this.operations.getLatestGasPrice();
42549
+ return bn(latestGasPrice.gasPrice);
42550
+ }
42551
+ async estimateGasPrice(blockHorizon) {
42552
+ const { estimateGasPrice } = await this.operations.estimateGasPrice({
42553
+ blockHorizon: String(blockHorizon)
42554
+ });
42555
+ return bn(estimateGasPrice.gasPrice);
42556
+ }
42306
42557
  /**
42307
42558
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
42308
42559
  *
@@ -42363,10 +42614,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42363
42614
  arrayify(gqlTransaction.rawPayload),
42364
42615
  0
42365
42616
  );
42366
- const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
42617
+ let txReceipts = [];
42618
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42619
+ txReceipts = gqlTransaction.status.receipts;
42620
+ }
42621
+ const receipts = txReceipts.map(processGqlReceipt);
42367
42622
  const {
42368
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42623
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42369
42624
  } = provider.getChain();
42625
+ const gasPrice = await provider.getLatestGasPrice();
42370
42626
  const transactionInfo = assembleTransactionSummary({
42371
42627
  id: gqlTransaction.id,
42372
42628
  receipts,
@@ -42377,7 +42633,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42377
42633
  gasPriceFactor: bn(gasPriceFactor),
42378
42634
  abiMap,
42379
42635
  maxInputs,
42380
- gasCosts
42636
+ gasCosts,
42637
+ maxGasPerTx,
42638
+ gasPrice
42381
42639
  });
42382
42640
  return {
42383
42641
  gqlTransaction,
@@ -42387,10 +42645,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42387
42645
  async function getTransactionSummaryFromRequest(params) {
42388
42646
  const { provider, transactionRequest, abiMap } = params;
42389
42647
  const { receipts } = await provider.call(transactionRequest);
42390
- const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
42648
+ const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
42391
42649
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
42392
42650
  const transaction = transactionRequest.toTransaction();
42393
42651
  const transactionBytes = transactionRequest.toTransactionBytes();
42652
+ const gasPrice = await provider.getLatestGasPrice();
42394
42653
  const transactionSummary = assembleTransactionSummary({
42395
42654
  receipts,
42396
42655
  transaction,
@@ -42399,7 +42658,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42399
42658
  gasPerByte,
42400
42659
  gasPriceFactor,
42401
42660
  maxInputs,
42402
- gasCosts
42661
+ gasCosts,
42662
+ maxGasPerTx,
42663
+ gasPrice
42403
42664
  });
42404
42665
  return transactionSummary;
42405
42666
  }
@@ -42408,13 +42669,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42408
42669
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
42409
42670
  const { edges, pageInfo } = transactionsByOwner;
42410
42671
  const {
42411
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42672
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42412
42673
  } = provider.getChain();
42674
+ const gasPrice = await provider.getLatestGasPrice();
42413
42675
  const transactions = edges.map((edge) => {
42414
42676
  const { node: gqlTransaction } = edge;
42415
- const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
42677
+ const { id, rawPayload, status } = gqlTransaction;
42416
42678
  const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
42417
- const receipts = gqlReceipts?.map(processGqlReceipt) || [];
42679
+ let txReceipts = [];
42680
+ if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42681
+ txReceipts = gqlTransaction.status.receipts;
42682
+ }
42683
+ const receipts = txReceipts.map(processGqlReceipt);
42418
42684
  const transactionSummary = assembleTransactionSummary({
42419
42685
  id,
42420
42686
  receipts,
@@ -42425,7 +42691,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42425
42691
  gasPerByte,
42426
42692
  gasPriceFactor,
42427
42693
  maxInputs,
42428
- gasCosts
42694
+ gasCosts,
42695
+ maxGasPerTx,
42696
+ gasPrice
42429
42697
  });
42430
42698
  const output3 = {
42431
42699
  gqlTransaction,
@@ -42716,8 +42984,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42716
42984
  * @param assetId - The asset ID to check the balance for.
42717
42985
  * @returns A promise that resolves to the balance amount.
42718
42986
  */
42719
- async getBalance(assetId = BaseAssetId) {
42720
- const amount = await this.provider.getBalance(this.address, assetId);
42987
+ async getBalance(assetId) {
42988
+ const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
42989
+ const amount = await this.provider.getBalance(this.address, assetIdToFetch);
42721
42990
  return amount;
42722
42991
  }
42723
42992
  /**
@@ -42754,37 +43023,31 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42754
43023
  * @param fee - The estimated transaction fee.
42755
43024
  * @returns A promise that resolves when the resources are added to the transaction.
42756
43025
  */
42757
- async fund(request, coinQuantities, fee) {
42758
- const updatedQuantities = addAmountToAsset({
43026
+ async fund(request, params) {
43027
+ const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
43028
+ const baseAssetId = this.provider.getBaseAssetId();
43029
+ const txRequest = request;
43030
+ const requiredQuantitiesWithFee = addAmountToCoinQuantities({
42759
43031
  amount: bn(fee),
42760
- assetId: BaseAssetId,
42761
- coinQuantities
43032
+ assetId: baseAssetId,
43033
+ coinQuantities: requiredQuantities
42762
43034
  });
42763
43035
  const quantitiesDict = {};
42764
- updatedQuantities.forEach(({ amount, assetId }) => {
43036
+ requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
42765
43037
  quantitiesDict[assetId] = {
42766
43038
  required: amount,
42767
43039
  owned: bn(0)
42768
43040
  };
42769
43041
  });
42770
- const cachedUtxos = [];
42771
- const cachedMessages = [];
42772
- const owner = this.address.toB256();
42773
- request.inputs.forEach((input) => {
43042
+ txRequest.inputs.forEach((input) => {
42774
43043
  const isResource = "amount" in input;
42775
- if (isResource) {
42776
- const isCoin2 = "owner" in input;
42777
- if (isCoin2) {
42778
- const assetId = String(input.assetId);
42779
- if (input.owner === owner && quantitiesDict[assetId]) {
42780
- const amount = bn(input.amount);
42781
- quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42782
- cachedUtxos.push(input.id);
42783
- }
42784
- } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
42785
- quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42786
- cachedMessages.push(input.nonce);
42787
- }
43044
+ if (!isResource) {
43045
+ return;
43046
+ }
43047
+ const isCoin2 = "owner" in input;
43048
+ const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
43049
+ if (quantitiesDict[assetId]) {
43050
+ quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
42788
43051
  }
42789
43052
  });
42790
43053
  const missingQuantities = [];
@@ -42798,12 +43061,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42798
43061
  });
42799
43062
  const needsToBeFunded = missingQuantities.length;
42800
43063
  if (needsToBeFunded) {
42801
- const resources = await this.getResourcesToSpend(missingQuantities, {
42802
- messages: cachedMessages,
42803
- utxos: cachedUtxos
42804
- });
42805
- request.addResources(resources);
42806
- }
43064
+ const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
43065
+ const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
43066
+ txRequest.addResources(resources);
43067
+ }
43068
+ txRequest.shiftPredicateData();
43069
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
43070
+ const requestToReestimate = clone_default(txRequest);
43071
+ if (addedSignatures) {
43072
+ Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
43073
+ }
43074
+ const { maxFee } = await this.provider.estimateTxGasAndFee({
43075
+ transactionRequest: requestToReestimate
43076
+ });
43077
+ txRequest.maxFee = maxFee;
43078
+ return txRequest;
42807
43079
  }
42808
43080
  /**
42809
43081
  * A helper that creates a transfer transaction request and returns it.
@@ -42811,28 +43083,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42811
43083
  * @param destination - The address of the destination.
42812
43084
  * @param amount - The amount of coins to transfer.
42813
43085
  * @param assetId - The asset ID of the coins to transfer.
42814
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
43086
+ * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
42815
43087
  * @returns A promise that resolves to the prepared transaction request.
42816
43088
  */
42817
- async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
42818
- const { minGasPrice } = this.provider.getGasConfig();
42819
- const params = { gasPrice: minGasPrice, ...txParams };
42820
- const request = new ScriptTransactionRequest(params);
42821
- request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
42822
- const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
43089
+ async createTransfer(destination, amount, assetId, txParams = {}) {
43090
+ const request = new ScriptTransactionRequest(txParams);
43091
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
43092
+ request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
43093
+ const txCost = await this.provider.getTransactionCost(request, {
42823
43094
  estimateTxDependencies: true,
42824
43095
  resourcesOwner: this
42825
43096
  });
42826
- request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
42827
- request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
42828
- this.validateGas({
42829
- gasUsed,
42830
- gasPrice: request.gasPrice,
42831
- gasLimit: request.gasLimit,
42832
- minGasPrice
43097
+ this.validateGasLimitAndMaxFee({
43098
+ gasUsed: txCost.gasUsed,
43099
+ maxFee: txCost.maxFee,
43100
+ txParams
42833
43101
  });
42834
- await this.fund(request, requiredQuantities, maxFee);
42835
- request.updatePredicateInputs(estimatedInputs);
43102
+ request.gasLimit = txCost.gasUsed;
43103
+ request.maxFee = txCost.maxFee;
43104
+ await this.fund(request, txCost);
42836
43105
  return request;
42837
43106
  }
42838
43107
  /**
@@ -42841,17 +43110,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42841
43110
  * @param destination - The address of the destination.
42842
43111
  * @param amount - The amount of coins to transfer.
42843
43112
  * @param assetId - The asset ID of the coins to transfer.
42844
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
43113
+ * @param txParams - The transaction parameters (gasLimit, maturity).
42845
43114
  * @returns A promise that resolves to the transaction response.
42846
43115
  */
42847
- async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
43116
+ async transfer(destination, amount, assetId, txParams = {}) {
42848
43117
  if (bn(amount).lte(0)) {
42849
43118
  throw new FuelError(
42850
43119
  ErrorCode.INVALID_TRANSFER_AMOUNT,
42851
43120
  "Transfer amount must be a positive number."
42852
43121
  );
42853
43122
  }
42854
- const request = await this.createTransfer(destination, amount, assetId, txParams);
43123
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
43124
+ const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
42855
43125
  return this.sendTransaction(request, { estimateTxDependencies: false });
42856
43126
  }
42857
43127
  /**
@@ -42863,7 +43133,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42863
43133
  * @param txParams - The optional transaction parameters.
42864
43134
  * @returns A promise that resolves to the transaction response.
42865
43135
  */
42866
- async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
43136
+ async transferToContract(contractId, amount, assetId, txParams = {}) {
42867
43137
  if (bn(amount).lte(0)) {
42868
43138
  throw new FuelError(
42869
43139
  ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -42871,31 +43141,30 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42871
43141
  );
42872
43142
  }
42873
43143
  const contractAddress = Address.fromAddressOrString(contractId);
42874
- const { minGasPrice } = this.provider.getGasConfig();
42875
- const params = { gasPrice: minGasPrice, ...txParams };
43144
+ const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
42876
43145
  const { script, scriptData } = await assembleTransferToContractScript({
42877
43146
  hexlifiedContractId: contractAddress.toB256(),
42878
43147
  amountToTransfer: bn(amount),
42879
- assetId
43148
+ assetId: assetIdToTransfer
42880
43149
  });
42881
43150
  const request = new ScriptTransactionRequest({
42882
- ...params,
43151
+ ...txParams,
42883
43152
  script,
42884
43153
  scriptData
42885
43154
  });
42886
43155
  request.addContractInputAndOutput(contractAddress);
42887
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42888
- request,
42889
- [{ amount: bn(amount), assetId: String(assetId) }]
42890
- );
42891
- request.gasLimit = bn(params.gasLimit ?? gasUsed);
42892
- this.validateGas({
42893
- gasUsed,
42894
- gasPrice: request.gasPrice,
42895
- gasLimit: request.gasLimit,
42896
- minGasPrice
43156
+ const txCost = await this.provider.getTransactionCost(request, {
43157
+ resourcesOwner: this,
43158
+ quantitiesToContract: [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
43159
+ });
43160
+ this.validateGasLimitAndMaxFee({
43161
+ gasUsed: txCost.gasUsed,
43162
+ maxFee: txCost.maxFee,
43163
+ txParams
42897
43164
  });
42898
- await this.fund(request, requiredQuantities, maxFee);
43165
+ request.gasLimit = txCost.gasUsed;
43166
+ request.maxFee = txCost.maxFee;
43167
+ await this.fund(request, txCost);
42899
43168
  return this.sendTransaction(request);
42900
43169
  }
42901
43170
  /**
@@ -42907,7 +43176,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42907
43176
  * @returns A promise that resolves to the transaction response.
42908
43177
  */
42909
43178
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42910
- const { minGasPrice } = this.provider.getGasConfig();
42911
43179
  const recipientAddress = Address.fromAddressOrString(recipient);
42912
43180
  const recipientDataArray = arrayify(
42913
43181
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -42920,21 +43188,19 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42920
43188
  ...recipientDataArray,
42921
43189
  ...amountDataArray
42922
43190
  ]);
42923
- const params = { script, gasPrice: minGasPrice, ...txParams };
43191
+ const params = { script, ...txParams };
43192
+ const baseAssetId = this.provider.getBaseAssetId();
42924
43193
  const request = new ScriptTransactionRequest(params);
42925
- const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42926
- const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42927
- request,
42928
- forwardingQuantities
42929
- );
42930
- request.gasLimit = bn(params.gasLimit ?? gasUsed);
42931
- this.validateGas({
42932
- gasUsed,
42933
- gasPrice: request.gasPrice,
42934
- gasLimit: request.gasLimit,
42935
- minGasPrice
43194
+ const quantitiesToContract = [{ amount: bn(amount), assetId: baseAssetId }];
43195
+ const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
43196
+ this.validateGasLimitAndMaxFee({
43197
+ gasUsed: txCost.gasUsed,
43198
+ maxFee: txCost.maxFee,
43199
+ txParams
42936
43200
  });
42937
- await this.fund(request, requiredQuantities, maxFee);
43201
+ request.maxFee = txCost.maxFee;
43202
+ request.gasLimit = txCost.gasUsed;
43203
+ await this.fund(request, txCost);
42938
43204
  return this.sendTransaction(request);
42939
43205
  }
42940
43206
  async signMessage(message) {
@@ -42992,22 +43258,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42992
43258
  }
42993
43259
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
42994
43260
  }
42995
- validateGas({
43261
+ validateGasLimitAndMaxFee({
43262
+ txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
42996
43263
  gasUsed,
42997
- gasPrice,
42998
- gasLimit,
42999
- minGasPrice
43264
+ maxFee
43000
43265
  }) {
43001
- if (minGasPrice.gt(gasPrice)) {
43266
+ if (isDefined(setGasLimit) && gasUsed.gt(setGasLimit)) {
43002
43267
  throw new FuelError(
43003
- ErrorCode.GAS_PRICE_TOO_LOW,
43004
- `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
43268
+ ErrorCode.GAS_LIMIT_TOO_LOW,
43269
+ `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
43005
43270
  );
43006
43271
  }
43007
- if (gasUsed.gt(gasLimit)) {
43272
+ if (isDefined(setMaxFee) && maxFee.gt(setMaxFee)) {
43008
43273
  throw new FuelError(
43009
- ErrorCode.GAS_LIMIT_TOO_LOW,
43010
- `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
43274
+ ErrorCode.MAX_FEE_TOO_LOW,
43275
+ `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
43011
43276
  );
43012
43277
  }
43013
43278
  }
@@ -44592,7 +44857,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44592
44857
  * @param transactionRequestLike - The transaction request to send.
44593
44858
  * @returns A promise that resolves to the TransactionResponse object.
44594
44859
  */
44595
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
44860
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
44596
44861
  const transactionRequest = transactionRequestify(transactionRequestLike);
44597
44862
  if (estimateTxDependencies) {
44598
44863
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -47870,34 +48135,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47870
48135
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
47871
48136
  request.inputs?.forEach((input) => {
47872
48137
  if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
47873
- input.predicate = this.bytes;
47874
- input.predicateData = this.getPredicateData(policies.length);
48138
+ input.predicate = hexlify(this.bytes);
48139
+ input.predicateData = hexlify(this.getPredicateData(policies.length));
47875
48140
  }
47876
48141
  });
47877
48142
  return request;
47878
48143
  }
47879
- /**
47880
- * A helper that creates a transfer transaction request and returns it.
47881
- *
47882
- * @param destination - The address of the destination.
47883
- * @param amount - The amount of coins to transfer.
47884
- * @param assetId - The asset ID of the coins to transfer.
47885
- * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
47886
- * @returns A promise that resolves to the prepared transaction request.
47887
- */
47888
- async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
47889
- const request = await super.createTransfer(destination, amount, assetId, txParams);
47890
- return this.populateTransactionPredicateData(request);
47891
- }
47892
48144
  /**
47893
48145
  * Sends a transaction with the populated predicate data.
47894
48146
  *
47895
48147
  * @param transactionRequestLike - The transaction request-like object.
47896
48148
  * @returns A promise that resolves to the transaction response.
47897
48149
  */
47898
- sendTransaction(transactionRequestLike, options) {
47899
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47900
- return super.sendTransaction(transactionRequest, options);
48150
+ sendTransaction(transactionRequestLike) {
48151
+ const transactionRequest = transactionRequestify(transactionRequestLike);
48152
+ return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
47901
48153
  }
47902
48154
  /**
47903
48155
  * Simulates a transaction with the populated predicate data.
@@ -47906,8 +48158,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47906
48158
  * @returns A promise that resolves to the call result.
47907
48159
  */
47908
48160
  simulateTransaction(transactionRequestLike) {
47909
- const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47910
- return super.simulateTransaction(transactionRequest);
48161
+ const transactionRequest = transactionRequestify(transactionRequestLike);
48162
+ return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
47911
48163
  }
47912
48164
  getPredicateData(policiesLength) {
47913
48165
  if (!this.predicateData.length) {
@@ -47953,6 +48205,25 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47953
48205
  predicateInterface: abiInterface
47954
48206
  };
47955
48207
  }
48208
+ /**
48209
+ * Retrieves resources satisfying the spend query for the account.
48210
+ *
48211
+ * @param quantities - IDs of coins to exclude.
48212
+ * @param excludedIds - IDs of resources to be excluded from the query.
48213
+ * @returns A promise that resolves to an array of Resources.
48214
+ */
48215
+ async getResourcesToSpend(quantities, excludedIds) {
48216
+ const resources = await this.provider.getResourcesToSpend(
48217
+ this.address,
48218
+ quantities,
48219
+ excludedIds
48220
+ );
48221
+ return resources.map((resource) => ({
48222
+ ...resource,
48223
+ predicate: hexlify(this.bytes),
48224
+ padPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
48225
+ }));
48226
+ }
47956
48227
  /**
47957
48228
  * Sets the configurable constants for the predicate.
47958
48229
  *