@fuel-ts/account 0.87.0 → 0.88.1

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
@@ -382,6 +382,7 @@ var TransactionEstimatePredicatesFragmentDoc = import_graphql_tag.default`
382
382
  ${InputEstimatePredicatesFragmentDoc}`;
383
383
  var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
384
384
  fragment dryRunFailureStatusFragment on DryRunFailureStatus {
385
+ type: __typename
385
386
  totalGas
386
387
  totalFee
387
388
  reason
@@ -393,6 +394,7 @@ var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
393
394
  `;
394
395
  var DryRunSuccessStatusFragmentDoc = import_graphql_tag.default`
395
396
  fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
397
+ type: __typename
396
398
  totalGas
397
399
  totalFee
398
400
  programState {
@@ -1877,17 +1879,16 @@ var import_errors7 = require("@fuel-ts/errors");
1877
1879
  var import_math6 = require("@fuel-ts/math");
1878
1880
  var import_transactions5 = require("@fuel-ts/transactions");
1879
1881
  var import_configs5 = require("@fuel-ts/transactions/configs");
1880
- var assemblePanicError = (status) => {
1881
- let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1882
- const reason = status.reason;
1883
- if (import_configs5.PANIC_REASONS.includes(status.reason)) {
1882
+ var assemblePanicError = (statusReason) => {
1883
+ let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
1884
+ if (import_configs5.PANIC_REASONS.includes(statusReason)) {
1884
1885
  errorMessage = `${errorMessage}
1885
1886
 
1886
1887
  You can read more about this error at:
1887
1888
 
1888
- ${import_configs5.PANIC_DOC_URL}#variant.${status.reason}`;
1889
+ ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
1889
1890
  }
1890
- return { errorMessage, reason };
1891
+ return { errorMessage, reason: statusReason };
1891
1892
  };
1892
1893
  var stringify = (obj) => JSON.stringify(obj, null, 2);
1893
1894
  var assembleRevertError = (receipts, logs) => {
@@ -1930,10 +1931,10 @@ var assembleRevertError = (receipts, logs) => {
1930
1931
  return { errorMessage, reason };
1931
1932
  };
1932
1933
  var extractTxError = (params) => {
1933
- const { receipts, status, logs } = params;
1934
+ const { receipts, statusReason, logs } = params;
1934
1935
  const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1935
1936
  const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
1936
- const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1937
+ const { errorMessage, reason } = isPanic ? assemblePanicError(statusReason) : assembleRevertError(receipts, logs);
1937
1938
  const metadata = {
1938
1939
  logs,
1939
1940
  receipts,
@@ -3710,7 +3711,7 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3710
3711
  if (receipt.type === import_transactions18.ReceiptType.LogData || receipt.type === import_transactions18.ReceiptType.Log) {
3711
3712
  const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3712
3713
  const data = receipt.type === import_transactions18.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3713
- const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3714
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toString());
3714
3715
  logs.push(decodedLog);
3715
3716
  }
3716
3717
  return logs;
@@ -3868,14 +3869,12 @@ var TransactionResponse = class {
3868
3869
  );
3869
3870
  transactionResult.logs = logs;
3870
3871
  }
3871
- if (transactionResult.isStatusFailure) {
3872
- const {
3873
- receipts,
3874
- gqlTransaction: { status }
3875
- } = transactionResult;
3872
+ const { gqlTransaction, receipts } = transactionResult;
3873
+ if (gqlTransaction.status?.type === "FailureStatus") {
3874
+ const { reason } = gqlTransaction.status;
3876
3875
  throw extractTxError({
3877
3876
  receipts,
3878
- status,
3877
+ statusReason: reason,
3879
3878
  logs
3880
3879
  });
3881
3880
  }
@@ -4607,7 +4606,10 @@ Supported fuel-core version: ${supportedVersion}.`
4607
4606
  await signatureCallback(txRequestClone);
4608
4607
  }
4609
4608
  ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
4610
- gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4609
+ if (dryRunStatus && "reason" in dryRunStatus) {
4610
+ throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
4611
+ }
4612
+ gasUsed = getGasUsedFromReceipts(receipts);
4611
4613
  txRequestClone.gasLimit = gasUsed;
4612
4614
  ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
4613
4615
  transactionRequest: txRequestClone,
@@ -5059,6 +5061,22 @@ Supported fuel-core version: ${supportedVersion}.`
5059
5061
  }
5060
5062
  return relayedTransactionStatus;
5061
5063
  }
5064
+ extractDryRunError(transactionRequest, receipts, dryRunStatus) {
5065
+ const status = dryRunStatus;
5066
+ let logs = [];
5067
+ if (transactionRequest.abis) {
5068
+ logs = getDecodedLogs(
5069
+ receipts,
5070
+ transactionRequest.abis.main,
5071
+ transactionRequest.abis.otherContractsAbis
5072
+ );
5073
+ }
5074
+ return extractTxError({
5075
+ logs,
5076
+ receipts,
5077
+ statusReason: status.reason
5078
+ });
5079
+ }
5062
5080
  };
5063
5081
  var Provider = _Provider;
5064
5082
  _cacheInputs = new WeakSet();
@@ -5214,7 +5232,7 @@ var getDefaultChainId = (networkType) => {
5214
5232
  return CHAIN_IDS.eth.sepolia;
5215
5233
  }
5216
5234
  if (networkType === "fuel") {
5217
- return CHAIN_IDS.fuel.beta5;
5235
+ return CHAIN_IDS.fuel.devnet;
5218
5236
  }
5219
5237
  return void 0;
5220
5238
  };