@fuel-ts/account 0.0.0-rc-1976-20240410103621 → 0.0.0-rc-2034-20240410113328

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.

@@ -24,12 +24,14 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
24
24
 
25
25
  // src/account.ts
26
26
  import { Address as Address3 } from "@fuel-ts/address";
27
+ import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
27
28
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
28
29
  import { AbstractAccount } from "@fuel-ts/interfaces";
29
30
  import { bn as bn17 } from "@fuel-ts/math";
30
31
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
31
32
 
32
33
  // src/providers/coin-quantity.ts
34
+ import { BaseAssetId } from "@fuel-ts/address/configs";
33
35
  import { bn } from "@fuel-ts/math";
34
36
  import { hexlify } from "@fuel-ts/utils";
35
37
  var coinQuantityfy = (coinQuantityLike) => {
@@ -38,11 +40,11 @@ var coinQuantityfy = (coinQuantityLike) => {
38
40
  let max2;
39
41
  if (Array.isArray(coinQuantityLike)) {
40
42
  amount = coinQuantityLike[0];
41
- assetId = coinQuantityLike[1];
42
- max2 = coinQuantityLike[2];
43
+ assetId = coinQuantityLike[1] ?? BaseAssetId;
44
+ max2 = coinQuantityLike[2] ?? void 0;
43
45
  } else {
44
46
  amount = coinQuantityLike.amount;
45
- assetId = coinQuantityLike.assetId;
47
+ assetId = coinQuantityLike.assetId ?? BaseAssetId;
46
48
  max2 = coinQuantityLike.max ?? void 0;
47
49
  }
48
50
  const bnAmount = bn(amount);
@@ -1030,7 +1032,7 @@ var inputify = (value) => {
1030
1032
  return {
1031
1033
  type: InputType.Coin,
1032
1034
  txID: hexlify3(arrayify(value.id).slice(0, 32)),
1033
- outputIndex: arrayify(value.id)[32],
1035
+ outputIndex: toNumber(arrayify(value.id).slice(32, 33)),
1034
1036
  owner: hexlify3(value.owner),
1035
1037
  amount: bn2(value.amount),
1036
1038
  assetId: hexlify3(value.assetId),
@@ -1149,7 +1151,7 @@ var outputify = (value) => {
1149
1151
 
1150
1152
  // src/providers/transaction-request/transaction-request.ts
1151
1153
  import { Address, addressify } from "@fuel-ts/address";
1152
- import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1154
+ import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1153
1155
  import { bn as bn7 } from "@fuel-ts/math";
1154
1156
  import {
1155
1157
  PolicyType,
@@ -1159,6 +1161,7 @@ import {
1159
1161
  TransactionType
1160
1162
  } from "@fuel-ts/transactions";
1161
1163
  import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1164
+ import { randomBytes } from "ethers";
1162
1165
 
1163
1166
  // src/providers/resource.ts
1164
1167
  var isCoin = (resource) => "id" in resource;
@@ -1609,8 +1612,6 @@ var BaseTransactionRequest = class {
1609
1612
  outputs = [];
1610
1613
  /** List of witnesses */
1611
1614
  witnesses = [];
1612
- /** Base asset ID - should be fetched from the chain */
1613
- baseAssetId = ZeroBytes324;
1614
1615
  /**
1615
1616
  * Constructor for initializing a base transaction request.
1616
1617
  *
@@ -1623,8 +1624,7 @@ var BaseTransactionRequest = class {
1623
1624
  witnessLimit,
1624
1625
  inputs,
1625
1626
  outputs,
1626
- witnesses,
1627
- baseAssetId
1627
+ witnesses
1628
1628
  } = {}) {
1629
1629
  this.gasPrice = bn7(gasPrice);
1630
1630
  this.maturity = maturity ?? 0;
@@ -1633,7 +1633,6 @@ var BaseTransactionRequest = class {
1633
1633
  this.inputs = inputs ?? [];
1634
1634
  this.outputs = outputs ?? [];
1635
1635
  this.witnesses = witnesses ?? [];
1636
- this.baseAssetId = baseAssetId ?? ZeroBytes324;
1637
1636
  }
1638
1637
  static getPolicyMeta(req) {
1639
1638
  let policyTypes = 0;
@@ -1858,9 +1857,11 @@ var BaseTransactionRequest = class {
1858
1857
  *
1859
1858
  * @param message - Message resource.
1860
1859
  * @param predicate - Predicate bytes.
1860
+ * @param predicateData - Predicate data bytes.
1861
1861
  */
1862
1862
  addMessageInput(message, predicate) {
1863
1863
  const { recipient, sender, amount } = message;
1864
+ const assetId = BaseAssetId2;
1864
1865
  let witnessIndex;
1865
1866
  if (predicate) {
1866
1867
  witnessIndex = 0;
@@ -1881,7 +1882,7 @@ var BaseTransactionRequest = class {
1881
1882
  predicateData: predicate?.predicateDataBytes
1882
1883
  };
1883
1884
  this.pushInput(input);
1884
- this.addChangeOutput(recipient, this.baseAssetId);
1885
+ this.addChangeOutput(recipient, assetId);
1885
1886
  }
1886
1887
  /**
1887
1888
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -1942,12 +1943,12 @@ var BaseTransactionRequest = class {
1942
1943
  * @param amount - Amount of coin.
1943
1944
  * @param assetId - Asset ID of coin.
1944
1945
  */
1945
- addCoinOutput(to, amount, assetId) {
1946
+ addCoinOutput(to, amount, assetId = BaseAssetId2) {
1946
1947
  this.pushOutput({
1947
1948
  type: OutputType2.Coin,
1948
1949
  to: addressify(to).toB256(),
1949
1950
  amount,
1950
- assetId: assetId ?? this.baseAssetId
1951
+ assetId
1951
1952
  });
1952
1953
  return this;
1953
1954
  }
@@ -1974,7 +1975,7 @@ var BaseTransactionRequest = class {
1974
1975
  * @param to - Address of the owner.
1975
1976
  * @param assetId - Asset ID of coin.
1976
1977
  */
1977
- addChangeOutput(to, assetId) {
1978
+ addChangeOutput(to, assetId = BaseAssetId2) {
1978
1979
  const changeOutput = this.getChangeOutputs().find(
1979
1980
  (output) => hexlify7(output.assetId) === assetId
1980
1981
  );
@@ -1982,7 +1983,7 @@ var BaseTransactionRequest = class {
1982
1983
  this.pushOutput({
1983
1984
  type: OutputType2.Change,
1984
1985
  to: addressify(to).toB256(),
1985
- assetId: assetId ?? this.baseAssetId
1986
+ assetId
1986
1987
  });
1987
1988
  }
1988
1989
  }
@@ -2033,12 +2034,6 @@ var BaseTransactionRequest = class {
2033
2034
  * @param quantities - CoinQuantity Array.
2034
2035
  */
2035
2036
  fundWithFakeUtxos(quantities, resourcesOwner) {
2036
- let idCounter = 0;
2037
- const generateId = () => {
2038
- const counterString = String(idCounter++);
2039
- const id = ZeroBytes324.slice(0, -counterString.length).concat(counterString);
2040
- return id;
2041
- };
2042
2037
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2043
2038
  if ("assetId" in input) {
2044
2039
  return input.assetId === assetId;
@@ -2048,12 +2043,12 @@ var BaseTransactionRequest = class {
2048
2043
  const updateAssetInput = (assetId, quantity) => {
2049
2044
  const assetInput = findAssetInput(assetId);
2050
2045
  if (assetInput && "assetId" in assetInput) {
2051
- assetInput.id = generateId();
2046
+ assetInput.id = hexlify7(randomBytes(33));
2052
2047
  assetInput.amount = quantity;
2053
2048
  } else {
2054
2049
  this.addResources([
2055
2050
  {
2056
- id: generateId(),
2051
+ id: hexlify7(randomBytes(33)),
2057
2052
  amount: quantity,
2058
2053
  assetId,
2059
2054
  owner: resourcesOwner || Address.fromRandom(),
@@ -2064,7 +2059,7 @@ var BaseTransactionRequest = class {
2064
2059
  ]);
2065
2060
  }
2066
2061
  };
2067
- updateAssetInput(this.baseAssetId, bn7(1e11));
2062
+ updateAssetInput(BaseAssetId2, bn7(1e11));
2068
2063
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2069
2064
  }
2070
2065
  /**
@@ -3491,7 +3486,6 @@ var processGqlChain = (chain) => {
3491
3486
  gasPerByte: bn15(feeParams.gasPerByte),
3492
3487
  maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3493
3488
  chainId: bn15(consensusParameters.chainId),
3494
- baseAssetId: consensusParameters.baseAssetId,
3495
3489
  gasCosts
3496
3490
  },
3497
3491
  gasCosts,
@@ -3734,17 +3728,6 @@ var _Provider = class {
3734
3728
  } = this.getChain();
3735
3729
  return chainId.toNumber();
3736
3730
  }
3737
- /**
3738
- * Returns the base asset ID
3739
- *
3740
- * @returns A promise that resolves to the base asset ID
3741
- */
3742
- getBaseAssetId() {
3743
- const {
3744
- consensusParameters: { baseAssetId }
3745
- } = this.getChain();
3746
- return baseAssetId;
3747
- }
3748
3731
  /**
3749
3732
  * Submits a transaction to the chain to be executed.
3750
3733
  *
@@ -3895,6 +3878,37 @@ var _Provider = class {
3895
3878
  missingContractIds
3896
3879
  };
3897
3880
  }
3881
+ /**
3882
+ * Estimates the transaction gas and fee based on the provided transaction request.
3883
+ * @param transactionRequest - The transaction request object.
3884
+ * @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
3885
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3886
+ */
3887
+ estimateTxGasAndFee(params) {
3888
+ const { transactionRequest } = params;
3889
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3890
+ const chainInfo = this.getChain();
3891
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3892
+ transactionRequest.gasPrice = gasPrice;
3893
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
3894
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3895
+ if (transactionRequest.type === TransactionType8.Script) {
3896
+ if (transactionRequest.gasLimit.eq(0)) {
3897
+ transactionRequest.gasLimit = minGas;
3898
+ transactionRequest.gasLimit = maxGasPerTx.sub(
3899
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
3900
+ );
3901
+ }
3902
+ }
3903
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3904
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3905
+ return {
3906
+ minGas,
3907
+ minFee,
3908
+ maxGas,
3909
+ maxFee
3910
+ };
3911
+ }
3898
3912
  /**
3899
3913
  * Executes a signed transaction without applying the states changes
3900
3914
  * on the chain.
@@ -3942,17 +3956,16 @@ var _Provider = class {
3942
3956
  signatureCallback
3943
3957
  } = {}) {
3944
3958
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3945
- const chainInfo = this.getChain();
3946
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3947
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
3959
+ const { minGasPrice } = this.getGasConfig();
3960
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
3948
3961
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3949
3962
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3950
3963
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3951
3964
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3965
+ if (isScriptTransaction) {
3966
+ txRequestClone.gasLimit = bn15(0);
3967
+ }
3952
3968
  if (estimatePredicates) {
3953
- if (isScriptTransaction) {
3954
- txRequestClone.gasLimit = bn15(0);
3955
- }
3956
3969
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3957
3970
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
3958
3971
  }
@@ -3961,36 +3974,34 @@ var _Provider = class {
3961
3974
  if (signatureCallback && isScriptTransaction) {
3962
3975
  await signatureCallback(txRequestClone);
3963
3976
  }
3964
- const minGas = txRequestClone.calculateMinGas(chainInfo);
3965
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3977
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3978
+ transactionRequest: txRequestClone
3979
+ });
3966
3980
  let receipts = [];
3967
3981
  let missingContractIds = [];
3968
3982
  let outputVariables = 0;
3983
+ let gasUsed = bn15(0);
3969
3984
  if (isScriptTransaction && estimateTxDependencies) {
3970
3985
  txRequestClone.gasPrice = bn15(0);
3971
- txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3972
3986
  const result = await this.estimateTxDependencies(txRequestClone);
3973
3987
  receipts = result.receipts;
3974
3988
  outputVariables = result.outputVariables;
3975
3989
  missingContractIds = result.missingContractIds;
3990
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
3991
+ txRequestClone.gasLimit = gasUsed;
3992
+ txRequestClone.gasPrice = setGasPrice;
3993
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3994
+ transactionRequest: txRequestClone
3995
+ }));
3976
3996
  }
3977
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3978
- const usedFee = calculatePriceWithFactor(
3979
- gasUsed,
3980
- gasPrice,
3981
- gasPriceFactor
3982
- ).normalizeZeroToOne();
3983
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3984
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3985
3997
  return {
3986
3998
  requiredQuantities: allQuantities,
3987
3999
  receipts,
3988
4000
  gasUsed,
3989
4001
  minGasPrice,
3990
- gasPrice,
4002
+ gasPrice: setGasPrice,
3991
4003
  minGas,
3992
4004
  maxGas,
3993
- usedFee,
3994
4005
  minFee,
3995
4006
  maxFee,
3996
4007
  estimatedInputs: txRequestClone.inputs,
@@ -4615,9 +4626,8 @@ var Account = class extends AbstractAccount {
4615
4626
  * @param assetId - The asset ID to check the balance for.
4616
4627
  * @returns A promise that resolves to the balance amount.
4617
4628
  */
4618
- async getBalance(assetId) {
4619
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4620
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4629
+ async getBalance(assetId = BaseAssetId3) {
4630
+ const amount = await this.provider.getBalance(this.address, assetId);
4621
4631
  return amount;
4622
4632
  }
4623
4633
  /**
@@ -4655,10 +4665,9 @@ var Account = class extends AbstractAccount {
4655
4665
  * @returns A promise that resolves when the resources are added to the transaction.
4656
4666
  */
4657
4667
  async fund(request, coinQuantities, fee) {
4658
- const baseAssetId = this.provider.getBaseAssetId();
4659
4668
  const updatedQuantities = addAmountToAsset({
4660
4669
  amount: bn17(fee),
4661
- assetId: baseAssetId,
4670
+ assetId: BaseAssetId3,
4662
4671
  coinQuantities
4663
4672
  });
4664
4673
  const quantitiesDict = {};
@@ -4682,8 +4691,8 @@ var Account = class extends AbstractAccount {
4682
4691
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4683
4692
  cachedUtxos.push(input.id);
4684
4693
  }
4685
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4686
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4694
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4695
+ quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4687
4696
  cachedMessages.push(input.nonce);
4688
4697
  }
4689
4698
  }
@@ -4715,12 +4724,11 @@ var Account = class extends AbstractAccount {
4715
4724
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4716
4725
  * @returns A promise that resolves to the prepared transaction request.
4717
4726
  */
4718
- async createTransfer(destination, amount, assetId, txParams = {}) {
4727
+ async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4719
4728
  const { minGasPrice } = this.provider.getGasConfig();
4720
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4721
4729
  const params = { gasPrice: minGasPrice, ...txParams };
4722
4730
  const request = new ScriptTransactionRequest(params);
4723
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
4731
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4724
4732
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4725
4733
  estimateTxDependencies: true,
4726
4734
  resourcesOwner: this
@@ -4746,15 +4754,14 @@ var Account = class extends AbstractAccount {
4746
4754
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4747
4755
  * @returns A promise that resolves to the transaction response.
4748
4756
  */
4749
- async transfer(destination, amount, assetId, txParams = {}) {
4757
+ async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4750
4758
  if (bn17(amount).lte(0)) {
4751
4759
  throw new FuelError15(
4752
4760
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4753
4761
  "Transfer amount must be a positive number."
4754
4762
  );
4755
4763
  }
4756
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4757
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
4764
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
4758
4765
  return this.sendTransaction(request, { estimateTxDependencies: false });
4759
4766
  }
4760
4767
  /**
@@ -4766,7 +4773,7 @@ var Account = class extends AbstractAccount {
4766
4773
  * @param txParams - The optional transaction parameters.
4767
4774
  * @returns A promise that resolves to the transaction response.
4768
4775
  */
4769
- async transferToContract(contractId, amount, assetId, txParams = {}) {
4776
+ async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4770
4777
  if (bn17(amount).lte(0)) {
4771
4778
  throw new FuelError15(
4772
4779
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
@@ -4775,12 +4782,11 @@ var Account = class extends AbstractAccount {
4775
4782
  }
4776
4783
  const contractAddress = Address3.fromAddressOrString(contractId);
4777
4784
  const { minGasPrice } = this.provider.getGasConfig();
4778
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4779
4785
  const params = { gasPrice: minGasPrice, ...txParams };
4780
4786
  const { script, scriptData } = await assembleTransferToContractScript({
4781
4787
  hexlifiedContractId: contractAddress.toB256(),
4782
4788
  amountToTransfer: bn17(amount),
4783
- assetId: assetIdToTransfer
4789
+ assetId
4784
4790
  });
4785
4791
  const request = new ScriptTransactionRequest({
4786
4792
  ...params,
@@ -4790,7 +4796,7 @@ var Account = class extends AbstractAccount {
4790
4796
  request.addContractInputAndOutput(contractAddress);
4791
4797
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4792
4798
  request,
4793
- [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
4799
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4794
4800
  );
4795
4801
  request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4796
4802
  this.validateGas({
@@ -4812,7 +4818,6 @@ var Account = class extends AbstractAccount {
4812
4818
  */
4813
4819
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4814
4820
  const { minGasPrice } = this.provider.getGasConfig();
4815
- const baseAssetId = this.provider.getBaseAssetId();
4816
4821
  const recipientAddress = Address3.fromAddressOrString(recipient);
4817
4822
  const recipientDataArray = arrayify14(
4818
4823
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -4827,7 +4832,7 @@ var Account = class extends AbstractAccount {
4827
4832
  ]);
4828
4833
  const params = { script, gasPrice: minGasPrice, ...txParams };
4829
4834
  const request = new ScriptTransactionRequest(params);
4830
- const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
4835
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4831
4836
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4832
4837
  request,
4833
4838
  forwardingQuantities
@@ -4920,7 +4925,7 @@ var Account = class extends AbstractAccount {
4920
4925
 
4921
4926
  // src/signer/signer.ts
4922
4927
  import { Address as Address4 } from "@fuel-ts/address";
4923
- import { randomBytes } from "@fuel-ts/crypto";
4928
+ import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
4924
4929
  import { hash } from "@fuel-ts/hasher";
4925
4930
  import { toBytes } from "@fuel-ts/math";
4926
4931
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5013,7 +5018,7 @@ var Signer = class {
5013
5018
  * @returns random 32-byte hashed
5014
5019
  */
5015
5020
  static generatePrivateKey(entropy) {
5016
- return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5021
+ return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
5017
5022
  }
5018
5023
  /**
5019
5024
  * Extended publicKey from a compact publicKey
@@ -5032,7 +5037,7 @@ import { Address as Address5 } from "@fuel-ts/address";
5032
5037
  import {
5033
5038
  bufferFromString,
5034
5039
  keccak256,
5035
- randomBytes as randomBytes2,
5040
+ randomBytes as randomBytes3,
5036
5041
  scrypt,
5037
5042
  stringFromBuffer,
5038
5043
  decryptJsonWalletData,
@@ -5055,7 +5060,7 @@ var removeHexPrefix = (hexString) => {
5055
5060
  async function encryptKeystoreWallet(privateKey, address, password) {
5056
5061
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5057
5062
  const ownerAddress = Address5.fromAddressOrString(address);
5058
- const salt = randomBytes2(DEFAULT_KEY_SIZE);
5063
+ const salt = randomBytes3(DEFAULT_KEY_SIZE);
5059
5064
  const key = scrypt({
5060
5065
  password: bufferFromString(password),
5061
5066
  salt,
@@ -5064,7 +5069,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5064
5069
  r: DEFAULT_KDF_PARAMS_R,
5065
5070
  p: DEFAULT_KDF_PARAMS_P
5066
5071
  });
5067
- const iv = randomBytes2(DEFAULT_IV_SIZE);
5072
+ const iv = randomBytes3(DEFAULT_IV_SIZE);
5068
5073
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5069
5074
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5070
5075
  const macHashUint8Array = keccak256(data);
@@ -5246,7 +5251,7 @@ import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from
5246
5251
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5247
5252
 
5248
5253
  // src/mnemonic/mnemonic.ts
5249
- import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5254
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5250
5255
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5251
5256
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5252
5257
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
@@ -7601,7 +7606,7 @@ var Mnemonic = class {
7601
7606
  * @returns A randomly generated mnemonic
7602
7607
  */
7603
7608
  static generate(size = 32, extraEntropy = "") {
7604
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7609
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7605
7610
  return Mnemonic.entropyToMnemonic(entropy);
7606
7611
  }
7607
7612
  };
@@ -7972,10 +7977,10 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
7972
7977
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
7973
7978
 
7974
7979
  // src/test-utils/seedTestWallet.ts
7975
- import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
7980
+ import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
7976
7981
  var seedTestWallet = async (wallet, quantities) => {
7977
7982
  const genesisWallet = new WalletUnlocked(
7978
- process.env.GENESIS_SECRET || randomBytes4(32),
7983
+ process.env.GENESIS_SECRET || randomBytes5(32),
7979
7984
  wallet.provider
7980
7985
  );
7981
7986
  const resources = await genesisWallet.getResourcesToSpend(quantities);
@@ -7999,7 +8004,7 @@ var generateTestWallet = async (provider, quantities) => {
7999
8004
  };
8000
8005
 
8001
8006
  // src/test-utils/launchNode.ts
8002
- import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
8007
+ import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8003
8008
  import { toHex as toHex2 } from "@fuel-ts/math";
8004
8009
  import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8005
8010
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
@@ -8099,7 +8104,7 @@ var launchNode = async ({
8099
8104
  {
8100
8105
  owner: signer.address.toHexString(),
8101
8106
  amount: toHex2(1e9),
8102
- asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes329
8107
+ asset_id: BaseAssetId4
8103
8108
  }
8104
8109
  ]
8105
8110
  }
@@ -8165,10 +8170,9 @@ var launchNode = async ({
8165
8170
  })
8166
8171
  );
8167
8172
  var generateWallets = async (count, provider) => {
8168
- const baseAssetId = provider.getBaseAssetId();
8169
8173
  const wallets = [];
8170
8174
  for (let i = 0; i < count; i += 1) {
8171
- const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
8175
+ const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId4]]);
8172
8176
  wallets.push(wallet);
8173
8177
  }
8174
8178
  return wallets;