@fuel-ts/account 0.0.0-rc-1356-20240510142347 → 0.0.0-rc-2037-20240510174704

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 (46) hide show
  1. package/dist/index.global.js +102 -45
  2. package/dist/index.global.js.map +1 -1
  3. package/dist/index.js +442 -363
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +242 -171
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/predicate/predicate.d.ts +9 -2
  8. package/dist/predicate/predicate.d.ts.map +1 -1
  9. package/dist/providers/provider.d.ts +1 -1
  10. package/dist/providers/provider.d.ts.map +1 -1
  11. package/dist/providers/transaction-request/helpers.d.ts +4 -0
  12. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  13. package/dist/providers/transaction-request/index.d.ts +1 -0
  14. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  15. package/dist/providers/transaction-request/transaction-request.d.ts +2 -0
  16. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  17. package/dist/providers/transaction-request/utils.d.ts +0 -4
  18. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  19. package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -1
  20. package/dist/providers/utils/index.d.ts +1 -0
  21. package/dist/providers/utils/index.d.ts.map +1 -1
  22. package/dist/providers/utils/sleep.d.ts +3 -0
  23. package/dist/providers/utils/sleep.d.ts.map +1 -0
  24. package/dist/test-utils/index.d.ts +0 -4
  25. package/dist/test-utils/index.d.ts.map +1 -1
  26. package/dist/test-utils/launchNode.d.ts +1 -8
  27. package/dist/test-utils/launchNode.d.ts.map +1 -1
  28. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  29. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  30. package/dist/test-utils.global.js +126 -432
  31. package/dist/test-utils.global.js.map +1 -1
  32. package/dist/test-utils.js +427 -642
  33. package/dist/test-utils.js.map +1 -1
  34. package/dist/test-utils.mjs +252 -463
  35. package/dist/test-utils.mjs.map +1 -1
  36. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  37. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  38. package/package.json +15 -16
  39. package/dist/test-utils/asset-id.d.ts +0 -8
  40. package/dist/test-utils/asset-id.d.ts.map +0 -1
  41. package/dist/test-utils/setup-test-provider-and-wallets.d.ts +0 -33
  42. package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +0 -1
  43. package/dist/test-utils/test-message.d.ts +0 -28
  44. package/dist/test-utils/test-message.d.ts.map +0 -1
  45. package/dist/test-utils/wallet-config.d.ts +0 -49
  46. package/dist/test-utils/wallet-config.d.ts.map +0 -1
@@ -68,7 +68,7 @@ var addAmountToCoinQuantities = (params) => {
68
68
  // src/providers/provider.ts
69
69
  import { Address as Address2 } from "@fuel-ts/address";
70
70
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
71
- import { BN, bn as bn17 } from "@fuel-ts/math";
71
+ import { BN, bn as bn18 } from "@fuel-ts/math";
72
72
  import {
73
73
  InputType as InputType7,
74
74
  TransactionType as TransactionType8,
@@ -1291,11 +1291,11 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1291
1291
  import { Address, addressify } from "@fuel-ts/address";
1292
1292
  import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1293
1293
  import { randomBytes } from "@fuel-ts/crypto";
1294
- import { bn as bn7 } from "@fuel-ts/math";
1294
+ import { bn as bn8 } from "@fuel-ts/math";
1295
1295
  import {
1296
1296
  PolicyType,
1297
1297
  TransactionCoder,
1298
- InputType as InputType2,
1298
+ InputType as InputType3,
1299
1299
  OutputType as OutputType2,
1300
1300
  TransactionType
1301
1301
  } from "@fuel-ts/transactions";
@@ -1645,6 +1645,15 @@ function normalizeJSON(root) {
1645
1645
  return normalize(clone(root));
1646
1646
  }
1647
1647
 
1648
+ // src/providers/utils/sleep.ts
1649
+ function sleep(time) {
1650
+ return new Promise((resolve) => {
1651
+ setTimeout(() => {
1652
+ resolve(true);
1653
+ }, time);
1654
+ });
1655
+ }
1656
+
1648
1657
  // src/providers/utils/extract-tx-error.ts
1649
1658
  import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
1650
1659
  import { bn as bn6 } from "@fuel-ts/math";
@@ -1735,6 +1744,36 @@ var NoWitnessAtIndexError = class extends Error {
1735
1744
  name = "NoWitnessAtIndexError";
1736
1745
  };
1737
1746
 
1747
+ // src/providers/transaction-request/helpers.ts
1748
+ import { bn as bn7 } from "@fuel-ts/math";
1749
+ import { InputType as InputType2 } from "@fuel-ts/transactions";
1750
+ var isRequestInputCoin = (input) => input.type === InputType2.Coin;
1751
+ var isRequestInputMessage = (input) => input.type === InputType2.Message;
1752
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1753
+ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
1754
+ if (isRequestInputCoin(input) && input.assetId === assetId) {
1755
+ return acc.add(input.amount);
1756
+ }
1757
+ if (isRequestInputMessage(input) && assetId === baseAsset) {
1758
+ return acc.add(input.amount);
1759
+ }
1760
+ return acc;
1761
+ }, bn7(0));
1762
+ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
1763
+ (acc, input) => {
1764
+ if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
1765
+ acc.utxos.push(input.id);
1766
+ } else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
1767
+ acc.messages.push(input.nonce);
1768
+ }
1769
+ return acc;
1770
+ },
1771
+ {
1772
+ utxos: [],
1773
+ messages: []
1774
+ }
1775
+ );
1776
+
1738
1777
  // src/providers/transaction-request/witness.ts
1739
1778
  import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
1740
1779
  var witnessify = (value) => {
@@ -1775,10 +1814,10 @@ var BaseTransactionRequest = class {
1775
1814
  outputs,
1776
1815
  witnesses
1777
1816
  } = {}) {
1778
- this.tip = tip ? bn7(tip) : void 0;
1817
+ this.tip = tip ? bn8(tip) : void 0;
1779
1818
  this.maturity = maturity && maturity > 0 ? maturity : void 0;
1780
- this.witnessLimit = isDefined(witnessLimit) ? bn7(witnessLimit) : void 0;
1781
- this.maxFee = bn7(maxFee);
1819
+ this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
1820
+ this.maxFee = bn8(maxFee);
1782
1821
  this.inputs = inputs ?? [];
1783
1822
  this.outputs = outputs ?? [];
1784
1823
  this.witnesses = witnesses ?? [];
@@ -1787,13 +1826,13 @@ var BaseTransactionRequest = class {
1787
1826
  let policyTypes = 0;
1788
1827
  const policies = [];
1789
1828
  const { tip, witnessLimit, maturity } = req;
1790
- if (bn7(tip).gt(0)) {
1829
+ if (bn8(tip).gt(0)) {
1791
1830
  policyTypes += PolicyType.Tip;
1792
- policies.push({ data: bn7(tip), type: PolicyType.Tip });
1831
+ policies.push({ data: bn8(tip), type: PolicyType.Tip });
1793
1832
  }
1794
- if (isDefined(witnessLimit) && bn7(witnessLimit).gte(0)) {
1833
+ if (isDefined(witnessLimit) && bn8(witnessLimit).gte(0)) {
1795
1834
  policyTypes += PolicyType.WitnessLimit;
1796
- policies.push({ data: bn7(witnessLimit), type: PolicyType.WitnessLimit });
1835
+ policies.push({ data: bn8(witnessLimit), type: PolicyType.WitnessLimit });
1797
1836
  }
1798
1837
  if (maturity && maturity > 0) {
1799
1838
  policyTypes += PolicyType.Maturity;
@@ -1924,7 +1963,7 @@ var BaseTransactionRequest = class {
1924
1963
  */
1925
1964
  getCoinInputs() {
1926
1965
  return this.inputs.filter(
1927
- (input) => input.type === InputType2.Coin
1966
+ (input) => input.type === InputType3.Coin
1928
1967
  );
1929
1968
  }
1930
1969
  /**
@@ -1956,9 +1995,9 @@ var BaseTransactionRequest = class {
1956
1995
  const ownerAddress = addressify(owner);
1957
1996
  const found = this.inputs.find((input) => {
1958
1997
  switch (input.type) {
1959
- case InputType2.Coin:
1998
+ case InputType3.Coin:
1960
1999
  return hexlify7(input.owner) === ownerAddress.toB256();
1961
- case InputType2.Message:
2000
+ case InputType3.Message:
1962
2001
  return hexlify7(input.recipient) === ownerAddress.toB256();
1963
2002
  default:
1964
2003
  return false;
@@ -1973,7 +2012,7 @@ var BaseTransactionRequest = class {
1973
2012
  * @param coin - Coin resource.
1974
2013
  */
1975
2014
  addCoinInput(coin) {
1976
- const { assetId, owner, amount } = coin;
2015
+ const { assetId, owner, amount, id, predicate } = coin;
1977
2016
  let witnessIndex;
1978
2017
  if (coin.predicate) {
1979
2018
  witnessIndex = 0;
@@ -1984,13 +2023,14 @@ var BaseTransactionRequest = class {
1984
2023
  }
1985
2024
  }
1986
2025
  const input = {
1987
- ...coin,
1988
- type: InputType2.Coin,
2026
+ id,
2027
+ type: InputType3.Coin,
1989
2028
  owner: owner.toB256(),
1990
2029
  amount,
1991
2030
  assetId,
1992
2031
  txPointer: "0x00000000000000000000000000000000",
1993
- witnessIndex
2032
+ witnessIndex,
2033
+ predicate
1994
2034
  };
1995
2035
  this.pushInput(input);
1996
2036
  this.addChangeOutput(owner, assetId);
@@ -2002,7 +2042,7 @@ var BaseTransactionRequest = class {
2002
2042
  * @param message - Message resource.
2003
2043
  */
2004
2044
  addMessageInput(message) {
2005
- const { recipient, sender, amount, assetId } = message;
2045
+ const { recipient, sender, amount, predicate, nonce, assetId } = message;
2006
2046
  let witnessIndex;
2007
2047
  if (message.predicate) {
2008
2048
  witnessIndex = 0;
@@ -2013,12 +2053,13 @@ var BaseTransactionRequest = class {
2013
2053
  }
2014
2054
  }
2015
2055
  const input = {
2016
- ...message,
2017
- type: InputType2.Message,
2056
+ nonce,
2057
+ type: InputType3.Message,
2018
2058
  sender: sender.toB256(),
2019
2059
  recipient: recipient.toB256(),
2020
2060
  amount,
2021
- witnessIndex
2061
+ witnessIndex,
2062
+ predicate
2022
2063
  };
2023
2064
  this.pushInput(input);
2024
2065
  this.addChangeOutput(recipient, assetId);
@@ -2165,7 +2206,7 @@ var BaseTransactionRequest = class {
2165
2206
  const assetInput = findAssetInput(assetId);
2166
2207
  let usedQuantity = quantity;
2167
2208
  if (assetId === baseAssetId) {
2168
- usedQuantity = bn7("1000000000000000000");
2209
+ usedQuantity = bn8("1000000000000000000");
2169
2210
  }
2170
2211
  if (assetInput && "assetId" in assetInput) {
2171
2212
  assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
@@ -2177,13 +2218,13 @@ var BaseTransactionRequest = class {
2177
2218
  amount: usedQuantity,
2178
2219
  assetId,
2179
2220
  owner: resourcesOwner || Address.fromRandom(),
2180
- blockCreated: bn7(1),
2181
- txCreatedIdx: bn7(1)
2221
+ blockCreated: bn8(1),
2222
+ txCreatedIdx: bn8(1)
2182
2223
  }
2183
2224
  ]);
2184
2225
  }
2185
2226
  };
2186
- updateAssetInput(baseAssetId, bn7(1e11));
2227
+ updateAssetInput(baseAssetId, bn8(1e11));
2187
2228
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2188
2229
  }
2189
2230
  /**
@@ -2194,7 +2235,7 @@ var BaseTransactionRequest = class {
2194
2235
  */
2195
2236
  getCoinOutputsQuantities() {
2196
2237
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2197
- amount: bn7(amount),
2238
+ amount: bn8(amount),
2198
2239
  assetId: assetId.toString()
2199
2240
  }));
2200
2241
  return coinsQuantities;
@@ -2208,22 +2249,33 @@ var BaseTransactionRequest = class {
2208
2249
  toJSON() {
2209
2250
  return normalizeJSON(this);
2210
2251
  }
2252
+ removeWitness(index) {
2253
+ this.witnesses.splice(index, 1);
2254
+ this.adjustWitnessIndexes(index);
2255
+ }
2256
+ adjustWitnessIndexes(removedIndex) {
2257
+ this.inputs.filter(isRequestInputResource).forEach((input) => {
2258
+ if (input.witnessIndex > removedIndex) {
2259
+ input.witnessIndex -= 1;
2260
+ }
2261
+ });
2262
+ }
2211
2263
  updatePredicateGasUsed(inputs) {
2212
2264
  this.inputs.forEach((i) => {
2213
2265
  let correspondingInput;
2214
2266
  switch (i.type) {
2215
- case InputType2.Coin:
2216
- correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
2267
+ case InputType3.Coin:
2268
+ correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
2217
2269
  break;
2218
- case InputType2.Message:
2270
+ case InputType3.Message:
2219
2271
  correspondingInput = inputs.find(
2220
- (x) => x.type === InputType2.Message && x.sender === i.sender
2272
+ (x) => x.type === InputType3.Message && x.sender === i.sender
2221
2273
  );
2222
2274
  break;
2223
2275
  default:
2224
2276
  return;
2225
2277
  }
2226
- if (correspondingInput && "predicateGasUsed" in correspondingInput && bn7(correspondingInput.predicateGasUsed).gt(0)) {
2278
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
2227
2279
  i.predicate = correspondingInput.predicate;
2228
2280
  i.predicateData = correspondingInput.predicateData;
2229
2281
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2243,15 +2295,15 @@ var BaseTransactionRequest = class {
2243
2295
 
2244
2296
  // src/providers/transaction-request/create-transaction-request.ts
2245
2297
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2246
- import { bn as bn9 } from "@fuel-ts/math";
2298
+ import { bn as bn10 } from "@fuel-ts/math";
2247
2299
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2248
2300
  import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2249
2301
 
2250
2302
  // src/providers/transaction-request/hash-transaction.ts
2251
2303
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2252
2304
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2253
- import { bn as bn8 } from "@fuel-ts/math";
2254
- import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2305
+ import { bn as bn9 } from "@fuel-ts/math";
2306
+ import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2255
2307
  import { concat as concat2 } from "@fuel-ts/utils";
2256
2308
  import { clone as clone2 } from "ramda";
2257
2309
  function hashTransaction(transactionRequest, chainId) {
@@ -2262,19 +2314,19 @@ function hashTransaction(transactionRequest, chainId) {
2262
2314
  transaction.inputs = transaction.inputs.map((input) => {
2263
2315
  const inputClone = clone2(input);
2264
2316
  switch (inputClone.type) {
2265
- case InputType3.Coin: {
2317
+ case InputType4.Coin: {
2266
2318
  inputClone.txPointer = {
2267
2319
  blockHeight: 0,
2268
2320
  txIndex: 0
2269
2321
  };
2270
- inputClone.predicateGasUsed = bn8(0);
2322
+ inputClone.predicateGasUsed = bn9(0);
2271
2323
  return inputClone;
2272
2324
  }
2273
- case InputType3.Message: {
2274
- inputClone.predicateGasUsed = bn8(0);
2325
+ case InputType4.Message: {
2326
+ inputClone.predicateGasUsed = bn9(0);
2275
2327
  return inputClone;
2276
2328
  }
2277
- case InputType3.Contract: {
2329
+ case InputType4.Contract: {
2278
2330
  inputClone.txPointer = {
2279
2331
  blockHeight: 0,
2280
2332
  txIndex: 0
@@ -2298,12 +2350,12 @@ function hashTransaction(transactionRequest, chainId) {
2298
2350
  return outputClone;
2299
2351
  }
2300
2352
  case OutputType3.Change: {
2301
- outputClone.amount = bn8(0);
2353
+ outputClone.amount = bn9(0);
2302
2354
  return outputClone;
2303
2355
  }
2304
2356
  case OutputType3.Variable: {
2305
2357
  outputClone.to = ZeroBytes325;
2306
- outputClone.amount = bn8(0);
2358
+ outputClone.amount = bn9(0);
2307
2359
  outputClone.assetId = ZeroBytes325;
2308
2360
  return outputClone;
2309
2361
  }
@@ -2381,7 +2433,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2381
2433
  type: TransactionType3.Create,
2382
2434
  ...baseTransaction,
2383
2435
  bytecodeWitnessIndex,
2384
- storageSlotsCount: bn9(storageSlots.length),
2436
+ storageSlotsCount: bn10(storageSlots.length),
2385
2437
  salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
2386
2438
  storageSlots
2387
2439
  };
@@ -2421,7 +2473,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2421
2473
  }
2422
2474
  metadataGas(gasCosts) {
2423
2475
  return calculateMetadataGasForTxCreate({
2424
- contractBytesSize: bn9(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2476
+ contractBytesSize: bn10(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2425
2477
  gasCosts,
2426
2478
  stateRootSize: this.storageSlots.length,
2427
2479
  txBytesSize: this.byteSize()
@@ -2433,8 +2485,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2433
2485
  import { Interface } from "@fuel-ts/abi-coder";
2434
2486
  import { addressify as addressify2 } from "@fuel-ts/address";
2435
2487
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2436
- import { bn as bn10 } from "@fuel-ts/math";
2437
- import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2488
+ import { bn as bn11 } from "@fuel-ts/math";
2489
+ import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2438
2490
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2439
2491
 
2440
2492
  // src/providers/transaction-request/scripts.ts
@@ -2487,7 +2539,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2487
2539
  */
2488
2540
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2489
2541
  super(rest);
2490
- this.gasLimit = bn10(gasLimit);
2542
+ this.gasLimit = bn11(gasLimit);
2491
2543
  this.script = arrayify8(script ?? returnZeroScript.bytes);
2492
2544
  this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
2493
2545
  this.abis = rest.abis;
@@ -2504,8 +2556,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2504
2556
  type: TransactionType4.Script,
2505
2557
  scriptGasLimit: this.gasLimit,
2506
2558
  ...super.getBaseTransaction(),
2507
- scriptLength: bn10(script.length),
2508
- scriptDataLength: bn10(scriptData.length),
2559
+ scriptLength: bn11(script.length),
2560
+ scriptDataLength: bn11(scriptData.length),
2509
2561
  receiptsRoot: ZeroBytes327,
2510
2562
  script: hexlify10(script),
2511
2563
  scriptData: hexlify10(scriptData)
@@ -2518,7 +2570,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2518
2570
  */
2519
2571
  getContractInputs() {
2520
2572
  return this.inputs.filter(
2521
- (input) => input.type === InputType4.Contract
2573
+ (input) => input.type === InputType5.Contract
2522
2574
  );
2523
2575
  }
2524
2576
  /**
@@ -2598,7 +2650,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2598
2650
  return this;
2599
2651
  }
2600
2652
  const inputIndex = super.pushInput({
2601
- type: InputType4.Contract,
2653
+ type: InputType5.Contract,
2602
2654
  contractId: contractAddress.toB256(),
2603
2655
  txPointer: "0x00000000000000000000000000000000"
2604
2656
  });
@@ -2640,7 +2692,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2640
2692
 
2641
2693
  // src/providers/transaction-request/utils.ts
2642
2694
  import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2643
- import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
2695
+ import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2644
2696
  var transactionRequestify = (obj) => {
2645
2697
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2646
2698
  return obj;
@@ -2658,35 +2710,20 @@ var transactionRequestify = (obj) => {
2658
2710
  }
2659
2711
  }
2660
2712
  };
2661
- var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2662
- (acc, input) => {
2663
- if (input.type === InputType5.Coin && input.owner === owner.toB256()) {
2664
- acc.utxos.push(input.id);
2665
- }
2666
- if (input.type === InputType5.Message && input.recipient === owner.toB256()) {
2667
- acc.messages.push(input.nonce);
2668
- }
2669
- return acc;
2670
- },
2671
- {
2672
- utxos: [],
2673
- messages: []
2674
- }
2675
- );
2676
2713
 
2677
2714
  // src/providers/transaction-response/transaction-response.ts
2678
2715
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2679
- import { bn as bn16 } from "@fuel-ts/math";
2716
+ import { bn as bn17 } from "@fuel-ts/math";
2680
2717
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2681
2718
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2682
2719
 
2683
2720
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2684
- import { bn as bn15 } from "@fuel-ts/math";
2721
+ import { bn as bn16 } from "@fuel-ts/math";
2685
2722
  import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2686
2723
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2687
2724
 
2688
2725
  // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
2689
- import { bn as bn11 } from "@fuel-ts/math";
2726
+ import { bn as bn12 } from "@fuel-ts/math";
2690
2727
  import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
2691
2728
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2692
2729
  var calculateTXFeeForSummary = (params) => {
@@ -2700,19 +2737,19 @@ var calculateTXFeeForSummary = (params) => {
2700
2737
  if (totalFee) {
2701
2738
  return totalFee;
2702
2739
  }
2703
- const gasPerByte = bn11(feeParams.gasPerByte);
2704
- const gasPriceFactor = bn11(feeParams.gasPriceFactor);
2740
+ const gasPerByte = bn12(feeParams.gasPerByte);
2741
+ const gasPriceFactor = bn12(feeParams.gasPriceFactor);
2705
2742
  const transactionBytes = arrayify9(rawPayload);
2706
2743
  const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
2707
2744
  const { type, witnesses, inputs, policies } = transaction;
2708
- let metadataGas = bn11(0);
2709
- let gasLimit = bn11(0);
2745
+ let metadataGas = bn12(0);
2746
+ let gasLimit = bn12(0);
2710
2747
  if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
2711
- return bn11(0);
2748
+ return bn12(0);
2712
2749
  }
2713
2750
  if (type === TransactionType6.Create) {
2714
2751
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2715
- const contractBytesSize = bn11(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2752
+ const contractBytesSize = bn12(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2716
2753
  metadataGas = calculateMetadataGasForTxCreate({
2717
2754
  contractBytesSize,
2718
2755
  gasCosts,
@@ -2731,7 +2768,7 @@ var calculateTXFeeForSummary = (params) => {
2731
2768
  }
2732
2769
  const minGas = getMinGas({
2733
2770
  gasCosts,
2734
- gasPerByte: bn11(gasPerByte),
2771
+ gasPerByte: bn12(gasPerByte),
2735
2772
  inputs,
2736
2773
  metadataGas,
2737
2774
  txBytesSize: transactionBytes.length
@@ -2758,12 +2795,12 @@ var calculateTXFeeForSummary = (params) => {
2758
2795
  // src/providers/transaction-summary/operations.ts
2759
2796
  import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
2760
2797
  import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
2761
- import { bn as bn13 } from "@fuel-ts/math";
2798
+ import { bn as bn14 } from "@fuel-ts/math";
2762
2799
  import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2763
2800
 
2764
2801
  // src/providers/transaction-summary/call.ts
2765
2802
  import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
2766
- import { bn as bn12 } from "@fuel-ts/math";
2803
+ import { bn as bn13 } from "@fuel-ts/math";
2767
2804
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2768
2805
  const abiInterface = new Interface2(abi);
2769
2806
  const callFunctionSelector = receipt.param1.toHex(8);
@@ -2772,7 +2809,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2772
2809
  let encodedArgs;
2773
2810
  if (functionFragment.isInputDataPointer) {
2774
2811
  if (rawPayload) {
2775
- const argsOffset = bn12(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2812
+ const argsOffset = bn13(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2776
2813
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2777
2814
  }
2778
2815
  } else {
@@ -2934,7 +2971,7 @@ var mergeAssets = (op1, op2) => {
2934
2971
  if (!matchingAsset) {
2935
2972
  return asset1;
2936
2973
  }
2937
- const mergedAmount = bn13(asset1.amount).add(matchingAsset.amount);
2974
+ const mergedAmount = bn14(asset1.amount).add(matchingAsset.amount);
2938
2975
  return { ...asset1, amount: mergedAmount };
2939
2976
  });
2940
2977
  return mergedAssets.concat(filteredAssets);
@@ -3257,7 +3294,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3257
3294
 
3258
3295
  // src/providers/transaction-summary/status.ts
3259
3296
  import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
3260
- import { bn as bn14 } from "@fuel-ts/math";
3297
+ import { bn as bn15 } from "@fuel-ts/math";
3261
3298
  var getTransactionStatusName = (gqlStatus) => {
3262
3299
  switch (gqlStatus) {
3263
3300
  case "FailureStatus":
@@ -3291,15 +3328,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3291
3328
  time = gqlTransactionStatus.time;
3292
3329
  blockId = gqlTransactionStatus.block.id;
3293
3330
  isStatusSuccess = true;
3294
- totalFee = bn14(gqlTransactionStatus.totalFee);
3295
- totalGas = bn14(gqlTransactionStatus.totalGas);
3331
+ totalFee = bn15(gqlTransactionStatus.totalFee);
3332
+ totalGas = bn15(gqlTransactionStatus.totalGas);
3296
3333
  break;
3297
3334
  case "FailureStatus":
3298
3335
  time = gqlTransactionStatus.time;
3299
3336
  blockId = gqlTransactionStatus.block.id;
3300
3337
  isStatusFailure = true;
3301
- totalFee = bn14(gqlTransactionStatus.totalFee);
3302
- totalGas = bn14(gqlTransactionStatus.totalGas);
3338
+ totalFee = bn15(gqlTransactionStatus.totalFee);
3339
+ totalGas = bn15(gqlTransactionStatus.totalGas);
3303
3340
  break;
3304
3341
  case "SubmittedStatus":
3305
3342
  time = gqlTransactionStatus.time;
@@ -3349,7 +3386,7 @@ function assembleTransactionSummary(params) {
3349
3386
  maxInputs
3350
3387
  });
3351
3388
  const typeName = getTransactionTypeName(transaction.type);
3352
- const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3389
+ const tip = bn16(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3353
3390
  const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3354
3391
  const fee = calculateTXFeeForSummary({
3355
3392
  totalFee,
@@ -3420,7 +3457,7 @@ var TransactionResponse = class {
3420
3457
  /** Current provider */
3421
3458
  provider;
3422
3459
  /** Gas used on the transaction */
3423
- gasUsed = bn16(0);
3460
+ gasUsed = bn17(0);
3424
3461
  /** The graphql Transaction with receipts object. */
3425
3462
  gqlTransaction;
3426
3463
  abis;
@@ -3588,7 +3625,6 @@ var TransactionResponse = class {
3588
3625
  };
3589
3626
 
3590
3627
  // src/providers/utils/auto-retry-fetch.ts
3591
- import { sleep } from "@fuel-ts/utils";
3592
3628
  function getWaitDelay(options, retryAttemptNum) {
3593
3629
  const duration = options.baseDelay ?? 150;
3594
3630
  switch (options.backoff) {
@@ -3655,47 +3691,47 @@ var processGqlChain = (chain) => {
3655
3691
  } = consensusParameters;
3656
3692
  return {
3657
3693
  name,
3658
- baseChainHeight: bn17(daHeight),
3694
+ baseChainHeight: bn18(daHeight),
3659
3695
  consensusParameters: {
3660
3696
  version,
3661
- chainId: bn17(chainId),
3697
+ chainId: bn18(chainId),
3662
3698
  baseAssetId,
3663
3699
  feeParameters: {
3664
3700
  version: feeParams.version,
3665
- gasPerByte: bn17(feeParams.gasPerByte),
3666
- gasPriceFactor: bn17(feeParams.gasPriceFactor)
3701
+ gasPerByte: bn18(feeParams.gasPerByte),
3702
+ gasPriceFactor: bn18(feeParams.gasPriceFactor)
3667
3703
  },
3668
3704
  contractParameters: {
3669
3705
  version: contractParams.version,
3670
- contractMaxSize: bn17(contractParams.contractMaxSize),
3671
- maxStorageSlots: bn17(contractParams.maxStorageSlots)
3706
+ contractMaxSize: bn18(contractParams.contractMaxSize),
3707
+ maxStorageSlots: bn18(contractParams.maxStorageSlots)
3672
3708
  },
3673
3709
  txParameters: {
3674
3710
  version: txParams.version,
3675
- maxInputs: bn17(txParams.maxInputs),
3676
- maxOutputs: bn17(txParams.maxOutputs),
3677
- maxWitnesses: bn17(txParams.maxWitnesses),
3678
- maxGasPerTx: bn17(txParams.maxGasPerTx),
3679
- maxSize: bn17(txParams.maxSize),
3680
- maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
3711
+ maxInputs: bn18(txParams.maxInputs),
3712
+ maxOutputs: bn18(txParams.maxOutputs),
3713
+ maxWitnesses: bn18(txParams.maxWitnesses),
3714
+ maxGasPerTx: bn18(txParams.maxGasPerTx),
3715
+ maxSize: bn18(txParams.maxSize),
3716
+ maxBytecodeSubsections: bn18(txParams.maxBytecodeSubsections)
3681
3717
  },
3682
3718
  predicateParameters: {
3683
3719
  version: predicateParams.version,
3684
- maxPredicateLength: bn17(predicateParams.maxPredicateLength),
3685
- maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
3686
- maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
3687
- maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
3720
+ maxPredicateLength: bn18(predicateParams.maxPredicateLength),
3721
+ maxPredicateDataLength: bn18(predicateParams.maxPredicateDataLength),
3722
+ maxGasPerPredicate: bn18(predicateParams.maxGasPerPredicate),
3723
+ maxMessageDataLength: bn18(predicateParams.maxMessageDataLength)
3688
3724
  },
3689
3725
  scriptParameters: {
3690
3726
  version: scriptParams.version,
3691
- maxScriptLength: bn17(scriptParams.maxScriptLength),
3692
- maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
3727
+ maxScriptLength: bn18(scriptParams.maxScriptLength),
3728
+ maxScriptDataLength: bn18(scriptParams.maxScriptDataLength)
3693
3729
  },
3694
3730
  gasCosts
3695
3731
  },
3696
3732
  latestBlock: {
3697
3733
  id: latestBlock.id,
3698
- height: bn17(latestBlock.height),
3734
+ height: bn18(latestBlock.height),
3699
3735
  time: latestBlock.header.time,
3700
3736
  transactions: latestBlock.transactions.map((i) => ({
3701
3737
  id: i.id
@@ -3891,7 +3927,7 @@ Supported fuel-core version: ${supportedVersion}.`
3891
3927
  */
3892
3928
  async getBlockNumber() {
3893
3929
  const { chain } = await this.operations.getChain();
3894
- return bn17(chain.latestBlock.height, 10);
3930
+ return bn18(chain.latestBlock.height, 10);
3895
3931
  }
3896
3932
  /**
3897
3933
  * Returns the chain information.
@@ -3901,8 +3937,8 @@ Supported fuel-core version: ${supportedVersion}.`
3901
3937
  async fetchNode() {
3902
3938
  const { nodeInfo } = await this.operations.getNodeInfo();
3903
3939
  const processedNodeInfo = {
3904
- maxDepth: bn17(nodeInfo.maxDepth),
3905
- maxTx: bn17(nodeInfo.maxTx),
3940
+ maxDepth: bn18(nodeInfo.maxDepth),
3941
+ maxTx: bn18(nodeInfo.maxTx),
3906
3942
  nodeVersion: nodeInfo.nodeVersion,
3907
3943
  utxoValidation: nodeInfo.utxoValidation,
3908
3944
  vmBacktrace: nodeInfo.vmBacktrace
@@ -4034,7 +4070,7 @@ Supported fuel-core version: ${supportedVersion}.`
4034
4070
  } = response;
4035
4071
  if (inputs) {
4036
4072
  inputs.forEach((input, index) => {
4037
- if ("predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
4073
+ if ("predicateGasUsed" in input && bn18(input.predicateGasUsed).gt(0)) {
4038
4074
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4039
4075
  }
4040
4076
  });
@@ -4192,12 +4228,12 @@ Supported fuel-core version: ${supportedVersion}.`
4192
4228
  gasPrice = await this.estimateGasPrice(10);
4193
4229
  }
4194
4230
  const minFee = calculateGasFee({
4195
- gasPrice: bn17(gasPrice),
4231
+ gasPrice: bn18(gasPrice),
4196
4232
  gas: minGas,
4197
4233
  priceFactor: gasPriceFactor,
4198
4234
  tip: transactionRequest.tip
4199
4235
  }).add(1);
4200
- let gasLimit = bn17(0);
4236
+ let gasLimit = bn18(0);
4201
4237
  if (transactionRequest.type === TransactionType8.Script) {
4202
4238
  gasLimit = transactionRequest.gasLimit;
4203
4239
  if (transactionRequest.gasLimit.eq(0)) {
@@ -4210,7 +4246,7 @@ Supported fuel-core version: ${supportedVersion}.`
4210
4246
  }
4211
4247
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4212
4248
  const maxFee = calculateGasFee({
4213
- gasPrice: bn17(gasPrice),
4249
+ gasPrice: bn18(gasPrice),
4214
4250
  gas: maxGas,
4215
4251
  priceFactor: gasPriceFactor,
4216
4252
  tip: transactionRequest.tip
@@ -4275,7 +4311,7 @@ Supported fuel-core version: ${supportedVersion}.`
4275
4311
  const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4276
4312
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4277
4313
  if (isScriptTransaction) {
4278
- txRequestClone.gasLimit = bn17(0);
4314
+ txRequestClone.gasLimit = bn18(0);
4279
4315
  }
4280
4316
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4281
4317
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4296,7 +4332,7 @@ Supported fuel-core version: ${supportedVersion}.`
4296
4332
  let dryRunStatus;
4297
4333
  let missingContractIds = [];
4298
4334
  let outputVariables = 0;
4299
- let gasUsed = bn17(0);
4335
+ let gasUsed = bn18(0);
4300
4336
  txRequestClone.maxFee = maxFee;
4301
4337
  if (isScriptTransaction) {
4302
4338
  txRequestClone.gasLimit = gasLimit;
@@ -4361,10 +4397,10 @@ Supported fuel-core version: ${supportedVersion}.`
4361
4397
  return coins.map((coin) => ({
4362
4398
  id: coin.utxoId,
4363
4399
  assetId: coin.assetId,
4364
- amount: bn17(coin.amount),
4400
+ amount: bn18(coin.amount),
4365
4401
  owner: Address2.fromAddressOrString(coin.owner),
4366
- blockCreated: bn17(coin.blockCreated),
4367
- txCreatedIdx: bn17(coin.txCreatedIdx)
4402
+ blockCreated: bn18(coin.blockCreated),
4403
+ txCreatedIdx: bn18(coin.txCreatedIdx)
4368
4404
  }));
4369
4405
  }
4370
4406
  /**
@@ -4401,9 +4437,9 @@ Supported fuel-core version: ${supportedVersion}.`
4401
4437
  switch (coin.type) {
4402
4438
  case "MessageCoin":
4403
4439
  return {
4404
- amount: bn17(coin.amount),
4440
+ amount: bn18(coin.amount),
4405
4441
  assetId: coin.assetId,
4406
- daHeight: bn17(coin.daHeight),
4442
+ daHeight: bn18(coin.daHeight),
4407
4443
  sender: Address2.fromAddressOrString(coin.sender),
4408
4444
  recipient: Address2.fromAddressOrString(coin.recipient),
4409
4445
  nonce: coin.nonce
@@ -4411,11 +4447,11 @@ Supported fuel-core version: ${supportedVersion}.`
4411
4447
  case "Coin":
4412
4448
  return {
4413
4449
  id: coin.utxoId,
4414
- amount: bn17(coin.amount),
4450
+ amount: bn18(coin.amount),
4415
4451
  assetId: coin.assetId,
4416
4452
  owner: Address2.fromAddressOrString(coin.owner),
4417
- blockCreated: bn17(coin.blockCreated),
4418
- txCreatedIdx: bn17(coin.txCreatedIdx)
4453
+ blockCreated: bn18(coin.blockCreated),
4454
+ txCreatedIdx: bn18(coin.txCreatedIdx)
4419
4455
  };
4420
4456
  default:
4421
4457
  return null;
@@ -4432,13 +4468,13 @@ Supported fuel-core version: ${supportedVersion}.`
4432
4468
  async getBlock(idOrHeight) {
4433
4469
  let variables;
4434
4470
  if (typeof idOrHeight === "number") {
4435
- variables = { height: bn17(idOrHeight).toString(10) };
4471
+ variables = { height: bn18(idOrHeight).toString(10) };
4436
4472
  } else if (idOrHeight === "latest") {
4437
4473
  variables = { height: (await this.getBlockNumber()).toString(10) };
4438
4474
  } else if (idOrHeight.length === 66) {
4439
4475
  variables = { blockId: idOrHeight };
4440
4476
  } else {
4441
- variables = { blockId: bn17(idOrHeight).toString(10) };
4477
+ variables = { blockId: bn18(idOrHeight).toString(10) };
4442
4478
  }
4443
4479
  const { block } = await this.operations.getBlock(variables);
4444
4480
  if (!block) {
@@ -4446,7 +4482,7 @@ Supported fuel-core version: ${supportedVersion}.`
4446
4482
  }
4447
4483
  return {
4448
4484
  id: block.id,
4449
- height: bn17(block.height),
4485
+ height: bn18(block.height),
4450
4486
  time: block.header.time,
4451
4487
  transactionIds: block.transactions.map((tx) => tx.id)
4452
4488
  };
@@ -4461,7 +4497,7 @@ Supported fuel-core version: ${supportedVersion}.`
4461
4497
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4462
4498
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4463
4499
  id: block.id,
4464
- height: bn17(block.height),
4500
+ height: bn18(block.height),
4465
4501
  time: block.header.time,
4466
4502
  transactionIds: block.transactions.map((tx) => tx.id)
4467
4503
  }));
@@ -4476,7 +4512,7 @@ Supported fuel-core version: ${supportedVersion}.`
4476
4512
  async getBlockWithTransactions(idOrHeight) {
4477
4513
  let variables;
4478
4514
  if (typeof idOrHeight === "number") {
4479
- variables = { blockHeight: bn17(idOrHeight).toString(10) };
4515
+ variables = { blockHeight: bn18(idOrHeight).toString(10) };
4480
4516
  } else if (idOrHeight === "latest") {
4481
4517
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4482
4518
  } else {
@@ -4488,7 +4524,7 @@ Supported fuel-core version: ${supportedVersion}.`
4488
4524
  }
4489
4525
  return {
4490
4526
  id: block.id,
4491
- height: bn17(block.height, 10),
4527
+ height: bn18(block.height, 10),
4492
4528
  time: block.header.time,
4493
4529
  transactionIds: block.transactions.map((tx) => tx.id),
4494
4530
  transactions: block.transactions.map(
@@ -4537,7 +4573,7 @@ Supported fuel-core version: ${supportedVersion}.`
4537
4573
  contract: Address2.fromAddressOrString(contractId).toB256(),
4538
4574
  asset: hexlify12(assetId)
4539
4575
  });
4540
- return bn17(contractBalance.amount, 10);
4576
+ return bn18(contractBalance.amount, 10);
4541
4577
  }
4542
4578
  /**
4543
4579
  * Returns the balance for the given owner for the given asset ID.
@@ -4551,7 +4587,7 @@ Supported fuel-core version: ${supportedVersion}.`
4551
4587
  owner: Address2.fromAddressOrString(owner).toB256(),
4552
4588
  assetId: hexlify12(assetId)
4553
4589
  });
4554
- return bn17(balance.amount, 10);
4590
+ return bn18(balance.amount, 10);
4555
4591
  }
4556
4592
  /**
4557
4593
  * Returns balances for the given owner.
@@ -4569,7 +4605,7 @@ Supported fuel-core version: ${supportedVersion}.`
4569
4605
  const balances = result.balances.edges.map((edge) => edge.node);
4570
4606
  return balances.map((balance) => ({
4571
4607
  assetId: balance.assetId,
4572
- amount: bn17(balance.amount)
4608
+ amount: bn18(balance.amount)
4573
4609
  }));
4574
4610
  }
4575
4611
  /**
@@ -4591,15 +4627,15 @@ Supported fuel-core version: ${supportedVersion}.`
4591
4627
  sender: message.sender,
4592
4628
  recipient: message.recipient,
4593
4629
  nonce: message.nonce,
4594
- amount: bn17(message.amount),
4630
+ amount: bn18(message.amount),
4595
4631
  data: message.data
4596
4632
  }),
4597
4633
  sender: Address2.fromAddressOrString(message.sender),
4598
4634
  recipient: Address2.fromAddressOrString(message.recipient),
4599
4635
  nonce: message.nonce,
4600
- amount: bn17(message.amount),
4636
+ amount: bn18(message.amount),
4601
4637
  data: InputMessageCoder.decodeData(message.data),
4602
- daHeight: bn17(message.daHeight)
4638
+ daHeight: bn18(message.daHeight)
4603
4639
  }));
4604
4640
  }
4605
4641
  /**
@@ -4652,19 +4688,19 @@ Supported fuel-core version: ${supportedVersion}.`
4652
4688
  } = result.messageProof;
4653
4689
  return {
4654
4690
  messageProof: {
4655
- proofIndex: bn17(messageProof.proofIndex),
4691
+ proofIndex: bn18(messageProof.proofIndex),
4656
4692
  proofSet: messageProof.proofSet
4657
4693
  },
4658
4694
  blockProof: {
4659
- proofIndex: bn17(blockProof.proofIndex),
4695
+ proofIndex: bn18(blockProof.proofIndex),
4660
4696
  proofSet: blockProof.proofSet
4661
4697
  },
4662
4698
  messageBlockHeader: {
4663
4699
  id: messageBlockHeader.id,
4664
- daHeight: bn17(messageBlockHeader.daHeight),
4700
+ daHeight: bn18(messageBlockHeader.daHeight),
4665
4701
  transactionsCount: Number(messageBlockHeader.transactionsCount),
4666
4702
  transactionsRoot: messageBlockHeader.transactionsRoot,
4667
- height: bn17(messageBlockHeader.height),
4703
+ height: bn18(messageBlockHeader.height),
4668
4704
  prevRoot: messageBlockHeader.prevRoot,
4669
4705
  time: messageBlockHeader.time,
4670
4706
  applicationHash: messageBlockHeader.applicationHash,
@@ -4676,10 +4712,10 @@ Supported fuel-core version: ${supportedVersion}.`
4676
4712
  },
4677
4713
  commitBlockHeader: {
4678
4714
  id: commitBlockHeader.id,
4679
- daHeight: bn17(commitBlockHeader.daHeight),
4715
+ daHeight: bn18(commitBlockHeader.daHeight),
4680
4716
  transactionsCount: Number(commitBlockHeader.transactionsCount),
4681
4717
  transactionsRoot: commitBlockHeader.transactionsRoot,
4682
- height: bn17(commitBlockHeader.height),
4718
+ height: bn18(commitBlockHeader.height),
4683
4719
  prevRoot: commitBlockHeader.prevRoot,
4684
4720
  time: commitBlockHeader.time,
4685
4721
  applicationHash: commitBlockHeader.applicationHash,
@@ -4692,19 +4728,19 @@ Supported fuel-core version: ${supportedVersion}.`
4692
4728
  sender: Address2.fromAddressOrString(sender),
4693
4729
  recipient: Address2.fromAddressOrString(recipient),
4694
4730
  nonce,
4695
- amount: bn17(amount),
4731
+ amount: bn18(amount),
4696
4732
  data
4697
4733
  };
4698
4734
  }
4699
4735
  async getLatestGasPrice() {
4700
4736
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4701
- return bn17(latestGasPrice.gasPrice);
4737
+ return bn18(latestGasPrice.gasPrice);
4702
4738
  }
4703
4739
  async estimateGasPrice(blockHorizon) {
4704
4740
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4705
4741
  blockHorizon: String(blockHorizon)
4706
4742
  });
4707
- return bn17(estimateGasPrice.gasPrice);
4743
+ return bn18(estimateGasPrice.gasPrice);
4708
4744
  }
4709
4745
  /**
4710
4746
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -4725,10 +4761,10 @@ Supported fuel-core version: ${supportedVersion}.`
4725
4761
  */
4726
4762
  async produceBlocks(amount, startTime) {
4727
4763
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4728
- blocksToProduce: bn17(amount).toString(10),
4764
+ blocksToProduce: bn18(amount).toString(10),
4729
4765
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4730
4766
  });
4731
- return bn17(latestBlockHeight);
4767
+ return bn18(latestBlockHeight);
4732
4768
  }
4733
4769
  // eslint-disable-next-line @typescript-eslint/require-await
4734
4770
  async getTransactionResponse(transactionId) {
@@ -4774,7 +4810,7 @@ __publicField(Provider, "nodeInfoCache", {});
4774
4810
 
4775
4811
  // src/providers/transaction-summary/get-transaction-summary.ts
4776
4812
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4777
- import { bn as bn18 } from "@fuel-ts/math";
4813
+ import { bn as bn19 } from "@fuel-ts/math";
4778
4814
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4779
4815
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4780
4816
 
@@ -4849,22 +4885,6 @@ var rawAssets = [
4849
4885
  ];
4850
4886
  var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
4851
4887
 
4852
- // src/providers/transaction-request/helpers.ts
4853
- import { bn as bn19 } from "@fuel-ts/math";
4854
- import { InputType as InputType8 } from "@fuel-ts/transactions";
4855
- var isRequestInputCoin = (input) => input.type === InputType8.Coin;
4856
- var isRequestInputMessage = (input) => input.type === InputType8.Message;
4857
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
4858
- var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
4859
- if (isRequestInputCoin(input) && input.assetId === assetId) {
4860
- return acc.add(input.amount);
4861
- }
4862
- if (isRequestInputMessage(input) && assetId === baseAsset) {
4863
- return acc.add(input.amount);
4864
- }
4865
- return acc;
4866
- }, bn19(0));
4867
-
4868
4888
  // src/utils/formatTransferToContractScriptData.ts
4869
4889
  import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
4870
4890
  import { BN as BN2 } from "@fuel-ts/math";
@@ -5102,7 +5122,7 @@ var Account = class extends AbstractAccount {
5102
5122
  while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
5103
5123
  const resources = await this.getResourcesToSpend(
5104
5124
  missingQuantities,
5105
- cacheTxInputsFromOwner(request.inputs, this.address)
5125
+ cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
5106
5126
  );
5107
5127
  request.addResources(resources);
5108
5128
  request.shiftPredicateData();
@@ -8412,16 +8432,18 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8412
8432
 
8413
8433
  // src/test-utils/seedTestWallet.ts
8414
8434
  import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
8415
- var seedTestWallet = async (wallet, quantities) => {
8416
- const genesisWallet = new WalletUnlocked(
8417
- process.env.GENESIS_SECRET || randomBytes5(32),
8418
- wallet.provider
8419
- );
8435
+ var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
8436
+ const accountsToBeFunded = Array.isArray(wallet) ? wallet : [wallet];
8437
+ const [{ provider }] = accountsToBeFunded;
8438
+ const genesisWallet = new WalletUnlocked(process.env.GENESIS_SECRET || randomBytes5(32), provider);
8420
8439
  const request = new ScriptTransactionRequest();
8421
- quantities.forEach((quantity) => {
8422
- const { amount, assetId } = coinQuantityfy(quantity);
8423
- request.addCoinOutput(wallet.address, amount, assetId);
8424
- });
8440
+ quantities.map(coinQuantityfy).forEach(
8441
+ ({ amount, assetId }) => accountsToBeFunded.forEach(({ address }) => {
8442
+ for (let i = 0; i < utxosAmount; i++) {
8443
+ request.addCoinOutput(address, amount.div(utxosAmount), assetId);
8444
+ }
8445
+ })
8446
+ );
8425
8447
  const txCost = await genesisWallet.provider.getTransactionCost(request);
8426
8448
  request.gasLimit = txCost.gasUsed;
8427
8449
  request.maxFee = txCost.maxFee;
@@ -8441,7 +8463,7 @@ var generateTestWallet = async (provider, quantities) => {
8441
8463
  // src/test-utils/launchNode.ts
8442
8464
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
8443
8465
  import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
8444
- import { defaultConsensusKey, hexlify as hexlify18, defaultSnapshotConfigs } from "@fuel-ts/utils";
8466
+ import { defaultSnapshotConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8445
8467
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
8446
8468
  import { spawn } from "child_process";
8447
8469
  import { randomUUID } from "crypto";
@@ -8481,40 +8503,6 @@ var killNode = (params) => {
8481
8503
  }
8482
8504
  }
8483
8505
  };
8484
- function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
8485
- const defaultCoins = defaultSnapshotConfigs.stateConfig.coins.map((coin) => ({
8486
- ...coin,
8487
- amount: "18446744073709551615"
8488
- }));
8489
- const defaultMessages = defaultSnapshotConfigs.stateConfig.messages.map((message) => ({
8490
- ...message,
8491
- amount: "18446744073709551615"
8492
- }));
8493
- const coins = defaultCoins.concat(stateConfig.coins.map((coin) => ({ ...coin, amount: coin.amount.toString() }))).filter((coin, index, self) => self.findIndex((c) => c.tx_id === coin.tx_id) === index);
8494
- const messages = defaultMessages.concat(stateConfig.messages.map((msg) => ({ ...msg, amount: msg.amount.toString() }))).filter((msg, index, self) => self.findIndex((m) => m.nonce === msg.nonce) === index);
8495
- if (!process.env.GENESIS_SECRET) {
8496
- const pk = Signer.generatePrivateKey();
8497
- const signer = new Signer(pk);
8498
- process.env.GENESIS_SECRET = hexlify18(pk);
8499
- coins.push({
8500
- tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
8501
- owner: signer.address.toHexString(),
8502
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8503
- amount: "18446744073709551615",
8504
- asset_id: chainConfig.consensus_parameters.V1.base_asset_id,
8505
- output_index: 0,
8506
- tx_pointer_block_height: 0,
8507
- tx_pointer_tx_idx: 0
8508
- });
8509
- }
8510
- const json = JSON.stringify({
8511
- ...stateConfig,
8512
- coins,
8513
- messages
8514
- });
8515
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8516
- return json.replace(regexMakeNumber, "$1$2");
8517
- }
8518
8506
  var launchNode = async ({
8519
8507
  ip,
8520
8508
  port,
@@ -8522,8 +8510,7 @@ var launchNode = async ({
8522
8510
  useSystemFuelCore = false,
8523
8511
  loggingEnabled = true,
8524
8512
  debugEnabled = false,
8525
- basePath,
8526
- snapshotConfig = defaultSnapshotConfigs
8513
+ basePath
8527
8514
  }) => (
8528
8515
  // eslint-disable-next-line no-async-promise-executor
8529
8516
  new Promise(async (resolve, reject) => {
@@ -8552,23 +8539,56 @@ var launchNode = async ({
8552
8539
  let snapshotDirToUse;
8553
8540
  const prefix = basePath || os.tmpdir();
8554
8541
  const suffix = basePath ? "" : randomUUID();
8555
- const tempDir = path.join(prefix, ".fuels", suffix, "snapshotDir");
8542
+ const tempDirPath = path.join(prefix, ".fuels", suffix, "snapshotDir");
8556
8543
  if (snapshotDir) {
8557
8544
  snapshotDirToUse = snapshotDir;
8558
8545
  } else {
8559
- if (!existsSync(tempDir)) {
8560
- mkdirSync(tempDir, { recursive: true });
8546
+ if (!existsSync(tempDirPath)) {
8547
+ mkdirSync(tempDirPath, { recursive: true });
8561
8548
  }
8562
- const { metadata } = snapshotConfig;
8563
- const metadataPath = path.join(tempDir, "metadata.json");
8564
- const chainConfigPath = path.join(tempDir, metadata.chain_config);
8565
- const stateConfigPath = path.join(tempDir, metadata.table_encoding.Json.filepath);
8566
- const stateTransitionPath = path.join(tempDir, "state_transition_bytecode.wasm");
8567
- writeFileSync(chainConfigPath, JSON.stringify(snapshotConfig.chainConfig), "utf8");
8568
- writeFileSync(stateConfigPath, getFinalStateConfigJSON(snapshotConfig), "utf8");
8569
- writeFileSync(metadataPath, JSON.stringify(metadata), "utf8");
8570
- writeFileSync(stateTransitionPath, JSON.stringify(""));
8571
- snapshotDirToUse = tempDir;
8549
+ let { stateConfigJson } = defaultSnapshotConfigs;
8550
+ const { chainConfigJson, metadataJson } = defaultSnapshotConfigs;
8551
+ stateConfigJson = {
8552
+ ...stateConfigJson,
8553
+ coins: [
8554
+ ...stateConfigJson.coins.map((coin) => ({
8555
+ ...coin,
8556
+ amount: "18446744073709551615"
8557
+ }))
8558
+ ],
8559
+ messages: stateConfigJson.messages.map((message) => ({
8560
+ ...message,
8561
+ amount: "18446744073709551615"
8562
+ }))
8563
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8564
+ };
8565
+ if (!process.env.GENESIS_SECRET) {
8566
+ const pk = Signer.generatePrivateKey();
8567
+ const signer = new Signer(pk);
8568
+ process.env.GENESIS_SECRET = hexlify18(pk);
8569
+ stateConfigJson.coins.push({
8570
+ tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
8571
+ owner: signer.address.toHexString(),
8572
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8573
+ amount: "18446744073709551615",
8574
+ asset_id: chainConfigJson.consensus_parameters.V1.base_asset_id,
8575
+ output_index: 0,
8576
+ tx_pointer_block_height: 0,
8577
+ tx_pointer_tx_idx: 0
8578
+ });
8579
+ }
8580
+ let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8581
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8582
+ fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8583
+ const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
8584
+ const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
8585
+ const metadataWritePath = path.join(tempDirPath, "metadata.json");
8586
+ const stateTransitionWritePath = path.join(tempDirPath, "state_transition_bytecode.wasm");
8587
+ writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8588
+ writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8589
+ writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8590
+ writeFileSync(stateTransitionWritePath, JSON.stringify(""));
8591
+ snapshotDirToUse = tempDirPath;
8572
8592
  }
8573
8593
  const child = spawn(
8574
8594
  command,
@@ -8576,7 +8596,7 @@ var launchNode = async ({
8576
8596
  "run",
8577
8597
  ["--ip", ipToUse],
8578
8598
  ["--port", portToUse],
8579
- useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDir],
8599
+ useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8580
8600
  ["--min-gas-price", "1"],
8581
8601
  poaInstant ? ["--poa-instant", "true"] : [],
8582
8602
  ["--consensus-key", consensusKey],
@@ -8598,28 +8618,23 @@ var launchNode = async ({
8598
8618
  }
8599
8619
  const cleanupConfig = {
8600
8620
  child,
8601
- configPath: tempDir,
8621
+ configPath: tempDirPath,
8602
8622
  killFn: treeKill,
8603
8623
  state: {
8604
8624
  isDead: false
8605
8625
  }
8606
8626
  };
8607
8627
  child.stderr.on("data", (chunk) => {
8608
- const text = typeof chunk === "string" ? chunk : chunk.toString();
8609
- if (text.indexOf(graphQLStartSubstring) !== -1) {
8610
- const rows = text.split("\n");
8611
- const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
8612
- const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
8628
+ if (chunk.indexOf(graphQLStartSubstring) !== -1) {
8613
8629
  resolve({
8614
8630
  cleanup: () => killNode(cleanupConfig),
8615
- ip: realIp,
8616
- port: realPort,
8617
- url: `http://${realIp}:${realPort}/v1/graphql`,
8631
+ ip: ipToUse,
8632
+ port: portToUse,
8618
8633
  snapshotDir: snapshotDirToUse
8619
8634
  });
8620
8635
  }
8621
- if (/error/i.test(text)) {
8622
- reject(text.toString());
8636
+ if (/error/i.test(chunk)) {
8637
+ reject(chunk.toString());
8623
8638
  }
8624
8639
  });
8625
8640
  process.on("exit", () => killNode(cleanupConfig));
@@ -8652,237 +8667,11 @@ var launchNodeAndGetWallets = async ({
8652
8667
  };
8653
8668
  return { wallets, stop: cleanup, provider };
8654
8669
  };
8655
-
8656
- // src/test-utils/setup-test-provider-and-wallets.ts
8657
- import { defaultSnapshotConfigs as defaultSnapshotConfigs3 } from "@fuel-ts/utils";
8658
- import { mergeDeepRight } from "ramda";
8659
-
8660
- // src/test-utils/asset-id.ts
8661
- import { randomBytes as randomBytes7 } from "@fuel-ts/crypto";
8662
- import { hexlify as hexlify19 } from "@fuel-ts/utils";
8663
- var _AssetId = class {
8664
- constructor(value) {
8665
- this.value = value;
8666
- }
8667
- static random() {
8668
- return new _AssetId(hexlify19(randomBytes7(32)));
8669
- }
8670
- };
8671
- var AssetId = _AssetId;
8672
- __publicField(AssetId, "A", new _AssetId(
8673
- "0x0101010101010101010101010101010101010101010101010101010101010101"
8674
- ));
8675
- __publicField(AssetId, "B", new _AssetId(
8676
- "0x0202020202020202020202020202020202020202020202020202020202020202"
8677
- ));
8678
-
8679
- // src/test-utils/wallet-config.ts
8680
- import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
8681
- import { FuelError as FuelError20 } from "@fuel-ts/errors";
8682
- import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify20 } from "@fuel-ts/utils";
8683
- var WalletConfig = class {
8684
- initialState;
8685
- options;
8686
- wallets;
8687
- generateWallets = () => {
8688
- const generatedWallets = [];
8689
- for (let index = 1; index <= this.options.count; index++) {
8690
- generatedWallets.push(new WalletUnlocked(randomBytes8(32)));
8691
- }
8692
- return generatedWallets;
8693
- };
8694
- constructor(baseAssetId, config) {
8695
- const BASE_ASSET_ID = baseAssetId.startsWith("0x") ? baseAssetId : `0x${baseAssetId}`;
8696
- WalletConfig.guard(config);
8697
- this.options = config;
8698
- const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
8699
- this.wallets = this.generateWallets();
8700
- this.initialState = {
8701
- messages: WalletConfig.createMessages(this.wallets, messages),
8702
- coins: WalletConfig.createCoins(
8703
- this.wallets,
8704
- BASE_ASSET_ID,
8705
- assets2,
8706
- coinsPerAsset,
8707
- amountPerCoin
8708
- )
8709
- };
8710
- }
8711
- apply(snapshotConfig) {
8712
- return {
8713
- ...snapshotConfig,
8714
- stateConfig: {
8715
- ...snapshotConfig?.stateConfig ?? defaultSnapshotConfigs2.stateConfig,
8716
- coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
8717
- messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
8718
- }
8719
- };
8720
- }
8721
- static createMessages(wallets, messages) {
8722
- return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
8723
- }
8724
- static createCoins(wallets, baseAssetId, assets2, coinsPerAsset, amountPerCoin) {
8725
- const coins = [];
8726
- let assetIds = [baseAssetId];
8727
- if (Array.isArray(assets2)) {
8728
- assetIds = assetIds.concat(assets2.map((a) => a.value));
8729
- } else {
8730
- for (let index = 0; index < assets2 - 1; index++) {
8731
- assetIds.push(AssetId.random().value);
8732
- }
8733
- }
8734
- wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
8735
- assetIds.forEach((assetId) => {
8736
- for (let index = 0; index < coinsPerAsset; index++) {
8737
- coins.push({
8738
- amount: amountPerCoin,
8739
- asset_id: assetId,
8740
- owner: walletAddress,
8741
- tx_pointer_block_height: 0,
8742
- tx_pointer_tx_idx: 0,
8743
- output_index: 0,
8744
- tx_id: hexlify20(randomBytes8(32))
8745
- });
8746
- }
8747
- });
8748
- });
8749
- return coins;
8750
- }
8751
- static guard({
8752
- count: wallets,
8753
- assets: assets2,
8754
- coinsPerAsset,
8755
- amountPerCoin
8756
- }) {
8757
- if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
8758
- throw new FuelError20(
8759
- FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8760
- "Number of wallets must be greater than zero."
8761
- );
8762
- }
8763
- if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
8764
- throw new FuelError20(
8765
- FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8766
- "Number of assets per wallet must be greater than zero."
8767
- );
8768
- }
8769
- if (coinsPerAsset <= 0) {
8770
- throw new FuelError20(
8771
- FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8772
- "Number of coins per asset must be greater than zero."
8773
- );
8774
- }
8775
- if (amountPerCoin <= 0) {
8776
- throw new FuelError20(
8777
- FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8778
- "Amount per coin must be greater than zero."
8779
- );
8780
- }
8781
- }
8782
- };
8783
-
8784
- // src/test-utils/setup-test-provider-and-wallets.ts
8785
- var defaultWalletConfigOptions = {
8786
- count: 2,
8787
- assets: [AssetId.A, AssetId.B],
8788
- coinsPerAsset: 1,
8789
- amountPerCoin: 1e10,
8790
- messages: []
8791
- };
8792
- async function setupTestProviderAndWallets({
8793
- walletConfig: walletConfigOptions = {},
8794
- providerOptions,
8795
- nodeOptions = {}
8796
- } = {}) {
8797
- Symbol.dispose ??= Symbol("Symbol.dispose");
8798
- const walletConfig = new WalletConfig(
8799
- nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ?? defaultSnapshotConfigs3.chainConfig.consensus_parameters.V1.base_asset_id,
8800
- {
8801
- ...defaultWalletConfigOptions,
8802
- ...walletConfigOptions
8803
- }
8804
- );
8805
- const { cleanup, url } = await launchNode({
8806
- loggingEnabled: false,
8807
- ...nodeOptions,
8808
- snapshotConfig: mergeDeepRight(
8809
- defaultSnapshotConfigs3,
8810
- walletConfig.apply(nodeOptions?.snapshotConfig)
8811
- ),
8812
- port: "0"
8813
- });
8814
- let provider;
8815
- try {
8816
- provider = await Provider.create(url, providerOptions);
8817
- } catch (err) {
8818
- cleanup();
8819
- throw err;
8820
- }
8821
- const wallets = walletConfig.wallets;
8822
- wallets.forEach((wallet) => {
8823
- wallet.connect(provider);
8824
- });
8825
- return {
8826
- provider,
8827
- wallets,
8828
- cleanup,
8829
- [Symbol.dispose]: cleanup
8830
- };
8831
- }
8832
-
8833
- // src/test-utils/test-message.ts
8834
- import { Address as Address6 } from "@fuel-ts/address";
8835
- import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
8836
- import { bn as bn22 } from "@fuel-ts/math";
8837
- import { hexlify as hexlify21 } from "@fuel-ts/utils";
8838
- var TestMessage = class {
8839
- sender;
8840
- recipient;
8841
- nonce;
8842
- amount;
8843
- data;
8844
- da_height;
8845
- /**
8846
- * A helper class to create messages for testing purposes.
8847
- *
8848
- * Used in tandem with `WalletConfig`.
8849
- * It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
8850
- */
8851
- constructor({
8852
- sender = Address6.fromRandom(),
8853
- recipient = Address6.fromRandom(),
8854
- nonce = hexlify21(randomBytes9(32)),
8855
- amount = 1e6,
8856
- data = "02",
8857
- da_height = 0
8858
- } = {}) {
8859
- this.sender = sender;
8860
- this.recipient = recipient;
8861
- this.nonce = nonce;
8862
- this.amount = amount;
8863
- this.data = data;
8864
- this.da_height = da_height;
8865
- }
8866
- toChainMessage(recipient) {
8867
- return {
8868
- sender: this.sender.toB256(),
8869
- recipient: recipient?.toB256() ?? this.recipient.toB256(),
8870
- nonce: this.nonce,
8871
- amount: bn22(this.amount).toNumber(),
8872
- data: this.data,
8873
- da_height: this.da_height
8874
- };
8875
- }
8876
- };
8877
8670
  export {
8878
- AssetId,
8879
- TestMessage,
8880
- WalletConfig,
8881
8671
  generateTestWallet,
8882
8672
  killNode,
8883
8673
  launchNode,
8884
8674
  launchNodeAndGetWallets,
8885
- seedTestWallet,
8886
- setupTestProviderAndWallets
8675
+ seedTestWallet
8887
8676
  };
8888
8677
  //# sourceMappingURL=test-utils.mjs.map