@fuel-ts/account 0.87.0 → 0.88.0

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.

@@ -248,6 +248,7 @@ var TransactionEstimatePredicatesFragmentDoc = import_graphql_tag.default`
248
248
  ${InputEstimatePredicatesFragmentDoc}`;
249
249
  var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
250
250
  fragment dryRunFailureStatusFragment on DryRunFailureStatus {
251
+ type: __typename
251
252
  totalGas
252
253
  totalFee
253
254
  reason
@@ -259,6 +260,7 @@ var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
259
260
  `;
260
261
  var DryRunSuccessStatusFragmentDoc = import_graphql_tag.default`
261
262
  fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
263
+ type: __typename
262
264
  totalGas
263
265
  totalFee
264
266
  programState {
@@ -1681,17 +1683,16 @@ var import_errors7 = require("@fuel-ts/errors");
1681
1683
  var import_math6 = require("@fuel-ts/math");
1682
1684
  var import_transactions5 = require("@fuel-ts/transactions");
1683
1685
  var import_configs5 = require("@fuel-ts/transactions/configs");
1684
- var assemblePanicError = (status) => {
1685
- let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1686
- const reason = status.reason;
1687
- if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1686
+ var assemblePanicError = (statusReason) => {
1687
+ let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
1688
+ if (import_configs5.PANIC_REASONS.includes(statusReason)) {
1688
1689
  errorMessage = `${errorMessage}
1689
1690
 
1690
1691
  You can read more about this error at:
1691
1692
 
1692
- ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1693
+ ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
1693
1694
  }
1694
- return { errorMessage, reason };
1695
+ return { errorMessage, reason: statusReason };
1695
1696
  };
1696
1697
  var stringify = (obj) => JSON.stringify(obj, null, 2);
1697
1698
  var assembleRevertError = (receipts, logs) => {
@@ -1734,10 +1735,10 @@ var assembleRevertError = (receipts, logs) => {
1734
1735
  return { errorMessage, reason };
1735
1736
  };
1736
1737
  var extractTxError = (params) => {
1737
- const { receipts, status, logs } = params;
1738
+ const { receipts, statusReason, logs } = params;
1738
1739
  const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1739
1740
  const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
1740
- const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1741
+ const { errorMessage, reason } = isPanic ? assemblePanicError(statusReason) : assembleRevertError(receipts, logs);
1741
1742
  const metadata = {
1742
1743
  logs,
1743
1744
  receipts,
@@ -3437,7 +3438,7 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3437
3438
  if (receipt.type === import_transactions18.ReceiptType.LogData || receipt.type === import_transactions18.ReceiptType.Log) {
3438
3439
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3439
3440
  const data = receipt.type === import_transactions18.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3440
- const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3441
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toString());
3441
3442
  logs.push(decodedLog);
3442
3443
  }
3443
3444
  return logs;
@@ -3595,14 +3596,12 @@ var TransactionResponse = class {
3595
3596
  );
3596
3597
  transactionResult.logs = logs;
3597
3598
  }
3598
- if (transactionResult.isStatusFailure) {
3599
- const {
3600
- receipts,
3601
- gqlTransaction: { status }
3602
- } = transactionResult;
3599
+ const { gqlTransaction, receipts } = transactionResult;
3600
+ if (gqlTransaction.status?.type === "FailureStatus") {
3601
+ const { reason } = gqlTransaction.status;
3603
3602
  throw extractTxError({
3604
3603
  receipts,
3605
- status,
3604
+ statusReason: reason,
3606
3605
  logs
3607
3606
  });
3608
3607
  }
@@ -4334,7 +4333,10 @@ Supported fuel-core version: ${supportedVersion}.`
4334
4333
  await signatureCallback(txRequestClone);
4335
4334
  }
4336
4335
  ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
4337
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4336
+ if (dryRunStatus && "reason" in dryRunStatus) {
4337
+ throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
4338
+ }
4339
+ gasUsed = getGasUsedFromReceipts(receipts);
4338
4340
  txRequestClone.gasLimit = gasUsed;
4339
4341
  ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4340
4342
  transactionRequest: txRequestClone,
@@ -4786,6 +4788,22 @@ Supported fuel-core version: ${supportedVersion}.`
4786
4788
  }
4787
4789
  return relayedTransactionStatus;
4788
4790
  }
4791
+ extractDryRunError(transactionRequest, receipts, dryRunStatus) {
4792
+ const status = dryRunStatus;
4793
+ let logs = [];
4794
+ if (transactionRequest.abis) {
4795
+ logs = getDecodedLogs(
4796
+ receipts,
4797
+ transactionRequest.abis.main,
4798
+ transactionRequest.abis.otherContractsAbis
4799
+ );
4800
+ }
4801
+ return extractTxError({
4802
+ logs,
4803
+ receipts,
4804
+ statusReason: status.reason
4805
+ });
4806
+ }
4789
4807
  };
4790
4808
  var Provider = _Provider;
4791
4809
  _cacheInputs = new WeakSet();