@fuel-ts/account 0.90.0 → 0.91.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.

@@ -547,6 +547,12 @@ var GasCostsFragmentDoc = import_graphql_tag.default`
547
547
  alocDependentCost {
548
548
  ...DependentCostFragment
549
549
  }
550
+ cfe {
551
+ ...DependentCostFragment
552
+ }
553
+ cfeiDependentCost {
554
+ ...DependentCostFragment
555
+ }
550
556
  call {
551
557
  ...DependentCostFragment
552
558
  }
@@ -1693,7 +1699,7 @@ var import_errors7 = require("@fuel-ts/errors");
1693
1699
  var import_math6 = require("@fuel-ts/math");
1694
1700
  var import_transactions5 = require("@fuel-ts/transactions");
1695
1701
  var import_configs5 = require("@fuel-ts/transactions/configs");
1696
- var assemblePanicError = (statusReason) => {
1702
+ var assemblePanicError = (statusReason, metadata) => {
1697
1703
  let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
1698
1704
  if (import_configs5.PANIC_REASONS.includes(statusReason)) {
1699
1705
  errorMessage = `${errorMessage}
@@ -1702,10 +1708,13 @@ You can read more about this error at:
1702
1708
 
1703
1709
  ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
1704
1710
  }
1705
- return { errorMessage, reason: statusReason };
1711
+ return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, {
1712
+ ...metadata,
1713
+ reason: statusReason
1714
+ });
1706
1715
  };
1707
1716
  var stringify = (obj) => JSON.stringify(obj, null, 2);
1708
- var assembleRevertError = (receipts, logs) => {
1717
+ var assembleRevertError = (receipts, logs, metadata) => {
1709
1718
  let errorMessage = "The transaction reverted with an unknown reason.";
1710
1719
  const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
1711
1720
  let reason = "";
@@ -1738,25 +1747,36 @@ var assembleRevertError = (receipts, logs) => {
1738
1747
  errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1739
1748
  break;
1740
1749
  default:
1741
- reason = "unknown";
1742
- errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1750
+ throw new import_errors7.FuelError(
1751
+ import_errors7.ErrorCode.UNKNOWN,
1752
+ `The transaction reverted with an unknown reason: ${revertReceipt.val}`,
1753
+ {
1754
+ ...metadata,
1755
+ reason: "unknown"
1756
+ }
1757
+ );
1743
1758
  }
1744
1759
  }
1745
- return { errorMessage, reason };
1760
+ return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, {
1761
+ ...metadata,
1762
+ reason
1763
+ });
1746
1764
  };
1747
1765
  var extractTxError = (params) => {
1748
1766
  const { receipts, statusReason, logs } = params;
1749
1767
  const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1750
1768
  const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
1751
- const { errorMessage, reason } = isPanic ? assemblePanicError(statusReason) : assembleRevertError(receipts, logs);
1752
1769
  const metadata = {
1753
1770
  logs,
1754
1771
  receipts,
1755
1772
  panic: isPanic,
1756
1773
  revert: isRevert,
1757
- reason
1774
+ reason: ""
1758
1775
  };
1759
- return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
1776
+ if (isPanic) {
1777
+ return assemblePanicError(statusReason, metadata);
1778
+ }
1779
+ return assembleRevertError(receipts, logs, metadata);
1760
1780
  };
1761
1781
 
1762
1782
  // src/providers/transaction-request/errors.ts
@@ -8623,8 +8643,8 @@ var generateTestWallet = async (provider, quantities) => {
8623
8643
  // src/test-utils/launchNode.ts
8624
8644
  var import_abi_coder8 = require("@fuel-ts/abi-coder");
8625
8645
  var import_crypto8 = require("@fuel-ts/crypto");
8646
+ var import_errors21 = require("@fuel-ts/errors");
8626
8647
  var import_utils37 = require("@fuel-ts/utils");
8627
- var import_child_process = require("child_process");
8628
8648
  var import_crypto9 = require("crypto");
8629
8649
  var import_fs = require("fs");
8630
8650
  var import_os = __toESM(require("os"));
@@ -8655,7 +8675,6 @@ var killNode = (params) => {
8655
8675
  state.isDead = true;
8656
8676
  killFn(Number(child.pid));
8657
8677
  }
8658
- child.stdout.removeAllListeners();
8659
8678
  child.stderr.removeAllListeners();
8660
8679
  if ((0, import_fs.existsSync)(configPath)) {
8661
8680
  (0, import_fs.rmSync)(configPath, { recursive: true });
@@ -8700,12 +8719,11 @@ var launchNode = async ({
8700
8719
  ip,
8701
8720
  port,
8702
8721
  args = [],
8703
- fuelCorePath = process.env.FUEL_CORE_PATH ?? void 0,
8722
+ fuelCorePath = process.env.FUEL_CORE_PATH || void 0,
8704
8723
  loggingEnabled = true,
8705
- debugEnabled = false,
8706
8724
  basePath,
8707
8725
  snapshotConfig = import_utils37.defaultSnapshotConfigs
8708
- }) => (
8726
+ } = {}) => (
8709
8727
  // eslint-disable-next-line no-async-promise-executor
8710
8728
  new Promise(async (resolve, reject) => {
8711
8729
  const remainingArgs = extractRemainingArgs(args, [
@@ -8722,7 +8740,7 @@ var launchNode = async ({
8722
8740
  const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
8723
8741
  const nativeExecutorVersion = getFlagValueFromArgs(args, "--native-executor-version") || "0";
8724
8742
  const graphQLStartSubstring = "Binding GraphQL provider to";
8725
- const command = fuelCorePath ?? "fuel-core";
8743
+ const command = fuelCorePath || "fuel-core";
8726
8744
  const ipToUse = ip || "0.0.0.0";
8727
8745
  const portToUse = port || (await (0, import_portfinder.getPortPromise)({
8728
8746
  port: 4e3,
@@ -8751,7 +8769,8 @@ var launchNode = async ({
8751
8769
  (0, import_fs.writeFileSync)(stateTransitionPath, JSON.stringify(""));
8752
8770
  snapshotDirToUse = tempDir;
8753
8771
  }
8754
- const child = (0, import_child_process.spawn)(
8772
+ const { spawn } = await import("child_process");
8773
+ const child = spawn(
8755
8774
  command,
8756
8775
  [
8757
8776
  "run",
@@ -8768,15 +8787,12 @@ var launchNode = async ({
8768
8787
  "--debug",
8769
8788
  ...remainingArgs
8770
8789
  ].flat(),
8771
- {
8772
- stdio: "pipe"
8773
- }
8790
+ { stdio: "pipe" }
8774
8791
  );
8775
8792
  if (loggingEnabled) {
8776
- child.stderr.pipe(process.stderr);
8777
- }
8778
- if (debugEnabled) {
8779
- child.stdout.pipe(process.stdout);
8793
+ child.stderr.on("data", (chunk) => {
8794
+ console.log(chunk.toString());
8795
+ });
8780
8796
  }
8781
8797
  const cleanupConfig = {
8782
8798
  child,
@@ -8801,7 +8817,8 @@ var launchNode = async ({
8801
8817
  });
8802
8818
  }
8803
8819
  if (/error/i.test(text)) {
8804
- reject(text.toString());
8820
+ console.log(text);
8821
+ reject(new import_errors21.FuelError(import_errors21.FuelError.CODES.NODE_LAUNCH_FAILED, text));
8805
8822
  }
8806
8823
  });
8807
8824
  process.on("exit", () => killNode(cleanupConfig));
@@ -8864,7 +8881,7 @@ __publicField(AssetId, "B", new _AssetId(
8864
8881
 
8865
8882
  // src/test-utils/wallet-config.ts
8866
8883
  var import_crypto11 = require("@fuel-ts/crypto");
8867
- var import_errors21 = require("@fuel-ts/errors");
8884
+ var import_errors22 = require("@fuel-ts/errors");
8868
8885
  var import_utils39 = require("@fuel-ts/utils");
8869
8886
  var WalletsConfig = class {
8870
8887
  initialState;
@@ -8944,26 +8961,26 @@ var WalletsConfig = class {
8944
8961
  amountPerCoin
8945
8962
  }) {
8946
8963
  if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
8947
- throw new import_errors21.FuelError(
8948
- import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8964
+ throw new import_errors22.FuelError(
8965
+ import_errors22.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8949
8966
  "Number of wallets must be greater than zero."
8950
8967
  );
8951
8968
  }
8952
8969
  if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
8953
- throw new import_errors21.FuelError(
8954
- import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8970
+ throw new import_errors22.FuelError(
8971
+ import_errors22.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8955
8972
  "Number of assets per wallet must be greater than zero."
8956
8973
  );
8957
8974
  }
8958
8975
  if (coinsPerAsset <= 0) {
8959
- throw new import_errors21.FuelError(
8960
- import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8976
+ throw new import_errors22.FuelError(
8977
+ import_errors22.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8961
8978
  "Number of coins per asset must be greater than zero."
8962
8979
  );
8963
8980
  }
8964
8981
  if (amountPerCoin <= 0) {
8965
- throw new import_errors21.FuelError(
8966
- import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8982
+ throw new import_errors22.FuelError(
8983
+ import_errors22.FuelError.CODES.INVALID_INPUT_PARAMETERS,
8967
8984
  "Amount per coin must be greater than zero."
8968
8985
  );
8969
8986
  }
@@ -8981,7 +8998,8 @@ var defaultWalletConfigOptions = {
8981
8998
  async function setupTestProviderAndWallets({
8982
8999
  walletsConfig: walletsConfigOptions = {},
8983
9000
  providerOptions,
8984
- nodeOptions = {}
9001
+ nodeOptions = {},
9002
+ launchNodeServerPort = process.env.LAUNCH_NODE_SERVER_PORT || void 0
8985
9003
  } = {}) {
8986
9004
  Symbol.dispose ??= Symbol("Symbol.dispose");
8987
9005
  const walletsConfig = new WalletsConfig(
@@ -8991,7 +9009,7 @@ async function setupTestProviderAndWallets({
8991
9009
  ...walletsConfigOptions
8992
9010
  }
8993
9011
  );
8994
- const { cleanup, url } = await launchNode({
9012
+ const launchNodeOptions = {
8995
9013
  loggingEnabled: false,
8996
9014
  ...nodeOptions,
8997
9015
  snapshotConfig: (0, import_ramda5.mergeDeepRight)(
@@ -8999,7 +9017,20 @@ async function setupTestProviderAndWallets({
8999
9017
  walletsConfig.apply(nodeOptions?.snapshotConfig)
9000
9018
  ),
9001
9019
  port: "0"
9002
- });
9020
+ };
9021
+ let cleanup;
9022
+ let url;
9023
+ if (launchNodeServerPort) {
9024
+ const serverUrl = `http://localhost:${launchNodeServerPort}`;
9025
+ url = await (await fetch(serverUrl, { method: "POST", body: JSON.stringify(launchNodeOptions) })).text();
9026
+ cleanup = () => {
9027
+ fetch(`${serverUrl}/cleanup/${url}`);
9028
+ };
9029
+ } else {
9030
+ const settings = await launchNode(launchNodeOptions);
9031
+ url = settings.url;
9032
+ cleanup = settings.cleanup;
9033
+ }
9003
9034
  let provider;
9004
9035
  try {
9005
9036
  provider = await Provider.create(url, providerOptions);