@fuel-ts/account 0.0.0-rc-1356-20240511074927 → 0.0.0-rc-2143-20240513161105
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 +19 -10
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +123 -113
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/providers/utils/sleep.d.ts +3 -0
- package/dist/providers/utils/sleep.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +0 -4
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +4 -9
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +2419 -506
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +166 -394
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +67 -291
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -16
- package/dist/test-utils/asset-id.d.ts +0 -8
- package/dist/test-utils/asset-id.d.ts.map +0 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts +0 -33
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +0 -1
- package/dist/test-utils/test-message.d.ts +0 -28
- package/dist/test-utils/test-message.d.ts.map +0 -1
- package/dist/test-utils/wallet-config.d.ts +0 -49
- package/dist/test-utils/wallet-config.d.ts.map +0 -1
package/dist/test-utils.mjs
CHANGED
@@ -1645,6 +1645,15 @@ function normalizeJSON(root) {
|
|
1645
1645
|
return normalize(clone(root));
|
1646
1646
|
}
|
1647
1647
|
|
1648
|
+
// src/providers/utils/sleep.ts
|
1649
|
+
function sleep(time) {
|
1650
|
+
return new Promise((resolve) => {
|
1651
|
+
setTimeout(() => {
|
1652
|
+
resolve(true);
|
1653
|
+
}, time);
|
1654
|
+
});
|
1655
|
+
}
|
1656
|
+
|
1648
1657
|
// src/providers/utils/extract-tx-error.ts
|
1649
1658
|
import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
|
1650
1659
|
import { bn as bn6 } from "@fuel-ts/math";
|
@@ -3616,7 +3625,6 @@ var TransactionResponse = class {
|
|
3616
3625
|
};
|
3617
3626
|
|
3618
3627
|
// src/providers/utils/auto-retry-fetch.ts
|
3619
|
-
import { sleep } from "@fuel-ts/utils";
|
3620
3628
|
function getWaitDelay(options, retryAttemptNum) {
|
3621
3629
|
const duration = options.baseDelay ?? 150;
|
3622
3630
|
switch (options.backoff) {
|
@@ -8454,7 +8462,7 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8454
8462
|
// src/test-utils/launchNode.ts
|
8455
8463
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
8456
8464
|
import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
|
8457
|
-
import { defaultConsensusKey, hexlify as hexlify18
|
8465
|
+
import { defaultSnapshotConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
|
8458
8466
|
import { findBinPath } from "@fuel-ts/utils/cli-utils";
|
8459
8467
|
import { spawn } from "child_process";
|
8460
8468
|
import { randomUUID } from "crypto";
|
@@ -8494,49 +8502,15 @@ var killNode = (params) => {
|
|
8494
8502
|
}
|
8495
8503
|
}
|
8496
8504
|
};
|
8497
|
-
function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
|
8498
|
-
const defaultCoins = defaultSnapshotConfigs.stateConfig.coins.map((coin) => ({
|
8499
|
-
...coin,
|
8500
|
-
amount: "18446744073709551615"
|
8501
|
-
}));
|
8502
|
-
const defaultMessages = defaultSnapshotConfigs.stateConfig.messages.map((message) => ({
|
8503
|
-
...message,
|
8504
|
-
amount: "18446744073709551615"
|
8505
|
-
}));
|
8506
|
-
const coins = defaultCoins.concat(stateConfig.coins.map((coin) => ({ ...coin, amount: coin.amount.toString() }))).filter((coin, index, self) => self.findIndex((c) => c.tx_id === coin.tx_id) === index);
|
8507
|
-
const messages = defaultMessages.concat(stateConfig.messages.map((msg) => ({ ...msg, amount: msg.amount.toString() }))).filter((msg, index, self) => self.findIndex((m) => m.nonce === msg.nonce) === index);
|
8508
|
-
if (!process.env.GENESIS_SECRET) {
|
8509
|
-
const pk = Signer.generatePrivateKey();
|
8510
|
-
const signer = new Signer(pk);
|
8511
|
-
process.env.GENESIS_SECRET = hexlify18(pk);
|
8512
|
-
coins.push({
|
8513
|
-
tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
|
8514
|
-
owner: signer.address.toHexString(),
|
8515
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8516
|
-
amount: "18446744073709551615",
|
8517
|
-
asset_id: chainConfig.consensus_parameters.V1.base_asset_id,
|
8518
|
-
output_index: 0,
|
8519
|
-
tx_pointer_block_height: 0,
|
8520
|
-
tx_pointer_tx_idx: 0
|
8521
|
-
});
|
8522
|
-
}
|
8523
|
-
const json = JSON.stringify({
|
8524
|
-
...stateConfig,
|
8525
|
-
coins,
|
8526
|
-
messages
|
8527
|
-
});
|
8528
|
-
const regexMakeNumber = /("amount":)"(\d+)"/gm;
|
8529
|
-
return json.replace(regexMakeNumber, "$1$2");
|
8530
|
-
}
|
8531
8505
|
var launchNode = async ({
|
8532
8506
|
ip,
|
8533
8507
|
port,
|
8534
8508
|
args = [],
|
8509
|
+
fuelCorePath = void 0,
|
8535
8510
|
useSystemFuelCore = false,
|
8536
8511
|
loggingEnabled = true,
|
8537
8512
|
debugEnabled = false,
|
8538
|
-
basePath
|
8539
|
-
snapshotConfig = defaultSnapshotConfigs
|
8513
|
+
basePath
|
8540
8514
|
}) => (
|
8541
8515
|
// eslint-disable-next-line no-async-promise-executor
|
8542
8516
|
new Promise(async (resolve, reject) => {
|
@@ -8553,7 +8527,7 @@ var launchNode = async ({
|
|
8553
8527
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
8554
8528
|
const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
|
8555
8529
|
const graphQLStartSubstring = "Binding GraphQL provider to";
|
8556
|
-
const binPath = findBinPath("fuels-core", __dirname);
|
8530
|
+
const binPath = fuelCorePath ?? findBinPath("fuels-core", __dirname);
|
8557
8531
|
const command = useSystemFuelCore ? "fuel-core" : binPath;
|
8558
8532
|
const ipToUse = ip || "0.0.0.0";
|
8559
8533
|
const portToUse = port || (await getPortPromise({
|
@@ -8565,23 +8539,56 @@ var launchNode = async ({
|
|
8565
8539
|
let snapshotDirToUse;
|
8566
8540
|
const prefix = basePath || os.tmpdir();
|
8567
8541
|
const suffix = basePath ? "" : randomUUID();
|
8568
|
-
const
|
8542
|
+
const tempDirPath = path.join(prefix, ".fuels", suffix, "snapshotDir");
|
8569
8543
|
if (snapshotDir) {
|
8570
8544
|
snapshotDirToUse = snapshotDir;
|
8571
8545
|
} else {
|
8572
|
-
if (!existsSync(
|
8573
|
-
mkdirSync(
|
8546
|
+
if (!existsSync(tempDirPath)) {
|
8547
|
+
mkdirSync(tempDirPath, { recursive: true });
|
8574
8548
|
}
|
8575
|
-
|
8576
|
-
const
|
8577
|
-
|
8578
|
-
|
8579
|
-
|
8580
|
-
|
8581
|
-
|
8582
|
-
|
8583
|
-
|
8584
|
-
|
8549
|
+
let { stateConfigJson } = defaultSnapshotConfigs;
|
8550
|
+
const { chainConfigJson, metadataJson } = defaultSnapshotConfigs;
|
8551
|
+
stateConfigJson = {
|
8552
|
+
...stateConfigJson,
|
8553
|
+
coins: [
|
8554
|
+
...stateConfigJson.coins.map((coin) => ({
|
8555
|
+
...coin,
|
8556
|
+
amount: "18446744073709551615"
|
8557
|
+
}))
|
8558
|
+
],
|
8559
|
+
messages: stateConfigJson.messages.map((message) => ({
|
8560
|
+
...message,
|
8561
|
+
amount: "18446744073709551615"
|
8562
|
+
}))
|
8563
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8564
|
+
};
|
8565
|
+
if (!process.env.GENESIS_SECRET) {
|
8566
|
+
const pk = Signer.generatePrivateKey();
|
8567
|
+
const signer = new Signer(pk);
|
8568
|
+
process.env.GENESIS_SECRET = hexlify18(pk);
|
8569
|
+
stateConfigJson.coins.push({
|
8570
|
+
tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
|
8571
|
+
owner: signer.address.toHexString(),
|
8572
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8573
|
+
amount: "18446744073709551615",
|
8574
|
+
asset_id: chainConfigJson.consensus_parameters.V1.base_asset_id,
|
8575
|
+
output_index: 0,
|
8576
|
+
tx_pointer_block_height: 0,
|
8577
|
+
tx_pointer_tx_idx: 0
|
8578
|
+
});
|
8579
|
+
}
|
8580
|
+
let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
|
8581
|
+
const regexMakeNumber = /("amount":)"(\d+)"/gm;
|
8582
|
+
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8583
|
+
const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
|
8584
|
+
const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
|
8585
|
+
const metadataWritePath = path.join(tempDirPath, "metadata.json");
|
8586
|
+
const stateTransitionWritePath = path.join(tempDirPath, "state_transition_bytecode.wasm");
|
8587
|
+
writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8588
|
+
writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8589
|
+
writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8590
|
+
writeFileSync(stateTransitionWritePath, JSON.stringify(""));
|
8591
|
+
snapshotDirToUse = tempDirPath;
|
8585
8592
|
}
|
8586
8593
|
const child = spawn(
|
8587
8594
|
command,
|
@@ -8589,7 +8596,7 @@ var launchNode = async ({
|
|
8589
8596
|
"run",
|
8590
8597
|
["--ip", ipToUse],
|
8591
8598
|
["--port", portToUse],
|
8592
|
-
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path",
|
8599
|
+
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8593
8600
|
["--min-gas-price", "1"],
|
8594
8601
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8595
8602
|
["--consensus-key", consensusKey],
|
@@ -8611,28 +8618,23 @@ var launchNode = async ({
|
|
8611
8618
|
}
|
8612
8619
|
const cleanupConfig = {
|
8613
8620
|
child,
|
8614
|
-
configPath:
|
8621
|
+
configPath: tempDirPath,
|
8615
8622
|
killFn: treeKill,
|
8616
8623
|
state: {
|
8617
8624
|
isDead: false
|
8618
8625
|
}
|
8619
8626
|
};
|
8620
8627
|
child.stderr.on("data", (chunk) => {
|
8621
|
-
|
8622
|
-
if (text.indexOf(graphQLStartSubstring) !== -1) {
|
8623
|
-
const rows = text.split("\n");
|
8624
|
-
const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
|
8625
|
-
const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
|
8628
|
+
if (chunk.indexOf(graphQLStartSubstring) !== -1) {
|
8626
8629
|
resolve({
|
8627
8630
|
cleanup: () => killNode(cleanupConfig),
|
8628
|
-
ip:
|
8629
|
-
port:
|
8630
|
-
url: `http://${realIp}:${realPort}/v1/graphql`,
|
8631
|
+
ip: ipToUse,
|
8632
|
+
port: portToUse,
|
8631
8633
|
snapshotDir: snapshotDirToUse
|
8632
8634
|
});
|
8633
8635
|
}
|
8634
|
-
if (/error/i.test(
|
8635
|
-
reject(
|
8636
|
+
if (/error/i.test(chunk)) {
|
8637
|
+
reject(chunk.toString());
|
8636
8638
|
}
|
8637
8639
|
});
|
8638
8640
|
process.on("exit", () => killNode(cleanupConfig));
|
@@ -8665,237 +8667,11 @@ var launchNodeAndGetWallets = async ({
|
|
8665
8667
|
};
|
8666
8668
|
return { wallets, stop: cleanup, provider };
|
8667
8669
|
};
|
8668
|
-
|
8669
|
-
// src/test-utils/setup-test-provider-and-wallets.ts
|
8670
|
-
import { defaultSnapshotConfigs as defaultSnapshotConfigs3 } from "@fuel-ts/utils";
|
8671
|
-
import { mergeDeepRight } from "ramda";
|
8672
|
-
|
8673
|
-
// src/test-utils/asset-id.ts
|
8674
|
-
import { randomBytes as randomBytes7 } from "@fuel-ts/crypto";
|
8675
|
-
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
8676
|
-
var _AssetId = class {
|
8677
|
-
constructor(value) {
|
8678
|
-
this.value = value;
|
8679
|
-
}
|
8680
|
-
static random() {
|
8681
|
-
return new _AssetId(hexlify19(randomBytes7(32)));
|
8682
|
-
}
|
8683
|
-
};
|
8684
|
-
var AssetId = _AssetId;
|
8685
|
-
__publicField(AssetId, "A", new _AssetId(
|
8686
|
-
"0x0101010101010101010101010101010101010101010101010101010101010101"
|
8687
|
-
));
|
8688
|
-
__publicField(AssetId, "B", new _AssetId(
|
8689
|
-
"0x0202020202020202020202020202020202020202020202020202020202020202"
|
8690
|
-
));
|
8691
|
-
|
8692
|
-
// src/test-utils/wallet-config.ts
|
8693
|
-
import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
|
8694
|
-
import { FuelError as FuelError20 } from "@fuel-ts/errors";
|
8695
|
-
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify20 } from "@fuel-ts/utils";
|
8696
|
-
var WalletConfig = class {
|
8697
|
-
initialState;
|
8698
|
-
options;
|
8699
|
-
wallets;
|
8700
|
-
generateWallets = () => {
|
8701
|
-
const generatedWallets = [];
|
8702
|
-
for (let index = 1; index <= this.options.count; index++) {
|
8703
|
-
generatedWallets.push(new WalletUnlocked(randomBytes8(32)));
|
8704
|
-
}
|
8705
|
-
return generatedWallets;
|
8706
|
-
};
|
8707
|
-
constructor(baseAssetId, config) {
|
8708
|
-
const BASE_ASSET_ID = baseAssetId.startsWith("0x") ? baseAssetId : `0x${baseAssetId}`;
|
8709
|
-
WalletConfig.guard(config);
|
8710
|
-
this.options = config;
|
8711
|
-
const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
|
8712
|
-
this.wallets = this.generateWallets();
|
8713
|
-
this.initialState = {
|
8714
|
-
messages: WalletConfig.createMessages(this.wallets, messages),
|
8715
|
-
coins: WalletConfig.createCoins(
|
8716
|
-
this.wallets,
|
8717
|
-
BASE_ASSET_ID,
|
8718
|
-
assets2,
|
8719
|
-
coinsPerAsset,
|
8720
|
-
amountPerCoin
|
8721
|
-
)
|
8722
|
-
};
|
8723
|
-
}
|
8724
|
-
apply(snapshotConfig) {
|
8725
|
-
return {
|
8726
|
-
...snapshotConfig,
|
8727
|
-
stateConfig: {
|
8728
|
-
...snapshotConfig?.stateConfig ?? defaultSnapshotConfigs2.stateConfig,
|
8729
|
-
coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
|
8730
|
-
messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
|
8731
|
-
}
|
8732
|
-
};
|
8733
|
-
}
|
8734
|
-
static createMessages(wallets, messages) {
|
8735
|
-
return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
|
8736
|
-
}
|
8737
|
-
static createCoins(wallets, baseAssetId, assets2, coinsPerAsset, amountPerCoin) {
|
8738
|
-
const coins = [];
|
8739
|
-
let assetIds = [baseAssetId];
|
8740
|
-
if (Array.isArray(assets2)) {
|
8741
|
-
assetIds = assetIds.concat(assets2.map((a) => a.value));
|
8742
|
-
} else {
|
8743
|
-
for (let index = 0; index < assets2 - 1; index++) {
|
8744
|
-
assetIds.push(AssetId.random().value);
|
8745
|
-
}
|
8746
|
-
}
|
8747
|
-
wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
|
8748
|
-
assetIds.forEach((assetId) => {
|
8749
|
-
for (let index = 0; index < coinsPerAsset; index++) {
|
8750
|
-
coins.push({
|
8751
|
-
amount: amountPerCoin,
|
8752
|
-
asset_id: assetId,
|
8753
|
-
owner: walletAddress,
|
8754
|
-
tx_pointer_block_height: 0,
|
8755
|
-
tx_pointer_tx_idx: 0,
|
8756
|
-
output_index: 0,
|
8757
|
-
tx_id: hexlify20(randomBytes8(32))
|
8758
|
-
});
|
8759
|
-
}
|
8760
|
-
});
|
8761
|
-
});
|
8762
|
-
return coins;
|
8763
|
-
}
|
8764
|
-
static guard({
|
8765
|
-
count: wallets,
|
8766
|
-
assets: assets2,
|
8767
|
-
coinsPerAsset,
|
8768
|
-
amountPerCoin
|
8769
|
-
}) {
|
8770
|
-
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
8771
|
-
throw new FuelError20(
|
8772
|
-
FuelError20.CODES.INVALID_INPUT_PARAMETERS,
|
8773
|
-
"Number of wallets must be greater than zero."
|
8774
|
-
);
|
8775
|
-
}
|
8776
|
-
if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
|
8777
|
-
throw new FuelError20(
|
8778
|
-
FuelError20.CODES.INVALID_INPUT_PARAMETERS,
|
8779
|
-
"Number of assets per wallet must be greater than zero."
|
8780
|
-
);
|
8781
|
-
}
|
8782
|
-
if (coinsPerAsset <= 0) {
|
8783
|
-
throw new FuelError20(
|
8784
|
-
FuelError20.CODES.INVALID_INPUT_PARAMETERS,
|
8785
|
-
"Number of coins per asset must be greater than zero."
|
8786
|
-
);
|
8787
|
-
}
|
8788
|
-
if (amountPerCoin <= 0) {
|
8789
|
-
throw new FuelError20(
|
8790
|
-
FuelError20.CODES.INVALID_INPUT_PARAMETERS,
|
8791
|
-
"Amount per coin must be greater than zero."
|
8792
|
-
);
|
8793
|
-
}
|
8794
|
-
}
|
8795
|
-
};
|
8796
|
-
|
8797
|
-
// src/test-utils/setup-test-provider-and-wallets.ts
|
8798
|
-
var defaultWalletConfigOptions = {
|
8799
|
-
count: 2,
|
8800
|
-
assets: [AssetId.A, AssetId.B],
|
8801
|
-
coinsPerAsset: 1,
|
8802
|
-
amountPerCoin: 1e10,
|
8803
|
-
messages: []
|
8804
|
-
};
|
8805
|
-
async function setupTestProviderAndWallets({
|
8806
|
-
walletConfig: walletConfigOptions = {},
|
8807
|
-
providerOptions,
|
8808
|
-
nodeOptions = {}
|
8809
|
-
} = {}) {
|
8810
|
-
Symbol.dispose ??= Symbol("Symbol.dispose");
|
8811
|
-
const walletConfig = new WalletConfig(
|
8812
|
-
nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ?? defaultSnapshotConfigs3.chainConfig.consensus_parameters.V1.base_asset_id,
|
8813
|
-
{
|
8814
|
-
...defaultWalletConfigOptions,
|
8815
|
-
...walletConfigOptions
|
8816
|
-
}
|
8817
|
-
);
|
8818
|
-
const { cleanup, url } = await launchNode({
|
8819
|
-
loggingEnabled: false,
|
8820
|
-
...nodeOptions,
|
8821
|
-
snapshotConfig: mergeDeepRight(
|
8822
|
-
defaultSnapshotConfigs3,
|
8823
|
-
walletConfig.apply(nodeOptions?.snapshotConfig)
|
8824
|
-
),
|
8825
|
-
port: "0"
|
8826
|
-
});
|
8827
|
-
let provider;
|
8828
|
-
try {
|
8829
|
-
provider = await Provider.create(url, providerOptions);
|
8830
|
-
} catch (err) {
|
8831
|
-
cleanup();
|
8832
|
-
throw err;
|
8833
|
-
}
|
8834
|
-
const wallets = walletConfig.wallets;
|
8835
|
-
wallets.forEach((wallet) => {
|
8836
|
-
wallet.connect(provider);
|
8837
|
-
});
|
8838
|
-
return {
|
8839
|
-
provider,
|
8840
|
-
wallets,
|
8841
|
-
cleanup,
|
8842
|
-
[Symbol.dispose]: cleanup
|
8843
|
-
};
|
8844
|
-
}
|
8845
|
-
|
8846
|
-
// src/test-utils/test-message.ts
|
8847
|
-
import { Address as Address6 } from "@fuel-ts/address";
|
8848
|
-
import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
|
8849
|
-
import { bn as bn22 } from "@fuel-ts/math";
|
8850
|
-
import { hexlify as hexlify21 } from "@fuel-ts/utils";
|
8851
|
-
var TestMessage = class {
|
8852
|
-
sender;
|
8853
|
-
recipient;
|
8854
|
-
nonce;
|
8855
|
-
amount;
|
8856
|
-
data;
|
8857
|
-
da_height;
|
8858
|
-
/**
|
8859
|
-
* A helper class to create messages for testing purposes.
|
8860
|
-
*
|
8861
|
-
* Used in tandem with `WalletConfig`.
|
8862
|
-
* It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
|
8863
|
-
*/
|
8864
|
-
constructor({
|
8865
|
-
sender = Address6.fromRandom(),
|
8866
|
-
recipient = Address6.fromRandom(),
|
8867
|
-
nonce = hexlify21(randomBytes9(32)),
|
8868
|
-
amount = 1e6,
|
8869
|
-
data = "02",
|
8870
|
-
da_height = 0
|
8871
|
-
} = {}) {
|
8872
|
-
this.sender = sender;
|
8873
|
-
this.recipient = recipient;
|
8874
|
-
this.nonce = nonce;
|
8875
|
-
this.amount = amount;
|
8876
|
-
this.data = data;
|
8877
|
-
this.da_height = da_height;
|
8878
|
-
}
|
8879
|
-
toChainMessage(recipient) {
|
8880
|
-
return {
|
8881
|
-
sender: this.sender.toB256(),
|
8882
|
-
recipient: recipient?.toB256() ?? this.recipient.toB256(),
|
8883
|
-
nonce: this.nonce,
|
8884
|
-
amount: bn22(this.amount).toNumber(),
|
8885
|
-
data: this.data,
|
8886
|
-
da_height: this.da_height
|
8887
|
-
};
|
8888
|
-
}
|
8889
|
-
};
|
8890
8670
|
export {
|
8891
|
-
AssetId,
|
8892
|
-
TestMessage,
|
8893
|
-
WalletConfig,
|
8894
8671
|
generateTestWallet,
|
8895
8672
|
killNode,
|
8896
8673
|
launchNode,
|
8897
8674
|
launchNodeAndGetWallets,
|
8898
|
-
seedTestWallet
|
8899
|
-
setupTestProviderAndWallets
|
8675
|
+
seedTestWallet
|
8900
8676
|
};
|
8901
8677
|
//# sourceMappingURL=test-utils.mjs.map
|