@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.

package/dist/index.mjs CHANGED
@@ -220,6 +220,7 @@ var TransactionEstimatePredicatesFragmentDoc = gql`
220
220
  ${InputEstimatePredicatesFragmentDoc}`;
221
221
  var DryRunFailureStatusFragmentDoc = gql`
222
222
  fragment dryRunFailureStatusFragment on DryRunFailureStatus {
223
+ type: __typename
223
224
  totalGas
224
225
  totalFee
225
226
  reason
@@ -231,6 +232,7 @@ var DryRunFailureStatusFragmentDoc = gql`
231
232
  `;
232
233
  var DryRunSuccessStatusFragmentDoc = gql`
233
234
  fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
235
+ type: __typename
234
236
  totalGas
235
237
  totalFee
236
238
  programState {
@@ -1734,17 +1736,16 @@ import {
1734
1736
  PANIC_REASONS,
1735
1737
  PANIC_DOC_URL
1736
1738
  } from "@fuel-ts/transactions/configs";
1737
- var assemblePanicError = (status) => {
1738
- let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1739
- const reason = status.reason;
1740
- if (PANIC_REASONS.includes(status.reason)) {
1739
+ var assemblePanicError = (statusReason) => {
1740
+ let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
1741
+ if (PANIC_REASONS.includes(statusReason)) {
1741
1742
  errorMessage = `${errorMessage}
1742
1743
 
1743
1744
  You can read more about this error at:
1744
1745
 
1745
- ${PANIC_DOC_URL}#variant.${status.reason}`;
1746
+ ${PANIC_DOC_URL}#variant.${statusReason}`;
1746
1747
  }
1747
- return { errorMessage, reason };
1748
+ return { errorMessage, reason: statusReason };
1748
1749
  };
1749
1750
  var stringify = (obj) => JSON.stringify(obj, null, 2);
1750
1751
  var assembleRevertError = (receipts, logs) => {
@@ -1787,10 +1788,10 @@ var assembleRevertError = (receipts, logs) => {
1787
1788
  return { errorMessage, reason };
1788
1789
  };
1789
1790
  var extractTxError = (params) => {
1790
- const { receipts, status, logs } = params;
1791
+ const { receipts, statusReason, logs } = params;
1791
1792
  const isPanic = receipts.some(({ type }) => type === ReceiptType3.Panic);
1792
1793
  const isRevert = receipts.some(({ type }) => type === ReceiptType3.Revert);
1793
- const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1794
+ const { errorMessage, reason } = isPanic ? assemblePanicError(statusReason) : assembleRevertError(receipts, logs);
1794
1795
  const metadata = {
1795
1796
  logs,
1796
1797
  receipts,
@@ -3567,7 +3568,7 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3567
3568
  if (receipt.type === ReceiptType6.LogData || receipt.type === ReceiptType6.Log) {
3568
3569
  const interfaceToUse = new Interface3(externalAbis[receipt.id] || mainAbi);
3569
3570
  const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3570
- const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3571
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toString());
3571
3572
  logs.push(decodedLog);
3572
3573
  }
3573
3574
  return logs;
@@ -3725,14 +3726,12 @@ var TransactionResponse = class {
3725
3726
  );
3726
3727
  transactionResult.logs = logs;
3727
3728
  }
3728
- if (transactionResult.isStatusFailure) {
3729
- const {
3730
- receipts,
3731
- gqlTransaction: { status }
3732
- } = transactionResult;
3729
+ const { gqlTransaction, receipts } = transactionResult;
3730
+ if (gqlTransaction.status?.type === "FailureStatus") {
3731
+ const { reason } = gqlTransaction.status;
3733
3732
  throw extractTxError({
3734
3733
  receipts,
3735
- status,
3734
+ statusReason: reason,
3736
3735
  logs
3737
3736
  });
3738
3737
  }
@@ -4464,7 +4463,10 @@ Supported fuel-core version: ${supportedVersion}.`
4464
4463
  await signatureCallback(txRequestClone);
4465
4464
  }
4466
4465
  ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
4467
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4466
+ if (dryRunStatus && "reason" in dryRunStatus) {
4467
+ throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
4468
+ }
4469
+ gasUsed = getGasUsedFromReceipts(receipts);
4468
4470
  txRequestClone.gasLimit = gasUsed;
4469
4471
  ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4470
4472
  transactionRequest: txRequestClone,
@@ -4916,6 +4918,22 @@ Supported fuel-core version: ${supportedVersion}.`
4916
4918
  }
4917
4919
  return relayedTransactionStatus;
4918
4920
  }
4921
+ extractDryRunError(transactionRequest, receipts, dryRunStatus) {
4922
+ const status = dryRunStatus;
4923
+ let logs = [];
4924
+ if (transactionRequest.abis) {
4925
+ logs = getDecodedLogs(
4926
+ receipts,
4927
+ transactionRequest.abis.main,
4928
+ transactionRequest.abis.otherContractsAbis
4929
+ );
4930
+ }
4931
+ return extractTxError({
4932
+ logs,
4933
+ receipts,
4934
+ statusReason: status.reason
4935
+ });
4936
+ }
4919
4937
  };
4920
4938
  var Provider = _Provider;
4921
4939
  _cacheInputs = new WeakSet();
@@ -5071,7 +5089,7 @@ var getDefaultChainId = (networkType) => {
5071
5089
  return CHAIN_IDS.eth.sepolia;
5072
5090
  }
5073
5091
  if (networkType === "fuel") {
5074
- return CHAIN_IDS.fuel.beta5;
5092
+ return CHAIN_IDS.fuel.devnet;
5075
5093
  }
5076
5094
  return void 0;
5077
5095
  };