@fuel-ts/account 0.0.0-rc-2395-20240528075431 → 0.0.0-rc-1356-20240528093309

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 (38) hide show
  1. package/dist/index.global.js +17 -30
  2. package/dist/index.global.js.map +1 -1
  3. package/dist/index.js +126 -147
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +11 -31
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  8. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -1
  9. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  10. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  11. package/dist/providers/transaction-summary/operations.d.ts +2 -4
  12. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  13. package/dist/providers/transaction-summary/types.d.ts +0 -1
  14. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  15. package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -1
  16. package/dist/providers/utils/index.d.ts +0 -1
  17. package/dist/providers/utils/index.d.ts.map +1 -1
  18. package/dist/test-utils/asset-id.d.ts +8 -0
  19. package/dist/test-utils/asset-id.d.ts.map +1 -0
  20. package/dist/test-utils/index.d.ts +4 -0
  21. package/dist/test-utils/index.d.ts.map +1 -1
  22. package/dist/test-utils/launchNode.d.ts +8 -1
  23. package/dist/test-utils/launchNode.d.ts.map +1 -1
  24. package/dist/test-utils/setup-test-provider-and-wallets.d.ts +33 -0
  25. package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -0
  26. package/dist/test-utils/test-message.d.ts +29 -0
  27. package/dist/test-utils/test-message.d.ts.map +1 -0
  28. package/dist/test-utils/wallet-config.d.ts +55 -0
  29. package/dist/test-utils/wallet-config.d.ts.map +1 -0
  30. package/dist/test-utils.global.js +401 -79
  31. package/dist/test-utils.global.js.map +1 -1
  32. package/dist/test-utils.js +410 -179
  33. package/dist/test-utils.js.map +1 -1
  34. package/dist/test-utils.mjs +304 -77
  35. package/dist/test-utils.mjs.map +1 -1
  36. package/package.json +16 -15
  37. package/dist/providers/utils/sleep.d.ts +0 -3
  38. 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
71
  var import_math20 = require("@fuel-ts/math");
68
- var import_utils28 = require("@fuel-ts/utils");
72
+ var import_utils29 = require("@fuel-ts/utils");
69
73
  var import_ramda4 = require("ramda");
70
74
 
71
75
  // src/providers/coin-quantity.ts
@@ -108,9 +112,9 @@ var import_address3 = require("@fuel-ts/address");
108
112
  var import_errors14 = require("@fuel-ts/errors");
109
113
  var import_math17 = 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
 
@@ -1669,15 +1673,6 @@ function normalizeJSON(root) {
1669
1673
  return normalize((0, import_ramda.clone)(root));
1670
1674
  }
1671
1675
 
1672
- // src/providers/utils/sleep.ts
1673
- function sleep(time) {
1674
- return new Promise((resolve) => {
1675
- setTimeout(() => {
1676
- resolve(true);
1677
- }, time);
1678
- });
1679
- }
1680
-
1681
1676
  // src/providers/utils/extract-tx-error.ts
1682
1677
  var import_errors7 = require("@fuel-ts/errors");
1683
1678
  var import_math6 = require("@fuel-ts/math");
@@ -2994,12 +2989,12 @@ function addOperation(operations, toAdd) {
2994
2989
  }
2995
2990
  function getWithdrawFromFuelOperations({
2996
2991
  inputs,
2997
- receipts,
2998
- assetId
2992
+ receipts
2999
2993
  }) {
3000
2994
  const messageOutReceipts = getReceiptsMessageOut(receipts);
3001
2995
  const withdrawFromFuelOperations = messageOutReceipts.reduce(
3002
2996
  (prevWithdrawFromFuelOps, receipt) => {
2997
+ const assetId = "0x0000000000000000000000000000000000000000000000000000000000000000";
3003
2998
  const input = getInputFromAssetId(inputs, assetId);
3004
2999
  if (input) {
3005
3000
  const inputAddress = getInputAccountAddress(input);
@@ -3213,8 +3208,7 @@ function getOperations({
3213
3208
  receipts,
3214
3209
  abiMap,
3215
3210
  rawPayload,
3216
- maxInputs,
3217
- assetId
3211
+ maxInputs
3218
3212
  }) {
3219
3213
  if (isTypeCreate(transactionType)) {
3220
3214
  return [
@@ -3233,7 +3227,7 @@ function getOperations({
3233
3227
  rawPayload,
3234
3228
  maxInputs
3235
3229
  }),
3236
- ...getWithdrawFromFuelOperations({ inputs, receipts, assetId })
3230
+ ...getWithdrawFromFuelOperations({ inputs, receipts })
3237
3231
  ];
3238
3232
  }
3239
3233
  return [...getPayProducerOperations(outputs)];
@@ -3369,8 +3363,7 @@ function assembleTransactionSummary(params) {
3369
3363
  maxInputs,
3370
3364
  gasCosts,
3371
3365
  maxGasPerTx,
3372
- gasPrice,
3373
- assetId
3366
+ gasPrice
3374
3367
  } = params;
3375
3368
  const gasUsed = getGasUsedFromReceipts(receipts);
3376
3369
  const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
@@ -3381,8 +3374,7 @@ function assembleTransactionSummary(params) {
3381
3374
  receipts,
3382
3375
  rawPayload,
3383
3376
  abiMap,
3384
- maxInputs,
3385
- assetId
3377
+ maxInputs
3386
3378
  });
3387
3379
  const typeName = getTransactionTypeName(transaction.type);
3388
3380
  const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
@@ -3542,7 +3534,6 @@ var TransactionResponse = class {
3542
3534
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3543
3535
  const gasPrice = await this.provider.getLatestGasPrice();
3544
3536
  const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3545
- const assetId = this.provider.getBaseAssetId();
3546
3537
  const transactionSummary = assembleTransactionSummary({
3547
3538
  id: this.id,
3548
3539
  receipts,
@@ -3555,8 +3546,7 @@ var TransactionResponse = class {
3555
3546
  maxInputs,
3556
3547
  gasCosts,
3557
3548
  maxGasPerTx,
3558
- gasPrice,
3559
- assetId
3549
+ gasPrice
3560
3550
  });
3561
3551
  return transactionSummary;
3562
3552
  }
@@ -3624,6 +3614,7 @@ var TransactionResponse = class {
3624
3614
  };
3625
3615
 
3626
3616
  // src/providers/utils/auto-retry-fetch.ts
3617
+ var import_utils22 = require("@fuel-ts/utils");
3627
3618
  function getWaitDelay(options, retryAttemptNum) {
3628
3619
  const duration = options.baseDelay ?? 150;
3629
3620
  switch (options.backoff) {
@@ -3653,7 +3644,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
3653
3644
  throw error;
3654
3645
  }
3655
3646
  const delay = getWaitDelay(options, retryNum);
3656
- await sleep(delay);
3647
+ await (0, import_utils22.sleep)(delay);
3657
3648
  return autoRetryFetch(fetchFn, options, retryNum)(...args);
3658
3649
  }
3659
3650
  };
@@ -4012,7 +4003,7 @@ Supported fuel-core version: ${supportedVersion}.`
4012
4003
  if (estimateTxDependencies) {
4013
4004
  await this.estimateTxDependencies(transactionRequest);
4014
4005
  }
4015
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4006
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4016
4007
  let abis;
4017
4008
  if (transactionRequest.type === import_transactions20.TransactionType.Script) {
4018
4009
  abis = transactionRequest.abis;
@@ -4055,7 +4046,7 @@ Supported fuel-core version: ${supportedVersion}.`
4055
4046
  if (estimateTxDependencies) {
4056
4047
  return this.estimateTxDependencies(transactionRequest);
4057
4048
  }
4058
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4049
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4059
4050
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4060
4051
  encodedTransactions: encodedTransaction,
4061
4052
  utxoValidation: utxoValidation || false
@@ -4075,13 +4066,13 @@ Supported fuel-core version: ${supportedVersion}.`
4075
4066
  async estimatePredicates(transactionRequest) {
4076
4067
  const shouldEstimatePredicates = Boolean(
4077
4068
  transactionRequest.inputs.find(
4078
- (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()
4069
+ (input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
4079
4070
  )
4080
4071
  );
4081
4072
  if (!shouldEstimatePredicates) {
4082
4073
  return transactionRequest;
4083
4074
  }
4084
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4075
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4085
4076
  const response = await this.operations.estimatePredicates({
4086
4077
  encodedTransaction
4087
4078
  });
@@ -4122,7 +4113,7 @@ Supported fuel-core version: ${supportedVersion}.`
4122
4113
  const {
4123
4114
  dryRun: [{ receipts: rawReceipts, status }]
4124
4115
  } = await this.operations.dryRun({
4125
- encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4116
+ encodedTransactions: [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())],
4126
4117
  utxoValidation: false
4127
4118
  });
4128
4119
  receipts = rawReceipts.map(processGqlReceipt);
@@ -4172,7 +4163,7 @@ Supported fuel-core version: ${supportedVersion}.`
4172
4163
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4173
4164
  allRequests.forEach((req, index) => {
4174
4165
  if (req.type === import_transactions20.TransactionType.Script) {
4175
- serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4166
+ serializedTransactionsMap.set(index, (0, import_utils23.hexlify)(req.toTransactionBytes()));
4176
4167
  }
4177
4168
  });
4178
4169
  let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
@@ -4208,7 +4199,7 @@ Supported fuel-core version: ${supportedVersion}.`
4208
4199
  transactionRequest: request
4209
4200
  });
4210
4201
  request.maxFee = maxFee;
4211
- serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
4202
+ serializedTransactionsMap.set(requestIdx, (0, import_utils23.hexlify)(request.toTransactionBytes()));
4212
4203
  nextRoundTransactions.push(requestIdx);
4213
4204
  }
4214
4205
  }
@@ -4229,7 +4220,7 @@ Supported fuel-core version: ${supportedVersion}.`
4229
4220
  if (estimateTxDependencies) {
4230
4221
  return this.estimateMultipleTxDependencies(transactionRequests);
4231
4222
  }
4232
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4223
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils23.hexlify)(tx.toTransactionBytes()));
4233
4224
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4234
4225
  encodedTransactions,
4235
4226
  utxoValidation: utxoValidation || false
@@ -4303,7 +4294,7 @@ Supported fuel-core version: ${supportedVersion}.`
4303
4294
  if (estimateTxDependencies) {
4304
4295
  return this.estimateTxDependencies(transactionRequest);
4305
4296
  }
4306
- const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4297
+ const encodedTransactions = [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())];
4307
4298
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4308
4299
  encodedTransactions,
4309
4300
  utxoValidation: true
@@ -4432,7 +4423,7 @@ Supported fuel-core version: ${supportedVersion}.`
4432
4423
  const result = await this.operations.getCoins({
4433
4424
  first: 10,
4434
4425
  ...paginationArgs,
4435
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4426
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4436
4427
  });
4437
4428
  const coins = result.coins.edges.map((edge) => edge.node);
4438
4429
  return coins.map((coin) => ({
@@ -4455,19 +4446,19 @@ Supported fuel-core version: ${supportedVersion}.`
4455
4446
  async getResourcesToSpend(owner, quantities, excludedIds) {
4456
4447
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4457
4448
  const excludeInput = {
4458
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4459
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4449
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4450
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4460
4451
  };
4461
4452
  if (this.cache) {
4462
4453
  const uniqueUtxos = new Set(
4463
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4454
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4464
4455
  );
4465
4456
  excludeInput.utxos = Array.from(uniqueUtxos);
4466
4457
  }
4467
4458
  const coinsQuery = {
4468
4459
  owner: ownerAddress.toB256(),
4469
4460
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4470
- assetId: (0, import_utils22.hexlify)(assetId),
4461
+ assetId: (0, import_utils23.hexlify)(assetId),
4471
4462
  amount: amount.toString(10),
4472
4463
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4473
4464
  })),
@@ -4569,7 +4560,7 @@ Supported fuel-core version: ${supportedVersion}.`
4569
4560
  time: block.header.time,
4570
4561
  transactionIds: block.transactions.map((tx) => tx.id),
4571
4562
  transactions: block.transactions.map(
4572
- (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4563
+ (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4573
4564
  )
4574
4565
  };
4575
4566
  }
@@ -4585,7 +4576,7 @@ Supported fuel-core version: ${supportedVersion}.`
4585
4576
  return null;
4586
4577
  }
4587
4578
  return new import_transactions20.TransactionCoder().decode(
4588
- (0, import_utils22.arrayify)(transaction.rawPayload),
4579
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4589
4580
  0
4590
4581
  )?.[0];
4591
4582
  }
@@ -4612,7 +4603,7 @@ Supported fuel-core version: ${supportedVersion}.`
4612
4603
  async getContractBalance(contractId, assetId) {
4613
4604
  const { contractBalance } = await this.operations.getContractBalance({
4614
4605
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4615
- asset: (0, import_utils22.hexlify)(assetId)
4606
+ asset: (0, import_utils23.hexlify)(assetId)
4616
4607
  });
4617
4608
  return (0, import_math17.bn)(contractBalance.amount, 10);
4618
4609
  }
@@ -4626,7 +4617,7 @@ Supported fuel-core version: ${supportedVersion}.`
4626
4617
  async getBalance(owner, assetId) {
4627
4618
  const { balance } = await this.operations.getBalance({
4628
4619
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4629
- assetId: (0, import_utils22.hexlify)(assetId)
4620
+ assetId: (0, import_utils23.hexlify)(assetId)
4630
4621
  });
4631
4622
  return (0, import_math17.bn)(balance.amount, 10);
4632
4623
  }
@@ -4814,7 +4805,7 @@ Supported fuel-core version: ${supportedVersion}.`
4814
4805
  async produceBlocks(amount, startTime) {
4815
4806
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4816
4807
  blocksToProduce: (0, import_math17.bn)(amount).toString(10),
4817
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4808
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4818
4809
  });
4819
4810
  return (0, import_math17.bn)(latestBlockHeight);
4820
4811
  }
@@ -4897,7 +4888,7 @@ __publicField(Provider, "nodeInfoCache", {});
4897
4888
  var import_errors15 = require("@fuel-ts/errors");
4898
4889
  var import_math18 = require("@fuel-ts/math");
4899
4890
  var import_transactions21 = require("@fuel-ts/transactions");
4900
- var import_utils25 = require("@fuel-ts/utils");
4891
+ var import_utils26 = require("@fuel-ts/utils");
4901
4892
 
4902
4893
  // src/providers/chains.ts
4903
4894
  var CHAIN_IDS = {
@@ -4973,16 +4964,16 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
4973
4964
  // src/utils/formatTransferToContractScriptData.ts
4974
4965
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4975
4966
  var import_math19 = require("@fuel-ts/math");
4976
- var import_utils27 = require("@fuel-ts/utils");
4967
+ var import_utils28 = require("@fuel-ts/utils");
4977
4968
  var asm = __toESM(require("@fuels/vm-asm"));
4978
4969
  var formatTransferToContractScriptData = (params) => {
4979
4970
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4980
4971
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4981
4972
  const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
4982
4973
  const scriptData = Uint8Array.from([
4983
- ...(0, import_utils27.arrayify)(hexlifiedContractId),
4974
+ ...(0, import_utils28.arrayify)(hexlifiedContractId),
4984
4975
  ...encoded,
4985
- ...(0, import_utils27.arrayify)(assetId)
4976
+ ...(0, import_utils28.arrayify)(assetId)
4986
4977
  ]);
4987
4978
  return scriptData;
4988
4979
  };
@@ -5387,14 +5378,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5387
5378
  */
5388
5379
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5389
5380
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5390
- const recipientDataArray = (0, import_utils28.arrayify)(
5381
+ const recipientDataArray = (0, import_utils29.arrayify)(
5391
5382
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5392
5383
  );
5393
- const amountDataArray = (0, import_utils28.arrayify)(
5384
+ const amountDataArray = (0, import_utils29.arrayify)(
5394
5385
  "0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
5395
5386
  );
5396
5387
  const script = new Uint8Array([
5397
- ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5388
+ ...(0, import_utils29.arrayify)(withdrawScript.bytes),
5398
5389
  ...recipientDataArray,
5399
5390
  ...amountDataArray
5400
5391
  ]);
@@ -5509,7 +5500,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5509
5500
  txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
5510
5501
  }) {
5511
5502
  const request = transactionRequestify(transactionRequest);
5512
- if (!(0, import_utils28.isDefined)(setGasLimit)) {
5503
+ if (!(0, import_utils29.isDefined)(setGasLimit)) {
5513
5504
  request.gasLimit = gasUsed;
5514
5505
  } else if (gasUsed.gt(setGasLimit)) {
5515
5506
  throw new import_errors16.FuelError(
@@ -5517,7 +5508,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5517
5508
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5518
5509
  );
5519
5510
  }
5520
- if (!(0, import_utils28.isDefined)(setMaxFee)) {
5511
+ if (!(0, import_utils29.isDefined)(setMaxFee)) {
5521
5512
  request.maxFee = maxFee;
5522
5513
  } else if (maxFee.gt(setMaxFee)) {
5523
5514
  throw new import_errors16.FuelError(
@@ -5534,7 +5525,7 @@ var import_address5 = require("@fuel-ts/address");
5534
5525
  var import_crypto2 = require("@fuel-ts/crypto");
5535
5526
  var import_hasher2 = require("@fuel-ts/hasher");
5536
5527
  var import_math21 = require("@fuel-ts/math");
5537
- var import_utils29 = require("@fuel-ts/utils");
5528
+ var import_utils30 = require("@fuel-ts/utils");
5538
5529
  var import_secp256k1 = require("@noble/curves/secp256k1");
5539
5530
  var Signer = class {
5540
5531
  address;
@@ -5554,9 +5545,9 @@ var Signer = class {
5554
5545
  }
5555
5546
  }
5556
5547
  const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
5557
- this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5558
- this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5559
- this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5548
+ this.privateKey = (0, import_utils30.hexlify)(privateKeyBytes);
5549
+ this.publicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5550
+ this.compressedPublicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5560
5551
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5561
5552
  }
5562
5553
  /**
@@ -5570,11 +5561,11 @@ var Signer = class {
5570
5561
  * @returns hashed signature
5571
5562
  */
5572
5563
  sign(data) {
5573
- const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5564
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils30.arrayify)(data), (0, import_utils30.arrayify)(this.privateKey));
5574
5565
  const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
5575
5566
  const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
5576
5567
  s[0] |= (signature.recovery || 0) << 7;
5577
- return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5568
+ return (0, import_utils30.hexlify)((0, import_utils30.concat)([r, s]));
5578
5569
  }
5579
5570
  /**
5580
5571
  * Add point on the current elliptic curve
@@ -5583,8 +5574,8 @@ var Signer = class {
5583
5574
  * @returns compressed point on the curve
5584
5575
  */
5585
5576
  addPoint(point) {
5586
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5587
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5577
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(this.compressedPublicKey));
5578
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(point));
5588
5579
  const result = p0.add(p1);
5589
5580
  return `0x${result.toHex(true)}`;
5590
5581
  }
@@ -5596,16 +5587,16 @@ var Signer = class {
5596
5587
  * @returns public key from signature from the
5597
5588
  */
5598
5589
  static recoverPublicKey(data, signature) {
5599
- const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5590
+ const signedMessageBytes = (0, import_utils30.arrayify)(signature);
5600
5591
  const r = signedMessageBytes.slice(0, 32);
5601
5592
  const s = signedMessageBytes.slice(32, 64);
5602
5593
  const recoveryParam = (s[0] & 128) >> 7;
5603
5594
  s[0] &= 127;
5604
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5595
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils30.hexlify)(r)), BigInt((0, import_utils30.hexlify)(s))).addRecoveryBit(
5605
5596
  recoveryParam
5606
5597
  );
5607
- const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5608
- return (0, import_utils29.hexlify)(publicKey);
5598
+ const publicKey = sig.recoverPublicKey((0, import_utils30.arrayify)(data)).toRawBytes(false).slice(1);
5599
+ return (0, import_utils30.hexlify)(publicKey);
5609
5600
  }
5610
5601
  /**
5611
5602
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5624,7 +5615,7 @@ var Signer = class {
5624
5615
  * @returns random 32-byte hashed
5625
5616
  */
5626
5617
  static generatePrivateKey(entropy) {
5627
- 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);
5618
+ 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);
5628
5619
  }
5629
5620
  /**
5630
5621
  * Extended publicKey from a compact publicKey
@@ -5633,8 +5624,8 @@ var Signer = class {
5633
5624
  * @returns extended publicKey
5634
5625
  */
5635
5626
  static extendPublicKey(publicKey) {
5636
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5637
- return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5627
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(publicKey));
5628
+ return (0, import_utils30.hexlify)(point.toRawBytes(false).slice(1));
5638
5629
  }
5639
5630
  };
5640
5631
 
@@ -5642,7 +5633,7 @@ var Signer = class {
5642
5633
  var import_address6 = require("@fuel-ts/address");
5643
5634
  var import_crypto3 = require("@fuel-ts/crypto");
5644
5635
  var import_errors17 = require("@fuel-ts/errors");
5645
- var import_utils30 = require("@fuel-ts/utils");
5636
+ var import_utils31 = require("@fuel-ts/utils");
5646
5637
  var import_uuid = require("uuid");
5647
5638
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5648
5639
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5725,7 +5716,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5725
5716
  );
5726
5717
  }
5727
5718
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5728
- const privateKey = (0, import_utils30.hexlify)(buffer);
5719
+ const privateKey = (0, import_utils31.hexlify)(buffer);
5729
5720
  return privateKey;
5730
5721
  }
5731
5722
 
@@ -5770,7 +5761,7 @@ var BaseWalletUnlocked = class extends Account {
5770
5761
  */
5771
5762
  async signMessage(message) {
5772
5763
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5773
- return (0, import_utils31.hexlify)(signedMessage);
5764
+ return (0, import_utils32.hexlify)(signedMessage);
5774
5765
  }
5775
5766
  /**
5776
5767
  * Signs a transaction with the wallet's private key.
@@ -5783,7 +5774,7 @@ var BaseWalletUnlocked = class extends Account {
5783
5774
  const chainId = this.provider.getChainId();
5784
5775
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5785
5776
  const signature = await this.signer().sign(hashedTransaction);
5786
- return (0, import_utils31.hexlify)(signature);
5777
+ return (0, import_utils32.hexlify)(signature);
5787
5778
  }
5788
5779
  /**
5789
5780
  * Populates a transaction with the witnesses signature.
@@ -5854,13 +5845,13 @@ var import_crypto5 = require("@fuel-ts/crypto");
5854
5845
  var import_errors20 = require("@fuel-ts/errors");
5855
5846
  var import_hasher6 = require("@fuel-ts/hasher");
5856
5847
  var import_math22 = require("@fuel-ts/math");
5857
- var import_utils35 = require("@fuel-ts/utils");
5848
+ var import_utils36 = require("@fuel-ts/utils");
5858
5849
 
5859
5850
  // src/mnemonic/mnemonic.ts
5860
5851
  var import_crypto4 = require("@fuel-ts/crypto");
5861
5852
  var import_errors19 = require("@fuel-ts/errors");
5862
5853
  var import_hasher5 = require("@fuel-ts/hasher");
5863
- var import_utils33 = require("@fuel-ts/utils");
5854
+ var import_utils34 = require("@fuel-ts/utils");
5864
5855
 
5865
5856
  // src/wordlists/words/english.ts
5866
5857
  var english = [
@@ -7917,7 +7908,7 @@ var english = [
7917
7908
  // src/mnemonic/utils.ts
7918
7909
  var import_errors18 = require("@fuel-ts/errors");
7919
7910
  var import_hasher4 = require("@fuel-ts/hasher");
7920
- var import_utils32 = require("@fuel-ts/utils");
7911
+ var import_utils33 = require("@fuel-ts/utils");
7921
7912
  function getLowerMask(bits) {
7922
7913
  return (1 << bits) - 1;
7923
7914
  }
@@ -7952,14 +7943,14 @@ function entropyToMnemonicIndices(entropy) {
7952
7943
  }
7953
7944
  }
7954
7945
  const checksumBits = entropy.length / 4;
7955
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7946
+ const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7956
7947
  indices[indices.length - 1] <<= checksumBits;
7957
7948
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7958
7949
  return indices;
7959
7950
  }
7960
7951
  function mnemonicWordsToEntropy(words, wordlist) {
7961
7952
  const size = Math.ceil(11 * words.length / 8);
7962
- const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7953
+ const entropy = (0, import_utils33.arrayify)(new Uint8Array(size));
7963
7954
  let offset = 0;
7964
7955
  for (let i = 0; i < words.length; i += 1) {
7965
7956
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7979,7 +7970,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7979
7970
  const entropyBits = 32 * words.length / 3;
7980
7971
  const checksumBits = words.length / 3;
7981
7972
  const checksumMask = getUpperMask(checksumBits);
7982
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7973
+ const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7983
7974
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7984
7975
  throw new import_errors18.FuelError(
7985
7976
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7990,7 +7981,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7990
7981
  }
7991
7982
 
7992
7983
  // src/mnemonic/mnemonic.ts
7993
- var MasterSecret = (0, import_utils33.toUtf8Bytes)("Bitcoin seed");
7984
+ var MasterSecret = (0, import_utils34.toUtf8Bytes)("Bitcoin seed");
7994
7985
  var MainnetPRV = "0x0488ade4";
7995
7986
  var TestnetPRV = "0x04358394";
7996
7987
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
@@ -8054,7 +8045,7 @@ var Mnemonic = class {
8054
8045
  static mnemonicToEntropy(phrase, wordlist = english) {
8055
8046
  const words = getWords(phrase);
8056
8047
  assertMnemonic(words);
8057
- return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8048
+ return (0, import_utils34.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8058
8049
  }
8059
8050
  /**
8060
8051
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8062,7 +8053,7 @@ var Mnemonic = class {
8062
8053
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8063
8054
  */
8064
8055
  static entropyToMnemonic(entropy, wordlist = english) {
8065
- const entropyBytes = (0, import_utils33.arrayify)(entropy);
8056
+ const entropyBytes = (0, import_utils34.arrayify)(entropy);
8066
8057
  assertWordList(wordlist);
8067
8058
  assertEntropy(entropyBytes);
8068
8059
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8074,8 +8065,8 @@ var Mnemonic = class {
8074
8065
  */
8075
8066
  static mnemonicToSeed(phrase, passphrase = "") {
8076
8067
  assertMnemonic(getWords(phrase));
8077
- const phraseBytes = (0, import_utils33.toUtf8Bytes)(getPhrase(phrase));
8078
- const salt = (0, import_utils33.toUtf8Bytes)(`mnemonic${passphrase}`);
8068
+ const phraseBytes = (0, import_utils34.toUtf8Bytes)(getPhrase(phrase));
8069
+ const salt = (0, import_utils34.toUtf8Bytes)(`mnemonic${passphrase}`);
8079
8070
  return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8080
8071
  }
8081
8072
  /**
@@ -8131,14 +8122,14 @@ var Mnemonic = class {
8131
8122
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8132
8123
  */
8133
8124
  static masterKeysFromSeed(seed) {
8134
- const seedArray = (0, import_utils33.arrayify)(seed);
8125
+ const seedArray = (0, import_utils34.arrayify)(seed);
8135
8126
  if (seedArray.length < 16 || seedArray.length > 64) {
8136
8127
  throw new import_errors19.FuelError(
8137
8128
  import_errors19.ErrorCode.INVALID_SEED,
8138
8129
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8139
8130
  );
8140
8131
  }
8141
- return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
8132
+ return (0, import_utils34.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
8142
8133
  }
8143
8134
  /**
8144
8135
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8149,22 +8140,22 @@ var Mnemonic = class {
8149
8140
  */
8150
8141
  static seedToExtendedKey(seed, testnet = false) {
8151
8142
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8152
- const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8143
+ const prefix = (0, import_utils34.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8153
8144
  const depth = "0x00";
8154
8145
  const fingerprint = "0x00000000";
8155
8146
  const index = "0x00000000";
8156
8147
  const chainCode = masterKey.slice(32);
8157
8148
  const privateKey = masterKey.slice(0, 32);
8158
- const extendedKey = (0, import_utils33.concat)([
8149
+ const extendedKey = (0, import_utils34.concat)([
8159
8150
  prefix,
8160
8151
  depth,
8161
8152
  fingerprint,
8162
8153
  index,
8163
8154
  chainCode,
8164
- (0, import_utils33.concat)(["0x00", privateKey])
8155
+ (0, import_utils34.concat)(["0x00", privateKey])
8165
8156
  ]);
8166
- const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8167
- return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8157
+ const checksum = (0, import_utils34.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8158
+ return (0, import_utils34.encodeBase58)((0, import_utils34.concat)([extendedKey, checksum]));
8168
8159
  }
8169
8160
  /**
8170
8161
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8179,7 +8170,7 @@ var Mnemonic = class {
8179
8170
  * @returns A randomly generated mnemonic
8180
8171
  */
8181
8172
  static generate(size = 32, extraEntropy = "") {
8182
- 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);
8173
+ 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);
8183
8174
  return Mnemonic.entropyToMnemonic(entropy);
8184
8175
  }
8185
8176
  };
@@ -8187,12 +8178,12 @@ var mnemonic_default = Mnemonic;
8187
8178
 
8188
8179
  // src/hdwallet/hdwallet.ts
8189
8180
  var HARDENED_INDEX = 2147483648;
8190
- var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8191
- var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8192
- var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8193
- var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8181
+ var MainnetPRV2 = (0, import_utils36.hexlify)("0x0488ade4");
8182
+ var MainnetPUB = (0, import_utils36.hexlify)("0x0488b21e");
8183
+ var TestnetPRV2 = (0, import_utils36.hexlify)("0x04358394");
8184
+ var TestnetPUB = (0, import_utils36.hexlify)("0x043587cf");
8194
8185
  function base58check(data) {
8195
- 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)]));
8186
+ 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)]));
8196
8187
  }
8197
8188
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8198
8189
  if (isPublic) {
@@ -8201,11 +8192,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8201
8192
  return testnet ? TestnetPRV2 : MainnetPRV2;
8202
8193
  }
8203
8194
  function isPublicExtendedKey(extendedKey) {
8204
- return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8195
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils36.hexlify)(extendedKey.slice(0, 4)));
8205
8196
  }
8206
8197
  function isValidExtendedKey(extendedKey) {
8207
8198
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8208
- (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8199
+ (0, import_utils36.hexlify)(extendedKey.slice(0, 4))
8209
8200
  );
8210
8201
  }
8211
8202
  function parsePath(path2, depth = 0) {
@@ -8223,8 +8214,8 @@ function parsePath(path2, depth = 0) {
8223
8214
  var HDWallet = class {
8224
8215
  depth = 0;
8225
8216
  index = 0;
8226
- fingerprint = (0, import_utils35.hexlify)("0x00000000");
8227
- parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8217
+ fingerprint = (0, import_utils36.hexlify)("0x00000000");
8218
+ parentFingerprint = (0, import_utils36.hexlify)("0x00000000");
8228
8219
  privateKey;
8229
8220
  publicKey;
8230
8221
  chainCode;
@@ -8236,8 +8227,8 @@ var HDWallet = class {
8236
8227
  constructor(config) {
8237
8228
  if (config.privateKey) {
8238
8229
  const signer = new Signer(config.privateKey);
8239
- this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8240
- this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8230
+ this.publicKey = (0, import_utils36.hexlify)(signer.compressedPublicKey);
8231
+ this.privateKey = (0, import_utils36.hexlify)(config.privateKey);
8241
8232
  } else {
8242
8233
  if (!config.publicKey) {
8243
8234
  throw new import_errors20.FuelError(
@@ -8245,10 +8236,10 @@ var HDWallet = class {
8245
8236
  "Both public and private Key cannot be missing. At least one should be provided."
8246
8237
  );
8247
8238
  }
8248
- this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8239
+ this.publicKey = (0, import_utils36.hexlify)(config.publicKey);
8249
8240
  }
8250
8241
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8251
- this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8242
+ this.fingerprint = (0, import_utils36.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8252
8243
  this.depth = config.depth || this.depth;
8253
8244
  this.index = config.index || this.index;
8254
8245
  this.chainCode = config.chainCode;
@@ -8264,9 +8255,9 @@ var HDWallet = class {
8264
8255
  * @returns A new instance of HDWallet on the derived index
8265
8256
  */
8266
8257
  deriveIndex(index) {
8267
- const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8268
- const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8269
- const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8258
+ const privateKey = this.privateKey && (0, import_utils36.arrayify)(this.privateKey);
8259
+ const publicKey = (0, import_utils36.arrayify)(this.publicKey);
8260
+ const chainCode = (0, import_utils36.arrayify)(this.chainCode);
8270
8261
  const data = new Uint8Array(37);
8271
8262
  if (index & HARDENED_INDEX) {
8272
8263
  if (!privateKey) {
@@ -8277,10 +8268,10 @@ var HDWallet = class {
8277
8268
  }
8278
8269
  data.set(privateKey, 1);
8279
8270
  } else {
8280
- data.set((0, import_utils35.arrayify)(this.publicKey));
8271
+ data.set((0, import_utils36.arrayify)(this.publicKey));
8281
8272
  }
8282
8273
  data.set((0, import_math22.toBytes)(index, 4), 33);
8283
- const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
8274
+ const bytes = (0, import_utils36.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
8284
8275
  const IL = bytes.slice(0, 32);
8285
8276
  const IR = bytes.slice(32);
8286
8277
  if (privateKey) {
@@ -8294,7 +8285,7 @@ var HDWallet = class {
8294
8285
  parentFingerprint: this.fingerprint
8295
8286
  });
8296
8287
  }
8297
- const signer = new Signer((0, import_utils35.hexlify)(IL));
8288
+ const signer = new Signer((0, import_utils36.hexlify)(IL));
8298
8289
  const Ki = signer.addPoint(publicKey);
8299
8290
  return new HDWallet({
8300
8291
  publicKey: Ki,
@@ -8329,12 +8320,12 @@ var HDWallet = class {
8329
8320
  );
8330
8321
  }
8331
8322
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8332
- const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8323
+ const depth = (0, import_utils36.hexlify)(Uint8Array.from([this.depth]));
8333
8324
  const parentFingerprint = this.parentFingerprint;
8334
8325
  const index = (0, import_math22.toHex)(this.index, 4);
8335
8326
  const chainCode = this.chainCode;
8336
- const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8337
- const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8327
+ const key = this.privateKey != null && !isPublic ? (0, import_utils36.concat)(["0x00", this.privateKey]) : this.publicKey;
8328
+ const extendedKey = (0, import_utils36.arrayify)((0, import_utils36.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8338
8329
  return base58check(extendedKey);
8339
8330
  }
8340
8331
  /**
@@ -8346,13 +8337,13 @@ var HDWallet = class {
8346
8337
  static fromSeed(seed) {
8347
8338
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8348
8339
  return new HDWallet({
8349
- chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8350
- privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8340
+ chainCode: (0, import_utils36.arrayify)(masterKey.slice(32)),
8341
+ privateKey: (0, import_utils36.arrayify)(masterKey.slice(0, 32))
8351
8342
  });
8352
8343
  }
8353
8344
  static fromExtendedKey(extendedKey) {
8354
- const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
8355
- const bytes = (0, import_utils35.arrayify)(decoded);
8345
+ const decoded = (0, import_utils36.hexlify)((0, import_math22.toBytes)((0, import_utils36.decodeBase58)(extendedKey)));
8346
+ const bytes = (0, import_utils36.arrayify)(decoded);
8356
8347
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8357
8348
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8358
8349
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8361,9 +8352,9 @@ var HDWallet = class {
8361
8352
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8362
8353
  }
8363
8354
  const depth = bytes[4];
8364
- const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8365
- const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8366
- const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8355
+ const parentFingerprint = (0, import_utils36.hexlify)(bytes.slice(5, 9));
8356
+ const index = parseInt((0, import_utils36.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8357
+ const chainCode = (0, import_utils36.hexlify)(bytes.slice(13, 45));
8367
8358
  const key = bytes.slice(45, 78);
8368
8359
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8369
8360
  throw new import_errors20.FuelError(
@@ -8582,7 +8573,7 @@ var generateTestWallet = async (provider, quantities) => {
8582
8573
  // src/test-utils/launchNode.ts
8583
8574
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
8584
8575
  var import_crypto7 = require("@fuel-ts/crypto");
8585
- var import_utils36 = require("@fuel-ts/utils");
8576
+ var import_utils37 = require("@fuel-ts/utils");
8586
8577
  var import_child_process = require("child_process");
8587
8578
  var import_crypto8 = require("crypto");
8588
8579
  var import_fs = require("fs");
@@ -8621,6 +8612,40 @@ var killNode = (params) => {
8621
8612
  }
8622
8613
  }
8623
8614
  };
8615
+ function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
8616
+ const defaultCoins = import_utils37.defaultSnapshotConfigs.stateConfig.coins.map((coin) => ({
8617
+ ...coin,
8618
+ amount: "18446744073709551615"
8619
+ }));
8620
+ const defaultMessages = import_utils37.defaultSnapshotConfigs.stateConfig.messages.map((message) => ({
8621
+ ...message,
8622
+ amount: "18446744073709551615"
8623
+ }));
8624
+ 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);
8625
+ 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);
8626
+ if (!process.env.GENESIS_SECRET) {
8627
+ const pk = Signer.generatePrivateKey();
8628
+ const signer = new Signer(pk);
8629
+ process.env.GENESIS_SECRET = (0, import_utils37.hexlify)(pk);
8630
+ coins.push({
8631
+ tx_id: (0, import_utils37.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8632
+ owner: signer.address.toHexString(),
8633
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8634
+ amount: "18446744073709551615",
8635
+ asset_id: chainConfig.consensus_parameters.V1.base_asset_id,
8636
+ output_index: 0,
8637
+ tx_pointer_block_height: 0,
8638
+ tx_pointer_tx_idx: 0
8639
+ });
8640
+ }
8641
+ const json = JSON.stringify({
8642
+ ...stateConfig,
8643
+ coins,
8644
+ messages
8645
+ });
8646
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8647
+ return json.replace(regexMakeNumber, "$1$2");
8648
+ }
8624
8649
  var launchNode = async ({
8625
8650
  ip,
8626
8651
  port,
@@ -8628,7 +8653,8 @@ var launchNode = async ({
8628
8653
  fuelCorePath = process.env.FUEL_CORE_PATH ?? void 0,
8629
8654
  loggingEnabled = true,
8630
8655
  debugEnabled = false,
8631
- basePath
8656
+ basePath,
8657
+ snapshotConfig = import_utils37.defaultSnapshotConfigs
8632
8658
  }) => (
8633
8659
  // eslint-disable-next-line no-async-promise-executor
8634
8660
  new Promise(async (resolve, reject) => {
@@ -8639,7 +8665,7 @@ var launchNode = async ({
8639
8665
  "--poa-instant"
8640
8666
  ]);
8641
8667
  const snapshotDir = getFlagValueFromArgs(args, "--snapshot");
8642
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8668
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils37.defaultConsensusKey;
8643
8669
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8644
8670
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8645
8671
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -8656,56 +8682,23 @@ var launchNode = async ({
8656
8682
  let snapshotDirToUse;
8657
8683
  const prefix = basePath || import_os.default.tmpdir();
8658
8684
  const suffix = basePath ? "" : (0, import_crypto8.randomUUID)();
8659
- const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "snapshotDir");
8685
+ const tempDir = import_path.default.join(prefix, ".fuels", suffix, "snapshotDir");
8660
8686
  if (snapshotDir) {
8661
8687
  snapshotDirToUse = snapshotDir;
8662
8688
  } else {
8663
- if (!(0, import_fs.existsSync)(tempDirPath)) {
8664
- (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8665
- }
8666
- let { stateConfigJson } = import_utils36.defaultSnapshotConfigs;
8667
- const { chainConfigJson, metadataJson } = import_utils36.defaultSnapshotConfigs;
8668
- stateConfigJson = {
8669
- ...stateConfigJson,
8670
- coins: [
8671
- ...stateConfigJson.coins.map((coin) => ({
8672
- ...coin,
8673
- amount: "18446744073709551615"
8674
- }))
8675
- ],
8676
- messages: stateConfigJson.messages.map((message) => ({
8677
- ...message,
8678
- amount: "18446744073709551615"
8679
- }))
8680
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8681
- };
8682
- if (!process.env.GENESIS_SECRET) {
8683
- const pk = Signer.generatePrivateKey();
8684
- const signer = new Signer(pk);
8685
- process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8686
- stateConfigJson.coins.push({
8687
- tx_id: (0, import_utils36.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8688
- owner: signer.address.toHexString(),
8689
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8690
- amount: "18446744073709551615",
8691
- asset_id: chainConfigJson.consensus_parameters.V1.base_asset_id,
8692
- output_index: 0,
8693
- tx_pointer_block_height: 0,
8694
- tx_pointer_tx_idx: 0
8695
- });
8689
+ if (!(0, import_fs.existsSync)(tempDir)) {
8690
+ (0, import_fs.mkdirSync)(tempDir, { recursive: true });
8696
8691
  }
8697
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8698
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8699
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8700
- const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8701
- const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8702
- const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8703
- const stateTransitionWritePath = import_path.default.join(tempDirPath, "state_transition_bytecode.wasm");
8704
- (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8705
- (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8706
- (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8707
- (0, import_fs.writeFileSync)(stateTransitionWritePath, JSON.stringify(""));
8708
- snapshotDirToUse = tempDirPath;
8692
+ const { metadata } = snapshotConfig;
8693
+ const metadataPath = import_path.default.join(tempDir, "metadata.json");
8694
+ const chainConfigPath = import_path.default.join(tempDir, metadata.chain_config);
8695
+ const stateConfigPath = import_path.default.join(tempDir, metadata.table_encoding.Json.filepath);
8696
+ const stateTransitionPath = import_path.default.join(tempDir, "state_transition_bytecode.wasm");
8697
+ (0, import_fs.writeFileSync)(chainConfigPath, JSON.stringify(snapshotConfig.chainConfig), "utf8");
8698
+ (0, import_fs.writeFileSync)(stateConfigPath, getFinalStateConfigJSON(snapshotConfig), "utf8");
8699
+ (0, import_fs.writeFileSync)(metadataPath, JSON.stringify(metadata), "utf8");
8700
+ (0, import_fs.writeFileSync)(stateTransitionPath, JSON.stringify(""));
8701
+ snapshotDirToUse = tempDir;
8709
8702
  }
8710
8703
  const child = (0, import_child_process.spawn)(
8711
8704
  command,
@@ -8713,7 +8706,7 @@ var launchNode = async ({
8713
8706
  "run",
8714
8707
  ["--ip", ipToUse],
8715
8708
  ["--port", portToUse],
8716
- useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8709
+ useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDir],
8717
8710
  ["--min-gas-price", "1"],
8718
8711
  poaInstant ? ["--poa-instant", "true"] : [],
8719
8712
  ["--consensus-key", consensusKey],
@@ -8735,23 +8728,28 @@ var launchNode = async ({
8735
8728
  }
8736
8729
  const cleanupConfig = {
8737
8730
  child,
8738
- configPath: tempDirPath,
8731
+ configPath: tempDir,
8739
8732
  killFn: import_tree_kill.default,
8740
8733
  state: {
8741
8734
  isDead: false
8742
8735
  }
8743
8736
  };
8744
8737
  child.stderr.on("data", (chunk) => {
8745
- if (chunk.indexOf(graphQLStartSubstring) !== -1) {
8738
+ const text = typeof chunk === "string" ? chunk : chunk.toString();
8739
+ if (text.indexOf(graphQLStartSubstring) !== -1) {
8740
+ const rows = text.split("\n");
8741
+ const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
8742
+ const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
8746
8743
  resolve({
8747
8744
  cleanup: () => killNode(cleanupConfig),
8748
- ip: ipToUse,
8749
- port: portToUse,
8745
+ ip: realIp,
8746
+ port: realPort,
8747
+ url: `http://${realIp}:${realPort}/v1/graphql`,
8750
8748
  snapshotDir: snapshotDirToUse
8751
8749
  });
8752
8750
  }
8753
- if (/error/i.test(chunk)) {
8754
- reject(chunk.toString());
8751
+ if (/error/i.test(text)) {
8752
+ reject(text.toString());
8755
8753
  }
8756
8754
  });
8757
8755
  process.on("exit", () => killNode(cleanupConfig));
@@ -8784,12 +8782,245 @@ var launchNodeAndGetWallets = async ({
8784
8782
  };
8785
8783
  return { wallets, stop: cleanup, provider };
8786
8784
  };
8785
+
8786
+ // src/test-utils/setup-test-provider-and-wallets.ts
8787
+ var import_utils40 = require("@fuel-ts/utils");
8788
+ var import_ramda5 = require("ramda");
8789
+
8790
+ // src/test-utils/asset-id.ts
8791
+ var import_crypto9 = require("@fuel-ts/crypto");
8792
+ var import_utils38 = require("@fuel-ts/utils");
8793
+ var _AssetId = class {
8794
+ constructor(value) {
8795
+ this.value = value;
8796
+ }
8797
+ static random(count = 1) {
8798
+ const assetIds = [];
8799
+ for (let i = 0; i < count; i++) {
8800
+ assetIds.push(new _AssetId((0, import_utils38.hexlify)((0, import_crypto9.randomBytes)(32))));
8801
+ }
8802
+ return assetIds;
8803
+ }
8804
+ };
8805
+ var AssetId = _AssetId;
8806
+ __publicField(AssetId, "A", new _AssetId(
8807
+ "0x0101010101010101010101010101010101010101010101010101010101010101"
8808
+ ));
8809
+ __publicField(AssetId, "B", new _AssetId(
8810
+ "0x0202020202020202020202020202020202020202020202020202020202020202"
8811
+ ));
8812
+
8813
+ // src/test-utils/wallet-config.ts
8814
+ var import_crypto10 = require("@fuel-ts/crypto");
8815
+ var import_errors21 = require("@fuel-ts/errors");
8816
+ var import_utils39 = require("@fuel-ts/utils");
8817
+ var WalletConfig = class {
8818
+ initialState;
8819
+ options;
8820
+ wallets;
8821
+ generateWallets = () => {
8822
+ const generatedWallets = [];
8823
+ for (let index = 1; index <= this.options.count; index++) {
8824
+ generatedWallets.push(new WalletUnlocked((0, import_crypto10.randomBytes)(32)));
8825
+ }
8826
+ return generatedWallets;
8827
+ };
8828
+ constructor(baseAssetId, config) {
8829
+ WalletConfig.validate(config);
8830
+ this.options = config;
8831
+ const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
8832
+ this.wallets = this.generateWallets();
8833
+ this.initialState = {
8834
+ messages: WalletConfig.createMessages(this.wallets, messages),
8835
+ coins: WalletConfig.createCoins(
8836
+ this.wallets,
8837
+ baseAssetId,
8838
+ assets2,
8839
+ coinsPerAsset,
8840
+ amountPerCoin
8841
+ )
8842
+ };
8843
+ }
8844
+ apply(snapshotConfig) {
8845
+ return {
8846
+ ...snapshotConfig,
8847
+ stateConfig: {
8848
+ ...snapshotConfig?.stateConfig ?? import_utils39.defaultSnapshotConfigs.stateConfig,
8849
+ coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
8850
+ messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
8851
+ }
8852
+ };
8853
+ }
8854
+ /**
8855
+ * Create messages for the wallets in the format that the chain expects.
8856
+ */
8857
+ static createMessages(wallets, messages) {
8858
+ return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
8859
+ }
8860
+ /**
8861
+ * Create coins for the wallets in the format that the chain expects.
8862
+ */
8863
+ static createCoins(wallets, baseAssetId, assets2, coinsPerAsset, amountPerCoin) {
8864
+ const coins = [];
8865
+ let assetIds = [baseAssetId];
8866
+ if (Array.isArray(assets2)) {
8867
+ assetIds = assetIds.concat(assets2.map((a) => a.value));
8868
+ } else {
8869
+ assetIds = assetIds.concat(AssetId.random(assets2 - 1).map((a) => a.value));
8870
+ }
8871
+ wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
8872
+ assetIds.forEach((assetId) => {
8873
+ for (let index = 0; index < coinsPerAsset; index++) {
8874
+ coins.push({
8875
+ amount: amountPerCoin,
8876
+ asset_id: assetId,
8877
+ owner: walletAddress,
8878
+ tx_pointer_block_height: 0,
8879
+ tx_pointer_tx_idx: 0,
8880
+ output_index: 0,
8881
+ tx_id: (0, import_utils39.hexlify)((0, import_crypto10.randomBytes)(32))
8882
+ });
8883
+ }
8884
+ });
8885
+ });
8886
+ return coins;
8887
+ }
8888
+ static validate({
8889
+ count: wallets,
8890
+ assets: assets2,
8891
+ coinsPerAsset,
8892
+ amountPerCoin
8893
+ }) {
8894
+ if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
8895
+ throw new import_errors21.FuelError(
8896
+ import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8897
+ "Number of wallets must be greater than zero."
8898
+ );
8899
+ }
8900
+ if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
8901
+ throw new import_errors21.FuelError(
8902
+ import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8903
+ "Number of assets per wallet must be greater than zero."
8904
+ );
8905
+ }
8906
+ if (coinsPerAsset <= 0) {
8907
+ throw new import_errors21.FuelError(
8908
+ import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8909
+ "Number of coins per asset must be greater than zero."
8910
+ );
8911
+ }
8912
+ if (amountPerCoin <= 0) {
8913
+ throw new import_errors21.FuelError(
8914
+ import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8915
+ "Amount per coin must be greater than zero."
8916
+ );
8917
+ }
8918
+ }
8919
+ };
8920
+
8921
+ // src/test-utils/setup-test-provider-and-wallets.ts
8922
+ var defaultWalletConfigOptions = {
8923
+ count: 2,
8924
+ assets: [AssetId.A, AssetId.B],
8925
+ coinsPerAsset: 1,
8926
+ amountPerCoin: 1e10,
8927
+ messages: []
8928
+ };
8929
+ async function setupTestProviderAndWallets({
8930
+ walletConfig: walletConfigOptions = {},
8931
+ providerOptions,
8932
+ nodeOptions = {}
8933
+ } = {}) {
8934
+ Symbol.dispose ??= Symbol("Symbol.dispose");
8935
+ const walletConfig = new WalletConfig(
8936
+ nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ?? import_utils40.defaultSnapshotConfigs.chainConfig.consensus_parameters.V1.base_asset_id,
8937
+ {
8938
+ ...defaultWalletConfigOptions,
8939
+ ...walletConfigOptions
8940
+ }
8941
+ );
8942
+ const { cleanup, url } = await launchNode({
8943
+ loggingEnabled: false,
8944
+ ...nodeOptions,
8945
+ snapshotConfig: (0, import_ramda5.mergeDeepRight)(
8946
+ import_utils40.defaultSnapshotConfigs,
8947
+ walletConfig.apply(nodeOptions?.snapshotConfig)
8948
+ ),
8949
+ port: "0"
8950
+ });
8951
+ let provider;
8952
+ try {
8953
+ provider = await Provider.create(url, providerOptions);
8954
+ } catch (err) {
8955
+ cleanup();
8956
+ throw err;
8957
+ }
8958
+ const wallets = walletConfig.wallets;
8959
+ wallets.forEach((wallet) => {
8960
+ wallet.connect(provider);
8961
+ });
8962
+ return {
8963
+ provider,
8964
+ wallets,
8965
+ cleanup,
8966
+ [Symbol.dispose]: cleanup
8967
+ };
8968
+ }
8969
+
8970
+ // src/test-utils/test-message.ts
8971
+ var import_address7 = require("@fuel-ts/address");
8972
+ var import_crypto11 = require("@fuel-ts/crypto");
8973
+ var import_math23 = require("@fuel-ts/math");
8974
+ var import_utils41 = require("@fuel-ts/utils");
8975
+ var TestMessage = class {
8976
+ sender;
8977
+ recipient;
8978
+ nonce;
8979
+ amount;
8980
+ data;
8981
+ da_height;
8982
+ /**
8983
+ * A helper class to create messages for testing purposes.
8984
+ *
8985
+ * Used in tandem with `WalletConfig`.
8986
+ * It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
8987
+ */
8988
+ constructor({
8989
+ sender = import_address7.Address.fromRandom(),
8990
+ recipient = import_address7.Address.fromRandom(),
8991
+ nonce = (0, import_utils41.hexlify)((0, import_crypto11.randomBytes)(32)),
8992
+ amount = 1e6,
8993
+ data = "02",
8994
+ da_height = 0
8995
+ } = {}) {
8996
+ this.sender = sender;
8997
+ this.recipient = recipient;
8998
+ this.nonce = nonce;
8999
+ this.amount = amount;
9000
+ this.data = data;
9001
+ this.da_height = da_height;
9002
+ }
9003
+ toChainMessage(recipient) {
9004
+ return {
9005
+ sender: this.sender.toB256(),
9006
+ recipient: recipient?.toB256() ?? this.recipient.toB256(),
9007
+ nonce: this.nonce,
9008
+ amount: (0, import_math23.bn)(this.amount).toNumber(),
9009
+ data: this.data,
9010
+ da_height: this.da_height
9011
+ };
9012
+ }
9013
+ };
8787
9014
  // Annotate the CommonJS export names for ESM import in node:
8788
9015
  0 && (module.exports = {
9016
+ AssetId,
9017
+ TestMessage,
9018
+ WalletConfig,
8789
9019
  generateTestWallet,
8790
9020
  killNode,
8791
9021
  launchNode,
8792
9022
  launchNodeAndGetWallets,
8793
- seedTestWallet
9023
+ seedTestWallet,
9024
+ setupTestProviderAndWallets
8794
9025
  });
8795
9026
  //# sourceMappingURL=test-utils.js.map