@fuel-ts/account 0.101.0 → 0.101.2

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.
@@ -405,7 +405,7 @@ var launchNode = /* @__PURE__ */ __name(async ({
405
405
  ), "launchNode");
406
406
 
407
407
  // src/test-utils/setup-test-provider-and-wallets.ts
408
- var import_utils46 = require("@fuel-ts/utils");
408
+ var import_utils47 = require("@fuel-ts/utils");
409
409
  var import_ramda10 = require("ramda");
410
410
 
411
411
  // src/providers/coin-quantity.ts
@@ -447,7 +447,7 @@ var import_address4 = require("@fuel-ts/address");
447
447
  var import_errors21 = require("@fuel-ts/errors");
448
448
  var import_math20 = require("@fuel-ts/math");
449
449
  var import_transactions25 = require("@fuel-ts/transactions");
450
- var import_utils32 = require("@fuel-ts/utils");
450
+ var import_utils33 = require("@fuel-ts/utils");
451
451
  var import_versions = require("@fuel-ts/versions");
452
452
  var import_graphql_request = require("graphql-request");
453
453
  var import_graphql_tag2 = __toESM(require("graphql-tag"));
@@ -2891,58 +2891,97 @@ ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
2891
2891
  });
2892
2892
  }, "assemblePanicError");
2893
2893
  var stringify = /* @__PURE__ */ __name((obj) => JSON.stringify(obj, null, 2), "stringify");
2894
- var assembleRevertError = /* @__PURE__ */ __name((receipts, logs, metadata) => {
2894
+ var assembleSignalErrorMessage = /* @__PURE__ */ __name((reasonHex, logs, metadata) => {
2895
2895
  let errorMessage = "The transaction reverted with an unknown reason.";
2896
- const revertReceipt = receipts.find(({ type }) => type === import_transactions7.ReceiptType.Revert);
2897
2896
  let reason = "";
2898
- if (revertReceipt) {
2899
- const reasonHex = (0, import_math8.bn)(revertReceipt.val).toHex();
2900
- const lastLog = logs[logs.length - 1];
2901
- const lastButOneLog = logs[logs.length - 2];
2902
- switch (reasonHex) {
2903
- case import_configs5.FAILED_REQUIRE_SIGNAL: {
2904
- reason = "require";
2905
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
2906
- break;
2907
- }
2908
- case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
2909
- const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
2910
- reason = "assert_eq";
2911
- errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
2912
- break;
2913
- }
2914
- case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
2915
- const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
2916
- reason = "assert_ne";
2917
- errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
2918
- break;
2919
- }
2920
- case import_configs5.FAILED_ASSERT_SIGNAL:
2921
- reason = "assert";
2922
- errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
2923
- break;
2924
- case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
2925
- reason = "MissingOutputVariable";
2926
- errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
2927
- break;
2928
- default:
2929
- throw new import_errors9.FuelError(
2930
- import_errors9.ErrorCode.UNKNOWN,
2931
- `The transaction reverted with an unknown reason: ${revertReceipt.val}`,
2932
- {
2933
- ...metadata,
2934
- reason: "unknown"
2935
- }
2936
- );
2897
+ const lastLog = logs[logs.length - 1];
2898
+ const lastButOneLog = logs[logs.length - 2];
2899
+ switch (reasonHex) {
2900
+ case import_configs5.FAILED_REQUIRE_SIGNAL: {
2901
+ reason = "require";
2902
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
2903
+ break;
2904
+ }
2905
+ case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
2906
+ const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
2907
+ reason = "assert_eq";
2908
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
2909
+ break;
2937
2910
  }
2911
+ case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
2912
+ const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
2913
+ reason = "assert_ne";
2914
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
2915
+ break;
2916
+ }
2917
+ case import_configs5.FAILED_ASSERT_SIGNAL:
2918
+ reason = "assert";
2919
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
2920
+ break;
2921
+ case import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
2922
+ reason = "MissingOutputVariable";
2923
+ errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
2924
+ break;
2925
+ default:
2926
+ reason = `revert_with_log`;
2927
+ errorMessage = `The transaction reverted because a "revert_with_log" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
2928
+ break;
2938
2929
  }
2939
2930
  return new import_errors9.FuelError(import_errors9.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2940
2931
  ...metadata,
2941
2932
  reason
2942
2933
  });
2934
+ }, "assembleSignalErrorMessage");
2935
+ function buildAbiErrorMessage(abiError, logs, metadata, reason) {
2936
+ const { pos, msg } = abiError;
2937
+ let errorMessage = "";
2938
+ const positionMessage = pos ? `
2939
+
2940
+ This error originated at ${JSON.stringify(pos, null, 2)}` : "";
2941
+ if (msg) {
2942
+ errorMessage = `A sway "panic" expression was invoked with the message: "${msg}".${positionMessage}`;
2943
+ } else {
2944
+ const value = logs[logs.length - 1];
2945
+ errorMessage = `A sway "panic" expression was invoked with the value: ${JSON.stringify(value)}.${positionMessage}`;
2946
+ }
2947
+ return new import_errors9.FuelError(import_errors9.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2948
+ ...metadata,
2949
+ reason
2950
+ });
2951
+ }
2952
+ __name(buildAbiErrorMessage, "buildAbiErrorMessage");
2953
+ function findErrorInAbis(statusReason, abis = []) {
2954
+ for (const abi of abis) {
2955
+ if (abi.errorCodes?.[statusReason]) {
2956
+ return abi.errorCodes[statusReason];
2957
+ }
2958
+ }
2959
+ return void 0;
2960
+ }
2961
+ __name(findErrorInAbis, "findErrorInAbis");
2962
+ var assembleRevertError = /* @__PURE__ */ __name((_receipts, logs, metadata, statusReason, abis) => {
2963
+ const match = statusReason.match(/Revert\((\d+)\)/);
2964
+ const reason = match?.[1] ?? statusReason;
2965
+ const reasonHex = (0, import_math8.bn)(reason).toHex();
2966
+ if (Object.values(import_configs5.SwaySignalErrors).includes(reasonHex)) {
2967
+ return assembleSignalErrorMessage(reasonHex, logs, metadata);
2968
+ }
2969
+ let abiError;
2970
+ if (abis) {
2971
+ const abisArr = [abis.main, ...Object.values(abis.otherContractsAbis)];
2972
+ abiError = findErrorInAbis(reason, abisArr);
2973
+ }
2974
+ if (abiError) {
2975
+ return buildAbiErrorMessage(abiError, logs, metadata, reason);
2976
+ }
2977
+ const errorMessage = `The transaction reverted with reason: ${reason}.`;
2978
+ return new import_errors9.FuelError(import_errors9.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2979
+ ...metadata,
2980
+ reason
2981
+ });
2943
2982
  }, "assembleRevertError");
2944
2983
  var extractTxError = /* @__PURE__ */ __name((params) => {
2945
- const { receipts, statusReason, logs, groupedLogs } = params;
2984
+ const { receipts, statusReason, logs, groupedLogs, abis } = params;
2946
2985
  const isPanic = receipts.some(({ type }) => type === import_transactions7.ReceiptType.Panic);
2947
2986
  const isRevert = receipts.some(({ type }) => type === import_transactions7.ReceiptType.Revert);
2948
2987
  const metadata = {
@@ -2956,7 +2995,7 @@ var extractTxError = /* @__PURE__ */ __name((params) => {
2956
2995
  if (isPanic) {
2957
2996
  return assemblePanicError(statusReason, metadata);
2958
2997
  }
2959
- return assembleRevertError(receipts, logs, metadata);
2998
+ return assembleRevertError(receipts, logs, metadata, statusReason, abis);
2960
2999
  }, "extractTxError");
2961
3000
 
2962
3001
  // src/providers/utils/merge-quantities.ts
@@ -4500,12 +4539,12 @@ var ResourceCache = class {
4500
4539
  var import_errors19 = require("@fuel-ts/errors");
4501
4540
  var import_math19 = require("@fuel-ts/math");
4502
4541
  var import_transactions23 = require("@fuel-ts/transactions");
4503
- var import_utils29 = require("@fuel-ts/utils");
4542
+ var import_utils30 = require("@fuel-ts/utils");
4504
4543
 
4505
4544
  // src/providers/transaction-summary/assemble-transaction-summary.ts
4506
4545
  var import_math18 = require("@fuel-ts/math");
4507
4546
  var import_transactions21 = require("@fuel-ts/transactions");
4508
- var import_utils27 = require("@fuel-ts/utils");
4547
+ var import_utils28 = require("@fuel-ts/utils");
4509
4548
 
4510
4549
  // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
4511
4550
  var import_math14 = require("@fuel-ts/math");
@@ -4578,6 +4617,45 @@ var import_configs11 = require("@fuel-ts/address/configs");
4578
4617
  var import_errors17 = require("@fuel-ts/errors");
4579
4618
  var import_math16 = require("@fuel-ts/math");
4580
4619
  var import_transactions19 = require("@fuel-ts/transactions");
4620
+ var import_utils26 = require("@fuel-ts/utils");
4621
+
4622
+ // src/providers/transaction-summary/call.ts
4623
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
4624
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
4625
+ var getFunctionCall = /* @__PURE__ */ __name(({
4626
+ abi,
4627
+ receipt,
4628
+ offset,
4629
+ scriptData
4630
+ }) => {
4631
+ const [functionSelector, argumentsOffset] = new import_abi_coder5.StdStringCoder().decode(scriptData, offset);
4632
+ const abiInterface = new import_abi_coder6.Interface(abi);
4633
+ const functionFragment = abiInterface.getFunction(functionSelector);
4634
+ const inputs = functionFragment.jsonFn.inputs;
4635
+ let argumentsProvided;
4636
+ if (inputs.length) {
4637
+ const functionArgsBytes = scriptData.slice(argumentsOffset);
4638
+ const decodedArguments = functionFragment.decodeArguments(functionArgsBytes);
4639
+ argumentsProvided = inputs.reduce((prev, input, index) => {
4640
+ const value = decodedArguments?.[index];
4641
+ const name = input.name;
4642
+ if (name) {
4643
+ return {
4644
+ ...prev,
4645
+ // reparse to remove bn
4646
+ [name]: JSON.parse(JSON.stringify(value))
4647
+ };
4648
+ }
4649
+ return prev;
4650
+ }, {});
4651
+ }
4652
+ return {
4653
+ functionSignature: functionFragment.signature,
4654
+ functionName: functionFragment.name,
4655
+ argumentsProvided,
4656
+ ...receipt.amount?.isZero() ? {} : { amount: receipt.amount, assetId: receipt.assetId }
4657
+ };
4658
+ }, "getFunctionCall");
4581
4659
 
4582
4660
  // src/providers/transaction-summary/input.ts
4583
4661
  var import_errors16 = require("@fuel-ts/errors");
@@ -4861,12 +4939,45 @@ function getWithdrawFromFuelOperations({
4861
4939
  return withdrawFromFuelOperations;
4862
4940
  }
4863
4941
  __name(getWithdrawFromFuelOperations, "getWithdrawFromFuelOperations");
4864
- function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
4865
- const abi = abiMap?.[contractInput.contractID];
4866
- if (!abi) {
4867
- return [];
4942
+ function findBytesSegmentIndex(whole, segment) {
4943
+ for (let i = 0; i <= whole.length - segment.length; i++) {
4944
+ let match = true;
4945
+ for (let j = 0; j < segment.length; j++) {
4946
+ if (whole[i + j] !== segment[j]) {
4947
+ match = false;
4948
+ break;
4949
+ }
4950
+ }
4951
+ if (match) {
4952
+ return i;
4953
+ }
4868
4954
  }
4869
- return [];
4955
+ return -1;
4956
+ }
4957
+ __name(findBytesSegmentIndex, "findBytesSegmentIndex");
4958
+ function getContractCalls(contractInput, abiMap, receipt, scriptData) {
4959
+ const calls = [];
4960
+ const abi = abiMap?.[contractInput.contractID];
4961
+ if (!abi || !scriptData) {
4962
+ return calls;
4963
+ }
4964
+ const bytesSegment = (0, import_utils26.concat)([
4965
+ (0, import_utils26.arrayify)(receipt.to),
4966
+ // Contract ID (32 bytes)
4967
+ (0, import_math16.toBytes)(receipt.param1.toHex(), 8),
4968
+ // Function selector offset (8 bytes)
4969
+ (0, import_math16.toBytes)(receipt.param2.toHex(), 8)
4970
+ // Function args offset (8 bytes)
4971
+ ]);
4972
+ const segmentIndex = findBytesSegmentIndex(scriptData, bytesSegment);
4973
+ const canDecodeFunctionCall = segmentIndex !== -1;
4974
+ if (!canDecodeFunctionCall) {
4975
+ return calls;
4976
+ }
4977
+ const offset = segmentIndex + bytesSegment.length;
4978
+ const call = getFunctionCall({ abi, receipt, offset, scriptData });
4979
+ calls.push(call);
4980
+ return calls;
4870
4981
  }
4871
4982
  __name(getContractCalls, "getContractCalls");
4872
4983
  function getAssetsSent(receipt) {
@@ -4878,14 +4989,14 @@ function getAssetsSent(receipt) {
4878
4989
  ];
4879
4990
  }
4880
4991
  __name(getAssetsSent, "getAssetsSent");
4881
- function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
4992
+ function processCallReceipt(receipt, contractInput, inputs, abiMap, scriptData, baseAssetId) {
4882
4993
  const assetId = receipt.assetId === import_configs11.ZeroBytes32 ? baseAssetId : receipt.assetId;
4883
4994
  const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
4884
4995
  if (!input) {
4885
4996
  return [];
4886
4997
  }
4887
4998
  const inputAddress = getInputAccountAddress(input);
4888
- const calls = getContractCalls(contractInput, abiMap, receipt, rawPayload, maxInputs);
4999
+ const calls = getContractCalls(contractInput, abiMap, receipt, scriptData);
4889
5000
  return [
4890
5001
  {
4891
5002
  name: "Contract call" /* contractCall */,
@@ -4910,7 +5021,6 @@ function getContractCallOperations({
4910
5021
  receipts,
4911
5022
  abiMap,
4912
5023
  rawPayload,
4913
- maxInputs,
4914
5024
  baseAssetId
4915
5025
  }) {
4916
5026
  const contractCallReceipts = getReceiptsCall(receipts);
@@ -4920,16 +5030,15 @@ function getContractCallOperations({
4920
5030
  if (!contractInput) {
4921
5031
  return [];
4922
5032
  }
5033
+ let scriptData;
5034
+ if (rawPayload) {
5035
+ const [transaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
5036
+ if (transaction.type === import_transactions19.TransactionType.Script) {
5037
+ scriptData = (0, import_utils26.arrayify)(transaction.scriptData);
5038
+ }
5039
+ }
4923
5040
  return contractCallReceipts.filter((receipt) => receipt.to === contractInput.contractID).flatMap(
4924
- (receipt) => processCallReceipt(
4925
- receipt,
4926
- contractInput,
4927
- inputs,
4928
- abiMap,
4929
- rawPayload,
4930
- maxInputs,
4931
- baseAssetId
4932
- )
5041
+ (receipt) => processCallReceipt(receipt, contractInput, inputs, abiMap, scriptData, baseAssetId)
4933
5042
  );
4934
5043
  });
4935
5044
  }
@@ -5253,7 +5362,7 @@ function assembleTransactionSummary(params) {
5253
5362
  baseAssetId
5254
5363
  } = params;
5255
5364
  const gasUsed = getGasUsedFromReceipts(receipts);
5256
- const rawPayload = (0, import_utils27.hexlify)(transactionBytes);
5365
+ const rawPayload = (0, import_utils28.hexlify)(transactionBytes);
5257
5366
  const operations = getOperations({
5258
5367
  transactionType: transaction.type,
5259
5368
  inputs: transaction.inputs || [],
@@ -5284,7 +5393,7 @@ function assembleTransactionSummary(params) {
5284
5393
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
5285
5394
  let date;
5286
5395
  if (time) {
5287
- date = import_utils27.DateTime.fromTai64(time);
5396
+ date = import_utils28.DateTime.fromTai64(time);
5288
5397
  }
5289
5398
  const transactionSummary = {
5290
5399
  id,
@@ -5345,7 +5454,7 @@ function assemblePreConfirmationTransactionSummary(params) {
5345
5454
  type = getTransactionTypeName(transaction.type);
5346
5455
  tip = (0, import_math18.bn)(transaction.policies?.find((policy) => policy.type === import_transactions21.PolicyType.Tip)?.data);
5347
5456
  if (receipts) {
5348
- const rawPayload = (0, import_utils27.hexlify)(new import_transactions21.TransactionCoder().encode(transaction));
5457
+ const rawPayload = (0, import_utils28.hexlify)(new import_transactions21.TransactionCoder().encode(transaction));
5349
5458
  operations = getOperations({
5350
5459
  transactionType: transaction.type,
5351
5460
  inputs: transaction.inputs || [],
@@ -5391,7 +5500,7 @@ function assemblePreConfirmationTransactionSummary(params) {
5391
5500
  __name(assemblePreConfirmationTransactionSummary, "assemblePreConfirmationTransactionSummary");
5392
5501
 
5393
5502
  // src/providers/transaction-response/getAllDecodedLogs.ts
5394
- var import_abi_coder5 = require("@fuel-ts/abi-coder");
5503
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
5395
5504
  var import_configs12 = require("@fuel-ts/address/configs");
5396
5505
  var import_transactions22 = require("@fuel-ts/transactions");
5397
5506
  function getAllDecodedLogs(opts) {
@@ -5411,8 +5520,8 @@ function getAllDecodedLogs(opts) {
5411
5520
  const isLogFromMainAbi = receipt.id === import_configs12.ZeroBytes32 || mainContract === receipt.id;
5412
5521
  const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
5413
5522
  if (isDecodable) {
5414
- const interfaceToUse = isLogFromMainAbi ? new import_abi_coder5.Interface(mainAbi) : new import_abi_coder5.Interface(externalAbis[receipt.id]);
5415
- const data = receipt.type === import_transactions22.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
5523
+ const interfaceToUse = isLogFromMainAbi ? new import_abi_coder7.Interface(mainAbi) : new import_abi_coder7.Interface(externalAbis[receipt.id]);
5524
+ const data = receipt.type === import_transactions22.ReceiptType.Log ? new import_abi_coder7.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
5416
5525
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
5417
5526
  logs.push(decodedLog);
5418
5527
  groupedLogs[receipt.id] = [...groupedLogs[receipt.id] || [], decodedLog];
@@ -5511,7 +5620,7 @@ var TransactionResponse = class _TransactionResponse {
5511
5620
  }
5512
5621
  const gqlTransaction = this.gqlTransaction ?? await this.fetch();
5513
5622
  const { rawPayload } = gqlTransaction;
5514
- const bytes = (0, import_utils29.arrayify)(rawPayload);
5623
+ const bytes = (0, import_utils30.arrayify)(rawPayload);
5515
5624
  const [tx] = new import_transactions23.TransactionCoder().decode(bytes, 0);
5516
5625
  return {
5517
5626
  tx,
@@ -5699,6 +5808,7 @@ var TransactionResponse = class _TransactionResponse {
5699
5808
  ...transactionSummary
5700
5809
  };
5701
5810
  let { logs, groupedLogs } = { logs: [], groupedLogs: {} };
5811
+ let abis;
5702
5812
  if (this.abis) {
5703
5813
  ({ logs, groupedLogs } = getAllDecodedLogs({
5704
5814
  receipts: transactionSummary.receipts,
@@ -5707,6 +5817,7 @@ var TransactionResponse = class _TransactionResponse {
5707
5817
  }));
5708
5818
  transactionResult.logs = logs;
5709
5819
  transactionResult.groupedLogs = groupedLogs;
5820
+ abis = this.abis;
5710
5821
  }
5711
5822
  const { receipts } = transactionResult;
5712
5823
  const status = this.getTransactionStatus();
@@ -5716,7 +5827,8 @@ var TransactionResponse = class _TransactionResponse {
5716
5827
  receipts,
5717
5828
  statusReason: reason,
5718
5829
  logs,
5719
- groupedLogs
5830
+ groupedLogs,
5831
+ abis
5720
5832
  });
5721
5833
  }
5722
5834
  return transactionResult;
@@ -5778,12 +5890,12 @@ var TransactionResponse = class _TransactionResponse {
5778
5890
  };
5779
5891
 
5780
5892
  // src/providers/transaction-response/getDecodedLogs.ts
5781
- var import_abi_coder6 = require("@fuel-ts/abi-coder");
5893
+ var import_abi_coder8 = require("@fuel-ts/abi-coder");
5782
5894
  var import_configs13 = require("@fuel-ts/address/configs");
5783
5895
  var import_transactions24 = require("@fuel-ts/transactions");
5784
5896
 
5785
5897
  // src/providers/utils/auto-retry-fetch.ts
5786
- var import_utils31 = require("@fuel-ts/utils");
5898
+ var import_utils32 = require("@fuel-ts/utils");
5787
5899
  function getWaitDelay(options, retryAttemptNum) {
5788
5900
  const duration = options.baseDelay ?? 150;
5789
5901
  switch (options.backoff) {
@@ -5814,7 +5926,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
5814
5926
  throw error;
5815
5927
  }
5816
5928
  const delay = getWaitDelay(options, retryNum);
5817
- await (0, import_utils31.sleep)(delay);
5929
+ await (0, import_utils32.sleep)(delay);
5818
5930
  return autoRetryFetch(fetchFn, options, retryNum)(...args);
5819
5931
  }
5820
5932
  };
@@ -5954,7 +6066,7 @@ var Provider = class _Provider {
5954
6066
  return url.replace(/-sub$/, "");
5955
6067
  }
5956
6068
  static hasWriteOperationHappened(url) {
5957
- return (0, import_utils32.isDefined)(_Provider.currentBlockHeightCache[this.normalizeUrl(url)]);
6069
+ return (0, import_utils33.isDefined)(_Provider.currentBlockHeightCache[this.normalizeUrl(url)]);
5958
6070
  }
5959
6071
  /**
5960
6072
  * @hidden
@@ -6009,14 +6121,14 @@ var Provider = class _Provider {
6009
6121
  }
6010
6122
  const retryAttempt = retryOptions.maxRetries - retriesLeft + 1;
6011
6123
  const sleepTime = getWaitDelay(retryOptions, retryAttempt);
6012
- await (0, import_utils32.sleep)(sleepTime);
6124
+ await (0, import_utils33.sleep)(sleepTime);
6013
6125
  response = await fetchFn();
6014
6126
  }
6015
6127
  return response;
6016
6128
  }
6017
6129
  static setCurrentBlockHeight(url, height) {
6018
6130
  const writeOperationHappened = _Provider.hasWriteOperationHappened(url);
6019
- if (!(0, import_utils32.isDefined)(height) || !writeOperationHappened) {
6131
+ if (!(0, import_utils33.isDefined)(height) || !writeOperationHappened) {
6020
6132
  return;
6021
6133
  }
6022
6134
  const normalizedUrl = _Provider.normalizeUrl(url);
@@ -6051,7 +6163,7 @@ var Provider = class _Provider {
6051
6163
  _Provider.chainInfoCache[this.urlWithoutAuth] = chain;
6052
6164
  _Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
6053
6165
  }
6054
- if ((0, import_utils32.isDefined)(resourceCacheTTL)) {
6166
+ if ((0, import_utils33.isDefined)(resourceCacheTTL)) {
6055
6167
  if (resourceCacheTTL !== -1) {
6056
6168
  this.cache = new ResourceCache(resourceCacheTTL);
6057
6169
  } else {
@@ -6414,7 +6526,7 @@ var Provider = class _Provider {
6414
6526
  await this.estimateTxDependencies(transactionRequest);
6415
6527
  }
6416
6528
  await this.validateTransaction(transactionRequest);
6417
- const encodedTransaction = (0, import_utils32.hexlify)(transactionRequest.toTransactionBytes());
6529
+ const encodedTransaction = (0, import_utils33.hexlify)(transactionRequest.toTransactionBytes());
6418
6530
  let abis;
6419
6531
  if (isTransactionTypeScript(transactionRequest)) {
6420
6532
  abis = transactionRequest.abis;
@@ -6445,7 +6557,7 @@ var Provider = class _Provider {
6445
6557
  if (estimateTxDependencies) {
6446
6558
  return this.estimateTxDependencies(transactionRequest);
6447
6559
  }
6448
- const encodedTransaction = (0, import_utils32.hexlify)(transactionRequest.toTransactionBytes());
6560
+ const encodedTransaction = (0, import_utils33.hexlify)(transactionRequest.toTransactionBytes());
6449
6561
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
6450
6562
  encodedTransactions: encodedTransaction,
6451
6563
  utxoValidation: utxoValidation || false
@@ -6469,7 +6581,7 @@ var Provider = class _Provider {
6469
6581
  if (!shouldEstimatePredicates) {
6470
6582
  return transactionRequest;
6471
6583
  }
6472
- const encodedTransaction = (0, import_utils32.hexlify)(transactionRequest.toTransactionBytes());
6584
+ const encodedTransaction = (0, import_utils33.hexlify)(transactionRequest.toTransactionBytes());
6473
6585
  const response = await this.operations.estimatePredicates({
6474
6586
  encodedTransaction
6475
6587
  });
@@ -6501,7 +6613,7 @@ var Provider = class _Provider {
6501
6613
  estimatePredicates
6502
6614
  } = await this.operations.estimatePredicatesAndGasPrice({
6503
6615
  blockHorizon: String(blockHorizon),
6504
- encodedTransaction: (0, import_utils32.hexlify)(transactionRequest.toTransactionBytes())
6616
+ encodedTransaction: (0, import_utils33.hexlify)(transactionRequest.toTransactionBytes())
6505
6617
  });
6506
6618
  transactionRequest = this.parseEstimatePredicatesResponse(
6507
6619
  transactionRequest,
@@ -6539,7 +6651,7 @@ var Provider = class _Provider {
6539
6651
  const {
6540
6652
  dryRun: [{ receipts: serializedReceipts, status }]
6541
6653
  } = await this.operations.dryRun({
6542
- encodedTransactions: [(0, import_utils32.hexlify)(transactionRequest.toTransactionBytes())],
6654
+ encodedTransactions: [(0, import_utils33.hexlify)(transactionRequest.toTransactionBytes())],
6543
6655
  utxoValidation: false,
6544
6656
  gasPrice: gasPrice.toString()
6545
6657
  });
@@ -6594,7 +6706,7 @@ var Provider = class _Provider {
6594
6706
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
6595
6707
  allRequests.forEach((req, index) => {
6596
6708
  if (isTransactionTypeScript(req)) {
6597
- serializedTransactionsMap.set(index, (0, import_utils32.hexlify)(req.toTransactionBytes()));
6709
+ serializedTransactionsMap.set(index, (0, import_utils33.hexlify)(req.toTransactionBytes()));
6598
6710
  }
6599
6711
  });
6600
6712
  let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
@@ -6630,7 +6742,7 @@ var Provider = class _Provider {
6630
6742
  transactionRequest: request
6631
6743
  });
6632
6744
  request.maxFee = maxFee;
6633
- serializedTransactionsMap.set(requestIdx, (0, import_utils32.hexlify)(request.toTransactionBytes()));
6745
+ serializedTransactionsMap.set(requestIdx, (0, import_utils33.hexlify)(request.toTransactionBytes()));
6634
6746
  nextRoundTransactions.push(requestIdx);
6635
6747
  }
6636
6748
  }
@@ -6651,7 +6763,7 @@ var Provider = class _Provider {
6651
6763
  if (estimateTxDependencies) {
6652
6764
  return this.estimateMultipleTxDependencies(transactionRequests);
6653
6765
  }
6654
- const encodedTransactions = transactionRequests.map((tx) => (0, import_utils32.hexlify)(tx.toTransactionBytes()));
6766
+ const encodedTransactions = transactionRequests.map((tx) => (0, import_utils33.hexlify)(tx.toTransactionBytes()));
6655
6767
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
6656
6768
  encodedTransactions,
6657
6769
  utxoValidation: utxoValidation || false
@@ -6701,7 +6813,7 @@ var Provider = class _Provider {
6701
6813
  const chainInfo = await this.getChain();
6702
6814
  const { gasPriceFactor, maxGasPerTx } = await this.getGasConfig();
6703
6815
  const minGas = transactionRequest.calculateMinGas(chainInfo);
6704
- if (!(0, import_utils32.isDefined)(gasPrice)) {
6816
+ if (!(0, import_utils33.isDefined)(gasPrice)) {
6705
6817
  gasPrice = await this.estimateGasPrice(10);
6706
6818
  }
6707
6819
  const minFee = calculateGasFee({
@@ -6753,7 +6865,7 @@ var Provider = class _Provider {
6753
6865
  if (estimateTxDependencies) {
6754
6866
  return this.estimateTxDependencies(transactionRequest);
6755
6867
  }
6756
- const encodedTransactions = [(0, import_utils32.hexlify)(transactionRequest.toTransactionBytes())];
6868
+ const encodedTransactions = [(0, import_utils33.hexlify)(transactionRequest.toTransactionBytes())];
6757
6869
  const { dryRun: dryRunStatuses } = await this.operations.dryRun({
6758
6870
  encodedTransactions,
6759
6871
  utxoValidation: true
@@ -6916,7 +7028,7 @@ var Provider = class _Provider {
6916
7028
  const {
6917
7029
  assembleTx: { status, transaction: gqlTransaction, gasPrice }
6918
7030
  } = await this.operations.assembleTx({
6919
- tx: (0, import_utils32.hexlify)(request.toTransactionBytes()),
7031
+ tx: (0, import_utils33.hexlify)(request.toTransactionBytes()),
6920
7032
  blockHorizon: String(blockHorizon),
6921
7033
  feeAddressIndex: String(feePayerIndex),
6922
7034
  requiredBalances,
@@ -6968,7 +7080,7 @@ var Provider = class _Provider {
6968
7080
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
6969
7081
  inputArgs: paginationArgs
6970
7082
  }),
6971
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils32.hexlify)(assetId) }
7083
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils33.hexlify)(assetId) }
6972
7084
  });
6973
7085
  const coins = edges.map(({ node }) => ({
6974
7086
  id: node.utxoId,
@@ -7000,7 +7112,7 @@ var Provider = class _Provider {
7000
7112
  const coinsQuery = {
7001
7113
  owner: ownerAddress.toB256(),
7002
7114
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
7003
- assetId: (0, import_utils32.hexlify)(assetId),
7115
+ assetId: (0, import_utils33.hexlify)(assetId),
7004
7116
  amount: (amount.eqn(0) ? (0, import_math20.bn)(1) : amount).toString(10),
7005
7117
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
7006
7118
  })),
@@ -7158,7 +7270,7 @@ var Provider = class _Provider {
7158
7270
  },
7159
7271
  transactionIds: block.transactions.map((tx) => tx.id),
7160
7272
  transactions: block.transactions.map(
7161
- (tx) => new import_transactions25.TransactionCoder().decode((0, import_utils32.arrayify)(tx.rawPayload), 0)?.[0]
7273
+ (tx) => new import_transactions25.TransactionCoder().decode((0, import_utils33.arrayify)(tx.rawPayload), 0)?.[0]
7162
7274
  )
7163
7275
  };
7164
7276
  }
@@ -7175,7 +7287,7 @@ var Provider = class _Provider {
7175
7287
  }
7176
7288
  try {
7177
7289
  return new import_transactions25.TransactionCoder().decode(
7178
- (0, import_utils32.arrayify)(transaction.rawPayload),
7290
+ (0, import_utils33.arrayify)(transaction.rawPayload),
7179
7291
  0
7180
7292
  )?.[0];
7181
7293
  } catch (error) {
@@ -7203,7 +7315,7 @@ var Provider = class _Provider {
7203
7315
  const coder = new import_transactions25.TransactionCoder();
7204
7316
  const transactions = edges.map(({ node: { rawPayload } }) => {
7205
7317
  try {
7206
- return coder.decode((0, import_utils32.arrayify)(rawPayload), 0)[0];
7318
+ return coder.decode((0, import_utils33.arrayify)(rawPayload), 0)[0];
7207
7319
  } catch (error) {
7208
7320
  if (error instanceof import_errors21.FuelError && error.code === import_errors21.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
7209
7321
  console.warn("Unsupported transaction type encountered");
@@ -7252,7 +7364,7 @@ var Provider = class _Provider {
7252
7364
  async getContractBalance(contractId, assetId) {
7253
7365
  const { contractBalance } = await this.operations.getContractBalance({
7254
7366
  contract: new import_address4.Address(contractId).toB256(),
7255
- asset: (0, import_utils32.hexlify)(assetId)
7367
+ asset: (0, import_utils33.hexlify)(assetId)
7256
7368
  });
7257
7369
  return (0, import_math20.bn)(contractBalance.amount, 10);
7258
7370
  }
@@ -7266,7 +7378,7 @@ var Provider = class _Provider {
7266
7378
  async getBalance(owner, assetId) {
7267
7379
  const { balance } = await this.operations.getBalanceV2({
7268
7380
  owner: new import_address4.Address(owner).toB256(),
7269
- assetId: (0, import_utils32.hexlify)(assetId)
7381
+ assetId: (0, import_utils33.hexlify)(assetId)
7270
7382
  });
7271
7383
  return (0, import_math20.bn)(balance.amountU128, 10);
7272
7384
  }
@@ -7471,7 +7583,7 @@ var Provider = class _Provider {
7471
7583
  async produceBlocks(amount, startTime) {
7472
7584
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
7473
7585
  blocksToProduce: (0, import_math20.bn)(amount).toString(10),
7474
- startTimestamp: startTime ? import_utils32.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
7586
+ startTimestamp: startTime ? import_utils33.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
7475
7587
  });
7476
7588
  return (0, import_math20.bn)(latestBlockHeight);
7477
7589
  }
@@ -7574,18 +7686,21 @@ var Provider = class _Provider {
7574
7686
  extractDryRunError(transactionRequest, receipts, reason) {
7575
7687
  let logs = [];
7576
7688
  let groupedLogs = {};
7689
+ let abis;
7577
7690
  if (transactionRequest.type === import_transactions25.TransactionType.Script && transactionRequest.abis) {
7578
7691
  ({ logs, groupedLogs } = getAllDecodedLogs({
7579
7692
  receipts,
7580
7693
  mainAbi: transactionRequest.abis.main,
7581
7694
  externalAbis: transactionRequest.abis.otherContractsAbis
7582
7695
  }));
7696
+ abis = transactionRequest.abis;
7583
7697
  }
7584
7698
  return extractTxError({
7585
7699
  logs,
7586
7700
  groupedLogs,
7587
7701
  receipts,
7588
- statusReason: reason
7702
+ statusReason: reason,
7703
+ abis
7589
7704
  });
7590
7705
  }
7591
7706
  /**
@@ -7624,8 +7739,8 @@ var Provider = class _Provider {
7624
7739
  */
7625
7740
  async adjustResourcesToIgnoreForAddresses(addresses, resourcesIdsToIgnore) {
7626
7741
  const final = {
7627
- messages: resourcesIdsToIgnore?.messages?.map((nonce) => (0, import_utils32.hexlify)(nonce)) || [],
7628
- utxos: resourcesIdsToIgnore?.utxos?.map((id) => (0, import_utils32.hexlify)(id)) || []
7742
+ messages: resourcesIdsToIgnore?.messages?.map((nonce) => (0, import_utils33.hexlify)(nonce)) || [],
7743
+ utxos: resourcesIdsToIgnore?.utxos?.map((id) => (0, import_utils33.hexlify)(id)) || []
7629
7744
  };
7630
7745
  if (this.cache) {
7631
7746
  const cache2 = this.cache;
@@ -7657,16 +7772,16 @@ var Provider = class _Provider {
7657
7772
  var import_errors22 = require("@fuel-ts/errors");
7658
7773
  var import_math21 = require("@fuel-ts/math");
7659
7774
  var import_transactions26 = require("@fuel-ts/transactions");
7660
- var import_utils34 = require("@fuel-ts/utils");
7775
+ var import_utils35 = require("@fuel-ts/utils");
7661
7776
 
7662
7777
  // src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
7663
7778
  var import_math22 = require("@fuel-ts/math");
7664
7779
  var import_transactions27 = require("@fuel-ts/transactions");
7665
- var import_utils35 = require("@fuel-ts/utils");
7780
+ var import_utils36 = require("@fuel-ts/utils");
7666
7781
 
7667
7782
  // src/test-utils/test-asset-id.ts
7668
7783
  var import_crypto4 = require("@fuel-ts/crypto");
7669
- var import_utils36 = require("@fuel-ts/utils");
7784
+ var import_utils37 = require("@fuel-ts/utils");
7670
7785
  var TestAssetId = class _TestAssetId {
7671
7786
  constructor(value) {
7672
7787
  this.value = value;
@@ -7683,7 +7798,7 @@ var TestAssetId = class _TestAssetId {
7683
7798
  static random(count = 1) {
7684
7799
  const assetIds = [];
7685
7800
  for (let i = 0; i < count; i++) {
7686
- assetIds.push(new _TestAssetId((0, import_utils36.hexlify)((0, import_crypto4.randomBytes)(32))));
7801
+ assetIds.push(new _TestAssetId((0, import_utils37.hexlify)((0, import_crypto4.randomBytes)(32))));
7687
7802
  }
7688
7803
  return assetIds;
7689
7804
  }
@@ -7693,20 +7808,20 @@ var TestAssetId = class _TestAssetId {
7693
7808
  var import_crypto9 = require("@fuel-ts/crypto");
7694
7809
  var import_errors28 = require("@fuel-ts/errors");
7695
7810
  var import_math25 = require("@fuel-ts/math");
7696
- var import_utils45 = require("@fuel-ts/utils");
7811
+ var import_utils46 = require("@fuel-ts/utils");
7697
7812
 
7698
7813
  // src/wallet/base-wallet-unlocked.ts
7699
7814
  var import_hasher4 = require("@fuel-ts/hasher");
7700
- var import_utils40 = require("@fuel-ts/utils");
7815
+ var import_utils41 = require("@fuel-ts/utils");
7701
7816
 
7702
7817
  // src/account.ts
7703
- var import_abi_coder8 = require("@fuel-ts/abi-coder");
7818
+ var import_abi_coder10 = require("@fuel-ts/abi-coder");
7704
7819
  var import_address6 = require("@fuel-ts/address");
7705
7820
  var import_crypto5 = require("@fuel-ts/crypto");
7706
7821
  var import_errors23 = require("@fuel-ts/errors");
7707
7822
  var import_math23 = require("@fuel-ts/math");
7708
7823
  var import_transactions28 = require("@fuel-ts/transactions");
7709
- var import_utils38 = require("@fuel-ts/utils");
7824
+ var import_utils39 = require("@fuel-ts/utils");
7710
7825
  var import_ramda9 = require("ramda");
7711
7826
 
7712
7827
  // src/types.ts
@@ -7717,17 +7832,17 @@ var AbstractAccount = class {
7717
7832
  };
7718
7833
 
7719
7834
  // src/utils/formatTransferToContractScriptData.ts
7720
- var import_abi_coder7 = require("@fuel-ts/abi-coder");
7835
+ var import_abi_coder9 = require("@fuel-ts/abi-coder");
7721
7836
  var import_address5 = require("@fuel-ts/address");
7722
- var import_utils37 = require("@fuel-ts/utils");
7837
+ var import_utils38 = require("@fuel-ts/utils");
7723
7838
  var asm = __toESM(require("@fuels/vm-asm"));
7724
7839
  var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
7725
- const numberCoder = new import_abi_coder7.BigNumberCoder("u64");
7840
+ const numberCoder = new import_abi_coder9.BigNumberCoder("u64");
7726
7841
  return transferParams.reduce((acc, transferParam) => {
7727
7842
  const { assetId, amount, contractId } = transferParam;
7728
7843
  const encoded = numberCoder.encode(amount);
7729
- const scriptData = (0, import_utils37.concat)([new import_address5.Address(contractId).toBytes(), encoded, (0, import_utils37.arrayify)(assetId)]);
7730
- return (0, import_utils37.concat)([acc, scriptData]);
7844
+ const scriptData = (0, import_utils38.concat)([new import_address5.Address(contractId).toBytes(), encoded, (0, import_utils38.arrayify)(assetId)]);
7845
+ return (0, import_utils38.concat)([acc, scriptData]);
7731
7846
  }, new Uint8Array());
7732
7847
  }, "formatTransferToContractScriptData");
7733
7848
  var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferParams) => {
@@ -7735,24 +7850,24 @@ var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferPar
7735
7850
  await asm.initWasm();
7736
7851
  let script = new Uint8Array();
7737
7852
  transferParams.forEach((_, i) => {
7738
- const offset = (import_abi_coder7.CONTRACT_ID_LEN + import_abi_coder7.WORD_SIZE + import_abi_coder7.ASSET_ID_LEN) * i;
7739
- script = (0, import_utils37.concat)([
7853
+ const offset = (import_abi_coder9.CONTRACT_ID_LEN + import_abi_coder9.WORD_SIZE + import_abi_coder9.ASSET_ID_LEN) * i;
7854
+ script = (0, import_utils38.concat)([
7740
7855
  script,
7741
7856
  // Load ScriptData into register 0x10.
7742
7857
  asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
7743
7858
  // Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
7744
7859
  asm.addi(17, 16, offset).to_bytes(),
7745
7860
  // Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
7746
- asm.addi(18, 17, import_abi_coder7.CONTRACT_ID_LEN).to_bytes(),
7861
+ asm.addi(18, 17, import_abi_coder9.CONTRACT_ID_LEN).to_bytes(),
7747
7862
  // Load word to the amount at 0x12 into register 0x13.
7748
7863
  asm.lw(19, 18, 0).to_bytes(),
7749
7864
  // Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
7750
- asm.addi(20, 18, import_abi_coder7.WORD_SIZE).to_bytes(),
7865
+ asm.addi(20, 18, import_abi_coder9.WORD_SIZE).to_bytes(),
7751
7866
  // Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
7752
7867
  asm.tr(17, 19, 20).to_bytes()
7753
7868
  ]);
7754
7869
  });
7755
- script = (0, import_utils37.concat)([script, asm.ret(1).to_bytes()]);
7870
+ script = (0, import_utils38.concat)([script, asm.ret(1).to_bytes()]);
7756
7871
  return { script, scriptData };
7757
7872
  }, "assembleTransferToContractScript");
7758
7873
 
@@ -8102,7 +8217,7 @@ var Account = class extends AbstractAccount {
8102
8217
  const transferParams = contractTransferParams.map((transferParam) => {
8103
8218
  const amount = (0, import_math23.bn)(transferParam.amount);
8104
8219
  const contractAddress = new import_address6.Address(transferParam.contractId);
8105
- const assetId = transferParam.assetId ? (0, import_utils38.hexlify)(transferParam.assetId) : defaultAssetId;
8220
+ const assetId = transferParam.assetId ? (0, import_utils39.hexlify)(transferParam.assetId) : defaultAssetId;
8106
8221
  if (amount.lte(0)) {
8107
8222
  throw new import_errors23.FuelError(
8108
8223
  import_errors23.ErrorCode.INVALID_TRANSFER_AMOUNT,
@@ -8140,14 +8255,14 @@ var Account = class extends AbstractAccount {
8140
8255
  */
8141
8256
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
8142
8257
  const recipientAddress = new import_address6.Address(recipient);
8143
- const recipientDataArray = (0, import_utils38.arrayify)(
8258
+ const recipientDataArray = (0, import_utils39.arrayify)(
8144
8259
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
8145
8260
  );
8146
- const amountDataArray = (0, import_utils38.arrayify)(
8261
+ const amountDataArray = (0, import_utils39.arrayify)(
8147
8262
  "0x".concat((0, import_math23.bn)(amount).toHex().substring(2).padStart(16, "0"))
8148
8263
  );
8149
8264
  const script = new Uint8Array([
8150
- ...(0, import_utils38.arrayify)(withdrawScript.bytes),
8265
+ ...(0, import_utils39.arrayify)(withdrawScript.bytes),
8151
8266
  ...recipientDataArray,
8152
8267
  ...amountDataArray
8153
8268
  ]);
@@ -8369,14 +8484,23 @@ var Account = class extends AbstractAccount {
8369
8484
  * @param transactionRequestLike - The transaction request to sign.
8370
8485
  * @returns A promise that resolves to the signature of the transaction.
8371
8486
  */
8372
- async signTransaction(transactionRequestLike) {
8487
+ async signTransaction(transactionRequestLike, connectorOptions = {}) {
8373
8488
  if (!this._connector) {
8374
8489
  throw new import_errors23.FuelError(
8375
8490
  import_errors23.ErrorCode.MISSING_CONNECTOR,
8376
8491
  "A connector is required to sign transactions."
8377
8492
  );
8378
8493
  }
8379
- return this._connector.signTransaction(this.address.toString(), transactionRequestLike);
8494
+ const transactionRequest = transactionRequestify(transactionRequestLike);
8495
+ const { transactionRequest: requestToSign, connectorsSendTxParams } = await this.setTransactionStateForConnectors({
8496
+ transactionRequest,
8497
+ connectorOptions
8498
+ });
8499
+ return this._connector.signTransaction(
8500
+ this.address.toString(),
8501
+ requestToSign,
8502
+ connectorsSendTxParams
8503
+ );
8380
8504
  }
8381
8505
  /**
8382
8506
  * Sends a transaction to the network.
@@ -8386,24 +8510,16 @@ var Account = class extends AbstractAccount {
8386
8510
  * @returns A promise that resolves to the transaction response.
8387
8511
  */
8388
8512
  async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, ...connectorOptions } = {}) {
8389
- let transactionRequest = transactionRequestify(transactionRequestLike);
8513
+ const transactionRequest = transactionRequestify(transactionRequestLike);
8390
8514
  if (this._connector) {
8391
- const { onBeforeSend, skipCustomFee = false } = connectorOptions;
8392
- transactionRequest = await this.prepareTransactionForSend(transactionRequest);
8393
- const params = {
8394
- onBeforeSend,
8395
- skipCustomFee,
8396
- provider: {
8397
- url: this.provider.url,
8398
- cache: await serializeProviderCache(this.provider)
8399
- },
8400
- transactionState: transactionRequest.flag.state,
8401
- transactionSummary: await this.prepareTransactionSummary(transactionRequest)
8402
- };
8515
+ const response = await this.setTransactionStateForConnectors({
8516
+ transactionRequest,
8517
+ connectorOptions
8518
+ });
8403
8519
  const transaction = await this._connector.sendTransaction(
8404
8520
  this.address.toString(),
8405
- transactionRequest,
8406
- params
8521
+ response.transactionRequest,
8522
+ response.connectorsSendTxParams
8407
8523
  );
8408
8524
  return typeof transaction === "string" ? this.provider.getTransactionResponse(transaction) : transaction;
8409
8525
  }
@@ -8436,7 +8552,7 @@ var Account = class extends AbstractAccount {
8436
8552
  */
8437
8553
  generateFakeResources(coins) {
8438
8554
  return coins.map((coin) => ({
8439
- id: (0, import_utils38.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
8555
+ id: (0, import_utils39.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder10.UTXO_ID_LEN)),
8440
8556
  owner: this.address,
8441
8557
  blockCreated: (0, import_math23.bn)(1),
8442
8558
  txCreatedIdx: (0, import_math23.bn)(1),
@@ -8446,7 +8562,7 @@ var Account = class extends AbstractAccount {
8446
8562
  /** @hidden */
8447
8563
  async prepareTransactionForSend(request) {
8448
8564
  const { transactionId } = request.flag;
8449
- if (!(0, import_utils38.isDefined)(transactionId)) {
8565
+ if (!(0, import_utils39.isDefined)(transactionId)) {
8450
8566
  return request;
8451
8567
  }
8452
8568
  const chainId = await this.provider.getChainId();
@@ -8459,10 +8575,10 @@ var Account = class extends AbstractAccount {
8459
8575
  /** @hidden */
8460
8576
  async prepareTransactionSummary(request) {
8461
8577
  const chainId = await this.provider.getChainId();
8462
- return (0, import_utils38.isDefined)(request.flag.summary) ? {
8578
+ return (0, import_utils39.isDefined)(request.flag.summary) ? {
8463
8579
  ...request.flag.summary,
8464
8580
  id: request.getTransactionId(chainId),
8465
- transactionBytes: (0, import_utils38.hexlify)(request.toTransactionBytes())
8581
+ transactionBytes: (0, import_utils39.hexlify)(request.toTransactionBytes())
8466
8582
  } : void 0;
8467
8583
  }
8468
8584
  /** @hidden * */
@@ -8507,7 +8623,7 @@ var Account = class extends AbstractAccount {
8507
8623
  txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
8508
8624
  }) {
8509
8625
  const request = transactionRequestify(transactionRequest);
8510
- if (!(0, import_utils38.isDefined)(setGasLimit)) {
8626
+ if (!(0, import_utils39.isDefined)(setGasLimit)) {
8511
8627
  request.gasLimit = gasUsed;
8512
8628
  } else if (gasUsed.gt(setGasLimit)) {
8513
8629
  throw new import_errors23.FuelError(
@@ -8515,7 +8631,7 @@ var Account = class extends AbstractAccount {
8515
8631
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
8516
8632
  );
8517
8633
  }
8518
- if (!(0, import_utils38.isDefined)(setMaxFee)) {
8634
+ if (!(0, import_utils39.isDefined)(setMaxFee)) {
8519
8635
  request.maxFee = maxFee;
8520
8636
  } else if (maxFee.gt(setMaxFee)) {
8521
8637
  throw new import_errors23.FuelError(
@@ -8537,13 +8653,30 @@ var Account = class extends AbstractAccount {
8537
8653
  );
8538
8654
  }
8539
8655
  }
8656
+ /** @hidden * */
8657
+ async setTransactionStateForConnectors(params) {
8658
+ const { transactionRequest: requestToPrepare, connectorOptions } = params;
8659
+ const { onBeforeSend, skipCustomFee = false } = connectorOptions;
8660
+ const transactionRequest = await this.prepareTransactionForSend(requestToPrepare);
8661
+ const connectorsSendTxParams = {
8662
+ onBeforeSend,
8663
+ skipCustomFee,
8664
+ provider: {
8665
+ url: this.provider.url,
8666
+ cache: await serializeProviderCache(this.provider)
8667
+ },
8668
+ transactionState: requestToPrepare.flag.state,
8669
+ transactionSummary: await this.prepareTransactionSummary(requestToPrepare)
8670
+ };
8671
+ return { transactionRequest, connectorsSendTxParams };
8672
+ }
8540
8673
  };
8541
8674
 
8542
8675
  // src/wallet/keystore-wallet.ts
8543
8676
  var import_address7 = require("@fuel-ts/address");
8544
8677
  var import_crypto6 = require("@fuel-ts/crypto");
8545
8678
  var import_errors24 = require("@fuel-ts/errors");
8546
- var import_utils39 = require("@fuel-ts/utils");
8679
+ var import_utils40 = require("@fuel-ts/utils");
8547
8680
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
8548
8681
  var DEFAULT_KDF_PARAMS_R = 8;
8549
8682
  var DEFAULT_KDF_PARAMS_P = 1;
@@ -8626,7 +8759,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
8626
8759
  );
8627
8760
  }
8628
8761
  const buffer = await (0, import_crypto6.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
8629
- const privateKey = (0, import_utils39.hexlify)(buffer);
8762
+ const privateKey = (0, import_utils40.hexlify)(buffer);
8630
8763
  return privateKey;
8631
8764
  }
8632
8765
  __name(decryptKeystoreWallet, "decryptKeystoreWallet");
@@ -8679,7 +8812,7 @@ var BaseWalletUnlocked = class extends Account {
8679
8812
  */
8680
8813
  async signMessage(message) {
8681
8814
  const signedMessage = await this.signer().sign((0, import_hasher4.hashMessage)(message));
8682
- return (0, import_utils40.hexlify)(signedMessage);
8815
+ return (0, import_utils41.hexlify)(signedMessage);
8683
8816
  }
8684
8817
  /**
8685
8818
  * Signs a transaction with the wallet's private key.
@@ -8692,7 +8825,7 @@ var BaseWalletUnlocked = class extends Account {
8692
8825
  const chainId = await this.provider.getChainId();
8693
8826
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
8694
8827
  const signature = await this.signer().sign(hashedTransaction);
8695
- return (0, import_utils40.hexlify)(signature);
8828
+ return (0, import_utils41.hexlify)(signature);
8696
8829
  }
8697
8830
  /**
8698
8831
  * Populates a transaction with the witnesses signature.
@@ -8763,13 +8896,13 @@ var import_crypto8 = require("@fuel-ts/crypto");
8763
8896
  var import_errors27 = require("@fuel-ts/errors");
8764
8897
  var import_hasher7 = require("@fuel-ts/hasher");
8765
8898
  var import_math24 = require("@fuel-ts/math");
8766
- var import_utils44 = require("@fuel-ts/utils");
8899
+ var import_utils45 = require("@fuel-ts/utils");
8767
8900
 
8768
8901
  // src/mnemonic/mnemonic.ts
8769
8902
  var import_crypto7 = require("@fuel-ts/crypto");
8770
8903
  var import_errors26 = require("@fuel-ts/errors");
8771
8904
  var import_hasher6 = require("@fuel-ts/hasher");
8772
- var import_utils42 = require("@fuel-ts/utils");
8905
+ var import_utils43 = require("@fuel-ts/utils");
8773
8906
 
8774
8907
  // src/wordlists/words/english.ts
8775
8908
  var english = [
@@ -10826,7 +10959,7 @@ var english = [
10826
10959
  // src/mnemonic/utils.ts
10827
10960
  var import_errors25 = require("@fuel-ts/errors");
10828
10961
  var import_hasher5 = require("@fuel-ts/hasher");
10829
- var import_utils41 = require("@fuel-ts/utils");
10962
+ var import_utils42 = require("@fuel-ts/utils");
10830
10963
  function getLowerMask(bits) {
10831
10964
  return (1 << bits) - 1;
10832
10965
  }
@@ -10865,7 +10998,7 @@ function entropyToMnemonicIndices(entropy) {
10865
10998
  }
10866
10999
  }
10867
11000
  const checksumBits = entropy.length / 4;
10868
- const checksum = (0, import_utils41.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
11001
+ const checksum = (0, import_utils42.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
10869
11002
  indices[indices.length - 1] <<= checksumBits;
10870
11003
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
10871
11004
  return indices;
@@ -10873,7 +11006,7 @@ function entropyToMnemonicIndices(entropy) {
10873
11006
  __name(entropyToMnemonicIndices, "entropyToMnemonicIndices");
10874
11007
  function mnemonicWordsToEntropy(words, wordlist) {
10875
11008
  const size = Math.ceil(11 * words.length / 8);
10876
- const entropy = (0, import_utils41.arrayify)(new Uint8Array(size));
11009
+ const entropy = (0, import_utils42.arrayify)(new Uint8Array(size));
10877
11010
  let offset = 0;
10878
11011
  for (let i = 0; i < words.length; i += 1) {
10879
11012
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -10893,7 +11026,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
10893
11026
  const entropyBits = 32 * words.length / 3;
10894
11027
  const checksumBits = words.length / 3;
10895
11028
  const checksumMask = getUpperMask(checksumBits);
10896
- const checksum = (0, import_utils41.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
11029
+ const checksum = (0, import_utils42.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
10897
11030
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
10898
11031
  throw new import_errors25.FuelError(
10899
11032
  import_errors25.ErrorCode.INVALID_CHECKSUM,
@@ -10905,7 +11038,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
10905
11038
  __name(mnemonicWordsToEntropy, "mnemonicWordsToEntropy");
10906
11039
 
10907
11040
  // src/mnemonic/mnemonic.ts
10908
- var MasterSecret = (0, import_utils42.toUtf8Bytes)("Bitcoin seed");
11041
+ var MasterSecret = (0, import_utils43.toUtf8Bytes)("Bitcoin seed");
10909
11042
  var MainnetPRV = "0x0488ade4";
10910
11043
  var TestnetPRV = "0x04358394";
10911
11044
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
@@ -10975,7 +11108,7 @@ var Mnemonic = class _Mnemonic {
10975
11108
  static mnemonicToEntropy(phrase, wordlist = english) {
10976
11109
  const words = getWords(phrase);
10977
11110
  assertMnemonic(words);
10978
- return (0, import_utils42.hexlify)(mnemonicWordsToEntropy(words, wordlist));
11111
+ return (0, import_utils43.hexlify)(mnemonicWordsToEntropy(words, wordlist));
10979
11112
  }
10980
11113
  /**
10981
11114
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -10983,7 +11116,7 @@ var Mnemonic = class _Mnemonic {
10983
11116
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
10984
11117
  */
10985
11118
  static entropyToMnemonic(entropy, wordlist = english) {
10986
- const entropyBytes = (0, import_utils42.arrayify)(entropy);
11119
+ const entropyBytes = (0, import_utils43.arrayify)(entropy);
10987
11120
  assertWordList(wordlist);
10988
11121
  assertEntropy(entropyBytes);
10989
11122
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -10995,8 +11128,8 @@ var Mnemonic = class _Mnemonic {
10995
11128
  */
10996
11129
  static mnemonicToSeed(phrase, passphrase = "") {
10997
11130
  assertMnemonic(getWords(phrase));
10998
- const phraseBytes = (0, import_utils42.toUtf8Bytes)(getPhrase(phrase));
10999
- const salt = (0, import_utils42.toUtf8Bytes)(`mnemonic${passphrase}`);
11131
+ const phraseBytes = (0, import_utils43.toUtf8Bytes)(getPhrase(phrase));
11132
+ const salt = (0, import_utils43.toUtf8Bytes)(`mnemonic${passphrase}`);
11000
11133
  return (0, import_crypto7.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
11001
11134
  }
11002
11135
  /**
@@ -11052,14 +11185,14 @@ var Mnemonic = class _Mnemonic {
11052
11185
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
11053
11186
  */
11054
11187
  static masterKeysFromSeed(seed) {
11055
- const seedArray = (0, import_utils42.arrayify)(seed);
11188
+ const seedArray = (0, import_utils43.arrayify)(seed);
11056
11189
  if (seedArray.length < 16 || seedArray.length > 64) {
11057
11190
  throw new import_errors26.FuelError(
11058
11191
  import_errors26.ErrorCode.INVALID_SEED,
11059
11192
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
11060
11193
  );
11061
11194
  }
11062
- return (0, import_utils42.arrayify)((0, import_crypto7.computeHmac)("sha512", MasterSecret, seedArray));
11195
+ return (0, import_utils43.arrayify)((0, import_crypto7.computeHmac)("sha512", MasterSecret, seedArray));
11063
11196
  }
11064
11197
  /**
11065
11198
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -11070,22 +11203,22 @@ var Mnemonic = class _Mnemonic {
11070
11203
  */
11071
11204
  static seedToExtendedKey(seed, testnet = false) {
11072
11205
  const masterKey = _Mnemonic.masterKeysFromSeed(seed);
11073
- const prefix = (0, import_utils42.arrayify)(testnet ? TestnetPRV : MainnetPRV);
11206
+ const prefix = (0, import_utils43.arrayify)(testnet ? TestnetPRV : MainnetPRV);
11074
11207
  const depth = "0x00";
11075
11208
  const fingerprint = "0x00000000";
11076
11209
  const index = "0x00000000";
11077
11210
  const chainCode = masterKey.slice(32);
11078
11211
  const privateKey = masterKey.slice(0, 32);
11079
- const extendedKey = (0, import_utils42.concat)([
11212
+ const extendedKey = (0, import_utils43.concat)([
11080
11213
  prefix,
11081
11214
  depth,
11082
11215
  fingerprint,
11083
11216
  index,
11084
11217
  chainCode,
11085
- (0, import_utils42.concat)(["0x00", privateKey])
11218
+ (0, import_utils43.concat)(["0x00", privateKey])
11086
11219
  ]);
11087
- const checksum = (0, import_utils42.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
11088
- return (0, import_utils42.encodeBase58)((0, import_utils42.concat)([extendedKey, checksum]));
11220
+ const checksum = (0, import_utils43.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
11221
+ return (0, import_utils43.encodeBase58)((0, import_utils43.concat)([extendedKey, checksum]));
11089
11222
  }
11090
11223
  /**
11091
11224
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -11100,7 +11233,7 @@ var Mnemonic = class _Mnemonic {
11100
11233
  * @returns A randomly generated mnemonic
11101
11234
  */
11102
11235
  static generate(size = 32, extraEntropy = "") {
11103
- const entropy = extraEntropy ? (0, import_hasher6.sha256)((0, import_utils42.concat)([(0, import_crypto7.randomBytes)(size), (0, import_utils42.arrayify)(extraEntropy)])) : (0, import_crypto7.randomBytes)(size);
11236
+ const entropy = extraEntropy ? (0, import_hasher6.sha256)((0, import_utils43.concat)([(0, import_crypto7.randomBytes)(size), (0, import_utils43.arrayify)(extraEntropy)])) : (0, import_crypto7.randomBytes)(size);
11104
11237
  return _Mnemonic.entropyToMnemonic(entropy);
11105
11238
  }
11106
11239
  };
@@ -11108,12 +11241,12 @@ var mnemonic_default = Mnemonic;
11108
11241
 
11109
11242
  // src/hdwallet/hdwallet.ts
11110
11243
  var HARDENED_INDEX = 2147483648;
11111
- var MainnetPRV2 = (0, import_utils44.hexlify)("0x0488ade4");
11112
- var MainnetPUB = (0, import_utils44.hexlify)("0x0488b21e");
11113
- var TestnetPRV2 = (0, import_utils44.hexlify)("0x04358394");
11114
- var TestnetPUB = (0, import_utils44.hexlify)("0x043587cf");
11244
+ var MainnetPRV2 = (0, import_utils45.hexlify)("0x0488ade4");
11245
+ var MainnetPUB = (0, import_utils45.hexlify)("0x0488b21e");
11246
+ var TestnetPRV2 = (0, import_utils45.hexlify)("0x04358394");
11247
+ var TestnetPUB = (0, import_utils45.hexlify)("0x043587cf");
11115
11248
  function base58check(data) {
11116
- return (0, import_utils44.encodeBase58)((0, import_utils44.concat)([data, (0, import_utils44.dataSlice)((0, import_hasher7.sha256)((0, import_hasher7.sha256)(data)), 0, 4)]));
11249
+ return (0, import_utils45.encodeBase58)((0, import_utils45.concat)([data, (0, import_utils45.dataSlice)((0, import_hasher7.sha256)((0, import_hasher7.sha256)(data)), 0, 4)]));
11117
11250
  }
11118
11251
  __name(base58check, "base58check");
11119
11252
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
@@ -11124,12 +11257,12 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
11124
11257
  }
11125
11258
  __name(getExtendedKeyPrefix, "getExtendedKeyPrefix");
11126
11259
  function isPublicExtendedKey(extendedKey) {
11127
- return [MainnetPUB, TestnetPUB].includes((0, import_utils44.hexlify)(extendedKey.slice(0, 4)));
11260
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils45.hexlify)(extendedKey.slice(0, 4)));
11128
11261
  }
11129
11262
  __name(isPublicExtendedKey, "isPublicExtendedKey");
11130
11263
  function isValidExtendedKey(extendedKey) {
11131
11264
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
11132
- (0, import_utils44.hexlify)(extendedKey.slice(0, 4))
11265
+ (0, import_utils45.hexlify)(extendedKey.slice(0, 4))
11133
11266
  );
11134
11267
  }
11135
11268
  __name(isValidExtendedKey, "isValidExtendedKey");
@@ -11152,8 +11285,8 @@ var HDWallet = class _HDWallet {
11152
11285
  }
11153
11286
  depth = 0;
11154
11287
  index = 0;
11155
- fingerprint = (0, import_utils44.hexlify)("0x00000000");
11156
- parentFingerprint = (0, import_utils44.hexlify)("0x00000000");
11288
+ fingerprint = (0, import_utils45.hexlify)("0x00000000");
11289
+ parentFingerprint = (0, import_utils45.hexlify)("0x00000000");
11157
11290
  privateKey;
11158
11291
  publicKey;
11159
11292
  chainCode;
@@ -11165,8 +11298,8 @@ var HDWallet = class _HDWallet {
11165
11298
  constructor(config) {
11166
11299
  if (config.privateKey) {
11167
11300
  const signer = new Signer(config.privateKey);
11168
- this.publicKey = (0, import_utils44.hexlify)(signer.compressedPublicKey);
11169
- this.privateKey = (0, import_utils44.hexlify)(config.privateKey);
11301
+ this.publicKey = (0, import_utils45.hexlify)(signer.compressedPublicKey);
11302
+ this.privateKey = (0, import_utils45.hexlify)(config.privateKey);
11170
11303
  } else {
11171
11304
  if (!config.publicKey) {
11172
11305
  throw new import_errors27.FuelError(
@@ -11174,10 +11307,10 @@ var HDWallet = class _HDWallet {
11174
11307
  "Both public and private Key cannot be missing. At least one should be provided."
11175
11308
  );
11176
11309
  }
11177
- this.publicKey = (0, import_utils44.hexlify)(config.publicKey);
11310
+ this.publicKey = (0, import_utils45.hexlify)(config.publicKey);
11178
11311
  }
11179
11312
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
11180
- this.fingerprint = (0, import_utils44.dataSlice)((0, import_crypto8.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
11313
+ this.fingerprint = (0, import_utils45.dataSlice)((0, import_crypto8.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
11181
11314
  this.depth = config.depth || this.depth;
11182
11315
  this.index = config.index || this.index;
11183
11316
  this.chainCode = config.chainCode;
@@ -11193,9 +11326,9 @@ var HDWallet = class _HDWallet {
11193
11326
  * @returns A new instance of HDWallet on the derived index
11194
11327
  */
11195
11328
  deriveIndex(index) {
11196
- const privateKey = this.privateKey && (0, import_utils44.arrayify)(this.privateKey);
11197
- const publicKey = (0, import_utils44.arrayify)(this.publicKey);
11198
- const chainCode = (0, import_utils44.arrayify)(this.chainCode);
11329
+ const privateKey = this.privateKey && (0, import_utils45.arrayify)(this.privateKey);
11330
+ const publicKey = (0, import_utils45.arrayify)(this.publicKey);
11331
+ const chainCode = (0, import_utils45.arrayify)(this.chainCode);
11199
11332
  const data = new Uint8Array(37);
11200
11333
  if (index & HARDENED_INDEX) {
11201
11334
  if (!privateKey) {
@@ -11206,10 +11339,10 @@ var HDWallet = class _HDWallet {
11206
11339
  }
11207
11340
  data.set(privateKey, 1);
11208
11341
  } else {
11209
- data.set((0, import_utils44.arrayify)(this.publicKey));
11342
+ data.set((0, import_utils45.arrayify)(this.publicKey));
11210
11343
  }
11211
11344
  data.set((0, import_math24.toBytes)(index, 4), 33);
11212
- const bytes = (0, import_utils44.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
11345
+ const bytes = (0, import_utils45.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
11213
11346
  const IL = bytes.slice(0, 32);
11214
11347
  const IR = bytes.slice(32);
11215
11348
  if (privateKey) {
@@ -11223,7 +11356,7 @@ var HDWallet = class _HDWallet {
11223
11356
  parentFingerprint: this.fingerprint
11224
11357
  });
11225
11358
  }
11226
- const signer = new Signer((0, import_utils44.hexlify)(IL));
11359
+ const signer = new Signer((0, import_utils45.hexlify)(IL));
11227
11360
  const Ki = signer.addPoint(publicKey);
11228
11361
  return new _HDWallet({
11229
11362
  publicKey: Ki,
@@ -11258,12 +11391,12 @@ var HDWallet = class _HDWallet {
11258
11391
  );
11259
11392
  }
11260
11393
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
11261
- const depth = (0, import_utils44.hexlify)(Uint8Array.from([this.depth]));
11394
+ const depth = (0, import_utils45.hexlify)(Uint8Array.from([this.depth]));
11262
11395
  const parentFingerprint = this.parentFingerprint;
11263
11396
  const index = (0, import_math24.toHex)(this.index, 4);
11264
11397
  const chainCode = this.chainCode;
11265
- const key = this.privateKey != null && !isPublic ? (0, import_utils44.concat)(["0x00", this.privateKey]) : this.publicKey;
11266
- const extendedKey = (0, import_utils44.arrayify)((0, import_utils44.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
11398
+ const key = this.privateKey != null && !isPublic ? (0, import_utils45.concat)(["0x00", this.privateKey]) : this.publicKey;
11399
+ const extendedKey = (0, import_utils45.arrayify)((0, import_utils45.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
11267
11400
  return base58check(extendedKey);
11268
11401
  }
11269
11402
  /**
@@ -11275,13 +11408,13 @@ var HDWallet = class _HDWallet {
11275
11408
  static fromSeed(seed) {
11276
11409
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
11277
11410
  return new _HDWallet({
11278
- chainCode: (0, import_utils44.arrayify)(masterKey.slice(32)),
11279
- privateKey: (0, import_utils44.arrayify)(masterKey.slice(0, 32))
11411
+ chainCode: (0, import_utils45.arrayify)(masterKey.slice(32)),
11412
+ privateKey: (0, import_utils45.arrayify)(masterKey.slice(0, 32))
11280
11413
  });
11281
11414
  }
11282
11415
  static fromExtendedKey(extendedKey) {
11283
- const decoded = (0, import_utils44.hexlify)((0, import_math24.toBytes)((0, import_utils44.decodeBase58)(extendedKey)));
11284
- const bytes = (0, import_utils44.arrayify)(decoded);
11416
+ const decoded = (0, import_utils45.hexlify)((0, import_math24.toBytes)((0, import_utils45.decodeBase58)(extendedKey)));
11417
+ const bytes = (0, import_utils45.arrayify)(decoded);
11285
11418
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
11286
11419
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
11287
11420
  throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -11290,9 +11423,9 @@ var HDWallet = class _HDWallet {
11290
11423
  throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
11291
11424
  }
11292
11425
  const depth = bytes[4];
11293
- const parentFingerprint = (0, import_utils44.hexlify)(bytes.slice(5, 9));
11294
- const index = parseInt((0, import_utils44.hexlify)(bytes.slice(9, 13)).substring(2), 16);
11295
- const chainCode = (0, import_utils44.hexlify)(bytes.slice(13, 45));
11426
+ const parentFingerprint = (0, import_utils45.hexlify)(bytes.slice(5, 9));
11427
+ const index = parseInt((0, import_utils45.hexlify)(bytes.slice(9, 13)).substring(2), 16);
11428
+ const chainCode = (0, import_utils45.hexlify)(bytes.slice(13, 45));
11296
11429
  const key = bytes.slice(45, 78);
11297
11430
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
11298
11431
  throw new import_errors27.FuelError(
@@ -11522,7 +11655,7 @@ var WalletsConfig = class _WalletsConfig {
11522
11655
  return {
11523
11656
  ...snapshotConfig,
11524
11657
  stateConfig: {
11525
- ...snapshotConfig?.stateConfig ?? import_utils45.defaultSnapshotConfigs.stateConfig,
11658
+ ...snapshotConfig?.stateConfig ?? import_utils46.defaultSnapshotConfigs.stateConfig,
11526
11659
  coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
11527
11660
  messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
11528
11661
  }
@@ -11555,7 +11688,7 @@ var WalletsConfig = class _WalletsConfig {
11555
11688
  tx_pointer_block_height: 0,
11556
11689
  tx_pointer_tx_idx: 0,
11557
11690
  output_index: 0,
11558
- tx_id: (0, import_utils45.hexlify)((0, import_crypto9.randomBytes)(32))
11691
+ tx_id: (0, import_utils46.hexlify)((0, import_crypto9.randomBytes)(32))
11559
11692
  });
11560
11693
  }
11561
11694
  });
@@ -11611,7 +11744,7 @@ async function setupTestProviderAndWallets({
11611
11744
  } = {}) {
11612
11745
  Symbol.dispose ??= Symbol("Symbol.dispose");
11613
11746
  const walletsConfig = new WalletsConfig(
11614
- nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V2?.base_asset_id ?? import_utils46.defaultSnapshotConfigs.chainConfig.consensus_parameters.V2.base_asset_id,
11747
+ nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V2?.base_asset_id ?? import_utils47.defaultSnapshotConfigs.chainConfig.consensus_parameters.V2.base_asset_id,
11615
11748
  {
11616
11749
  ...defaultWalletConfigOptions,
11617
11750
  ...walletsConfigOptions
@@ -11621,7 +11754,7 @@ async function setupTestProviderAndWallets({
11621
11754
  loggingEnabled: false,
11622
11755
  ...nodeOptions,
11623
11756
  snapshotConfig: (0, import_ramda10.mergeDeepRight)(
11624
- import_utils46.defaultSnapshotConfigs,
11757
+ import_utils47.defaultSnapshotConfigs,
11625
11758
  walletsConfig.apply(nodeOptions?.snapshotConfig)
11626
11759
  ),
11627
11760
  port: nodeOptions.port || "0"
@@ -11667,7 +11800,7 @@ __name(setupTestProviderAndWallets, "setupTestProviderAndWallets");
11667
11800
  var import_address8 = require("@fuel-ts/address");
11668
11801
  var import_crypto10 = require("@fuel-ts/crypto");
11669
11802
  var import_math26 = require("@fuel-ts/math");
11670
- var import_utils47 = require("@fuel-ts/utils");
11803
+ var import_utils48 = require("@fuel-ts/utils");
11671
11804
  var TestMessage = class {
11672
11805
  static {
11673
11806
  __name(this, "TestMessage");
@@ -11687,7 +11820,7 @@ var TestMessage = class {
11687
11820
  constructor({
11688
11821
  sender = import_address8.Address.fromRandom(),
11689
11822
  recipient = import_address8.Address.fromRandom(),
11690
- nonce = (0, import_utils47.hexlify)((0, import_crypto10.randomBytes)(32)),
11823
+ nonce = (0, import_utils48.hexlify)((0, import_crypto10.randomBytes)(32)),
11691
11824
  amount = 1e6,
11692
11825
  data = "",
11693
11826
  // Will default to empty data in order to be a spendable message