@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.
- package/dist/index.global.js +845 -432
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +29 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -9
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +655 -507
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/utils/network.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +2 -8
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +3 -5
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts +2 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -1
- package/dist/test-utils.global.js +894 -459
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +67 -36
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +66 -35
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +23 -23
package/dist/test-utils.mjs
CHANGED
@@ -510,6 +510,12 @@ var GasCostsFragmentDoc = gql`
|
|
510
510
|
alocDependentCost {
|
511
511
|
...DependentCostFragment
|
512
512
|
}
|
513
|
+
cfe {
|
514
|
+
...DependentCostFragment
|
515
|
+
}
|
516
|
+
cfeiDependentCost {
|
517
|
+
...DependentCostFragment
|
518
|
+
}
|
513
519
|
call {
|
514
520
|
...DependentCostFragment
|
515
521
|
}
|
@@ -1675,7 +1681,7 @@ import {
|
|
1675
1681
|
PANIC_REASONS,
|
1676
1682
|
PANIC_DOC_URL
|
1677
1683
|
} from "@fuel-ts/transactions/configs";
|
1678
|
-
var assemblePanicError = (statusReason) => {
|
1684
|
+
var assemblePanicError = (statusReason, metadata) => {
|
1679
1685
|
let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
|
1680
1686
|
if (PANIC_REASONS.includes(statusReason)) {
|
1681
1687
|
errorMessage = `${errorMessage}
|
@@ -1684,10 +1690,13 @@ You can read more about this error at:
|
|
1684
1690
|
|
1685
1691
|
${PANIC_DOC_URL}#variant.${statusReason}`;
|
1686
1692
|
}
|
1687
|
-
return
|
1693
|
+
return new FuelError7(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
1694
|
+
...metadata,
|
1695
|
+
reason: statusReason
|
1696
|
+
});
|
1688
1697
|
};
|
1689
1698
|
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
1690
|
-
var assembleRevertError = (receipts, logs) => {
|
1699
|
+
var assembleRevertError = (receipts, logs, metadata) => {
|
1691
1700
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
1692
1701
|
const revertReceipt = receipts.find(({ type }) => type === ReceiptType3.Revert);
|
1693
1702
|
let reason = "";
|
@@ -1720,25 +1729,36 @@ var assembleRevertError = (receipts, logs) => {
|
|
1720
1729
|
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
1721
1730
|
break;
|
1722
1731
|
default:
|
1723
|
-
|
1724
|
-
|
1732
|
+
throw new FuelError7(
|
1733
|
+
ErrorCode7.UNKNOWN,
|
1734
|
+
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
1735
|
+
{
|
1736
|
+
...metadata,
|
1737
|
+
reason: "unknown"
|
1738
|
+
}
|
1739
|
+
);
|
1725
1740
|
}
|
1726
1741
|
}
|
1727
|
-
return
|
1742
|
+
return new FuelError7(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
1743
|
+
...metadata,
|
1744
|
+
reason
|
1745
|
+
});
|
1728
1746
|
};
|
1729
1747
|
var extractTxError = (params) => {
|
1730
1748
|
const { receipts, statusReason, logs } = params;
|
1731
1749
|
const isPanic = receipts.some(({ type }) => type === ReceiptType3.Panic);
|
1732
1750
|
const isRevert = receipts.some(({ type }) => type === ReceiptType3.Revert);
|
1733
|
-
const { errorMessage, reason } = isPanic ? assemblePanicError(statusReason) : assembleRevertError(receipts, logs);
|
1734
1751
|
const metadata = {
|
1735
1752
|
logs,
|
1736
1753
|
receipts,
|
1737
1754
|
panic: isPanic,
|
1738
1755
|
revert: isRevert,
|
1739
|
-
reason
|
1756
|
+
reason: ""
|
1740
1757
|
};
|
1741
|
-
|
1758
|
+
if (isPanic) {
|
1759
|
+
return assemblePanicError(statusReason, metadata);
|
1760
|
+
}
|
1761
|
+
return assembleRevertError(receipts, logs, metadata);
|
1742
1762
|
};
|
1743
1763
|
|
1744
1764
|
// src/providers/transaction-request/errors.ts
|
@@ -8613,8 +8633,8 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8613
8633
|
// src/test-utils/launchNode.ts
|
8614
8634
|
import { BYTES_32 as BYTES_322 } from "@fuel-ts/abi-coder";
|
8615
8635
|
import { randomBytes as randomBytes7 } from "@fuel-ts/crypto";
|
8636
|
+
import { FuelError as FuelError20 } from "@fuel-ts/errors";
|
8616
8637
|
import { defaultConsensusKey, hexlify as hexlify19, defaultSnapshotConfigs } from "@fuel-ts/utils";
|
8617
|
-
import { spawn } from "child_process";
|
8618
8638
|
import { randomUUID } from "crypto";
|
8619
8639
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
|
8620
8640
|
import os from "os";
|
@@ -8645,7 +8665,6 @@ var killNode = (params) => {
|
|
8645
8665
|
state.isDead = true;
|
8646
8666
|
killFn(Number(child.pid));
|
8647
8667
|
}
|
8648
|
-
child.stdout.removeAllListeners();
|
8649
8668
|
child.stderr.removeAllListeners();
|
8650
8669
|
if (existsSync(configPath)) {
|
8651
8670
|
rmSync(configPath, { recursive: true });
|
@@ -8690,12 +8709,11 @@ var launchNode = async ({
|
|
8690
8709
|
ip,
|
8691
8710
|
port,
|
8692
8711
|
args = [],
|
8693
|
-
fuelCorePath = process.env.FUEL_CORE_PATH
|
8712
|
+
fuelCorePath = process.env.FUEL_CORE_PATH || void 0,
|
8694
8713
|
loggingEnabled = true,
|
8695
|
-
debugEnabled = false,
|
8696
8714
|
basePath,
|
8697
8715
|
snapshotConfig = defaultSnapshotConfigs
|
8698
|
-
}) => (
|
8716
|
+
} = {}) => (
|
8699
8717
|
// eslint-disable-next-line no-async-promise-executor
|
8700
8718
|
new Promise(async (resolve, reject) => {
|
8701
8719
|
const remainingArgs = extractRemainingArgs(args, [
|
@@ -8712,7 +8730,7 @@ var launchNode = async ({
|
|
8712
8730
|
const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
|
8713
8731
|
const nativeExecutorVersion = getFlagValueFromArgs(args, "--native-executor-version") || "0";
|
8714
8732
|
const graphQLStartSubstring = "Binding GraphQL provider to";
|
8715
|
-
const command = fuelCorePath
|
8733
|
+
const command = fuelCorePath || "fuel-core";
|
8716
8734
|
const ipToUse = ip || "0.0.0.0";
|
8717
8735
|
const portToUse = port || (await getPortPromise({
|
8718
8736
|
port: 4e3,
|
@@ -8741,6 +8759,7 @@ var launchNode = async ({
|
|
8741
8759
|
writeFileSync(stateTransitionPath, JSON.stringify(""));
|
8742
8760
|
snapshotDirToUse = tempDir;
|
8743
8761
|
}
|
8762
|
+
const { spawn } = await import("child_process");
|
8744
8763
|
const child = spawn(
|
8745
8764
|
command,
|
8746
8765
|
[
|
@@ -8758,15 +8777,12 @@ var launchNode = async ({
|
|
8758
8777
|
"--debug",
|
8759
8778
|
...remainingArgs
|
8760
8779
|
].flat(),
|
8761
|
-
{
|
8762
|
-
stdio: "pipe"
|
8763
|
-
}
|
8780
|
+
{ stdio: "pipe" }
|
8764
8781
|
);
|
8765
8782
|
if (loggingEnabled) {
|
8766
|
-
child.stderr.
|
8767
|
-
|
8768
|
-
|
8769
|
-
child.stdout.pipe(process.stdout);
|
8783
|
+
child.stderr.on("data", (chunk) => {
|
8784
|
+
console.log(chunk.toString());
|
8785
|
+
});
|
8770
8786
|
}
|
8771
8787
|
const cleanupConfig = {
|
8772
8788
|
child,
|
@@ -8791,7 +8807,8 @@ var launchNode = async ({
|
|
8791
8807
|
});
|
8792
8808
|
}
|
8793
8809
|
if (/error/i.test(text)) {
|
8794
|
-
|
8810
|
+
console.log(text);
|
8811
|
+
reject(new FuelError20(FuelError20.CODES.NODE_LAUNCH_FAILED, text));
|
8795
8812
|
}
|
8796
8813
|
});
|
8797
8814
|
process.on("exit", () => killNode(cleanupConfig));
|
@@ -8854,7 +8871,7 @@ __publicField(AssetId, "B", new _AssetId(
|
|
8854
8871
|
|
8855
8872
|
// src/test-utils/wallet-config.ts
|
8856
8873
|
import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
|
8857
|
-
import { FuelError as
|
8874
|
+
import { FuelError as FuelError21 } from "@fuel-ts/errors";
|
8858
8875
|
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify21 } from "@fuel-ts/utils";
|
8859
8876
|
var WalletsConfig = class {
|
8860
8877
|
initialState;
|
@@ -8934,26 +8951,26 @@ var WalletsConfig = class {
|
|
8934
8951
|
amountPerCoin
|
8935
8952
|
}) {
|
8936
8953
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
8937
|
-
throw new
|
8938
|
-
|
8954
|
+
throw new FuelError21(
|
8955
|
+
FuelError21.CODES.INVALID_INPUT_PARAMETERS,
|
8939
8956
|
"Number of wallets must be greater than zero."
|
8940
8957
|
);
|
8941
8958
|
}
|
8942
8959
|
if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
|
8943
|
-
throw new
|
8944
|
-
|
8960
|
+
throw new FuelError21(
|
8961
|
+
FuelError21.CODES.INVALID_INPUT_PARAMETERS,
|
8945
8962
|
"Number of assets per wallet must be greater than zero."
|
8946
8963
|
);
|
8947
8964
|
}
|
8948
8965
|
if (coinsPerAsset <= 0) {
|
8949
|
-
throw new
|
8950
|
-
|
8966
|
+
throw new FuelError21(
|
8967
|
+
FuelError21.CODES.INVALID_INPUT_PARAMETERS,
|
8951
8968
|
"Number of coins per asset must be greater than zero."
|
8952
8969
|
);
|
8953
8970
|
}
|
8954
8971
|
if (amountPerCoin <= 0) {
|
8955
|
-
throw new
|
8956
|
-
|
8972
|
+
throw new FuelError21(
|
8973
|
+
FuelError21.CODES.INVALID_INPUT_PARAMETERS,
|
8957
8974
|
"Amount per coin must be greater than zero."
|
8958
8975
|
);
|
8959
8976
|
}
|
@@ -8971,7 +8988,8 @@ var defaultWalletConfigOptions = {
|
|
8971
8988
|
async function setupTestProviderAndWallets({
|
8972
8989
|
walletsConfig: walletsConfigOptions = {},
|
8973
8990
|
providerOptions,
|
8974
|
-
nodeOptions = {}
|
8991
|
+
nodeOptions = {},
|
8992
|
+
launchNodeServerPort = process.env.LAUNCH_NODE_SERVER_PORT || void 0
|
8975
8993
|
} = {}) {
|
8976
8994
|
Symbol.dispose ??= Symbol("Symbol.dispose");
|
8977
8995
|
const walletsConfig = new WalletsConfig(
|
@@ -8981,7 +8999,7 @@ async function setupTestProviderAndWallets({
|
|
8981
8999
|
...walletsConfigOptions
|
8982
9000
|
}
|
8983
9001
|
);
|
8984
|
-
const
|
9002
|
+
const launchNodeOptions = {
|
8985
9003
|
loggingEnabled: false,
|
8986
9004
|
...nodeOptions,
|
8987
9005
|
snapshotConfig: mergeDeepRight(
|
@@ -8989,7 +9007,20 @@ async function setupTestProviderAndWallets({
|
|
8989
9007
|
walletsConfig.apply(nodeOptions?.snapshotConfig)
|
8990
9008
|
),
|
8991
9009
|
port: "0"
|
8992
|
-
}
|
9010
|
+
};
|
9011
|
+
let cleanup;
|
9012
|
+
let url;
|
9013
|
+
if (launchNodeServerPort) {
|
9014
|
+
const serverUrl = `http://localhost:${launchNodeServerPort}`;
|
9015
|
+
url = await (await fetch(serverUrl, { method: "POST", body: JSON.stringify(launchNodeOptions) })).text();
|
9016
|
+
cleanup = () => {
|
9017
|
+
fetch(`${serverUrl}/cleanup/${url}`);
|
9018
|
+
};
|
9019
|
+
} else {
|
9020
|
+
const settings = await launchNode(launchNodeOptions);
|
9021
|
+
url = settings.url;
|
9022
|
+
cleanup = settings.cleanup;
|
9023
|
+
}
|
8993
9024
|
let provider;
|
8994
9025
|
try {
|
8995
9026
|
provider = await Provider.create(url, providerOptions);
|