@fuel-ts/account 0.0.0-rc-1976-20240415100843 → 0.0.0-rc-2040-20240415161332

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);
@@ -1016,7 +1018,6 @@ var MemoryCache = class {
1016
1018
  };
1017
1019
 
1018
1020
  // src/providers/transaction-request/input.ts
1019
- import { BYTES_32, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
1020
1021
  import { ZeroBytes32 } from "@fuel-ts/address/configs";
1021
1022
  import { ErrorCode as ErrorCode3, FuelError as FuelError3 } from "@fuel-ts/errors";
1022
1023
  import { bn as bn2, toNumber } from "@fuel-ts/math";
@@ -1030,8 +1031,8 @@ var inputify = (value) => {
1030
1031
  const predicateData = arrayify(value.predicateData ?? "0x");
1031
1032
  return {
1032
1033
  type: InputType.Coin,
1033
- txID: hexlify3(arrayify(value.id).slice(0, BYTES_32)),
1034
- outputIndex: toNumber(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
1034
+ txID: hexlify3(arrayify(value.id).slice(0, 32)),
1035
+ outputIndex: arrayify(value.id)[32],
1035
1036
  owner: hexlify3(value.owner),
1036
1037
  amount: bn2(value.amount),
1037
1038
  assetId: hexlify3(value.assetId),
@@ -1149,10 +1150,8 @@ var outputify = (value) => {
1149
1150
  };
1150
1151
 
1151
1152
  // src/providers/transaction-request/transaction-request.ts
1152
- import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1153
1153
  import { Address, addressify } from "@fuel-ts/address";
1154
- import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1155
- import { randomBytes } from "@fuel-ts/crypto";
1154
+ import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1156
1155
  import { bn as bn7 } from "@fuel-ts/math";
1157
1156
  import {
1158
1157
  PolicyType,
@@ -1612,8 +1611,6 @@ var BaseTransactionRequest = class {
1612
1611
  outputs = [];
1613
1612
  /** List of witnesses */
1614
1613
  witnesses = [];
1615
- /** Base asset ID - should be fetched from the chain */
1616
- baseAssetId;
1617
1614
  /**
1618
1615
  * Constructor for initializing a base transaction request.
1619
1616
  *
@@ -1626,9 +1623,8 @@ var BaseTransactionRequest = class {
1626
1623
  witnessLimit,
1627
1624
  inputs,
1628
1625
  outputs,
1629
- witnesses,
1630
- baseAssetId
1631
- }) {
1626
+ witnesses
1627
+ } = {}) {
1632
1628
  this.gasPrice = bn7(gasPrice);
1633
1629
  this.maturity = maturity ?? 0;
1634
1630
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
@@ -1636,7 +1632,6 @@ var BaseTransactionRequest = class {
1636
1632
  this.inputs = inputs ?? [];
1637
1633
  this.outputs = outputs ?? [];
1638
1634
  this.witnesses = witnesses ?? [];
1639
- this.baseAssetId = baseAssetId;
1640
1635
  }
1641
1636
  static getPolicyMeta(req) {
1642
1637
  let policyTypes = 0;
@@ -1860,9 +1855,11 @@ var BaseTransactionRequest = class {
1860
1855
  *
1861
1856
  * @param message - Message resource.
1862
1857
  * @param predicate - Predicate bytes.
1858
+ * @param predicateData - Predicate data bytes.
1863
1859
  */
1864
1860
  addMessageInput(message, predicate) {
1865
1861
  const { recipient, sender, amount } = message;
1862
+ const assetId = BaseAssetId2;
1866
1863
  let witnessIndex;
1867
1864
  if (predicate) {
1868
1865
  witnessIndex = 0;
@@ -1882,7 +1879,7 @@ var BaseTransactionRequest = class {
1882
1879
  predicate: predicate?.bytes
1883
1880
  };
1884
1881
  this.pushInput(input);
1885
- this.addChangeOutput(recipient, this.baseAssetId);
1882
+ this.addChangeOutput(recipient, assetId);
1886
1883
  }
1887
1884
  /**
1888
1885
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -1943,12 +1940,12 @@ var BaseTransactionRequest = class {
1943
1940
  * @param amount - Amount of coin.
1944
1941
  * @param assetId - Asset ID of coin.
1945
1942
  */
1946
- addCoinOutput(to, amount, assetId) {
1943
+ addCoinOutput(to, amount, assetId = BaseAssetId2) {
1947
1944
  this.pushOutput({
1948
1945
  type: OutputType2.Coin,
1949
1946
  to: addressify(to).toB256(),
1950
1947
  amount,
1951
- assetId: assetId ?? this.baseAssetId
1948
+ assetId
1952
1949
  });
1953
1950
  return this;
1954
1951
  }
@@ -1975,7 +1972,7 @@ var BaseTransactionRequest = class {
1975
1972
  * @param to - Address of the owner.
1976
1973
  * @param assetId - Asset ID of coin.
1977
1974
  */
1978
- addChangeOutput(to, assetId) {
1975
+ addChangeOutput(to, assetId = BaseAssetId2) {
1979
1976
  const changeOutput = this.getChangeOutputs().find(
1980
1977
  (output) => hexlify7(output.assetId) === assetId
1981
1978
  );
@@ -1983,7 +1980,7 @@ var BaseTransactionRequest = class {
1983
1980
  this.pushOutput({
1984
1981
  type: OutputType2.Change,
1985
1982
  to: addressify(to).toB256(),
1986
- assetId: assetId ?? this.baseAssetId
1983
+ assetId
1987
1984
  });
1988
1985
  }
1989
1986
  }
@@ -2034,6 +2031,12 @@ var BaseTransactionRequest = class {
2034
2031
  * @param quantities - CoinQuantity Array.
2035
2032
  */
2036
2033
  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
+ };
2037
2040
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2038
2041
  if ("assetId" in input) {
2039
2042
  return input.assetId === assetId;
@@ -2043,12 +2046,12 @@ var BaseTransactionRequest = class {
2043
2046
  const updateAssetInput = (assetId, quantity) => {
2044
2047
  const assetInput = findAssetInput(assetId);
2045
2048
  if (assetInput && "assetId" in assetInput) {
2046
- assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2049
+ assetInput.id = generateId();
2047
2050
  assetInput.amount = quantity;
2048
2051
  } else {
2049
2052
  this.addResources([
2050
2053
  {
2051
- id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2054
+ id: generateId(),
2052
2055
  amount: quantity,
2053
2056
  assetId,
2054
2057
  owner: resourcesOwner || Address.fromRandom(),
@@ -2059,7 +2062,7 @@ var BaseTransactionRequest = class {
2059
2062
  ]);
2060
2063
  }
2061
2064
  };
2062
- updateAssetInput(this.baseAssetId, bn7(1e11));
2065
+ updateAssetInput(BaseAssetId2, bn7(1e11));
2063
2066
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2064
2067
  }
2065
2068
  /**
@@ -2229,7 +2232,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2229
2232
  *
2230
2233
  * @param createTransactionRequestLike - The initial values for the instance
2231
2234
  */
2232
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2235
+ constructor({
2236
+ bytecodeWitnessIndex,
2237
+ salt,
2238
+ storageSlots,
2239
+ ...rest
2240
+ } = {}) {
2233
2241
  super(rest);
2234
2242
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2235
2243
  this.salt = hexlify9(salt ?? ZeroBytes326);
@@ -2353,7 +2361,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2353
2361
  *
2354
2362
  * @param scriptTransactionRequestLike - The initial values for the instance.
2355
2363
  */
2356
- constructor({ script, scriptData, gasLimit, ...rest }) {
2364
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2357
2365
  super(rest);
2358
2366
  this.gasLimit = bn10(gasLimit);
2359
2367
  this.script = arrayify8(script ?? returnZeroScript.bytes);
@@ -3481,7 +3489,6 @@ var processGqlChain = (chain) => {
3481
3489
  gasPerByte: bn15(feeParams.gasPerByte),
3482
3490
  maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3483
3491
  chainId: bn15(consensusParameters.chainId),
3484
- baseAssetId: consensusParameters.baseAssetId,
3485
3492
  gasCosts
3486
3493
  },
3487
3494
  gasCosts,
@@ -3724,17 +3731,6 @@ var _Provider = class {
3724
3731
  } = this.getChain();
3725
3732
  return chainId.toNumber();
3726
3733
  }
3727
- /**
3728
- * Returns the base asset ID
3729
- *
3730
- * @returns A promise that resolves to the base asset ID
3731
- */
3732
- getBaseAssetId() {
3733
- const {
3734
- consensusParameters: { baseAssetId }
3735
- } = this.getChain();
3736
- return baseAssetId;
3737
- }
3738
3734
  /**
3739
3735
  * Submits a transaction to the chain to be executed.
3740
3736
  *
@@ -3885,36 +3881,6 @@ var _Provider = class {
3885
3881
  missingContractIds
3886
3882
  };
3887
3883
  }
3888
- /**
3889
- * Estimates the transaction gas and fee based on the provided transaction request.
3890
- * @param transactionRequest - The transaction request object.
3891
- * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3892
- */
3893
- estimateTxGasAndFee(params) {
3894
- const { transactionRequest } = params;
3895
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3896
- const chainInfo = this.getChain();
3897
- const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3898
- transactionRequest.gasPrice = gasPrice;
3899
- const minGas = transactionRequest.calculateMinGas(chainInfo);
3900
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3901
- if (transactionRequest.type === TransactionType8.Script) {
3902
- if (transactionRequest.gasLimit.eq(0)) {
3903
- transactionRequest.gasLimit = minGas;
3904
- transactionRequest.gasLimit = maxGasPerTx.sub(
3905
- transactionRequest.calculateMaxGas(chainInfo, minGas)
3906
- );
3907
- }
3908
- }
3909
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3910
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3911
- return {
3912
- minGas,
3913
- minFee,
3914
- maxGas,
3915
- maxFee
3916
- };
3917
- }
3918
3884
  /**
3919
3885
  * Executes a signed transaction without applying the states changes
3920
3886
  * on the chain.
@@ -3962,16 +3928,17 @@ var _Provider = class {
3962
3928
  signatureCallback
3963
3929
  } = {}) {
3964
3930
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3965
- const { minGasPrice } = this.getGasConfig();
3966
- const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
3931
+ const chainInfo = this.getChain();
3932
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3933
+ const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
3967
3934
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3968
3935
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3969
3936
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3970
3937
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3971
- if (isScriptTransaction) {
3972
- txRequestClone.gasLimit = bn15(0);
3973
- }
3974
3938
  if (estimatePredicates) {
3939
+ if (isScriptTransaction) {
3940
+ txRequestClone.gasLimit = bn15(0);
3941
+ }
3975
3942
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3976
3943
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
3977
3944
  }
@@ -3980,34 +3947,36 @@ var _Provider = class {
3980
3947
  if (signatureCallback && isScriptTransaction) {
3981
3948
  await signatureCallback(txRequestClone);
3982
3949
  }
3983
- let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3984
- transactionRequest: txRequestClone
3985
- });
3950
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
3951
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3986
3952
  let receipts = [];
3987
3953
  let missingContractIds = [];
3988
3954
  let outputVariables = 0;
3989
- let gasUsed = bn15(0);
3990
3955
  if (isScriptTransaction && estimateTxDependencies) {
3991
3956
  txRequestClone.gasPrice = bn15(0);
3957
+ txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3992
3958
  const result = await this.estimateTxDependencies(txRequestClone);
3993
3959
  receipts = result.receipts;
3994
3960
  outputVariables = result.outputVariables;
3995
3961
  missingContractIds = result.missingContractIds;
3996
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
3997
- txRequestClone.gasLimit = gasUsed;
3998
- txRequestClone.gasPrice = setGasPrice;
3999
- ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4000
- transactionRequest: txRequestClone
4001
- }));
4002
3962
  }
3963
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3964
+ const usedFee = calculatePriceWithFactor(
3965
+ gasUsed,
3966
+ gasPrice,
3967
+ gasPriceFactor
3968
+ ).normalizeZeroToOne();
3969
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3970
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4003
3971
  return {
4004
3972
  requiredQuantities: allQuantities,
4005
3973
  receipts,
4006
3974
  gasUsed,
4007
3975
  minGasPrice,
4008
- gasPrice: setGasPrice,
3976
+ gasPrice,
4009
3977
  minGas,
4010
3978
  maxGas,
3979
+ usedFee,
4011
3980
  minFee,
4012
3981
  maxFee,
4013
3982
  estimatedInputs: txRequestClone.inputs,
@@ -4632,9 +4601,8 @@ var Account = class extends AbstractAccount {
4632
4601
  * @param assetId - The asset ID to check the balance for.
4633
4602
  * @returns A promise that resolves to the balance amount.
4634
4603
  */
4635
- async getBalance(assetId) {
4636
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4637
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4604
+ async getBalance(assetId = BaseAssetId3) {
4605
+ const amount = await this.provider.getBalance(this.address, assetId);
4638
4606
  return amount;
4639
4607
  }
4640
4608
  /**
@@ -4672,10 +4640,9 @@ var Account = class extends AbstractAccount {
4672
4640
  * @returns A promise that resolves when the resources are added to the transaction.
4673
4641
  */
4674
4642
  async fund(request, coinQuantities, fee) {
4675
- const baseAssetId = this.provider.getBaseAssetId();
4676
4643
  const updatedQuantities = addAmountToAsset({
4677
4644
  amount: bn17(fee),
4678
- assetId: baseAssetId,
4645
+ assetId: BaseAssetId3,
4679
4646
  coinQuantities
4680
4647
  });
4681
4648
  const quantitiesDict = {};
@@ -4699,8 +4666,8 @@ var Account = class extends AbstractAccount {
4699
4666
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4700
4667
  cachedUtxos.push(input.id);
4701
4668
  }
4702
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4703
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4669
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4670
+ quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4704
4671
  cachedMessages.push(input.nonce);
4705
4672
  }
4706
4673
  }
@@ -4732,13 +4699,11 @@ var Account = class extends AbstractAccount {
4732
4699
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4733
4700
  * @returns A promise that resolves to the prepared transaction request.
4734
4701
  */
4735
- async createTransfer(destination, amount, assetId, txParams = {}) {
4702
+ async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4736
4703
  const { minGasPrice } = this.provider.getGasConfig();
4737
- const baseAssetId = this.provider.getBaseAssetId();
4738
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4739
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
4704
+ const params = { gasPrice: minGasPrice, ...txParams };
4740
4705
  const request = new ScriptTransactionRequest(params);
4741
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
4706
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
4742
4707
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4743
4708
  estimateTxDependencies: true,
4744
4709
  resourcesOwner: this
@@ -4764,15 +4729,14 @@ var Account = class extends AbstractAccount {
4764
4729
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4765
4730
  * @returns A promise that resolves to the transaction response.
4766
4731
  */
4767
- async transfer(destination, amount, assetId, txParams = {}) {
4732
+ async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4768
4733
  if (bn17(amount).lte(0)) {
4769
4734
  throw new FuelError15(
4770
4735
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4771
4736
  "Transfer amount must be a positive number."
4772
4737
  );
4773
4738
  }
4774
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4775
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
4739
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
4776
4740
  return this.sendTransaction(request, { estimateTxDependencies: false });
4777
4741
  }
4778
4742
  /**
@@ -4784,7 +4748,7 @@ var Account = class extends AbstractAccount {
4784
4748
  * @param txParams - The optional transaction parameters.
4785
4749
  * @returns A promise that resolves to the transaction response.
4786
4750
  */
4787
- async transferToContract(contractId, amount, assetId, txParams = {}) {
4751
+ async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4788
4752
  if (bn17(amount).lte(0)) {
4789
4753
  throw new FuelError15(
4790
4754
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
@@ -4793,13 +4757,11 @@ var Account = class extends AbstractAccount {
4793
4757
  }
4794
4758
  const contractAddress = Address3.fromAddressOrString(contractId);
4795
4759
  const { minGasPrice } = this.provider.getGasConfig();
4796
- const baseAssetId = this.provider.getBaseAssetId();
4797
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
4798
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
4760
+ const params = { gasPrice: minGasPrice, ...txParams };
4799
4761
  const { script, scriptData } = await assembleTransferToContractScript({
4800
4762
  hexlifiedContractId: contractAddress.toB256(),
4801
4763
  amountToTransfer: bn17(amount),
4802
- assetId: assetIdToTransfer
4764
+ assetId
4803
4765
  });
4804
4766
  const request = new ScriptTransactionRequest({
4805
4767
  ...params,
@@ -4809,7 +4771,7 @@ var Account = class extends AbstractAccount {
4809
4771
  request.addContractInputAndOutput(contractAddress);
4810
4772
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4811
4773
  request,
4812
- [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
4774
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4813
4775
  );
4814
4776
  request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4815
4777
  this.validateGas({
@@ -4831,7 +4793,6 @@ var Account = class extends AbstractAccount {
4831
4793
  */
4832
4794
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4833
4795
  const { minGasPrice } = this.provider.getGasConfig();
4834
- const baseAssetId = this.provider.getBaseAssetId();
4835
4796
  const recipientAddress = Address3.fromAddressOrString(recipient);
4836
4797
  const recipientDataArray = arrayify14(
4837
4798
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -4844,14 +4805,9 @@ var Account = class extends AbstractAccount {
4844
4805
  ...recipientDataArray,
4845
4806
  ...amountDataArray
4846
4807
  ]);
4847
- const params = {
4848
- script,
4849
- gasPrice: minGasPrice,
4850
- baseAssetId,
4851
- ...txParams
4852
- };
4808
+ const params = { script, gasPrice: minGasPrice, ...txParams };
4853
4809
  const request = new ScriptTransactionRequest(params);
4854
- const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
4810
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4855
4811
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4856
4812
  request,
4857
4813
  forwardingQuantities
@@ -4944,7 +4900,7 @@ var Account = class extends AbstractAccount {
4944
4900
 
4945
4901
  // src/signer/signer.ts
4946
4902
  import { Address as Address4 } from "@fuel-ts/address";
4947
- import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
4903
+ import { randomBytes } from "@fuel-ts/crypto";
4948
4904
  import { hash } from "@fuel-ts/hasher";
4949
4905
  import { toBytes } from "@fuel-ts/math";
4950
4906
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5037,7 +4993,7 @@ var Signer = class {
5037
4993
  * @returns random 32-byte hashed
5038
4994
  */
5039
4995
  static generatePrivateKey(entropy) {
5040
- return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
4996
+ return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5041
4997
  }
5042
4998
  /**
5043
4999
  * Extended publicKey from a compact publicKey
@@ -5056,7 +5012,7 @@ import { Address as Address5 } from "@fuel-ts/address";
5056
5012
  import {
5057
5013
  bufferFromString,
5058
5014
  keccak256,
5059
- randomBytes as randomBytes3,
5015
+ randomBytes as randomBytes2,
5060
5016
  scrypt,
5061
5017
  stringFromBuffer,
5062
5018
  decryptJsonWalletData,
@@ -5079,7 +5035,7 @@ var removeHexPrefix = (hexString) => {
5079
5035
  async function encryptKeystoreWallet(privateKey, address, password) {
5080
5036
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5081
5037
  const ownerAddress = Address5.fromAddressOrString(address);
5082
- const salt = randomBytes3(DEFAULT_KEY_SIZE);
5038
+ const salt = randomBytes2(DEFAULT_KEY_SIZE);
5083
5039
  const key = scrypt({
5084
5040
  password: bufferFromString(password),
5085
5041
  salt,
@@ -5088,7 +5044,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5088
5044
  r: DEFAULT_KDF_PARAMS_R,
5089
5045
  p: DEFAULT_KDF_PARAMS_P
5090
5046
  });
5091
- const iv = randomBytes3(DEFAULT_IV_SIZE);
5047
+ const iv = randomBytes2(DEFAULT_IV_SIZE);
5092
5048
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5093
5049
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5094
5050
  const macHashUint8Array = keccak256(data);
@@ -5270,7 +5226,7 @@ import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from
5270
5226
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5271
5227
 
5272
5228
  // src/mnemonic/mnemonic.ts
5273
- import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5229
+ import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5274
5230
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5275
5231
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5276
5232
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
@@ -7625,7 +7581,7 @@ var Mnemonic = class {
7625
7581
  * @returns A randomly generated mnemonic
7626
7582
  */
7627
7583
  static generate(size = 32, extraEntropy = "") {
7628
- const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7584
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7629
7585
  return Mnemonic.entropyToMnemonic(entropy);
7630
7586
  }
7631
7587
  };
@@ -7996,17 +7952,15 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
7996
7952
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
7997
7953
 
7998
7954
  // src/test-utils/seedTestWallet.ts
7999
- import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
7955
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
8000
7956
  var seedTestWallet = async (wallet, quantities) => {
8001
7957
  const genesisWallet = new WalletUnlocked(
8002
- process.env.GENESIS_SECRET || randomBytes5(32),
7958
+ process.env.GENESIS_SECRET || randomBytes4(32),
8003
7959
  wallet.provider
8004
7960
  );
8005
7961
  const resources = await genesisWallet.getResourcesToSpend(quantities);
8006
7962
  const { minGasPrice } = genesisWallet.provider.getGasConfig();
8007
- const baseAssetId = genesisWallet.provider.getBaseAssetId();
8008
7963
  const request = new ScriptTransactionRequest({
8009
- baseAssetId,
8010
7964
  gasLimit: 1e4,
8011
7965
  gasPrice: minGasPrice
8012
7966
  });
@@ -8025,7 +7979,7 @@ var generateTestWallet = async (provider, quantities) => {
8025
7979
  };
8026
7980
 
8027
7981
  // src/test-utils/launchNode.ts
8028
- import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
7982
+ import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8029
7983
  import { toHex as toHex2 } from "@fuel-ts/math";
8030
7984
  import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8031
7985
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
@@ -8125,7 +8079,7 @@ var launchNode = async ({
8125
8079
  {
8126
8080
  owner: signer.address.toHexString(),
8127
8081
  amount: toHex2(1e9),
8128
- asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes329
8082
+ asset_id: BaseAssetId4
8129
8083
  }
8130
8084
  ]
8131
8085
  }
@@ -8191,10 +8145,9 @@ var launchNode = async ({
8191
8145
  })
8192
8146
  );
8193
8147
  var generateWallets = async (count, provider) => {
8194
- const baseAssetId = provider.getBaseAssetId();
8195
8148
  const wallets = [];
8196
8149
  for (let i = 0; i < count; i += 1) {
8197
- const wallet = await generateTestWallet(provider, [[1e3, baseAssetId]]);
8150
+ const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId4]]);
8198
8151
  wallets.push(wallet);
8199
8152
  }
8200
8153
  return wallets;