@fuel-ts/account 0.0.0-rc-2040-20240411104812 → 0.0.0-rc-2034-20240411105200

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.js CHANGED
@@ -1173,6 +1173,7 @@ var MemoryCache = class {
1173
1173
  };
1174
1174
 
1175
1175
  // src/providers/transaction-request/input.ts
1176
+ var import_abi_coder = require("@fuel-ts/abi-coder");
1176
1177
  var import_configs2 = require("@fuel-ts/address/configs");
1177
1178
  var import_errors3 = require("@fuel-ts/errors");
1178
1179
  var import_math2 = require("@fuel-ts/math");
@@ -1186,8 +1187,8 @@ var inputify = (value) => {
1186
1187
  const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
1187
1188
  return {
1188
1189
  type: import_transactions.InputType.Coin,
1189
- txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1190
- outputIndex: (0, import_utils3.arrayify)(value.id)[32],
1190
+ txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, import_abi_coder.BYTES_32)),
1191
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(import_abi_coder.BYTES_32, import_abi_coder.UTXO_ID_LEN)),
1191
1192
  owner: (0, import_utils3.hexlify)(value.owner),
1192
1193
  amount: (0, import_math2.bn)(value.amount),
1193
1194
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1305,8 +1306,10 @@ var outputify = (value) => {
1305
1306
  };
1306
1307
 
1307
1308
  // src/providers/transaction-request/transaction-request.ts
1309
+ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1308
1310
  var import_address = require("@fuel-ts/address");
1309
1311
  var import_configs7 = require("@fuel-ts/address/configs");
1312
+ var import_crypto = require("@fuel-ts/crypto");
1310
1313
  var import_math7 = require("@fuel-ts/math");
1311
1314
  var import_transactions6 = require("@fuel-ts/transactions");
1312
1315
  var import_utils9 = require("@fuel-ts/utils");
@@ -2241,12 +2244,6 @@ var BaseTransactionRequest = class {
2241
2244
  * @param quantities - CoinQuantity Array.
2242
2245
  */
2243
2246
  fundWithFakeUtxos(quantities, resourcesOwner) {
2244
- let idCounter = 0;
2245
- const generateId = () => {
2246
- const counterString = String(idCounter++);
2247
- const id = import_configs7.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2248
- return id;
2249
- };
2250
2247
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2251
2248
  if ("assetId" in input) {
2252
2249
  return input.assetId === assetId;
@@ -2256,12 +2253,12 @@ var BaseTransactionRequest = class {
2256
2253
  const updateAssetInput = (assetId, quantity) => {
2257
2254
  const assetInput = findAssetInput(assetId);
2258
2255
  if (assetInput && "assetId" in assetInput) {
2259
- assetInput.id = generateId();
2256
+ assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2260
2257
  assetInput.amount = quantity;
2261
2258
  } else {
2262
2259
  this.addResources([
2263
2260
  {
2264
- id: generateId(),
2261
+ id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2265
2262
  amount: quantity,
2266
2263
  assetId,
2267
2264
  owner: resourcesOwner || import_address.Address.fromRandom(),
@@ -2516,7 +2513,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2516
2513
  };
2517
2514
 
2518
2515
  // src/providers/transaction-request/script-transaction-request.ts
2519
- var import_abi_coder = require("@fuel-ts/abi-coder");
2516
+ var import_abi_coder3 = require("@fuel-ts/abi-coder");
2520
2517
  var import_address2 = require("@fuel-ts/address");
2521
2518
  var import_configs10 = require("@fuel-ts/address/configs");
2522
2519
  var import_math10 = require("@fuel-ts/math");
@@ -2708,7 +2705,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2708
2705
  * @returns The current instance of the `ScriptTransactionRequest`.
2709
2706
  */
2710
2707
  setData(abi, args) {
2711
- const abiInterface = new import_abi_coder.Interface(abi);
2708
+ const abiInterface = new import_abi_coder3.Interface(abi);
2712
2709
  this.scriptData = abiInterface.functions.main.encodeArguments(args);
2713
2710
  return this;
2714
2711
  }
@@ -2830,17 +2827,17 @@ var import_math13 = require("@fuel-ts/math");
2830
2827
  var import_transactions14 = require("@fuel-ts/transactions");
2831
2828
 
2832
2829
  // src/providers/transaction-summary/call.ts
2833
- var import_abi_coder2 = require("@fuel-ts/abi-coder");
2830
+ var import_abi_coder4 = require("@fuel-ts/abi-coder");
2834
2831
  var import_math12 = require("@fuel-ts/math");
2835
2832
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2836
- const abiInterface = new import_abi_coder2.Interface(abi);
2833
+ const abiInterface = new import_abi_coder4.Interface(abi);
2837
2834
  const callFunctionSelector = receipt.param1.toHex(8);
2838
2835
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2839
2836
  const inputs = functionFragment.jsonFn.inputs;
2840
2837
  let encodedArgs;
2841
2838
  if (functionFragment.isInputDataPointer) {
2842
2839
  if (rawPayload) {
2843
- const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2840
+ const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2844
2841
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2845
2842
  }
2846
2843
  } else {
@@ -3490,13 +3487,13 @@ function assembleTransactionSummary(params) {
3490
3487
  }
3491
3488
 
3492
3489
  // src/providers/transaction-response/getDecodedLogs.ts
3493
- var import_abi_coder3 = require("@fuel-ts/abi-coder");
3490
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
3494
3491
  var import_transactions16 = require("@fuel-ts/transactions");
3495
3492
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3496
3493
  return receipts.reduce((logs, receipt) => {
3497
3494
  if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3498
- const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3499
- const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3495
+ const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3496
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3500
3497
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3501
3498
  logs.push(decodedLog);
3502
3499
  }
@@ -4138,6 +4135,36 @@ var _Provider = class {
4138
4135
  missingContractIds
4139
4136
  };
4140
4137
  }
4138
+ /**
4139
+ * Estimates the transaction gas and fee based on the provided transaction request.
4140
+ * @param transactionRequest - The transaction request object.
4141
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4142
+ */
4143
+ estimateTxGasAndFee(params) {
4144
+ const { transactionRequest } = params;
4145
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4146
+ const chainInfo = this.getChain();
4147
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4148
+ transactionRequest.gasPrice = gasPrice;
4149
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4150
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4151
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4152
+ if (transactionRequest.gasLimit.eq(0)) {
4153
+ transactionRequest.gasLimit = minGas;
4154
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4155
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4156
+ );
4157
+ }
4158
+ }
4159
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4160
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4161
+ return {
4162
+ minGas,
4163
+ minFee,
4164
+ maxGas,
4165
+ maxFee
4166
+ };
4167
+ }
4141
4168
  /**
4142
4169
  * Executes a signed transaction without applying the states changes
4143
4170
  * on the chain.
@@ -4185,17 +4212,16 @@ var _Provider = class {
4185
4212
  signatureCallback
4186
4213
  } = {}) {
4187
4214
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4188
- const chainInfo = this.getChain();
4189
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4190
- const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4215
+ const { minGasPrice } = this.getGasConfig();
4216
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4191
4217
  const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4192
4218
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4193
4219
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4194
4220
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4221
+ if (isScriptTransaction) {
4222
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4223
+ }
4195
4224
  if (estimatePredicates) {
4196
- if (isScriptTransaction) {
4197
- txRequestClone.gasLimit = (0, import_math15.bn)(0);
4198
- }
4199
4225
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4200
4226
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
4201
4227
  }
@@ -4204,36 +4230,34 @@ var _Provider = class {
4204
4230
  if (signatureCallback && isScriptTransaction) {
4205
4231
  await signatureCallback(txRequestClone);
4206
4232
  }
4207
- const minGas = txRequestClone.calculateMinGas(chainInfo);
4208
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4233
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4234
+ transactionRequest: txRequestClone
4235
+ });
4209
4236
  let receipts = [];
4210
4237
  let missingContractIds = [];
4211
4238
  let outputVariables = 0;
4239
+ let gasUsed = (0, import_math15.bn)(0);
4212
4240
  if (isScriptTransaction && estimateTxDependencies) {
4213
4241
  txRequestClone.gasPrice = (0, import_math15.bn)(0);
4214
- txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4215
4242
  const result = await this.estimateTxDependencies(txRequestClone);
4216
4243
  receipts = result.receipts;
4217
4244
  outputVariables = result.outputVariables;
4218
4245
  missingContractIds = result.missingContractIds;
4246
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4247
+ txRequestClone.gasLimit = gasUsed;
4248
+ txRequestClone.gasPrice = setGasPrice;
4249
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4250
+ transactionRequest: txRequestClone
4251
+ }));
4219
4252
  }
4220
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4221
- const usedFee = calculatePriceWithFactor(
4222
- gasUsed,
4223
- gasPrice,
4224
- gasPriceFactor
4225
- ).normalizeZeroToOne();
4226
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4227
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4228
4253
  return {
4229
4254
  requiredQuantities: allQuantities,
4230
4255
  receipts,
4231
4256
  gasUsed,
4232
4257
  minGasPrice,
4233
- gasPrice,
4258
+ gasPrice: setGasPrice,
4234
4259
  minGas,
4235
4260
  maxGas,
4236
- usedFee,
4237
4261
  minFee,
4238
4262
  maxFee,
4239
4263
  estimatedInputs: txRequestClone.inputs,
@@ -4866,13 +4890,13 @@ var assets = [
4866
4890
  ];
4867
4891
 
4868
4892
  // src/utils/formatTransferToContractScriptData.ts
4869
- var import_abi_coder4 = require("@fuel-ts/abi-coder");
4893
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
4870
4894
  var import_math17 = require("@fuel-ts/math");
4871
4895
  var import_utils27 = require("@fuel-ts/utils");
4872
4896
  var asm = __toESM(require("@fuels/vm-asm"));
4873
4897
  var formatTransferToContractScriptData = (params) => {
4874
4898
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4875
- const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4899
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4876
4900
  const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4877
4901
  const scriptData = Uint8Array.from([
4878
4902
  ...(0, import_utils27.arrayify)(hexlifiedContractId),
@@ -5327,7 +5351,7 @@ var import_utils31 = require("@fuel-ts/utils");
5327
5351
 
5328
5352
  // src/signer/signer.ts
5329
5353
  var import_address5 = require("@fuel-ts/address");
5330
- var import_crypto = require("@fuel-ts/crypto");
5354
+ var import_crypto2 = require("@fuel-ts/crypto");
5331
5355
  var import_hasher2 = require("@fuel-ts/hasher");
5332
5356
  var import_math19 = require("@fuel-ts/math");
5333
5357
  var import_utils29 = require("@fuel-ts/utils");
@@ -5420,7 +5444,7 @@ var Signer = class {
5420
5444
  * @returns random 32-byte hashed
5421
5445
  */
5422
5446
  static generatePrivateKey(entropy) {
5423
- return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5447
+ return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5424
5448
  }
5425
5449
  /**
5426
5450
  * Extended publicKey from a compact publicKey
@@ -5436,7 +5460,7 @@ var Signer = class {
5436
5460
 
5437
5461
  // src/wallet/keystore-wallet.ts
5438
5462
  var import_address6 = require("@fuel-ts/address");
5439
- var import_crypto2 = require("@fuel-ts/crypto");
5463
+ var import_crypto3 = require("@fuel-ts/crypto");
5440
5464
  var import_errors17 = require("@fuel-ts/errors");
5441
5465
  var import_utils30 = require("@fuel-ts/utils");
5442
5466
  var import_uuid = require("uuid");
@@ -5452,22 +5476,22 @@ var removeHexPrefix = (hexString) => {
5452
5476
  return hexString;
5453
5477
  };
5454
5478
  async function encryptKeystoreWallet(privateKey, address, password) {
5455
- const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
5479
+ const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
5456
5480
  const ownerAddress = import_address6.Address.fromAddressOrString(address);
5457
- const salt = (0, import_crypto2.randomBytes)(DEFAULT_KEY_SIZE);
5458
- const key = (0, import_crypto2.scrypt)({
5459
- password: (0, import_crypto2.bufferFromString)(password),
5481
+ const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
5482
+ const key = (0, import_crypto3.scrypt)({
5483
+ password: (0, import_crypto3.bufferFromString)(password),
5460
5484
  salt,
5461
5485
  dklen: DEFAULT_KEY_SIZE,
5462
5486
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5463
5487
  r: DEFAULT_KDF_PARAMS_R,
5464
5488
  p: DEFAULT_KDF_PARAMS_P
5465
5489
  });
5466
- const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
5467
- const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5490
+ const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
5491
+ const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5468
5492
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5469
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5470
- const mac = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5493
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5494
+ const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5471
5495
  const keystore = {
5472
5496
  id: (0, import_uuid.v4)(),
5473
5497
  version: 3,
@@ -5475,15 +5499,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5475
5499
  crypto: {
5476
5500
  cipher: "aes-128-ctr",
5477
5501
  mac,
5478
- cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
5479
- ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
5502
+ cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
5503
+ ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
5480
5504
  kdf: "scrypt",
5481
5505
  kdfparams: {
5482
5506
  dklen: DEFAULT_KEY_SIZE,
5483
5507
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5484
5508
  p: DEFAULT_KDF_PARAMS_P,
5485
5509
  r: DEFAULT_KDF_PARAMS_R,
5486
- salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
5510
+ salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
5487
5511
  }
5488
5512
  }
5489
5513
  };
@@ -5499,11 +5523,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5499
5523
  kdfparams: { dklen, n, r, p, salt }
5500
5524
  }
5501
5525
  } = keystoreWallet;
5502
- const ciphertextBuffer = (0, import_crypto2.bufferFromString)(ciphertext, "hex");
5503
- const ivBuffer = (0, import_crypto2.bufferFromString)(iv, "hex");
5504
- const saltBuffer = (0, import_crypto2.bufferFromString)(salt, "hex");
5505
- const passwordBuffer = (0, import_crypto2.bufferFromString)(password);
5506
- const key = (0, import_crypto2.scrypt)({
5526
+ const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
5527
+ const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
5528
+ const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
5529
+ const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
5530
+ const key = (0, import_crypto3.scrypt)({
5507
5531
  password: passwordBuffer,
5508
5532
  salt: saltBuffer,
5509
5533
  n,
@@ -5512,15 +5536,15 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5512
5536
  dklen
5513
5537
  });
5514
5538
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
5515
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5516
- const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5539
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5540
+ const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5517
5541
  if (mac !== macHash) {
5518
5542
  throw new import_errors17.FuelError(
5519
5543
  import_errors17.ErrorCode.INVALID_PASSWORD,
5520
5544
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5521
5545
  );
5522
5546
  }
5523
- const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5547
+ const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5524
5548
  const privateKey = (0, import_utils30.hexlify)(buffer);
5525
5549
  return privateKey;
5526
5550
  }
@@ -5645,7 +5669,7 @@ var import_utils35 = require("@fuel-ts/utils");
5645
5669
  var import_ethers3 = require("ethers");
5646
5670
 
5647
5671
  // src/mnemonic/mnemonic.ts
5648
- var import_crypto3 = require("@fuel-ts/crypto");
5672
+ var import_crypto4 = require("@fuel-ts/crypto");
5649
5673
  var import_errors19 = require("@fuel-ts/errors");
5650
5674
  var import_hasher5 = require("@fuel-ts/hasher");
5651
5675
  var import_utils33 = require("@fuel-ts/utils");
@@ -8006,7 +8030,7 @@ var Mnemonic = class {
8006
8030
  * @returns A randomly generated mnemonic
8007
8031
  */
8008
8032
  static generate(size = 32, extraEntropy = "") {
8009
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
8033
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
8010
8034
  return Mnemonic.entropyToMnemonic(entropy);
8011
8035
  }
8012
8036
  };
@@ -8378,7 +8402,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8378
8402
 
8379
8403
  // src/wallet-manager/wallet-manager.ts
8380
8404
  var import_address9 = require("@fuel-ts/address");
8381
- var import_crypto4 = require("@fuel-ts/crypto");
8405
+ var import_crypto5 = require("@fuel-ts/crypto");
8382
8406
  var import_errors23 = require("@fuel-ts/errors");
8383
8407
  var import_events = require("events");
8384
8408
 
@@ -8706,7 +8730,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8706
8730
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8707
8731
  const data = await this.storage.getItem(this.STORAGE_KEY);
8708
8732
  if (data) {
8709
- const state = await (0, import_crypto4.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8733
+ const state = await (0, import_crypto5.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8710
8734
  __privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
8711
8735
  }
8712
8736
  }
@@ -8715,7 +8739,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8715
8739
  */
8716
8740
  async saveState() {
8717
8741
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8718
- const encryptedData = await (0, import_crypto4.encrypt)(__privateGet(this, _passphrase), {
8742
+ const encryptedData = await (0, import_crypto5.encrypt)(__privateGet(this, _passphrase), {
8719
8743
  vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
8720
8744
  });
8721
8745
  await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
@@ -8791,7 +8815,7 @@ var StorageAbstract = class {
8791
8815
  };
8792
8816
 
8793
8817
  // src/predicate/predicate.ts
8794
- var import_abi_coder5 = require("@fuel-ts/abi-coder");
8818
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
8795
8819
  var import_address10 = require("@fuel-ts/address");
8796
8820
  var import_configs13 = require("@fuel-ts/address/configs");
8797
8821
  var import_errors25 = require("@fuel-ts/errors");
@@ -8901,10 +8925,10 @@ var Predicate = class extends Account {
8901
8925
  }
8902
8926
  const mainFn = this.interface?.functions.main;
8903
8927
  const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8904
- const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
8928
+ const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
8905
8929
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8906
8930
  });
8907
- const OFFSET = VM_TX_MEMORY + import_abi_coder5.SCRIPT_FIXED_SIZE + import_abi_coder5.INPUT_COIN_FIXED_SIZE + import_abi_coder5.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder5.WORD_SIZE;
8931
+ const OFFSET = VM_TX_MEMORY + import_abi_coder7.SCRIPT_FIXED_SIZE + import_abi_coder7.INPUT_COIN_FIXED_SIZE + import_abi_coder7.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder7.WORD_SIZE;
8908
8932
  return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
8909
8933
  }
8910
8934
  /**
@@ -8919,7 +8943,7 @@ var Predicate = class extends Account {
8919
8943
  let predicateBytes = (0, import_utils37.arrayify)(bytes);
8920
8944
  let abiInterface;
8921
8945
  if (jsonAbi) {
8922
- abiInterface = new import_abi_coder5.Interface(jsonAbi);
8946
+ abiInterface = new import_abi_coder7.Interface(jsonAbi);
8923
8947
  if (abiInterface.functions.main === void 0) {
8924
8948
  throw new import_errors25.FuelError(
8925
8949
  import_errors25.ErrorCode.ABI_MAIN_METHOD_MISSING,