@fuel-ts/account 0.0.0-rc-2272-20240517113706 → 0.0.0-rc-2143-20240517135655

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.

@@ -36816,6 +36816,7 @@ ${SqueezedOutStatusFragmentDoc}`;
36816
36816
  ${InputEstimatePredicatesFragmentDoc}`;
36817
36817
  var DryRunFailureStatusFragmentDoc = lib_default2`
36818
36818
  fragment dryRunFailureStatusFragment on DryRunFailureStatus {
36819
+ type: __typename
36819
36820
  totalGas
36820
36821
  totalFee
36821
36822
  reason
@@ -36827,6 +36828,7 @@ ${SqueezedOutStatusFragmentDoc}`;
36827
36828
  `;
36828
36829
  var DryRunSuccessStatusFragmentDoc = lib_default2`
36829
36830
  fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
36831
+ type: __typename
36830
36832
  totalGas
36831
36833
  totalFee
36832
36834
  programState {
@@ -38335,17 +38337,16 @@ ${MessageCoinFragmentDoc}`;
38335
38337
  }
38336
38338
 
38337
38339
  // src/providers/utils/extract-tx-error.ts
38338
- var assemblePanicError = (status) => {
38339
- let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
38340
- const reason = status.reason;
38341
- if (PANIC_REASONS.includes(status.reason)) {
38340
+ var assemblePanicError = (statusReason) => {
38341
+ let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
38342
+ if (PANIC_REASONS.includes(statusReason)) {
38342
38343
  errorMessage = `${errorMessage}
38343
38344
 
38344
38345
  You can read more about this error at:
38345
38346
 
38346
- ${PANIC_DOC_URL}#variant.${status.reason}`;
38347
+ ${PANIC_DOC_URL}#variant.${statusReason}`;
38347
38348
  }
38348
- return { errorMessage, reason };
38349
+ return { errorMessage, reason: statusReason };
38349
38350
  };
38350
38351
  var stringify = (obj) => JSON.stringify(obj, null, 2);
38351
38352
  var assembleRevertError = (receipts, logs) => {
@@ -38388,10 +38389,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
38388
38389
  return { errorMessage, reason };
38389
38390
  };
38390
38391
  var extractTxError = (params) => {
38391
- const { receipts, status, logs } = params;
38392
+ const { receipts, statusReason, logs } = params;
38392
38393
  const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
38393
38394
  const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
38394
- const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
38395
+ const { errorMessage, reason } = isPanic ? assemblePanicError(statusReason) : assembleRevertError(receipts, logs);
38395
38396
  const metadata = {
38396
38397
  logs,
38397
38398
  receipts,
@@ -40270,14 +40271,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
40270
40271
  );
40271
40272
  transactionResult.logs = logs;
40272
40273
  }
40273
- if (transactionResult.isStatusFailure) {
40274
- const {
40275
- receipts,
40276
- gqlTransaction: { status }
40277
- } = transactionResult;
40274
+ const { gqlTransaction, receipts } = transactionResult;
40275
+ if (gqlTransaction.status?.type === "FailureStatus") {
40276
+ const { reason } = gqlTransaction.status;
40278
40277
  throw extractTxError({
40279
40278
  receipts,
40280
- status,
40279
+ statusReason: reason,
40281
40280
  logs
40282
40281
  });
40283
40282
  }
@@ -41009,7 +41008,10 @@ Supported fuel-core version: ${supportedVersion}.`
41009
41008
  await signatureCallback(txRequestClone);
41010
41009
  }
41011
41010
  ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
41012
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
41011
+ if (dryRunStatus && "reason" in dryRunStatus) {
41012
+ throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
41013
+ }
41014
+ gasUsed = getGasUsedFromReceipts(receipts);
41013
41015
  txRequestClone.gasLimit = gasUsed;
41014
41016
  ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
41015
41017
  transactionRequest: txRequestClone,
@@ -41461,6 +41463,22 @@ Supported fuel-core version: ${supportedVersion}.`
41461
41463
  }
41462
41464
  return relayedTransactionStatus;
41463
41465
  }
41466
+ extractDryRunError(transactionRequest, receipts, dryRunStatus) {
41467
+ const status = dryRunStatus;
41468
+ let logs = [];
41469
+ if (transactionRequest.abis) {
41470
+ logs = getDecodedLogs(
41471
+ receipts,
41472
+ transactionRequest.abis.main,
41473
+ transactionRequest.abis.otherContractsAbis
41474
+ );
41475
+ }
41476
+ return extractTxError({
41477
+ logs,
41478
+ receipts,
41479
+ statusReason: status.reason
41480
+ });
41481
+ }
41464
41482
  };
41465
41483
  var Provider = _Provider;
41466
41484
  _cacheInputs = new WeakSet();