@fuel-ts/account 0.0.0-rc-1356-20240511074927 → 0.0.0-rc-2143-20240513161105

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.

@@ -48,28 +48,24 @@ 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,
54
51
  generateTestWallet: () => generateTestWallet,
55
52
  killNode: () => killNode,
56
53
  launchNode: () => launchNode,
57
54
  launchNodeAndGetWallets: () => launchNodeAndGetWallets,
58
- seedTestWallet: () => seedTestWallet,
59
- setupTestProviderAndWallets: () => setupTestProviderAndWallets
55
+ seedTestWallet: () => seedTestWallet
60
56
  });
61
57
  module.exports = __toCommonJS(test_utils_exports);
62
58
 
63
59
  // src/wallet/base-wallet-unlocked.ts
64
60
  var import_hasher3 = require("@fuel-ts/hasher");
65
- var import_utils32 = require("@fuel-ts/utils");
61
+ var import_utils31 = require("@fuel-ts/utils");
66
62
 
67
63
  // src/account.ts
68
64
  var import_address4 = require("@fuel-ts/address");
69
65
  var import_errors16 = require("@fuel-ts/errors");
70
66
  var import_interfaces = require("@fuel-ts/interfaces");
71
67
  var import_math21 = require("@fuel-ts/math");
72
- var import_utils29 = require("@fuel-ts/utils");
68
+ var import_utils28 = require("@fuel-ts/utils");
73
69
  var import_ramda4 = require("ramda");
74
70
 
75
71
  // src/providers/coin-quantity.ts
@@ -112,9 +108,9 @@ var import_address3 = require("@fuel-ts/address");
112
108
  var import_errors14 = require("@fuel-ts/errors");
113
109
  var import_math18 = require("@fuel-ts/math");
114
110
  var import_transactions20 = require("@fuel-ts/transactions");
115
- var import_utils23 = require("@fuel-ts/utils");
111
+ var import_utils22 = require("@fuel-ts/utils");
116
112
  var import_versions = require("@fuel-ts/versions");
117
- var import_utils24 = require("@noble/curves/abstract/utils");
113
+ var import_utils23 = require("@noble/curves/abstract/utils");
118
114
  var import_graphql_request = require("graphql-request");
119
115
  var import_ramda3 = require("ramda");
120
116
 
@@ -1671,6 +1667,15 @@ function normalizeJSON(root) {
1671
1667
  return normalize((0, import_ramda.clone)(root));
1672
1668
  }
1673
1669
 
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
+
1674
1679
  // src/providers/utils/extract-tx-error.ts
1675
1680
  var import_errors7 = require("@fuel-ts/errors");
1676
1681
  var import_math6 = require("@fuel-ts/math");
@@ -3634,7 +3639,6 @@ var TransactionResponse = class {
3634
3639
  };
3635
3640
 
3636
3641
  // src/providers/utils/auto-retry-fetch.ts
3637
- var import_utils22 = require("@fuel-ts/utils");
3638
3642
  function getWaitDelay(options, retryAttemptNum) {
3639
3643
  const duration = options.baseDelay ?? 150;
3640
3644
  switch (options.backoff) {
@@ -3664,7 +3668,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
3664
3668
  throw error;
3665
3669
  }
3666
3670
  const delay = getWaitDelay(options, retryNum);
3667
- await (0, import_utils22.sleep)(delay);
3671
+ await sleep(delay);
3668
3672
  return autoRetryFetch(fetchFn, options, retryNum)(...args);
3669
3673
  }
3670
3674
  };
@@ -4004,7 +4008,7 @@ Supported fuel-core version: ${supportedVersion}.`
4004
4008
  if (estimateTxDependencies) {
4005
4009
  await this.estimateTxDependencies(transactionRequest);
4006
4010
  }
4007
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4011
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4008
4012
  let abis;
4009
4013
  if (transactionRequest.type === import_transactions20.TransactionType.Script) {
4010
4014
  abis = transactionRequest.abis;
@@ -4047,7 +4051,7 @@ Supported fuel-core version: ${supportedVersion}.`
4047
4051
  if (estimateTxDependencies) {
4048
4052
  return this.estimateTxDependencies(transactionRequest);
4049
4053
  }
4050
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4054
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4051
4055
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4052
4056
  encodedTransactions: encodedTransaction,
4053
4057
  utxoValidation: utxoValidation || false
@@ -4065,13 +4069,13 @@ Supported fuel-core version: ${supportedVersion}.`
4065
4069
  async estimatePredicates(transactionRequest) {
4066
4070
  const shouldEstimatePredicates = Boolean(
4067
4071
  transactionRequest.inputs.find(
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()
4072
+ (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math18.BN(input.predicateGasUsed).isZero()
4069
4073
  )
4070
4074
  );
4071
4075
  if (!shouldEstimatePredicates) {
4072
4076
  return transactionRequest;
4073
4077
  }
4074
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4078
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4075
4079
  const response = await this.operations.estimatePredicates({
4076
4080
  encodedTransaction
4077
4081
  });
@@ -4113,7 +4117,7 @@ Supported fuel-core version: ${supportedVersion}.`
4113
4117
  const {
4114
4118
  dryRun: [{ receipts: rawReceipts, status }]
4115
4119
  } = await this.operations.dryRun({
4116
- encodedTransactions: [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())],
4120
+ encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4117
4121
  utxoValidation: false
4118
4122
  });
4119
4123
  receipts = rawReceipts.map(processGqlReceipt);
@@ -4163,7 +4167,7 @@ Supported fuel-core version: ${supportedVersion}.`
4163
4167
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4164
4168
  allRequests.forEach((req, index) => {
4165
4169
  if (req.type === import_transactions20.TransactionType.Script) {
4166
- serializedTransactionsMap.set(index, (0, import_utils23.hexlify)(req.toTransactionBytes()));
4170
+ serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4167
4171
  }
4168
4172
  });
4169
4173
  let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
@@ -4199,7 +4203,7 @@ Supported fuel-core version: ${supportedVersion}.`
4199
4203
  transactionRequest: request
4200
4204
  });
4201
4205
  request.maxFee = maxFee;
4202
- serializedTransactionsMap.set(requestIdx, (0, import_utils23.hexlify)(request.toTransactionBytes()));
4206
+ serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
4203
4207
  nextRoundTransactions.push(requestIdx);
4204
4208
  }
4205
4209
  }
@@ -4212,7 +4216,7 @@ Supported fuel-core version: ${supportedVersion}.`
4212
4216
  if (estimateTxDependencies) {
4213
4217
  return this.estimateMultipleTxDependencies(transactionRequests);
4214
4218
  }
4215
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils23.hexlify)(tx.toTransactionBytes()));
4219
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4216
4220
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4217
4221
  encodedTransactions,
4218
4222
  utxoValidation: utxoValidation || false
@@ -4285,7 +4289,7 @@ Supported fuel-core version: ${supportedVersion}.`
4285
4289
  if (estimateTxDependencies) {
4286
4290
  return this.estimateTxDependencies(transactionRequest);
4287
4291
  }
4288
- const encodedTransactions = [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())];
4292
+ const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4289
4293
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4290
4294
  encodedTransactions,
4291
4295
  utxoValidation: true
@@ -4401,7 +4405,7 @@ Supported fuel-core version: ${supportedVersion}.`
4401
4405
  const result = await this.operations.getCoins({
4402
4406
  first: 10,
4403
4407
  ...paginationArgs,
4404
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4408
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4405
4409
  });
4406
4410
  const coins = result.coins.edges.map((edge) => edge.node);
4407
4411
  return coins.map((coin) => ({
@@ -4424,19 +4428,19 @@ Supported fuel-core version: ${supportedVersion}.`
4424
4428
  async getResourcesToSpend(owner, quantities, excludedIds) {
4425
4429
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4426
4430
  const excludeInput = {
4427
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4428
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4431
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4432
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4429
4433
  };
4430
4434
  if (this.cache) {
4431
4435
  const uniqueUtxos = new Set(
4432
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4436
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4433
4437
  );
4434
4438
  excludeInput.utxos = Array.from(uniqueUtxos);
4435
4439
  }
4436
4440
  const coinsQuery = {
4437
4441
  owner: ownerAddress.toB256(),
4438
4442
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4439
- assetId: (0, import_utils23.hexlify)(assetId),
4443
+ assetId: (0, import_utils22.hexlify)(assetId),
4440
4444
  amount: amount.toString(10),
4441
4445
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4442
4446
  })),
@@ -4538,7 +4542,7 @@ Supported fuel-core version: ${supportedVersion}.`
4538
4542
  time: block.header.time,
4539
4543
  transactionIds: block.transactions.map((tx) => tx.id),
4540
4544
  transactions: block.transactions.map(
4541
- (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4545
+ (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4542
4546
  )
4543
4547
  };
4544
4548
  }
@@ -4554,7 +4558,7 @@ Supported fuel-core version: ${supportedVersion}.`
4554
4558
  return null;
4555
4559
  }
4556
4560
  return new import_transactions20.TransactionCoder().decode(
4557
- (0, import_utils23.arrayify)(transaction.rawPayload),
4561
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4558
4562
  0
4559
4563
  )?.[0];
4560
4564
  }
@@ -4581,7 +4585,7 @@ Supported fuel-core version: ${supportedVersion}.`
4581
4585
  async getContractBalance(contractId, assetId) {
4582
4586
  const { contractBalance } = await this.operations.getContractBalance({
4583
4587
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4584
- asset: (0, import_utils23.hexlify)(assetId)
4588
+ asset: (0, import_utils22.hexlify)(assetId)
4585
4589
  });
4586
4590
  return (0, import_math18.bn)(contractBalance.amount, 10);
4587
4591
  }
@@ -4595,7 +4599,7 @@ Supported fuel-core version: ${supportedVersion}.`
4595
4599
  async getBalance(owner, assetId) {
4596
4600
  const { balance } = await this.operations.getBalance({
4597
4601
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4598
- assetId: (0, import_utils23.hexlify)(assetId)
4602
+ assetId: (0, import_utils22.hexlify)(assetId)
4599
4603
  });
4600
4604
  return (0, import_math18.bn)(balance.amount, 10);
4601
4605
  }
@@ -4772,7 +4776,7 @@ Supported fuel-core version: ${supportedVersion}.`
4772
4776
  async produceBlocks(amount, startTime) {
4773
4777
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4774
4778
  blocksToProduce: (0, import_math18.bn)(amount).toString(10),
4775
- startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4779
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4776
4780
  });
4777
4781
  return (0, import_math18.bn)(latestBlockHeight);
4778
4782
  }
@@ -4822,7 +4826,7 @@ __publicField(Provider, "nodeInfoCache", {});
4822
4826
  var import_errors15 = require("@fuel-ts/errors");
4823
4827
  var import_math19 = require("@fuel-ts/math");
4824
4828
  var import_transactions21 = require("@fuel-ts/transactions");
4825
- var import_utils26 = require("@fuel-ts/utils");
4829
+ var import_utils25 = require("@fuel-ts/utils");
4826
4830
 
4827
4831
  // src/providers/chains.ts
4828
4832
  var CHAIN_IDS = {
@@ -4898,16 +4902,16 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
4898
4902
  // src/utils/formatTransferToContractScriptData.ts
4899
4903
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4900
4904
  var import_math20 = require("@fuel-ts/math");
4901
- var import_utils28 = require("@fuel-ts/utils");
4905
+ var import_utils27 = require("@fuel-ts/utils");
4902
4906
  var asm = __toESM(require("@fuels/vm-asm"));
4903
4907
  var formatTransferToContractScriptData = (params) => {
4904
4908
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4905
4909
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4906
4910
  const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
4907
4911
  const scriptData = Uint8Array.from([
4908
- ...(0, import_utils28.arrayify)(hexlifiedContractId),
4912
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4909
4913
  ...encoded,
4910
- ...(0, import_utils28.arrayify)(assetId)
4914
+ ...(0, import_utils27.arrayify)(assetId)
4911
4915
  ]);
4912
4916
  return scriptData;
4913
4917
  };
@@ -5280,14 +5284,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5280
5284
  */
5281
5285
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5282
5286
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5283
- const recipientDataArray = (0, import_utils29.arrayify)(
5287
+ const recipientDataArray = (0, import_utils28.arrayify)(
5284
5288
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5285
5289
  );
5286
- const amountDataArray = (0, import_utils29.arrayify)(
5290
+ const amountDataArray = (0, import_utils28.arrayify)(
5287
5291
  "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
5288
5292
  );
5289
5293
  const script = new Uint8Array([
5290
- ...(0, import_utils29.arrayify)(withdrawScript.bytes),
5294
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5291
5295
  ...recipientDataArray,
5292
5296
  ...amountDataArray
5293
5297
  ]);
@@ -5367,7 +5371,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5367
5371
  txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
5368
5372
  }) {
5369
5373
  const request = transactionRequestify(transactionRequest);
5370
- if (!(0, import_utils29.isDefined)(setGasLimit)) {
5374
+ if (!(0, import_utils28.isDefined)(setGasLimit)) {
5371
5375
  request.gasLimit = gasUsed;
5372
5376
  } else if (gasUsed.gt(setGasLimit)) {
5373
5377
  throw new import_errors16.FuelError(
@@ -5375,7 +5379,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5375
5379
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5376
5380
  );
5377
5381
  }
5378
- if (!(0, import_utils29.isDefined)(setMaxFee)) {
5382
+ if (!(0, import_utils28.isDefined)(setMaxFee)) {
5379
5383
  request.maxFee = maxFee;
5380
5384
  } else if (maxFee.gt(setMaxFee)) {
5381
5385
  throw new import_errors16.FuelError(
@@ -5392,7 +5396,7 @@ var import_address5 = require("@fuel-ts/address");
5392
5396
  var import_crypto2 = require("@fuel-ts/crypto");
5393
5397
  var import_hasher2 = require("@fuel-ts/hasher");
5394
5398
  var import_math22 = require("@fuel-ts/math");
5395
- var import_utils30 = require("@fuel-ts/utils");
5399
+ var import_utils29 = require("@fuel-ts/utils");
5396
5400
  var import_secp256k1 = require("@noble/curves/secp256k1");
5397
5401
  var Signer = class {
5398
5402
  address;
@@ -5412,9 +5416,9 @@ var Signer = class {
5412
5416
  }
5413
5417
  }
5414
5418
  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));
5419
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5420
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5421
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5418
5422
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5419
5423
  }
5420
5424
  /**
@@ -5428,11 +5432,11 @@ var Signer = class {
5428
5432
  * @returns hashed signature
5429
5433
  */
5430
5434
  sign(data) {
5431
- const signature = import_secp256k1.secp256k1.sign((0, import_utils30.arrayify)(data), (0, import_utils30.arrayify)(this.privateKey));
5435
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5432
5436
  const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
5433
5437
  const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
5434
5438
  s[0] |= (signature.recovery || 0) << 7;
5435
- return (0, import_utils30.hexlify)((0, import_utils30.concat)([r, s]));
5439
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5436
5440
  }
5437
5441
  /**
5438
5442
  * Add point on the current elliptic curve
@@ -5441,8 +5445,8 @@ var Signer = class {
5441
5445
  * @returns compressed point on the curve
5442
5446
  */
5443
5447
  addPoint(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));
5448
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5449
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5446
5450
  const result = p0.add(p1);
5447
5451
  return `0x${result.toHex(true)}`;
5448
5452
  }
@@ -5454,16 +5458,16 @@ var Signer = class {
5454
5458
  * @returns public key from signature from the
5455
5459
  */
5456
5460
  static recoverPublicKey(data, signature) {
5457
- const signedMessageBytes = (0, import_utils30.arrayify)(signature);
5461
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5458
5462
  const r = signedMessageBytes.slice(0, 32);
5459
5463
  const s = signedMessageBytes.slice(32, 64);
5460
5464
  const recoveryParam = (s[0] & 128) >> 7;
5461
5465
  s[0] &= 127;
5462
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils30.hexlify)(r)), BigInt((0, import_utils30.hexlify)(s))).addRecoveryBit(
5466
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5463
5467
  recoveryParam
5464
5468
  );
5465
- const publicKey = sig.recoverPublicKey((0, import_utils30.arrayify)(data)).toRawBytes(false).slice(1);
5466
- return (0, import_utils30.hexlify)(publicKey);
5469
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5470
+ return (0, import_utils29.hexlify)(publicKey);
5467
5471
  }
5468
5472
  /**
5469
5473
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5482,7 +5486,7 @@ var Signer = class {
5482
5486
  * @returns random 32-byte hashed
5483
5487
  */
5484
5488
  static generatePrivateKey(entropy) {
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);
5489
+ 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);
5486
5490
  }
5487
5491
  /**
5488
5492
  * Extended publicKey from a compact publicKey
@@ -5491,8 +5495,8 @@ var Signer = class {
5491
5495
  * @returns extended publicKey
5492
5496
  */
5493
5497
  static extendPublicKey(publicKey) {
5494
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(publicKey));
5495
- return (0, import_utils30.hexlify)(point.toRawBytes(false).slice(1));
5498
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5499
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5496
5500
  }
5497
5501
  };
5498
5502
 
@@ -5500,7 +5504,7 @@ var Signer = class {
5500
5504
  var import_address6 = require("@fuel-ts/address");
5501
5505
  var import_crypto3 = require("@fuel-ts/crypto");
5502
5506
  var import_errors17 = require("@fuel-ts/errors");
5503
- var import_utils31 = require("@fuel-ts/utils");
5507
+ var import_utils30 = require("@fuel-ts/utils");
5504
5508
  var import_uuid = require("uuid");
5505
5509
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5506
5510
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5583,7 +5587,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5583
5587
  );
5584
5588
  }
5585
5589
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5586
- const privateKey = (0, import_utils31.hexlify)(buffer);
5590
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5587
5591
  return privateKey;
5588
5592
  }
5589
5593
 
@@ -5628,7 +5632,7 @@ var BaseWalletUnlocked = class extends Account {
5628
5632
  */
5629
5633
  async signMessage(message) {
5630
5634
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5631
- return (0, import_utils32.hexlify)(signedMessage);
5635
+ return (0, import_utils31.hexlify)(signedMessage);
5632
5636
  }
5633
5637
  /**
5634
5638
  * Signs a transaction with the wallet's private key.
@@ -5641,7 +5645,7 @@ var BaseWalletUnlocked = class extends Account {
5641
5645
  const chainId = this.provider.getChainId();
5642
5646
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5643
5647
  const signature = await this.signer().sign(hashedTransaction);
5644
- return (0, import_utils32.hexlify)(signature);
5648
+ return (0, import_utils31.hexlify)(signature);
5645
5649
  }
5646
5650
  /**
5647
5651
  * Populates a transaction with the witnesses signature.
@@ -5704,13 +5708,13 @@ var import_crypto5 = require("@fuel-ts/crypto");
5704
5708
  var import_errors20 = require("@fuel-ts/errors");
5705
5709
  var import_hasher6 = require("@fuel-ts/hasher");
5706
5710
  var import_math23 = require("@fuel-ts/math");
5707
- var import_utils36 = require("@fuel-ts/utils");
5711
+ var import_utils35 = require("@fuel-ts/utils");
5708
5712
 
5709
5713
  // src/mnemonic/mnemonic.ts
5710
5714
  var import_crypto4 = require("@fuel-ts/crypto");
5711
5715
  var import_errors19 = require("@fuel-ts/errors");
5712
5716
  var import_hasher5 = require("@fuel-ts/hasher");
5713
- var import_utils34 = require("@fuel-ts/utils");
5717
+ var import_utils33 = require("@fuel-ts/utils");
5714
5718
 
5715
5719
  // src/wordlists/words/english.ts
5716
5720
  var english = [
@@ -7767,7 +7771,7 @@ var english = [
7767
7771
  // src/mnemonic/utils.ts
7768
7772
  var import_errors18 = require("@fuel-ts/errors");
7769
7773
  var import_hasher4 = require("@fuel-ts/hasher");
7770
- var import_utils33 = require("@fuel-ts/utils");
7774
+ var import_utils32 = require("@fuel-ts/utils");
7771
7775
  function toUtf8Bytes(stri) {
7772
7776
  const str = stri.normalize("NFKD");
7773
7777
  const result = [];
@@ -7834,14 +7838,14 @@ function entropyToMnemonicIndices(entropy) {
7834
7838
  }
7835
7839
  }
7836
7840
  const checksumBits = entropy.length / 4;
7837
- const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7841
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7838
7842
  indices[indices.length - 1] <<= checksumBits;
7839
7843
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7840
7844
  return indices;
7841
7845
  }
7842
7846
  function mnemonicWordsToEntropy(words, wordlist) {
7843
7847
  const size = Math.ceil(11 * words.length / 8);
7844
- const entropy = (0, import_utils33.arrayify)(new Uint8Array(size));
7848
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7845
7849
  let offset = 0;
7846
7850
  for (let i = 0; i < words.length; i += 1) {
7847
7851
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7861,7 +7865,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7861
7865
  const entropyBits = 32 * words.length / 3;
7862
7866
  const checksumBits = words.length / 3;
7863
7867
  const checksumMask = getUpperMask(checksumBits);
7864
- const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7868
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7865
7869
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7866
7870
  throw new import_errors18.FuelError(
7867
7871
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -7936,7 +7940,7 @@ var Mnemonic = class {
7936
7940
  static mnemonicToEntropy(phrase, wordlist = english) {
7937
7941
  const words = getWords(phrase);
7938
7942
  assertMnemonic(words);
7939
- return (0, import_utils34.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7943
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7940
7944
  }
7941
7945
  /**
7942
7946
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7944,7 +7948,7 @@ var Mnemonic = class {
7944
7948
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7945
7949
  */
7946
7950
  static entropyToMnemonic(entropy, wordlist = english) {
7947
- const entropyBytes = (0, import_utils34.arrayify)(entropy);
7951
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7948
7952
  assertWordList(wordlist);
7949
7953
  assertEntropy(entropyBytes);
7950
7954
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8013,14 +8017,14 @@ var Mnemonic = class {
8013
8017
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8014
8018
  */
8015
8019
  static masterKeysFromSeed(seed) {
8016
- const seedArray = (0, import_utils34.arrayify)(seed);
8020
+ const seedArray = (0, import_utils33.arrayify)(seed);
8017
8021
  if (seedArray.length < 16 || seedArray.length > 64) {
8018
8022
  throw new import_errors19.FuelError(
8019
8023
  import_errors19.ErrorCode.INVALID_SEED,
8020
8024
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8021
8025
  );
8022
8026
  }
8023
- return (0, import_utils34.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
8027
+ return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
8024
8028
  }
8025
8029
  /**
8026
8030
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8031,22 +8035,22 @@ var Mnemonic = class {
8031
8035
  */
8032
8036
  static seedToExtendedKey(seed, testnet = false) {
8033
8037
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8034
- const prefix = (0, import_utils34.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8038
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8035
8039
  const depth = "0x00";
8036
8040
  const fingerprint = "0x00000000";
8037
8041
  const index = "0x00000000";
8038
8042
  const chainCode = masterKey.slice(32);
8039
8043
  const privateKey = masterKey.slice(0, 32);
8040
- const extendedKey = (0, import_utils34.concat)([
8044
+ const extendedKey = (0, import_utils33.concat)([
8041
8045
  prefix,
8042
8046
  depth,
8043
8047
  fingerprint,
8044
8048
  index,
8045
8049
  chainCode,
8046
- (0, import_utils34.concat)(["0x00", privateKey])
8050
+ (0, import_utils33.concat)(["0x00", privateKey])
8047
8051
  ]);
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]));
8052
+ const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8053
+ return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8050
8054
  }
8051
8055
  /**
8052
8056
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8061,7 +8065,7 @@ var Mnemonic = class {
8061
8065
  * @returns A randomly generated mnemonic
8062
8066
  */
8063
8067
  static generate(size = 32, extraEntropy = "") {
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);
8068
+ 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);
8065
8069
  return Mnemonic.entropyToMnemonic(entropy);
8066
8070
  }
8067
8071
  };
@@ -8069,12 +8073,12 @@ var mnemonic_default = Mnemonic;
8069
8073
 
8070
8074
  // src/hdwallet/hdwallet.ts
8071
8075
  var HARDENED_INDEX = 2147483648;
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");
8076
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8077
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8078
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8079
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8076
8080
  function base58check(data) {
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)]));
8081
+ 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)]));
8078
8082
  }
8079
8083
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8080
8084
  if (isPublic) {
@@ -8083,11 +8087,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8083
8087
  return testnet ? TestnetPRV2 : MainnetPRV2;
8084
8088
  }
8085
8089
  function isPublicExtendedKey(extendedKey) {
8086
- return [MainnetPUB, TestnetPUB].includes((0, import_utils36.hexlify)(extendedKey.slice(0, 4)));
8090
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8087
8091
  }
8088
8092
  function isValidExtendedKey(extendedKey) {
8089
8093
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8090
- (0, import_utils36.hexlify)(extendedKey.slice(0, 4))
8094
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8091
8095
  );
8092
8096
  }
8093
8097
  function parsePath(path2, depth = 0) {
@@ -8105,8 +8109,8 @@ function parsePath(path2, depth = 0) {
8105
8109
  var HDWallet = class {
8106
8110
  depth = 0;
8107
8111
  index = 0;
8108
- fingerprint = (0, import_utils36.hexlify)("0x00000000");
8109
- parentFingerprint = (0, import_utils36.hexlify)("0x00000000");
8112
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8113
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8110
8114
  privateKey;
8111
8115
  publicKey;
8112
8116
  chainCode;
@@ -8118,8 +8122,8 @@ var HDWallet = class {
8118
8122
  constructor(config) {
8119
8123
  if (config.privateKey) {
8120
8124
  const signer = new Signer(config.privateKey);
8121
- this.publicKey = (0, import_utils36.hexlify)(signer.compressedPublicKey);
8122
- this.privateKey = (0, import_utils36.hexlify)(config.privateKey);
8125
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8126
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8123
8127
  } else {
8124
8128
  if (!config.publicKey) {
8125
8129
  throw new import_errors20.FuelError(
@@ -8127,10 +8131,10 @@ var HDWallet = class {
8127
8131
  "Both public and private Key cannot be missing. At least one should be provided."
8128
8132
  );
8129
8133
  }
8130
- this.publicKey = (0, import_utils36.hexlify)(config.publicKey);
8134
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8131
8135
  }
8132
8136
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8133
- this.fingerprint = (0, import_utils36.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8137
+ this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8134
8138
  this.depth = config.depth || this.depth;
8135
8139
  this.index = config.index || this.index;
8136
8140
  this.chainCode = config.chainCode;
@@ -8146,9 +8150,9 @@ var HDWallet = class {
8146
8150
  * @returns A new instance of HDWallet on the derived index
8147
8151
  */
8148
8152
  deriveIndex(index) {
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);
8153
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8154
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8155
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8152
8156
  const data = new Uint8Array(37);
8153
8157
  if (index & HARDENED_INDEX) {
8154
8158
  if (!privateKey) {
@@ -8159,10 +8163,10 @@ var HDWallet = class {
8159
8163
  }
8160
8164
  data.set(privateKey, 1);
8161
8165
  } else {
8162
- data.set((0, import_utils36.arrayify)(this.publicKey));
8166
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8163
8167
  }
8164
8168
  data.set((0, import_math23.toBytes)(index, 4), 33);
8165
- const bytes = (0, import_utils36.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
8169
+ const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
8166
8170
  const IL = bytes.slice(0, 32);
8167
8171
  const IR = bytes.slice(32);
8168
8172
  if (privateKey) {
@@ -8176,7 +8180,7 @@ var HDWallet = class {
8176
8180
  parentFingerprint: this.fingerprint
8177
8181
  });
8178
8182
  }
8179
- const signer = new Signer((0, import_utils36.hexlify)(IL));
8183
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8180
8184
  const Ki = signer.addPoint(publicKey);
8181
8185
  return new HDWallet({
8182
8186
  publicKey: Ki,
@@ -8211,12 +8215,12 @@ var HDWallet = class {
8211
8215
  );
8212
8216
  }
8213
8217
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8214
- const depth = (0, import_utils36.hexlify)(Uint8Array.from([this.depth]));
8218
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8215
8219
  const parentFingerprint = this.parentFingerprint;
8216
8220
  const index = (0, import_math23.toHex)(this.index, 4);
8217
8221
  const chainCode = this.chainCode;
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]));
8222
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8223
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8220
8224
  return base58check(extendedKey);
8221
8225
  }
8222
8226
  /**
@@ -8228,13 +8232,13 @@ var HDWallet = class {
8228
8232
  static fromSeed(seed) {
8229
8233
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8230
8234
  return new HDWallet({
8231
- chainCode: (0, import_utils36.arrayify)(masterKey.slice(32)),
8232
- privateKey: (0, import_utils36.arrayify)(masterKey.slice(0, 32))
8235
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8236
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8233
8237
  });
8234
8238
  }
8235
8239
  static fromExtendedKey(extendedKey) {
8236
- const decoded = (0, import_utils36.hexlify)((0, import_math23.toBytes)((0, import_utils36.decodeBase58)(extendedKey)));
8237
- const bytes = (0, import_utils36.arrayify)(decoded);
8240
+ const decoded = (0, import_utils35.hexlify)((0, import_math23.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
8241
+ const bytes = (0, import_utils35.arrayify)(decoded);
8238
8242
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8239
8243
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8240
8244
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8243,9 +8247,9 @@ var HDWallet = class {
8243
8247
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8244
8248
  }
8245
8249
  const depth = bytes[4];
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));
8250
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8251
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8252
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8249
8253
  const key = bytes.slice(45, 78);
8250
8254
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8251
8255
  throw new import_errors20.FuelError(
@@ -8464,7 +8468,7 @@ var generateTestWallet = async (provider, quantities) => {
8464
8468
  // src/test-utils/launchNode.ts
8465
8469
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
8466
8470
  var import_crypto7 = require("@fuel-ts/crypto");
8467
- var import_utils37 = require("@fuel-ts/utils");
8471
+ var import_utils36 = require("@fuel-ts/utils");
8468
8472
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
8469
8473
  var import_child_process = require("child_process");
8470
8474
  var import_crypto8 = require("crypto");
@@ -8504,49 +8508,15 @@ var killNode = (params) => {
8504
8508
  }
8505
8509
  }
8506
8510
  };
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
- }
8541
8511
  var launchNode = async ({
8542
8512
  ip,
8543
8513
  port,
8544
8514
  args = [],
8515
+ fuelCorePath = void 0,
8545
8516
  useSystemFuelCore = false,
8546
8517
  loggingEnabled = true,
8547
8518
  debugEnabled = false,
8548
- basePath,
8549
- snapshotConfig = import_utils37.defaultSnapshotConfigs
8519
+ basePath
8550
8520
  }) => (
8551
8521
  // eslint-disable-next-line no-async-promise-executor
8552
8522
  new Promise(async (resolve, reject) => {
@@ -8557,13 +8527,13 @@ var launchNode = async ({
8557
8527
  "--poa-instant"
8558
8528
  ]);
8559
8529
  const snapshotDir = getFlagValueFromArgs(args, "--snapshot");
8560
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils37.defaultConsensusKey;
8530
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
8561
8531
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
8562
8532
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
8563
8533
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
8564
8534
  const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
8565
8535
  const graphQLStartSubstring = "Binding GraphQL provider to";
8566
- const binPath = (0, import_cli_utils.findBinPath)("fuels-core", __dirname);
8536
+ const binPath = fuelCorePath ?? (0, import_cli_utils.findBinPath)("fuels-core", __dirname);
8567
8537
  const command = useSystemFuelCore ? "fuel-core" : binPath;
8568
8538
  const ipToUse = ip || "0.0.0.0";
8569
8539
  const portToUse = port || (await (0, import_portfinder.getPortPromise)({
@@ -8575,23 +8545,56 @@ var launchNode = async ({
8575
8545
  let snapshotDirToUse;
8576
8546
  const prefix = basePath || import_os.default.tmpdir();
8577
8547
  const suffix = basePath ? "" : (0, import_crypto8.randomUUID)();
8578
- const tempDir = import_path.default.join(prefix, ".fuels", suffix, "snapshotDir");
8548
+ const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "snapshotDir");
8579
8549
  if (snapshotDir) {
8580
8550
  snapshotDirToUse = snapshotDir;
8581
8551
  } else {
8582
- if (!(0, import_fs.existsSync)(tempDir)) {
8583
- (0, import_fs.mkdirSync)(tempDir, { recursive: true });
8552
+ if (!(0, import_fs.existsSync)(tempDirPath)) {
8553
+ (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
8584
8554
  }
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;
8555
+ let { stateConfigJson } = import_utils36.defaultSnapshotConfigs;
8556
+ const { chainConfigJson, metadataJson } = import_utils36.defaultSnapshotConfigs;
8557
+ stateConfigJson = {
8558
+ ...stateConfigJson,
8559
+ coins: [
8560
+ ...stateConfigJson.coins.map((coin) => ({
8561
+ ...coin,
8562
+ amount: "18446744073709551615"
8563
+ }))
8564
+ ],
8565
+ messages: stateConfigJson.messages.map((message) => ({
8566
+ ...message,
8567
+ amount: "18446744073709551615"
8568
+ }))
8569
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8570
+ };
8571
+ if (!process.env.GENESIS_SECRET) {
8572
+ const pk = Signer.generatePrivateKey();
8573
+ const signer = new Signer(pk);
8574
+ process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8575
+ stateConfigJson.coins.push({
8576
+ tx_id: (0, import_utils36.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
8577
+ owner: signer.address.toHexString(),
8578
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8579
+ amount: "18446744073709551615",
8580
+ asset_id: chainConfigJson.consensus_parameters.V1.base_asset_id,
8581
+ output_index: 0,
8582
+ tx_pointer_block_height: 0,
8583
+ tx_pointer_tx_idx: 0
8584
+ });
8585
+ }
8586
+ let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8587
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8588
+ fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8589
+ const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8590
+ const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8591
+ const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8592
+ const stateTransitionWritePath = import_path.default.join(tempDirPath, "state_transition_bytecode.wasm");
8593
+ (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8594
+ (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8595
+ (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8596
+ (0, import_fs.writeFileSync)(stateTransitionWritePath, JSON.stringify(""));
8597
+ snapshotDirToUse = tempDirPath;
8595
8598
  }
8596
8599
  const child = (0, import_child_process.spawn)(
8597
8600
  command,
@@ -8599,7 +8602,7 @@ var launchNode = async ({
8599
8602
  "run",
8600
8603
  ["--ip", ipToUse],
8601
8604
  ["--port", portToUse],
8602
- useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDir],
8605
+ useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8603
8606
  ["--min-gas-price", "1"],
8604
8607
  poaInstant ? ["--poa-instant", "true"] : [],
8605
8608
  ["--consensus-key", consensusKey],
@@ -8621,28 +8624,23 @@ var launchNode = async ({
8621
8624
  }
8622
8625
  const cleanupConfig = {
8623
8626
  child,
8624
- configPath: tempDir,
8627
+ configPath: tempDirPath,
8625
8628
  killFn: import_tree_kill.default,
8626
8629
  state: {
8627
8630
  isDead: false
8628
8631
  }
8629
8632
  };
8630
8633
  child.stderr.on("data", (chunk) => {
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(":");
8634
+ if (chunk.indexOf(graphQLStartSubstring) !== -1) {
8636
8635
  resolve({
8637
8636
  cleanup: () => killNode(cleanupConfig),
8638
- ip: realIp,
8639
- port: realPort,
8640
- url: `http://${realIp}:${realPort}/v1/graphql`,
8637
+ ip: ipToUse,
8638
+ port: portToUse,
8641
8639
  snapshotDir: snapshotDirToUse
8642
8640
  });
8643
8641
  }
8644
- if (/error/i.test(text)) {
8645
- reject(text.toString());
8642
+ if (/error/i.test(chunk)) {
8643
+ reject(chunk.toString());
8646
8644
  }
8647
8645
  });
8648
8646
  process.on("exit", () => killNode(cleanupConfig));
@@ -8675,238 +8673,12 @@ var launchNodeAndGetWallets = async ({
8675
8673
  };
8676
8674
  return { wallets, stop: cleanup, provider };
8677
8675
  };
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
- };
8900
8676
  // Annotate the CommonJS export names for ESM import in node:
8901
8677
  0 && (module.exports = {
8902
- AssetId,
8903
- TestMessage,
8904
- WalletConfig,
8905
8678
  generateTestWallet,
8906
8679
  killNode,
8907
8680
  launchNode,
8908
8681
  launchNodeAndGetWallets,
8909
- seedTestWallet,
8910
- setupTestProviderAndWallets
8682
+ seedTestWallet
8911
8683
  });
8912
8684
  //# sourceMappingURL=test-utils.js.map