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

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