@fuel-ts/account 0.0.0-rc-2395-20240528075431 → 0.0.0-rc-1356-20240528093309

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.

Files changed (38) hide show
  1. package/dist/index.global.js +17 -30
  2. package/dist/index.global.js.map +1 -1
  3. package/dist/index.js +126 -147
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +11 -31
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  8. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -1
  9. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  10. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  11. package/dist/providers/transaction-summary/operations.d.ts +2 -4
  12. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  13. package/dist/providers/transaction-summary/types.d.ts +0 -1
  14. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  15. package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -1
  16. package/dist/providers/utils/index.d.ts +0 -1
  17. package/dist/providers/utils/index.d.ts.map +1 -1
  18. package/dist/test-utils/asset-id.d.ts +8 -0
  19. package/dist/test-utils/asset-id.d.ts.map +1 -0
  20. package/dist/test-utils/index.d.ts +4 -0
  21. package/dist/test-utils/index.d.ts.map +1 -1
  22. package/dist/test-utils/launchNode.d.ts +8 -1
  23. package/dist/test-utils/launchNode.d.ts.map +1 -1
  24. package/dist/test-utils/setup-test-provider-and-wallets.d.ts +33 -0
  25. package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -0
  26. package/dist/test-utils/test-message.d.ts +29 -0
  27. package/dist/test-utils/test-message.d.ts.map +1 -0
  28. package/dist/test-utils/wallet-config.d.ts +55 -0
  29. package/dist/test-utils/wallet-config.d.ts.map +1 -0
  30. package/dist/test-utils.global.js +401 -79
  31. package/dist/test-utils.global.js.map +1 -1
  32. package/dist/test-utils.js +410 -179
  33. package/dist/test-utils.js.map +1 -1
  34. package/dist/test-utils.mjs +304 -77
  35. package/dist/test-utils.mjs.map +1 -1
  36. package/package.json +16 -15
  37. package/dist/providers/utils/sleep.d.ts +0 -3
  38. package/dist/providers/utils/sleep.d.ts.map +0 -1
@@ -1647,15 +1647,6 @@ function normalizeJSON(root) {
1647
1647
  return normalize(clone(root));
1648
1648
  }
1649
1649
 
1650
- // src/providers/utils/sleep.ts
1651
- function sleep(time) {
1652
- return new Promise((resolve) => {
1653
- setTimeout(() => {
1654
- resolve(true);
1655
- }, time);
1656
- });
1657
- }
1658
-
1659
1650
  // src/providers/utils/extract-tx-error.ts
1660
1651
  import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
1661
1652
  import { bn as bn6 } from "@fuel-ts/math";
@@ -2980,12 +2971,12 @@ function addOperation(operations, toAdd) {
2980
2971
  }
2981
2972
  function getWithdrawFromFuelOperations({
2982
2973
  inputs,
2983
- receipts,
2984
- assetId
2974
+ receipts
2985
2975
  }) {
2986
2976
  const messageOutReceipts = getReceiptsMessageOut(receipts);
2987
2977
  const withdrawFromFuelOperations = messageOutReceipts.reduce(
2988
2978
  (prevWithdrawFromFuelOps, receipt) => {
2979
+ const assetId = "0x0000000000000000000000000000000000000000000000000000000000000000";
2989
2980
  const input = getInputFromAssetId(inputs, assetId);
2990
2981
  if (input) {
2991
2982
  const inputAddress = getInputAccountAddress(input);
@@ -3199,8 +3190,7 @@ function getOperations({
3199
3190
  receipts,
3200
3191
  abiMap,
3201
3192
  rawPayload,
3202
- maxInputs,
3203
- assetId
3193
+ maxInputs
3204
3194
  }) {
3205
3195
  if (isTypeCreate(transactionType)) {
3206
3196
  return [
@@ -3219,7 +3209,7 @@ function getOperations({
3219
3209
  rawPayload,
3220
3210
  maxInputs
3221
3211
  }),
3222
- ...getWithdrawFromFuelOperations({ inputs, receipts, assetId })
3212
+ ...getWithdrawFromFuelOperations({ inputs, receipts })
3223
3213
  ];
3224
3214
  }
3225
3215
  return [...getPayProducerOperations(outputs)];
@@ -3355,8 +3345,7 @@ function assembleTransactionSummary(params) {
3355
3345
  maxInputs,
3356
3346
  gasCosts,
3357
3347
  maxGasPerTx,
3358
- gasPrice,
3359
- assetId
3348
+ gasPrice
3360
3349
  } = params;
3361
3350
  const gasUsed = getGasUsedFromReceipts(receipts);
3362
3351
  const rawPayload = hexlify11(transactionBytes);
@@ -3367,8 +3356,7 @@ function assembleTransactionSummary(params) {
3367
3356
  receipts,
3368
3357
  rawPayload,
3369
3358
  abiMap,
3370
- maxInputs,
3371
- assetId
3359
+ maxInputs
3372
3360
  });
3373
3361
  const typeName = getTransactionTypeName(transaction.type);
3374
3362
  const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
@@ -3528,7 +3516,6 @@ var TransactionResponse = class {
3528
3516
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3529
3517
  const gasPrice = await this.provider.getLatestGasPrice();
3530
3518
  const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3531
- const assetId = this.provider.getBaseAssetId();
3532
3519
  const transactionSummary = assembleTransactionSummary({
3533
3520
  id: this.id,
3534
3521
  receipts,
@@ -3541,8 +3528,7 @@ var TransactionResponse = class {
3541
3528
  maxInputs,
3542
3529
  gasCosts,
3543
3530
  maxGasPerTx,
3544
- gasPrice,
3545
- assetId
3531
+ gasPrice
3546
3532
  });
3547
3533
  return transactionSummary;
3548
3534
  }
@@ -3610,6 +3596,7 @@ var TransactionResponse = class {
3610
3596
  };
3611
3597
 
3612
3598
  // src/providers/utils/auto-retry-fetch.ts
3599
+ import { sleep } from "@fuel-ts/utils";
3613
3600
  function getWaitDelay(options, retryAttemptNum) {
3614
3601
  const duration = options.baseDelay ?? 150;
3615
3602
  switch (options.backoff) {
@@ -8576,7 +8563,7 @@ var generateTestWallet = async (provider, quantities) => {
8576
8563
  // src/test-utils/launchNode.ts
8577
8564
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
8578
8565
  import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
8579
- import { defaultSnapshotConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8566
+ import { defaultConsensusKey, hexlify as hexlify18, defaultSnapshotConfigs } from "@fuel-ts/utils";
8580
8567
  import { spawn } from "child_process";
8581
8568
  import { randomUUID } from "crypto";
8582
8569
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
@@ -8615,6 +8602,40 @@ var killNode = (params) => {
8615
8602
  }
8616
8603
  }
8617
8604
  };
8605
+ function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
8606
+ const defaultCoins = defaultSnapshotConfigs.stateConfig.coins.map((coin) => ({
8607
+ ...coin,
8608
+ amount: "18446744073709551615"
8609
+ }));
8610
+ const defaultMessages = defaultSnapshotConfigs.stateConfig.messages.map((message) => ({
8611
+ ...message,
8612
+ amount: "18446744073709551615"
8613
+ }));
8614
+ 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);
8615
+ 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);
8616
+ if (!process.env.GENESIS_SECRET) {
8617
+ const pk = Signer.generatePrivateKey();
8618
+ const signer = new Signer(pk);
8619
+ process.env.GENESIS_SECRET = hexlify18(pk);
8620
+ coins.push({
8621
+ tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
8622
+ owner: signer.address.toHexString(),
8623
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8624
+ amount: "18446744073709551615",
8625
+ asset_id: chainConfig.consensus_parameters.V1.base_asset_id,
8626
+ output_index: 0,
8627
+ tx_pointer_block_height: 0,
8628
+ tx_pointer_tx_idx: 0
8629
+ });
8630
+ }
8631
+ const json = JSON.stringify({
8632
+ ...stateConfig,
8633
+ coins,
8634
+ messages
8635
+ });
8636
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8637
+ return json.replace(regexMakeNumber, "$1$2");
8638
+ }
8618
8639
  var launchNode = async ({
8619
8640
  ip,
8620
8641
  port,
@@ -8622,7 +8643,8 @@ var launchNode = async ({
8622
8643
  fuelCorePath = process.env.FUEL_CORE_PATH ?? void 0,
8623
8644
  loggingEnabled = true,
8624
8645
  debugEnabled = false,
8625
- basePath
8646
+ basePath,
8647
+ snapshotConfig = defaultSnapshotConfigs
8626
8648
  }) => (
8627
8649
  // eslint-disable-next-line no-async-promise-executor
8628
8650
  new Promise(async (resolve, reject) => {
@@ -8650,56 +8672,23 @@ var launchNode = async ({
8650
8672
  let snapshotDirToUse;
8651
8673
  const prefix = basePath || os.tmpdir();
8652
8674
  const suffix = basePath ? "" : randomUUID();
8653
- const tempDirPath = path.join(prefix, ".fuels", suffix, "snapshotDir");
8675
+ const tempDir = path.join(prefix, ".fuels", suffix, "snapshotDir");
8654
8676
  if (snapshotDir) {
8655
8677
  snapshotDirToUse = snapshotDir;
8656
8678
  } else {
8657
- if (!existsSync(tempDirPath)) {
8658
- mkdirSync(tempDirPath, { recursive: true });
8659
- }
8660
- let { stateConfigJson } = defaultSnapshotConfigs;
8661
- const { chainConfigJson, metadataJson } = defaultSnapshotConfigs;
8662
- stateConfigJson = {
8663
- ...stateConfigJson,
8664
- coins: [
8665
- ...stateConfigJson.coins.map((coin) => ({
8666
- ...coin,
8667
- amount: "18446744073709551615"
8668
- }))
8669
- ],
8670
- messages: stateConfigJson.messages.map((message) => ({
8671
- ...message,
8672
- amount: "18446744073709551615"
8673
- }))
8674
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8675
- };
8676
- if (!process.env.GENESIS_SECRET) {
8677
- const pk = Signer.generatePrivateKey();
8678
- const signer = new Signer(pk);
8679
- process.env.GENESIS_SECRET = hexlify18(pk);
8680
- stateConfigJson.coins.push({
8681
- tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
8682
- owner: signer.address.toHexString(),
8683
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8684
- amount: "18446744073709551615",
8685
- asset_id: chainConfigJson.consensus_parameters.V1.base_asset_id,
8686
- output_index: 0,
8687
- tx_pointer_block_height: 0,
8688
- tx_pointer_tx_idx: 0
8689
- });
8679
+ if (!existsSync(tempDir)) {
8680
+ mkdirSync(tempDir, { recursive: true });
8690
8681
  }
8691
- let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8692
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8693
- fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8694
- const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
8695
- const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
8696
- const metadataWritePath = path.join(tempDirPath, "metadata.json");
8697
- const stateTransitionWritePath = path.join(tempDirPath, "state_transition_bytecode.wasm");
8698
- writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8699
- writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8700
- writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8701
- writeFileSync(stateTransitionWritePath, JSON.stringify(""));
8702
- snapshotDirToUse = tempDirPath;
8682
+ const { metadata } = snapshotConfig;
8683
+ const metadataPath = path.join(tempDir, "metadata.json");
8684
+ const chainConfigPath = path.join(tempDir, metadata.chain_config);
8685
+ const stateConfigPath = path.join(tempDir, metadata.table_encoding.Json.filepath);
8686
+ const stateTransitionPath = path.join(tempDir, "state_transition_bytecode.wasm");
8687
+ writeFileSync(chainConfigPath, JSON.stringify(snapshotConfig.chainConfig), "utf8");
8688
+ writeFileSync(stateConfigPath, getFinalStateConfigJSON(snapshotConfig), "utf8");
8689
+ writeFileSync(metadataPath, JSON.stringify(metadata), "utf8");
8690
+ writeFileSync(stateTransitionPath, JSON.stringify(""));
8691
+ snapshotDirToUse = tempDir;
8703
8692
  }
8704
8693
  const child = spawn(
8705
8694
  command,
@@ -8707,7 +8696,7 @@ var launchNode = async ({
8707
8696
  "run",
8708
8697
  ["--ip", ipToUse],
8709
8698
  ["--port", portToUse],
8710
- useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8699
+ useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDir],
8711
8700
  ["--min-gas-price", "1"],
8712
8701
  poaInstant ? ["--poa-instant", "true"] : [],
8713
8702
  ["--consensus-key", consensusKey],
@@ -8729,23 +8718,28 @@ var launchNode = async ({
8729
8718
  }
8730
8719
  const cleanupConfig = {
8731
8720
  child,
8732
- configPath: tempDirPath,
8721
+ configPath: tempDir,
8733
8722
  killFn: treeKill,
8734
8723
  state: {
8735
8724
  isDead: false
8736
8725
  }
8737
8726
  };
8738
8727
  child.stderr.on("data", (chunk) => {
8739
- if (chunk.indexOf(graphQLStartSubstring) !== -1) {
8728
+ const text = typeof chunk === "string" ? chunk : chunk.toString();
8729
+ if (text.indexOf(graphQLStartSubstring) !== -1) {
8730
+ const rows = text.split("\n");
8731
+ const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
8732
+ const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
8740
8733
  resolve({
8741
8734
  cleanup: () => killNode(cleanupConfig),
8742
- ip: ipToUse,
8743
- port: portToUse,
8735
+ ip: realIp,
8736
+ port: realPort,
8737
+ url: `http://${realIp}:${realPort}/v1/graphql`,
8744
8738
  snapshotDir: snapshotDirToUse
8745
8739
  });
8746
8740
  }
8747
- if (/error/i.test(chunk)) {
8748
- reject(chunk.toString());
8741
+ if (/error/i.test(text)) {
8742
+ reject(text.toString());
8749
8743
  }
8750
8744
  });
8751
8745
  process.on("exit", () => killNode(cleanupConfig));
@@ -8778,11 +8772,244 @@ var launchNodeAndGetWallets = async ({
8778
8772
  };
8779
8773
  return { wallets, stop: cleanup, provider };
8780
8774
  };
8775
+
8776
+ // src/test-utils/setup-test-provider-and-wallets.ts
8777
+ import { defaultSnapshotConfigs as defaultSnapshotConfigs3 } from "@fuel-ts/utils";
8778
+ import { mergeDeepRight } from "ramda";
8779
+
8780
+ // src/test-utils/asset-id.ts
8781
+ import { randomBytes as randomBytes7 } from "@fuel-ts/crypto";
8782
+ import { hexlify as hexlify19 } from "@fuel-ts/utils";
8783
+ var _AssetId = class {
8784
+ constructor(value) {
8785
+ this.value = value;
8786
+ }
8787
+ static random(count = 1) {
8788
+ const assetIds = [];
8789
+ for (let i = 0; i < count; i++) {
8790
+ assetIds.push(new _AssetId(hexlify19(randomBytes7(32))));
8791
+ }
8792
+ return assetIds;
8793
+ }
8794
+ };
8795
+ var AssetId = _AssetId;
8796
+ __publicField(AssetId, "A", new _AssetId(
8797
+ "0x0101010101010101010101010101010101010101010101010101010101010101"
8798
+ ));
8799
+ __publicField(AssetId, "B", new _AssetId(
8800
+ "0x0202020202020202020202020202020202020202020202020202020202020202"
8801
+ ));
8802
+
8803
+ // src/test-utils/wallet-config.ts
8804
+ import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
8805
+ import { FuelError as FuelError20 } from "@fuel-ts/errors";
8806
+ import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify20 } from "@fuel-ts/utils";
8807
+ var WalletConfig = class {
8808
+ initialState;
8809
+ options;
8810
+ wallets;
8811
+ generateWallets = () => {
8812
+ const generatedWallets = [];
8813
+ for (let index = 1; index <= this.options.count; index++) {
8814
+ generatedWallets.push(new WalletUnlocked(randomBytes8(32)));
8815
+ }
8816
+ return generatedWallets;
8817
+ };
8818
+ constructor(baseAssetId, config) {
8819
+ WalletConfig.validate(config);
8820
+ this.options = config;
8821
+ const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
8822
+ this.wallets = this.generateWallets();
8823
+ this.initialState = {
8824
+ messages: WalletConfig.createMessages(this.wallets, messages),
8825
+ coins: WalletConfig.createCoins(
8826
+ this.wallets,
8827
+ baseAssetId,
8828
+ assets2,
8829
+ coinsPerAsset,
8830
+ amountPerCoin
8831
+ )
8832
+ };
8833
+ }
8834
+ apply(snapshotConfig) {
8835
+ return {
8836
+ ...snapshotConfig,
8837
+ stateConfig: {
8838
+ ...snapshotConfig?.stateConfig ?? defaultSnapshotConfigs2.stateConfig,
8839
+ coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
8840
+ messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
8841
+ }
8842
+ };
8843
+ }
8844
+ /**
8845
+ * Create messages for the wallets in the format that the chain expects.
8846
+ */
8847
+ static createMessages(wallets, messages) {
8848
+ return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
8849
+ }
8850
+ /**
8851
+ * Create coins for the wallets in the format that the chain expects.
8852
+ */
8853
+ static createCoins(wallets, baseAssetId, assets2, coinsPerAsset, amountPerCoin) {
8854
+ const coins = [];
8855
+ let assetIds = [baseAssetId];
8856
+ if (Array.isArray(assets2)) {
8857
+ assetIds = assetIds.concat(assets2.map((a) => a.value));
8858
+ } else {
8859
+ assetIds = assetIds.concat(AssetId.random(assets2 - 1).map((a) => a.value));
8860
+ }
8861
+ wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
8862
+ assetIds.forEach((assetId) => {
8863
+ for (let index = 0; index < coinsPerAsset; index++) {
8864
+ coins.push({
8865
+ amount: amountPerCoin,
8866
+ asset_id: assetId,
8867
+ owner: walletAddress,
8868
+ tx_pointer_block_height: 0,
8869
+ tx_pointer_tx_idx: 0,
8870
+ output_index: 0,
8871
+ tx_id: hexlify20(randomBytes8(32))
8872
+ });
8873
+ }
8874
+ });
8875
+ });
8876
+ return coins;
8877
+ }
8878
+ static validate({
8879
+ count: wallets,
8880
+ assets: assets2,
8881
+ coinsPerAsset,
8882
+ amountPerCoin
8883
+ }) {
8884
+ if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
8885
+ throw new FuelError20(
8886
+ FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8887
+ "Number of wallets must be greater than zero."
8888
+ );
8889
+ }
8890
+ if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
8891
+ throw new FuelError20(
8892
+ FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8893
+ "Number of assets per wallet must be greater than zero."
8894
+ );
8895
+ }
8896
+ if (coinsPerAsset <= 0) {
8897
+ throw new FuelError20(
8898
+ FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8899
+ "Number of coins per asset must be greater than zero."
8900
+ );
8901
+ }
8902
+ if (amountPerCoin <= 0) {
8903
+ throw new FuelError20(
8904
+ FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8905
+ "Amount per coin must be greater than zero."
8906
+ );
8907
+ }
8908
+ }
8909
+ };
8910
+
8911
+ // src/test-utils/setup-test-provider-and-wallets.ts
8912
+ var defaultWalletConfigOptions = {
8913
+ count: 2,
8914
+ assets: [AssetId.A, AssetId.B],
8915
+ coinsPerAsset: 1,
8916
+ amountPerCoin: 1e10,
8917
+ messages: []
8918
+ };
8919
+ async function setupTestProviderAndWallets({
8920
+ walletConfig: walletConfigOptions = {},
8921
+ providerOptions,
8922
+ nodeOptions = {}
8923
+ } = {}) {
8924
+ Symbol.dispose ??= Symbol("Symbol.dispose");
8925
+ const walletConfig = new WalletConfig(
8926
+ nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ?? defaultSnapshotConfigs3.chainConfig.consensus_parameters.V1.base_asset_id,
8927
+ {
8928
+ ...defaultWalletConfigOptions,
8929
+ ...walletConfigOptions
8930
+ }
8931
+ );
8932
+ const { cleanup, url } = await launchNode({
8933
+ loggingEnabled: false,
8934
+ ...nodeOptions,
8935
+ snapshotConfig: mergeDeepRight(
8936
+ defaultSnapshotConfigs3,
8937
+ walletConfig.apply(nodeOptions?.snapshotConfig)
8938
+ ),
8939
+ port: "0"
8940
+ });
8941
+ let provider;
8942
+ try {
8943
+ provider = await Provider.create(url, providerOptions);
8944
+ } catch (err) {
8945
+ cleanup();
8946
+ throw err;
8947
+ }
8948
+ const wallets = walletConfig.wallets;
8949
+ wallets.forEach((wallet) => {
8950
+ wallet.connect(provider);
8951
+ });
8952
+ return {
8953
+ provider,
8954
+ wallets,
8955
+ cleanup,
8956
+ [Symbol.dispose]: cleanup
8957
+ };
8958
+ }
8959
+
8960
+ // src/test-utils/test-message.ts
8961
+ import { Address as Address6 } from "@fuel-ts/address";
8962
+ import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
8963
+ import { bn as bn21 } from "@fuel-ts/math";
8964
+ import { hexlify as hexlify21 } from "@fuel-ts/utils";
8965
+ var TestMessage = class {
8966
+ sender;
8967
+ recipient;
8968
+ nonce;
8969
+ amount;
8970
+ data;
8971
+ da_height;
8972
+ /**
8973
+ * A helper class to create messages for testing purposes.
8974
+ *
8975
+ * Used in tandem with `WalletConfig`.
8976
+ * It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
8977
+ */
8978
+ constructor({
8979
+ sender = Address6.fromRandom(),
8980
+ recipient = Address6.fromRandom(),
8981
+ nonce = hexlify21(randomBytes9(32)),
8982
+ amount = 1e6,
8983
+ data = "02",
8984
+ da_height = 0
8985
+ } = {}) {
8986
+ this.sender = sender;
8987
+ this.recipient = recipient;
8988
+ this.nonce = nonce;
8989
+ this.amount = amount;
8990
+ this.data = data;
8991
+ this.da_height = da_height;
8992
+ }
8993
+ toChainMessage(recipient) {
8994
+ return {
8995
+ sender: this.sender.toB256(),
8996
+ recipient: recipient?.toB256() ?? this.recipient.toB256(),
8997
+ nonce: this.nonce,
8998
+ amount: bn21(this.amount).toNumber(),
8999
+ data: this.data,
9000
+ da_height: this.da_height
9001
+ };
9002
+ }
9003
+ };
8781
9004
  export {
9005
+ AssetId,
9006
+ TestMessage,
9007
+ WalletConfig,
8782
9008
  generateTestWallet,
8783
9009
  killNode,
8784
9010
  launchNode,
8785
9011
  launchNodeAndGetWallets,
8786
- seedTestWallet
9012
+ seedTestWallet,
9013
+ setupTestProviderAndWallets
8787
9014
  };
8788
9015
  //# sourceMappingURL=test-utils.mjs.map