@fuel-ts/account 0.0.0-rc-2238-20240514123903 → 0.0.0-rc-1356-20240514125020

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 (42) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/index.global.js +1140 -408
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +254 -234
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +145 -118
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/predicate/predicate.d.ts.map +1 -1
  9. package/dist/providers/coin.d.ts +1 -0
  10. package/dist/providers/coin.d.ts.map +1 -1
  11. package/dist/providers/message.d.ts +1 -0
  12. package/dist/providers/message.d.ts.map +1 -1
  13. package/dist/providers/transaction-request/input.d.ts +2 -0
  14. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  15. package/dist/providers/transaction-request/transaction-request.d.ts +1 -0
  16. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  17. package/dist/providers/transaction-summary/call.d.ts +1 -1
  18. package/dist/providers/transaction-summary/call.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 +0 -1
  21. package/dist/providers/utils/index.d.ts.map +1 -1
  22. package/dist/test-utils/asset-id.d.ts +8 -0
  23. package/dist/test-utils/asset-id.d.ts.map +1 -0
  24. package/dist/test-utils/index.d.ts +4 -0
  25. package/dist/test-utils/index.d.ts.map +1 -1
  26. package/dist/test-utils/launchNode.d.ts +8 -1
  27. package/dist/test-utils/launchNode.d.ts.map +1 -1
  28. package/dist/test-utils/setup-test-provider-and-wallets.d.ts +33 -0
  29. package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -0
  30. package/dist/test-utils/test-message.d.ts +28 -0
  31. package/dist/test-utils/test-message.d.ts.map +1 -0
  32. package/dist/test-utils/wallet-config.d.ts +49 -0
  33. package/dist/test-utils/wallet-config.d.ts.map +1 -0
  34. package/dist/test-utils.global.js +1465 -418
  35. package/dist/test-utils.global.js.map +1 -1
  36. package/dist/test-utils.js +523 -272
  37. package/dist/test-utils.js.map +1 -1
  38. package/dist/test-utils.mjs +413 -166
  39. package/dist/test-utils.mjs.map +1 -1
  40. package/package.json +16 -15
  41. package/dist/providers/utils/sleep.d.ts +0 -3
  42. package/dist/providers/utils/sleep.d.ts.map +0 -1
@@ -48,24 +48,28 @@ var __privateMethod = (obj, member, method) => {
48
48
  // src/test-utils/index.ts
49
49
  var test_utils_exports = {};
50
50
  __export(test_utils_exports, {
51
+ AssetId: () => AssetId,
52
+ TestMessage: () => TestMessage,
53
+ WalletConfig: () => WalletConfig,
51
54
  generateTestWallet: () => generateTestWallet,
52
55
  killNode: () => killNode,
53
56
  launchNode: () => launchNode,
54
57
  launchNodeAndGetWallets: () => launchNodeAndGetWallets,
55
- seedTestWallet: () => seedTestWallet
58
+ seedTestWallet: () => seedTestWallet,
59
+ setupTestProviderAndWallets: () => setupTestProviderAndWallets
56
60
  });
57
61
  module.exports = __toCommonJS(test_utils_exports);
58
62
 
59
63
  // src/wallet/base-wallet-unlocked.ts
60
64
  var import_hasher3 = require("@fuel-ts/hasher");
61
- var import_utils31 = require("@fuel-ts/utils");
65
+ var import_utils32 = require("@fuel-ts/utils");
62
66
 
63
67
  // src/account.ts
64
68
  var import_address4 = require("@fuel-ts/address");
65
69
  var import_errors16 = require("@fuel-ts/errors");
66
70
  var import_interfaces = require("@fuel-ts/interfaces");
67
- var import_math20 = require("@fuel-ts/math");
68
- var import_utils28 = require("@fuel-ts/utils");
71
+ var import_math21 = require("@fuel-ts/math");
72
+ var import_utils29 = require("@fuel-ts/utils");
69
73
  var import_ramda4 = require("ramda");
70
74
 
71
75
  // src/providers/coin-quantity.ts
@@ -106,11 +110,11 @@ var addAmountToCoinQuantities = (params) => {
106
110
  // src/providers/provider.ts
107
111
  var import_address3 = require("@fuel-ts/address");
108
112
  var import_errors14 = require("@fuel-ts/errors");
109
- var import_math17 = require("@fuel-ts/math");
113
+ var import_math18 = require("@fuel-ts/math");
110
114
  var import_transactions20 = require("@fuel-ts/transactions");
111
- var import_utils22 = require("@fuel-ts/utils");
115
+ var import_utils23 = require("@fuel-ts/utils");
112
116
  var import_versions = require("@fuel-ts/versions");
113
- var import_utils23 = require("@noble/curves/abstract/utils");
117
+ var import_utils24 = require("@noble/curves/abstract/utils");
114
118
  var import_graphql_request = require("graphql-request");
115
119
  var import_ramda3 = require("ramda");
116
120
 
@@ -1667,15 +1671,6 @@ function normalizeJSON(root) {
1667
1671
  return normalize((0, import_ramda.clone)(root));
1668
1672
  }
1669
1673
 
1670
- // src/providers/utils/sleep.ts
1671
- function sleep(time) {
1672
- return new Promise((resolve) => {
1673
- setTimeout(() => {
1674
- resolve(true);
1675
- }, time);
1676
- });
1677
- }
1678
-
1679
1674
  // src/providers/utils/extract-tx-error.ts
1680
1675
  var import_errors7 = require("@fuel-ts/errors");
1681
1676
  var import_math6 = require("@fuel-ts/math");
@@ -2296,6 +2291,15 @@ var BaseTransactionRequest = class {
2296
2291
  }
2297
2292
  });
2298
2293
  }
2294
+ shiftPredicateData() {
2295
+ this.inputs.forEach((input) => {
2296
+ if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
2297
+ input.predicateData = input.padPredicateData(
2298
+ BaseTransactionRequest.getPolicyMeta(this).policies.length
2299
+ );
2300
+ }
2301
+ });
2302
+ }
2299
2303
  };
2300
2304
 
2301
2305
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2718,12 +2722,12 @@ var transactionRequestify = (obj) => {
2718
2722
 
2719
2723
  // src/providers/transaction-response/transaction-response.ts
2720
2724
  var import_errors13 = require("@fuel-ts/errors");
2721
- var import_math16 = require("@fuel-ts/math");
2725
+ var import_math17 = require("@fuel-ts/math");
2722
2726
  var import_transactions19 = require("@fuel-ts/transactions");
2723
2727
  var import_utils20 = require("@fuel-ts/utils");
2724
2728
 
2725
2729
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2726
- var import_math15 = require("@fuel-ts/math");
2730
+ var import_math16 = require("@fuel-ts/math");
2727
2731
  var import_transactions17 = require("@fuel-ts/transactions");
2728
2732
  var import_utils18 = require("@fuel-ts/utils");
2729
2733
 
@@ -2800,32 +2804,43 @@ var calculateTXFeeForSummary = (params) => {
2800
2804
  // src/providers/transaction-summary/operations.ts
2801
2805
  var import_configs10 = require("@fuel-ts/address/configs");
2802
2806
  var import_errors11 = require("@fuel-ts/errors");
2803
- var import_math13 = require("@fuel-ts/math");
2807
+ var import_math14 = require("@fuel-ts/math");
2804
2808
  var import_transactions15 = require("@fuel-ts/transactions");
2805
2809
 
2806
2810
  // src/providers/transaction-summary/call.ts
2807
2811
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
2808
- var getFunctionCall = ({ abi, receipt }) => {
2812
+ var import_math13 = require("@fuel-ts/math");
2813
+ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2809
2814
  const abiInterface = new import_abi_coder4.Interface(abi);
2810
2815
  const callFunctionSelector = receipt.param1.toHex(8);
2811
2816
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2812
2817
  const inputs = functionFragment.jsonFn.inputs;
2813
- const encodedArgs = receipt.param2.toHex();
2818
+ let encodedArgs;
2819
+ if (functionFragment.isInputDataPointer) {
2820
+ if (rawPayload) {
2821
+ const argsOffset = (0, import_math13.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2822
+ encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2823
+ }
2824
+ } else {
2825
+ encodedArgs = receipt.param2.toHex();
2826
+ }
2814
2827
  let argumentsProvided;
2815
- const data = functionFragment.decodeArguments(encodedArgs);
2816
- if (data) {
2817
- argumentsProvided = inputs.reduce((prev, input, index) => {
2818
- const value = data[index];
2819
- const name = input.name;
2820
- if (name) {
2821
- return {
2822
- ...prev,
2823
- // reparse to remove bn
2824
- [name]: JSON.parse(JSON.stringify(value))
2825
- };
2826
- }
2827
- return prev;
2828
- }, {});
2828
+ if (encodedArgs) {
2829
+ const data = functionFragment.decodeArguments(encodedArgs);
2830
+ if (data) {
2831
+ argumentsProvided = inputs.reduce((prev, input, index) => {
2832
+ const value = data[index];
2833
+ const name = input.name;
2834
+ if (name) {
2835
+ return {
2836
+ ...prev,
2837
+ // reparse to remove bn
2838
+ [name]: JSON.parse(JSON.stringify(value))
2839
+ };
2840
+ }
2841
+ return prev;
2842
+ }, {});
2843
+ }
2829
2844
  }
2830
2845
  const call = {
2831
2846
  functionSignature: functionFragment.signature,
@@ -2965,7 +2980,7 @@ var mergeAssets = (op1, op2) => {
2965
2980
  if (!matchingAsset) {
2966
2981
  return asset1;
2967
2982
  }
2968
- const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
2983
+ const mergedAmount = (0, import_math14.bn)(asset1.amount).add(matchingAsset.amount);
2969
2984
  return { ...asset1, amount: mergedAmount };
2970
2985
  });
2971
2986
  return mergedAssets.concat(filteredAssets);
@@ -3288,7 +3303,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3288
3303
 
3289
3304
  // src/providers/transaction-summary/status.ts
3290
3305
  var import_errors12 = require("@fuel-ts/errors");
3291
- var import_math14 = require("@fuel-ts/math");
3306
+ var import_math15 = require("@fuel-ts/math");
3292
3307
  var getTransactionStatusName = (gqlStatus) => {
3293
3308
  switch (gqlStatus) {
3294
3309
  case "FailureStatus":
@@ -3322,15 +3337,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3322
3337
  time = gqlTransactionStatus.time;
3323
3338
  blockId = gqlTransactionStatus.block.id;
3324
3339
  isStatusSuccess = true;
3325
- totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3326
- totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3340
+ totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
3341
+ totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
3327
3342
  break;
3328
3343
  case "FailureStatus":
3329
3344
  time = gqlTransactionStatus.time;
3330
3345
  blockId = gqlTransactionStatus.block.id;
3331
3346
  isStatusFailure = true;
3332
- totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3333
- totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3347
+ totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
3348
+ totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
3334
3349
  break;
3335
3350
  case "SubmittedStatus":
3336
3351
  time = gqlTransactionStatus.time;
@@ -3380,7 +3395,7 @@ function assembleTransactionSummary(params) {
3380
3395
  maxInputs
3381
3396
  });
3382
3397
  const typeName = getTransactionTypeName(transaction.type);
3383
- const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
3398
+ const tip = (0, import_math16.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
3384
3399
  const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3385
3400
  const fee = calculateTXFeeForSummary({
3386
3401
  totalFee,
@@ -3451,7 +3466,7 @@ var TransactionResponse = class {
3451
3466
  /** Current provider */
3452
3467
  provider;
3453
3468
  /** Gas used on the transaction */
3454
- gasUsed = (0, import_math16.bn)(0);
3469
+ gasUsed = (0, import_math17.bn)(0);
3455
3470
  /** The graphql Transaction with receipts object. */
3456
3471
  gqlTransaction;
3457
3472
  abis;
@@ -3619,6 +3634,7 @@ var TransactionResponse = class {
3619
3634
  };
3620
3635
 
3621
3636
  // src/providers/utils/auto-retry-fetch.ts
3637
+ var import_utils22 = require("@fuel-ts/utils");
3622
3638
  function getWaitDelay(options, retryAttemptNum) {
3623
3639
  const duration = options.baseDelay ?? 150;
3624
3640
  switch (options.backoff) {
@@ -3648,7 +3664,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
3648
3664
  throw error;
3649
3665
  }
3650
3666
  const delay = getWaitDelay(options, retryNum);
3651
- await sleep(delay);
3667
+ await (0, import_utils22.sleep)(delay);
3652
3668
  return autoRetryFetch(fetchFn, options, retryNum)(...args);
3653
3669
  }
3654
3670
  };
@@ -3685,47 +3701,47 @@ var processGqlChain = (chain) => {
3685
3701
  } = consensusParameters;
3686
3702
  return {
3687
3703
  name,
3688
- baseChainHeight: (0, import_math17.bn)(daHeight),
3704
+ baseChainHeight: (0, import_math18.bn)(daHeight),
3689
3705
  consensusParameters: {
3690
3706
  version,
3691
- chainId: (0, import_math17.bn)(chainId),
3707
+ chainId: (0, import_math18.bn)(chainId),
3692
3708
  baseAssetId,
3693
3709
  feeParameters: {
3694
3710
  version: feeParams.version,
3695
- gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
3696
- gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
3711
+ gasPerByte: (0, import_math18.bn)(feeParams.gasPerByte),
3712
+ gasPriceFactor: (0, import_math18.bn)(feeParams.gasPriceFactor)
3697
3713
  },
3698
3714
  contractParameters: {
3699
3715
  version: contractParams.version,
3700
- contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
3701
- maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
3716
+ contractMaxSize: (0, import_math18.bn)(contractParams.contractMaxSize),
3717
+ maxStorageSlots: (0, import_math18.bn)(contractParams.maxStorageSlots)
3702
3718
  },
3703
3719
  txParameters: {
3704
3720
  version: txParams.version,
3705
- maxInputs: (0, import_math17.bn)(txParams.maxInputs),
3706
- maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
3707
- maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
3708
- maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
3709
- maxSize: (0, import_math17.bn)(txParams.maxSize),
3710
- maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
3721
+ maxInputs: (0, import_math18.bn)(txParams.maxInputs),
3722
+ maxOutputs: (0, import_math18.bn)(txParams.maxOutputs),
3723
+ maxWitnesses: (0, import_math18.bn)(txParams.maxWitnesses),
3724
+ maxGasPerTx: (0, import_math18.bn)(txParams.maxGasPerTx),
3725
+ maxSize: (0, import_math18.bn)(txParams.maxSize),
3726
+ maxBytecodeSubsections: (0, import_math18.bn)(txParams.maxBytecodeSubsections)
3711
3727
  },
3712
3728
  predicateParameters: {
3713
3729
  version: predicateParams.version,
3714
- maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
3715
- maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
3716
- maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
3717
- maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
3730
+ maxPredicateLength: (0, import_math18.bn)(predicateParams.maxPredicateLength),
3731
+ maxPredicateDataLength: (0, import_math18.bn)(predicateParams.maxPredicateDataLength),
3732
+ maxGasPerPredicate: (0, import_math18.bn)(predicateParams.maxGasPerPredicate),
3733
+ maxMessageDataLength: (0, import_math18.bn)(predicateParams.maxMessageDataLength)
3718
3734
  },
3719
3735
  scriptParameters: {
3720
3736
  version: scriptParams.version,
3721
- maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
3722
- maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
3737
+ maxScriptLength: (0, import_math18.bn)(scriptParams.maxScriptLength),
3738
+ maxScriptDataLength: (0, import_math18.bn)(scriptParams.maxScriptDataLength)
3723
3739
  },
3724
3740
  gasCosts
3725
3741
  },
3726
3742
  latestBlock: {
3727
3743
  id: latestBlock.id,
3728
- height: (0, import_math17.bn)(latestBlock.height),
3744
+ height: (0, import_math18.bn)(latestBlock.height),
3729
3745
  time: latestBlock.header.time,
3730
3746
  transactions: latestBlock.transactions.map((i) => ({
3731
3747
  id: i.id
@@ -3921,7 +3937,7 @@ Supported fuel-core version: ${supportedVersion}.`
3921
3937
  */
3922
3938
  async getBlockNumber() {
3923
3939
  const { chain } = await this.operations.getChain();
3924
- return (0, import_math17.bn)(chain.latestBlock.height, 10);
3940
+ return (0, import_math18.bn)(chain.latestBlock.height, 10);
3925
3941
  }
3926
3942
  /**
3927
3943
  * Returns the chain information.
@@ -3931,8 +3947,8 @@ Supported fuel-core version: ${supportedVersion}.`
3931
3947
  async fetchNode() {
3932
3948
  const { nodeInfo } = await this.operations.getNodeInfo();
3933
3949
  const processedNodeInfo = {
3934
- maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
3935
- maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
3950
+ maxDepth: (0, import_math18.bn)(nodeInfo.maxDepth),
3951
+ maxTx: (0, import_math18.bn)(nodeInfo.maxTx),
3936
3952
  nodeVersion: nodeInfo.nodeVersion,
3937
3953
  utxoValidation: nodeInfo.utxoValidation,
3938
3954
  vmBacktrace: nodeInfo.vmBacktrace
@@ -3988,7 +4004,7 @@ Supported fuel-core version: ${supportedVersion}.`
3988
4004
  if (estimateTxDependencies) {
3989
4005
  await this.estimateTxDependencies(transactionRequest);
3990
4006
  }
3991
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4007
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3992
4008
  let abis;
3993
4009
  if (transactionRequest.type === import_transactions20.TransactionType.Script) {
3994
4010
  abis = transactionRequest.abis;
@@ -4031,7 +4047,7 @@ Supported fuel-core version: ${supportedVersion}.`
4031
4047
  if (estimateTxDependencies) {
4032
4048
  return this.estimateTxDependencies(transactionRequest);
4033
4049
  }
4034
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4050
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4035
4051
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4036
4052
  encodedTransactions: encodedTransaction,
4037
4053
  utxoValidation: utxoValidation || false
@@ -4049,13 +4065,13 @@ Supported fuel-core version: ${supportedVersion}.`
4049
4065
  async estimatePredicates(transactionRequest) {
4050
4066
  const shouldEstimatePredicates = Boolean(
4051
4067
  transactionRequest.inputs.find(
4052
- (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
4068
+ (input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math18.BN(input.predicateGasUsed).isZero()
4053
4069
  )
4054
4070
  );
4055
4071
  if (!shouldEstimatePredicates) {
4056
4072
  return transactionRequest;
4057
4073
  }
4058
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4074
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4059
4075
  const response = await this.operations.estimatePredicates({
4060
4076
  encodedTransaction
4061
4077
  });
@@ -4064,7 +4080,7 @@ Supported fuel-core version: ${supportedVersion}.`
4064
4080
  } = response;
4065
4081
  if (inputs) {
4066
4082
  inputs.forEach((input, index) => {
4067
- if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
4083
+ if ("predicateGasUsed" in input && (0, import_math18.bn)(input.predicateGasUsed).gt(0)) {
4068
4084
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4069
4085
  }
4070
4086
  });
@@ -4097,7 +4113,7 @@ Supported fuel-core version: ${supportedVersion}.`
4097
4113
  const {
4098
4114
  dryRun: [{ receipts: rawReceipts, status }]
4099
4115
  } = await this.operations.dryRun({
4100
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4116
+ encodedTransactions: [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())],
4101
4117
  utxoValidation: false
4102
4118
  });
4103
4119
  receipts = rawReceipts.map(processGqlReceipt);
@@ -4147,7 +4163,7 @@ Supported fuel-core version: ${supportedVersion}.`
4147
4163
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4148
4164
  allRequests.forEach((req, index) => {
4149
4165
  if (req.type === import_transactions20.TransactionType.Script) {
4150
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4166
+ serializedTransactionsMap.set(index, (0, import_utils23.hexlify)(req.toTransactionBytes()));
4151
4167
  }
4152
4168
  });
4153
4169
  let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
@@ -4183,7 +4199,7 @@ Supported fuel-core version: ${supportedVersion}.`
4183
4199
  transactionRequest: request
4184
4200
  });
4185
4201
  request.maxFee = maxFee;
4186
- serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
4202
+ serializedTransactionsMap.set(requestIdx, (0, import_utils23.hexlify)(request.toTransactionBytes()));
4187
4203
  nextRoundTransactions.push(requestIdx);
4188
4204
  }
4189
4205
  }
@@ -4196,7 +4212,7 @@ Supported fuel-core version: ${supportedVersion}.`
4196
4212
  if (estimateTxDependencies) {
4197
4213
  return this.estimateMultipleTxDependencies(transactionRequests);
4198
4214
  }
4199
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4215
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils23.hexlify)(tx.toTransactionBytes()));
4200
4216
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4201
4217
  encodedTransactions,
4202
4218
  utxoValidation: utxoValidation || false
@@ -4222,12 +4238,12 @@ Supported fuel-core version: ${supportedVersion}.`
4222
4238
  gasPrice = await this.estimateGasPrice(10);
4223
4239
  }
4224
4240
  const minFee = calculateGasFee({
4225
- gasPrice: (0, import_math17.bn)(gasPrice),
4241
+ gasPrice: (0, import_math18.bn)(gasPrice),
4226
4242
  gas: minGas,
4227
4243
  priceFactor: gasPriceFactor,
4228
4244
  tip: transactionRequest.tip
4229
4245
  }).add(1);
4230
- let gasLimit = (0, import_math17.bn)(0);
4246
+ let gasLimit = (0, import_math18.bn)(0);
4231
4247
  if (transactionRequest.type === import_transactions20.TransactionType.Script) {
4232
4248
  gasLimit = transactionRequest.gasLimit;
4233
4249
  if (transactionRequest.gasLimit.eq(0)) {
@@ -4240,7 +4256,7 @@ Supported fuel-core version: ${supportedVersion}.`
4240
4256
  }
4241
4257
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4242
4258
  const maxFee = calculateGasFee({
4243
- gasPrice: (0, import_math17.bn)(gasPrice),
4259
+ gasPrice: (0, import_math18.bn)(gasPrice),
4244
4260
  gas: maxGas,
4245
4261
  priceFactor: gasPriceFactor,
4246
4262
  tip: transactionRequest.tip
@@ -4269,7 +4285,7 @@ Supported fuel-core version: ${supportedVersion}.`
4269
4285
  if (estimateTxDependencies) {
4270
4286
  return this.estimateTxDependencies(transactionRequest);
4271
4287
  }
4272
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4288
+ const encodedTransactions = [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())];
4273
4289
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4274
4290
  encodedTransactions,
4275
4291
  utxoValidation: true
@@ -4305,7 +4321,7 @@ Supported fuel-core version: ${supportedVersion}.`
4305
4321
  const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4306
4322
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4307
4323
  if (isScriptTransaction) {
4308
- txRequestClone.gasLimit = (0, import_math17.bn)(0);
4324
+ txRequestClone.gasLimit = (0, import_math18.bn)(0);
4309
4325
  }
4310
4326
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4311
4327
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4326,7 +4342,7 @@ Supported fuel-core version: ${supportedVersion}.`
4326
4342
  let dryRunStatus;
4327
4343
  let missingContractIds = [];
4328
4344
  let outputVariables = 0;
4329
- let gasUsed = (0, import_math17.bn)(0);
4345
+ let gasUsed = (0, import_math18.bn)(0);
4330
4346
  txRequestClone.maxFee = maxFee;
4331
4347
  if (isScriptTransaction) {
4332
4348
  txRequestClone.gasLimit = gasLimit;
@@ -4385,16 +4401,16 @@ Supported fuel-core version: ${supportedVersion}.`
4385
4401
  const result = await this.operations.getCoins({
4386
4402
  first: 10,
4387
4403
  ...paginationArgs,
4388
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4404
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4389
4405
  });
4390
4406
  const coins = result.coins.edges.map((edge) => edge.node);
4391
4407
  return coins.map((coin) => ({
4392
4408
  id: coin.utxoId,
4393
4409
  assetId: coin.assetId,
4394
- amount: (0, import_math17.bn)(coin.amount),
4410
+ amount: (0, import_math18.bn)(coin.amount),
4395
4411
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4396
- blockCreated: (0, import_math17.bn)(coin.blockCreated),
4397
- txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4412
+ blockCreated: (0, import_math18.bn)(coin.blockCreated),
4413
+ txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
4398
4414
  }));
4399
4415
  }
4400
4416
  /**
@@ -4408,19 +4424,19 @@ Supported fuel-core version: ${supportedVersion}.`
4408
4424
  async getResourcesToSpend(owner, quantities, excludedIds) {
4409
4425
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4410
4426
  const excludeInput = {
4411
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4412
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4427
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4428
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4413
4429
  };
4414
4430
  if (this.cache) {
4415
4431
  const uniqueUtxos = new Set(
4416
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4432
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4417
4433
  );
4418
4434
  excludeInput.utxos = Array.from(uniqueUtxos);
4419
4435
  }
4420
4436
  const coinsQuery = {
4421
4437
  owner: ownerAddress.toB256(),
4422
4438
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4423
- assetId: (0, import_utils22.hexlify)(assetId),
4439
+ assetId: (0, import_utils23.hexlify)(assetId),
4424
4440
  amount: amount.toString(10),
4425
4441
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4426
4442
  })),
@@ -4431,9 +4447,9 @@ Supported fuel-core version: ${supportedVersion}.`
4431
4447
  switch (coin.type) {
4432
4448
  case "MessageCoin":
4433
4449
  return {
4434
- amount: (0, import_math17.bn)(coin.amount),
4450
+ amount: (0, import_math18.bn)(coin.amount),
4435
4451
  assetId: coin.assetId,
4436
- daHeight: (0, import_math17.bn)(coin.daHeight),
4452
+ daHeight: (0, import_math18.bn)(coin.daHeight),
4437
4453
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4438
4454
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4439
4455
  nonce: coin.nonce
@@ -4441,11 +4457,11 @@ Supported fuel-core version: ${supportedVersion}.`
4441
4457
  case "Coin":
4442
4458
  return {
4443
4459
  id: coin.utxoId,
4444
- amount: (0, import_math17.bn)(coin.amount),
4460
+ amount: (0, import_math18.bn)(coin.amount),
4445
4461
  assetId: coin.assetId,
4446
4462
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4447
- blockCreated: (0, import_math17.bn)(coin.blockCreated),
4448
- txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4463
+ blockCreated: (0, import_math18.bn)(coin.blockCreated),
4464
+ txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
4449
4465
  };
4450
4466
  default:
4451
4467
  return null;
@@ -4462,13 +4478,13 @@ Supported fuel-core version: ${supportedVersion}.`
4462
4478
  async getBlock(idOrHeight) {
4463
4479
  let variables;
4464
4480
  if (typeof idOrHeight === "number") {
4465
- variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
4481
+ variables = { height: (0, import_math18.bn)(idOrHeight).toString(10) };
4466
4482
  } else if (idOrHeight === "latest") {
4467
4483
  variables = { height: (await this.getBlockNumber()).toString(10) };
4468
4484
  } else if (idOrHeight.length === 66) {
4469
4485
  variables = { blockId: idOrHeight };
4470
4486
  } else {
4471
- variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
4487
+ variables = { blockId: (0, import_math18.bn)(idOrHeight).toString(10) };
4472
4488
  }
4473
4489
  const { block } = await this.operations.getBlock(variables);
4474
4490
  if (!block) {
@@ -4476,7 +4492,7 @@ Supported fuel-core version: ${supportedVersion}.`
4476
4492
  }
4477
4493
  return {
4478
4494
  id: block.id,
4479
- height: (0, import_math17.bn)(block.height),
4495
+ height: (0, import_math18.bn)(block.height),
4480
4496
  time: block.header.time,
4481
4497
  transactionIds: block.transactions.map((tx) => tx.id)
4482
4498
  };
@@ -4491,7 +4507,7 @@ Supported fuel-core version: ${supportedVersion}.`
4491
4507
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4492
4508
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4493
4509
  id: block.id,
4494
- height: (0, import_math17.bn)(block.height),
4510
+ height: (0, import_math18.bn)(block.height),
4495
4511
  time: block.header.time,
4496
4512
  transactionIds: block.transactions.map((tx) => tx.id)
4497
4513
  }));
@@ -4506,7 +4522,7 @@ Supported fuel-core version: ${supportedVersion}.`
4506
4522
  async getBlockWithTransactions(idOrHeight) {
4507
4523
  let variables;
4508
4524
  if (typeof idOrHeight === "number") {
4509
- variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
4525
+ variables = { blockHeight: (0, import_math18.bn)(idOrHeight).toString(10) };
4510
4526
  } else if (idOrHeight === "latest") {
4511
4527
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4512
4528
  } else {
@@ -4518,11 +4534,11 @@ Supported fuel-core version: ${supportedVersion}.`
4518
4534
  }
4519
4535
  return {
4520
4536
  id: block.id,
4521
- height: (0, import_math17.bn)(block.height, 10),
4537
+ height: (0, import_math18.bn)(block.height, 10),
4522
4538
  time: block.header.time,
4523
4539
  transactionIds: block.transactions.map((tx) => tx.id),
4524
4540
  transactions: block.transactions.map(
4525
- (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4541
+ (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4526
4542
  )
4527
4543
  };
4528
4544
  }
@@ -4538,7 +4554,7 @@ Supported fuel-core version: ${supportedVersion}.`
4538
4554
  return null;
4539
4555
  }
4540
4556
  return new import_transactions20.TransactionCoder().decode(
4541
- (0, import_utils22.arrayify)(transaction.rawPayload),
4557
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4542
4558
  0
4543
4559
  )?.[0];
4544
4560
  }
@@ -4565,9 +4581,9 @@ Supported fuel-core version: ${supportedVersion}.`
4565
4581
  async getContractBalance(contractId, assetId) {
4566
4582
  const { contractBalance } = await this.operations.getContractBalance({
4567
4583
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4568
- asset: (0, import_utils22.hexlify)(assetId)
4584
+ asset: (0, import_utils23.hexlify)(assetId)
4569
4585
  });
4570
- return (0, import_math17.bn)(contractBalance.amount, 10);
4586
+ return (0, import_math18.bn)(contractBalance.amount, 10);
4571
4587
  }
4572
4588
  /**
4573
4589
  * Returns the balance for the given owner for the given asset ID.
@@ -4579,9 +4595,9 @@ Supported fuel-core version: ${supportedVersion}.`
4579
4595
  async getBalance(owner, assetId) {
4580
4596
  const { balance } = await this.operations.getBalance({
4581
4597
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4582
- assetId: (0, import_utils22.hexlify)(assetId)
4598
+ assetId: (0, import_utils23.hexlify)(assetId)
4583
4599
  });
4584
- return (0, import_math17.bn)(balance.amount, 10);
4600
+ return (0, import_math18.bn)(balance.amount, 10);
4585
4601
  }
4586
4602
  /**
4587
4603
  * Returns balances for the given owner.
@@ -4599,7 +4615,7 @@ Supported fuel-core version: ${supportedVersion}.`
4599
4615
  const balances = result.balances.edges.map((edge) => edge.node);
4600
4616
  return balances.map((balance) => ({
4601
4617
  assetId: balance.assetId,
4602
- amount: (0, import_math17.bn)(balance.amount)
4618
+ amount: (0, import_math18.bn)(balance.amount)
4603
4619
  }));
4604
4620
  }
4605
4621
  /**
@@ -4621,15 +4637,15 @@ Supported fuel-core version: ${supportedVersion}.`
4621
4637
  sender: message.sender,
4622
4638
  recipient: message.recipient,
4623
4639
  nonce: message.nonce,
4624
- amount: (0, import_math17.bn)(message.amount),
4640
+ amount: (0, import_math18.bn)(message.amount),
4625
4641
  data: message.data
4626
4642
  }),
4627
4643
  sender: import_address3.Address.fromAddressOrString(message.sender),
4628
4644
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4629
4645
  nonce: message.nonce,
4630
- amount: (0, import_math17.bn)(message.amount),
4646
+ amount: (0, import_math18.bn)(message.amount),
4631
4647
  data: import_transactions20.InputMessageCoder.decodeData(message.data),
4632
- daHeight: (0, import_math17.bn)(message.daHeight)
4648
+ daHeight: (0, import_math18.bn)(message.daHeight)
4633
4649
  }));
4634
4650
  }
4635
4651
  /**
@@ -4682,19 +4698,19 @@ Supported fuel-core version: ${supportedVersion}.`
4682
4698
  } = result.messageProof;
4683
4699
  return {
4684
4700
  messageProof: {
4685
- proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
4701
+ proofIndex: (0, import_math18.bn)(messageProof.proofIndex),
4686
4702
  proofSet: messageProof.proofSet
4687
4703
  },
4688
4704
  blockProof: {
4689
- proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
4705
+ proofIndex: (0, import_math18.bn)(blockProof.proofIndex),
4690
4706
  proofSet: blockProof.proofSet
4691
4707
  },
4692
4708
  messageBlockHeader: {
4693
4709
  id: messageBlockHeader.id,
4694
- daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
4710
+ daHeight: (0, import_math18.bn)(messageBlockHeader.daHeight),
4695
4711
  transactionsCount: Number(messageBlockHeader.transactionsCount),
4696
4712
  transactionsRoot: messageBlockHeader.transactionsRoot,
4697
- height: (0, import_math17.bn)(messageBlockHeader.height),
4713
+ height: (0, import_math18.bn)(messageBlockHeader.height),
4698
4714
  prevRoot: messageBlockHeader.prevRoot,
4699
4715
  time: messageBlockHeader.time,
4700
4716
  applicationHash: messageBlockHeader.applicationHash,
@@ -4706,10 +4722,10 @@ Supported fuel-core version: ${supportedVersion}.`
4706
4722
  },
4707
4723
  commitBlockHeader: {
4708
4724
  id: commitBlockHeader.id,
4709
- daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
4725
+ daHeight: (0, import_math18.bn)(commitBlockHeader.daHeight),
4710
4726
  transactionsCount: Number(commitBlockHeader.transactionsCount),
4711
4727
  transactionsRoot: commitBlockHeader.transactionsRoot,
4712
- height: (0, import_math17.bn)(commitBlockHeader.height),
4728
+ height: (0, import_math18.bn)(commitBlockHeader.height),
4713
4729
  prevRoot: commitBlockHeader.prevRoot,
4714
4730
  time: commitBlockHeader.time,
4715
4731
  applicationHash: commitBlockHeader.applicationHash,
@@ -4722,19 +4738,19 @@ Supported fuel-core version: ${supportedVersion}.`
4722
4738
  sender: import_address3.Address.fromAddressOrString(sender),
4723
4739
  recipient: import_address3.Address.fromAddressOrString(recipient),
4724
4740
  nonce,
4725
- amount: (0, import_math17.bn)(amount),
4741
+ amount: (0, import_math18.bn)(amount),
4726
4742
  data
4727
4743
  };
4728
4744
  }
4729
4745
  async getLatestGasPrice() {
4730
4746
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4731
- return (0, import_math17.bn)(latestGasPrice.gasPrice);
4747
+ return (0, import_math18.bn)(latestGasPrice.gasPrice);
4732
4748
  }
4733
4749
  async estimateGasPrice(blockHorizon) {
4734
4750
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4735
4751
  blockHorizon: String(blockHorizon)
4736
4752
  });
4737
- return (0, import_math17.bn)(estimateGasPrice.gasPrice);
4753
+ return (0, import_math18.bn)(estimateGasPrice.gasPrice);
4738
4754
  }
4739
4755
  /**
4740
4756
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -4755,10 +4771,10 @@ Supported fuel-core version: ${supportedVersion}.`
4755
4771
  */
4756
4772
  async produceBlocks(amount, startTime) {
4757
4773
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4758
- blocksToProduce: (0, import_math17.bn)(amount).toString(10),
4759
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4774
+ blocksToProduce: (0, import_math18.bn)(amount).toString(10),
4775
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4760
4776
  });
4761
- return (0, import_math17.bn)(latestBlockHeight);
4777
+ return (0, import_math18.bn)(latestBlockHeight);
4762
4778
  }
4763
4779
  // eslint-disable-next-line @typescript-eslint/require-await
4764
4780
  async getTransactionResponse(transactionId) {
@@ -4804,9 +4820,9 @@ __publicField(Provider, "nodeInfoCache", {});
4804
4820
 
4805
4821
  // src/providers/transaction-summary/get-transaction-summary.ts
4806
4822
  var import_errors15 = require("@fuel-ts/errors");
4807
- var import_math18 = require("@fuel-ts/math");
4823
+ var import_math19 = require("@fuel-ts/math");
4808
4824
  var import_transactions21 = require("@fuel-ts/transactions");
4809
- var import_utils25 = require("@fuel-ts/utils");
4825
+ var import_utils26 = require("@fuel-ts/utils");
4810
4826
 
4811
4827
  // src/providers/chains.ts
4812
4828
  var CHAIN_IDS = {
@@ -4881,17 +4897,17 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
4881
4897
 
4882
4898
  // src/utils/formatTransferToContractScriptData.ts
4883
4899
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4884
- var import_math19 = require("@fuel-ts/math");
4885
- var import_utils27 = require("@fuel-ts/utils");
4900
+ var import_math20 = require("@fuel-ts/math");
4901
+ var import_utils28 = require("@fuel-ts/utils");
4886
4902
  var asm = __toESM(require("@fuels/vm-asm"));
4887
4903
  var formatTransferToContractScriptData = (params) => {
4888
4904
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4889
4905
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4890
- const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
4906
+ const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
4891
4907
  const scriptData = Uint8Array.from([
4892
- ...(0, import_utils27.arrayify)(hexlifiedContractId),
4908
+ ...(0, import_utils28.arrayify)(hexlifiedContractId),
4893
4909
  ...encoded,
4894
- ...(0, import_utils27.arrayify)(assetId)
4910
+ ...(0, import_utils28.arrayify)(assetId)
4895
4911
  ]);
4896
4912
  return scriptData;
4897
4913
  };
@@ -5082,9 +5098,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5082
5098
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
5083
5099
  const fee = request.maxFee;
5084
5100
  const baseAssetId = this.provider.getBaseAssetId();
5085
- const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
5101
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
5086
5102
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5087
- amount: (0, import_math20.bn)(fee),
5103
+ amount: (0, import_math21.bn)(fee),
5088
5104
  assetId: baseAssetId,
5089
5105
  coinQuantities: requiredQuantities
5090
5106
  });
@@ -5092,7 +5108,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5092
5108
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5093
5109
  quantitiesDict[assetId] = {
5094
5110
  required: amount,
5095
- owned: (0, import_math20.bn)(0)
5111
+ owned: (0, import_math21.bn)(0)
5096
5112
  };
5097
5113
  });
5098
5114
  request.inputs.filter(isRequestInputResource).forEach((input) => {
@@ -5119,6 +5135,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5119
5135
  cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
5120
5136
  );
5121
5137
  request.addResources(resources);
5138
+ request.shiftPredicateData();
5122
5139
  request.updatePredicateGasUsed(estimatedPredicates);
5123
5140
  const requestToReestimate2 = (0, import_ramda4.clone)(request);
5124
5141
  if (addedSignatures) {
@@ -5150,6 +5167,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5150
5167
  }
5151
5168
  fundingAttempts += 1;
5152
5169
  }
5170
+ request.shiftPredicateData();
5153
5171
  request.updatePredicateGasUsed(estimatedPredicates);
5154
5172
  const requestToReestimate = (0, import_ramda4.clone)(request);
5155
5173
  if (addedSignatures) {
@@ -5200,7 +5218,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5200
5218
  * @returns A promise that resolves to the transaction response.
5201
5219
  */
5202
5220
  async transfer(destination, amount, assetId, txParams = {}) {
5203
- if ((0, import_math20.bn)(amount).lte(0)) {
5221
+ if ((0, import_math21.bn)(amount).lte(0)) {
5204
5222
  throw new import_errors16.FuelError(
5205
5223
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5206
5224
  "Transfer amount must be a positive number."
@@ -5220,7 +5238,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5220
5238
  * @returns A promise that resolves to the transaction response.
5221
5239
  */
5222
5240
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5223
- if ((0, import_math20.bn)(amount).lte(0)) {
5241
+ if ((0, import_math21.bn)(amount).lte(0)) {
5224
5242
  throw new import_errors16.FuelError(
5225
5243
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5226
5244
  "Transfer amount must be a positive number."
@@ -5230,7 +5248,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5230
5248
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5231
5249
  const { script, scriptData } = await assembleTransferToContractScript({
5232
5250
  hexlifiedContractId: contractAddress.toB256(),
5233
- amountToTransfer: (0, import_math20.bn)(amount),
5251
+ amountToTransfer: (0, import_math21.bn)(amount),
5234
5252
  assetId: assetIdToTransfer
5235
5253
  });
5236
5254
  let request = new ScriptTransactionRequest({
@@ -5241,7 +5259,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5241
5259
  request.addContractInputAndOutput(contractAddress);
5242
5260
  const txCost = await this.provider.getTransactionCost(request, {
5243
5261
  resourcesOwner: this,
5244
- quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
5262
+ quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
5245
5263
  });
5246
5264
  request = this.validateGasLimitAndMaxFee({
5247
5265
  transactionRequest: request,
@@ -5262,21 +5280,21 @@ var Account = class extends import_interfaces.AbstractAccount {
5262
5280
  */
5263
5281
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5264
5282
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5265
- const recipientDataArray = (0, import_utils28.arrayify)(
5283
+ const recipientDataArray = (0, import_utils29.arrayify)(
5266
5284
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5267
5285
  );
5268
- const amountDataArray = (0, import_utils28.arrayify)(
5269
- "0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
5286
+ const amountDataArray = (0, import_utils29.arrayify)(
5287
+ "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
5270
5288
  );
5271
5289
  const script = new Uint8Array([
5272
- ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5290
+ ...(0, import_utils29.arrayify)(withdrawScript.bytes),
5273
5291
  ...recipientDataArray,
5274
5292
  ...amountDataArray
5275
5293
  ]);
5276
5294
  const params = { script, ...txParams };
5277
5295
  const baseAssetId = this.provider.getBaseAssetId();
5278
5296
  let request = new ScriptTransactionRequest(params);
5279
- const quantitiesToContract = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
5297
+ const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
5280
5298
  const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5281
5299
  request = this.validateGasLimitAndMaxFee({
5282
5300
  transactionRequest: request,
@@ -5349,7 +5367,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5349
5367
  txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
5350
5368
  }) {
5351
5369
  const request = transactionRequestify(transactionRequest);
5352
- if (!(0, import_utils28.isDefined)(setGasLimit)) {
5370
+ if (!(0, import_utils29.isDefined)(setGasLimit)) {
5353
5371
  request.gasLimit = gasUsed;
5354
5372
  } else if (gasUsed.gt(setGasLimit)) {
5355
5373
  throw new import_errors16.FuelError(
@@ -5357,7 +5375,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5357
5375
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5358
5376
  );
5359
5377
  }
5360
- if (!(0, import_utils28.isDefined)(setMaxFee)) {
5378
+ if (!(0, import_utils29.isDefined)(setMaxFee)) {
5361
5379
  request.maxFee = maxFee;
5362
5380
  } else if (maxFee.gt(setMaxFee)) {
5363
5381
  throw new import_errors16.FuelError(
@@ -5373,8 +5391,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5373
5391
  var import_address5 = require("@fuel-ts/address");
5374
5392
  var import_crypto2 = require("@fuel-ts/crypto");
5375
5393
  var import_hasher2 = require("@fuel-ts/hasher");
5376
- var import_math21 = require("@fuel-ts/math");
5377
- var import_utils29 = require("@fuel-ts/utils");
5394
+ var import_math22 = require("@fuel-ts/math");
5395
+ var import_utils30 = require("@fuel-ts/utils");
5378
5396
  var import_secp256k1 = require("@noble/curves/secp256k1");
5379
5397
  var Signer = class {
5380
5398
  address;
@@ -5393,10 +5411,10 @@ var Signer = class {
5393
5411
  privateKey = `0x${privateKey}`;
5394
5412
  }
5395
5413
  }
5396
- const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
5397
- this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5398
- this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5399
- this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5414
+ const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
5415
+ this.privateKey = (0, import_utils30.hexlify)(privateKeyBytes);
5416
+ this.publicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5417
+ this.compressedPublicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5400
5418
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5401
5419
  }
5402
5420
  /**
@@ -5410,11 +5428,11 @@ var Signer = class {
5410
5428
  * @returns hashed signature
5411
5429
  */
5412
5430
  sign(data) {
5413
- const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5414
- const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
5415
- const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
5431
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils30.arrayify)(data), (0, import_utils30.arrayify)(this.privateKey));
5432
+ const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
5433
+ const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
5416
5434
  s[0] |= (signature.recovery || 0) << 7;
5417
- return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5435
+ return (0, import_utils30.hexlify)((0, import_utils30.concat)([r, s]));
5418
5436
  }
5419
5437
  /**
5420
5438
  * Add point on the current elliptic curve
@@ -5423,8 +5441,8 @@ var Signer = class {
5423
5441
  * @returns compressed point on the curve
5424
5442
  */
5425
5443
  addPoint(point) {
5426
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5427
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5444
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(this.compressedPublicKey));
5445
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(point));
5428
5446
  const result = p0.add(p1);
5429
5447
  return `0x${result.toHex(true)}`;
5430
5448
  }
@@ -5436,16 +5454,16 @@ var Signer = class {
5436
5454
  * @returns public key from signature from the
5437
5455
  */
5438
5456
  static recoverPublicKey(data, signature) {
5439
- const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5457
+ const signedMessageBytes = (0, import_utils30.arrayify)(signature);
5440
5458
  const r = signedMessageBytes.slice(0, 32);
5441
5459
  const s = signedMessageBytes.slice(32, 64);
5442
5460
  const recoveryParam = (s[0] & 128) >> 7;
5443
5461
  s[0] &= 127;
5444
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5462
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils30.hexlify)(r)), BigInt((0, import_utils30.hexlify)(s))).addRecoveryBit(
5445
5463
  recoveryParam
5446
5464
  );
5447
- const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5448
- return (0, import_utils29.hexlify)(publicKey);
5465
+ const publicKey = sig.recoverPublicKey((0, import_utils30.arrayify)(data)).toRawBytes(false).slice(1);
5466
+ return (0, import_utils30.hexlify)(publicKey);
5449
5467
  }
5450
5468
  /**
5451
5469
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5464,7 +5482,7 @@ var Signer = class {
5464
5482
  * @returns random 32-byte hashed
5465
5483
  */
5466
5484
  static generatePrivateKey(entropy) {
5467
- return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5485
+ return entropy ? (0, import_hasher2.hash)((0, import_utils30.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils30.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5468
5486
  }
5469
5487
  /**
5470
5488
  * Extended publicKey from a compact publicKey
@@ -5473,8 +5491,8 @@ var Signer = class {
5473
5491
  * @returns extended publicKey
5474
5492
  */
5475
5493
  static extendPublicKey(publicKey) {
5476
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5477
- return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5494
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(publicKey));
5495
+ return (0, import_utils30.hexlify)(point.toRawBytes(false).slice(1));
5478
5496
  }
5479
5497
  };
5480
5498
 
@@ -5482,7 +5500,7 @@ var Signer = class {
5482
5500
  var import_address6 = require("@fuel-ts/address");
5483
5501
  var import_crypto3 = require("@fuel-ts/crypto");
5484
5502
  var import_errors17 = require("@fuel-ts/errors");
5485
- var import_utils30 = require("@fuel-ts/utils");
5503
+ var import_utils31 = require("@fuel-ts/utils");
5486
5504
  var import_uuid = require("uuid");
5487
5505
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5488
5506
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5565,7 +5583,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5565
5583
  );
5566
5584
  }
5567
5585
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5568
- const privateKey = (0, import_utils30.hexlify)(buffer);
5586
+ const privateKey = (0, import_utils31.hexlify)(buffer);
5569
5587
  return privateKey;
5570
5588
  }
5571
5589
 
@@ -5610,7 +5628,7 @@ var BaseWalletUnlocked = class extends Account {
5610
5628
  */
5611
5629
  async signMessage(message) {
5612
5630
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5613
- return (0, import_utils31.hexlify)(signedMessage);
5631
+ return (0, import_utils32.hexlify)(signedMessage);
5614
5632
  }
5615
5633
  /**
5616
5634
  * Signs a transaction with the wallet's private key.
@@ -5623,7 +5641,7 @@ var BaseWalletUnlocked = class extends Account {
5623
5641
  const chainId = this.provider.getChainId();
5624
5642
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5625
5643
  const signature = await this.signer().sign(hashedTransaction);
5626
- return (0, import_utils31.hexlify)(signature);
5644
+ return (0, import_utils32.hexlify)(signature);
5627
5645
  }
5628
5646
  /**
5629
5647
  * Populates a transaction with the witnesses signature.
@@ -5685,14 +5703,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5685
5703
  var import_crypto5 = require("@fuel-ts/crypto");
5686
5704
  var import_errors20 = require("@fuel-ts/errors");
5687
5705
  var import_hasher6 = require("@fuel-ts/hasher");
5688
- var import_math22 = require("@fuel-ts/math");
5689
- var import_utils35 = require("@fuel-ts/utils");
5706
+ var import_math23 = require("@fuel-ts/math");
5707
+ var import_utils36 = require("@fuel-ts/utils");
5690
5708
 
5691
5709
  // src/mnemonic/mnemonic.ts
5692
5710
  var import_crypto4 = require("@fuel-ts/crypto");
5693
5711
  var import_errors19 = require("@fuel-ts/errors");
5694
5712
  var import_hasher5 = require("@fuel-ts/hasher");
5695
- var import_utils33 = require("@fuel-ts/utils");
5713
+ var import_utils34 = require("@fuel-ts/utils");
5696
5714
 
5697
5715
  // src/wordlists/words/english.ts
5698
5716
  var english = [
@@ -7749,7 +7767,7 @@ var english = [
7749
7767
  // src/mnemonic/utils.ts
7750
7768
  var import_errors18 = require("@fuel-ts/errors");
7751
7769
  var import_hasher4 = require("@fuel-ts/hasher");
7752
- var import_utils32 = require("@fuel-ts/utils");
7770
+ var import_utils33 = require("@fuel-ts/utils");
7753
7771
  function toUtf8Bytes(stri) {
7754
7772
  const str = stri.normalize("NFKD");
7755
7773
  const result = [];
@@ -7816,14 +7834,14 @@ function entropyToMnemonicIndices(entropy) {
7816
7834
  }
7817
7835
  }
7818
7836
  const checksumBits = entropy.length / 4;
7819
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7837
+ const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7820
7838
  indices[indices.length - 1] <<= checksumBits;
7821
7839
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7822
7840
  return indices;
7823
7841
  }
7824
7842
  function mnemonicWordsToEntropy(words, wordlist) {
7825
7843
  const size = Math.ceil(11 * words.length / 8);
7826
- const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7844
+ const entropy = (0, import_utils33.arrayify)(new Uint8Array(size));
7827
7845
  let offset = 0;
7828
7846
  for (let i = 0; i < words.length; i += 1) {
7829
7847
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7843,7 +7861,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7843
7861
  const entropyBits = 32 * words.length / 3;
7844
7862
  const checksumBits = words.length / 3;
7845
7863
  const checksumMask = getUpperMask(checksumBits);
7846
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7864
+ const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7847
7865
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7848
7866
  throw new import_errors18.FuelError(
7849
7867
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7918,7 +7936,7 @@ var Mnemonic = class {
7918
7936
  static mnemonicToEntropy(phrase, wordlist = english) {
7919
7937
  const words = getWords(phrase);
7920
7938
  assertMnemonic(words);
7921
- return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7939
+ return (0, import_utils34.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7922
7940
  }
7923
7941
  /**
7924
7942
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7926,7 +7944,7 @@ var Mnemonic = class {
7926
7944
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7927
7945
  */
7928
7946
  static entropyToMnemonic(entropy, wordlist = english) {
7929
- const entropyBytes = (0, import_utils33.arrayify)(entropy);
7947
+ const entropyBytes = (0, import_utils34.arrayify)(entropy);
7930
7948
  assertWordList(wordlist);
7931
7949
  assertEntropy(entropyBytes);
7932
7950
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7995,14 +8013,14 @@ var Mnemonic = class {
7995
8013
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7996
8014
  */
7997
8015
  static masterKeysFromSeed(seed) {
7998
- const seedArray = (0, import_utils33.arrayify)(seed);
8016
+ const seedArray = (0, import_utils34.arrayify)(seed);
7999
8017
  if (seedArray.length < 16 || seedArray.length > 64) {
8000
8018
  throw new import_errors19.FuelError(
8001
8019
  import_errors19.ErrorCode.INVALID_SEED,
8002
8020
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8003
8021
  );
8004
8022
  }
8005
- return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
8023
+ return (0, import_utils34.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
8006
8024
  }
8007
8025
  /**
8008
8026
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8013,22 +8031,22 @@ var Mnemonic = class {
8013
8031
  */
8014
8032
  static seedToExtendedKey(seed, testnet = false) {
8015
8033
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8016
- const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8034
+ const prefix = (0, import_utils34.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8017
8035
  const depth = "0x00";
8018
8036
  const fingerprint = "0x00000000";
8019
8037
  const index = "0x00000000";
8020
8038
  const chainCode = masterKey.slice(32);
8021
8039
  const privateKey = masterKey.slice(0, 32);
8022
- const extendedKey = (0, import_utils33.concat)([
8040
+ const extendedKey = (0, import_utils34.concat)([
8023
8041
  prefix,
8024
8042
  depth,
8025
8043
  fingerprint,
8026
8044
  index,
8027
8045
  chainCode,
8028
- (0, import_utils33.concat)(["0x00", privateKey])
8046
+ (0, import_utils34.concat)(["0x00", privateKey])
8029
8047
  ]);
8030
- const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8031
- return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8048
+ const checksum = (0, import_utils34.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8049
+ return (0, import_utils34.encodeBase58)((0, import_utils34.concat)([extendedKey, checksum]));
8032
8050
  }
8033
8051
  /**
8034
8052
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8043,7 +8061,7 @@ var Mnemonic = class {
8043
8061
  * @returns A randomly generated mnemonic
8044
8062
  */
8045
8063
  static generate(size = 32, extraEntropy = "") {
8046
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
8064
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils34.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils34.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
8047
8065
  return Mnemonic.entropyToMnemonic(entropy);
8048
8066
  }
8049
8067
  };
@@ -8051,12 +8069,12 @@ var mnemonic_default = Mnemonic;
8051
8069
 
8052
8070
  // src/hdwallet/hdwallet.ts
8053
8071
  var HARDENED_INDEX = 2147483648;
8054
- var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8055
- var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8056
- var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8057
- var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8072
+ var MainnetPRV2 = (0, import_utils36.hexlify)("0x0488ade4");
8073
+ var MainnetPUB = (0, import_utils36.hexlify)("0x0488b21e");
8074
+ var TestnetPRV2 = (0, import_utils36.hexlify)("0x04358394");
8075
+ var TestnetPUB = (0, import_utils36.hexlify)("0x043587cf");
8058
8076
  function base58check(data) {
8059
- return (0, import_utils35.encodeBase58)((0, import_utils35.concat)([data, (0, import_utils35.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8077
+ return (0, import_utils36.encodeBase58)((0, import_utils36.concat)([data, (0, import_utils36.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8060
8078
  }
8061
8079
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8062
8080
  if (isPublic) {
@@ -8065,11 +8083,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8065
8083
  return testnet ? TestnetPRV2 : MainnetPRV2;
8066
8084
  }
8067
8085
  function isPublicExtendedKey(extendedKey) {
8068
- return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8086
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils36.hexlify)(extendedKey.slice(0, 4)));
8069
8087
  }
8070
8088
  function isValidExtendedKey(extendedKey) {
8071
8089
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8072
- (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8090
+ (0, import_utils36.hexlify)(extendedKey.slice(0, 4))
8073
8091
  );
8074
8092
  }
8075
8093
  function parsePath(path2, depth = 0) {
@@ -8087,8 +8105,8 @@ function parsePath(path2, depth = 0) {
8087
8105
  var HDWallet = class {
8088
8106
  depth = 0;
8089
8107
  index = 0;
8090
- fingerprint = (0, import_utils35.hexlify)("0x00000000");
8091
- parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8108
+ fingerprint = (0, import_utils36.hexlify)("0x00000000");
8109
+ parentFingerprint = (0, import_utils36.hexlify)("0x00000000");
8092
8110
  privateKey;
8093
8111
  publicKey;
8094
8112
  chainCode;
@@ -8100,8 +8118,8 @@ var HDWallet = class {
8100
8118
  constructor(config) {
8101
8119
  if (config.privateKey) {
8102
8120
  const signer = new Signer(config.privateKey);
8103
- this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8104
- this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8121
+ this.publicKey = (0, import_utils36.hexlify)(signer.compressedPublicKey);
8122
+ this.privateKey = (0, import_utils36.hexlify)(config.privateKey);
8105
8123
  } else {
8106
8124
  if (!config.publicKey) {
8107
8125
  throw new import_errors20.FuelError(
@@ -8109,10 +8127,10 @@ var HDWallet = class {
8109
8127
  "Both public and private Key cannot be missing. At least one should be provided."
8110
8128
  );
8111
8129
  }
8112
- this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8130
+ this.publicKey = (0, import_utils36.hexlify)(config.publicKey);
8113
8131
  }
8114
8132
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8115
- this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8133
+ this.fingerprint = (0, import_utils36.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8116
8134
  this.depth = config.depth || this.depth;
8117
8135
  this.index = config.index || this.index;
8118
8136
  this.chainCode = config.chainCode;
@@ -8128,9 +8146,9 @@ var HDWallet = class {
8128
8146
  * @returns A new instance of HDWallet on the derived index
8129
8147
  */
8130
8148
  deriveIndex(index) {
8131
- const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8132
- const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8133
- const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8149
+ const privateKey = this.privateKey && (0, import_utils36.arrayify)(this.privateKey);
8150
+ const publicKey = (0, import_utils36.arrayify)(this.publicKey);
8151
+ const chainCode = (0, import_utils36.arrayify)(this.chainCode);
8134
8152
  const data = new Uint8Array(37);
8135
8153
  if (index & HARDENED_INDEX) {
8136
8154
  if (!privateKey) {
@@ -8141,15 +8159,15 @@ var HDWallet = class {
8141
8159
  }
8142
8160
  data.set(privateKey, 1);
8143
8161
  } else {
8144
- data.set((0, import_utils35.arrayify)(this.publicKey));
8162
+ data.set((0, import_utils36.arrayify)(this.publicKey));
8145
8163
  }
8146
- data.set((0, import_math22.toBytes)(index, 4), 33);
8147
- const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
8164
+ data.set((0, import_math23.toBytes)(index, 4), 33);
8165
+ const bytes = (0, import_utils36.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
8148
8166
  const IL = bytes.slice(0, 32);
8149
8167
  const IR = bytes.slice(32);
8150
8168
  if (privateKey) {
8151
8169
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8152
- const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
8170
+ const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
8153
8171
  return new HDWallet({
8154
8172
  privateKey: ki,
8155
8173
  chainCode: IR,
@@ -8158,7 +8176,7 @@ var HDWallet = class {
8158
8176
  parentFingerprint: this.fingerprint
8159
8177
  });
8160
8178
  }
8161
- const signer = new Signer((0, import_utils35.hexlify)(IL));
8179
+ const signer = new Signer((0, import_utils36.hexlify)(IL));
8162
8180
  const Ki = signer.addPoint(publicKey);
8163
8181
  return new HDWallet({
8164
8182
  publicKey: Ki,
@@ -8193,12 +8211,12 @@ var HDWallet = class {
8193
8211
  );
8194
8212
  }
8195
8213
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8196
- const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8214
+ const depth = (0, import_utils36.hexlify)(Uint8Array.from([this.depth]));
8197
8215
  const parentFingerprint = this.parentFingerprint;
8198
- const index = (0, import_math22.toHex)(this.index, 4);
8216
+ const index = (0, import_math23.toHex)(this.index, 4);
8199
8217
  const chainCode = this.chainCode;
8200
- const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8201
- const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8218
+ const key = this.privateKey != null && !isPublic ? (0, import_utils36.concat)(["0x00", this.privateKey]) : this.publicKey;
8219
+ const extendedKey = (0, import_utils36.arrayify)((0, import_utils36.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8202
8220
  return base58check(extendedKey);
8203
8221
  }
8204
8222
  /**
@@ -8210,13 +8228,13 @@ var HDWallet = class {
8210
8228
  static fromSeed(seed) {
8211
8229
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8212
8230
  return new HDWallet({
8213
- chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8214
- privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8231
+ chainCode: (0, import_utils36.arrayify)(masterKey.slice(32)),
8232
+ privateKey: (0, import_utils36.arrayify)(masterKey.slice(0, 32))
8215
8233
  });
8216
8234
  }
8217
8235
  static fromExtendedKey(extendedKey) {
8218
- const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
8219
- const bytes = (0, import_utils35.arrayify)(decoded);
8236
+ const decoded = (0, import_utils36.hexlify)((0, import_math23.toBytes)((0, import_utils36.decodeBase58)(extendedKey)));
8237
+ const bytes = (0, import_utils36.arrayify)(decoded);
8220
8238
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8221
8239
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8222
8240
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8225,9 +8243,9 @@ var HDWallet = class {
8225
8243
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8226
8244
  }
8227
8245
  const depth = bytes[4];
8228
- const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8229
- const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8230
- const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8246
+ const parentFingerprint = (0, import_utils36.hexlify)(bytes.slice(5, 9));
8247
+ const index = parseInt((0, import_utils36.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8248
+ const chainCode = (0, import_utils36.hexlify)(bytes.slice(13, 45));
8231
8249
  const key = bytes.slice(45, 78);
8232
8250
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8233
8251
  throw new import_errors20.FuelError(
@@ -8446,7 +8464,7 @@ var generateTestWallet = async (provider, quantities) => {
8446
8464
  // src/test-utils/launchNode.ts
8447
8465
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
8448
8466
  var import_crypto7 = require("@fuel-ts/crypto");
8449
- var import_utils36 = require("@fuel-ts/utils");
8467
+ var import_utils37 = require("@fuel-ts/utils");
8450
8468
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8451
8469
  var import_child_process = require("child_process");
8452
8470
  var import_crypto8 = require("crypto");
@@ -8486,6 +8504,40 @@ var killNode = (params) => {
8486
8504
  }
8487
8505
  }
8488
8506
  };
8507
+ function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
8508
+ const defaultCoins = import_utils37.defaultSnapshotConfigs.stateConfig.coins.map((coin) => ({
8509
+ ...coin,
8510
+ amount: "18446744073709551615"
8511
+ }));
8512
+ const defaultMessages = import_utils37.defaultSnapshotConfigs.stateConfig.messages.map((message) => ({
8513
+ ...message,
8514
+ amount: "18446744073709551615"
8515
+ }));
8516
+ 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);
8517
+ 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);
8518
+ if (!process.env.GENESIS_SECRET) {
8519
+ const pk = Signer.generatePrivateKey();
8520
+ const signer = new Signer(pk);
8521
+ process.env.GENESIS_SECRET = (0, import_utils37.hexlify)(pk);
8522
+ coins.push({
8523
+ tx_id: (0, import_utils37.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8524
+ owner: signer.address.toHexString(),
8525
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8526
+ amount: "18446744073709551615",
8527
+ asset_id: chainConfig.consensus_parameters.V1.base_asset_id,
8528
+ output_index: 0,
8529
+ tx_pointer_block_height: 0,
8530
+ tx_pointer_tx_idx: 0
8531
+ });
8532
+ }
8533
+ const json = JSON.stringify({
8534
+ ...stateConfig,
8535
+ coins,
8536
+ messages
8537
+ });
8538
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8539
+ return json.replace(regexMakeNumber, "$1$2");
8540
+ }
8489
8541
  var launchNode = async ({
8490
8542
  ip,
8491
8543
  port,
@@ -8493,7 +8545,8 @@ var launchNode = async ({
8493
8545
  useSystemFuelCore = false,
8494
8546
  loggingEnabled = true,
8495
8547
  debugEnabled = false,
8496
- basePath
8548
+ basePath,
8549
+ snapshotConfig = import_utils37.defaultSnapshotConfigs
8497
8550
  }) => (
8498
8551
  // eslint-disable-next-line no-async-promise-executor
8499
8552
  new Promise(async (resolve, reject) => {
@@ -8504,7 +8557,7 @@ var launchNode = async ({
8504
8557
  "--poa-instant"
8505
8558
  ]);
8506
8559
  const snapshotDir = getFlagValueFromArgs(args, "--snapshot");
8507
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8560
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils37.defaultConsensusKey;
8508
8561
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8509
8562
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8510
8563
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -8522,56 +8575,23 @@ var launchNode = async ({
8522
8575
  let snapshotDirToUse;
8523
8576
  const prefix = basePath || import_os.default.tmpdir();
8524
8577
  const suffix = basePath ? "" : (0, import_crypto8.randomUUID)();
8525
- const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "snapshotDir");
8578
+ const tempDir = import_path.default.join(prefix, ".fuels", suffix, "snapshotDir");
8526
8579
  if (snapshotDir) {
8527
8580
  snapshotDirToUse = snapshotDir;
8528
8581
  } else {
8529
- if (!(0, import_fs.existsSync)(tempDirPath)) {
8530
- (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8582
+ if (!(0, import_fs.existsSync)(tempDir)) {
8583
+ (0, import_fs.mkdirSync)(tempDir, { recursive: true });
8531
8584
  }
8532
- let { stateConfigJson } = import_utils36.defaultSnapshotConfigs;
8533
- const { chainConfigJson, metadataJson } = import_utils36.defaultSnapshotConfigs;
8534
- stateConfigJson = {
8535
- ...stateConfigJson,
8536
- coins: [
8537
- ...stateConfigJson.coins.map((coin) => ({
8538
- ...coin,
8539
- amount: "18446744073709551615"
8540
- }))
8541
- ],
8542
- messages: stateConfigJson.messages.map((message) => ({
8543
- ...message,
8544
- amount: "18446744073709551615"
8545
- }))
8546
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8547
- };
8548
- if (!process.env.GENESIS_SECRET) {
8549
- const pk = Signer.generatePrivateKey();
8550
- const signer = new Signer(pk);
8551
- process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8552
- stateConfigJson.coins.push({
8553
- tx_id: (0, import_utils36.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8554
- owner: signer.address.toHexString(),
8555
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8556
- amount: "18446744073709551615",
8557
- asset_id: chainConfigJson.consensus_parameters.V1.base_asset_id,
8558
- output_index: 0,
8559
- tx_pointer_block_height: 0,
8560
- tx_pointer_tx_idx: 0
8561
- });
8562
- }
8563
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8564
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8565
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8566
- const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8567
- const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8568
- const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8569
- const stateTransitionWritePath = import_path.default.join(tempDirPath, "state_transition_bytecode.wasm");
8570
- (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8571
- (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8572
- (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8573
- (0, import_fs.writeFileSync)(stateTransitionWritePath, JSON.stringify(""));
8574
- snapshotDirToUse = tempDirPath;
8585
+ const { metadata } = snapshotConfig;
8586
+ const metadataPath = import_path.default.join(tempDir, "metadata.json");
8587
+ const chainConfigPath = import_path.default.join(tempDir, metadata.chain_config);
8588
+ const stateConfigPath = import_path.default.join(tempDir, metadata.table_encoding.Json.filepath);
8589
+ const stateTransitionPath = import_path.default.join(tempDir, "state_transition_bytecode.wasm");
8590
+ (0, import_fs.writeFileSync)(chainConfigPath, JSON.stringify(snapshotConfig.chainConfig), "utf8");
8591
+ (0, import_fs.writeFileSync)(stateConfigPath, getFinalStateConfigJSON(snapshotConfig), "utf8");
8592
+ (0, import_fs.writeFileSync)(metadataPath, JSON.stringify(metadata), "utf8");
8593
+ (0, import_fs.writeFileSync)(stateTransitionPath, JSON.stringify(""));
8594
+ snapshotDirToUse = tempDir;
8575
8595
  }
8576
8596
  const child = (0, import_child_process.spawn)(
8577
8597
  command,
@@ -8579,7 +8599,7 @@ var launchNode = async ({
8579
8599
  "run",
8580
8600
  ["--ip", ipToUse],
8581
8601
  ["--port", portToUse],
8582
- useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8602
+ useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDir],
8583
8603
  ["--min-gas-price", "1"],
8584
8604
  poaInstant ? ["--poa-instant", "true"] : [],
8585
8605
  ["--consensus-key", consensusKey],
@@ -8601,23 +8621,28 @@ var launchNode = async ({
8601
8621
  }
8602
8622
  const cleanupConfig = {
8603
8623
  child,
8604
- configPath: tempDirPath,
8624
+ configPath: tempDir,
8605
8625
  killFn: import_tree_kill.default,
8606
8626
  state: {
8607
8627
  isDead: false
8608
8628
  }
8609
8629
  };
8610
8630
  child.stderr.on("data", (chunk) => {
8611
- if (chunk.indexOf(graphQLStartSubstring) !== -1) {
8631
+ const text = typeof chunk === "string" ? chunk : chunk.toString();
8632
+ if (text.indexOf(graphQLStartSubstring) !== -1) {
8633
+ const rows = text.split("\n");
8634
+ const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
8635
+ const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
8612
8636
  resolve({
8613
8637
  cleanup: () => killNode(cleanupConfig),
8614
- ip: ipToUse,
8615
- port: portToUse,
8638
+ ip: realIp,
8639
+ port: realPort,
8640
+ url: `http://${realIp}:${realPort}/v1/graphql`,
8616
8641
  snapshotDir: snapshotDirToUse
8617
8642
  });
8618
8643
  }
8619
- if (/error/i.test(chunk)) {
8620
- reject(chunk.toString());
8644
+ if (/error/i.test(text)) {
8645
+ reject(text.toString());
8621
8646
  }
8622
8647
  });
8623
8648
  process.on("exit", () => killNode(cleanupConfig));
@@ -8650,12 +8675,238 @@ var launchNodeAndGetWallets = async ({
8650
8675
  };
8651
8676
  return { wallets, stop: cleanup, provider };
8652
8677
  };
8678
+
8679
+ // src/test-utils/setup-test-provider-and-wallets.ts
8680
+ var import_utils40 = require("@fuel-ts/utils");
8681
+ var import_ramda5 = require("ramda");
8682
+
8683
+ // src/test-utils/asset-id.ts
8684
+ var import_crypto9 = require("@fuel-ts/crypto");
8685
+ var import_utils38 = require("@fuel-ts/utils");
8686
+ var _AssetId = class {
8687
+ constructor(value) {
8688
+ this.value = value;
8689
+ }
8690
+ static random() {
8691
+ return new _AssetId((0, import_utils38.hexlify)((0, import_crypto9.randomBytes)(32)));
8692
+ }
8693
+ };
8694
+ var AssetId = _AssetId;
8695
+ __publicField(AssetId, "A", new _AssetId(
8696
+ "0x0101010101010101010101010101010101010101010101010101010101010101"
8697
+ ));
8698
+ __publicField(AssetId, "B", new _AssetId(
8699
+ "0x0202020202020202020202020202020202020202020202020202020202020202"
8700
+ ));
8701
+
8702
+ // src/test-utils/wallet-config.ts
8703
+ var import_crypto10 = require("@fuel-ts/crypto");
8704
+ var import_errors21 = require("@fuel-ts/errors");
8705
+ var import_utils39 = require("@fuel-ts/utils");
8706
+ var WalletConfig = class {
8707
+ initialState;
8708
+ options;
8709
+ wallets;
8710
+ generateWallets = () => {
8711
+ const generatedWallets = [];
8712
+ for (let index = 1; index <= this.options.count; index++) {
8713
+ generatedWallets.push(new WalletUnlocked((0, import_crypto10.randomBytes)(32)));
8714
+ }
8715
+ return generatedWallets;
8716
+ };
8717
+ constructor(baseAssetId, config) {
8718
+ const BASE_ASSET_ID = baseAssetId.startsWith("0x") ? baseAssetId : `0x${baseAssetId}`;
8719
+ WalletConfig.guard(config);
8720
+ this.options = config;
8721
+ const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
8722
+ this.wallets = this.generateWallets();
8723
+ this.initialState = {
8724
+ messages: WalletConfig.createMessages(this.wallets, messages),
8725
+ coins: WalletConfig.createCoins(
8726
+ this.wallets,
8727
+ BASE_ASSET_ID,
8728
+ assets2,
8729
+ coinsPerAsset,
8730
+ amountPerCoin
8731
+ )
8732
+ };
8733
+ }
8734
+ apply(snapshotConfig) {
8735
+ return {
8736
+ ...snapshotConfig,
8737
+ stateConfig: {
8738
+ ...snapshotConfig?.stateConfig ?? import_utils39.defaultSnapshotConfigs.stateConfig,
8739
+ coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
8740
+ messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
8741
+ }
8742
+ };
8743
+ }
8744
+ static createMessages(wallets, messages) {
8745
+ return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
8746
+ }
8747
+ static createCoins(wallets, baseAssetId, assets2, coinsPerAsset, amountPerCoin) {
8748
+ const coins = [];
8749
+ let assetIds = [baseAssetId];
8750
+ if (Array.isArray(assets2)) {
8751
+ assetIds = assetIds.concat(assets2.map((a) => a.value));
8752
+ } else {
8753
+ for (let index = 0; index < assets2 - 1; index++) {
8754
+ assetIds.push(AssetId.random().value);
8755
+ }
8756
+ }
8757
+ wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
8758
+ assetIds.forEach((assetId) => {
8759
+ for (let index = 0; index < coinsPerAsset; index++) {
8760
+ coins.push({
8761
+ amount: amountPerCoin,
8762
+ asset_id: assetId,
8763
+ owner: walletAddress,
8764
+ tx_pointer_block_height: 0,
8765
+ tx_pointer_tx_idx: 0,
8766
+ output_index: 0,
8767
+ tx_id: (0, import_utils39.hexlify)((0, import_crypto10.randomBytes)(32))
8768
+ });
8769
+ }
8770
+ });
8771
+ });
8772
+ return coins;
8773
+ }
8774
+ static guard({
8775
+ count: wallets,
8776
+ assets: assets2,
8777
+ coinsPerAsset,
8778
+ amountPerCoin
8779
+ }) {
8780
+ if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
8781
+ throw new import_errors21.FuelError(
8782
+ import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8783
+ "Number of wallets must be greater than zero."
8784
+ );
8785
+ }
8786
+ if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
8787
+ throw new import_errors21.FuelError(
8788
+ import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8789
+ "Number of assets per wallet must be greater than zero."
8790
+ );
8791
+ }
8792
+ if (coinsPerAsset <= 0) {
8793
+ throw new import_errors21.FuelError(
8794
+ import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8795
+ "Number of coins per asset must be greater than zero."
8796
+ );
8797
+ }
8798
+ if (amountPerCoin <= 0) {
8799
+ throw new import_errors21.FuelError(
8800
+ import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8801
+ "Amount per coin must be greater than zero."
8802
+ );
8803
+ }
8804
+ }
8805
+ };
8806
+
8807
+ // src/test-utils/setup-test-provider-and-wallets.ts
8808
+ var defaultWalletConfigOptions = {
8809
+ count: 2,
8810
+ assets: [AssetId.A, AssetId.B],
8811
+ coinsPerAsset: 1,
8812
+ amountPerCoin: 1e10,
8813
+ messages: []
8814
+ };
8815
+ async function setupTestProviderAndWallets({
8816
+ walletConfig: walletConfigOptions = {},
8817
+ providerOptions,
8818
+ nodeOptions = {}
8819
+ } = {}) {
8820
+ Symbol.dispose ??= Symbol("Symbol.dispose");
8821
+ const walletConfig = new WalletConfig(
8822
+ nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ?? import_utils40.defaultSnapshotConfigs.chainConfig.consensus_parameters.V1.base_asset_id,
8823
+ {
8824
+ ...defaultWalletConfigOptions,
8825
+ ...walletConfigOptions
8826
+ }
8827
+ );
8828
+ const { cleanup, url } = await launchNode({
8829
+ loggingEnabled: false,
8830
+ ...nodeOptions,
8831
+ snapshotConfig: (0, import_ramda5.mergeDeepRight)(
8832
+ import_utils40.defaultSnapshotConfigs,
8833
+ walletConfig.apply(nodeOptions?.snapshotConfig)
8834
+ ),
8835
+ port: "0"
8836
+ });
8837
+ let provider;
8838
+ try {
8839
+ provider = await Provider.create(url, providerOptions);
8840
+ } catch (err) {
8841
+ cleanup();
8842
+ throw err;
8843
+ }
8844
+ const wallets = walletConfig.wallets;
8845
+ wallets.forEach((wallet) => {
8846
+ wallet.connect(provider);
8847
+ });
8848
+ return {
8849
+ provider,
8850
+ wallets,
8851
+ cleanup,
8852
+ [Symbol.dispose]: cleanup
8853
+ };
8854
+ }
8855
+
8856
+ // src/test-utils/test-message.ts
8857
+ var import_address7 = require("@fuel-ts/address");
8858
+ var import_crypto11 = require("@fuel-ts/crypto");
8859
+ var import_math24 = require("@fuel-ts/math");
8860
+ var import_utils41 = require("@fuel-ts/utils");
8861
+ var TestMessage = class {
8862
+ sender;
8863
+ recipient;
8864
+ nonce;
8865
+ amount;
8866
+ data;
8867
+ da_height;
8868
+ /**
8869
+ * A helper class to create messages for testing purposes.
8870
+ *
8871
+ * Used in tandem with `WalletConfig`.
8872
+ * It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
8873
+ */
8874
+ constructor({
8875
+ sender = import_address7.Address.fromRandom(),
8876
+ recipient = import_address7.Address.fromRandom(),
8877
+ nonce = (0, import_utils41.hexlify)((0, import_crypto11.randomBytes)(32)),
8878
+ amount = 1e6,
8879
+ data = "02",
8880
+ da_height = 0
8881
+ } = {}) {
8882
+ this.sender = sender;
8883
+ this.recipient = recipient;
8884
+ this.nonce = nonce;
8885
+ this.amount = amount;
8886
+ this.data = data;
8887
+ this.da_height = da_height;
8888
+ }
8889
+ toChainMessage(recipient) {
8890
+ return {
8891
+ sender: this.sender.toB256(),
8892
+ recipient: recipient?.toB256() ?? this.recipient.toB256(),
8893
+ nonce: this.nonce,
8894
+ amount: (0, import_math24.bn)(this.amount).toNumber(),
8895
+ data: this.data,
8896
+ da_height: this.da_height
8897
+ };
8898
+ }
8899
+ };
8653
8900
  // Annotate the CommonJS export names for ESM import in node:
8654
8901
  0 && (module.exports = {
8902
+ AssetId,
8903
+ TestMessage,
8904
+ WalletConfig,
8655
8905
  generateTestWallet,
8656
8906
  killNode,
8657
8907
  launchNode,
8658
8908
  launchNodeAndGetWallets,
8659
- seedTestWallet
8909
+ seedTestWallet,
8910
+ setupTestProviderAndWallets
8660
8911
  });
8661
8912
  //# sourceMappingURL=test-utils.js.map