@fuel-ts/account 0.0.0-rc-2034-20240410133013 → 0.0.0-rc-1976-20240410142521

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