@fuel-ts/account 0.0.0-rc-2021-20240423205052 → 0.0.0-rc-2045-20240424064755

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 (53) hide show
  1. package/README.md +1 -1
  2. package/dist/account.d.ts +4 -5
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts.map +1 -1
  5. package/dist/configs.global.js +1 -1
  6. package/dist/configs.global.js.map +1 -1
  7. package/dist/configs.js +1 -1
  8. package/dist/configs.js.map +1 -1
  9. package/dist/configs.mjs +1 -1
  10. package/dist/configs.mjs.map +1 -1
  11. package/dist/index.global.js +589 -861
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +517 -793
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +398 -673
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/predicate/predicate.d.ts +2 -10
  18. package/dist/predicate/predicate.d.ts.map +1 -1
  19. package/dist/providers/__generated__/operations.d.ts +327 -821
  20. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  21. package/dist/providers/coin-quantity.d.ts +1 -1
  22. package/dist/providers/coin-quantity.d.ts.map +1 -1
  23. package/dist/providers/coin.d.ts +2 -4
  24. package/dist/providers/coin.d.ts.map +1 -1
  25. package/dist/providers/message.d.ts +1 -7
  26. package/dist/providers/message.d.ts.map +1 -1
  27. package/dist/providers/provider.d.ts +27 -37
  28. package/dist/providers/provider.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  30. package/dist/providers/transaction-request/input.d.ts +2 -2
  31. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  32. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  33. package/dist/providers/transaction-request/transaction-request.d.ts +29 -8
  34. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  35. package/dist/providers/transaction-request/utils.d.ts +0 -3
  36. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  37. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  38. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
  39. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  40. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
  41. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
  42. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  43. package/dist/providers/utils/gas.d.ts +2 -8
  44. package/dist/providers/utils/gas.d.ts.map +1 -1
  45. package/dist/test-utils/launchNode.d.ts.map +1 -1
  46. package/dist/test-utils.global.js +1090 -1579
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +515 -774
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +407 -666
  51. package/dist/test-utils.mjs.map +1 -1
  52. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  53. package/package.json +16 -16
@@ -289,7 +289,7 @@
289
289
  }
290
290
  return num !== null && typeof num === "object" && num.constructor.wordSize === BN2.wordSize && Array.isArray(num.words);
291
291
  };
292
- BN2.max = function max(left, right) {
292
+ BN2.max = function max2(left, right) {
293
293
  if (left.cmp(right) > 0)
294
294
  return left;
295
295
  return right;
@@ -5113,7 +5113,7 @@
5113
5113
  function isBlob(obj) {
5114
5114
  return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
5115
5115
  }
5116
- function clone3(instance) {
5116
+ function clone(instance) {
5117
5117
  let p1, p2;
5118
5118
  let body = instance.body;
5119
5119
  if (instance.bodyUsed) {
@@ -6047,7 +6047,7 @@
6047
6047
  * @return Response
6048
6048
  */
6049
6049
  clone() {
6050
- return new Response2(clone3(this), {
6050
+ return new Response2(clone(this), {
6051
6051
  url: this.url,
6052
6052
  status: this.status,
6053
6053
  statusText: this.statusText,
@@ -6097,7 +6097,7 @@
6097
6097
  if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
6098
6098
  throw new TypeError("Request with GET/HEAD method cannot have body");
6099
6099
  }
6100
- let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone3(input) : null;
6100
+ let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
6101
6101
  Body.call(this, inputBody, {
6102
6102
  timeout: init.timeout || input.timeout || 0,
6103
6103
  size: init.size || input.size || 0
@@ -28952,8 +28952,8 @@ spurious results.`);
28952
28952
  // ../versions/dist/index.mjs
28953
28953
  function getBuiltinVersions() {
28954
28954
  return {
28955
- FORC: "0.51.1",
28956
- FUEL_CORE: "0.24.2",
28955
+ FORC: "0.55.0",
28956
+ FUEL_CORE: "0.22.1",
28957
28957
  FUELS: "0.81.0"
28958
28958
  };
28959
28959
  }
@@ -31144,7 +31144,7 @@ This unreleased fuel-core build may include features and updates not yet support
31144
31144
  toEvmAddress() {
31145
31145
  const b256Address = toB256(this.bech32Address);
31146
31146
  return {
31147
- value: clearFirst12BytesFromB256(b256Address)
31147
+ bits: clearFirst12BytesFromB256(b256Address)
31148
31148
  };
31149
31149
  }
31150
31150
  /**
@@ -31154,7 +31154,7 @@ This unreleased fuel-core build may include features and updates not yet support
31154
31154
  */
31155
31155
  toAssetId() {
31156
31156
  return {
31157
- value: this.toB256()
31157
+ bits: this.toB256()
31158
31158
  };
31159
31159
  }
31160
31160
  /**
@@ -31495,182 +31495,32 @@ This unreleased fuel-core build may include features and updates not yet support
31495
31495
  function toBytes3(value, bytesPadding) {
31496
31496
  return bn(value).toBytes(bytesPadding);
31497
31497
  }
31498
-
31499
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
31500
- function _isPlaceholder(a) {
31501
- return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
31502
- }
31503
-
31504
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
31505
- function _curry1(fn) {
31506
- return function f1(a) {
31507
- if (arguments.length === 0 || _isPlaceholder(a)) {
31508
- return f1;
31509
- } else {
31510
- return fn.apply(this, arguments);
31511
- }
31512
- };
31513
- }
31514
-
31515
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
31516
- var isArray_default = Array.isArray || function _isArray(val) {
31517
- return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
31518
- };
31519
-
31520
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
31521
- var type = /* @__PURE__ */ _curry1(function type2(val) {
31522
- return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
31523
- });
31524
- var type_default = type;
31525
-
31526
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
31527
- var pad = function pad2(n) {
31528
- return (n < 10 ? "0" : "") + n;
31529
- };
31530
- var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
31531
- return d.toISOString();
31532
- } : function _toISOString3(d) {
31533
- return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
31534
- };
31535
-
31536
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
31537
- var isInteger_default = Number.isInteger || function _isInteger(n) {
31538
- return n << 0 === n;
31539
- };
31540
-
31541
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
31542
- function _cloneRegExp(pattern) {
31543
- return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
31544
- }
31545
-
31546
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
31547
- function _clone(value, deep, map) {
31548
- map || (map = new _ObjectMap());
31549
- if (_isPrimitive(value)) {
31550
- return value;
31551
- }
31552
- var copy = function copy2(copiedValue) {
31553
- var cachedCopy = map.get(value);
31554
- if (cachedCopy) {
31555
- return cachedCopy;
31556
- }
31557
- map.set(value, copiedValue);
31558
- for (var key in value) {
31559
- if (Object.prototype.hasOwnProperty.call(value, key)) {
31560
- copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
31561
- }
31562
- }
31563
- return copiedValue;
31564
- };
31565
- switch (type_default(value)) {
31566
- case "Object":
31567
- return copy(Object.create(Object.getPrototypeOf(value)));
31568
- case "Array":
31569
- return copy([]);
31570
- case "Date":
31571
- return new Date(value.valueOf());
31572
- case "RegExp":
31573
- return _cloneRegExp(value);
31574
- case "Int8Array":
31575
- case "Uint8Array":
31576
- case "Uint8ClampedArray":
31577
- case "Int16Array":
31578
- case "Uint16Array":
31579
- case "Int32Array":
31580
- case "Uint32Array":
31581
- case "Float32Array":
31582
- case "Float64Array":
31583
- case "BigInt64Array":
31584
- case "BigUint64Array":
31585
- return value.slice();
31586
- default:
31587
- return value;
31588
- }
31589
- }
31590
- function _isPrimitive(param) {
31591
- var type3 = typeof param;
31592
- return param == null || type3 != "object" && type3 != "function";
31498
+ function max(...numbers) {
31499
+ return numbers.reduce((prev, cur) => bn(cur).gt(prev) ? bn(cur) : prev, bn(0));
31593
31500
  }
31594
- var _ObjectMap = /* @__PURE__ */ function() {
31595
- function _ObjectMap2() {
31596
- this.map = {};
31597
- this.length = 0;
31598
- }
31599
- _ObjectMap2.prototype.set = function(key, value) {
31600
- const hashedKey = this.hash(key);
31601
- let bucket = this.map[hashedKey];
31602
- if (!bucket) {
31603
- this.map[hashedKey] = bucket = [];
31604
- }
31605
- bucket.push([key, value]);
31606
- this.length += 1;
31607
- };
31608
- _ObjectMap2.prototype.hash = function(key) {
31609
- let hashedKey = [];
31610
- for (var value in key) {
31611
- hashedKey.push(Object.prototype.toString.call(key[value]));
31612
- }
31613
- return hashedKey.join();
31614
- };
31615
- _ObjectMap2.prototype.get = function(key) {
31616
- if (this.length <= 180) {
31617
- for (const p in this.map) {
31618
- const bucket2 = this.map[p];
31619
- for (let i = 0; i < bucket2.length; i += 1) {
31620
- const element = bucket2[i];
31621
- if (element[0] === key) {
31622
- return element[1];
31623
- }
31624
- }
31625
- }
31626
- return;
31627
- }
31628
- const hashedKey = this.hash(key);
31629
- const bucket = this.map[hashedKey];
31630
- if (!bucket) {
31631
- return;
31632
- }
31633
- for (let i = 0; i < bucket.length; i += 1) {
31634
- const element = bucket[i];
31635
- if (element[0] === key) {
31636
- return element[1];
31637
- }
31638
- }
31639
- };
31640
- return _ObjectMap2;
31641
- }();
31642
-
31643
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
31644
- var clone = /* @__PURE__ */ _curry1(function clone2(value) {
31645
- return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
31646
- });
31647
- var clone_default = clone;
31648
-
31649
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
31650
- var hasProtoTrim = typeof String.prototype.trim === "function";
31651
31501
 
31652
31502
  // src/providers/coin-quantity.ts
31653
31503
  var coinQuantityfy = (coinQuantityLike) => {
31654
31504
  let assetId;
31655
31505
  let amount;
31656
- let max;
31506
+ let max2;
31657
31507
  if (Array.isArray(coinQuantityLike)) {
31658
31508
  amount = coinQuantityLike[0];
31659
31509
  assetId = coinQuantityLike[1] ?? BaseAssetId;
31660
- max = coinQuantityLike[2] ?? void 0;
31510
+ max2 = coinQuantityLike[2] ?? void 0;
31661
31511
  } else {
31662
31512
  amount = coinQuantityLike.amount;
31663
31513
  assetId = coinQuantityLike.assetId ?? BaseAssetId;
31664
- max = coinQuantityLike.max ?? void 0;
31514
+ max2 = coinQuantityLike.max ?? void 0;
31665
31515
  }
31666
31516
  const bnAmount = bn(amount);
31667
31517
  return {
31668
31518
  assetId: hexlify(assetId),
31669
31519
  amount: bnAmount.lt(1) ? bn(1) : bnAmount,
31670
- max: max ? bn(max) : void 0
31520
+ max: max2 ? bn(max2) : void 0
31671
31521
  };
31672
31522
  };
31673
- var addAmountToCoinQuantities = (params) => {
31523
+ var addAmountToAsset = (params) => {
31674
31524
  const { amount, assetId } = params;
31675
31525
  const coinQuantities = [...params.coinQuantities];
31676
31526
  const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
@@ -31755,7 +31605,7 @@ This unreleased fuel-core build may include features and updates not yet support
31755
31605
  var ENCODING_V1 = "1";
31756
31606
  var WORD_SIZE = 8;
31757
31607
  var BYTES_32 = 32;
31758
- var UTXO_ID_LEN = BYTES_32 + 2;
31608
+ var UTXO_ID_LEN = BYTES_32 + 1;
31759
31609
  var ASSET_ID_LEN = BYTES_32;
31760
31610
  var ADDRESS_LEN = BYTES_32;
31761
31611
  var NONCE_LEN = BYTES_32;
@@ -31763,9 +31613,9 @@ This unreleased fuel-core build may include features and updates not yet support
31763
31613
  var TX_POINTER_LEN = WORD_SIZE * 2;
31764
31614
  var MAX_BYTES = 2 ** 32 - 1;
31765
31615
  var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
31766
- ASSET_ID_LEN + // Base asset ID
31616
+ WORD_SIZE + // Tx size
31767
31617
  // Asset ID/Balance coin input pairs
31768
- maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
31618
+ maxInputs * (ASSET_ID_LEN + WORD_SIZE);
31769
31619
  var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
31770
31620
  WORD_SIZE + // Gas limit
31771
31621
  WORD_SIZE + // Script size
@@ -31783,6 +31633,7 @@ This unreleased fuel-core build may include features and updates not yet support
31783
31633
  ASSET_ID_LEN + // Asset id
31784
31634
  TX_POINTER_LEN + // TxPointer
31785
31635
  WORD_SIZE + // Witnesses index
31636
+ WORD_SIZE + // Maturity
31786
31637
  WORD_SIZE + // Predicate size
31787
31638
  WORD_SIZE + // Predicate data size
31788
31639
  WORD_SIZE;
@@ -32104,7 +31955,7 @@ This unreleased fuel-core build may include features and updates not yet support
32104
31955
  constructor(name, coders) {
32105
31956
  const caseIndexCoder = new BigNumberCoder("u64");
32106
31957
  const encodedValueSize = Object.values(coders).reduce(
32107
- (max, coder) => Math.max(max, coder.encodedLength),
31958
+ (max2, coder) => Math.max(max2, coder.encodedLength),
32108
31959
  0
32109
31960
  );
32110
31961
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -32822,7 +32673,7 @@ This unreleased fuel-core build may include features and updates not yet support
32822
32673
  constructor(name, coders) {
32823
32674
  const caseIndexCoder = new BigNumberCoder("u64");
32824
32675
  const encodedValueSize = Object.values(coders).reduce(
32825
- (max, coder) => Math.max(max, coder.encodedLength),
32676
+ (max2, coder) => Math.max(max2, coder.encodedLength),
32826
32677
  0
32827
32678
  );
32828
32679
  super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
@@ -33536,19 +33387,18 @@ This unreleased fuel-core build may include features and updates not yet support
33536
33387
  encode(value) {
33537
33388
  const parts = [];
33538
33389
  parts.push(new B256Coder().encode(value.txID));
33539
- parts.push(new NumberCoder("u16").encode(value.outputIndex));
33390
+ parts.push(new NumberCoder("u8").encode(value.outputIndex));
33540
33391
  parts.push(new B256Coder().encode(value.owner));
33541
33392
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33542
33393
  parts.push(new B256Coder().encode(value.assetId));
33543
33394
  parts.push(new TxPointerCoder().encode(value.txPointer));
33544
- parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33395
+ parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33396
+ parts.push(new NumberCoder("u32").encode(value.maturity));
33545
33397
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33546
- parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33547
- parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33548
- parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33549
- parts.push(
33550
- new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33551
- );
33398
+ parts.push(new NumberCoder("u32").encode(value.predicateLength));
33399
+ parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
33400
+ parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33401
+ parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33552
33402
  return concat(parts);
33553
33403
  }
33554
33404
  decode(data, offset) {
@@ -33556,7 +33406,7 @@ This unreleased fuel-core build may include features and updates not yet support
33556
33406
  let o = offset;
33557
33407
  [decoded, o] = new B256Coder().decode(data, o);
33558
33408
  const txID = decoded;
33559
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33409
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33560
33410
  const outputIndex = decoded;
33561
33411
  [decoded, o] = new B256Coder().decode(data, o);
33562
33412
  const owner = decoded;
@@ -33566,17 +33416,19 @@ This unreleased fuel-core build may include features and updates not yet support
33566
33416
  const assetId = decoded;
33567
33417
  [decoded, o] = new TxPointerCoder().decode(data, o);
33568
33418
  const txPointer = decoded;
33569
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33419
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33570
33420
  const witnessIndex = Number(decoded);
33421
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33422
+ const maturity = decoded;
33571
33423
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33572
33424
  const predicateGasUsed = decoded;
33573
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33425
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33574
33426
  const predicateLength = decoded;
33575
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33427
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33576
33428
  const predicateDataLength = decoded;
33577
- [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33429
+ [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33578
33430
  const predicate = decoded;
33579
- [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33431
+ [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33580
33432
  const predicateData = decoded;
33581
33433
  return [
33582
33434
  {
@@ -33588,6 +33440,7 @@ This unreleased fuel-core build may include features and updates not yet support
33588
33440
  assetId,
33589
33441
  txPointer,
33590
33442
  witnessIndex,
33443
+ maturity,
33591
33444
  predicateGasUsed,
33592
33445
  predicateLength,
33593
33446
  predicateDataLength,
@@ -33605,7 +33458,7 @@ This unreleased fuel-core build may include features and updates not yet support
33605
33458
  encode(value) {
33606
33459
  const parts = [];
33607
33460
  parts.push(new B256Coder().encode(value.txID));
33608
- parts.push(new NumberCoder("u16").encode(value.outputIndex));
33461
+ parts.push(new NumberCoder("u8").encode(value.outputIndex));
33609
33462
  parts.push(new B256Coder().encode(value.balanceRoot));
33610
33463
  parts.push(new B256Coder().encode(value.stateRoot));
33611
33464
  parts.push(new TxPointerCoder().encode(value.txPointer));
@@ -33617,7 +33470,7 @@ This unreleased fuel-core build may include features and updates not yet support
33617
33470
  let o = offset;
33618
33471
  [decoded, o] = new B256Coder().decode(data, o);
33619
33472
  const txID = decoded;
33620
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33473
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33621
33474
  const outputIndex = decoded;
33622
33475
  [decoded, o] = new B256Coder().decode(data, o);
33623
33476
  const balanceRoot = decoded;
@@ -33666,16 +33519,14 @@ This unreleased fuel-core build may include features and updates not yet support
33666
33519
  parts.push(new ByteArrayCoder(32).encode(value.recipient));
33667
33520
  parts.push(new BigNumberCoder("u64").encode(value.amount));
33668
33521
  parts.push(new ByteArrayCoder(32).encode(value.nonce));
33669
- parts.push(new NumberCoder("u16").encode(value.witnessIndex));
33522
+ parts.push(new NumberCoder("u8").encode(value.witnessIndex));
33670
33523
  parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
33671
- parts.push(new BigNumberCoder("u64").encode(data.length));
33672
- parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
33673
- parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
33524
+ parts.push(new NumberCoder("u32").encode(data.length));
33525
+ parts.push(new NumberCoder("u32").encode(value.predicateLength));
33526
+ parts.push(new NumberCoder("u32").encode(value.predicateDataLength));
33674
33527
  parts.push(new ByteArrayCoder(data.length).encode(data));
33675
- parts.push(new ByteArrayCoder(value.predicateLength.toNumber()).encode(value.predicate));
33676
- parts.push(
33677
- new ByteArrayCoder(value.predicateDataLength.toNumber()).encode(value.predicateData)
33678
- );
33528
+ parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate));
33529
+ parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData));
33679
33530
  return concat(parts);
33680
33531
  }
33681
33532
  static decodeData(messageData) {
@@ -33695,21 +33546,21 @@ This unreleased fuel-core build may include features and updates not yet support
33695
33546
  const amount = decoded;
33696
33547
  [decoded, o] = new B256Coder().decode(data, o);
33697
33548
  const nonce = decoded;
33698
- [decoded, o] = new NumberCoder("u16").decode(data, o);
33549
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
33699
33550
  const witnessIndex = Number(decoded);
33700
33551
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33701
33552
  const predicateGasUsed = decoded;
33702
33553
  [decoded, o] = new NumberCoder("u32").decode(data, o);
33703
33554
  const dataLength2 = decoded;
33704
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33555
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33705
33556
  const predicateLength = decoded;
33706
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33557
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
33707
33558
  const predicateDataLength = decoded;
33708
33559
  [decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
33709
33560
  const messageData = decoded;
33710
- [decoded, o] = new ByteArrayCoder(predicateLength.toNumber()).decode(data, o);
33561
+ [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o);
33711
33562
  const predicate = decoded;
33712
- [decoded, o] = new ByteArrayCoder(predicateDataLength.toNumber()).decode(data, o);
33563
+ [decoded, o] = new ByteArrayCoder(predicateDataLength).decode(data, o);
33713
33564
  const predicateData = decoded;
33714
33565
  return [
33715
33566
  {
@@ -34021,7 +33872,7 @@ This unreleased fuel-core build may include features and updates not yet support
34021
33872
  }
34022
33873
  };
34023
33874
  var PolicyType = /* @__PURE__ */ ((PolicyType2) => {
34024
- PolicyType2[PolicyType2["Tip"] = 1] = "Tip";
33875
+ PolicyType2[PolicyType2["GasPrice"] = 1] = "GasPrice";
34025
33876
  PolicyType2[PolicyType2["WitnessLimit"] = 2] = "WitnessLimit";
34026
33877
  PolicyType2[PolicyType2["Maturity"] = 4] = "Maturity";
34027
33878
  PolicyType2[PolicyType2["MaxFee"] = 8] = "MaxFee";
@@ -34069,9 +33920,9 @@ This unreleased fuel-core build may include features and updates not yet support
34069
33920
  let o = offset;
34070
33921
  const policies = [];
34071
33922
  if (policyTypes & 1) {
34072
- const [tip, nextOffset] = new BigNumberCoder("u64").decode(data, o);
33923
+ const [gasPrice, nextOffset] = new BigNumberCoder("u64").decode(data, o);
34073
33924
  o = nextOffset;
34074
- policies.push({ type: 1, data: tip });
33925
+ policies.push({ type: 1, data: gasPrice });
34075
33926
  }
34076
33927
  if (policyTypes & 2) {
34077
33928
  const [witnessLimit, nextOffset] = new BigNumberCoder("u64").decode(data, o);
@@ -34303,15 +34154,15 @@ This unreleased fuel-core build may include features and updates not yet support
34303
34154
  encode(value) {
34304
34155
  const parts = [];
34305
34156
  parts.push(new BigNumberCoder("u64").encode(value.scriptGasLimit));
34306
- parts.push(new B256Coder().encode(value.receiptsRoot));
34307
- parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
34308
- parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
34157
+ parts.push(new NumberCoder("u32").encode(value.scriptLength));
34158
+ parts.push(new NumberCoder("u32").encode(value.scriptDataLength));
34309
34159
  parts.push(new NumberCoder("u32").encode(value.policyTypes));
34310
- parts.push(new NumberCoder("u16").encode(value.inputsCount));
34311
- parts.push(new NumberCoder("u16").encode(value.outputsCount));
34312
- parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34313
- parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
34314
- parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
34160
+ parts.push(new NumberCoder("u8").encode(value.inputsCount));
34161
+ parts.push(new NumberCoder("u8").encode(value.outputsCount));
34162
+ parts.push(new NumberCoder("u8").encode(value.witnessesCount));
34163
+ parts.push(new B256Coder().encode(value.receiptsRoot));
34164
+ parts.push(new ByteArrayCoder(value.scriptLength).encode(value.script));
34165
+ parts.push(new ByteArrayCoder(value.scriptDataLength).encode(value.scriptData));
34315
34166
  parts.push(new PoliciesCoder().encode(value.policies));
34316
34167
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34317
34168
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
@@ -34323,23 +34174,23 @@ This unreleased fuel-core build may include features and updates not yet support
34323
34174
  let o = offset;
34324
34175
  [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34325
34176
  const scriptGasLimit = decoded;
34326
- [decoded, o] = new B256Coder().decode(data, o);
34327
- const receiptsRoot = decoded;
34328
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34177
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
34329
34178
  const scriptLength = decoded;
34330
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34179
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
34331
34180
  const scriptDataLength = decoded;
34332
34181
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34333
34182
  const policyTypes = decoded;
34334
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34183
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34335
34184
  const inputsCount = decoded;
34336
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34185
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34337
34186
  const outputsCount = decoded;
34338
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34187
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34339
34188
  const witnessesCount = decoded;
34340
- [decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
34189
+ [decoded, o] = new B256Coder().decode(data, o);
34190
+ const receiptsRoot = decoded;
34191
+ [decoded, o] = new ByteArrayCoder(scriptLength).decode(data, o);
34341
34192
  const script = decoded;
34342
- [decoded, o] = new ByteArrayCoder(scriptDataLength.toNumber()).decode(data, o);
34193
+ [decoded, o] = new ByteArrayCoder(scriptDataLength).decode(data, o);
34343
34194
  const scriptData = decoded;
34344
34195
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34345
34196
  const policies = decoded;
@@ -34377,19 +34228,18 @@ This unreleased fuel-core build may include features and updates not yet support
34377
34228
  }
34378
34229
  encode(value) {
34379
34230
  const parts = [];
34380
- parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
34381
- parts.push(new B256Coder().encode(value.salt));
34382
- parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
34231
+ parts.push(new NumberCoder("u32").encode(value.bytecodeLength));
34232
+ parts.push(new NumberCoder("u8").encode(value.bytecodeWitnessIndex));
34383
34233
  parts.push(new NumberCoder("u32").encode(value.policyTypes));
34384
- parts.push(new NumberCoder("u16").encode(value.inputsCount));
34385
- parts.push(new NumberCoder("u16").encode(value.outputsCount));
34386
- parts.push(new NumberCoder("u16").encode(value.witnessesCount));
34234
+ parts.push(new NumberCoder("u16").encode(value.storageSlotsCount));
34235
+ parts.push(new NumberCoder("u8").encode(value.inputsCount));
34236
+ parts.push(new NumberCoder("u8").encode(value.outputsCount));
34237
+ parts.push(new NumberCoder("u8").encode(value.witnessesCount));
34238
+ parts.push(new B256Coder().encode(value.salt));
34239
+ parts.push(new PoliciesCoder().encode(value.policies));
34387
34240
  parts.push(
34388
- new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
34389
- value.storageSlots
34390
- )
34241
+ new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount).encode(value.storageSlots)
34391
34242
  );
34392
- parts.push(new PoliciesCoder().encode(value.policies));
34393
34243
  parts.push(new ArrayCoder(new InputCoder(), value.inputsCount).encode(value.inputs));
34394
34244
  parts.push(new ArrayCoder(new OutputCoder(), value.outputsCount).encode(value.outputs));
34395
34245
  parts.push(new ArrayCoder(new WitnessCoder(), value.witnessesCount).encode(value.witnesses));
@@ -34398,27 +34248,26 @@ This unreleased fuel-core build may include features and updates not yet support
34398
34248
  decode(data, offset) {
34399
34249
  let decoded;
34400
34250
  let o = offset;
34401
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34251
+ [decoded, o] = new NumberCoder("u32").decode(data, o);
34252
+ const bytecodeLength = decoded;
34253
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34402
34254
  const bytecodeWitnessIndex = decoded;
34403
- [decoded, o] = new B256Coder().decode(data, o);
34404
- const salt = decoded;
34405
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34406
- const storageSlotsCount = decoded;
34407
34255
  [decoded, o] = new NumberCoder("u32").decode(data, o);
34408
34256
  const policyTypes = decoded;
34409
34257
  [decoded, o] = new NumberCoder("u16").decode(data, o);
34258
+ const storageSlotsCount = decoded;
34259
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34410
34260
  const inputsCount = decoded;
34411
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34261
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34412
34262
  const outputsCount = decoded;
34413
- [decoded, o] = new NumberCoder("u16").decode(data, o);
34263
+ [decoded, o] = new NumberCoder("u8").decode(data, o);
34414
34264
  const witnessesCount = decoded;
34415
- [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
34416
- data,
34417
- o
34418
- );
34419
- const storageSlots = decoded;
34265
+ [decoded, o] = new B256Coder().decode(data, o);
34266
+ const salt = decoded;
34420
34267
  [decoded, o] = new PoliciesCoder().decode(data, o, policyTypes);
34421
34268
  const policies = decoded;
34269
+ [decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount).decode(data, o);
34270
+ const storageSlots = decoded;
34422
34271
  [decoded, o] = new ArrayCoder(new InputCoder(), inputsCount).decode(data, o);
34423
34272
  const inputs = decoded;
34424
34273
  [decoded, o] = new ArrayCoder(new OutputCoder(), outputsCount).decode(data, o);
@@ -34428,6 +34277,7 @@ This unreleased fuel-core build may include features and updates not yet support
34428
34277
  return [
34429
34278
  {
34430
34279
  type: 1,
34280
+ bytecodeLength,
34431
34281
  bytecodeWitnessIndex,
34432
34282
  policyTypes,
34433
34283
  storageSlotsCount,
@@ -34456,7 +34306,6 @@ This unreleased fuel-core build may include features and updates not yet support
34456
34306
  parts.push(new OutputContractCoder().encode(value.outputContract));
34457
34307
  parts.push(new BigNumberCoder("u64").encode(value.mintAmount));
34458
34308
  parts.push(new B256Coder().encode(value.mintAssetId));
34459
- parts.push(new BigNumberCoder("u64").encode(value.gasPrice));
34460
34309
  return concat(parts);
34461
34310
  }
34462
34311
  decode(data, offset) {
@@ -34472,8 +34321,6 @@ This unreleased fuel-core build may include features and updates not yet support
34472
34321
  const mintAmount = decoded;
34473
34322
  [decoded, o] = new B256Coder().decode(data, o);
34474
34323
  const mintAssetId = decoded;
34475
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
34476
- const gasPrice = decoded;
34477
34324
  return [
34478
34325
  {
34479
34326
  type: 2,
@@ -34481,8 +34328,7 @@ This unreleased fuel-core build may include features and updates not yet support
34481
34328
  inputContract,
34482
34329
  outputContract,
34483
34330
  mintAmount,
34484
- mintAssetId,
34485
- gasPrice
34331
+ mintAssetId
34486
34332
  },
34487
34333
  o
34488
34334
  ];
@@ -34789,6 +34635,159 @@ This unreleased fuel-core build may include features and updates not yet support
34789
34635
  // src/providers/provider.ts
34790
34636
  var import_graphql_request = __toESM(require_dist2());
34791
34637
 
34638
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
34639
+ function _isPlaceholder(a) {
34640
+ return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
34641
+ }
34642
+
34643
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
34644
+ function _curry1(fn) {
34645
+ return function f1(a) {
34646
+ if (arguments.length === 0 || _isPlaceholder(a)) {
34647
+ return f1;
34648
+ } else {
34649
+ return fn.apply(this, arguments);
34650
+ }
34651
+ };
34652
+ }
34653
+
34654
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
34655
+ var isArray_default = Array.isArray || function _isArray(val) {
34656
+ return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
34657
+ };
34658
+
34659
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
34660
+ var type = /* @__PURE__ */ _curry1(function type2(val) {
34661
+ return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
34662
+ });
34663
+ var type_default = type;
34664
+
34665
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
34666
+ var pad = function pad2(n) {
34667
+ return (n < 10 ? "0" : "") + n;
34668
+ };
34669
+ var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
34670
+ return d.toISOString();
34671
+ } : function _toISOString3(d) {
34672
+ return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
34673
+ };
34674
+
34675
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
34676
+ var isInteger_default = Number.isInteger || function _isInteger(n) {
34677
+ return n << 0 === n;
34678
+ };
34679
+
34680
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
34681
+ function _cloneRegExp(pattern) {
34682
+ return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
34683
+ }
34684
+
34685
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
34686
+ function _clone(value, deep, map) {
34687
+ map || (map = new _ObjectMap());
34688
+ if (_isPrimitive(value)) {
34689
+ return value;
34690
+ }
34691
+ var copy = function copy2(copiedValue) {
34692
+ var cachedCopy = map.get(value);
34693
+ if (cachedCopy) {
34694
+ return cachedCopy;
34695
+ }
34696
+ map.set(value, copiedValue);
34697
+ for (var key in value) {
34698
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
34699
+ copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
34700
+ }
34701
+ }
34702
+ return copiedValue;
34703
+ };
34704
+ switch (type_default(value)) {
34705
+ case "Object":
34706
+ return copy(Object.create(Object.getPrototypeOf(value)));
34707
+ case "Array":
34708
+ return copy([]);
34709
+ case "Date":
34710
+ return new Date(value.valueOf());
34711
+ case "RegExp":
34712
+ return _cloneRegExp(value);
34713
+ case "Int8Array":
34714
+ case "Uint8Array":
34715
+ case "Uint8ClampedArray":
34716
+ case "Int16Array":
34717
+ case "Uint16Array":
34718
+ case "Int32Array":
34719
+ case "Uint32Array":
34720
+ case "Float32Array":
34721
+ case "Float64Array":
34722
+ case "BigInt64Array":
34723
+ case "BigUint64Array":
34724
+ return value.slice();
34725
+ default:
34726
+ return value;
34727
+ }
34728
+ }
34729
+ function _isPrimitive(param) {
34730
+ var type3 = typeof param;
34731
+ return param == null || type3 != "object" && type3 != "function";
34732
+ }
34733
+ var _ObjectMap = /* @__PURE__ */ function() {
34734
+ function _ObjectMap2() {
34735
+ this.map = {};
34736
+ this.length = 0;
34737
+ }
34738
+ _ObjectMap2.prototype.set = function(key, value) {
34739
+ const hashedKey = this.hash(key);
34740
+ let bucket = this.map[hashedKey];
34741
+ if (!bucket) {
34742
+ this.map[hashedKey] = bucket = [];
34743
+ }
34744
+ bucket.push([key, value]);
34745
+ this.length += 1;
34746
+ };
34747
+ _ObjectMap2.prototype.hash = function(key) {
34748
+ let hashedKey = [];
34749
+ for (var value in key) {
34750
+ hashedKey.push(Object.prototype.toString.call(key[value]));
34751
+ }
34752
+ return hashedKey.join();
34753
+ };
34754
+ _ObjectMap2.prototype.get = function(key) {
34755
+ if (this.length <= 180) {
34756
+ for (const p in this.map) {
34757
+ const bucket2 = this.map[p];
34758
+ for (let i = 0; i < bucket2.length; i += 1) {
34759
+ const element = bucket2[i];
34760
+ if (element[0] === key) {
34761
+ return element[1];
34762
+ }
34763
+ }
34764
+ }
34765
+ return;
34766
+ }
34767
+ const hashedKey = this.hash(key);
34768
+ const bucket = this.map[hashedKey];
34769
+ if (!bucket) {
34770
+ return;
34771
+ }
34772
+ for (let i = 0; i < bucket.length; i += 1) {
34773
+ const element = bucket[i];
34774
+ if (element[0] === key) {
34775
+ return element[1];
34776
+ }
34777
+ }
34778
+ };
34779
+ return _ObjectMap2;
34780
+ }();
34781
+
34782
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
34783
+ var clone2 = /* @__PURE__ */ _curry1(function clone3(value) {
34784
+ return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
34785
+ });
34786
+ var clone_default = clone2;
34787
+
34788
+ // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
34789
+ var hasProtoTrim = typeof String.prototype.trim === "function";
34790
+
34792
34791
  // ../../node_modules/.pnpm/tslib@2.6.0/node_modules/tslib/tslib.es6.mjs
34793
34792
  var __assign = function() {
34794
34793
  __assign = Object.assign || function __assign2(t) {
@@ -37954,8 +37953,44 @@ spurious results.`);
37954
37953
  var lib_default2 = gql;
37955
37954
 
37956
37955
  // src/providers/__generated__/operations.ts
37957
- var TransactionStatusSubscriptionFragmentFragmentDoc = lib_default2`
37958
- fragment transactionStatusSubscriptionFragment on TransactionStatus {
37956
+ var ReceiptFragmentFragmentDoc = lib_default2`
37957
+ fragment receiptFragment on Receipt {
37958
+ contract {
37959
+ id
37960
+ }
37961
+ pc
37962
+ is
37963
+ to {
37964
+ id
37965
+ }
37966
+ toAddress
37967
+ amount
37968
+ assetId
37969
+ gas
37970
+ param1
37971
+ param2
37972
+ val
37973
+ ptr
37974
+ digest
37975
+ reason
37976
+ ra
37977
+ rb
37978
+ rc
37979
+ rd
37980
+ len
37981
+ receiptType
37982
+ result
37983
+ gasUsed
37984
+ data
37985
+ sender
37986
+ recipient
37987
+ nonce
37988
+ contractId
37989
+ subId
37990
+ }
37991
+ `;
37992
+ var TransactionStatusFragmentFragmentDoc = lib_default2`
37993
+ fragment transactionStatusFragment on TransactionStatus {
37959
37994
  type: __typename
37960
37995
  ... on SubmittedStatus {
37961
37996
  time
@@ -37982,84 +38017,20 @@ spurious results.`);
37982
38017
  }
37983
38018
  }
37984
38019
  `;
37985
- var ReceiptFragmentFragmentDoc = lib_default2`
37986
- fragment receiptFragment on Receipt {
37987
- id
37988
- pc
37989
- is
37990
- to
37991
- toAddress
37992
- amount
37993
- assetId
37994
- gas
37995
- param1
37996
- param2
37997
- val
37998
- ptr
37999
- digest
38000
- reason
38001
- ra
38002
- rb
38003
- rc
38004
- rd
38005
- len
38006
- receiptType
38007
- result
38008
- gasUsed
38009
- data
38010
- sender
38011
- recipient
38012
- nonce
38013
- contractId
38014
- subId
38015
- }
38016
- `;
38017
- var TransactionStatusFragmentFragmentDoc = lib_default2`
38018
- fragment transactionStatusFragment on TransactionStatus {
38019
- type: __typename
38020
- ... on SubmittedStatus {
38021
- time
38022
- }
38023
- ... on SuccessStatus {
38024
- block {
38025
- id
38026
- }
38027
- time
38028
- receipts {
38029
- ...receiptFragment
38030
- }
38031
- programState {
38032
- returnType
38033
- data
38034
- }
38035
- receipts {
38036
- ...receiptFragment
38037
- }
38038
- }
38039
- ... on FailureStatus {
38040
- block {
38041
- id
38042
- }
38043
- time
38044
- reason
38045
- receipts {
38046
- ...receiptFragment
38047
- }
38048
- }
38049
- ... on SqueezedOutStatus {
38050
- reason
38051
- }
38052
- }
38053
- ${ReceiptFragmentFragmentDoc}`;
38054
38020
  var TransactionFragmentFragmentDoc = lib_default2`
38055
38021
  fragment transactionFragment on Transaction {
38056
38022
  id
38057
38023
  rawPayload
38024
+ gasPrice
38025
+ receipts {
38026
+ ...receiptFragment
38027
+ }
38058
38028
  status {
38059
38029
  ...transactionStatusFragment
38060
38030
  }
38061
38031
  }
38062
- ${TransactionStatusFragmentFragmentDoc}`;
38032
+ ${ReceiptFragmentFragmentDoc}
38033
+ ${TransactionStatusFragmentFragmentDoc}`;
38063
38034
  var InputEstimatePredicatesFragmentFragmentDoc = lib_default2`
38064
38035
  fragment inputEstimatePredicatesFragment on Input {
38065
38036
  ... on InputCoin {
@@ -38077,46 +38048,6 @@ spurious results.`);
38077
38048
  }
38078
38049
  }
38079
38050
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
38080
- var DryRunFailureStatusFragmentFragmentDoc = lib_default2`
38081
- fragment dryRunFailureStatusFragment on DryRunFailureStatus {
38082
- reason
38083
- programState {
38084
- returnType
38085
- data
38086
- }
38087
- }
38088
- `;
38089
- var DryRunSuccessStatusFragmentFragmentDoc = lib_default2`
38090
- fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
38091
- programState {
38092
- returnType
38093
- data
38094
- }
38095
- }
38096
- `;
38097
- var DryRunTransactionStatusFragmentFragmentDoc = lib_default2`
38098
- fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
38099
- ... on DryRunFailureStatus {
38100
- ...dryRunFailureStatusFragment
38101
- }
38102
- ... on DryRunSuccessStatus {
38103
- ...dryRunSuccessStatusFragment
38104
- }
38105
- }
38106
- ${DryRunFailureStatusFragmentFragmentDoc}
38107
- ${DryRunSuccessStatusFragmentFragmentDoc}`;
38108
- var DryRunTransactionExecutionStatusFragmentFragmentDoc = lib_default2`
38109
- fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
38110
- id
38111
- status {
38112
- ...dryRunTransactionStatusFragment
38113
- }
38114
- receipts {
38115
- ...receiptFragment
38116
- }
38117
- }
38118
- ${DryRunTransactionStatusFragmentFragmentDoc}
38119
- ${ReceiptFragmentFragmentDoc}`;
38120
38051
  var CoinFragmentFragmentDoc = lib_default2`
38121
38052
  fragment coinFragment on Coin {
38122
38053
  __typename
@@ -38124,6 +38055,7 @@ ${ReceiptFragmentFragmentDoc}`;
38124
38055
  owner
38125
38056
  amount
38126
38057
  assetId
38058
+ maturity
38127
38059
  blockCreated
38128
38060
  txCreatedIdx
38129
38061
  }
@@ -38162,32 +38094,26 @@ ${ReceiptFragmentFragmentDoc}`;
38162
38094
  messageBlockHeader {
38163
38095
  id
38164
38096
  daHeight
38165
- consensusParametersVersion
38166
- stateTransitionBytecodeVersion
38167
38097
  transactionsCount
38168
- messageReceiptCount
38169
38098
  transactionsRoot
38170
- messageOutboxRoot
38171
- eventInboxRoot
38172
38099
  height
38173
38100
  prevRoot
38174
38101
  time
38175
38102
  applicationHash
38103
+ messageReceiptRoot
38104
+ messageReceiptCount
38176
38105
  }
38177
38106
  commitBlockHeader {
38178
38107
  id
38179
38108
  daHeight
38180
- consensusParametersVersion
38181
- stateTransitionBytecodeVersion
38182
38109
  transactionsCount
38183
- messageReceiptCount
38184
38110
  transactionsRoot
38185
- messageOutboxRoot
38186
- eventInboxRoot
38187
38111
  height
38188
38112
  prevRoot
38189
38113
  time
38190
38114
  applicationHash
38115
+ messageReceiptRoot
38116
+ messageReceiptCount
38191
38117
  }
38192
38118
  sender
38193
38119
  recipient
@@ -38206,8 +38132,8 @@ ${ReceiptFragmentFragmentDoc}`;
38206
38132
  var BlockFragmentFragmentDoc = lib_default2`
38207
38133
  fragment blockFragment on Block {
38208
38134
  id
38209
- height
38210
38135
  header {
38136
+ height
38211
38137
  time
38212
38138
  }
38213
38139
  transactions {
@@ -38265,11 +38191,6 @@ ${ReceiptFragmentFragmentDoc}`;
38265
38191
  `;
38266
38192
  var GasCostsFragmentFragmentDoc = lib_default2`
38267
38193
  fragment GasCostsFragment on GasCosts {
38268
- version {
38269
- ... on Version {
38270
- value
38271
- }
38272
- }
38273
38194
  add
38274
38195
  addi
38275
38196
  aloc
@@ -38282,6 +38203,7 @@ ${ReceiptFragmentFragmentDoc}`;
38282
38203
  cb
38283
38204
  cfei
38284
38205
  cfsi
38206
+ croo
38285
38207
  div
38286
38208
  divi
38287
38209
  ecr1
@@ -38364,9 +38286,6 @@ ${ReceiptFragmentFragmentDoc}`;
38364
38286
  ccp {
38365
38287
  ...DependentCostFragment
38366
38288
  }
38367
- croo {
38368
- ...DependentCostFragment
38369
- }
38370
38289
  csiz {
38371
38290
  ...DependentCostFragment
38372
38291
  }
@@ -38426,11 +38345,6 @@ ${ReceiptFragmentFragmentDoc}`;
38426
38345
  ${DependentCostFragmentFragmentDoc}`;
38427
38346
  var ConsensusParametersFragmentFragmentDoc = lib_default2`
38428
38347
  fragment consensusParametersFragment on ConsensusParameters {
38429
- version {
38430
- ... on Version {
38431
- value
38432
- }
38433
- }
38434
38348
  txParams {
38435
38349
  ...TxParametersFragment
38436
38350
  }
@@ -38490,9 +38404,18 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38490
38404
  fragment nodeInfoFragment on NodeInfo {
38491
38405
  utxoValidation
38492
38406
  vmBacktrace
38407
+ minGasPrice
38493
38408
  maxTx
38494
38409
  maxDepth
38495
38410
  nodeVersion
38411
+ peers {
38412
+ id
38413
+ addresses
38414
+ clientVersion
38415
+ blockHeight
38416
+ lastHeartbeatMs
38417
+ appScore
38418
+ }
38496
38419
  }
38497
38420
  `;
38498
38421
  var GetVersionDocument = lib_default2`
@@ -38527,9 +38450,13 @@ ${ConsensusParametersFragmentFragmentDoc}`;
38527
38450
  query getTransactionWithReceipts($transactionId: TransactionId!) {
38528
38451
  transaction(id: $transactionId) {
38529
38452
  ...transactionFragment
38453
+ receipts {
38454
+ ...receiptFragment
38455
+ }
38530
38456
  }
38531
38457
  }
38532
- ${TransactionFragmentFragmentDoc}`;
38458
+ ${TransactionFragmentFragmentDoc}
38459
+ ${ReceiptFragmentFragmentDoc}`;
38533
38460
  var GetTransactionsDocument = lib_default2`
38534
38461
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
38535
38462
  transactions(after: $after, before: $before, first: $first, last: $last) {
@@ -38657,20 +38584,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38657
38584
  }
38658
38585
  }
38659
38586
  ${BalanceFragmentFragmentDoc}`;
38660
- var GetLatestGasPriceDocument = lib_default2`
38661
- query getLatestGasPrice {
38662
- latestGasPrice {
38663
- gasPrice
38664
- }
38665
- }
38666
- `;
38667
- var EstimateGasPriceDocument = lib_default2`
38668
- query estimateGasPrice($blockHorizon: U32!) {
38669
- estimateGasPrice(blockHorizon: $blockHorizon) {
38670
- gasPrice
38671
- }
38672
- }
38673
- `;
38674
38587
  var GetBalancesDocument = lib_default2`
38675
38588
  query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
38676
38589
  balances(
@@ -38725,12 +38638,12 @@ ${MessageCoinFragmentFragmentDoc}`;
38725
38638
  }
38726
38639
  `;
38727
38640
  var DryRunDocument = lib_default2`
38728
- mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
38729
- dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
38730
- ...dryRunTransactionExecutionStatusFragment
38641
+ mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
38642
+ dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
38643
+ ...receiptFragment
38731
38644
  }
38732
38645
  }
38733
- ${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
38646
+ ${ReceiptFragmentFragmentDoc}`;
38734
38647
  var SubmitDocument = lib_default2`
38735
38648
  mutation submit($encodedTransaction: HexString!) {
38736
38649
  submit(tx: $encodedTransaction) {
@@ -38749,17 +38662,17 @@ ${MessageCoinFragmentFragmentDoc}`;
38749
38662
  var SubmitAndAwaitDocument = lib_default2`
38750
38663
  subscription submitAndAwait($encodedTransaction: HexString!) {
38751
38664
  submitAndAwait(tx: $encodedTransaction) {
38752
- ...transactionStatusSubscriptionFragment
38665
+ ...transactionStatusFragment
38753
38666
  }
38754
38667
  }
38755
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
38668
+ ${TransactionStatusFragmentFragmentDoc}`;
38756
38669
  var StatusChangeDocument = lib_default2`
38757
38670
  subscription statusChange($transactionId: TransactionId!) {
38758
38671
  statusChange(id: $transactionId) {
38759
- ...transactionStatusSubscriptionFragment
38672
+ ...transactionStatusFragment
38760
38673
  }
38761
38674
  }
38762
- ${TransactionStatusSubscriptionFragmentFragmentDoc}`;
38675
+ ${TransactionStatusFragmentFragmentDoc}`;
38763
38676
  function getSdk(requester) {
38764
38677
  return {
38765
38678
  getVersion(variables, options) {
@@ -38813,12 +38726,6 @@ ${MessageCoinFragmentFragmentDoc}`;
38813
38726
  getBalance(variables, options) {
38814
38727
  return requester(GetBalanceDocument, variables, options);
38815
38728
  },
38816
- getLatestGasPrice(variables, options) {
38817
- return requester(GetLatestGasPriceDocument, variables, options);
38818
- },
38819
- estimateGasPrice(variables, options) {
38820
- return requester(EstimateGasPriceDocument, variables, options);
38821
- },
38822
38729
  getBalances(variables, options) {
38823
38730
  return requester(GetBalancesDocument, variables, options);
38824
38731
  },
@@ -39002,9 +38909,10 @@ ${MessageCoinFragmentFragmentDoc}`;
39002
38909
  txIndex: toNumber2(arrayify(value.txPointer).slice(8, 16))
39003
38910
  },
39004
38911
  witnessIndex: value.witnessIndex,
38912
+ maturity: value.maturity ?? 0,
39005
38913
  predicateGasUsed: bn(value.predicateGasUsed),
39006
- predicateLength: bn(predicate.length),
39007
- predicateDataLength: bn(predicateData.length),
38914
+ predicateLength: predicate.length,
38915
+ predicateDataLength: predicateData.length,
39008
38916
  predicate: hexlify(predicate),
39009
38917
  predicateData: hexlify(predicateData)
39010
38918
  };
@@ -39035,8 +38943,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39035
38943
  nonce: hexlify(value.nonce),
39036
38944
  witnessIndex: value.witnessIndex,
39037
38945
  predicateGasUsed: bn(value.predicateGasUsed),
39038
- predicateLength: bn(predicate.length),
39039
- predicateDataLength: bn(predicateData.length),
38946
+ predicateLength: predicate.length,
38947
+ predicateDataLength: predicateData.length,
39040
38948
  predicate: hexlify(predicate),
39041
38949
  predicateData: hexlify(predicateData),
39042
38950
  data: hexlify(data),
@@ -39196,8 +39104,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39196
39104
  case "CALL" /* Call */: {
39197
39105
  const callReceipt = {
39198
39106
  type: ReceiptType.Call,
39199
- from: hexOrZero(receipt.id || receipt.contractId),
39200
- to: hexOrZero(receipt?.to),
39107
+ from: hexOrZero(receipt.contract?.id),
39108
+ to: hexOrZero(receipt?.to?.id),
39201
39109
  amount: bn(receipt.amount),
39202
39110
  assetId: hexOrZero(receipt.assetId),
39203
39111
  gas: bn(receipt.gas),
@@ -39211,7 +39119,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39211
39119
  case "RETURN" /* Return */: {
39212
39120
  const returnReceipt = {
39213
39121
  type: ReceiptType.Return,
39214
- id: hexOrZero(receipt.id || receipt.contractId),
39122
+ id: hexOrZero(receipt.contract?.id),
39215
39123
  val: bn(receipt.val),
39216
39124
  pc: bn(receipt.pc),
39217
39125
  is: bn(receipt.is)
@@ -39221,7 +39129,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39221
39129
  case "RETURN_DATA" /* ReturnData */: {
39222
39130
  const returnDataReceipt = {
39223
39131
  type: ReceiptType.ReturnData,
39224
- id: hexOrZero(receipt.id || receipt.contractId),
39132
+ id: hexOrZero(receipt.contract?.id),
39225
39133
  ptr: bn(receipt.ptr),
39226
39134
  len: bn(receipt.len),
39227
39135
  digest: hexOrZero(receipt.digest),
@@ -39233,7 +39141,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39233
39141
  case "PANIC" /* Panic */: {
39234
39142
  const panicReceipt = {
39235
39143
  type: ReceiptType.Panic,
39236
- id: hexOrZero(receipt.id),
39144
+ id: hexOrZero(receipt.contract?.id),
39237
39145
  reason: bn(receipt.reason),
39238
39146
  pc: bn(receipt.pc),
39239
39147
  is: bn(receipt.is),
@@ -39244,7 +39152,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39244
39152
  case "REVERT" /* Revert */: {
39245
39153
  const revertReceipt = {
39246
39154
  type: ReceiptType.Revert,
39247
- id: hexOrZero(receipt.id || receipt.contractId),
39155
+ id: hexOrZero(receipt.contract?.id),
39248
39156
  val: bn(receipt.ra),
39249
39157
  pc: bn(receipt.pc),
39250
39158
  is: bn(receipt.is)
@@ -39254,7 +39162,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39254
39162
  case "LOG" /* Log */: {
39255
39163
  const logReceipt = {
39256
39164
  type: ReceiptType.Log,
39257
- id: hexOrZero(receipt.id || receipt.contractId),
39165
+ id: hexOrZero(receipt.contract?.id),
39258
39166
  val0: bn(receipt.ra),
39259
39167
  val1: bn(receipt.rb),
39260
39168
  val2: bn(receipt.rc),
@@ -39267,7 +39175,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39267
39175
  case "LOG_DATA" /* LogData */: {
39268
39176
  const logDataReceipt = {
39269
39177
  type: ReceiptType.LogData,
39270
- id: hexOrZero(receipt.id || receipt.contractId),
39178
+ id: hexOrZero(receipt.contract?.id),
39271
39179
  val0: bn(receipt.ra),
39272
39180
  val1: bn(receipt.rb),
39273
39181
  ptr: bn(receipt.ptr),
@@ -39281,8 +39189,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39281
39189
  case "TRANSFER" /* Transfer */: {
39282
39190
  const transferReceipt = {
39283
39191
  type: ReceiptType.Transfer,
39284
- from: hexOrZero(receipt.id || receipt.contractId),
39285
- to: hexOrZero(receipt.toAddress || receipt?.to),
39192
+ from: hexOrZero(receipt.contract?.id),
39193
+ to: hexOrZero(receipt.toAddress || receipt?.to?.id),
39286
39194
  amount: bn(receipt.amount),
39287
39195
  assetId: hexOrZero(receipt.assetId),
39288
39196
  pc: bn(receipt.pc),
@@ -39293,8 +39201,8 @@ ${MessageCoinFragmentFragmentDoc}`;
39293
39201
  case "TRANSFER_OUT" /* TransferOut */: {
39294
39202
  const transferOutReceipt = {
39295
39203
  type: ReceiptType.TransferOut,
39296
- from: hexOrZero(receipt.id || receipt.contractId),
39297
- to: hexOrZero(receipt.toAddress || receipt.to),
39204
+ from: hexOrZero(receipt.contract?.id),
39205
+ to: hexOrZero(receipt.toAddress || receipt.to?.id),
39298
39206
  amount: bn(receipt.amount),
39299
39207
  assetId: hexOrZero(receipt.assetId),
39300
39208
  pc: bn(receipt.pc),
@@ -39337,7 +39245,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39337
39245
  return receiptMessageOut;
39338
39246
  }
39339
39247
  case "MINT" /* Mint */: {
39340
- const contractId = hexOrZero(receipt.id || receipt.contractId);
39248
+ const contractId = hexOrZero(receipt.contract?.id);
39341
39249
  const subId = hexOrZero(receipt.subId);
39342
39250
  const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
39343
39251
  const mintReceipt = {
@@ -39352,7 +39260,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39352
39260
  return mintReceipt;
39353
39261
  }
39354
39262
  case "BURN" /* Burn */: {
39355
- const contractId = hexOrZero(receipt.id || receipt.contractId);
39263
+ const contractId = hexOrZero(receipt.contract?.id);
39356
39264
  const subId = hexOrZero(receipt.subId);
39357
39265
  const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
39358
39266
  const burnReceipt = {
@@ -39433,6 +39341,7 @@ ${MessageCoinFragmentFragmentDoc}`;
39433
39341
  };
39434
39342
 
39435
39343
  // src/providers/utils/gas.ts
39344
+ var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
39436
39345
  var getGasUsedFromReceipts = (receipts) => {
39437
39346
  const scriptResult = receipts.filter(
39438
39347
  (receipt) => receipt.type === ReceiptType.ScriptResult
@@ -39453,28 +39362,18 @@ ${MessageCoinFragmentFragmentDoc}`;
39453
39362
  }
39454
39363
  function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
39455
39364
  const witnessCache = [];
39456
- const chargeableInputs = inputs.filter((input) => {
39457
- const isCoinOrMessage = "owner" in input || "sender" in input;
39458
- if (isCoinOrMessage) {
39459
- if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39460
- return true;
39461
- }
39462
- if (!witnessCache.includes(input.witnessIndex)) {
39463
- witnessCache.push(input.witnessIndex);
39464
- return true;
39465
- }
39466
- }
39467
- return false;
39468
- });
39469
- const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
39470
- const totalGas = chargeableInputs.reduce((total, input) => {
39365
+ const totalGas = inputs.reduce((total, input) => {
39471
39366
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
39472
39367
  return total.add(
39473
- vmInitializationCost.add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39368
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify(input.predicate).length, gasCosts.contractRoot)).add(bn(input.predicateGasUsed))
39474
39369
  );
39475
39370
  }
39476
- return total.add(gasCosts.ecr1);
39477
- }, bn(0));
39371
+ if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
39372
+ witnessCache.push(input.witnessIndex);
39373
+ return total.add(gasCosts.ecr1);
39374
+ }
39375
+ return total;
39376
+ }, bn());
39478
39377
  return totalGas;
39479
39378
  }
39480
39379
  function getMinGas(params) {
@@ -39486,20 +39385,12 @@ ${MessageCoinFragmentFragmentDoc}`;
39486
39385
  return minGas;
39487
39386
  }
39488
39387
  function getMaxGas(params) {
39489
- const {
39490
- gasPerByte,
39491
- witnessesLength,
39492
- witnessLimit,
39493
- minGas,
39494
- gasLimit = bn(0),
39495
- maxGasPerTx
39496
- } = params;
39388
+ const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn(0) } = params;
39497
39389
  let remainingAllowedWitnessGas = bn(0);
39498
39390
  if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
39499
39391
  remainingAllowedWitnessGas = bn(witnessLimit).sub(witnessesLength).mul(gasPerByte);
39500
39392
  }
39501
- const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39502
- return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
39393
+ return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
39503
39394
  }
39504
39395
  function calculateMetadataGasForTxCreate({
39505
39396
  gasCosts,
@@ -39521,10 +39412,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39521
39412
  }) {
39522
39413
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
39523
39414
  }
39524
- var calculateGasFee = (params) => {
39525
- const { gas, gasPrice, priceFactor, tip } = params;
39526
- return gas.mul(gasPrice).div(priceFactor).add(tip);
39527
- };
39528
39415
 
39529
39416
  // src/providers/utils/json.ts
39530
39417
  function normalize2(object) {
@@ -39666,7 +39553,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39666
39553
  // src/providers/transaction-request/transaction-request.ts
39667
39554
  var BaseTransactionRequest = class {
39668
39555
  /** Gas price for transaction */
39669
- tip;
39556
+ gasPrice;
39670
39557
  /** Block until which tx cannot be included */
39671
39558
  maturity;
39672
39559
  /** The maximum fee payable by this transaction using BASE_ASSET. */
@@ -39685,7 +39572,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39685
39572
  * @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
39686
39573
  */
39687
39574
  constructor({
39688
- tip,
39575
+ gasPrice,
39689
39576
  maturity,
39690
39577
  maxFee,
39691
39578
  witnessLimit,
@@ -39693,7 +39580,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39693
39580
  outputs,
39694
39581
  witnesses
39695
39582
  } = {}) {
39696
- this.tip = bn(tip);
39583
+ this.gasPrice = bn(gasPrice);
39697
39584
  this.maturity = maturity ?? 0;
39698
39585
  this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
39699
39586
  this.maxFee = maxFee ? bn(maxFee) : void 0;
@@ -39704,9 +39591,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39704
39591
  static getPolicyMeta(req) {
39705
39592
  let policyTypes = 0;
39706
39593
  const policies = [];
39707
- if (req.tip) {
39708
- policyTypes += PolicyType.Tip;
39709
- policies.push({ data: req.tip, type: PolicyType.Tip });
39594
+ if (req.gasPrice) {
39595
+ policyTypes += PolicyType.GasPrice;
39596
+ policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
39710
39597
  }
39711
39598
  if (req.witnessLimit) {
39712
39599
  policyTypes += PolicyType.WitnessLimit;
@@ -39890,11 +39777,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39890
39777
  * assetId, if one it was not added yet.
39891
39778
  *
39892
39779
  * @param coin - Coin resource.
39780
+ * @param predicate - Predicate bytes.
39781
+ * @param predicateData - Predicate data bytes.
39893
39782
  */
39894
- addCoinInput(coin) {
39783
+ addCoinInput(coin, predicate) {
39895
39784
  const { assetId, owner, amount } = coin;
39896
39785
  let witnessIndex;
39897
- if (coin.predicate) {
39786
+ if (predicate) {
39898
39787
  witnessIndex = 0;
39899
39788
  } else {
39900
39789
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
@@ -39909,7 +39798,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39909
39798
  amount,
39910
39799
  assetId,
39911
39800
  txPointer: "0x00000000000000000000000000000000",
39912
- witnessIndex
39801
+ witnessIndex,
39802
+ predicate: predicate?.bytes
39913
39803
  };
39914
39804
  this.pushInput(input);
39915
39805
  this.addChangeOutput(owner, assetId);
@@ -39919,12 +39809,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39919
39809
  * baseAssetId, if one it was not added yet.
39920
39810
  *
39921
39811
  * @param message - Message resource.
39812
+ * @param predicate - Predicate bytes.
39813
+ * @param predicateData - Predicate data bytes.
39922
39814
  */
39923
- addMessageInput(message) {
39815
+ addMessageInput(message, predicate) {
39924
39816
  const { recipient, sender, amount } = message;
39925
39817
  const assetId = BaseAssetId;
39926
39818
  let witnessIndex;
39927
- if (message.predicate) {
39819
+ if (predicate) {
39928
39820
  witnessIndex = 0;
39929
39821
  } else {
39930
39822
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
@@ -39938,7 +39830,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39938
39830
  sender: sender.toB256(),
39939
39831
  recipient: recipient.toB256(),
39940
39832
  amount,
39941
- witnessIndex
39833
+ witnessIndex,
39834
+ predicate: predicate?.bytes
39942
39835
  };
39943
39836
  this.pushInput(input);
39944
39837
  this.addChangeOutput(recipient, assetId);
@@ -39969,6 +39862,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39969
39862
  resources.forEach((resource) => this.addResource(resource));
39970
39863
  return this;
39971
39864
  }
39865
+ /**
39866
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
39867
+ * outputs from the related assetIds.
39868
+ *
39869
+ * @param resources - The resources to add.
39870
+ * @returns This transaction.
39871
+ */
39872
+ addPredicateResource(resource, predicate) {
39873
+ if (isCoin(resource)) {
39874
+ this.addCoinInput(resource, predicate);
39875
+ } else {
39876
+ this.addMessageInput(resource, predicate);
39877
+ }
39878
+ return this;
39879
+ }
39880
+ /**
39881
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
39882
+ * from the related assetIds.
39883
+ *
39884
+ * @param resources - The resources to add.
39885
+ * @returns This transaction.
39886
+ */
39887
+ addPredicateResources(resources, predicate) {
39888
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
39889
+ return this;
39890
+ }
39972
39891
  /**
39973
39892
  * Adds a coin output to the transaction.
39974
39893
  *
@@ -40048,7 +39967,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40048
39967
  }
40049
39968
  calculateMaxGas(chainInfo, minGas) {
40050
39969
  const { consensusParameters } = chainInfo;
40051
- const { gasPerByte, maxGasPerTx } = consensusParameters;
39970
+ const { gasPerByte } = consensusParameters;
40052
39971
  const witnessesLength = this.toTransaction().witnesses.reduce(
40053
39972
  (acc, wit) => acc + wit.dataLength,
40054
39973
  0
@@ -40057,8 +39976,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40057
39976
  gasPerByte,
40058
39977
  minGas,
40059
39978
  witnessesLength,
40060
- witnessLimit: this.witnessLimit,
40061
- maxGasPerTx
39979
+ witnessLimit: this.witnessLimit
40062
39980
  });
40063
39981
  }
40064
39982
  /**
@@ -40076,20 +39994,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40076
39994
  });
40077
39995
  const updateAssetInput = (assetId, quantity) => {
40078
39996
  const assetInput = findAssetInput(assetId);
40079
- let usedQuantity = quantity;
40080
- if (assetId === BaseAssetId) {
40081
- usedQuantity = bn("1000000000000000000");
40082
- }
40083
39997
  if (assetInput && "assetId" in assetInput) {
40084
39998
  assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
40085
- assetInput.amount = usedQuantity;
39999
+ assetInput.amount = quantity;
40086
40000
  } else {
40087
40001
  this.addResources([
40088
40002
  {
40089
40003
  id: hexlify(randomBytes22(UTXO_ID_LEN)),
40090
- amount: usedQuantity,
40004
+ amount: quantity,
40091
40005
  assetId,
40092
40006
  owner: resourcesOwner || Address.fromRandom(),
40007
+ maturity: 0,
40093
40008
  blockCreated: bn(1),
40094
40009
  txCreatedIdx: bn(1)
40095
40010
  }
@@ -40121,7 +40036,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40121
40036
  toJSON() {
40122
40037
  return normalizeJSON(this);
40123
40038
  }
40124
- updatePredicateGasUsed(inputs) {
40039
+ updatePredicateInputs(inputs) {
40125
40040
  this.inputs.forEach((i) => {
40126
40041
  let correspondingInput;
40127
40042
  switch (i.type) {
@@ -40143,15 +40058,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40143
40058
  }
40144
40059
  });
40145
40060
  }
40146
- shiftPredicateData() {
40147
- this.inputs.forEach((input) => {
40148
- if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
40149
- input.predicateData = input.paddPredicateData(
40150
- BaseTransactionRequest.getPolicyMeta(this).policies.length
40151
- );
40152
- }
40153
- });
40154
- }
40155
40061
  };
40156
40062
 
40157
40063
  // src/providers/transaction-request/hash-transaction.ts
@@ -40285,8 +40191,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40285
40191
  return {
40286
40192
  type: TransactionType.Create,
40287
40193
  ...baseTransaction,
40194
+ bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
40288
40195
  bytecodeWitnessIndex,
40289
- storageSlotsCount: bn(storageSlots.length),
40196
+ storageSlotsCount: storageSlots.length,
40290
40197
  salt: this.salt ? hexlify(this.salt) : ZeroBytes32,
40291
40198
  storageSlots
40292
40199
  };
@@ -40400,8 +40307,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40400
40307
  type: TransactionType.Script,
40401
40308
  scriptGasLimit: this.gasLimit,
40402
40309
  ...super.getBaseTransaction(),
40403
- scriptLength: bn(script.length),
40404
- scriptDataLength: bn(scriptData.length),
40310
+ scriptLength: script.length,
40311
+ scriptDataLength: scriptData.length,
40405
40312
  receiptsRoot: ZeroBytes32,
40406
40313
  script: hexlify(script),
40407
40314
  scriptData: hexlify(scriptData)
@@ -40465,7 +40372,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40465
40372
  }
40466
40373
  calculateMaxGas(chainInfo, minGas) {
40467
40374
  const { consensusParameters } = chainInfo;
40468
- const { gasPerByte, maxGasPerTx } = consensusParameters;
40375
+ const { gasPerByte } = consensusParameters;
40469
40376
  const witnessesLength = this.toTransaction().witnesses.reduce(
40470
40377
  (acc, wit) => acc + wit.dataLength,
40471
40378
  0
@@ -40475,8 +40382,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40475
40382
  minGas,
40476
40383
  witnessesLength,
40477
40384
  witnessLimit: this.witnessLimit,
40478
- gasLimit: this.gasLimit,
40479
- maxGasPerTx
40385
+ gasLimit: this.gasLimit
40480
40386
  });
40481
40387
  }
40482
40388
  /**
@@ -40549,29 +40455,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40549
40455
  }
40550
40456
  }
40551
40457
  };
40552
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
40553
- (acc, input) => {
40554
- if (input.type === InputType.Coin && input.owner === owner) {
40555
- acc.utxos.push(input.id);
40556
- }
40557
- if (input.type === InputType.Message && input.recipient === owner) {
40558
- acc.messages.push(input.nonce);
40559
- }
40560
- return acc;
40561
- },
40562
- {
40563
- utxos: [],
40564
- messages: []
40565
- }
40566
- );
40567
40458
 
40568
40459
  // src/providers/transaction-summary/calculate-transaction-fee.ts
40569
40460
  var calculateTransactionFee = (params) => {
40570
40461
  const {
40571
- gasPrice,
40462
+ gasUsed,
40572
40463
  rawPayload,
40573
- tip,
40574
- consensusParameters: { gasCosts, feeParams, maxGasPerTx }
40464
+ consensusParameters: { gasCosts, feeParams }
40575
40465
  } = params;
40576
40466
  const gasPerByte = bn(feeParams.gasPerByte);
40577
40467
  const gasPriceFactor = bn(feeParams.gasPriceFactor);
@@ -40581,7 +40471,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40581
40471
  return {
40582
40472
  fee: bn(0),
40583
40473
  minFee: bn(0),
40584
- maxFee: bn(0)
40474
+ maxFee: bn(0),
40475
+ feeFromGasUsed: bn(0)
40585
40476
  };
40586
40477
  }
40587
40478
  const { type: type3, witnesses, inputs, policies } = transaction;
@@ -40613,6 +40504,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40613
40504
  metadataGas,
40614
40505
  txBytesSize: transactionBytes.length
40615
40506
  });
40507
+ const gasPrice = bn(policies.find((policy) => policy.type === PolicyType.GasPrice)?.data);
40616
40508
  const witnessLimit = policies.find((policy) => policy.type === PolicyType.WitnessLimit)?.data;
40617
40509
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
40618
40510
  const maxGas = getMaxGas({
@@ -40620,25 +40512,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40620
40512
  minGas,
40621
40513
  witnessesLength,
40622
40514
  gasLimit,
40623
- witnessLimit,
40624
- maxGasPerTx
40625
- });
40626
- const minFee = calculateGasFee({
40627
- gasPrice,
40628
- gas: minGas,
40629
- priceFactor: gasPriceFactor,
40630
- tip
40631
- });
40632
- const maxFee = calculateGasFee({
40633
- gasPrice,
40634
- gas: maxGas,
40635
- priceFactor: gasPriceFactor,
40636
- tip
40515
+ witnessLimit
40637
40516
  });
40517
+ const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
40518
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
40519
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
40520
+ const fee = minFee.add(feeFromGasUsed);
40638
40521
  return {
40522
+ fee,
40639
40523
  minFee,
40640
40524
  maxFee,
40641
- fee: maxFee
40525
+ feeFromGasUsed
40642
40526
  };
40643
40527
  };
40644
40528
 
@@ -41239,9 +41123,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41239
41123
  gqlTransactionStatus,
41240
41124
  abiMap = {},
41241
41125
  maxInputs,
41242
- gasCosts,
41243
- maxGasPerTx,
41244
- gasPrice
41126
+ gasCosts
41245
41127
  } = params;
41246
41128
  const gasUsed = getGasUsedFromReceipts(receipts);
41247
41129
  const rawPayload = hexlify(transactionBytes);
@@ -41255,14 +41137,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41255
41137
  maxInputs
41256
41138
  });
41257
41139
  const typeName = getTransactionTypeName(transaction.type);
41258
- const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data);
41259
41140
  const { fee } = calculateTransactionFee({
41260
- gasPrice,
41141
+ gasUsed,
41261
41142
  rawPayload,
41262
- tip,
41263
41143
  consensusParameters: {
41264
41144
  gasCosts,
41265
- maxGasPerTx,
41266
41145
  feeParams: {
41267
41146
  gasPerByte,
41268
41147
  gasPriceFactor
@@ -41398,13 +41277,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41398
41277
  const decodedTransaction = this.decodeTransaction(
41399
41278
  transaction
41400
41279
  );
41401
- let txReceipts = [];
41402
- if (transaction?.status && "receipts" in transaction.status) {
41403
- txReceipts = transaction.status.receipts;
41404
- }
41405
- const receipts = txReceipts.map(processGqlReceipt) || [];
41406
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
41407
- const gasPrice = await this.provider.getLatestGasPrice();
41280
+ const receipts = transaction.receipts?.map(processGqlReceipt) || [];
41281
+ const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
41408
41282
  const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
41409
41283
  const transactionSummary = assembleTransactionSummary({
41410
41284
  id: this.id,
@@ -41416,9 +41290,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41416
41290
  gasPriceFactor,
41417
41291
  abiMap: contractsAbiMap,
41418
41292
  maxInputs,
41419
- gasCosts,
41420
- maxGasPerTx,
41421
- gasPrice
41293
+ gasCosts
41422
41294
  });
41423
41295
  return transactionSummary;
41424
41296
  }
@@ -41567,7 +41439,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41567
41439
  gasCosts,
41568
41440
  latestBlock: {
41569
41441
  id: latestBlock.id,
41570
- height: bn(latestBlock.height),
41442
+ height: bn(latestBlock.header.height),
41571
41443
  time: latestBlock.header.time,
41572
41444
  transactions: latestBlock.transactions.map((i) => ({
41573
41445
  id: i.id
@@ -41661,8 +41533,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41661
41533
  * Returns some helpful parameters related to gas fees.
41662
41534
  */
41663
41535
  getGasConfig() {
41536
+ const { minGasPrice } = this.getNode();
41664
41537
  const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
41665
41538
  return {
41539
+ minGasPrice,
41666
41540
  maxGasPerTx,
41667
41541
  maxGasPerPredicate,
41668
41542
  gasPriceFactor,
@@ -41760,7 +41634,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41760
41634
  */
41761
41635
  async getBlockNumber() {
41762
41636
  const { chain } = await this.operations.getChain();
41763
- return bn(chain.latestBlock.height, 10);
41637
+ return bn(chain.latestBlock.header.height, 10);
41764
41638
  }
41765
41639
  /**
41766
41640
  * Returns the chain information.
@@ -41772,9 +41646,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41772
41646
  const processedNodeInfo = {
41773
41647
  maxDepth: bn(nodeInfo.maxDepth),
41774
41648
  maxTx: bn(nodeInfo.maxTx),
41649
+ minGasPrice: bn(nodeInfo.minGasPrice),
41775
41650
  nodeVersion: nodeInfo.nodeVersion,
41776
41651
  utxoValidation: nodeInfo.utxoValidation,
41777
- vmBacktrace: nodeInfo.vmBacktrace
41652
+ vmBacktrace: nodeInfo.vmBacktrace,
41653
+ peers: nodeInfo.peers
41778
41654
  };
41779
41655
  _Provider.nodeInfoCache[this.url] = processedNodeInfo;
41780
41656
  return processedNodeInfo;
@@ -41860,13 +41736,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41860
41736
  return this.estimateTxDependencies(transactionRequest);
41861
41737
  }
41862
41738
  const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41863
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
41864
- encodedTransactions: encodedTransaction,
41739
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
41740
+ encodedTransaction,
41865
41741
  utxoValidation: utxoValidation || false
41866
41742
  });
41867
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
41868
- const receipts = rawReceipts.map(processGqlReceipt);
41869
- return { receipts, dryrunStatus: status };
41743
+ const receipts = gqlReceipts.map(processGqlReceipt);
41744
+ return {
41745
+ receipts
41746
+ };
41870
41747
  }
41871
41748
  /**
41872
41749
  * Verifies whether enough gas is available to complete transaction.
@@ -41905,6 +41782,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41905
41782
  * If there are missing variable outputs,
41906
41783
  * `addVariableOutputs` is called on the transaction.
41907
41784
  *
41785
+ * @privateRemarks
41786
+ * TODO: Investigate support for missing contract IDs
41787
+ * TODO: Add support for missing output messages
41908
41788
  *
41909
41789
  * @param transactionRequest - The transaction request object.
41910
41790
  * @returns A promise.
@@ -41917,19 +41797,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41917
41797
  missingContractIds: []
41918
41798
  };
41919
41799
  }
41800
+ await this.estimatePredicates(transactionRequest);
41920
41801
  let receipts = [];
41921
41802
  const missingContractIds = [];
41922
41803
  let outputVariables = 0;
41923
- let dryrunStatus;
41924
41804
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
41925
- const {
41926
- dryRun: [{ receipts: rawReceipts, status }]
41927
- } = await this.operations.dryRun({
41928
- encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())],
41805
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
41806
+ encodedTransaction: hexlify(transactionRequest.toTransactionBytes()),
41929
41807
  utxoValidation: false
41930
41808
  });
41931
- receipts = rawReceipts.map(processGqlReceipt);
41932
- dryrunStatus = status;
41809
+ receipts = gqlReceipts.map(processGqlReceipt);
41933
41810
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
41934
41811
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
41935
41812
  if (hasMissingOutputs) {
@@ -41939,10 +41816,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41939
41816
  transactionRequest.addContractInputAndOutput(Address.fromString(contractId));
41940
41817
  missingContractIds.push(contractId);
41941
41818
  });
41942
- const { maxFee } = await this.estimateTxGasAndFee({
41943
- transactionRequest
41944
- });
41945
- transactionRequest.maxFee = maxFee;
41946
41819
  } else {
41947
41820
  break;
41948
41821
  }
@@ -41950,139 +41823,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41950
41823
  return {
41951
41824
  receipts,
41952
41825
  outputVariables,
41953
- missingContractIds,
41954
- dryrunStatus
41826
+ missingContractIds
41955
41827
  };
41956
41828
  }
41957
- /**
41958
- * Dry runs multiple transactions and checks for missing dependencies in batches.
41959
- *
41960
- * Transactions are dry run in batches. After each dry run, transactions requiring
41961
- * further modifications are identified. The method iteratively updates these transactions
41962
- * and performs subsequent dry runs until all dependencies for each transaction are satisfied.
41963
- *
41964
- * @param transactionRequests - Array of transaction request objects.
41965
- * @returns A promise that resolves to an array of results for each transaction.
41966
- */
41967
- async estimateMultipleTxDependencies(transactionRequests) {
41968
- const results = transactionRequests.map(() => ({
41969
- receipts: [],
41970
- outputVariables: 0,
41971
- missingContractIds: [],
41972
- dryrunStatus: void 0
41973
- }));
41974
- const allRequests = clone_default(transactionRequests);
41975
- const serializedTransactionsMap = /* @__PURE__ */ new Map();
41976
- allRequests.forEach((req, index) => {
41977
- if (req.type === TransactionType.Script) {
41978
- serializedTransactionsMap.set(index, hexlify(req.toTransactionBytes()));
41979
- }
41980
- });
41981
- let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
41982
- let attempt = 0;
41983
- while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
41984
- const encodedTransactions = transactionsToProcess.map(
41985
- (index) => serializedTransactionsMap.get(index)
41986
- );
41987
- const dryRunResults = await this.operations.dryRun({
41988
- encodedTransactions,
41989
- utxoValidation: false
41990
- });
41991
- const nextRoundTransactions = [];
41992
- for (let i = 0; i < dryRunResults.dryRun.length; i++) {
41993
- const currentResultIndex = transactionsToProcess[i];
41994
- const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
41995
- results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
41996
- results[currentResultIndex].dryrunStatus = status;
41997
- const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
41998
- results[currentResultIndex].receipts
41999
- );
42000
- const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
42001
- const requestToProcess = allRequests[currentResultIndex];
42002
- if (hasMissingOutputs && requestToProcess?.type === TransactionType.Script) {
42003
- results[currentResultIndex].outputVariables += missingOutputVariables.length;
42004
- requestToProcess.addVariableOutputs(missingOutputVariables.length);
42005
- missingOutputContractIds.forEach(({ contractId }) => {
42006
- requestToProcess.addContractInputAndOutput(Address.fromString(contractId));
42007
- results[currentResultIndex].missingContractIds.push(contractId);
42008
- });
42009
- const { maxFee } = await this.estimateTxGasAndFee({
42010
- transactionRequest: requestToProcess
42011
- });
42012
- requestToProcess.maxFee = maxFee;
42013
- serializedTransactionsMap.set(
42014
- currentResultIndex,
42015
- hexlify(requestToProcess.toTransactionBytes())
42016
- );
42017
- nextRoundTransactions.push(currentResultIndex);
42018
- allRequests[currentResultIndex] = requestToProcess;
42019
- }
42020
- }
42021
- transactionsToProcess = nextRoundTransactions;
42022
- attempt += 1;
42023
- }
42024
- return results;
42025
- }
42026
- async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
42027
- if (estimateTxDependencies) {
42028
- return this.estimateMultipleTxDependencies(transactionRequests);
42029
- }
42030
- const encodedTransactions = transactionRequests.map((tx) => hexlify(tx.toTransactionBytes()));
42031
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42032
- encodedTransactions,
42033
- utxoValidation: utxoValidation || false
42034
- });
42035
- const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
42036
- const receipts = rawReceipts.map(processGqlReceipt);
42037
- return { receipts, dryrunStatus: status };
42038
- });
42039
- return results;
42040
- }
42041
41829
  /**
42042
41830
  * Estimates the transaction gas and fee based on the provided transaction request.
42043
41831
  * @param transactionRequest - The transaction request object.
42044
41832
  * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
42045
41833
  */
42046
- async estimateTxGasAndFee(params) {
41834
+ estimateTxGasAndFee(params) {
42047
41835
  const { transactionRequest } = params;
42048
- let { gasPrice } = params;
41836
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
42049
41837
  const chainInfo = this.getChain();
42050
- const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
41838
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
41839
+ transactionRequest.gasPrice = gasPrice;
42051
41840
  const minGas = transactionRequest.calculateMinGas(chainInfo);
42052
- if (!gasPrice) {
42053
- gasPrice = await this.estimateGasPrice(10);
42054
- }
42055
- const minFee = calculateGasFee({
42056
- gasPrice: bn(gasPrice),
42057
- gas: minGas,
42058
- priceFactor: gasPriceFactor,
42059
- tip: transactionRequest.tip
42060
- }).add(1);
42061
- let gasLimit = bn(0);
41841
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42062
41842
  if (transactionRequest.type === TransactionType.Script) {
42063
- gasLimit = transactionRequest.gasLimit;
42064
41843
  if (transactionRequest.gasLimit.eq(0)) {
42065
41844
  transactionRequest.gasLimit = minGas;
42066
41845
  transactionRequest.gasLimit = maxGasPerTx.sub(
42067
41846
  transactionRequest.calculateMaxGas(chainInfo, minGas)
42068
41847
  );
42069
- gasLimit = transactionRequest.gasLimit;
42070
41848
  }
42071
41849
  }
42072
41850
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
42073
- const maxFee = calculateGasFee({
42074
- gasPrice: bn(gasPrice),
42075
- gas: maxGas,
42076
- priceFactor: gasPriceFactor,
42077
- tip: transactionRequest.tip
42078
- }).add(1);
41851
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
42079
41852
  return {
42080
41853
  minGas,
42081
41854
  minFee,
42082
41855
  maxGas,
42083
- maxFee,
42084
- gasPrice,
42085
- gasLimit
41856
+ maxFee
42086
41857
  };
42087
41858
  }
42088
41859
  /**
@@ -42100,17 +41871,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42100
41871
  if (estimateTxDependencies) {
42101
41872
  return this.estimateTxDependencies(transactionRequest);
42102
41873
  }
42103
- const encodedTransactions = [hexlify(transactionRequest.toTransactionBytes())];
42104
- const { dryRun: dryRunStatuses } = await this.operations.dryRun({
42105
- encodedTransactions,
41874
+ const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
41875
+ const { dryRun: gqlReceipts } = await this.operations.dryRun({
41876
+ encodedTransaction,
42106
41877
  utxoValidation: true
42107
41878
  });
42108
- const callResult = dryRunStatuses.map((dryRunStatus) => {
42109
- const { id, receipts, status } = dryRunStatus;
42110
- const processedReceipts = receipts.map(processGqlReceipt);
42111
- return { id, receipts: processedReceipts, status };
42112
- });
42113
- return { receipts: callResult[0].receipts };
41879
+ const receipts = gqlReceipts.map(processGqlReceipt);
41880
+ return {
41881
+ receipts
41882
+ };
42114
41883
  }
42115
41884
  /**
42116
41885
  * Returns a transaction cost to enable user
@@ -42127,79 +41896,77 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42127
41896
  * @param tolerance - The tolerance to add on top of the gasUsed.
42128
41897
  * @returns A promise that resolves to the transaction cost object.
42129
41898
  */
42130
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
41899
+ async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
41900
+ estimateTxDependencies = true,
41901
+ estimatePredicates = true,
41902
+ resourcesOwner,
41903
+ signatureCallback
41904
+ } = {}) {
42131
41905
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41906
+ const { minGasPrice } = this.getGasConfig();
41907
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
42132
41908
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
42133
41909
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
42134
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
41910
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
42135
41911
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
42136
- txRequestClone.maxFee = bn(0);
42137
41912
  if (isScriptTransaction) {
42138
41913
  txRequestClone.gasLimit = bn(0);
42139
41914
  }
42140
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
42141
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
41915
+ if (estimatePredicates) {
41916
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41917
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
41918
+ }
41919
+ await this.estimatePredicates(txRequestClone);
42142
41920
  }
42143
- const signedRequest = clone_default(txRequestClone);
42144
- let addedSignatures = 0;
42145
41921
  if (signatureCallback && isScriptTransaction) {
42146
- const lengthBefore = signedRequest.witnesses.length;
42147
- await signatureCallback(signedRequest);
42148
- addedSignatures = signedRequest.witnesses.length - lengthBefore;
41922
+ await signatureCallback(txRequestClone);
42149
41923
  }
42150
- await this.estimatePredicates(signedRequest);
42151
- let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
42152
- transactionRequest: signedRequest
41924
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41925
+ transactionRequest: txRequestClone
42153
41926
  });
42154
41927
  let receipts = [];
42155
41928
  let missingContractIds = [];
42156
41929
  let outputVariables = 0;
42157
41930
  let gasUsed = bn(0);
42158
- txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
42159
- txRequestClone.maxFee = maxFee;
42160
- if (isScriptTransaction) {
42161
- txRequestClone.gasLimit = gasLimit;
42162
- if (signatureCallback) {
42163
- await signatureCallback(txRequestClone);
42164
- }
41931
+ if (isScriptTransaction && estimateTxDependencies) {
41932
+ txRequestClone.gasPrice = bn(0);
42165
41933
  const result = await this.estimateTxDependencies(txRequestClone);
42166
41934
  receipts = result.receipts;
42167
41935
  outputVariables = result.outputVariables;
42168
41936
  missingContractIds = result.missingContractIds;
42169
41937
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
42170
41938
  txRequestClone.gasLimit = gasUsed;
42171
- ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
42172
- transactionRequest: txRequestClone,
42173
- gasPrice
41939
+ txRequestClone.gasPrice = setGasPrice;
41940
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
41941
+ transactionRequest: txRequestClone
42174
41942
  }));
42175
41943
  }
42176
41944
  return {
42177
41945
  requiredQuantities: allQuantities,
42178
41946
  receipts,
42179
41947
  gasUsed,
42180
- gasPrice,
41948
+ minGasPrice,
41949
+ gasPrice: setGasPrice,
42181
41950
  minGas,
42182
41951
  maxGas,
42183
41952
  minFee,
42184
41953
  maxFee,
41954
+ estimatedInputs: txRequestClone.inputs,
42185
41955
  outputVariables,
42186
- missingContractIds,
42187
- addedSignatures,
42188
- estimatedPredicates: txRequestClone.inputs
41956
+ missingContractIds
42189
41957
  };
42190
41958
  }
42191
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
41959
+ async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
42192
41960
  const ownerAddress = Address.fromAddressOrString(owner);
42193
41961
  const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
42194
- const transactionCost = await this.getTransactionCost(transactionRequest, {
42195
- quantitiesToContract
42196
- });
41962
+ const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
42197
41963
  transactionRequest.addResources(
42198
41964
  await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
42199
41965
  );
42200
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
42201
- quantitiesToContract
42202
- });
41966
+ const { requiredQuantities, ...txCost } = await this.getTransactionCost(
41967
+ transactionRequest,
41968
+ forwardingQuantities
41969
+ );
42203
41970
  const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
42204
41971
  return {
42205
41972
  resources,
@@ -42223,6 +41990,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42223
41990
  assetId: coin.assetId,
42224
41991
  amount: bn(coin.amount),
42225
41992
  owner: Address.fromAddressOrString(coin.owner),
41993
+ maturity: bn(coin.maturity).toNumber(),
42226
41994
  blockCreated: bn(coin.blockCreated),
42227
41995
  txCreatedIdx: bn(coin.txCreatedIdx)
42228
41996
  }));
@@ -42274,6 +42042,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42274
42042
  amount: bn(coin.amount),
42275
42043
  assetId: coin.assetId,
42276
42044
  owner: Address.fromAddressOrString(coin.owner),
42045
+ maturity: bn(coin.maturity).toNumber(),
42277
42046
  blockCreated: bn(coin.blockCreated),
42278
42047
  txCreatedIdx: bn(coin.txCreatedIdx)
42279
42048
  };
@@ -42306,7 +42075,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42306
42075
  }
42307
42076
  return {
42308
42077
  id: block2.id,
42309
- height: bn(block2.height),
42078
+ height: bn(block2.header.height),
42310
42079
  time: block2.header.time,
42311
42080
  transactionIds: block2.transactions.map((tx) => tx.id)
42312
42081
  };
@@ -42321,7 +42090,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42321
42090
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
42322
42091
  const blocks = fetchedData.edges.map(({ node: block2 }) => ({
42323
42092
  id: block2.id,
42324
- height: bn(block2.height),
42093
+ height: bn(block2.header.height),
42325
42094
  time: block2.header.time,
42326
42095
  transactionIds: block2.transactions.map((tx) => tx.id)
42327
42096
  }));
@@ -42348,7 +42117,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42348
42117
  }
42349
42118
  return {
42350
42119
  id: block2.id,
42351
- height: bn(block2.height, 10),
42120
+ height: bn(block2.header.height, 10),
42352
42121
  time: block2.header.time,
42353
42122
  transactionIds: block2.transactions.map((tx) => tx.id),
42354
42123
  transactions: block2.transactions.map(
@@ -42528,11 +42297,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42528
42297
  prevRoot: messageBlockHeader.prevRoot,
42529
42298
  time: messageBlockHeader.time,
42530
42299
  applicationHash: messageBlockHeader.applicationHash,
42531
- messageReceiptCount: bn(messageBlockHeader.messageReceiptCount),
42532
- messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
42533
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
42534
- eventInboxRoot: messageBlockHeader.eventInboxRoot,
42535
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
42300
+ messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
42301
+ messageReceiptCount: bn(messageBlockHeader.messageReceiptCount)
42536
42302
  },
42537
42303
  commitBlockHeader: {
42538
42304
  id: commitBlockHeader.id,
@@ -42543,11 +42309,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42543
42309
  prevRoot: commitBlockHeader.prevRoot,
42544
42310
  time: commitBlockHeader.time,
42545
42311
  applicationHash: commitBlockHeader.applicationHash,
42546
- messageReceiptCount: bn(commitBlockHeader.messageReceiptCount),
42547
- messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
42548
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
42549
- eventInboxRoot: commitBlockHeader.eventInboxRoot,
42550
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
42312
+ messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
42313
+ messageReceiptCount: bn(commitBlockHeader.messageReceiptCount)
42551
42314
  },
42552
42315
  sender: Address.fromAddressOrString(sender),
42553
42316
  recipient: Address.fromAddressOrString(recipient),
@@ -42556,16 +42319,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42556
42319
  data
42557
42320
  };
42558
42321
  }
42559
- async getLatestGasPrice() {
42560
- const { latestGasPrice } = await this.operations.getLatestGasPrice();
42561
- return bn(latestGasPrice.gasPrice);
42562
- }
42563
- async estimateGasPrice(blockHorizon) {
42564
- const { estimateGasPrice } = await this.operations.estimateGasPrice({
42565
- blockHorizon: String(blockHorizon)
42566
- });
42567
- return bn(estimateGasPrice.gasPrice);
42568
- }
42569
42322
  /**
42570
42323
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
42571
42324
  *
@@ -42626,15 +42379,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42626
42379
  arrayify(gqlTransaction.rawPayload),
42627
42380
  0
42628
42381
  );
42629
- let txReceipts = [];
42630
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42631
- txReceipts = gqlTransaction.status.receipts;
42632
- }
42633
- const receipts = txReceipts.map(processGqlReceipt);
42382
+ const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
42634
42383
  const {
42635
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42384
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42636
42385
  } = provider.getChain();
42637
- const gasPrice = await provider.getLatestGasPrice();
42638
42386
  const transactionInfo = assembleTransactionSummary({
42639
42387
  id: gqlTransaction.id,
42640
42388
  receipts,
@@ -42645,9 +42393,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42645
42393
  gasPriceFactor: bn(gasPriceFactor),
42646
42394
  abiMap,
42647
42395
  maxInputs,
42648
- gasCosts,
42649
- maxGasPerTx,
42650
- gasPrice
42396
+ gasCosts
42651
42397
  });
42652
42398
  return {
42653
42399
  gqlTransaction,
@@ -42657,11 +42403,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42657
42403
  async function getTransactionSummaryFromRequest(params) {
42658
42404
  const { provider, transactionRequest, abiMap } = params;
42659
42405
  const { receipts } = await provider.call(transactionRequest);
42660
- const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
42406
+ const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
42661
42407
  const maxInputs = provider.getChain().consensusParameters.maxInputs;
42662
42408
  const transaction = transactionRequest.toTransaction();
42663
42409
  const transactionBytes = transactionRequest.toTransactionBytes();
42664
- const gasPrice = await provider.getLatestGasPrice();
42665
42410
  const transactionSummary = assembleTransactionSummary({
42666
42411
  receipts,
42667
42412
  transaction,
@@ -42670,9 +42415,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42670
42415
  gasPerByte,
42671
42416
  gasPriceFactor,
42672
42417
  maxInputs,
42673
- gasCosts,
42674
- maxGasPerTx,
42675
- gasPrice
42418
+ gasCosts
42676
42419
  });
42677
42420
  return transactionSummary;
42678
42421
  }
@@ -42681,18 +42424,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42681
42424
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
42682
42425
  const { edges, pageInfo } = transactionsByOwner;
42683
42426
  const {
42684
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
42427
+ consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
42685
42428
  } = provider.getChain();
42686
- const gasPrice = await provider.getLatestGasPrice();
42687
42429
  const transactions = edges.map((edge) => {
42688
42430
  const { node: gqlTransaction } = edge;
42689
- const { id, rawPayload, status } = gqlTransaction;
42431
+ const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
42690
42432
  const [decodedTransaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
42691
- let txReceipts = [];
42692
- if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
42693
- txReceipts = gqlTransaction.status.receipts;
42694
- }
42695
- const receipts = txReceipts.map(processGqlReceipt);
42433
+ const receipts = gqlReceipts?.map(processGqlReceipt) || [];
42696
42434
  const transactionSummary = assembleTransactionSummary({
42697
42435
  id,
42698
42436
  receipts,
@@ -42703,9 +42441,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
42703
42441
  gasPerByte,
42704
42442
  gasPriceFactor,
42705
42443
  maxInputs,
42706
- gasCosts,
42707
- maxGasPerTx,
42708
- gasPrice
42444
+ gasCosts
42709
42445
  });
42710
42446
  const output3 = {
42711
42447
  gqlTransaction,
@@ -43034,33 +42770,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43034
42770
  * @param fee - The estimated transaction fee.
43035
42771
  * @returns A promise that resolves when the resources are added to the transaction.
43036
42772
  */
43037
- async fund(request, params) {
43038
- const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
43039
- const txRequest = request;
43040
- const requiredQuantitiesWithFee = addAmountToCoinQuantities({
42773
+ async fund(request, coinQuantities, fee) {
42774
+ const updatedQuantities = addAmountToAsset({
43041
42775
  amount: bn(fee),
43042
42776
  assetId: BaseAssetId,
43043
- coinQuantities: requiredQuantities
42777
+ coinQuantities
43044
42778
  });
43045
42779
  const quantitiesDict = {};
43046
- requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
42780
+ updatedQuantities.forEach(({ amount, assetId }) => {
43047
42781
  quantitiesDict[assetId] = {
43048
42782
  required: amount,
43049
42783
  owned: bn(0)
43050
42784
  };
43051
42785
  });
43052
- txRequest.inputs.forEach((input) => {
42786
+ const cachedUtxos = [];
42787
+ const cachedMessages = [];
42788
+ const owner = this.address.toB256();
42789
+ request.inputs.forEach((input) => {
43053
42790
  const isResource = "amount" in input;
43054
42791
  if (isResource) {
43055
42792
  const isCoin2 = "owner" in input;
43056
42793
  if (isCoin2) {
43057
42794
  const assetId = String(input.assetId);
43058
- if (quantitiesDict[assetId]) {
42795
+ if (input.owner === owner && quantitiesDict[assetId]) {
43059
42796
  const amount = bn(input.amount);
43060
42797
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
42798
+ cachedUtxos.push(input.id);
43061
42799
  }
43062
- } else if (input.amount && quantitiesDict[BaseAssetId]) {
42800
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
43063
42801
  quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
42802
+ cachedMessages.push(input.nonce);
43064
42803
  }
43065
42804
  }
43066
42805
  });
@@ -43075,23 +42814,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43075
42814
  });
43076
42815
  const needsToBeFunded = missingQuantities.length;
43077
42816
  if (needsToBeFunded) {
43078
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
43079
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
43080
- txRequest.addResources(resources);
43081
- }
43082
- txRequest.shiftPredicateData();
43083
- txRequest.updatePredicateGasUsed(estimatedPredicates);
43084
- const requestToBeReEstimate = clone_default(txRequest);
43085
- if (addedSignatures) {
43086
- Array.from({ length: addedSignatures }).forEach(
43087
- () => requestToBeReEstimate.addEmptyWitness()
43088
- );
42817
+ const resources = await this.getResourcesToSpend(missingQuantities, {
42818
+ messages: cachedMessages,
42819
+ utxos: cachedUtxos
42820
+ });
42821
+ request.addResources(resources);
43089
42822
  }
43090
- const { maxFee } = await this.provider.estimateTxGasAndFee({
43091
- transactionRequest: requestToBeReEstimate
43092
- });
43093
- txRequest.maxFee = maxFee;
43094
- return txRequest;
43095
42823
  }
43096
42824
  /**
43097
42825
  * A helper that creates a transfer transaction request and returns it.
@@ -43099,25 +42827,28 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43099
42827
  * @param destination - The address of the destination.
43100
42828
  * @param amount - The amount of coins to transfer.
43101
42829
  * @param assetId - The asset ID of the coins to transfer.
43102
- * @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
42830
+ * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
43103
42831
  * @returns A promise that resolves to the prepared transaction request.
43104
42832
  */
43105
42833
  async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
43106
- const request = new ScriptTransactionRequest(txParams);
42834
+ const { minGasPrice } = this.provider.getGasConfig();
42835
+ const params = { gasPrice: minGasPrice, ...txParams };
42836
+ const request = new ScriptTransactionRequest(params);
43107
42837
  request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
43108
- const txCost = await this.provider.getTransactionCost(request, {
42838
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
43109
42839
  estimateTxDependencies: true,
43110
42840
  resourcesOwner: this
43111
42841
  });
43112
- if ("gasLimit" in txParams) {
43113
- this.validateGas({
43114
- gasUsed: txCost.gasUsed,
43115
- gasLimit: request.gasLimit
43116
- });
43117
- }
43118
- request.gasLimit = txCost.gasUsed;
43119
- request.maxFee = txCost.maxFee;
43120
- await this.fund(request, txCost);
42842
+ request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
42843
+ request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
42844
+ this.validateGas({
42845
+ gasUsed,
42846
+ gasPrice: request.gasPrice,
42847
+ gasLimit: request.gasLimit,
42848
+ minGasPrice
42849
+ });
42850
+ await this.fund(request, requiredQuantities, maxFee);
42851
+ request.updatePredicateInputs(estimatedInputs);
43121
42852
  return request;
43122
42853
  }
43123
42854
  /**
@@ -43156,30 +42887,31 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43156
42887
  );
43157
42888
  }
43158
42889
  const contractAddress = Address.fromAddressOrString(contractId);
42890
+ const { minGasPrice } = this.provider.getGasConfig();
42891
+ const params = { gasPrice: minGasPrice, ...txParams };
43159
42892
  const { script, scriptData } = await assembleTransferToContractScript({
43160
42893
  hexlifiedContractId: contractAddress.toB256(),
43161
42894
  amountToTransfer: bn(amount),
43162
42895
  assetId
43163
42896
  });
43164
42897
  const request = new ScriptTransactionRequest({
43165
- ...txParams,
42898
+ ...params,
43166
42899
  script,
43167
42900
  scriptData
43168
42901
  });
43169
42902
  request.addContractInputAndOutput(contractAddress);
43170
- const txCost = await this.provider.getTransactionCost(request, {
43171
- resourcesOwner: this,
43172
- quantitiesToContract: [{ amount: bn(amount), assetId: String(assetId) }]
42903
+ const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
42904
+ request,
42905
+ [{ amount: bn(amount), assetId: String(assetId) }]
42906
+ );
42907
+ request.gasLimit = bn(params.gasLimit ?? gasUsed);
42908
+ this.validateGas({
42909
+ gasUsed,
42910
+ gasPrice: request.gasPrice,
42911
+ gasLimit: request.gasLimit,
42912
+ minGasPrice
43173
42913
  });
43174
- if (txParams.gasLimit) {
43175
- this.validateGas({
43176
- gasUsed: txCost.gasUsed,
43177
- gasLimit: request.gasLimit
43178
- });
43179
- }
43180
- request.gasLimit = txCost.gasUsed;
43181
- request.maxFee = txCost.maxFee;
43182
- await this.fund(request, txCost);
42914
+ await this.fund(request, requiredQuantities, maxFee);
43183
42915
  return this.sendTransaction(request);
43184
42916
  }
43185
42917
  /**
@@ -43191,6 +42923,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43191
42923
  * @returns A promise that resolves to the transaction response.
43192
42924
  */
43193
42925
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
42926
+ const { minGasPrice } = this.provider.getGasConfig();
43194
42927
  const recipientAddress = Address.fromAddressOrString(recipient);
43195
42928
  const recipientDataArray = arrayify(
43196
42929
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -43203,19 +42936,21 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43203
42936
  ...recipientDataArray,
43204
42937
  ...amountDataArray
43205
42938
  ]);
43206
- const params = { script, ...txParams };
42939
+ const params = { script, gasPrice: minGasPrice, ...txParams };
43207
42940
  const request = new ScriptTransactionRequest(params);
43208
- const quantitiesToContract = [{ amount: bn(amount), assetId: BaseAssetId }];
43209
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
43210
- if (txParams.gasLimit) {
43211
- this.validateGas({
43212
- gasUsed: txCost.gasUsed,
43213
- gasLimit: request.gasLimit
43214
- });
43215
- }
43216
- request.maxFee = txCost.maxFee;
43217
- request.gasLimit = txCost.gasUsed;
43218
- await this.fund(request, txCost);
42941
+ const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
42942
+ const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
42943
+ request,
42944
+ forwardingQuantities
42945
+ );
42946
+ request.gasLimit = bn(params.gasLimit ?? gasUsed);
42947
+ this.validateGas({
42948
+ gasUsed,
42949
+ gasPrice: request.gasPrice,
42950
+ gasLimit: request.gasLimit,
42951
+ minGasPrice
42952
+ });
42953
+ await this.fund(request, requiredQuantities, maxFee);
43219
42954
  return this.sendTransaction(request);
43220
42955
  }
43221
42956
  async signMessage(message) {
@@ -43273,7 +43008,18 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
43273
43008
  }
43274
43009
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
43275
43010
  }
43276
- validateGas({ gasUsed, gasLimit }) {
43011
+ validateGas({
43012
+ gasUsed,
43013
+ gasPrice,
43014
+ gasLimit,
43015
+ minGasPrice
43016
+ }) {
43017
+ if (minGasPrice.gt(gasPrice)) {
43018
+ throw new FuelError(
43019
+ ErrorCode.GAS_PRICE_TOO_LOW,
43020
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
43021
+ );
43022
+ }
43277
43023
  if (gasUsed.gt(gasLimit)) {
43278
43024
  throw new FuelError(
43279
43025
  ErrorCode.GAS_LIMIT_TOO_LOW,
@@ -44862,7 +44608,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
44862
44608
  * @param transactionRequestLike - The transaction request to send.
44863
44609
  * @returns A promise that resolves to the TransactionResponse object.
44864
44610
  */
44865
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
44611
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
44866
44612
  const transactionRequest = transactionRequestify(transactionRequestLike);
44867
44613
  if (estimateTxDependencies) {
44868
44614
  await this.provider.estimateTxDependencies(transactionRequest);
@@ -48140,8 +47886,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48140
47886
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
48141
47887
  request.inputs?.forEach((input) => {
48142
47888
  if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
48143
- input.predicate = hexlify(this.bytes);
48144
- input.predicateData = hexlify(this.getPredicateData(policies.length));
47889
+ input.predicate = this.bytes;
47890
+ input.predicateData = this.getPredicateData(policies.length);
48145
47891
  }
48146
47892
  });
48147
47893
  return request;
@@ -48156,7 +47902,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48156
47902
  * @returns A promise that resolves to the prepared transaction request.
48157
47903
  */
48158
47904
  async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
48159
- return super.createTransfer(destination, amount, assetId, txParams);
47905
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
47906
+ return this.populateTransactionPredicateData(request);
48160
47907
  }
48161
47908
  /**
48162
47909
  * Sends a transaction with the populated predicate data.
@@ -48164,9 +47911,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48164
47911
  * @param transactionRequestLike - The transaction request-like object.
48165
47912
  * @returns A promise that resolves to the transaction response.
48166
47913
  */
48167
- sendTransaction(transactionRequestLike) {
48168
- const transactionRequest = transactionRequestify(transactionRequestLike);
48169
- return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
47914
+ sendTransaction(transactionRequestLike, options) {
47915
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47916
+ return super.sendTransaction(transactionRequest, options);
48170
47917
  }
48171
47918
  /**
48172
47919
  * Simulates a transaction with the populated predicate data.
@@ -48175,8 +47922,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48175
47922
  * @returns A promise that resolves to the call result.
48176
47923
  */
48177
47924
  simulateTransaction(transactionRequestLike) {
48178
- const transactionRequest = transactionRequestify(transactionRequestLike);
48179
- return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
47925
+ const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47926
+ return super.simulateTransaction(transactionRequest);
48180
47927
  }
48181
47928
  getPredicateData(policiesLength) {
48182
47929
  if (!this.predicateData.length) {
@@ -48222,25 +47969,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
48222
47969
  predicateInterface: abiInterface
48223
47970
  };
48224
47971
  }
48225
- /**
48226
- * Retrieves resources satisfying the spend query for the account.
48227
- *
48228
- * @param quantities - IDs of coins to exclude.
48229
- * @param excludedIds - IDs of resources to be excluded from the query.
48230
- * @returns A promise that resolves to an array of Resources.
48231
- */
48232
- async getResourcesToSpend(quantities, excludedIds) {
48233
- const resources = await this.provider.getResourcesToSpend(
48234
- this.address,
48235
- quantities,
48236
- excludedIds
48237
- );
48238
- return resources.map((resource) => ({
48239
- ...resource,
48240
- predicate: hexlify(this.bytes),
48241
- paddPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
48242
- }));
48243
- }
48244
47972
  /**
48245
47973
  * Sets the configurable constants for the predicate.
48246
47974
  *