@fuel-ts/account 0.0.0-rc-1356-20240520180710 → 0.0.0-rc-2333-20240520180734

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
@@ -186,6 +186,7 @@ __export(src_exports, {
186
186
  resolveGasDependentCosts: () => resolveGasDependentCosts,
187
187
  resolveIconPaths: () => resolveIconPaths,
188
188
  returnZeroScript: () => returnZeroScript,
189
+ sleep: () => sleep,
189
190
  transactionRequestify: () => transactionRequestify,
190
191
  urlJoin: () => urlJoin,
191
192
  withTimeout: () => withTimeout,
@@ -198,7 +199,7 @@ var import_address4 = require("@fuel-ts/address");
198
199
  var import_errors16 = require("@fuel-ts/errors");
199
200
  var import_interfaces = require("@fuel-ts/interfaces");
200
201
  var import_math20 = require("@fuel-ts/math");
201
- var import_utils29 = require("@fuel-ts/utils");
202
+ var import_utils28 = require("@fuel-ts/utils");
202
203
  var import_ramda4 = require("ramda");
203
204
 
204
205
  // src/providers/coin-quantity.ts
@@ -241,9 +242,9 @@ var import_address3 = require("@fuel-ts/address");
241
242
  var import_errors14 = require("@fuel-ts/errors");
242
243
  var import_math17 = require("@fuel-ts/math");
243
244
  var import_transactions20 = require("@fuel-ts/transactions");
244
- var import_utils23 = require("@fuel-ts/utils");
245
+ var import_utils22 = require("@fuel-ts/utils");
245
246
  var import_versions = require("@fuel-ts/versions");
246
- var import_utils24 = require("@noble/curves/abstract/utils");
247
+ var import_utils23 = require("@noble/curves/abstract/utils");
247
248
  var import_graphql_request = require("graphql-request");
248
249
  var import_ramda3 = require("ramda");
249
250
 
@@ -1864,6 +1865,15 @@ function normalizeJSON(root) {
1864
1865
  return normalize((0, import_ramda.clone)(root));
1865
1866
  }
1866
1867
 
1868
+ // src/providers/utils/sleep.ts
1869
+ function sleep(time) {
1870
+ return new Promise((resolve) => {
1871
+ setTimeout(() => {
1872
+ resolve(true);
1873
+ }, time);
1874
+ });
1875
+ }
1876
+
1867
1877
  // src/providers/utils/extract-tx-error.ts
1868
1878
  var import_errors7 = require("@fuel-ts/errors");
1869
1879
  var import_math6 = require("@fuel-ts/math");
@@ -3881,7 +3891,6 @@ var TransactionResponse = class {
3881
3891
  };
3882
3892
 
3883
3893
  // src/providers/utils/auto-retry-fetch.ts
3884
- var import_utils22 = require("@fuel-ts/utils");
3885
3894
  function getWaitDelay(options, retryAttemptNum) {
3886
3895
  const duration = options.baseDelay ?? 150;
3887
3896
  switch (options.backoff) {
@@ -3911,7 +3920,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
3911
3920
  throw error;
3912
3921
  }
3913
3922
  const delay = getWaitDelay(options, retryNum);
3914
- await (0, import_utils22.sleep)(delay);
3923
+ await sleep(delay);
3915
3924
  return autoRetryFetch(fetchFn, options, retryNum)(...args);
3916
3925
  }
3917
3926
  };
@@ -4251,7 +4260,7 @@ Supported fuel-core version: ${supportedVersion}.`
4251
4260
  if (estimateTxDependencies) {
4252
4261
  await this.estimateTxDependencies(transactionRequest);
4253
4262
  }
4254
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4263
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4255
4264
  let abis;
4256
4265
  if (transactionRequest.type === import_transactions20.TransactionType.Script) {
4257
4266
  abis = transactionRequest.abis;
@@ -4294,7 +4303,7 @@ Supported fuel-core version: ${supportedVersion}.`
4294
4303
  if (estimateTxDependencies) {
4295
4304
  return this.estimateTxDependencies(transactionRequest);
4296
4305
  }
4297
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4306
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4298
4307
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4299
4308
  encodedTransactions: encodedTransaction,
4300
4309
  utxoValidation: utxoValidation || false
@@ -4312,13 +4321,13 @@ Supported fuel-core version: ${supportedVersion}.`
4312
4321
  async estimatePredicates(transactionRequest) {
4313
4322
  const shouldEstimatePredicates = Boolean(
4314
4323
  transactionRequest.inputs.find(
4315
- (input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
4324
+ (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
4316
4325
  )
4317
4326
  );
4318
4327
  if (!shouldEstimatePredicates) {
4319
4328
  return transactionRequest;
4320
4329
  }
4321
- const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4330
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4322
4331
  const response = await this.operations.estimatePredicates({
4323
4332
  encodedTransaction
4324
4333
  });
@@ -4360,7 +4369,7 @@ Supported fuel-core version: ${supportedVersion}.`
4360
4369
  const {
4361
4370
  dryRun: [{ receipts: rawReceipts, status }]
4362
4371
  } = await this.operations.dryRun({
4363
- encodedTransactions: [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())],
4372
+ encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
4364
4373
  utxoValidation: false
4365
4374
  });
4366
4375
  receipts = rawReceipts.map(processGqlReceipt);
@@ -4410,7 +4419,7 @@ Supported fuel-core version: ${supportedVersion}.`
4410
4419
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4411
4420
  allRequests.forEach((req, index) => {
4412
4421
  if (req.type === import_transactions20.TransactionType.Script) {
4413
- serializedTransactionsMap.set(index, (0, import_utils23.hexlify)(req.toTransactionBytes()));
4422
+ serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
4414
4423
  }
4415
4424
  });
4416
4425
  let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
@@ -4446,7 +4455,7 @@ Supported fuel-core version: ${supportedVersion}.`
4446
4455
  transactionRequest: request
4447
4456
  });
4448
4457
  request.maxFee = maxFee;
4449
- serializedTransactionsMap.set(requestIdx, (0, import_utils23.hexlify)(request.toTransactionBytes()));
4458
+ serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
4450
4459
  nextRoundTransactions.push(requestIdx);
4451
4460
  }
4452
4461
  }
@@ -4459,7 +4468,7 @@ Supported fuel-core version: ${supportedVersion}.`
4459
4468
  if (estimateTxDependencies) {
4460
4469
  return this.estimateMultipleTxDependencies(transactionRequests);
4461
4470
  }
4462
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils23.hexlify)(tx.toTransactionBytes()));
4471
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
4463
4472
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4464
4473
  encodedTransactions,
4465
4474
  utxoValidation: utxoValidation || false
@@ -4532,7 +4541,7 @@ Supported fuel-core version: ${supportedVersion}.`
4532
4541
  if (estimateTxDependencies) {
4533
4542
  return this.estimateTxDependencies(transactionRequest);
4534
4543
  }
4535
- const encodedTransactions = [(0, import_utils23.hexlify)(transactionRequest.toTransactionBytes())];
4544
+ const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
4536
4545
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
4537
4546
  encodedTransactions,
4538
4547
  utxoValidation: true
@@ -4651,7 +4660,7 @@ Supported fuel-core version: ${supportedVersion}.`
4651
4660
  const result = await this.operations.getCoins({
4652
4661
  first: 10,
4653
4662
  ...paginationArgs,
4654
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4663
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4655
4664
  });
4656
4665
  const coins = result.coins.edges.map((edge) => edge.node);
4657
4666
  return coins.map((coin) => ({
@@ -4674,19 +4683,19 @@ Supported fuel-core version: ${supportedVersion}.`
4674
4683
  async getResourcesToSpend(owner, quantities, excludedIds) {
4675
4684
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4676
4685
  const excludeInput = {
4677
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4678
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4686
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4687
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4679
4688
  };
4680
4689
  if (this.cache) {
4681
4690
  const uniqueUtxos = new Set(
4682
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4691
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4683
4692
  );
4684
4693
  excludeInput.utxos = Array.from(uniqueUtxos);
4685
4694
  }
4686
4695
  const coinsQuery = {
4687
4696
  owner: ownerAddress.toB256(),
4688
4697
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4689
- assetId: (0, import_utils23.hexlify)(assetId),
4698
+ assetId: (0, import_utils22.hexlify)(assetId),
4690
4699
  amount: amount.toString(10),
4691
4700
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4692
4701
  })),
@@ -4788,7 +4797,7 @@ Supported fuel-core version: ${supportedVersion}.`
4788
4797
  time: block.header.time,
4789
4798
  transactionIds: block.transactions.map((tx) => tx.id),
4790
4799
  transactions: block.transactions.map(
4791
- (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4800
+ (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4792
4801
  )
4793
4802
  };
4794
4803
  }
@@ -4804,7 +4813,7 @@ Supported fuel-core version: ${supportedVersion}.`
4804
4813
  return null;
4805
4814
  }
4806
4815
  return new import_transactions20.TransactionCoder().decode(
4807
- (0, import_utils23.arrayify)(transaction.rawPayload),
4816
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4808
4817
  0
4809
4818
  )?.[0];
4810
4819
  }
@@ -4831,7 +4840,7 @@ Supported fuel-core version: ${supportedVersion}.`
4831
4840
  async getContractBalance(contractId, assetId) {
4832
4841
  const { contractBalance } = await this.operations.getContractBalance({
4833
4842
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4834
- asset: (0, import_utils23.hexlify)(assetId)
4843
+ asset: (0, import_utils22.hexlify)(assetId)
4835
4844
  });
4836
4845
  return (0, import_math17.bn)(contractBalance.amount, 10);
4837
4846
  }
@@ -4845,7 +4854,7 @@ Supported fuel-core version: ${supportedVersion}.`
4845
4854
  async getBalance(owner, assetId) {
4846
4855
  const { balance } = await this.operations.getBalance({
4847
4856
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4848
- assetId: (0, import_utils23.hexlify)(assetId)
4857
+ assetId: (0, import_utils22.hexlify)(assetId)
4849
4858
  });
4850
4859
  return (0, import_math17.bn)(balance.amount, 10);
4851
4860
  }
@@ -5022,7 +5031,7 @@ Supported fuel-core version: ${supportedVersion}.`
5022
5031
  async produceBlocks(amount, startTime) {
5023
5032
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
5024
5033
  blocksToProduce: (0, import_math17.bn)(amount).toString(10),
5025
- startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
5034
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
5026
5035
  });
5027
5036
  return (0, import_math17.bn)(latestBlockHeight);
5028
5037
  }
@@ -5088,7 +5097,7 @@ __publicField(Provider, "nodeInfoCache", {});
5088
5097
  var import_errors15 = require("@fuel-ts/errors");
5089
5098
  var import_math18 = require("@fuel-ts/math");
5090
5099
  var import_transactions21 = require("@fuel-ts/transactions");
5091
- var import_utils26 = require("@fuel-ts/utils");
5100
+ var import_utils25 = require("@fuel-ts/utils");
5092
5101
  async function getTransactionSummary(params) {
5093
5102
  const { id, provider, abiMap } = params;
5094
5103
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
@@ -5101,7 +5110,7 @@ async function getTransactionSummary(params) {
5101
5110
  );
5102
5111
  }
5103
5112
  const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
5104
- (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
5113
+ (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
5105
5114
  0
5106
5115
  );
5107
5116
  let txReceipts = [];
@@ -5121,7 +5130,7 @@ async function getTransactionSummary(params) {
5121
5130
  id: gqlTransaction.id,
5122
5131
  receipts,
5123
5132
  transaction: decodedTransaction,
5124
- transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
5133
+ transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
5125
5134
  gqlTransactionStatus: gqlTransaction.status,
5126
5135
  gasPerByte: (0, import_math18.bn)(gasPerByte),
5127
5136
  gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
@@ -5173,7 +5182,7 @@ async function getTransactionsSummaries(params) {
5173
5182
  const transactions = edges.map((edge) => {
5174
5183
  const { node: gqlTransaction } = edge;
5175
5184
  const { id, rawPayload, status } = gqlTransaction;
5176
- const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
5185
+ const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
5177
5186
  let txReceipts = [];
5178
5187
  if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
5179
5188
  txReceipts = gqlTransaction.status.receipts;
@@ -5183,7 +5192,7 @@ async function getTransactionsSummaries(params) {
5183
5192
  id,
5184
5193
  receipts,
5185
5194
  transaction: decodedTransaction,
5186
- transactionBytes: (0, import_utils26.arrayify)(rawPayload),
5195
+ transactionBytes: (0, import_utils25.arrayify)(rawPayload),
5187
5196
  gqlTransactionStatus: status,
5188
5197
  abiMap,
5189
5198
  gasPerByte,
@@ -5333,16 +5342,16 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
5333
5342
  // src/utils/formatTransferToContractScriptData.ts
5334
5343
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5335
5344
  var import_math19 = require("@fuel-ts/math");
5336
- var import_utils28 = require("@fuel-ts/utils");
5345
+ var import_utils27 = require("@fuel-ts/utils");
5337
5346
  var asm = __toESM(require("@fuels/vm-asm"));
5338
5347
  var formatTransferToContractScriptData = (params) => {
5339
5348
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5340
5349
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5341
5350
  const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
5342
5351
  const scriptData = Uint8Array.from([
5343
- ...(0, import_utils28.arrayify)(hexlifiedContractId),
5352
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
5344
5353
  ...encoded,
5345
- ...(0, import_utils28.arrayify)(assetId)
5354
+ ...(0, import_utils27.arrayify)(assetId)
5346
5355
  ]);
5347
5356
  return scriptData;
5348
5357
  };
@@ -5626,19 +5635,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5626
5635
  */
5627
5636
  async createTransfer(destination, amount, assetId, txParams = {}) {
5628
5637
  let request = new ScriptTransactionRequest(txParams);
5629
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5630
- request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
5631
- const txCost = await this.provider.getTransactionCost(request, {
5632
- estimateTxDependencies: true,
5633
- resourcesOwner: this
5634
- });
5635
- request = this.validateGasLimitAndMaxFee({
5636
- transactionRequest: request,
5637
- gasUsed: txCost.gasUsed,
5638
- maxFee: txCost.maxFee,
5639
- txParams
5640
- });
5641
- await this.fund(request, txCost);
5638
+ request = this.addTransfer(request, { destination, amount, assetId });
5639
+ request = await this.estimateAndFundTransaction(request, txParams);
5642
5640
  return request;
5643
5641
  }
5644
5642
  /**
@@ -5651,16 +5649,57 @@ var Account = class extends import_interfaces.AbstractAccount {
5651
5649
  * @returns A promise that resolves to the transaction response.
5652
5650
  */
5653
5651
  async transfer(destination, amount, assetId, txParams = {}) {
5654
- if ((0, import_math20.bn)(amount).lte(0)) {
5655
- throw new import_errors16.FuelError(
5656
- import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5657
- "Transfer amount must be a positive number."
5658
- );
5659
- }
5660
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5661
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5652
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
5653
+ return this.sendTransaction(request, { estimateTxDependencies: false });
5654
+ }
5655
+ /**
5656
+ * Transfers multiple amounts of a token to multiple recipients.
5657
+ *
5658
+ * @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
5659
+ * @param txParams - Optional transaction parameters.
5660
+ * @returns A promise that resolves to a `TransactionResponse` object representing the transaction result.
5661
+ */
5662
+ async batchTransfer(transferParams, txParams = {}) {
5663
+ let request = new ScriptTransactionRequest(txParams);
5664
+ request = this.addBatchTransfer(request, transferParams);
5665
+ request = await this.estimateAndFundTransaction(request, txParams);
5662
5666
  return this.sendTransaction(request, { estimateTxDependencies: false });
5663
5667
  }
5668
+ /**
5669
+ * Adds a transfer to the given transaction request.
5670
+ *
5671
+ * @param request - The script transaction request to add transfers to.
5672
+ * @param transferParams - The object representing the transfer to be made.
5673
+ * @returns The updated transaction request with the added transfer.
5674
+ */
5675
+ addTransfer(request, transferParams) {
5676
+ const { destination, amount, assetId } = transferParams;
5677
+ this.validateTransferAmount(amount);
5678
+ request.addCoinOutput(
5679
+ import_address4.Address.fromAddressOrString(destination),
5680
+ amount,
5681
+ assetId ?? this.provider.getBaseAssetId()
5682
+ );
5683
+ return request;
5684
+ }
5685
+ /**
5686
+ * Adds multiple transfers to a script transaction request.
5687
+ *
5688
+ * @param request - The script transaction request to add transfers to.
5689
+ * @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
5690
+ * @returns The updated script transaction request.
5691
+ */
5692
+ addBatchTransfer(request, transferParams) {
5693
+ const baseAssetId = this.provider.getBaseAssetId();
5694
+ transferParams.forEach(({ destination, amount, assetId }) => {
5695
+ this.addTransfer(request, {
5696
+ destination,
5697
+ amount,
5698
+ assetId: assetId ?? baseAssetId
5699
+ });
5700
+ });
5701
+ return request;
5702
+ }
5664
5703
  /**
5665
5704
  * Transfers coins to a contract address.
5666
5705
  *
@@ -5713,14 +5752,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5713
5752
  */
5714
5753
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5715
5754
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5716
- const recipientDataArray = (0, import_utils29.arrayify)(
5755
+ const recipientDataArray = (0, import_utils28.arrayify)(
5717
5756
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5718
5757
  );
5719
- const amountDataArray = (0, import_utils29.arrayify)(
5758
+ const amountDataArray = (0, import_utils28.arrayify)(
5720
5759
  "0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
5721
5760
  );
5722
5761
  const script = new Uint8Array([
5723
- ...(0, import_utils29.arrayify)(withdrawScript.bytes),
5762
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5724
5763
  ...recipientDataArray,
5725
5764
  ...amountDataArray
5726
5765
  ]);
@@ -5738,6 +5777,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5738
5777
  await this.fund(request, txCost);
5739
5778
  return this.sendTransaction(request);
5740
5779
  }
5780
+ /** @hidden * */
5741
5781
  async signMessage(message) {
5742
5782
  if (!this._connector) {
5743
5783
  throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
@@ -5793,6 +5833,31 @@ var Account = class extends import_interfaces.AbstractAccount {
5793
5833
  }
5794
5834
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5795
5835
  }
5836
+ /** @hidden * */
5837
+ validateTransferAmount(amount) {
5838
+ if ((0, import_math20.bn)(amount).lte(0)) {
5839
+ throw new import_errors16.FuelError(
5840
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5841
+ "Transfer amount must be a positive number."
5842
+ );
5843
+ }
5844
+ }
5845
+ /** @hidden * */
5846
+ async estimateAndFundTransaction(transactionRequest, txParams) {
5847
+ let request = transactionRequest;
5848
+ const txCost = await this.provider.getTransactionCost(request, {
5849
+ resourcesOwner: this
5850
+ });
5851
+ request = this.validateGasLimitAndMaxFee({
5852
+ transactionRequest: request,
5853
+ gasUsed: txCost.gasUsed,
5854
+ maxFee: txCost.maxFee,
5855
+ txParams
5856
+ });
5857
+ request = await this.fund(request, txCost);
5858
+ return request;
5859
+ }
5860
+ /** @hidden * */
5796
5861
  validateGasLimitAndMaxFee({
5797
5862
  gasUsed,
5798
5863
  maxFee,
@@ -5800,7 +5865,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5800
5865
  txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
5801
5866
  }) {
5802
5867
  const request = transactionRequestify(transactionRequest);
5803
- if (!(0, import_utils29.isDefined)(setGasLimit)) {
5868
+ if (!(0, import_utils28.isDefined)(setGasLimit)) {
5804
5869
  request.gasLimit = gasUsed;
5805
5870
  } else if (gasUsed.gt(setGasLimit)) {
5806
5871
  throw new import_errors16.FuelError(
@@ -5808,7 +5873,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5808
5873
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5809
5874
  );
5810
5875
  }
5811
- if (!(0, import_utils29.isDefined)(setMaxFee)) {
5876
+ if (!(0, import_utils28.isDefined)(setMaxFee)) {
5812
5877
  request.maxFee = maxFee;
5813
5878
  } else if (maxFee.gt(setMaxFee)) {
5814
5879
  throw new import_errors16.FuelError(
@@ -5822,14 +5887,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5822
5887
 
5823
5888
  // src/wallet/base-wallet-unlocked.ts
5824
5889
  var import_hasher3 = require("@fuel-ts/hasher");
5825
- var import_utils32 = require("@fuel-ts/utils");
5890
+ var import_utils31 = require("@fuel-ts/utils");
5826
5891
 
5827
5892
  // src/signer/signer.ts
5828
5893
  var import_address5 = require("@fuel-ts/address");
5829
5894
  var import_crypto2 = require("@fuel-ts/crypto");
5830
5895
  var import_hasher2 = require("@fuel-ts/hasher");
5831
5896
  var import_math21 = require("@fuel-ts/math");
5832
- var import_utils30 = require("@fuel-ts/utils");
5897
+ var import_utils29 = require("@fuel-ts/utils");
5833
5898
  var import_secp256k1 = require("@noble/curves/secp256k1");
5834
5899
  var Signer = class {
5835
5900
  address;
@@ -5849,9 +5914,9 @@ var Signer = class {
5849
5914
  }
5850
5915
  }
5851
5916
  const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
5852
- this.privateKey = (0, import_utils30.hexlify)(privateKeyBytes);
5853
- this.publicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5854
- this.compressedPublicKey = (0, import_utils30.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5917
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5918
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5919
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5855
5920
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5856
5921
  }
5857
5922
  /**
@@ -5865,11 +5930,11 @@ var Signer = class {
5865
5930
  * @returns hashed signature
5866
5931
  */
5867
5932
  sign(data) {
5868
- const signature = import_secp256k1.secp256k1.sign((0, import_utils30.arrayify)(data), (0, import_utils30.arrayify)(this.privateKey));
5933
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5869
5934
  const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
5870
5935
  const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
5871
5936
  s[0] |= (signature.recovery || 0) << 7;
5872
- return (0, import_utils30.hexlify)((0, import_utils30.concat)([r, s]));
5937
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5873
5938
  }
5874
5939
  /**
5875
5940
  * Add point on the current elliptic curve
@@ -5878,8 +5943,8 @@ var Signer = class {
5878
5943
  * @returns compressed point on the curve
5879
5944
  */
5880
5945
  addPoint(point) {
5881
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(this.compressedPublicKey));
5882
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(point));
5946
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5947
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5883
5948
  const result = p0.add(p1);
5884
5949
  return `0x${result.toHex(true)}`;
5885
5950
  }
@@ -5891,16 +5956,16 @@ var Signer = class {
5891
5956
  * @returns public key from signature from the
5892
5957
  */
5893
5958
  static recoverPublicKey(data, signature) {
5894
- const signedMessageBytes = (0, import_utils30.arrayify)(signature);
5959
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5895
5960
  const r = signedMessageBytes.slice(0, 32);
5896
5961
  const s = signedMessageBytes.slice(32, 64);
5897
5962
  const recoveryParam = (s[0] & 128) >> 7;
5898
5963
  s[0] &= 127;
5899
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils30.hexlify)(r)), BigInt((0, import_utils30.hexlify)(s))).addRecoveryBit(
5964
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5900
5965
  recoveryParam
5901
5966
  );
5902
- const publicKey = sig.recoverPublicKey((0, import_utils30.arrayify)(data)).toRawBytes(false).slice(1);
5903
- return (0, import_utils30.hexlify)(publicKey);
5967
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5968
+ return (0, import_utils29.hexlify)(publicKey);
5904
5969
  }
5905
5970
  /**
5906
5971
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5919,7 +5984,7 @@ var Signer = class {
5919
5984
  * @returns random 32-byte hashed
5920
5985
  */
5921
5986
  static generatePrivateKey(entropy) {
5922
- return entropy ? (0, import_hasher2.hash)((0, import_utils30.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils30.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
5987
+ 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);
5923
5988
  }
5924
5989
  /**
5925
5990
  * Extended publicKey from a compact publicKey
@@ -5928,8 +5993,8 @@ var Signer = class {
5928
5993
  * @returns extended publicKey
5929
5994
  */
5930
5995
  static extendPublicKey(publicKey) {
5931
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils30.arrayify)(publicKey));
5932
- return (0, import_utils30.hexlify)(point.toRawBytes(false).slice(1));
5996
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5997
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5933
5998
  }
5934
5999
  };
5935
6000
 
@@ -5937,7 +6002,7 @@ var Signer = class {
5937
6002
  var import_address6 = require("@fuel-ts/address");
5938
6003
  var import_crypto3 = require("@fuel-ts/crypto");
5939
6004
  var import_errors17 = require("@fuel-ts/errors");
5940
- var import_utils31 = require("@fuel-ts/utils");
6005
+ var import_utils30 = require("@fuel-ts/utils");
5941
6006
  var import_uuid = require("uuid");
5942
6007
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5943
6008
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -6020,7 +6085,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
6020
6085
  );
6021
6086
  }
6022
6087
  const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
6023
- const privateKey = (0, import_utils31.hexlify)(buffer);
6088
+ const privateKey = (0, import_utils30.hexlify)(buffer);
6024
6089
  return privateKey;
6025
6090
  }
6026
6091
 
@@ -6065,7 +6130,7 @@ var BaseWalletUnlocked = class extends Account {
6065
6130
  */
6066
6131
  async signMessage(message) {
6067
6132
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
6068
- return (0, import_utils32.hexlify)(signedMessage);
6133
+ return (0, import_utils31.hexlify)(signedMessage);
6069
6134
  }
6070
6135
  /**
6071
6136
  * Signs a transaction with the wallet's private key.
@@ -6078,7 +6143,7 @@ var BaseWalletUnlocked = class extends Account {
6078
6143
  const chainId = this.provider.getChainId();
6079
6144
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
6080
6145
  const signature = await this.signer().sign(hashedTransaction);
6081
- return (0, import_utils32.hexlify)(signature);
6146
+ return (0, import_utils31.hexlify)(signature);
6082
6147
  }
6083
6148
  /**
6084
6149
  * Populates a transaction with the witnesses signature.
@@ -6141,13 +6206,13 @@ var import_crypto5 = require("@fuel-ts/crypto");
6141
6206
  var import_errors20 = require("@fuel-ts/errors");
6142
6207
  var import_hasher6 = require("@fuel-ts/hasher");
6143
6208
  var import_math22 = require("@fuel-ts/math");
6144
- var import_utils36 = require("@fuel-ts/utils");
6209
+ var import_utils35 = require("@fuel-ts/utils");
6145
6210
 
6146
6211
  // src/mnemonic/mnemonic.ts
6147
6212
  var import_crypto4 = require("@fuel-ts/crypto");
6148
6213
  var import_errors19 = require("@fuel-ts/errors");
6149
6214
  var import_hasher5 = require("@fuel-ts/hasher");
6150
- var import_utils34 = require("@fuel-ts/utils");
6215
+ var import_utils33 = require("@fuel-ts/utils");
6151
6216
 
6152
6217
  // src/wordlists/words/english.ts
6153
6218
  var english = [
@@ -8210,7 +8275,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
8210
8275
  // src/mnemonic/utils.ts
8211
8276
  var import_errors18 = require("@fuel-ts/errors");
8212
8277
  var import_hasher4 = require("@fuel-ts/hasher");
8213
- var import_utils33 = require("@fuel-ts/utils");
8278
+ var import_utils32 = require("@fuel-ts/utils");
8214
8279
  function getLowerMask(bits) {
8215
8280
  return (1 << bits) - 1;
8216
8281
  }
@@ -8245,14 +8310,14 @@ function entropyToMnemonicIndices(entropy) {
8245
8310
  }
8246
8311
  }
8247
8312
  const checksumBits = entropy.length / 4;
8248
- const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8313
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
8249
8314
  indices[indices.length - 1] <<= checksumBits;
8250
8315
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
8251
8316
  return indices;
8252
8317
  }
8253
8318
  function mnemonicWordsToEntropy(words, wordlist) {
8254
8319
  const size = Math.ceil(11 * words.length / 8);
8255
- const entropy = (0, import_utils33.arrayify)(new Uint8Array(size));
8320
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
8256
8321
  let offset = 0;
8257
8322
  for (let i = 0; i < words.length; i += 1) {
8258
8323
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -8272,7 +8337,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8272
8337
  const entropyBits = 32 * words.length / 3;
8273
8338
  const checksumBits = words.length / 3;
8274
8339
  const checksumMask = getUpperMask(checksumBits);
8275
- const checksum = (0, import_utils33.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8340
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8276
8341
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8277
8342
  throw new import_errors18.FuelError(
8278
8343
  import_errors18.ErrorCode.INVALID_CHECKSUM,
@@ -8283,7 +8348,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8283
8348
  }
8284
8349
 
8285
8350
  // src/mnemonic/mnemonic.ts
8286
- var MasterSecret = (0, import_utils34.toUtf8Bytes)("Bitcoin seed");
8351
+ var MasterSecret = (0, import_utils33.toUtf8Bytes)("Bitcoin seed");
8287
8352
  var MainnetPRV = "0x0488ade4";
8288
8353
  var TestnetPRV = "0x04358394";
8289
8354
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
@@ -8347,7 +8412,7 @@ var Mnemonic = class {
8347
8412
  static mnemonicToEntropy(phrase, wordlist = english) {
8348
8413
  const words = getWords(phrase);
8349
8414
  assertMnemonic(words);
8350
- return (0, import_utils34.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8415
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
8351
8416
  }
8352
8417
  /**
8353
8418
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -8355,7 +8420,7 @@ var Mnemonic = class {
8355
8420
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8356
8421
  */
8357
8422
  static entropyToMnemonic(entropy, wordlist = english) {
8358
- const entropyBytes = (0, import_utils34.arrayify)(entropy);
8423
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
8359
8424
  assertWordList(wordlist);
8360
8425
  assertEntropy(entropyBytes);
8361
8426
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -8367,8 +8432,8 @@ var Mnemonic = class {
8367
8432
  */
8368
8433
  static mnemonicToSeed(phrase, passphrase = "") {
8369
8434
  assertMnemonic(getWords(phrase));
8370
- const phraseBytes = (0, import_utils34.toUtf8Bytes)(getPhrase(phrase));
8371
- const salt = (0, import_utils34.toUtf8Bytes)(`mnemonic${passphrase}`);
8435
+ const phraseBytes = (0, import_utils33.toUtf8Bytes)(getPhrase(phrase));
8436
+ const salt = (0, import_utils33.toUtf8Bytes)(`mnemonic${passphrase}`);
8372
8437
  return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8373
8438
  }
8374
8439
  /**
@@ -8424,14 +8489,14 @@ var Mnemonic = class {
8424
8489
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
8425
8490
  */
8426
8491
  static masterKeysFromSeed(seed) {
8427
- const seedArray = (0, import_utils34.arrayify)(seed);
8492
+ const seedArray = (0, import_utils33.arrayify)(seed);
8428
8493
  if (seedArray.length < 16 || seedArray.length > 64) {
8429
8494
  throw new import_errors19.FuelError(
8430
8495
  import_errors19.ErrorCode.INVALID_SEED,
8431
8496
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8432
8497
  );
8433
8498
  }
8434
- return (0, import_utils34.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
8499
+ return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
8435
8500
  }
8436
8501
  /**
8437
8502
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8442,22 +8507,22 @@ var Mnemonic = class {
8442
8507
  */
8443
8508
  static seedToExtendedKey(seed, testnet = false) {
8444
8509
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
8445
- const prefix = (0, import_utils34.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8510
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8446
8511
  const depth = "0x00";
8447
8512
  const fingerprint = "0x00000000";
8448
8513
  const index = "0x00000000";
8449
8514
  const chainCode = masterKey.slice(32);
8450
8515
  const privateKey = masterKey.slice(0, 32);
8451
- const extendedKey = (0, import_utils34.concat)([
8516
+ const extendedKey = (0, import_utils33.concat)([
8452
8517
  prefix,
8453
8518
  depth,
8454
8519
  fingerprint,
8455
8520
  index,
8456
8521
  chainCode,
8457
- (0, import_utils34.concat)(["0x00", privateKey])
8522
+ (0, import_utils33.concat)(["0x00", privateKey])
8458
8523
  ]);
8459
- const checksum = (0, import_utils34.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8460
- return (0, import_utils34.encodeBase58)((0, import_utils34.concat)([extendedKey, checksum]));
8524
+ const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8525
+ return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
8461
8526
  }
8462
8527
  /**
8463
8528
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8472,7 +8537,7 @@ var Mnemonic = class {
8472
8537
  * @returns A randomly generated mnemonic
8473
8538
  */
8474
8539
  static generate(size = 32, extraEntropy = "") {
8475
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils34.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils34.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
8540
+ 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);
8476
8541
  return Mnemonic.entropyToMnemonic(entropy);
8477
8542
  }
8478
8543
  };
@@ -8480,12 +8545,12 @@ var mnemonic_default = Mnemonic;
8480
8545
 
8481
8546
  // src/hdwallet/hdwallet.ts
8482
8547
  var HARDENED_INDEX = 2147483648;
8483
- var MainnetPRV2 = (0, import_utils36.hexlify)("0x0488ade4");
8484
- var MainnetPUB = (0, import_utils36.hexlify)("0x0488b21e");
8485
- var TestnetPRV2 = (0, import_utils36.hexlify)("0x04358394");
8486
- var TestnetPUB = (0, import_utils36.hexlify)("0x043587cf");
8548
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8549
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8550
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8551
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
8487
8552
  function base58check(data) {
8488
- return (0, import_utils36.encodeBase58)((0, import_utils36.concat)([data, (0, import_utils36.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8553
+ return (0, import_utils35.encodeBase58)((0, import_utils35.concat)([data, (0, import_utils35.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8489
8554
  }
8490
8555
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8491
8556
  if (isPublic) {
@@ -8494,11 +8559,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8494
8559
  return testnet ? TestnetPRV2 : MainnetPRV2;
8495
8560
  }
8496
8561
  function isPublicExtendedKey(extendedKey) {
8497
- return [MainnetPUB, TestnetPUB].includes((0, import_utils36.hexlify)(extendedKey.slice(0, 4)));
8562
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
8498
8563
  }
8499
8564
  function isValidExtendedKey(extendedKey) {
8500
8565
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
8501
- (0, import_utils36.hexlify)(extendedKey.slice(0, 4))
8566
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
8502
8567
  );
8503
8568
  }
8504
8569
  function parsePath(path, depth = 0) {
@@ -8516,8 +8581,8 @@ function parsePath(path, depth = 0) {
8516
8581
  var HDWallet = class {
8517
8582
  depth = 0;
8518
8583
  index = 0;
8519
- fingerprint = (0, import_utils36.hexlify)("0x00000000");
8520
- parentFingerprint = (0, import_utils36.hexlify)("0x00000000");
8584
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8585
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
8521
8586
  privateKey;
8522
8587
  publicKey;
8523
8588
  chainCode;
@@ -8529,8 +8594,8 @@ var HDWallet = class {
8529
8594
  constructor(config) {
8530
8595
  if (config.privateKey) {
8531
8596
  const signer = new Signer(config.privateKey);
8532
- this.publicKey = (0, import_utils36.hexlify)(signer.compressedPublicKey);
8533
- this.privateKey = (0, import_utils36.hexlify)(config.privateKey);
8597
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8598
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
8534
8599
  } else {
8535
8600
  if (!config.publicKey) {
8536
8601
  throw new import_errors20.FuelError(
@@ -8538,10 +8603,10 @@ var HDWallet = class {
8538
8603
  "Both public and private Key cannot be missing. At least one should be provided."
8539
8604
  );
8540
8605
  }
8541
- this.publicKey = (0, import_utils36.hexlify)(config.publicKey);
8606
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
8542
8607
  }
8543
8608
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8544
- this.fingerprint = (0, import_utils36.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8609
+ this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8545
8610
  this.depth = config.depth || this.depth;
8546
8611
  this.index = config.index || this.index;
8547
8612
  this.chainCode = config.chainCode;
@@ -8557,9 +8622,9 @@ var HDWallet = class {
8557
8622
  * @returns A new instance of HDWallet on the derived index
8558
8623
  */
8559
8624
  deriveIndex(index) {
8560
- const privateKey = this.privateKey && (0, import_utils36.arrayify)(this.privateKey);
8561
- const publicKey = (0, import_utils36.arrayify)(this.publicKey);
8562
- const chainCode = (0, import_utils36.arrayify)(this.chainCode);
8625
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8626
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8627
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8563
8628
  const data = new Uint8Array(37);
8564
8629
  if (index & HARDENED_INDEX) {
8565
8630
  if (!privateKey) {
@@ -8570,10 +8635,10 @@ var HDWallet = class {
8570
8635
  }
8571
8636
  data.set(privateKey, 1);
8572
8637
  } else {
8573
- data.set((0, import_utils36.arrayify)(this.publicKey));
8638
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8574
8639
  }
8575
8640
  data.set((0, import_math22.toBytes)(index, 4), 33);
8576
- const bytes = (0, import_utils36.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
8641
+ const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
8577
8642
  const IL = bytes.slice(0, 32);
8578
8643
  const IR = bytes.slice(32);
8579
8644
  if (privateKey) {
@@ -8587,7 +8652,7 @@ var HDWallet = class {
8587
8652
  parentFingerprint: this.fingerprint
8588
8653
  });
8589
8654
  }
8590
- const signer = new Signer((0, import_utils36.hexlify)(IL));
8655
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8591
8656
  const Ki = signer.addPoint(publicKey);
8592
8657
  return new HDWallet({
8593
8658
  publicKey: Ki,
@@ -8622,12 +8687,12 @@ var HDWallet = class {
8622
8687
  );
8623
8688
  }
8624
8689
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8625
- const depth = (0, import_utils36.hexlify)(Uint8Array.from([this.depth]));
8690
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8626
8691
  const parentFingerprint = this.parentFingerprint;
8627
8692
  const index = (0, import_math22.toHex)(this.index, 4);
8628
8693
  const chainCode = this.chainCode;
8629
- const key = this.privateKey != null && !isPublic ? (0, import_utils36.concat)(["0x00", this.privateKey]) : this.publicKey;
8630
- const extendedKey = (0, import_utils36.arrayify)((0, import_utils36.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8694
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8695
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8631
8696
  return base58check(extendedKey);
8632
8697
  }
8633
8698
  /**
@@ -8639,13 +8704,13 @@ var HDWallet = class {
8639
8704
  static fromSeed(seed) {
8640
8705
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8641
8706
  return new HDWallet({
8642
- chainCode: (0, import_utils36.arrayify)(masterKey.slice(32)),
8643
- privateKey: (0, import_utils36.arrayify)(masterKey.slice(0, 32))
8707
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8708
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8644
8709
  });
8645
8710
  }
8646
8711
  static fromExtendedKey(extendedKey) {
8647
- const decoded = (0, import_utils36.hexlify)((0, import_math22.toBytes)((0, import_utils36.decodeBase58)(extendedKey)));
8648
- const bytes = (0, import_utils36.arrayify)(decoded);
8712
+ const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
8713
+ const bytes = (0, import_utils35.arrayify)(decoded);
8649
8714
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8650
8715
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8651
8716
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -8654,9 +8719,9 @@ var HDWallet = class {
8654
8719
  throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8655
8720
  }
8656
8721
  const depth = bytes[4];
8657
- const parentFingerprint = (0, import_utils36.hexlify)(bytes.slice(5, 9));
8658
- const index = parseInt((0, import_utils36.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8659
- const chainCode = (0, import_utils36.hexlify)(bytes.slice(13, 45));
8722
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8723
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8724
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8660
8725
  const key = bytes.slice(45, 78);
8661
8726
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8662
8727
  throw new import_errors20.FuelError(
@@ -9260,18 +9325,18 @@ var StorageAbstract = class {
9260
9325
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
9261
9326
  var import_address10 = require("@fuel-ts/address");
9262
9327
  var import_errors25 = require("@fuel-ts/errors");
9263
- var import_utils38 = require("@fuel-ts/utils");
9328
+ var import_utils37 = require("@fuel-ts/utils");
9264
9329
 
9265
9330
  // src/predicate/utils/getPredicateRoot.ts
9266
9331
  var import_hasher7 = require("@fuel-ts/hasher");
9267
9332
  var import_merkle = require("@fuel-ts/merkle");
9268
- var import_utils37 = require("@fuel-ts/utils");
9333
+ var import_utils36 = require("@fuel-ts/utils");
9269
9334
  var getPredicateRoot = (bytecode) => {
9270
9335
  const chunkSize = 16 * 1024;
9271
- const bytes = (0, import_utils37.arrayify)(bytecode);
9272
- const chunks = (0, import_utils37.chunkAndPadBytes)(bytes, chunkSize);
9273
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils37.hexlify)(c)));
9274
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils37.concat)(["0x4655454C", codeRoot]));
9336
+ const bytes = (0, import_utils36.arrayify)(bytecode);
9337
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
9338
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
9339
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
9275
9340
  return predicateRoot;
9276
9341
  };
9277
9342
 
@@ -9323,8 +9388,8 @@ var Predicate = class extends Account {
9323
9388
  }
9324
9389
  request.inputs.filter(isRequestInputResource).forEach((input) => {
9325
9390
  if (isRequestInputResourceFromOwner(input, this.address)) {
9326
- input.predicate = (0, import_utils38.hexlify)(this.bytes);
9327
- input.predicateData = (0, import_utils38.hexlify)(this.getPredicateData());
9391
+ input.predicate = (0, import_utils37.hexlify)(this.bytes);
9392
+ input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData());
9328
9393
  input.witnessIndex = 0;
9329
9394
  }
9330
9395
  });
@@ -9366,7 +9431,7 @@ var Predicate = class extends Account {
9366
9431
  * @returns An object containing the new predicate bytes and interface.
9367
9432
  */
9368
9433
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
9369
- let predicateBytes = (0, import_utils38.arrayify)(bytes);
9434
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
9370
9435
  let abiInterface;
9371
9436
  if (jsonAbi) {
9372
9437
  abiInterface = new import_abi_coder7.Interface(jsonAbi);
@@ -9404,7 +9469,7 @@ var Predicate = class extends Account {
9404
9469
  );
9405
9470
  return resources.map((resource) => ({
9406
9471
  ...resource,
9407
- predicate: (0, import_utils38.hexlify)(this.bytes)
9472
+ predicate: (0, import_utils37.hexlify)(this.bytes)
9408
9473
  }));
9409
9474
  }
9410
9475
  /**
@@ -10269,6 +10334,7 @@ __publicField(Fuel, "defaultConfig", {});
10269
10334
  resolveGasDependentCosts,
10270
10335
  resolveIconPaths,
10271
10336
  returnZeroScript,
10337
+ sleep,
10272
10338
  transactionRequestify,
10273
10339
  urlJoin,
10274
10340
  withTimeout,