@fuel-ts/account 0.0.0-rc-1976-20240410144111 → 0.0.0-rc-2034-20240410182856

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.

package/dist/index.mjs CHANGED
@@ -29,12 +29,14 @@ var __privateMethod = (obj, member, method) => {
29
29
 
30
30
  // src/account.ts
31
31
  import { Address as Address3 } from "@fuel-ts/address";
32
+ import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
32
33
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
33
34
  import { AbstractAccount } from "@fuel-ts/interfaces";
34
35
  import { bn as bn17 } from "@fuel-ts/math";
35
36
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
36
37
 
37
38
  // src/providers/coin-quantity.ts
39
+ import { BaseAssetId } from "@fuel-ts/address/configs";
38
40
  import { bn } from "@fuel-ts/math";
39
41
  import { hexlify } from "@fuel-ts/utils";
40
42
  var coinQuantityfy = (coinQuantityLike) => {
@@ -43,11 +45,11 @@ var coinQuantityfy = (coinQuantityLike) => {
43
45
  let max2;
44
46
  if (Array.isArray(coinQuantityLike)) {
45
47
  amount = coinQuantityLike[0];
46
- assetId = coinQuantityLike[1];
47
- max2 = coinQuantityLike[2];
48
+ assetId = coinQuantityLike[1] ?? BaseAssetId;
49
+ max2 = coinQuantityLike[2] ?? void 0;
48
50
  } else {
49
51
  amount = coinQuantityLike.amount;
50
- assetId = coinQuantityLike.assetId;
52
+ assetId = coinQuantityLike.assetId ?? BaseAssetId;
51
53
  max2 = coinQuantityLike.max ?? void 0;
52
54
  }
53
55
  const bnAmount = bn(amount);
@@ -1021,6 +1023,7 @@ var MemoryCache = class {
1021
1023
  };
1022
1024
 
1023
1025
  // src/providers/transaction-request/input.ts
1026
+ import { BYTES_32, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
1024
1027
  import { ZeroBytes32 } from "@fuel-ts/address/configs";
1025
1028
  import { ErrorCode as ErrorCode3, FuelError as FuelError3 } from "@fuel-ts/errors";
1026
1029
  import { bn as bn2, toNumber } from "@fuel-ts/math";
@@ -1034,8 +1037,8 @@ var inputify = (value) => {
1034
1037
  const predicateData = arrayify(value.predicateData ?? "0x");
1035
1038
  return {
1036
1039
  type: InputType.Coin,
1037
- txID: hexlify3(arrayify(value.id).slice(0, 32)),
1038
- outputIndex: arrayify(value.id)[32],
1040
+ txID: hexlify3(arrayify(value.id).slice(0, BYTES_32)),
1041
+ outputIndex: toNumber(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
1039
1042
  owner: hexlify3(value.owner),
1040
1043
  amount: bn2(value.amount),
1041
1044
  assetId: hexlify3(value.assetId),
@@ -1153,8 +1156,10 @@ var outputify = (value) => {
1153
1156
  };
1154
1157
 
1155
1158
  // src/providers/transaction-request/transaction-request.ts
1159
+ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1156
1160
  import { Address, addressify } from "@fuel-ts/address";
1157
- import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1161
+ import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1162
+ import { randomBytes } from "@fuel-ts/crypto";
1158
1163
  import { bn as bn7 } from "@fuel-ts/math";
1159
1164
  import {
1160
1165
  PolicyType,
@@ -1688,8 +1693,6 @@ var BaseTransactionRequest = class {
1688
1693
  outputs = [];
1689
1694
  /** List of witnesses */
1690
1695
  witnesses = [];
1691
- /** Base asset ID - should be fetched from the chain */
1692
- baseAssetId;
1693
1696
  /**
1694
1697
  * Constructor for initializing a base transaction request.
1695
1698
  *
@@ -1702,9 +1705,8 @@ var BaseTransactionRequest = class {
1702
1705
  witnessLimit,
1703
1706
  inputs,
1704
1707
  outputs,
1705
- witnesses,
1706
- baseAssetId
1707
- }) {
1708
+ witnesses
1709
+ } = {}) {
1708
1710
  this.gasPrice = bn7(gasPrice);
1709
1711
  this.maturity = maturity ?? 0;
1710
1712
  this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
@@ -1712,7 +1714,6 @@ var BaseTransactionRequest = class {
1712
1714
  this.inputs = inputs ?? [];
1713
1715
  this.outputs = outputs ?? [];
1714
1716
  this.witnesses = witnesses ?? [];
1715
- this.baseAssetId = baseAssetId;
1716
1717
  }
1717
1718
  static getPolicyMeta(req) {
1718
1719
  let policyTypes = 0;
@@ -1936,9 +1937,11 @@ var BaseTransactionRequest = class {
1936
1937
  *
1937
1938
  * @param message - Message resource.
1938
1939
  * @param predicate - Predicate bytes.
1940
+ * @param predicateData - Predicate data bytes.
1939
1941
  */
1940
1942
  addMessageInput(message, predicate) {
1941
1943
  const { recipient, sender, amount } = message;
1944
+ const assetId = BaseAssetId2;
1942
1945
  let witnessIndex;
1943
1946
  if (predicate) {
1944
1947
  witnessIndex = 0;
@@ -1958,7 +1961,7 @@ var BaseTransactionRequest = class {
1958
1961
  predicate: predicate?.bytes
1959
1962
  };
1960
1963
  this.pushInput(input);
1961
- this.addChangeOutput(recipient, this.baseAssetId);
1964
+ this.addChangeOutput(recipient, assetId);
1962
1965
  }
1963
1966
  /**
1964
1967
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2019,12 +2022,12 @@ var BaseTransactionRequest = class {
2019
2022
  * @param amount - Amount of coin.
2020
2023
  * @param assetId - Asset ID of coin.
2021
2024
  */
2022
- addCoinOutput(to, amount, assetId) {
2025
+ addCoinOutput(to, amount, assetId = BaseAssetId2) {
2023
2026
  this.pushOutput({
2024
2027
  type: OutputType2.Coin,
2025
2028
  to: addressify(to).toB256(),
2026
2029
  amount,
2027
- assetId: assetId ?? this.baseAssetId
2030
+ assetId
2028
2031
  });
2029
2032
  return this;
2030
2033
  }
@@ -2051,7 +2054,7 @@ var BaseTransactionRequest = class {
2051
2054
  * @param to - Address of the owner.
2052
2055
  * @param assetId - Asset ID of coin.
2053
2056
  */
2054
- addChangeOutput(to, assetId) {
2057
+ addChangeOutput(to, assetId = BaseAssetId2) {
2055
2058
  const changeOutput = this.getChangeOutputs().find(
2056
2059
  (output) => hexlify7(output.assetId) === assetId
2057
2060
  );
@@ -2059,7 +2062,7 @@ var BaseTransactionRequest = class {
2059
2062
  this.pushOutput({
2060
2063
  type: OutputType2.Change,
2061
2064
  to: addressify(to).toB256(),
2062
- assetId: assetId ?? this.baseAssetId
2065
+ assetId
2063
2066
  });
2064
2067
  }
2065
2068
  }
@@ -2110,12 +2113,6 @@ var BaseTransactionRequest = class {
2110
2113
  * @param quantities - CoinQuantity Array.
2111
2114
  */
2112
2115
  fundWithFakeUtxos(quantities, resourcesOwner) {
2113
- let idCounter = 0;
2114
- const generateId = () => {
2115
- const counterString = String(idCounter++);
2116
- const id = ZeroBytes324.slice(0, -counterString.length).concat(counterString);
2117
- return id;
2118
- };
2119
2116
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2120
2117
  if ("assetId" in input) {
2121
2118
  return input.assetId === assetId;
@@ -2125,12 +2122,12 @@ var BaseTransactionRequest = class {
2125
2122
  const updateAssetInput = (assetId, quantity) => {
2126
2123
  const assetInput = findAssetInput(assetId);
2127
2124
  if (assetInput && "assetId" in assetInput) {
2128
- assetInput.id = generateId();
2125
+ assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2129
2126
  assetInput.amount = quantity;
2130
2127
  } else {
2131
2128
  this.addResources([
2132
2129
  {
2133
- id: generateId(),
2130
+ id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2134
2131
  amount: quantity,
2135
2132
  assetId,
2136
2133
  owner: resourcesOwner || Address.fromRandom(),
@@ -2141,7 +2138,7 @@ var BaseTransactionRequest = class {
2141
2138
  ]);
2142
2139
  }
2143
2140
  };
2144
- updateAssetInput(this.baseAssetId, bn7(1e11));
2141
+ updateAssetInput(BaseAssetId2, bn7(1e11));
2145
2142
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2146
2143
  }
2147
2144
  /**
@@ -2311,7 +2308,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2311
2308
  *
2312
2309
  * @param createTransactionRequestLike - The initial values for the instance
2313
2310
  */
2314
- constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
2311
+ constructor({
2312
+ bytecodeWitnessIndex,
2313
+ salt,
2314
+ storageSlots,
2315
+ ...rest
2316
+ } = {}) {
2315
2317
  super(rest);
2316
2318
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2317
2319
  this.salt = hexlify9(salt ?? ZeroBytes326);
@@ -2435,7 +2437,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2435
2437
  *
2436
2438
  * @param scriptTransactionRequestLike - The initial values for the instance.
2437
2439
  */
2438
- constructor({ script, scriptData, gasLimit, ...rest }) {
2440
+ constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2439
2441
  super(rest);
2440
2442
  this.gasLimit = bn10(gasLimit);
2441
2443
  this.script = arrayify8(script ?? returnZeroScript.bytes);
@@ -3610,7 +3612,6 @@ var processGqlChain = (chain) => {
3610
3612
  gasPerByte: bn15(feeParams.gasPerByte),
3611
3613
  maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3612
3614
  chainId: bn15(consensusParameters.chainId),
3613
- baseAssetId: consensusParameters.baseAssetId,
3614
3615
  gasCosts
3615
3616
  },
3616
3617
  gasCosts,
@@ -3853,17 +3854,6 @@ var _Provider = class {
3853
3854
  } = this.getChain();
3854
3855
  return chainId.toNumber();
3855
3856
  }
3856
- /**
3857
- * Returns the base asset ID
3858
- *
3859
- * @returns A promise that resolves to the base asset ID
3860
- */
3861
- getBaseAssetId() {
3862
- const {
3863
- consensusParameters: { baseAssetId }
3864
- } = this.getChain();
3865
- return baseAssetId;
3866
- }
3867
3857
  /**
3868
3858
  * Submits a transaction to the chain to be executed.
3869
3859
  *
@@ -4014,6 +4004,36 @@ var _Provider = class {
4014
4004
  missingContractIds
4015
4005
  };
4016
4006
  }
4007
+ /**
4008
+ * Estimates the transaction gas and fee based on the provided transaction request.
4009
+ * @param transactionRequest - The transaction request object.
4010
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4011
+ */
4012
+ estimateTxGasAndFee(params) {
4013
+ const { transactionRequest } = params;
4014
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4015
+ const chainInfo = this.getChain();
4016
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4017
+ transactionRequest.gasPrice = gasPrice;
4018
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4019
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4020
+ if (transactionRequest.type === TransactionType8.Script) {
4021
+ if (transactionRequest.gasLimit.eq(0)) {
4022
+ transactionRequest.gasLimit = minGas;
4023
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4024
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4025
+ );
4026
+ }
4027
+ }
4028
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4029
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4030
+ return {
4031
+ minGas,
4032
+ minFee,
4033
+ maxGas,
4034
+ maxFee
4035
+ };
4036
+ }
4017
4037
  /**
4018
4038
  * Executes a signed transaction without applying the states changes
4019
4039
  * on the chain.
@@ -4061,17 +4081,16 @@ var _Provider = class {
4061
4081
  signatureCallback
4062
4082
  } = {}) {
4063
4083
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4064
- const chainInfo = this.getChain();
4065
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4066
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
4084
+ const { minGasPrice } = this.getGasConfig();
4085
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4067
4086
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4068
4087
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4069
4088
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4070
4089
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4090
+ if (isScriptTransaction) {
4091
+ txRequestClone.gasLimit = bn15(0);
4092
+ }
4071
4093
  if (estimatePredicates) {
4072
- if (isScriptTransaction) {
4073
- txRequestClone.gasLimit = bn15(0);
4074
- }
4075
4094
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4076
4095
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
4077
4096
  }
@@ -4080,36 +4099,34 @@ var _Provider = class {
4080
4099
  if (signatureCallback && isScriptTransaction) {
4081
4100
  await signatureCallback(txRequestClone);
4082
4101
  }
4083
- const minGas = txRequestClone.calculateMinGas(chainInfo);
4084
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4102
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4103
+ transactionRequest: txRequestClone
4104
+ });
4085
4105
  let receipts = [];
4086
4106
  let missingContractIds = [];
4087
4107
  let outputVariables = 0;
4108
+ let gasUsed = bn15(0);
4088
4109
  if (isScriptTransaction && estimateTxDependencies) {
4089
4110
  txRequestClone.gasPrice = bn15(0);
4090
- txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4091
4111
  const result = await this.estimateTxDependencies(txRequestClone);
4092
4112
  receipts = result.receipts;
4093
4113
  outputVariables = result.outputVariables;
4094
4114
  missingContractIds = result.missingContractIds;
4115
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4116
+ txRequestClone.gasLimit = gasUsed;
4117
+ txRequestClone.gasPrice = setGasPrice;
4118
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4119
+ transactionRequest: txRequestClone
4120
+ }));
4095
4121
  }
4096
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4097
- const usedFee = calculatePriceWithFactor(
4098
- gasUsed,
4099
- gasPrice,
4100
- gasPriceFactor
4101
- ).normalizeZeroToOne();
4102
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4103
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4104
4122
  return {
4105
4123
  requiredQuantities: allQuantities,
4106
4124
  receipts,
4107
4125
  gasUsed,
4108
4126
  minGasPrice,
4109
- gasPrice,
4127
+ gasPrice: setGasPrice,
4110
4128
  minGas,
4111
4129
  maxGas,
4112
- usedFee,
4113
4130
  minFee,
4114
4131
  maxFee,
4115
4132
  estimatedInputs: txRequestClone.inputs,
@@ -4900,9 +4917,8 @@ var Account = class extends AbstractAccount {
4900
4917
  * @param assetId - The asset ID to check the balance for.
4901
4918
  * @returns A promise that resolves to the balance amount.
4902
4919
  */
4903
- async getBalance(assetId) {
4904
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4905
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4920
+ async getBalance(assetId = BaseAssetId3) {
4921
+ const amount = await this.provider.getBalance(this.address, assetId);
4906
4922
  return amount;
4907
4923
  }
4908
4924
  /**
@@ -4940,10 +4956,9 @@ var Account = class extends AbstractAccount {
4940
4956
  * @returns A promise that resolves when the resources are added to the transaction.
4941
4957
  */
4942
4958
  async fund(request, coinQuantities, fee) {
4943
- const baseAssetId = this.provider.getBaseAssetId();
4944
4959
  const updatedQuantities = addAmountToAsset({
4945
4960
  amount: bn17(fee),
4946
- assetId: baseAssetId,
4961
+ assetId: BaseAssetId3,
4947
4962
  coinQuantities
4948
4963
  });
4949
4964
  const quantitiesDict = {};
@@ -4967,8 +4982,8 @@ var Account = class extends AbstractAccount {
4967
4982
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4968
4983
  cachedUtxos.push(input.id);
4969
4984
  }
4970
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4971
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4985
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4986
+ quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4972
4987
  cachedMessages.push(input.nonce);
4973
4988
  }
4974
4989
  }
@@ -5000,13 +5015,11 @@ var Account = class extends AbstractAccount {
5000
5015
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5001
5016
  * @returns A promise that resolves to the prepared transaction request.
5002
5017
  */
5003
- async createTransfer(destination, amount, assetId, txParams = {}) {
5018
+ async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5004
5019
  const { minGasPrice } = this.provider.getGasConfig();
5005
- const baseAssetId = this.provider.getBaseAssetId();
5006
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5007
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5020
+ const params = { gasPrice: minGasPrice, ...txParams };
5008
5021
  const request = new ScriptTransactionRequest(params);
5009
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
5022
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5010
5023
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5011
5024
  estimateTxDependencies: true,
5012
5025
  resourcesOwner: this
@@ -5032,15 +5045,14 @@ var Account = class extends AbstractAccount {
5032
5045
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5033
5046
  * @returns A promise that resolves to the transaction response.
5034
5047
  */
5035
- async transfer(destination, amount, assetId, txParams = {}) {
5048
+ async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5036
5049
  if (bn17(amount).lte(0)) {
5037
5050
  throw new FuelError15(
5038
5051
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5039
5052
  "Transfer amount must be a positive number."
5040
5053
  );
5041
5054
  }
5042
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5043
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5055
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
5044
5056
  return this.sendTransaction(request, { estimateTxDependencies: false });
5045
5057
  }
5046
5058
  /**
@@ -5052,7 +5064,7 @@ var Account = class extends AbstractAccount {
5052
5064
  * @param txParams - The optional transaction parameters.
5053
5065
  * @returns A promise that resolves to the transaction response.
5054
5066
  */
5055
- async transferToContract(contractId, amount, assetId, txParams = {}) {
5067
+ async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5056
5068
  if (bn17(amount).lte(0)) {
5057
5069
  throw new FuelError15(
5058
5070
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
@@ -5061,13 +5073,11 @@ var Account = class extends AbstractAccount {
5061
5073
  }
5062
5074
  const contractAddress = Address3.fromAddressOrString(contractId);
5063
5075
  const { minGasPrice } = this.provider.getGasConfig();
5064
- const baseAssetId = this.provider.getBaseAssetId();
5065
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5066
- const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
5076
+ const params = { gasPrice: minGasPrice, ...txParams };
5067
5077
  const { script, scriptData } = await assembleTransferToContractScript({
5068
5078
  hexlifiedContractId: contractAddress.toB256(),
5069
5079
  amountToTransfer: bn17(amount),
5070
- assetId: assetIdToTransfer
5080
+ assetId
5071
5081
  });
5072
5082
  const request = new ScriptTransactionRequest({
5073
5083
  ...params,
@@ -5077,7 +5087,7 @@ var Account = class extends AbstractAccount {
5077
5087
  request.addContractInputAndOutput(contractAddress);
5078
5088
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5079
5089
  request,
5080
- [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
5090
+ [{ amount: bn17(amount), assetId: String(assetId) }]
5081
5091
  );
5082
5092
  request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5083
5093
  this.validateGas({
@@ -5099,7 +5109,6 @@ var Account = class extends AbstractAccount {
5099
5109
  */
5100
5110
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5101
5111
  const { minGasPrice } = this.provider.getGasConfig();
5102
- const baseAssetId = this.provider.getBaseAssetId();
5103
5112
  const recipientAddress = Address3.fromAddressOrString(recipient);
5104
5113
  const recipientDataArray = arrayify14(
5105
5114
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -5112,14 +5121,9 @@ var Account = class extends AbstractAccount {
5112
5121
  ...recipientDataArray,
5113
5122
  ...amountDataArray
5114
5123
  ]);
5115
- const params = {
5116
- script,
5117
- gasPrice: minGasPrice,
5118
- baseAssetId,
5119
- ...txParams
5120
- };
5124
+ const params = { script, gasPrice: minGasPrice, ...txParams };
5121
5125
  const request = new ScriptTransactionRequest(params);
5122
- const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
5126
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5123
5127
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5124
5128
  request,
5125
5129
  forwardingQuantities
@@ -5216,7 +5220,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
5216
5220
 
5217
5221
  // src/signer/signer.ts
5218
5222
  import { Address as Address4 } from "@fuel-ts/address";
5219
- import { randomBytes } from "@fuel-ts/crypto";
5223
+ import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
5220
5224
  import { hash } from "@fuel-ts/hasher";
5221
5225
  import { toBytes } from "@fuel-ts/math";
5222
5226
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5309,7 +5313,7 @@ var Signer = class {
5309
5313
  * @returns random 32-byte hashed
5310
5314
  */
5311
5315
  static generatePrivateKey(entropy) {
5312
- return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5316
+ return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
5313
5317
  }
5314
5318
  /**
5315
5319
  * Extended publicKey from a compact publicKey
@@ -5328,7 +5332,7 @@ import { Address as Address5 } from "@fuel-ts/address";
5328
5332
  import {
5329
5333
  bufferFromString,
5330
5334
  keccak256,
5331
- randomBytes as randomBytes2,
5335
+ randomBytes as randomBytes3,
5332
5336
  scrypt,
5333
5337
  stringFromBuffer,
5334
5338
  decryptJsonWalletData,
@@ -5351,7 +5355,7 @@ var removeHexPrefix = (hexString) => {
5351
5355
  async function encryptKeystoreWallet(privateKey, address, password) {
5352
5356
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5353
5357
  const ownerAddress = Address5.fromAddressOrString(address);
5354
- const salt = randomBytes2(DEFAULT_KEY_SIZE);
5358
+ const salt = randomBytes3(DEFAULT_KEY_SIZE);
5355
5359
  const key = scrypt({
5356
5360
  password: bufferFromString(password),
5357
5361
  salt,
@@ -5360,7 +5364,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5360
5364
  r: DEFAULT_KDF_PARAMS_R,
5361
5365
  p: DEFAULT_KDF_PARAMS_P
5362
5366
  });
5363
- const iv = randomBytes2(DEFAULT_IV_SIZE);
5367
+ const iv = randomBytes3(DEFAULT_IV_SIZE);
5364
5368
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5365
5369
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5366
5370
  const macHashUint8Array = keccak256(data);
@@ -5542,7 +5546,7 @@ import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from
5542
5546
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5543
5547
 
5544
5548
  // src/mnemonic/mnemonic.ts
5545
- import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5549
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5546
5550
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5547
5551
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5548
5552
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
@@ -7903,7 +7907,7 @@ var Mnemonic = class {
7903
7907
  * @returns A randomly generated mnemonic
7904
7908
  */
7905
7909
  static generate(size = 32, extraEntropy = "") {
7906
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7910
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7907
7911
  return Mnemonic.entropyToMnemonic(entropy);
7908
7912
  }
7909
7913
  };
@@ -8696,6 +8700,7 @@ import {
8696
8700
  SCRIPT_FIXED_SIZE
8697
8701
  } from "@fuel-ts/abi-coder";
8698
8702
  import { Address as Address9 } from "@fuel-ts/address";
8703
+ import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8699
8704
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8700
8705
  import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8701
8706
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
@@ -8773,9 +8778,8 @@ var Predicate = class extends Account {
8773
8778
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8774
8779
  * @returns A promise that resolves to the prepared transaction request.
8775
8780
  */
8776
- async createTransfer(destination, amount, assetId, txParams = {}) {
8777
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8778
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8781
+ async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
8782
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8779
8783
  return this.populateTransactionPredicateData(request);
8780
8784
  }
8781
8785
  /**