@fuel-ts/account 0.92.1 → 0.93.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3035,7 +3035,7 @@
3035
3035
  }
3036
3036
  return chk;
3037
3037
  }
3038
- function convert2(data, inBits, outBits, pad3) {
3038
+ function convert2(data, inBits, outBits, pad) {
3039
3039
  let value = 0;
3040
3040
  let bits = 0;
3041
3041
  const maxV = (1 << outBits) - 1;
@@ -3048,7 +3048,7 @@
3048
3048
  result.push(value >> bits & maxV);
3049
3049
  }
3050
3050
  }
3051
- if (pad3) {
3051
+ if (pad) {
3052
3052
  if (bits > 0) {
3053
3053
  result.push(value << outBits - bits & maxV);
3054
3054
  }
@@ -28638,9 +28638,9 @@ spurious results.`);
28638
28638
  // ../versions/dist/index.mjs
28639
28639
  function getBuiltinVersions() {
28640
28640
  return {
28641
- FORC: "0.61.2",
28641
+ FORC: "0.62.0",
28642
28642
  FUEL_CORE: "0.31.0",
28643
- FUELS: "0.92.1"
28643
+ FUELS: "0.93.0"
28644
28644
  };
28645
28645
  }
28646
28646
  function parseVersion(version) {
@@ -28747,11 +28747,12 @@ This unreleased fuel-core build may include features and updates not yet support
28747
28747
  ErrorCode2["INVALID_TRANSACTION_INPUT"] = "invalid-transaction-input";
28748
28748
  ErrorCode2["INVALID_TRANSACTION_OUTPUT"] = "invalid-transaction-output";
28749
28749
  ErrorCode2["INVALID_TRANSACTION_STATUS"] = "invalid-transaction-status";
28750
- ErrorCode2["INVALID_TRANSACTION_TYPE"] = "invalid-transaction-type";
28750
+ ErrorCode2["UNSUPPORTED_TRANSACTION_TYPE"] = "unsupported-transaction-type";
28751
28751
  ErrorCode2["TRANSACTION_ERROR"] = "transaction-error";
28752
28752
  ErrorCode2["INVALID_POLICY_TYPE"] = "invalid-policy-type";
28753
28753
  ErrorCode2["DUPLICATED_POLICY"] = "duplicated-policy";
28754
28754
  ErrorCode2["TRANSACTION_SQUEEZED_OUT"] = "transaction-squeezed-out";
28755
+ ErrorCode2["CONTRACT_SIZE_EXCEEDS_LIMIT"] = "contract-size-exceeds-limit";
28755
28756
  ErrorCode2["INVALID_RECEIPT_TYPE"] = "invalid-receipt-type";
28756
28757
  ErrorCode2["INVALID_WORD_LIST"] = "invalid-word-list";
28757
28758
  ErrorCode2["INVALID_MNEMONIC"] = "invalid-mnemonic";
@@ -29687,16 +29688,16 @@ If you are attempting to transform a hex value, please make sure it is being pas
29687
29688
  this.blockLen = this.iHash.blockLen;
29688
29689
  this.outputLen = this.iHash.outputLen;
29689
29690
  const blockLen = this.blockLen;
29690
- const pad3 = new Uint8Array(blockLen);
29691
- pad3.set(key.length > blockLen ? hash4.create().update(key).digest() : key);
29692
- for (let i = 0; i < pad3.length; i++)
29693
- pad3[i] ^= 54;
29694
- this.iHash.update(pad3);
29691
+ const pad = new Uint8Array(blockLen);
29692
+ pad.set(key.length > blockLen ? hash4.create().update(key).digest() : key);
29693
+ for (let i = 0; i < pad.length; i++)
29694
+ pad[i] ^= 54;
29695
+ this.iHash.update(pad);
29695
29696
  this.oHash = hash4.create();
29696
- for (let i = 0; i < pad3.length; i++)
29697
- pad3[i] ^= 54 ^ 92;
29698
- this.oHash.update(pad3);
29699
- pad3.fill(0);
29697
+ for (let i = 0; i < pad.length; i++)
29698
+ pad[i] ^= 54 ^ 92;
29699
+ this.oHash.update(pad);
29700
+ pad.fill(0);
29700
29701
  }
29701
29702
  update(buf) {
29702
29703
  exists(this);
@@ -31807,12 +31808,12 @@ If you are attempting to transform a hex value, please make sure it is being pas
31807
31808
  }
31808
31809
  };
31809
31810
 
31810
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js
31811
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isPlaceholder.js
31811
31812
  function _isPlaceholder(a) {
31812
31813
  return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
31813
31814
  }
31814
31815
 
31815
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js
31816
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_curry1.js
31816
31817
  function _curry1(fn) {
31817
31818
  return function f1(a) {
31818
31819
  if (arguments.length === 0 || _isPlaceholder(a)) {
@@ -31823,38 +31824,18 @@ If you are attempting to transform a hex value, please make sure it is being pas
31823
31824
  };
31824
31825
  }
31825
31826
 
31826
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js
31827
- var isArray_default = Array.isArray || function _isArray(val) {
31828
- return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
31829
- };
31830
-
31831
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/type.js
31827
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/type.js
31832
31828
  var type = /* @__PURE__ */ _curry1(function type2(val) {
31833
31829
  return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
31834
31830
  });
31835
31831
  var type_default = type;
31836
31832
 
31837
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js
31838
- var pad = function pad2(n) {
31839
- return (n < 10 ? "0" : "") + n;
31840
- };
31841
- var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
31842
- return d.toISOString();
31843
- } : function _toISOString3(d) {
31844
- 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";
31845
- };
31846
-
31847
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js
31848
- var isInteger_default = Number.isInteger || function _isInteger(n) {
31849
- return n << 0 === n;
31850
- };
31851
-
31852
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_cloneRegExp.js
31833
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_cloneRegExp.js
31853
31834
  function _cloneRegExp(pattern) {
31854
31835
  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" : ""));
31855
31836
  }
31856
31837
 
31857
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_clone.js
31838
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_clone.js
31858
31839
  function _clone(value, deep, map) {
31859
31840
  map || (map = new _ObjectMap());
31860
31841
  if (_isPrimitive(value)) {
@@ -31877,7 +31858,7 @@ If you are attempting to transform a hex value, please make sure it is being pas
31877
31858
  case "Object":
31878
31859
  return copy(Object.create(Object.getPrototypeOf(value)));
31879
31860
  case "Array":
31880
- return copy([]);
31861
+ return copy(Array(value.length));
31881
31862
  case "Date":
31882
31863
  return new Date(value.valueOf());
31883
31864
  case "RegExp":
@@ -31908,8 +31889,8 @@ If you are attempting to transform a hex value, please make sure it is being pas
31908
31889
  this.length = 0;
31909
31890
  }
31910
31891
  _ObjectMap2.prototype.set = function(key, value) {
31911
- const hashedKey = this.hash(key);
31912
- let bucket = this.map[hashedKey];
31892
+ var hashedKey = this.hash(key);
31893
+ var bucket = this.map[hashedKey];
31913
31894
  if (!bucket) {
31914
31895
  this.map[hashedKey] = bucket = [];
31915
31896
  }
@@ -31917,7 +31898,7 @@ If you are attempting to transform a hex value, please make sure it is being pas
31917
31898
  this.length += 1;
31918
31899
  };
31919
31900
  _ObjectMap2.prototype.hash = function(key) {
31920
- let hashedKey = [];
31901
+ var hashedKey = [];
31921
31902
  for (var value in key) {
31922
31903
  hashedKey.push(Object.prototype.toString.call(key[value]));
31923
31904
  }
@@ -31925,10 +31906,10 @@ If you are attempting to transform a hex value, please make sure it is being pas
31925
31906
  };
31926
31907
  _ObjectMap2.prototype.get = function(key) {
31927
31908
  if (this.length <= 180) {
31928
- for (const p in this.map) {
31929
- const bucket2 = this.map[p];
31930
- for (let i = 0; i < bucket2.length; i += 1) {
31931
- const element = bucket2[i];
31909
+ for (var p in this.map) {
31910
+ var bucket = this.map[p];
31911
+ for (var i = 0; i < bucket.length; i += 1) {
31912
+ var element = bucket[i];
31932
31913
  if (element[0] === key) {
31933
31914
  return element[1];
31934
31915
  }
@@ -31936,13 +31917,13 @@ If you are attempting to transform a hex value, please make sure it is being pas
31936
31917
  }
31937
31918
  return;
31938
31919
  }
31939
- const hashedKey = this.hash(key);
31940
- const bucket = this.map[hashedKey];
31920
+ var hashedKey = this.hash(key);
31921
+ var bucket = this.map[hashedKey];
31941
31922
  if (!bucket) {
31942
31923
  return;
31943
31924
  }
31944
- for (let i = 0; i < bucket.length; i += 1) {
31945
- const element = bucket[i];
31925
+ for (var i = 0; i < bucket.length; i += 1) {
31926
+ var element = bucket[i];
31946
31927
  if (element[0] === key) {
31947
31928
  return element[1];
31948
31929
  }
@@ -31951,15 +31932,12 @@ If you are attempting to transform a hex value, please make sure it is being pas
31951
31932
  return _ObjectMap2;
31952
31933
  }();
31953
31934
 
31954
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/clone.js
31935
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/clone.js
31955
31936
  var clone = /* @__PURE__ */ _curry1(function clone2(value) {
31956
31937
  return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
31957
31938
  });
31958
31939
  var clone_default = clone;
31959
31940
 
31960
- // ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js
31961
- var hasProtoTrim = typeof String.prototype.trim === "function";
31962
-
31963
31941
  // src/providers/coin-quantity.ts
31964
31942
  var coinQuantityfy = (coinQuantityLike) => {
31965
31943
  let assetId;
@@ -32801,8 +32779,8 @@ If you are attempting to transform a hex value, please make sure it is being pas
32801
32779
  }
32802
32780
  default: {
32803
32781
  throw new FuelError(
32804
- ErrorCode.INVALID_TRANSACTION_TYPE,
32805
- `Invalid transaction type: ${type3}`
32782
+ ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
32783
+ `Unsupported transaction type: ${type3}`
32806
32784
  );
32807
32785
  }
32808
32786
  }
@@ -32828,8 +32806,8 @@ If you are attempting to transform a hex value, please make sure it is being pas
32828
32806
  }
32829
32807
  default: {
32830
32808
  throw new FuelError(
32831
- ErrorCode.INVALID_TRANSACTION_TYPE,
32832
- `Invalid transaction type: ${type3}`
32809
+ ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
32810
+ `Unsupported transaction type: ${type3}`
32833
32811
  );
32834
32812
  }
32835
32813
  }
@@ -33235,8 +33213,8 @@ If you are attempting to transform a hex value, please make sure it is being pas
33235
33213
  }
33236
33214
  default: {
33237
33215
  throw new FuelError(
33238
- ErrorCode.INVALID_TRANSACTION_TYPE,
33239
- `Invalid transaction type: ${type3}`
33216
+ ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
33217
+ `Unsupported transaction type: ${type3}`
33240
33218
  );
33241
33219
  }
33242
33220
  }
@@ -33270,8 +33248,8 @@ If you are attempting to transform a hex value, please make sure it is being pas
33270
33248
  }
33271
33249
  default: {
33272
33250
  throw new FuelError(
33273
- ErrorCode.INVALID_TRANSACTION_TYPE,
33274
- `Invalid transaction type: ${type3}`
33251
+ ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
33252
+ `Unsupported transaction type: ${type3}`
33275
33253
  );
33276
33254
  }
33277
33255
  }
@@ -33402,10 +33380,10 @@ If you are attempting to transform a hex value, please make sure it is being pas
33402
33380
  sum += a.length;
33403
33381
  }
33404
33382
  const res = new Uint8Array(sum);
33405
- for (let i = 0, pad3 = 0; i < arrays.length; i++) {
33383
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
33406
33384
  const a = arrays[i];
33407
- res.set(a, pad3);
33408
- pad3 += a.length;
33385
+ res.set(a, pad);
33386
+ pad += a.length;
33409
33387
  }
33410
33388
  return res;
33411
33389
  }
@@ -39406,7 +39384,10 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
39406
39384
  return CreateTransactionRequest.from(obj);
39407
39385
  }
39408
39386
  default: {
39409
- throw new FuelError(ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type3}.`);
39387
+ throw new FuelError(
39388
+ ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
39389
+ `Unsupported transaction type: ${type3}.`
39390
+ );
39410
39391
  }
39411
39392
  }
39412
39393
  };
@@ -39638,8 +39619,8 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
39638
39619
  return "Script" /* Script */;
39639
39620
  default:
39640
39621
  throw new FuelError(
39641
- ErrorCode.INVALID_TRANSACTION_TYPE,
39642
- `Invalid transaction type: ${transactionType}.`
39622
+ ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
39623
+ `Unsupported transaction type: ${transactionType}.`
39643
39624
  );
39644
39625
  }
39645
39626
  }
@@ -40387,24 +40368,11 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
40387
40368
  };
40388
40369
  }
40389
40370
 
40390
- // src/providers/utils/merge-quantities.ts
40391
- var mergeQuantities = (...coinQuantities) => {
40392
- const resultMap = {};
40393
- function addToMap({ amount, assetId }) {
40394
- if (resultMap[assetId]) {
40395
- resultMap[assetId] = resultMap[assetId].add(amount);
40396
- } else {
40397
- resultMap[assetId] = amount;
40398
- }
40399
- }
40400
- coinQuantities.forEach((arr) => arr.forEach(addToMap));
40401
- return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
40402
- };
40403
-
40404
40371
  // src/providers/provider.ts
40405
40372
  var MAX_RETRIES = 10;
40406
40373
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
40407
40374
  var BLOCKS_PAGE_SIZE_LIMIT = 5;
40375
+ var DEFAULT_UTXOS_CACHE_TTL = 2e4;
40408
40376
  var processGqlChain = (chain) => {
40409
40377
  const { name, daHeight, consensusParameters, latestBlock } = chain;
40410
40378
  const {
@@ -40494,7 +40462,16 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
40494
40462
  this.options = { ...this.options, ...options };
40495
40463
  this.url = url;
40496
40464
  this.operations = this.createOperations();
40497
- this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
40465
+ const { cacheUtxo } = this.options;
40466
+ if (isDefined(cacheUtxo)) {
40467
+ if (cacheUtxo !== -1) {
40468
+ this.cache = new MemoryCache(cacheUtxo);
40469
+ } else {
40470
+ this.cache = void 0;
40471
+ }
40472
+ } else {
40473
+ this.cache = new MemoryCache(DEFAULT_UTXOS_CACHE_TTL);
40474
+ }
40498
40475
  }
40499
40476
  /** @hidden */
40500
40477
  static clearChainAndNodeCaches() {
@@ -40736,9 +40713,8 @@ Supported fuel-core version: ${supportedVersion}.`
40736
40713
  * @returns A promise that resolves to the transaction response object.
40737
40714
  */
40738
40715
  // #region Provider-sendTransaction
40739
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution = false } = {}) {
40716
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
40740
40717
  const transactionRequest = transactionRequestify(transactionRequestLike);
40741
- __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs);
40742
40718
  if (estimateTxDependencies) {
40743
40719
  await this.estimateTxDependencies(transactionRequest);
40744
40720
  }
@@ -40747,27 +40723,10 @@ Supported fuel-core version: ${supportedVersion}.`
40747
40723
  if (transactionRequest.type === TransactionType.Script) {
40748
40724
  abis = transactionRequest.abis;
40749
40725
  }
40750
- if (awaitExecution) {
40751
- const subscription = this.operations.submitAndAwait({ encodedTransaction });
40752
- for await (const { submitAndAwait } of subscription) {
40753
- if (submitAndAwait.type === "SqueezedOutStatus") {
40754
- throw new FuelError(
40755
- ErrorCode.TRANSACTION_SQUEEZED_OUT,
40756
- `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
40757
- );
40758
- }
40759
- if (submitAndAwait.type !== "SubmittedStatus") {
40760
- break;
40761
- }
40762
- }
40763
- const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
40764
- const response = new TransactionResponse(transactionId2, this, abis);
40765
- await response.fetch();
40766
- return response;
40767
- }
40768
40726
  const {
40769
40727
  submit: { id: transactionId }
40770
40728
  } = await this.operations.submit({ encodedTransaction });
40729
+ __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs);
40771
40730
  return new TransactionResponse(transactionId, this, abis);
40772
40731
  }
40773
40732
  /**
@@ -41046,6 +41005,8 @@ Supported fuel-core version: ${supportedVersion}.`
41046
41005
  return { receipts: callResult[0].receipts };
41047
41006
  }
41048
41007
  /**
41008
+ * @hidden
41009
+ *
41049
41010
  * Returns a transaction cost to enable user
41050
41011
  * to set gasLimit and also reserve balance amounts
41051
41012
  * on the transaction.
@@ -41055,20 +41016,13 @@ Supported fuel-core version: ${supportedVersion}.`
41055
41016
  *
41056
41017
  * @returns A promise that resolves to the transaction cost object.
41057
41018
  */
41058
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
41019
+ async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
41059
41020
  const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
41060
41021
  const isScriptTransaction = txRequestClone.type === TransactionType.Script;
41061
- const baseAssetId = this.getBaseAssetId();
41062
41022
  const updateMaxFee = txRequestClone.maxFee.eq(0);
41063
- const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
41064
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
41065
- txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
41066
41023
  if (isScriptTransaction) {
41067
41024
  txRequestClone.gasLimit = bn(0);
41068
41025
  }
41069
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
41070
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
41071
- }
41072
41026
  const signedRequest = clone_default(txRequestClone);
41073
41027
  let addedSignatures = 0;
41074
41028
  if (signatureCallback && isScriptTransaction) {
@@ -41104,7 +41058,6 @@ Supported fuel-core version: ${supportedVersion}.`
41104
41058
  }));
41105
41059
  }
41106
41060
  return {
41107
- requiredQuantities: allQuantities,
41108
41061
  receipts,
41109
41062
  gasUsed,
41110
41063
  gasPrice,
@@ -41120,34 +41073,6 @@ Supported fuel-core version: ${supportedVersion}.`
41120
41073
  updateMaxFee
41121
41074
  };
41122
41075
  }
41123
- /**
41124
- * Get the required quantities and associated resources for a transaction.
41125
- *
41126
- * @param owner - address to add resources from.
41127
- * @param transactionRequestLike - transaction request to populate resources for.
41128
- * @param quantitiesToContract - quantities for the contract (optional).
41129
- *
41130
- * @returns a promise resolving to the required quantities for the transaction.
41131
- */
41132
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
41133
- const ownerAddress = Address.fromAddressOrString(owner);
41134
- const transactionRequest = transactionRequestify(clone_default(transactionRequestLike));
41135
- const transactionCost = await this.getTransactionCost(transactionRequest, {
41136
- quantitiesToContract
41137
- });
41138
- transactionRequest.addResources(
41139
- await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
41140
- );
41141
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
41142
- quantitiesToContract
41143
- });
41144
- const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
41145
- return {
41146
- resources,
41147
- requiredQuantities,
41148
- ...txCost
41149
- };
41150
- }
41151
41076
  /**
41152
41077
  * Returns coins for the given owner.
41153
41078
  *
@@ -41947,6 +41872,20 @@ Supported fuel-core version: ${supportedVersion}.`
41947
41872
  ];
41948
41873
  var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
41949
41874
 
41875
+ // src/providers/utils/merge-quantities.ts
41876
+ var mergeQuantities = (...coinQuantities) => {
41877
+ const resultMap = {};
41878
+ function addToMap({ amount, assetId }) {
41879
+ if (resultMap[assetId]) {
41880
+ resultMap[assetId] = resultMap[assetId].add(amount);
41881
+ } else {
41882
+ resultMap[assetId] = amount;
41883
+ }
41884
+ }
41885
+ coinQuantities.forEach((arr) => arr.forEach(addToMap));
41886
+ return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
41887
+ };
41888
+
41950
41889
  // src/utils/formatTransferToContractScriptData.ts
41951
41890
  var asm = __toESM(require_node());
41952
41891
  var formatTransferToContractScriptData = (params) => {
@@ -42284,9 +42223,8 @@ Supported fuel-core version: ${supportedVersion}.`
42284
42223
  scriptData
42285
42224
  });
42286
42225
  request.addContractInputAndOutput(contractAddress);
42287
- const txCost = await this.provider.getTransactionCost(request, {
42288
- resourcesOwner: this,
42289
- quantitiesToContract: [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42226
+ const txCost = await this.getTransactionCost(request, {
42227
+ quantities: [{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
42290
42228
  });
42291
42229
  request = this.validateGasLimitAndMaxFee({
42292
42230
  transactionRequest: request,
@@ -42321,8 +42259,8 @@ Supported fuel-core version: ${supportedVersion}.`
42321
42259
  const params = { script, ...txParams };
42322
42260
  const baseAssetId = this.provider.getBaseAssetId();
42323
42261
  let request = new ScriptTransactionRequest(params);
42324
- const quantitiesToContract = [{ amount: bn(amount), assetId: baseAssetId }];
42325
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
42262
+ const quantities = [{ amount: bn(amount), assetId: baseAssetId }];
42263
+ const txCost = await this.getTransactionCost(request, { quantities });
42326
42264
  request = this.validateGasLimitAndMaxFee({
42327
42265
  transactionRequest: request,
42328
42266
  gasUsed: txCost.gasUsed,
@@ -42332,6 +42270,34 @@ Supported fuel-core version: ${supportedVersion}.`
42332
42270
  await this.fund(request, txCost);
42333
42271
  return this.sendTransaction(request);
42334
42272
  }
42273
+ /**
42274
+ * Returns a transaction cost to enable user
42275
+ * to set gasLimit and also reserve balance amounts
42276
+ * on the transaction.
42277
+ *
42278
+ * @param transactionRequestLike - The transaction request object.
42279
+ * @param transactionCostParams - The transaction cost parameters (optional).
42280
+ *
42281
+ * @returns A promise that resolves to the transaction cost object.
42282
+ */
42283
+ async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
42284
+ const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
42285
+ const baseAssetId = this.provider.getBaseAssetId();
42286
+ const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
42287
+ const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
42288
+ const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn("100000000000000000") }];
42289
+ const resources = this.generateFakeResources(
42290
+ mergeQuantities(requiredQuantities, transactionFeeForDryRun)
42291
+ );
42292
+ txRequestClone.addResources(resources);
42293
+ const txCost = await this.provider.getTransactionCost(txRequestClone, {
42294
+ signatureCallback
42295
+ });
42296
+ return {
42297
+ ...txCost,
42298
+ requiredQuantities
42299
+ };
42300
+ }
42335
42301
  /**
42336
42302
  * Sign a message from the account via the connector.
42337
42303
  *
@@ -42368,7 +42334,7 @@ Supported fuel-core version: ${supportedVersion}.`
42368
42334
  * @param sendTransactionParams - The provider send transaction parameters (optional).
42369
42335
  * @returns A promise that resolves to the transaction response.
42370
42336
  */
42371
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
42337
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
42372
42338
  if (this._connector) {
42373
42339
  return this.provider.getTransactionResponse(
42374
42340
  await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
@@ -42379,7 +42345,6 @@ Supported fuel-core version: ${supportedVersion}.`
42379
42345
  await this.provider.estimateTxDependencies(transactionRequest);
42380
42346
  }
42381
42347
  return this.provider.sendTransaction(transactionRequest, {
42382
- awaitExecution,
42383
42348
  estimateTxDependencies: false
42384
42349
  });
42385
42350
  }
@@ -42424,9 +42389,7 @@ Supported fuel-core version: ${supportedVersion}.`
42424
42389
  /** @hidden * */
42425
42390
  async estimateAndFundTransaction(transactionRequest, txParams) {
42426
42391
  let request = transactionRequest;
42427
- const txCost = await this.provider.getTransactionCost(request, {
42428
- resourcesOwner: this
42429
- });
42392
+ const txCost = await this.getTransactionCost(request);
42430
42393
  request = this.validateGasLimitAndMaxFee({
42431
42394
  transactionRequest: request,
42432
42395
  gasUsed: txCost.gasUsed,
@@ -42525,10 +42488,10 @@ Supported fuel-core version: ${supportedVersion}.`
42525
42488
  sum += a.length;
42526
42489
  }
42527
42490
  const res = new Uint8Array(sum);
42528
- for (let i = 0, pad3 = 0; i < arrays.length; i++) {
42491
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
42529
42492
  const a = arrays[i];
42530
- res.set(a, pad3);
42531
- pad3 += a.length;
42493
+ res.set(a, pad);
42494
+ pad += a.length;
42532
42495
  }
42533
42496
  return res;
42534
42497
  }
@@ -42820,16 +42783,16 @@ Supported fuel-core version: ${supportedVersion}.`
42820
42783
  this.blockLen = this.iHash.blockLen;
42821
42784
  this.outputLen = this.iHash.outputLen;
42822
42785
  const blockLen = this.blockLen;
42823
- const pad3 = new Uint8Array(blockLen);
42824
- pad3.set(key.length > blockLen ? hash4.create().update(key).digest() : key);
42825
- for (let i = 0; i < pad3.length; i++)
42826
- pad3[i] ^= 54;
42827
- this.iHash.update(pad3);
42786
+ const pad = new Uint8Array(blockLen);
42787
+ pad.set(key.length > blockLen ? hash4.create().update(key).digest() : key);
42788
+ for (let i = 0; i < pad.length; i++)
42789
+ pad[i] ^= 54;
42790
+ this.iHash.update(pad);
42828
42791
  this.oHash = hash4.create();
42829
- for (let i = 0; i < pad3.length; i++)
42830
- pad3[i] ^= 54 ^ 92;
42831
- this.oHash.update(pad3);
42832
- pad3.fill(0);
42792
+ for (let i = 0; i < pad.length; i++)
42793
+ pad[i] ^= 54 ^ 92;
42794
+ this.oHash.update(pad);
42795
+ pad.fill(0);
42833
42796
  }
42834
42797
  update(buf) {
42835
42798
  exists2(this);
@@ -44454,17 +44417,16 @@ Supported fuel-core version: ${supportedVersion}.`
44454
44417
  *
44455
44418
  * @param transactionRequestLike - The transaction request to send.
44456
44419
  * @param estimateTxDependencies - Whether to estimate the transaction dependencies.
44457
- * @param awaitExecution - Whether to wait for the transaction to be executed.
44458
44420
  * @returns A promise that resolves to the TransactionResponse object.
44459
44421
  */
44460
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
44422
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false } = {}) {
44461
44423
  const transactionRequest = transactionRequestify(transactionRequestLike);
44462
44424
  if (estimateTxDependencies) {
44463
44425
  await this.provider.estimateTxDependencies(transactionRequest);
44464
44426
  }
44465
44427
  return this.provider.sendTransaction(
44466
44428
  await this.populateTransactionWitnessesSignature(transactionRequest),
44467
- { awaitExecution, estimateTxDependencies: false }
44429
+ { estimateTxDependencies: false }
44468
44430
  );
44469
44431
  }
44470
44432
  /**