@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.

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