@fuel-ts/account 0.0.0-rc-1976-20240410143455 → 0.0.0-rc-2034-20240410172045

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,8 @@ 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";
1155
+ import { randomBytes } from "@fuel-ts/crypto";
1153
1156
  import { bn as bn7 } from "@fuel-ts/math";
1154
1157
  import {
1155
1158
  PolicyType,
@@ -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;
1614
1615
  /**
1615
1616
  * Constructor for initializing a base transaction request.
1616
1617
  *
@@ -1623,9 +1624,8 @@ var BaseTransactionRequest = class {
1623
1624
  witnessLimit,
1624
1625
  inputs,
1625
1626
  outputs,
1626
- witnesses,
1627
- baseAssetId
1628
- }) {
1627
+ witnesses
1628
+ } = {}) {
1629
1629
  this.gasPrice = bn7(gasPrice);
1630
1630
  this.maturity = maturity ?? 0;
1631
1631
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 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;
1637
1636
  }
1638
1637
  static getPolicyMeta(req) {
1639
1638
  let policyTypes = 0;
@@ -1857,9 +1856,11 @@ var BaseTransactionRequest = class {
1857
1856
  *
1858
1857
  * @param message - Message resource.
1859
1858
  * @param predicate - Predicate bytes.
1859
+ * @param predicateData - Predicate data bytes.
1860
1860
  */
1861
1861
  addMessageInput(message, predicate) {
1862
1862
  const { recipient, sender, amount } = message;
1863
+ const assetId = BaseAssetId2;
1863
1864
  let witnessIndex;
1864
1865
  if (predicate) {
1865
1866
  witnessIndex = 0;
@@ -1879,7 +1880,7 @@ var BaseTransactionRequest = class {
1879
1880
  predicate: predicate?.bytes
1880
1881
  };
1881
1882
  this.pushInput(input);
1882
- this.addChangeOutput(recipient, this.baseAssetId);
1883
+ this.addChangeOutput(recipient, assetId);
1883
1884
  }
1884
1885
  /**
1885
1886
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -1940,12 +1941,12 @@ var BaseTransactionRequest = class {
1940
1941
  * @param amount - Amount of coin.
1941
1942
  * @param assetId - Asset ID of coin.
1942
1943
  */
1943
- addCoinOutput(to, amount, assetId) {
1944
+ addCoinOutput(to, amount, assetId = BaseAssetId2) {
1944
1945
  this.pushOutput({
1945
1946
  type: OutputType2.Coin,
1946
1947
  to: addressify(to).toB256(),
1947
1948
  amount,
1948
- assetId: assetId ?? this.baseAssetId
1949
+ assetId
1949
1950
  });
1950
1951
  return this;
1951
1952
  }
@@ -1972,7 +1973,7 @@ var BaseTransactionRequest = class {
1972
1973
  * @param to - Address of the owner.
1973
1974
  * @param assetId - Asset ID of coin.
1974
1975
  */
1975
- addChangeOutput(to, assetId) {
1976
+ addChangeOutput(to, assetId = BaseAssetId2) {
1976
1977
  const changeOutput = this.getChangeOutputs().find(
1977
1978
  (output) => hexlify7(output.assetId) === assetId
1978
1979
  );
@@ -1980,7 +1981,7 @@ var BaseTransactionRequest = class {
1980
1981
  this.pushOutput({
1981
1982
  type: OutputType2.Change,
1982
1983
  to: addressify(to).toB256(),
1983
- assetId: assetId ?? this.baseAssetId
1984
+ assetId
1984
1985
  });
1985
1986
  }
1986
1987
  }
@@ -2031,12 +2032,6 @@ var BaseTransactionRequest = class {
2031
2032
  * @param quantities - CoinQuantity Array.
2032
2033
  */
2033
2034
  fundWithFakeUtxos(quantities, resourcesOwner) {
2034
- let idCounter = 0;
2035
- const generateId = () => {
2036
- const counterString = String(idCounter++);
2037
- const id = ZeroBytes324.slice(0, -counterString.length).concat(counterString);
2038
- return id;
2039
- };
2040
2035
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2041
2036
  if ("assetId" in input) {
2042
2037
  return input.assetId === assetId;
@@ -2046,12 +2041,12 @@ var BaseTransactionRequest = class {
2046
2041
  const updateAssetInput = (assetId, quantity) => {
2047
2042
  const assetInput = findAssetInput(assetId);
2048
2043
  if (assetInput && "assetId" in assetInput) {
2049
- assetInput.id = generateId();
2044
+ assetInput.id = hexlify7(randomBytes(33));
2050
2045
  assetInput.amount = quantity;
2051
2046
  } else {
2052
2047
  this.addResources([
2053
2048
  {
2054
- id: generateId(),
2049
+ id: hexlify7(randomBytes(33)),
2055
2050
  amount: quantity,
2056
2051
  assetId,
2057
2052
  owner: resourcesOwner || Address.fromRandom(),
@@ -2062,7 +2057,7 @@ var BaseTransactionRequest = class {
2062
2057
  ]);
2063
2058
  }
2064
2059
  };
2065
- updateAssetInput(this.baseAssetId, bn7(1e11));
2060
+ updateAssetInput(BaseAssetId2, bn7(1e11));
2066
2061
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2067
2062
  }
2068
2063
  /**
@@ -2232,7 +2227,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2232
2227
  *
2233
2228
  * @param createTransactionRequestLike - The initial values for the instance
2234
2229
  */
2235
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2230
+ constructor({
2231
+ bytecodeWitnessIndex,
2232
+ salt,
2233
+ storageSlots,
2234
+ ...rest
2235
+ } = {}) {
2236
2236
  super(rest);
2237
2237
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2238
2238
  this.salt = hexlify9(salt ?? ZeroBytes326);
@@ -2356,7 +2356,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2356
2356
  *
2357
2357
  * @param scriptTransactionRequestLike - The initial values for the instance.
2358
2358
  */
2359
- constructor({ script, scriptData, gasLimit, ...rest }) {
2359
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2360
2360
  super(rest);
2361
2361
  this.gasLimit = bn10(gasLimit);
2362
2362
  this.script = arrayify8(script ?? returnZeroScript.bytes);
@@ -3484,7 +3484,6 @@ var processGqlChain = (chain) => {
3484
3484
  gasPerByte: bn15(feeParams.gasPerByte),
3485
3485
  maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3486
3486
  chainId: bn15(consensusParameters.chainId),
3487
- baseAssetId: consensusParameters.baseAssetId,
3488
3487
  gasCosts
3489
3488
  },
3490
3489
  gasCosts,
@@ -3727,17 +3726,6 @@ var _Provider = class {
3727
3726
  } = this.getChain();
3728
3727
  return chainId.toNumber();
3729
3728
  }
3730
- /**
3731
- * Returns the base asset ID
3732
- *
3733
- * @returns A promise that resolves to the base asset ID
3734
- */
3735
- getBaseAssetId() {
3736
- const {
3737
- consensusParameters: { baseAssetId }
3738
- } = this.getChain();
3739
- return baseAssetId;
3740
- }
3741
3729
  /**
3742
3730
  * Submits a transaction to the chain to be executed.
3743
3731
  *
@@ -3888,6 +3876,36 @@ var _Provider = class {
3888
3876
  missingContractIds
3889
3877
  };
3890
3878
  }
3879
+ /**
3880
+ * Estimates the transaction gas and fee based on the provided transaction request.
3881
+ * @param transactionRequest - The transaction request object.
3882
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3883
+ */
3884
+ estimateTxGasAndFee(params) {
3885
+ const { transactionRequest } = params;
3886
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3887
+ const chainInfo = this.getChain();
3888
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3889
+ transactionRequest.gasPrice = gasPrice;
3890
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
3891
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3892
+ if (transactionRequest.type === TransactionType8.Script) {
3893
+ if (transactionRequest.gasLimit.eq(0)) {
3894
+ transactionRequest.gasLimit = minGas;
3895
+ transactionRequest.gasLimit = maxGasPerTx.sub(
3896
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
3897
+ );
3898
+ }
3899
+ }
3900
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3901
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3902
+ return {
3903
+ minGas,
3904
+ minFee,
3905
+ maxGas,
3906
+ maxFee
3907
+ };
3908
+ }
3891
3909
  /**
3892
3910
  * Executes a signed transaction without applying the states changes
3893
3911
  * on the chain.
@@ -3935,17 +3953,16 @@ var _Provider = class {
3935
3953
  signatureCallback
3936
3954
  } = {}) {
3937
3955
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3938
- const chainInfo = this.getChain();
3939
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3940
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
3956
+ const { minGasPrice } = this.getGasConfig();
3957
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
3941
3958
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3942
3959
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3943
3960
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3944
3961
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3962
+ if (isScriptTransaction) {
3963
+ txRequestClone.gasLimit = bn15(0);
3964
+ }
3945
3965
  if (estimatePredicates) {
3946
- if (isScriptTransaction) {
3947
- txRequestClone.gasLimit = bn15(0);
3948
- }
3949
3966
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3950
3967
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
3951
3968
  }
@@ -3954,36 +3971,34 @@ var _Provider = class {
3954
3971
  if (signatureCallback && isScriptTransaction) {
3955
3972
  await signatureCallback(txRequestClone);
3956
3973
  }
3957
- const minGas = txRequestClone.calculateMinGas(chainInfo);
3958
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3974
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3975
+ transactionRequest: txRequestClone
3976
+ });
3959
3977
  let receipts = [];
3960
3978
  let missingContractIds = [];
3961
3979
  let outputVariables = 0;
3980
+ let gasUsed = bn15(0);
3962
3981
  if (isScriptTransaction && estimateTxDependencies) {
3963
3982
  txRequestClone.gasPrice = bn15(0);
3964
- txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3965
3983
  const result = await this.estimateTxDependencies(txRequestClone);
3966
3984
  receipts = result.receipts;
3967
3985
  outputVariables = result.outputVariables;
3968
3986
  missingContractIds = result.missingContractIds;
3987
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
3988
+ txRequestClone.gasLimit = gasUsed;
3989
+ txRequestClone.gasPrice = setGasPrice;
3990
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3991
+ transactionRequest: txRequestClone
3992
+ }));
3969
3993
  }
3970
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3971
- const usedFee = calculatePriceWithFactor(
3972
- gasUsed,
3973
- gasPrice,
3974
- gasPriceFactor
3975
- ).normalizeZeroToOne();
3976
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3977
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3978
3994
  return {
3979
3995
  requiredQuantities: allQuantities,
3980
3996
  receipts,
3981
3997
  gasUsed,
3982
3998
  minGasPrice,
3983
- gasPrice,
3999
+ gasPrice: setGasPrice,
3984
4000
  minGas,
3985
4001
  maxGas,
3986
- usedFee,
3987
4002
  minFee,
3988
4003
  maxFee,
3989
4004
  estimatedInputs: txRequestClone.inputs,
@@ -4608,9 +4623,8 @@ var Account = class extends AbstractAccount {
4608
4623
  * @param assetId - The asset ID to check the balance for.
4609
4624
  * @returns A promise that resolves to the balance amount.
4610
4625
  */
4611
- async getBalance(assetId) {
4612
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4613
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4626
+ async getBalance(assetId = BaseAssetId3) {
4627
+ const amount = await this.provider.getBalance(this.address, assetId);
4614
4628
  return amount;
4615
4629
  }
4616
4630
  /**
@@ -4648,10 +4662,9 @@ var Account = class extends AbstractAccount {
4648
4662
  * @returns A promise that resolves when the resources are added to the transaction.
4649
4663
  */
4650
4664
  async fund(request, coinQuantities, fee) {
4651
- const baseAssetId = this.provider.getBaseAssetId();
4652
4665
  const updatedQuantities = addAmountToAsset({
4653
4666
  amount: bn17(fee),
4654
- assetId: baseAssetId,
4667
+ assetId: BaseAssetId3,
4655
4668
  coinQuantities
4656
4669
  });
4657
4670
  const quantitiesDict = {};
@@ -4675,8 +4688,8 @@ var Account = class extends AbstractAccount {
4675
4688
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4676
4689
  cachedUtxos.push(input.id);
4677
4690
  }
4678
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4679
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4691
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4692
+ quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4680
4693
  cachedMessages.push(input.nonce);
4681
4694
  }
4682
4695
  }
@@ -4708,13 +4721,11 @@ var Account = class extends AbstractAccount {
4708
4721
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4709
4722
  * @returns A promise that resolves to the prepared transaction request.
4710
4723
  */
4711
- async createTransfer(destination, amount, assetId, txParams = {}) {
4724
+ async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4712
4725
  const { minGasPrice } = this.provider.getGasConfig();
4713
- const baseAssetId = this.provider.getBaseAssetId();
4714
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4715
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
4726
+ const params = { gasPrice: minGasPrice, ...txParams };
4716
4727
  const request = new ScriptTransactionRequest(params);
4717
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
4728
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4718
4729
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4719
4730
  estimateTxDependencies: true,
4720
4731
  resourcesOwner: this
@@ -4740,15 +4751,14 @@ var Account = class extends AbstractAccount {
4740
4751
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4741
4752
  * @returns A promise that resolves to the transaction response.
4742
4753
  */
4743
- async transfer(destination, amount, assetId, txParams = {}) {
4754
+ async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4744
4755
  if (bn17(amount).lte(0)) {
4745
4756
  throw new FuelError15(
4746
4757
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4747
4758
  "Transfer amount must be a positive number."
4748
4759
  );
4749
4760
  }
4750
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4751
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
4761
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
4752
4762
  return this.sendTransaction(request, { estimateTxDependencies: false });
4753
4763
  }
4754
4764
  /**
@@ -4760,7 +4770,7 @@ var Account = class extends AbstractAccount {
4760
4770
  * @param txParams - The optional transaction parameters.
4761
4771
  * @returns A promise that resolves to the transaction response.
4762
4772
  */
4763
- async transferToContract(contractId, amount, assetId, txParams = {}) {
4773
+ async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4764
4774
  if (bn17(amount).lte(0)) {
4765
4775
  throw new FuelError15(
4766
4776
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
@@ -4769,13 +4779,11 @@ var Account = class extends AbstractAccount {
4769
4779
  }
4770
4780
  const contractAddress = Address3.fromAddressOrString(contractId);
4771
4781
  const { minGasPrice } = this.provider.getGasConfig();
4772
- const baseAssetId = this.provider.getBaseAssetId();
4773
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4774
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
4782
+ const params = { gasPrice: minGasPrice, ...txParams };
4775
4783
  const { script, scriptData } = await assembleTransferToContractScript({
4776
4784
  hexlifiedContractId: contractAddress.toB256(),
4777
4785
  amountToTransfer: bn17(amount),
4778
- assetId: assetIdToTransfer
4786
+ assetId
4779
4787
  });
4780
4788
  const request = new ScriptTransactionRequest({
4781
4789
  ...params,
@@ -4785,7 +4793,7 @@ var Account = class extends AbstractAccount {
4785
4793
  request.addContractInputAndOutput(contractAddress);
4786
4794
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4787
4795
  request,
4788
- [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
4796
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4789
4797
  );
4790
4798
  request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4791
4799
  this.validateGas({
@@ -4807,7 +4815,6 @@ var Account = class extends AbstractAccount {
4807
4815
  */
4808
4816
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4809
4817
  const { minGasPrice } = this.provider.getGasConfig();
4810
- const baseAssetId = this.provider.getBaseAssetId();
4811
4818
  const recipientAddress = Address3.fromAddressOrString(recipient);
4812
4819
  const recipientDataArray = arrayify14(
4813
4820
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -4820,14 +4827,9 @@ var Account = class extends AbstractAccount {
4820
4827
  ...recipientDataArray,
4821
4828
  ...amountDataArray
4822
4829
  ]);
4823
- const params = {
4824
- script,
4825
- gasPrice: minGasPrice,
4826
- baseAssetId,
4827
- ...txParams
4828
- };
4830
+ const params = { script, gasPrice: minGasPrice, ...txParams };
4829
4831
  const request = new ScriptTransactionRequest(params);
4830
- const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
4832
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4831
4833
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4832
4834
  request,
4833
4835
  forwardingQuantities
@@ -4920,7 +4922,7 @@ var Account = class extends AbstractAccount {
4920
4922
 
4921
4923
  // src/signer/signer.ts
4922
4924
  import { Address as Address4 } from "@fuel-ts/address";
4923
- import { randomBytes } from "@fuel-ts/crypto";
4925
+ import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
4924
4926
  import { hash } from "@fuel-ts/hasher";
4925
4927
  import { toBytes } from "@fuel-ts/math";
4926
4928
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5013,7 +5015,7 @@ var Signer = class {
5013
5015
  * @returns random 32-byte hashed
5014
5016
  */
5015
5017
  static generatePrivateKey(entropy) {
5016
- return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5018
+ return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
5017
5019
  }
5018
5020
  /**
5019
5021
  * Extended publicKey from a compact publicKey
@@ -5032,7 +5034,7 @@ import { Address as Address5 } from "@fuel-ts/address";
5032
5034
  import {
5033
5035
  bufferFromString,
5034
5036
  keccak256,
5035
- randomBytes as randomBytes2,
5037
+ randomBytes as randomBytes3,
5036
5038
  scrypt,
5037
5039
  stringFromBuffer,
5038
5040
  decryptJsonWalletData,
@@ -5055,7 +5057,7 @@ var removeHexPrefix = (hexString) => {
5055
5057
  async function encryptKeystoreWallet(privateKey, address, password) {
5056
5058
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5057
5059
  const ownerAddress = Address5.fromAddressOrString(address);
5058
- const salt = randomBytes2(DEFAULT_KEY_SIZE);
5060
+ const salt = randomBytes3(DEFAULT_KEY_SIZE);
5059
5061
  const key = scrypt({
5060
5062
  password: bufferFromString(password),
5061
5063
  salt,
@@ -5064,7 +5066,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5064
5066
  r: DEFAULT_KDF_PARAMS_R,
5065
5067
  p: DEFAULT_KDF_PARAMS_P
5066
5068
  });
5067
- const iv = randomBytes2(DEFAULT_IV_SIZE);
5069
+ const iv = randomBytes3(DEFAULT_IV_SIZE);
5068
5070
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5069
5071
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5070
5072
  const macHashUint8Array = keccak256(data);
@@ -5246,7 +5248,7 @@ import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from
5246
5248
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5247
5249
 
5248
5250
  // src/mnemonic/mnemonic.ts
5249
- import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5251
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5250
5252
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5251
5253
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5252
5254
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
@@ -7601,7 +7603,7 @@ var Mnemonic = class {
7601
7603
  * @returns A randomly generated mnemonic
7602
7604
  */
7603
7605
  static generate(size = 32, extraEntropy = "") {
7604
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7606
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7605
7607
  return Mnemonic.entropyToMnemonic(entropy);
7606
7608
  }
7607
7609
  };
@@ -7972,17 +7974,15 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
7972
7974
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
7973
7975
 
7974
7976
  // src/test-utils/seedTestWallet.ts
7975
- import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
7977
+ import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
7976
7978
  var seedTestWallet = async (wallet, quantities) => {
7977
7979
  const genesisWallet = new WalletUnlocked(
7978
- process.env.GENESIS_SECRET || randomBytes4(32),
7980
+ process.env.GENESIS_SECRET || randomBytes5(32),
7979
7981
  wallet.provider
7980
7982
  );
7981
7983
  const resources = await genesisWallet.getResourcesToSpend(quantities);
7982
7984
  const { minGasPrice } = genesisWallet.provider.getGasConfig();
7983
- const baseAssetId = genesisWallet.provider.getBaseAssetId();
7984
7985
  const request = new ScriptTransactionRequest({
7985
- baseAssetId,
7986
7986
  gasLimit: 1e4,
7987
7987
  gasPrice: minGasPrice
7988
7988
  });
@@ -8001,7 +8001,7 @@ var generateTestWallet = async (provider, quantities) => {
8001
8001
  };
8002
8002
 
8003
8003
  // src/test-utils/launchNode.ts
8004
- import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
8004
+ import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8005
8005
  import { toHex as toHex2 } from "@fuel-ts/math";
8006
8006
  import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8007
8007
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
@@ -8101,7 +8101,7 @@ var launchNode = async ({
8101
8101
  {
8102
8102
  owner: signer.address.toHexString(),
8103
8103
  amount: toHex2(1e9),
8104
- asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes329
8104
+ asset_id: BaseAssetId4
8105
8105
  }
8106
8106
  ]
8107
8107
  }
@@ -8167,10 +8167,9 @@ var launchNode = async ({
8167
8167
  })
8168
8168
  );
8169
8169
  var generateWallets = async (count, provider) => {
8170
- const baseAssetId = provider.getBaseAssetId();
8171
8170
  const wallets = [];
8172
8171
  for (let i = 0; i < count; i += 1) {
8173
- const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
8172
+ const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId4]]);
8174
8173
  wallets.push(wallet);
8175
8174
  }
8176
8175
  return wallets;