@fuel-ts/account 0.0.0-rc-1356-20240322130951 → 0.0.0-rc-1832-20240322144804

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,21 +48,17 @@ 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_utils31 = require("@fuel-ts/utils");
61
+ var import_utils30 = require("@fuel-ts/utils");
66
62
 
67
63
  // src/account.ts
68
64
  var import_address4 = require("@fuel-ts/address");
@@ -70,7 +66,7 @@ var import_configs11 = require("@fuel-ts/address/configs");
70
66
  var import_errors15 = require("@fuel-ts/errors");
71
67
  var import_interfaces = require("@fuel-ts/interfaces");
72
68
  var import_math17 = require("@fuel-ts/math");
73
- var import_utils28 = require("@fuel-ts/utils");
69
+ var import_utils27 = require("@fuel-ts/utils");
74
70
 
75
71
  // src/providers/coin-quantity.ts
76
72
  var import_configs = require("@fuel-ts/address/configs");
@@ -113,9 +109,9 @@ var import_address3 = require("@fuel-ts/address");
113
109
  var import_errors13 = require("@fuel-ts/errors");
114
110
  var import_math14 = require("@fuel-ts/math");
115
111
  var import_transactions17 = require("@fuel-ts/transactions");
116
- var import_utils23 = require("@fuel-ts/utils");
112
+ var import_utils22 = require("@fuel-ts/utils");
117
113
  var import_versions = require("@fuel-ts/versions");
118
- var import_utils24 = require("@noble/curves/abstract/utils");
114
+ var import_utils23 = require("@noble/curves/abstract/utils");
119
115
  var import_ethers = require("ethers");
120
116
  var import_graphql_request = require("graphql-request");
121
117
  var import_ramda3 = require("ramda");
@@ -1512,6 +1508,15 @@ function normalizeJSON(root) {
1512
1508
  return normalize((0, import_ramda.clone)(root));
1513
1509
  }
1514
1510
 
1511
+ // src/providers/utils/sleep.ts
1512
+ function sleep(time) {
1513
+ return new Promise((resolve) => {
1514
+ setTimeout(() => {
1515
+ resolve(true);
1516
+ }, time);
1517
+ });
1518
+ }
1519
+
1515
1520
  // src/providers/transaction-request/errors.ts
1516
1521
  var NoWitnessAtIndexError = class extends Error {
1517
1522
  constructor(index) {
@@ -3297,7 +3302,6 @@ var import_abi_coder3 = require("@fuel-ts/abi-coder");
3297
3302
  var import_transactions16 = require("@fuel-ts/transactions");
3298
3303
 
3299
3304
  // src/providers/utils/auto-retry-fetch.ts
3300
- var import_utils22 = require("@fuel-ts/utils");
3301
3305
  function getWaitDelay(options, retryAttemptNum) {
3302
3306
  const duration = options.baseDelay ?? 150;
3303
3307
  switch (options.backoff) {
@@ -3327,7 +3331,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
3327
3331
  throw error;
3328
3332
  }
3329
3333
  const delay = getWaitDelay(options, retryNum);
3330
- await (0, import_utils22.sleep)(delay);
3334
+ await sleep(delay);
3331
3335
  return autoRetryFetch(fetchFn, options, retryNum)(...args);
3332
3336
  }
3333
3337
  };
@@ -3630,7 +3634,7 @@ var _Provider = class {
3630
3634
  if (estimateTxDependencies) {
3631
3635
  await this.estimateTxDependencies(transactionRequest);
3632
3636
  }
3633
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3637
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3634
3638
  if (awaitExecution) {
3635
3639
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3636
3640
  for await (const { submitAndAwait } of subscription) {
@@ -3669,7 +3673,7 @@ var _Provider = class {
3669
3673
  if (estimateTxDependencies) {
3670
3674
  return this.estimateTxDependencies(transactionRequest);
3671
3675
  }
3672
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3676
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3673
3677
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3674
3678
  encodedTransaction,
3675
3679
  utxoValidation: utxoValidation || false
@@ -3688,13 +3692,13 @@ var _Provider = class {
3688
3692
  async estimatePredicates(transactionRequest) {
3689
3693
  const shouldEstimatePredicates = Boolean(
3690
3694
  transactionRequest.inputs.find(
3691
- (input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
3695
+ (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
3692
3696
  )
3693
3697
  );
3694
3698
  if (!shouldEstimatePredicates) {
3695
3699
  return transactionRequest;
3696
3700
  }
3697
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3701
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3698
3702
  const response = await this.operations.estimatePredicates({
3699
3703
  encodedTransaction
3700
3704
  });
@@ -3737,7 +3741,7 @@ var _Provider = class {
3737
3741
  let outputVariables = 0;
3738
3742
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3739
3743
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3740
- encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
3744
+ encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
3741
3745
  utxoValidation: false
3742
3746
  });
3743
3747
  receipts = gqlReceipts.map(processGqlReceipt);
@@ -3775,7 +3779,7 @@ var _Provider = class {
3775
3779
  if (estimateTxDependencies) {
3776
3780
  return this.estimateTxDependencies(transactionRequest);
3777
3781
  }
3778
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3782
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3779
3783
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3780
3784
  encodedTransaction,
3781
3785
  utxoValidation: true
@@ -3885,7 +3889,7 @@ var _Provider = class {
3885
3889
  const result = await this.operations.getCoins({
3886
3890
  first: 10,
3887
3891
  ...paginationArgs,
3888
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
3892
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
3889
3893
  });
3890
3894
  const coins = result.coins.edges.map((edge) => edge.node);
3891
3895
  return coins.map((coin) => ({
@@ -3909,19 +3913,19 @@ var _Provider = class {
3909
3913
  async getResourcesToSpend(owner, quantities, excludedIds) {
3910
3914
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
3911
3915
  const excludeInput = {
3912
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
3913
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
3916
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
3917
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
3914
3918
  };
3915
3919
  if (this.cache) {
3916
3920
  const uniqueUtxos = new Set(
3917
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
3921
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
3918
3922
  );
3919
3923
  excludeInput.utxos = Array.from(uniqueUtxos);
3920
3924
  }
3921
3925
  const coinsQuery = {
3922
3926
  owner: ownerAddress.toB256(),
3923
3927
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
3924
- assetId: (0, import_utils23.hexlify)(assetId),
3928
+ assetId: (0, import_utils22.hexlify)(assetId),
3925
3929
  amount: amount.toString(10),
3926
3930
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
3927
3931
  })),
@@ -4024,7 +4028,7 @@ var _Provider = class {
4024
4028
  time: block.header.time,
4025
4029
  transactionIds: block.transactions.map((tx) => tx.id),
4026
4030
  transactions: block.transactions.map(
4027
- (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4031
+ (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4028
4032
  )
4029
4033
  };
4030
4034
  }
@@ -4040,7 +4044,7 @@ var _Provider = class {
4040
4044
  return null;
4041
4045
  }
4042
4046
  return new import_transactions17.TransactionCoder().decode(
4043
- (0, import_utils23.arrayify)(transaction.rawPayload),
4047
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4044
4048
  0
4045
4049
  )?.[0];
4046
4050
  }
@@ -4067,7 +4071,7 @@ var _Provider = class {
4067
4071
  async getContractBalance(contractId, assetId) {
4068
4072
  const { contractBalance } = await this.operations.getContractBalance({
4069
4073
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4070
- asset: (0, import_utils23.hexlify)(assetId)
4074
+ asset: (0, import_utils22.hexlify)(assetId)
4071
4075
  });
4072
4076
  return (0, import_math14.bn)(contractBalance.amount, 10);
4073
4077
  }
@@ -4081,7 +4085,7 @@ var _Provider = class {
4081
4085
  async getBalance(owner, assetId) {
4082
4086
  const { balance } = await this.operations.getBalance({
4083
4087
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4084
- assetId: (0, import_utils23.hexlify)(assetId)
4088
+ assetId: (0, import_utils22.hexlify)(assetId)
4085
4089
  });
4086
4090
  return (0, import_math14.bn)(balance.amount, 10);
4087
4091
  }
@@ -4242,7 +4246,7 @@ var _Provider = class {
4242
4246
  async produceBlocks(amount, startTime) {
4243
4247
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4244
4248
  blocksToProduce: (0, import_math14.bn)(amount).toString(10),
4245
- startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4249
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4246
4250
  });
4247
4251
  return (0, import_math14.bn)(latestBlockHeight);
4248
4252
  }
@@ -4270,7 +4274,7 @@ __publicField(Provider, "nodeInfoCache", {});
4270
4274
  var import_errors14 = require("@fuel-ts/errors");
4271
4275
  var import_math15 = require("@fuel-ts/math");
4272
4276
  var import_transactions18 = require("@fuel-ts/transactions");
4273
- var import_utils26 = require("@fuel-ts/utils");
4277
+ var import_utils25 = require("@fuel-ts/utils");
4274
4278
 
4275
4279
  // src/providers/chains.ts
4276
4280
  var CHAIN_IDS = {
@@ -4320,16 +4324,16 @@ var assets = [
4320
4324
  // src/utils/formatTransferToContractScriptData.ts
4321
4325
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
4322
4326
  var import_math16 = require("@fuel-ts/math");
4323
- var import_utils27 = require("@fuel-ts/utils");
4327
+ var import_utils26 = require("@fuel-ts/utils");
4324
4328
  var asm = __toESM(require("@fuels/vm-asm"));
4325
4329
  var formatTransferToContractScriptData = (params) => {
4326
4330
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4327
4331
  const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4328
4332
  const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4329
4333
  const scriptData = Uint8Array.from([
4330
- ...(0, import_utils27.arrayify)(hexlifiedContractId),
4334
+ ...(0, import_utils26.arrayify)(hexlifiedContractId),
4331
4335
  ...encoded,
4332
- ...(0, import_utils27.arrayify)(assetId)
4336
+ ...(0, import_utils26.arrayify)(assetId)
4333
4337
  ]);
4334
4338
  return scriptData;
4335
4339
  };
@@ -4669,14 +4673,14 @@ var Account = class extends import_interfaces.AbstractAccount {
4669
4673
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4670
4674
  const { minGasPrice } = this.provider.getGasConfig();
4671
4675
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
4672
- const recipientDataArray = (0, import_utils28.arrayify)(
4676
+ const recipientDataArray = (0, import_utils27.arrayify)(
4673
4677
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4674
4678
  );
4675
- const amountDataArray = (0, import_utils28.arrayify)(
4679
+ const amountDataArray = (0, import_utils27.arrayify)(
4676
4680
  "0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
4677
4681
  );
4678
4682
  const script = new Uint8Array([
4679
- ...(0, import_utils28.arrayify)(withdrawScript.bytes),
4683
+ ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4680
4684
  ...recipientDataArray,
4681
4685
  ...amountDataArray
4682
4686
  ]);
@@ -4763,7 +4767,7 @@ var import_address5 = require("@fuel-ts/address");
4763
4767
  var import_crypto = require("@fuel-ts/crypto");
4764
4768
  var import_hasher2 = require("@fuel-ts/hasher");
4765
4769
  var import_math18 = require("@fuel-ts/math");
4766
- var import_utils29 = require("@fuel-ts/utils");
4770
+ var import_utils28 = require("@fuel-ts/utils");
4767
4771
  var import_secp256k1 = require("@noble/curves/secp256k1");
4768
4772
  var Signer = class {
4769
4773
  address;
@@ -4783,9 +4787,9 @@ var Signer = class {
4783
4787
  }
4784
4788
  }
4785
4789
  const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
4786
- this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
4787
- this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4788
- this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4790
+ this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
4791
+ this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4792
+ this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4789
4793
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
4790
4794
  }
4791
4795
  /**
@@ -4799,11 +4803,11 @@ var Signer = class {
4799
4803
  * @returns hashed signature
4800
4804
  */
4801
4805
  sign(data) {
4802
- const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
4806
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
4803
4807
  const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
4804
4808
  const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
4805
4809
  s[0] |= (signature.recovery || 0) << 7;
4806
- return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
4810
+ return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4807
4811
  }
4808
4812
  /**
4809
4813
  * Add point on the current elliptic curve
@@ -4812,8 +4816,8 @@ var Signer = class {
4812
4816
  * @returns compressed point on the curve
4813
4817
  */
4814
4818
  addPoint(point) {
4815
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
4816
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
4819
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
4820
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
4817
4821
  const result = p0.add(p1);
4818
4822
  return `0x${result.toHex(true)}`;
4819
4823
  }
@@ -4825,16 +4829,16 @@ var Signer = class {
4825
4829
  * @returns public key from signature from the
4826
4830
  */
4827
4831
  static recoverPublicKey(data, signature) {
4828
- const signedMessageBytes = (0, import_utils29.arrayify)(signature);
4832
+ const signedMessageBytes = (0, import_utils28.arrayify)(signature);
4829
4833
  const r = signedMessageBytes.slice(0, 32);
4830
4834
  const s = signedMessageBytes.slice(32, 64);
4831
4835
  const recoveryParam = (s[0] & 128) >> 7;
4832
4836
  s[0] &= 127;
4833
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
4837
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
4834
4838
  recoveryParam
4835
4839
  );
4836
- const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
4837
- return (0, import_utils29.hexlify)(publicKey);
4840
+ const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
4841
+ return (0, import_utils28.hexlify)(publicKey);
4838
4842
  }
4839
4843
  /**
4840
4844
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -4853,7 +4857,7 @@ var Signer = class {
4853
4857
  * @returns random 32-byte hashed
4854
4858
  */
4855
4859
  static generatePrivateKey(entropy) {
4856
- return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
4860
+ return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
4857
4861
  }
4858
4862
  /**
4859
4863
  * Extended publicKey from a compact publicKey
@@ -4862,8 +4866,8 @@ var Signer = class {
4862
4866
  * @returns extended publicKey
4863
4867
  */
4864
4868
  static extendPublicKey(publicKey) {
4865
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
4866
- return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
4869
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
4870
+ return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
4867
4871
  }
4868
4872
  };
4869
4873
 
@@ -4871,7 +4875,7 @@ var Signer = class {
4871
4875
  var import_address6 = require("@fuel-ts/address");
4872
4876
  var import_crypto2 = require("@fuel-ts/crypto");
4873
4877
  var import_errors16 = require("@fuel-ts/errors");
4874
- var import_utils30 = require("@fuel-ts/utils");
4878
+ var import_utils29 = require("@fuel-ts/utils");
4875
4879
  var import_uuid = require("uuid");
4876
4880
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
4877
4881
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -4954,7 +4958,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
4954
4958
  );
4955
4959
  }
4956
4960
  const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
4957
- const privateKey = (0, import_utils30.hexlify)(buffer);
4961
+ const privateKey = (0, import_utils29.hexlify)(buffer);
4958
4962
  return privateKey;
4959
4963
  }
4960
4964
 
@@ -4999,7 +5003,7 @@ var BaseWalletUnlocked = class extends Account {
4999
5003
  */
5000
5004
  async signMessage(message) {
5001
5005
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5002
- return (0, import_utils31.hexlify)(signedMessage);
5006
+ return (0, import_utils30.hexlify)(signedMessage);
5003
5007
  }
5004
5008
  /**
5005
5009
  * Signs a transaction with the wallet's private key.
@@ -5012,7 +5016,7 @@ var BaseWalletUnlocked = class extends Account {
5012
5016
  const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
5013
5017
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5014
5018
  const signature = await this.signer().sign(hashedTransaction);
5015
- return (0, import_utils31.hexlify)(signature);
5019
+ return (0, import_utils30.hexlify)(signature);
5016
5020
  }
5017
5021
  /**
5018
5022
  * Populates a transaction with the witnesses signature.
@@ -5074,14 +5078,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5074
5078
  var import_errors19 = require("@fuel-ts/errors");
5075
5079
  var import_hasher6 = require("@fuel-ts/hasher");
5076
5080
  var import_math19 = require("@fuel-ts/math");
5077
- var import_utils35 = require("@fuel-ts/utils");
5081
+ var import_utils34 = require("@fuel-ts/utils");
5078
5082
  var import_ethers3 = require("ethers");
5079
5083
 
5080
5084
  // src/mnemonic/mnemonic.ts
5081
5085
  var import_crypto3 = require("@fuel-ts/crypto");
5082
5086
  var import_errors18 = require("@fuel-ts/errors");
5083
5087
  var import_hasher5 = require("@fuel-ts/hasher");
5084
- var import_utils33 = require("@fuel-ts/utils");
5088
+ var import_utils32 = require("@fuel-ts/utils");
5085
5089
  var import_ethers2 = require("ethers");
5086
5090
 
5087
5091
  // src/wordlists/words/english.ts
@@ -7139,7 +7143,7 @@ var english = [
7139
7143
  // src/mnemonic/utils.ts
7140
7144
  var import_errors17 = require("@fuel-ts/errors");
7141
7145
  var import_hasher4 = require("@fuel-ts/hasher");
7142
- var import_utils32 = require("@fuel-ts/utils");
7146
+ var import_utils31 = require("@fuel-ts/utils");
7143
7147
  function toUtf8Bytes(stri) {
7144
7148
  const str = stri.normalize("NFKD");
7145
7149
  const result = [];
@@ -7206,14 +7210,14 @@ function entropyToMnemonicIndices(entropy) {
7206
7210
  }
7207
7211
  }
7208
7212
  const checksumBits = entropy.length / 4;
7209
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7213
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7210
7214
  indices[indices.length - 1] <<= checksumBits;
7211
7215
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7212
7216
  return indices;
7213
7217
  }
7214
7218
  function mnemonicWordsToEntropy(words, wordlist) {
7215
7219
  const size = Math.ceil(11 * words.length / 8);
7216
- const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7220
+ const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7217
7221
  let offset = 0;
7218
7222
  for (let i = 0; i < words.length; i += 1) {
7219
7223
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7233,7 +7237,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7233
7237
  const entropyBits = 32 * words.length / 3;
7234
7238
  const checksumBits = words.length / 3;
7235
7239
  const checksumMask = getUpperMask(checksumBits);
7236
- const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7240
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7237
7241
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7238
7242
  throw new import_errors17.FuelError(
7239
7243
  import_errors17.ErrorCode.INVALID_CHECKSUM,
@@ -7308,7 +7312,7 @@ var Mnemonic = class {
7308
7312
  static mnemonicToEntropy(phrase, wordlist = english) {
7309
7313
  const words = getWords(phrase);
7310
7314
  assertMnemonic(words);
7311
- return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7315
+ return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7312
7316
  }
7313
7317
  /**
7314
7318
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7316,7 +7320,7 @@ var Mnemonic = class {
7316
7320
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7317
7321
  */
7318
7322
  static entropyToMnemonic(entropy, wordlist = english) {
7319
- const entropyBytes = (0, import_utils33.arrayify)(entropy);
7323
+ const entropyBytes = (0, import_utils32.arrayify)(entropy);
7320
7324
  assertWordList(wordlist);
7321
7325
  assertEntropy(entropyBytes);
7322
7326
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7385,14 +7389,14 @@ var Mnemonic = class {
7385
7389
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7386
7390
  */
7387
7391
  static masterKeysFromSeed(seed) {
7388
- const seedArray = (0, import_utils33.arrayify)(seed);
7392
+ const seedArray = (0, import_utils32.arrayify)(seed);
7389
7393
  if (seedArray.length < 16 || seedArray.length > 64) {
7390
7394
  throw new import_errors18.FuelError(
7391
7395
  import_errors18.ErrorCode.INVALID_SEED,
7392
7396
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7393
7397
  );
7394
7398
  }
7395
- return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7399
+ return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7396
7400
  }
7397
7401
  /**
7398
7402
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7403,22 +7407,22 @@ var Mnemonic = class {
7403
7407
  */
7404
7408
  static seedToExtendedKey(seed, testnet = false) {
7405
7409
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7406
- const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7410
+ const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7407
7411
  const depth = "0x00";
7408
7412
  const fingerprint = "0x00000000";
7409
7413
  const index = "0x00000000";
7410
7414
  const chainCode = masterKey.slice(32);
7411
7415
  const privateKey = masterKey.slice(0, 32);
7412
- const extendedKey = (0, import_utils33.concat)([
7416
+ const extendedKey = (0, import_utils32.concat)([
7413
7417
  prefix,
7414
7418
  depth,
7415
7419
  fingerprint,
7416
7420
  index,
7417
7421
  chainCode,
7418
- (0, import_utils33.concat)(["0x00", privateKey])
7422
+ (0, import_utils32.concat)(["0x00", privateKey])
7419
7423
  ]);
7420
7424
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7421
- return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7425
+ return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7422
7426
  }
7423
7427
  /**
7424
7428
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7433,7 +7437,7 @@ var Mnemonic = class {
7433
7437
  * @returns A randomly generated mnemonic
7434
7438
  */
7435
7439
  static generate(size = 32, extraEntropy = "") {
7436
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7440
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7437
7441
  return Mnemonic.entropyToMnemonic(entropy);
7438
7442
  }
7439
7443
  };
@@ -7441,12 +7445,12 @@ var mnemonic_default = Mnemonic;
7441
7445
 
7442
7446
  // src/hdwallet/hdwallet.ts
7443
7447
  var HARDENED_INDEX = 2147483648;
7444
- var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7445
- var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7446
- var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7447
- var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7448
+ var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7449
+ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7450
+ var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7451
+ var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7448
7452
  function base58check(data) {
7449
- return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7453
+ return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7450
7454
  }
7451
7455
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7452
7456
  if (isPublic) {
@@ -7455,11 +7459,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7455
7459
  return testnet ? TestnetPRV2 : MainnetPRV2;
7456
7460
  }
7457
7461
  function isPublicExtendedKey(extendedKey) {
7458
- return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7462
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7459
7463
  }
7460
7464
  function isValidExtendedKey(extendedKey) {
7461
7465
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7462
- (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7466
+ (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7463
7467
  );
7464
7468
  }
7465
7469
  function parsePath(path2, depth = 0) {
@@ -7477,8 +7481,8 @@ function parsePath(path2, depth = 0) {
7477
7481
  var HDWallet = class {
7478
7482
  depth = 0;
7479
7483
  index = 0;
7480
- fingerprint = (0, import_utils35.hexlify)("0x00000000");
7481
- parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7484
+ fingerprint = (0, import_utils34.hexlify)("0x00000000");
7485
+ parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7482
7486
  privateKey;
7483
7487
  publicKey;
7484
7488
  chainCode;
@@ -7490,8 +7494,8 @@ var HDWallet = class {
7490
7494
  constructor(config) {
7491
7495
  if (config.privateKey) {
7492
7496
  const signer = new Signer(config.privateKey);
7493
- this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7494
- this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7497
+ this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7498
+ this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7495
7499
  } else {
7496
7500
  if (!config.publicKey) {
7497
7501
  throw new import_errors19.FuelError(
@@ -7499,7 +7503,7 @@ var HDWallet = class {
7499
7503
  "Both public and private Key cannot be missing. At least one should be provided."
7500
7504
  );
7501
7505
  }
7502
- this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7506
+ this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7503
7507
  }
7504
7508
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7505
7509
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7518,9 +7522,9 @@ var HDWallet = class {
7518
7522
  * @returns A new instance of HDWallet on the derived index
7519
7523
  */
7520
7524
  deriveIndex(index) {
7521
- const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
7522
- const publicKey = (0, import_utils35.arrayify)(this.publicKey);
7523
- const chainCode = (0, import_utils35.arrayify)(this.chainCode);
7525
+ const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7526
+ const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7527
+ const chainCode = (0, import_utils34.arrayify)(this.chainCode);
7524
7528
  const data = new Uint8Array(37);
7525
7529
  if (index & HARDENED_INDEX) {
7526
7530
  if (!privateKey) {
@@ -7531,10 +7535,10 @@ var HDWallet = class {
7531
7535
  }
7532
7536
  data.set(privateKey, 1);
7533
7537
  } else {
7534
- data.set((0, import_utils35.arrayify)(this.publicKey));
7538
+ data.set((0, import_utils34.arrayify)(this.publicKey));
7535
7539
  }
7536
7540
  data.set((0, import_math19.toBytes)(index, 4), 33);
7537
- const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7541
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7538
7542
  const IL = bytes.slice(0, 32);
7539
7543
  const IR = bytes.slice(32);
7540
7544
  if (privateKey) {
@@ -7548,7 +7552,7 @@ var HDWallet = class {
7548
7552
  parentFingerprint: this.fingerprint
7549
7553
  });
7550
7554
  }
7551
- const signer = new Signer((0, import_utils35.hexlify)(IL));
7555
+ const signer = new Signer((0, import_utils34.hexlify)(IL));
7552
7556
  const Ki = signer.addPoint(publicKey);
7553
7557
  return new HDWallet({
7554
7558
  publicKey: Ki,
@@ -7583,12 +7587,12 @@ var HDWallet = class {
7583
7587
  );
7584
7588
  }
7585
7589
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7586
- const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
7590
+ const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7587
7591
  const parentFingerprint = this.parentFingerprint;
7588
7592
  const index = (0, import_math19.toHex)(this.index, 4);
7589
7593
  const chainCode = this.chainCode;
7590
- const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
7591
- const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7594
+ const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
7595
+ const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7592
7596
  return base58check(extendedKey);
7593
7597
  }
7594
7598
  /**
@@ -7600,13 +7604,13 @@ var HDWallet = class {
7600
7604
  static fromSeed(seed) {
7601
7605
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7602
7606
  return new HDWallet({
7603
- chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7604
- privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
7607
+ chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
7608
+ privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7605
7609
  });
7606
7610
  }
7607
7611
  static fromExtendedKey(extendedKey) {
7608
7612
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
7609
- const bytes = (0, import_utils35.arrayify)(decoded);
7613
+ const bytes = (0, import_utils34.arrayify)(decoded);
7610
7614
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7611
7615
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7612
7616
  throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -7615,9 +7619,9 @@ var HDWallet = class {
7615
7619
  throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7616
7620
  }
7617
7621
  const depth = bytes[4];
7618
- const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
7619
- const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7620
- const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
7622
+ const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
7623
+ const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7624
+ const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
7621
7625
  const key = bytes.slice(45, 78);
7622
7626
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7623
7627
  throw new import_errors19.FuelError(
@@ -7833,7 +7837,7 @@ var generateTestWallet = async (provider, quantities) => {
7833
7837
  // src/test-utils/launchNode.ts
7834
7838
  var import_configs12 = require("@fuel-ts/address/configs");
7835
7839
  var import_math20 = require("@fuel-ts/math");
7836
- var import_utils36 = require("@fuel-ts/utils");
7840
+ var import_utils35 = require("@fuel-ts/utils");
7837
7841
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
7838
7842
  var import_child_process = require("child_process");
7839
7843
  var import_crypto5 = require("crypto");
@@ -7880,8 +7884,7 @@ var launchNode = async ({
7880
7884
  useSystemFuelCore = false,
7881
7885
  loggingEnabled = true,
7882
7886
  debugEnabled = false,
7883
- basePath,
7884
- chainConfig = import_utils36.defaultChainConfig
7887
+ basePath
7885
7888
  }) => (
7886
7889
  // eslint-disable-next-line no-async-promise-executor
7887
7890
  new Promise(async (resolve, reject) => {
@@ -7892,7 +7895,7 @@ var launchNode = async ({
7892
7895
  "--poa-instant"
7893
7896
  ]);
7894
7897
  const chainConfigPath = getFlagValueFromArgs(args, "--chain");
7895
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
7898
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
7896
7899
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
7897
7900
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
7898
7901
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -7918,17 +7921,17 @@ var launchNode = async ({
7918
7921
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
7919
7922
  }
7920
7923
  const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
7921
- let generatedChainConfig = chainConfig;
7924
+ let chainConfig = import_utils35.defaultChainConfig;
7922
7925
  if (!process.env.GENESIS_SECRET) {
7923
7926
  const pk = Signer.generatePrivateKey();
7924
7927
  const signer = new Signer(pk);
7925
- process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
7926
- generatedChainConfig = {
7927
- ...generatedChainConfig,
7928
+ process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
7929
+ chainConfig = {
7930
+ ...import_utils35.defaultChainConfig,
7928
7931
  initial_state: {
7929
- ...generatedChainConfig.initial_state,
7932
+ ...import_utils35.defaultChainConfig.initial_state,
7930
7933
  coins: [
7931
- ...generatedChainConfig.initial_state.coins,
7934
+ ...import_utils35.defaultChainConfig.initial_state.coins,
7932
7935
  {
7933
7936
  owner: signer.address.toHexString(),
7934
7937
  amount: (0, import_math20.toHex)(1e9),
@@ -7938,7 +7941,7 @@ var launchNode = async ({
7938
7941
  }
7939
7942
  };
7940
7943
  }
7941
- (0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(generatedChainConfig), "utf8");
7944
+ (0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
7942
7945
  chainConfigPathToUse = tempChainConfigFilePath;
7943
7946
  }
7944
7947
  const child = (0, import_child_process.spawn)(
@@ -7976,21 +7979,16 @@ var launchNode = async ({
7976
7979
  }
7977
7980
  };
7978
7981
  child.stderr.on("data", (chunk) => {
7979
- const text = typeof chunk === "string" ? chunk : chunk.toString();
7980
- if (text.indexOf(graphQLStartSubstring) !== -1) {
7981
- const rows = text.split("\n");
7982
- const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
7983
- const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
7982
+ if (chunk.indexOf(graphQLStartSubstring) !== -1) {
7984
7983
  resolve({
7985
7984
  cleanup: () => killNode(cleanupConfig),
7986
- ip: realIp,
7987
- port: realPort,
7988
- url: `http://${realIp}:${realPort}/graphql`,
7985
+ ip: ipToUse,
7986
+ port: portToUse,
7989
7987
  chainConfigPath: chainConfigPathToUse
7990
7988
  });
7991
7989
  }
7992
- if (/error/i.test(text)) {
7993
- reject(text.toString());
7990
+ if (/error/i.test(chunk)) {
7991
+ reject(chunk.toString());
7994
7992
  }
7995
7993
  });
7996
7994
  process.on("exit", () => killNode(cleanupConfig));
@@ -8022,222 +8020,12 @@ var launchNodeAndGetWallets = async ({
8022
8020
  };
8023
8021
  return { wallets, stop: cleanup, provider };
8024
8022
  };
8025
-
8026
- // src/test-utils/setup-test-provider-and-wallets.ts
8027
- var import_utils38 = require("@fuel-ts/utils");
8028
- var import_ramda4 = require("ramda");
8029
-
8030
- // src/test-utils/asset-id.ts
8031
- var import_configs13 = require("@fuel-ts/address/configs");
8032
- var import_crypto6 = require("@fuel-ts/crypto");
8033
- var import_utils37 = require("@fuel-ts/utils");
8034
- var _AssetId = class {
8035
- constructor(value) {
8036
- this.value = value;
8037
- }
8038
- static random() {
8039
- return new _AssetId((0, import_utils37.hexlify)((0, import_crypto6.randomBytes)(32)));
8040
- }
8041
- };
8042
- var AssetId = _AssetId;
8043
- __publicField(AssetId, "BaseAssetId", new _AssetId(import_configs13.BaseAssetId));
8044
- __publicField(AssetId, "A", new _AssetId(
8045
- "0x0101010101010101010101010101010101010101010101010101010101010101"
8046
- ));
8047
- __publicField(AssetId, "B", new _AssetId(
8048
- "0x0202020202020202020202020202020202020202020202020202020202020202"
8049
- ));
8050
-
8051
- // src/test-utils/wallet-config.ts
8052
- var import_crypto7 = require("@fuel-ts/crypto");
8053
- var import_errors20 = require("@fuel-ts/errors");
8054
- var import_math21 = require("@fuel-ts/math");
8055
- var WalletConfig = class {
8056
- initialState;
8057
- options;
8058
- wallets;
8059
- generateWallets = () => {
8060
- const generatedWallets = [];
8061
- for (let index = 1; index <= this.options.count; index++) {
8062
- generatedWallets.push(new WalletUnlocked((0, import_crypto7.randomBytes)(32)));
8063
- }
8064
- return generatedWallets;
8065
- };
8066
- constructor(config) {
8067
- WalletConfig.guard(config);
8068
- this.options = config;
8069
- const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
8070
- this.wallets = this.generateWallets();
8071
- this.initialState = {
8072
- messages: WalletConfig.createMessages(this.wallets, messages),
8073
- coins: WalletConfig.createCoins(this.wallets, assets2, coinsPerAsset, amountPerCoin)
8074
- };
8075
- }
8076
- apply(chainConfig) {
8077
- return {
8078
- ...chainConfig,
8079
- initial_state: {
8080
- ...chainConfig?.initial_state,
8081
- coins: this.initialState.coins.concat(chainConfig?.initial_state?.coins || []),
8082
- messages: this.initialState.messages.concat(chainConfig?.initial_state?.messages ?? [])
8083
- }
8084
- };
8085
- }
8086
- static createMessages(wallets, messages) {
8087
- return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
8088
- }
8089
- static createCoins(wallets, assets2, coinsPerAsset, amountPerCoin) {
8090
- const coins = [];
8091
- let assetIds = [AssetId.BaseAssetId.value];
8092
- if (Array.isArray(assets2)) {
8093
- assetIds = assetIds.concat(assets2.map((a) => a.value));
8094
- } else {
8095
- for (let index = 0; index < assets2 - 1; index++) {
8096
- assetIds.push(AssetId.random().value);
8097
- }
8098
- }
8099
- wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
8100
- assetIds.forEach((assetId) => {
8101
- for (let index = 0; index < coinsPerAsset; index++) {
8102
- coins.push({
8103
- amount: (0, import_math21.toHex)(amountPerCoin, 8),
8104
- asset_id: assetId,
8105
- owner: walletAddress
8106
- });
8107
- }
8108
- });
8109
- });
8110
- return coins;
8111
- }
8112
- static guard({
8113
- count: wallets,
8114
- assets: assets2,
8115
- coinsPerAsset,
8116
- amountPerCoin
8117
- }) {
8118
- if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
8119
- throw new import_errors20.FuelError(
8120
- import_errors20.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8121
- "Number of wallets must be greater than zero."
8122
- );
8123
- }
8124
- if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
8125
- throw new import_errors20.FuelError(
8126
- import_errors20.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8127
- "Number of assets per wallet must be greater than zero."
8128
- );
8129
- }
8130
- if (coinsPerAsset <= 0) {
8131
- throw new import_errors20.FuelError(
8132
- import_errors20.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8133
- "Number of coins per asset must be greater than zero."
8134
- );
8135
- }
8136
- if (amountPerCoin <= 0) {
8137
- throw new import_errors20.FuelError(
8138
- import_errors20.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8139
- "Amount per coin must be greater than zero."
8140
- );
8141
- }
8142
- }
8143
- };
8144
-
8145
- // src/test-utils/setup-test-provider-and-wallets.ts
8146
- var defaultWalletConfigOptions = {
8147
- count: 2,
8148
- assets: [AssetId.A, AssetId.B],
8149
- coinsPerAsset: 1,
8150
- amountPerCoin: 1e10,
8151
- messages: []
8152
- };
8153
- async function setupTestProviderAndWallets({
8154
- walletConfig: walletConfigOptions = {},
8155
- providerOptions,
8156
- nodeOptions = {}
8157
- } = {}) {
8158
- Symbol.dispose ??= Symbol("Symbol.dispose");
8159
- const walletConfig = new WalletConfig({
8160
- ...defaultWalletConfigOptions,
8161
- ...walletConfigOptions
8162
- });
8163
- const { cleanup, url } = await launchNode({
8164
- ...nodeOptions,
8165
- chainConfig: (0, import_ramda4.mergeDeepRight)(import_utils38.defaultChainConfig, walletConfig.apply(nodeOptions?.chainConfig)),
8166
- port: "0"
8167
- });
8168
- let provider;
8169
- try {
8170
- provider = await Provider.create(url, providerOptions);
8171
- } catch (err) {
8172
- cleanup();
8173
- throw err;
8174
- }
8175
- const wallets = walletConfig.wallets;
8176
- wallets.forEach((wallet) => {
8177
- wallet.connect(provider);
8178
- });
8179
- return {
8180
- provider,
8181
- wallets,
8182
- cleanup,
8183
- [Symbol.dispose]: cleanup
8184
- };
8185
- }
8186
-
8187
- // src/test-utils/test-message.ts
8188
- var import_address7 = require("@fuel-ts/address");
8189
- var import_crypto8 = require("@fuel-ts/crypto");
8190
- var import_math22 = require("@fuel-ts/math");
8191
- var import_utils39 = require("@fuel-ts/utils");
8192
- var TestMessage = class {
8193
- sender;
8194
- recipient;
8195
- nonce;
8196
- amount;
8197
- data;
8198
- da_height;
8199
- /**
8200
- * A helper class to create messages for testing purposes.
8201
- *
8202
- * Used in tandem with `WalletConfig`.
8203
- * It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
8204
- */
8205
- constructor({
8206
- sender = import_address7.Address.fromRandom(),
8207
- recipient = import_address7.Address.fromRandom(),
8208
- nonce = (0, import_utils39.hexlify)((0, import_crypto8.randomBytes)(32)),
8209
- amount = 1e6,
8210
- data = "02",
8211
- da_height = "0x00"
8212
- } = {}) {
8213
- this.sender = sender;
8214
- this.recipient = recipient;
8215
- this.nonce = nonce;
8216
- this.amount = amount;
8217
- this.data = data;
8218
- this.da_height = da_height;
8219
- }
8220
- toChainMessage(recipient) {
8221
- return {
8222
- sender: this.sender.toB256(),
8223
- recipient: recipient?.toB256() ?? this.recipient.toB256(),
8224
- nonce: this.nonce,
8225
- amount: new import_math22.BN(this.amount).toHex(8),
8226
- data: this.data,
8227
- da_height: this.da_height
8228
- };
8229
- }
8230
- };
8231
8023
  // Annotate the CommonJS export names for ESM import in node:
8232
8024
  0 && (module.exports = {
8233
- AssetId,
8234
- TestMessage,
8235
- WalletConfig,
8236
8025
  generateTestWallet,
8237
8026
  killNode,
8238
8027
  launchNode,
8239
8028
  launchNodeAndGetWallets,
8240
- seedTestWallet,
8241
- setupTestProviderAndWallets
8029
+ seedTestWallet
8242
8030
  });
8243
8031
  //# sourceMappingURL=test-utils.js.map