@fuel-ts/account 0.0.0-rc-1976-20240410103621 → 0.0.0-rc-2034-20240410113328

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,7 @@ 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";
1158
1160
  import { bn as bn7 } from "@fuel-ts/math";
1159
1161
  import {
1160
1162
  PolicyType,
@@ -1164,6 +1166,7 @@ import {
1164
1166
  TransactionType
1165
1167
  } from "@fuel-ts/transactions";
1166
1168
  import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1169
+ import { randomBytes } from "ethers";
1167
1170
 
1168
1171
  // src/providers/resource.ts
1169
1172
  var isRawCoin = (resource) => "utxoId" in resource;
@@ -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 = ZeroBytes324;
1693
1694
  /**
1694
1695
  * Constructor for initializing a base transaction request.
1695
1696
  *
@@ -1702,8 +1703,7 @@ var BaseTransactionRequest = class {
1702
1703
  witnessLimit,
1703
1704
  inputs,
1704
1705
  outputs,
1705
- witnesses,
1706
- baseAssetId
1706
+ witnesses
1707
1707
  } = {}) {
1708
1708
  this.gasPrice = bn7(gasPrice);
1709
1709
  this.maturity = maturity ?? 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 ?? ZeroBytes324;
1716
1715
  }
1717
1716
  static getPolicyMeta(req) {
1718
1717
  let policyTypes = 0;
@@ -1937,9 +1936,11 @@ var BaseTransactionRequest = class {
1937
1936
  *
1938
1937
  * @param message - Message resource.
1939
1938
  * @param predicate - Predicate bytes.
1939
+ * @param predicateData - Predicate data bytes.
1940
1940
  */
1941
1941
  addMessageInput(message, predicate) {
1942
1942
  const { recipient, sender, amount } = message;
1943
+ const assetId = BaseAssetId2;
1943
1944
  let witnessIndex;
1944
1945
  if (predicate) {
1945
1946
  witnessIndex = 0;
@@ -1960,7 +1961,7 @@ var BaseTransactionRequest = class {
1960
1961
  predicateData: predicate?.predicateDataBytes
1961
1962
  };
1962
1963
  this.pushInput(input);
1963
- this.addChangeOutput(recipient, this.baseAssetId);
1964
+ this.addChangeOutput(recipient, assetId);
1964
1965
  }
1965
1966
  /**
1966
1967
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2021,12 +2022,12 @@ var BaseTransactionRequest = class {
2021
2022
  * @param amount - Amount of coin.
2022
2023
  * @param assetId - Asset ID of coin.
2023
2024
  */
2024
- addCoinOutput(to, amount, assetId) {
2025
+ addCoinOutput(to, amount, assetId = BaseAssetId2) {
2025
2026
  this.pushOutput({
2026
2027
  type: OutputType2.Coin,
2027
2028
  to: addressify(to).toB256(),
2028
2029
  amount,
2029
- assetId: assetId ?? this.baseAssetId
2030
+ assetId
2030
2031
  });
2031
2032
  return this;
2032
2033
  }
@@ -2053,7 +2054,7 @@ var BaseTransactionRequest = class {
2053
2054
  * @param to - Address of the owner.
2054
2055
  * @param assetId - Asset ID of coin.
2055
2056
  */
2056
- addChangeOutput(to, assetId) {
2057
+ addChangeOutput(to, assetId = BaseAssetId2) {
2057
2058
  const changeOutput = this.getChangeOutputs().find(
2058
2059
  (output) => hexlify7(output.assetId) === assetId
2059
2060
  );
@@ -2061,7 +2062,7 @@ var BaseTransactionRequest = class {
2061
2062
  this.pushOutput({
2062
2063
  type: OutputType2.Change,
2063
2064
  to: addressify(to).toB256(),
2064
- assetId: assetId ?? this.baseAssetId
2065
+ assetId
2065
2066
  });
2066
2067
  }
2067
2068
  }
@@ -2112,12 +2113,6 @@ var BaseTransactionRequest = class {
2112
2113
  * @param quantities - CoinQuantity Array.
2113
2114
  */
2114
2115
  fundWithFakeUtxos(quantities, resourcesOwner) {
2115
- let idCounter = 0;
2116
- const generateId = () => {
2117
- const counterString = String(idCounter++);
2118
- const id = ZeroBytes324.slice(0, -counterString.length).concat(counterString);
2119
- return id;
2120
- };
2121
2116
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2122
2117
  if ("assetId" in input) {
2123
2118
  return input.assetId === assetId;
@@ -2127,12 +2122,12 @@ var BaseTransactionRequest = class {
2127
2122
  const updateAssetInput = (assetId, quantity) => {
2128
2123
  const assetInput = findAssetInput(assetId);
2129
2124
  if (assetInput && "assetId" in assetInput) {
2130
- assetInput.id = generateId();
2125
+ assetInput.id = hexlify7(randomBytes(33));
2131
2126
  assetInput.amount = quantity;
2132
2127
  } else {
2133
2128
  this.addResources([
2134
2129
  {
2135
- id: generateId(),
2130
+ id: hexlify7(randomBytes(33)),
2136
2131
  amount: quantity,
2137
2132
  assetId,
2138
2133
  owner: resourcesOwner || Address.fromRandom(),
@@ -2143,7 +2138,7 @@ var BaseTransactionRequest = class {
2143
2138
  ]);
2144
2139
  }
2145
2140
  };
2146
- updateAssetInput(this.baseAssetId, bn7(1e11));
2141
+ updateAssetInput(BaseAssetId2, bn7(1e11));
2147
2142
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2148
2143
  }
2149
2144
  /**
@@ -3617,7 +3612,6 @@ var processGqlChain = (chain) => {
3617
3612
  gasPerByte: bn15(feeParams.gasPerByte),
3618
3613
  maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3619
3614
  chainId: bn15(consensusParameters.chainId),
3620
- baseAssetId: consensusParameters.baseAssetId,
3621
3615
  gasCosts
3622
3616
  },
3623
3617
  gasCosts,
@@ -3860,17 +3854,6 @@ var _Provider = class {
3860
3854
  } = this.getChain();
3861
3855
  return chainId.toNumber();
3862
3856
  }
3863
- /**
3864
- * Returns the base asset ID
3865
- *
3866
- * @returns A promise that resolves to the base asset ID
3867
- */
3868
- getBaseAssetId() {
3869
- const {
3870
- consensusParameters: { baseAssetId }
3871
- } = this.getChain();
3872
- return baseAssetId;
3873
- }
3874
3857
  /**
3875
3858
  * Submits a transaction to the chain to be executed.
3876
3859
  *
@@ -4021,6 +4004,37 @@ var _Provider = class {
4021
4004
  missingContractIds
4022
4005
  };
4023
4006
  }
4007
+ /**
4008
+ * Estimates the transaction gas and fee based on the provided transaction request.
4009
+ * @param transactionRequest - The transaction request object.
4010
+ * @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
4011
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4012
+ */
4013
+ estimateTxGasAndFee(params) {
4014
+ const { transactionRequest } = params;
4015
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4016
+ const chainInfo = this.getChain();
4017
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4018
+ transactionRequest.gasPrice = gasPrice;
4019
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4020
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4021
+ if (transactionRequest.type === TransactionType8.Script) {
4022
+ if (transactionRequest.gasLimit.eq(0)) {
4023
+ transactionRequest.gasLimit = minGas;
4024
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4025
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4026
+ );
4027
+ }
4028
+ }
4029
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4030
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4031
+ return {
4032
+ minGas,
4033
+ minFee,
4034
+ maxGas,
4035
+ maxFee
4036
+ };
4037
+ }
4024
4038
  /**
4025
4039
  * Executes a signed transaction without applying the states changes
4026
4040
  * on the chain.
@@ -4068,17 +4082,16 @@ var _Provider = class {
4068
4082
  signatureCallback
4069
4083
  } = {}) {
4070
4084
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4071
- const chainInfo = this.getChain();
4072
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4073
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
4085
+ const { minGasPrice } = this.getGasConfig();
4086
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
4074
4087
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4075
4088
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4076
4089
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4077
4090
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4091
+ if (isScriptTransaction) {
4092
+ txRequestClone.gasLimit = bn15(0);
4093
+ }
4078
4094
  if (estimatePredicates) {
4079
- if (isScriptTransaction) {
4080
- txRequestClone.gasLimit = bn15(0);
4081
- }
4082
4095
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4083
4096
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
4084
4097
  }
@@ -4087,36 +4100,34 @@ var _Provider = class {
4087
4100
  if (signatureCallback && isScriptTransaction) {
4088
4101
  await signatureCallback(txRequestClone);
4089
4102
  }
4090
- const minGas = txRequestClone.calculateMinGas(chainInfo);
4091
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4103
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4104
+ transactionRequest: txRequestClone
4105
+ });
4092
4106
  let receipts = [];
4093
4107
  let missingContractIds = [];
4094
4108
  let outputVariables = 0;
4109
+ let gasUsed = bn15(0);
4095
4110
  if (isScriptTransaction && estimateTxDependencies) {
4096
4111
  txRequestClone.gasPrice = bn15(0);
4097
- txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4098
4112
  const result = await this.estimateTxDependencies(txRequestClone);
4099
4113
  receipts = result.receipts;
4100
4114
  outputVariables = result.outputVariables;
4101
4115
  missingContractIds = result.missingContractIds;
4116
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4117
+ txRequestClone.gasLimit = gasUsed;
4118
+ txRequestClone.gasPrice = setGasPrice;
4119
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4120
+ transactionRequest: txRequestClone
4121
+ }));
4102
4122
  }
4103
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4104
- const usedFee = calculatePriceWithFactor(
4105
- gasUsed,
4106
- gasPrice,
4107
- gasPriceFactor
4108
- ).normalizeZeroToOne();
4109
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4110
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4111
4123
  return {
4112
4124
  requiredQuantities: allQuantities,
4113
4125
  receipts,
4114
4126
  gasUsed,
4115
4127
  minGasPrice,
4116
- gasPrice,
4128
+ gasPrice: setGasPrice,
4117
4129
  minGas,
4118
4130
  maxGas,
4119
- usedFee,
4120
4131
  minFee,
4121
4132
  maxFee,
4122
4133
  estimatedInputs: txRequestClone.inputs,
@@ -4907,9 +4918,8 @@ var Account = class extends AbstractAccount {
4907
4918
  * @param assetId - The asset ID to check the balance for.
4908
4919
  * @returns A promise that resolves to the balance amount.
4909
4920
  */
4910
- async getBalance(assetId) {
4911
- const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
4912
- const amount = await this.provider.getBalance(this.address, assetIdToFetch);
4921
+ async getBalance(assetId = BaseAssetId3) {
4922
+ const amount = await this.provider.getBalance(this.address, assetId);
4913
4923
  return amount;
4914
4924
  }
4915
4925
  /**
@@ -4947,10 +4957,9 @@ var Account = class extends AbstractAccount {
4947
4957
  * @returns A promise that resolves when the resources are added to the transaction.
4948
4958
  */
4949
4959
  async fund(request, coinQuantities, fee) {
4950
- const baseAssetId = this.provider.getBaseAssetId();
4951
4960
  const updatedQuantities = addAmountToAsset({
4952
4961
  amount: bn17(fee),
4953
- assetId: baseAssetId,
4962
+ assetId: BaseAssetId3,
4954
4963
  coinQuantities
4955
4964
  });
4956
4965
  const quantitiesDict = {};
@@ -4974,8 +4983,8 @@ var Account = class extends AbstractAccount {
4974
4983
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4975
4984
  cachedUtxos.push(input.id);
4976
4985
  }
4977
- } else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
4978
- quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
4986
+ } else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
4987
+ quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
4979
4988
  cachedMessages.push(input.nonce);
4980
4989
  }
4981
4990
  }
@@ -5007,12 +5016,11 @@ var Account = class extends AbstractAccount {
5007
5016
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5008
5017
  * @returns A promise that resolves to the prepared transaction request.
5009
5018
  */
5010
- async createTransfer(destination, amount, assetId, txParams = {}) {
5019
+ async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5011
5020
  const { minGasPrice } = this.provider.getGasConfig();
5012
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5013
5021
  const params = { gasPrice: minGasPrice, ...txParams };
5014
5022
  const request = new ScriptTransactionRequest(params);
5015
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
5023
+ request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
5016
5024
  const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
5017
5025
  estimateTxDependencies: true,
5018
5026
  resourcesOwner: this
@@ -5038,15 +5046,14 @@ var Account = class extends AbstractAccount {
5038
5046
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5039
5047
  * @returns A promise that resolves to the transaction response.
5040
5048
  */
5041
- async transfer(destination, amount, assetId, txParams = {}) {
5049
+ async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
5042
5050
  if (bn17(amount).lte(0)) {
5043
5051
  throw new FuelError15(
5044
5052
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5045
5053
  "Transfer amount must be a positive number."
5046
5054
  );
5047
5055
  }
5048
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5049
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5056
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
5050
5057
  return this.sendTransaction(request, { estimateTxDependencies: false });
5051
5058
  }
5052
5059
  /**
@@ -5058,7 +5065,7 @@ var Account = class extends AbstractAccount {
5058
5065
  * @param txParams - The optional transaction parameters.
5059
5066
  * @returns A promise that resolves to the transaction response.
5060
5067
  */
5061
- async transferToContract(contractId, amount, assetId, txParams = {}) {
5068
+ async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
5062
5069
  if (bn17(amount).lte(0)) {
5063
5070
  throw new FuelError15(
5064
5071
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
@@ -5067,12 +5074,11 @@ var Account = class extends AbstractAccount {
5067
5074
  }
5068
5075
  const contractAddress = Address3.fromAddressOrString(contractId);
5069
5076
  const { minGasPrice } = this.provider.getGasConfig();
5070
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5071
5077
  const params = { gasPrice: minGasPrice, ...txParams };
5072
5078
  const { script, scriptData } = await assembleTransferToContractScript({
5073
5079
  hexlifiedContractId: contractAddress.toB256(),
5074
5080
  amountToTransfer: bn17(amount),
5075
- assetId: assetIdToTransfer
5081
+ assetId
5076
5082
  });
5077
5083
  const request = new ScriptTransactionRequest({
5078
5084
  ...params,
@@ -5082,7 +5088,7 @@ var Account = class extends AbstractAccount {
5082
5088
  request.addContractInputAndOutput(contractAddress);
5083
5089
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5084
5090
  request,
5085
- [{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
5091
+ [{ amount: bn17(amount), assetId: String(assetId) }]
5086
5092
  );
5087
5093
  request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5088
5094
  this.validateGas({
@@ -5104,7 +5110,6 @@ var Account = class extends AbstractAccount {
5104
5110
  */
5105
5111
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5106
5112
  const { minGasPrice } = this.provider.getGasConfig();
5107
- const baseAssetId = this.provider.getBaseAssetId();
5108
5113
  const recipientAddress = Address3.fromAddressOrString(recipient);
5109
5114
  const recipientDataArray = arrayify14(
5110
5115
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -5119,7 +5124,7 @@ var Account = class extends AbstractAccount {
5119
5124
  ]);
5120
5125
  const params = { script, gasPrice: minGasPrice, ...txParams };
5121
5126
  const request = new ScriptTransactionRequest(params);
5122
- const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
5127
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5123
5128
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5124
5129
  request,
5125
5130
  forwardingQuantities
@@ -5216,7 +5221,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
5216
5221
 
5217
5222
  // src/signer/signer.ts
5218
5223
  import { Address as Address4 } from "@fuel-ts/address";
5219
- import { randomBytes } from "@fuel-ts/crypto";
5224
+ import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
5220
5225
  import { hash } from "@fuel-ts/hasher";
5221
5226
  import { toBytes } from "@fuel-ts/math";
5222
5227
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5309,7 +5314,7 @@ var Signer = class {
5309
5314
  * @returns random 32-byte hashed
5310
5315
  */
5311
5316
  static generatePrivateKey(entropy) {
5312
- return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5317
+ return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
5313
5318
  }
5314
5319
  /**
5315
5320
  * Extended publicKey from a compact publicKey
@@ -5328,7 +5333,7 @@ import { Address as Address5 } from "@fuel-ts/address";
5328
5333
  import {
5329
5334
  bufferFromString,
5330
5335
  keccak256,
5331
- randomBytes as randomBytes2,
5336
+ randomBytes as randomBytes3,
5332
5337
  scrypt,
5333
5338
  stringFromBuffer,
5334
5339
  decryptJsonWalletData,
@@ -5351,7 +5356,7 @@ var removeHexPrefix = (hexString) => {
5351
5356
  async function encryptKeystoreWallet(privateKey, address, password) {
5352
5357
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5353
5358
  const ownerAddress = Address5.fromAddressOrString(address);
5354
- const salt = randomBytes2(DEFAULT_KEY_SIZE);
5359
+ const salt = randomBytes3(DEFAULT_KEY_SIZE);
5355
5360
  const key = scrypt({
5356
5361
  password: bufferFromString(password),
5357
5362
  salt,
@@ -5360,7 +5365,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5360
5365
  r: DEFAULT_KDF_PARAMS_R,
5361
5366
  p: DEFAULT_KDF_PARAMS_P
5362
5367
  });
5363
- const iv = randomBytes2(DEFAULT_IV_SIZE);
5368
+ const iv = randomBytes3(DEFAULT_IV_SIZE);
5364
5369
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5365
5370
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5366
5371
  const macHashUint8Array = keccak256(data);
@@ -5542,7 +5547,7 @@ import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from
5542
5547
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5543
5548
 
5544
5549
  // src/mnemonic/mnemonic.ts
5545
- import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5550
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5546
5551
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5547
5552
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5548
5553
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
@@ -7903,7 +7908,7 @@ var Mnemonic = class {
7903
7908
  * @returns A randomly generated mnemonic
7904
7909
  */
7905
7910
  static generate(size = 32, extraEntropy = "") {
7906
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7911
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7907
7912
  return Mnemonic.entropyToMnemonic(entropy);
7908
7913
  }
7909
7914
  };
@@ -8696,6 +8701,7 @@ import {
8696
8701
  SCRIPT_FIXED_SIZE
8697
8702
  } from "@fuel-ts/abi-coder";
8698
8703
  import { Address as Address9 } from "@fuel-ts/address";
8704
+ import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8699
8705
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8700
8706
  import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8701
8707
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
@@ -8774,9 +8780,8 @@ var Predicate = class extends Account {
8774
8780
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8775
8781
  * @returns A promise that resolves to the prepared transaction request.
8776
8782
  */
8777
- async createTransfer(destination, amount, assetId, txParams = {}) {
8778
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
8779
- const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
8783
+ async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
8784
+ const request = await super.createTransfer(destination, amount, assetId, txParams);
8780
8785
  return this.populateTransactionPredicateData(request);
8781
8786
  }
8782
8787
  /**