@fuel-ts/account 0.0.0-rc-1356-20240520180710 → 0.0.0-rc-2333-20240520180734

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.

@@ -1647,6 +1647,15 @@ 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
+
1650
1659
  // src/providers/utils/extract-tx-error.ts
1651
1660
  import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
1652
1661
  import { bn as bn6 } from "@fuel-ts/math";
@@ -3595,7 +3604,6 @@ var TransactionResponse = class {
3595
3604
  };
3596
3605
 
3597
3606
  // src/providers/utils/auto-retry-fetch.ts
3598
- import { sleep } from "@fuel-ts/utils";
3599
3607
  function getWaitDelay(options, retryAttemptNum) {
3600
3608
  const duration = options.baseDelay ?? 150;
3601
3609
  switch (options.backoff) {
@@ -5171,19 +5179,8 @@ var Account = class extends AbstractAccount {
5171
5179
  */
5172
5180
  async createTransfer(destination, amount, assetId, txParams = {}) {
5173
5181
  let request = new ScriptTransactionRequest(txParams);
5174
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5175
- request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
5176
- const txCost = await this.provider.getTransactionCost(request, {
5177
- estimateTxDependencies: true,
5178
- resourcesOwner: this
5179
- });
5180
- request = this.validateGasLimitAndMaxFee({
5181
- transactionRequest: request,
5182
- gasUsed: txCost.gasUsed,
5183
- maxFee: txCost.maxFee,
5184
- txParams
5185
- });
5186
- await this.fund(request, txCost);
5182
+ request = this.addTransfer(request, { destination, amount, assetId });
5183
+ request = await this.estimateAndFundTransaction(request, txParams);
5187
5184
  return request;
5188
5185
  }
5189
5186
  /**
@@ -5196,16 +5193,57 @@ var Account = class extends AbstractAccount {
5196
5193
  * @returns A promise that resolves to the transaction response.
5197
5194
  */
5198
5195
  async transfer(destination, amount, assetId, txParams = {}) {
5199
- if (bn19(amount).lte(0)) {
5200
- throw new FuelError15(
5201
- ErrorCode15.INVALID_TRANSFER_AMOUNT,
5202
- "Transfer amount must be a positive number."
5203
- );
5204
- }
5205
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5206
- const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
5196
+ const request = await this.createTransfer(destination, amount, assetId, txParams);
5197
+ return this.sendTransaction(request, { estimateTxDependencies: false });
5198
+ }
5199
+ /**
5200
+ * Transfers multiple amounts of a token to multiple recipients.
5201
+ *
5202
+ * @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
5203
+ * @param txParams - Optional transaction parameters.
5204
+ * @returns A promise that resolves to a `TransactionResponse` object representing the transaction result.
5205
+ */
5206
+ async batchTransfer(transferParams, txParams = {}) {
5207
+ let request = new ScriptTransactionRequest(txParams);
5208
+ request = this.addBatchTransfer(request, transferParams);
5209
+ request = await this.estimateAndFundTransaction(request, txParams);
5207
5210
  return this.sendTransaction(request, { estimateTxDependencies: false });
5208
5211
  }
5212
+ /**
5213
+ * Adds a transfer to the given transaction request.
5214
+ *
5215
+ * @param request - The script transaction request to add transfers to.
5216
+ * @param transferParams - The object representing the transfer to be made.
5217
+ * @returns The updated transaction request with the added transfer.
5218
+ */
5219
+ addTransfer(request, transferParams) {
5220
+ const { destination, amount, assetId } = transferParams;
5221
+ this.validateTransferAmount(amount);
5222
+ request.addCoinOutput(
5223
+ Address3.fromAddressOrString(destination),
5224
+ amount,
5225
+ assetId ?? this.provider.getBaseAssetId()
5226
+ );
5227
+ return request;
5228
+ }
5229
+ /**
5230
+ * Adds multiple transfers to a script transaction request.
5231
+ *
5232
+ * @param request - The script transaction request to add transfers to.
5233
+ * @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
5234
+ * @returns The updated script transaction request.
5235
+ */
5236
+ addBatchTransfer(request, transferParams) {
5237
+ const baseAssetId = this.provider.getBaseAssetId();
5238
+ transferParams.forEach(({ destination, amount, assetId }) => {
5239
+ this.addTransfer(request, {
5240
+ destination,
5241
+ amount,
5242
+ assetId: assetId ?? baseAssetId
5243
+ });
5244
+ });
5245
+ return request;
5246
+ }
5209
5247
  /**
5210
5248
  * Transfers coins to a contract address.
5211
5249
  *
@@ -5283,6 +5321,7 @@ var Account = class extends AbstractAccount {
5283
5321
  await this.fund(request, txCost);
5284
5322
  return this.sendTransaction(request);
5285
5323
  }
5324
+ /** @hidden * */
5286
5325
  async signMessage(message) {
5287
5326
  if (!this._connector) {
5288
5327
  throw new FuelError15(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
@@ -5338,6 +5377,31 @@ var Account = class extends AbstractAccount {
5338
5377
  }
5339
5378
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
5340
5379
  }
5380
+ /** @hidden * */
5381
+ validateTransferAmount(amount) {
5382
+ if (bn19(amount).lte(0)) {
5383
+ throw new FuelError15(
5384
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
5385
+ "Transfer amount must be a positive number."
5386
+ );
5387
+ }
5388
+ }
5389
+ /** @hidden * */
5390
+ async estimateAndFundTransaction(transactionRequest, txParams) {
5391
+ let request = transactionRequest;
5392
+ const txCost = await this.provider.getTransactionCost(request, {
5393
+ resourcesOwner: this
5394
+ });
5395
+ request = this.validateGasLimitAndMaxFee({
5396
+ transactionRequest: request,
5397
+ gasUsed: txCost.gasUsed,
5398
+ maxFee: txCost.maxFee,
5399
+ txParams
5400
+ });
5401
+ request = await this.fund(request, txCost);
5402
+ return request;
5403
+ }
5404
+ /** @hidden * */
5341
5405
  validateGasLimitAndMaxFee({
5342
5406
  gasUsed,
5343
5407
  maxFee,
@@ -8418,7 +8482,7 @@ var generateTestWallet = async (provider, quantities) => {
8418
8482
  // src/test-utils/launchNode.ts
8419
8483
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
8420
8484
  import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
8421
- import { defaultConsensusKey, hexlify as hexlify18, defaultSnapshotConfigs } from "@fuel-ts/utils";
8485
+ import { defaultSnapshotConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
8422
8486
  import { findBinPath } from "@fuel-ts/utils/cli-utils";
8423
8487
  import { spawn } from "child_process";
8424
8488
  import { randomUUID } from "crypto";
@@ -8458,40 +8522,6 @@ var killNode = (params) => {
8458
8522
  }
8459
8523
  }
8460
8524
  };
8461
- function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
8462
- const defaultCoins = defaultSnapshotConfigs.stateConfig.coins.map((coin) => ({
8463
- ...coin,
8464
- amount: "18446744073709551615"
8465
- }));
8466
- const defaultMessages = defaultSnapshotConfigs.stateConfig.messages.map((message) => ({
8467
- ...message,
8468
- amount: "18446744073709551615"
8469
- }));
8470
- 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);
8471
- 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);
8472
- if (!process.env.GENESIS_SECRET) {
8473
- const pk = Signer.generatePrivateKey();
8474
- const signer = new Signer(pk);
8475
- process.env.GENESIS_SECRET = hexlify18(pk);
8476
- coins.push({
8477
- tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
8478
- owner: signer.address.toHexString(),
8479
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8480
- amount: "18446744073709551615",
8481
- asset_id: chainConfig.consensus_parameters.V1.base_asset_id,
8482
- output_index: 0,
8483
- tx_pointer_block_height: 0,
8484
- tx_pointer_tx_idx: 0
8485
- });
8486
- }
8487
- const json = JSON.stringify({
8488
- ...stateConfig,
8489
- coins,
8490
- messages
8491
- });
8492
- const regexMakeNumber = /("amount":)"(\d+)"/gm;
8493
- return json.replace(regexMakeNumber, "$1$2");
8494
- }
8495
8525
  var launchNode = async ({
8496
8526
  ip,
8497
8527
  port,
@@ -8499,8 +8529,7 @@ var launchNode = async ({
8499
8529
  useSystemFuelCore = false,
8500
8530
  loggingEnabled = true,
8501
8531
  debugEnabled = false,
8502
- basePath,
8503
- snapshotConfig = defaultSnapshotConfigs
8532
+ basePath
8504
8533
  }) => (
8505
8534
  // eslint-disable-next-line no-async-promise-executor
8506
8535
  new Promise(async (resolve, reject) => {
@@ -8529,23 +8558,56 @@ var launchNode = async ({
8529
8558
  let snapshotDirToUse;
8530
8559
  const prefix = basePath || os.tmpdir();
8531
8560
  const suffix = basePath ? "" : randomUUID();
8532
- const tempDir = path.join(prefix, ".fuels", suffix, "snapshotDir");
8561
+ const tempDirPath = path.join(prefix, ".fuels", suffix, "snapshotDir");
8533
8562
  if (snapshotDir) {
8534
8563
  snapshotDirToUse = snapshotDir;
8535
8564
  } else {
8536
- if (!existsSync(tempDir)) {
8537
- mkdirSync(tempDir, { recursive: true });
8565
+ if (!existsSync(tempDirPath)) {
8566
+ mkdirSync(tempDirPath, { recursive: true });
8567
+ }
8568
+ let { stateConfigJson } = defaultSnapshotConfigs;
8569
+ const { chainConfigJson, metadataJson } = defaultSnapshotConfigs;
8570
+ stateConfigJson = {
8571
+ ...stateConfigJson,
8572
+ coins: [
8573
+ ...stateConfigJson.coins.map((coin) => ({
8574
+ ...coin,
8575
+ amount: "18446744073709551615"
8576
+ }))
8577
+ ],
8578
+ messages: stateConfigJson.messages.map((message) => ({
8579
+ ...message,
8580
+ amount: "18446744073709551615"
8581
+ }))
8582
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8583
+ };
8584
+ if (!process.env.GENESIS_SECRET) {
8585
+ const pk = Signer.generatePrivateKey();
8586
+ const signer = new Signer(pk);
8587
+ process.env.GENESIS_SECRET = hexlify18(pk);
8588
+ stateConfigJson.coins.push({
8589
+ tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
8590
+ owner: signer.address.toHexString(),
8591
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8592
+ amount: "18446744073709551615",
8593
+ asset_id: chainConfigJson.consensus_parameters.V1.base_asset_id,
8594
+ output_index: 0,
8595
+ tx_pointer_block_height: 0,
8596
+ tx_pointer_tx_idx: 0
8597
+ });
8538
8598
  }
8539
- const { metadata } = snapshotConfig;
8540
- const metadataPath = path.join(tempDir, "metadata.json");
8541
- const chainConfigPath = path.join(tempDir, metadata.chain_config);
8542
- const stateConfigPath = path.join(tempDir, metadata.table_encoding.Json.filepath);
8543
- const stateTransitionPath = path.join(tempDir, "state_transition_bytecode.wasm");
8544
- writeFileSync(chainConfigPath, JSON.stringify(snapshotConfig.chainConfig), "utf8");
8545
- writeFileSync(stateConfigPath, getFinalStateConfigJSON(snapshotConfig), "utf8");
8546
- writeFileSync(metadataPath, JSON.stringify(metadata), "utf8");
8547
- writeFileSync(stateTransitionPath, JSON.stringify(""));
8548
- snapshotDirToUse = tempDir;
8599
+ let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
8600
+ const regexMakeNumber = /("amount":)"(\d+)"/gm;
8601
+ fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
8602
+ const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
8603
+ const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
8604
+ const metadataWritePath = path.join(tempDirPath, "metadata.json");
8605
+ const stateTransitionWritePath = path.join(tempDirPath, "state_transition_bytecode.wasm");
8606
+ writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8607
+ writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8608
+ writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8609
+ writeFileSync(stateTransitionWritePath, JSON.stringify(""));
8610
+ snapshotDirToUse = tempDirPath;
8549
8611
  }
8550
8612
  const child = spawn(
8551
8613
  command,
@@ -8553,7 +8615,7 @@ var launchNode = async ({
8553
8615
  "run",
8554
8616
  ["--ip", ipToUse],
8555
8617
  ["--port", portToUse],
8556
- useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDir],
8618
+ useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
8557
8619
  ["--min-gas-price", "1"],
8558
8620
  poaInstant ? ["--poa-instant", "true"] : [],
8559
8621
  ["--consensus-key", consensusKey],
@@ -8575,28 +8637,23 @@ var launchNode = async ({
8575
8637
  }
8576
8638
  const cleanupConfig = {
8577
8639
  child,
8578
- configPath: tempDir,
8640
+ configPath: tempDirPath,
8579
8641
  killFn: treeKill,
8580
8642
  state: {
8581
8643
  isDead: false
8582
8644
  }
8583
8645
  };
8584
8646
  child.stderr.on("data", (chunk) => {
8585
- const text = typeof chunk === "string" ? chunk : chunk.toString();
8586
- if (text.indexOf(graphQLStartSubstring) !== -1) {
8587
- const rows = text.split("\n");
8588
- const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
8589
- const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
8647
+ if (chunk.indexOf(graphQLStartSubstring) !== -1) {
8590
8648
  resolve({
8591
8649
  cleanup: () => killNode(cleanupConfig),
8592
- ip: realIp,
8593
- port: realPort,
8594
- url: `http://${realIp}:${realPort}/v1/graphql`,
8650
+ ip: ipToUse,
8651
+ port: portToUse,
8595
8652
  snapshotDir: snapshotDirToUse
8596
8653
  });
8597
8654
  }
8598
- if (/error/i.test(text)) {
8599
- reject(text.toString());
8655
+ if (/error/i.test(chunk)) {
8656
+ reject(chunk.toString());
8600
8657
  }
8601
8658
  });
8602
8659
  process.on("exit", () => killNode(cleanupConfig));
@@ -8629,244 +8686,11 @@ var launchNodeAndGetWallets = async ({
8629
8686
  };
8630
8687
  return { wallets, stop: cleanup, provider };
8631
8688
  };
8632
-
8633
- // src/test-utils/setup-test-provider-and-wallets.ts
8634
- import { defaultSnapshotConfigs as defaultSnapshotConfigs3 } from "@fuel-ts/utils";
8635
- import { mergeDeepRight } from "ramda";
8636
-
8637
- // src/test-utils/asset-id.ts
8638
- import { randomBytes as randomBytes7 } from "@fuel-ts/crypto";
8639
- import { hexlify as hexlify19 } from "@fuel-ts/utils";
8640
- var _AssetId = class {
8641
- constructor(value) {
8642
- this.value = value;
8643
- }
8644
- static random(count = 1) {
8645
- const assetIds = [];
8646
- for (let i = 0; i < count; i++) {
8647
- assetIds.push(new _AssetId(hexlify19(randomBytes7(32))));
8648
- }
8649
- return assetIds;
8650
- }
8651
- };
8652
- var AssetId = _AssetId;
8653
- __publicField(AssetId, "A", new _AssetId(
8654
- "0x0101010101010101010101010101010101010101010101010101010101010101"
8655
- ));
8656
- __publicField(AssetId, "B", new _AssetId(
8657
- "0x0202020202020202020202020202020202020202020202020202020202020202"
8658
- ));
8659
-
8660
- // src/test-utils/wallet-config.ts
8661
- import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
8662
- import { FuelError as FuelError20 } from "@fuel-ts/errors";
8663
- import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify20 } from "@fuel-ts/utils";
8664
- var WalletConfig = class {
8665
- initialState;
8666
- options;
8667
- wallets;
8668
- generateWallets = () => {
8669
- const generatedWallets = [];
8670
- for (let index = 1; index <= this.options.count; index++) {
8671
- generatedWallets.push(new WalletUnlocked(randomBytes8(32)));
8672
- }
8673
- return generatedWallets;
8674
- };
8675
- constructor(baseAssetId, config) {
8676
- WalletConfig.validate(config);
8677
- this.options = config;
8678
- const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
8679
- this.wallets = this.generateWallets();
8680
- this.initialState = {
8681
- messages: WalletConfig.createMessages(this.wallets, messages),
8682
- coins: WalletConfig.createCoins(
8683
- this.wallets,
8684
- baseAssetId,
8685
- assets2,
8686
- coinsPerAsset,
8687
- amountPerCoin
8688
- )
8689
- };
8690
- }
8691
- apply(snapshotConfig) {
8692
- return {
8693
- ...snapshotConfig,
8694
- stateConfig: {
8695
- ...snapshotConfig?.stateConfig ?? defaultSnapshotConfigs2.stateConfig,
8696
- coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
8697
- messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
8698
- }
8699
- };
8700
- }
8701
- /**
8702
- * Create messages for the wallets in the format that the chain expects.
8703
- */
8704
- static createMessages(wallets, messages) {
8705
- return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
8706
- }
8707
- /**
8708
- * Create coins for the wallets in the format that the chain expects.
8709
- */
8710
- static createCoins(wallets, baseAssetId, assets2, coinsPerAsset, amountPerCoin) {
8711
- const coins = [];
8712
- let assetIds = [baseAssetId];
8713
- if (Array.isArray(assets2)) {
8714
- assetIds = assetIds.concat(assets2.map((a) => a.value));
8715
- } else {
8716
- assetIds.concat(AssetId.random(assets2).map((a) => a.value));
8717
- }
8718
- wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
8719
- assetIds.forEach((assetId) => {
8720
- for (let index = 0; index < coinsPerAsset; index++) {
8721
- coins.push({
8722
- amount: amountPerCoin,
8723
- asset_id: assetId,
8724
- owner: walletAddress,
8725
- tx_pointer_block_height: 0,
8726
- tx_pointer_tx_idx: 0,
8727
- output_index: 0,
8728
- tx_id: hexlify20(randomBytes8(32))
8729
- });
8730
- }
8731
- });
8732
- });
8733
- return coins;
8734
- }
8735
- static validate({
8736
- count: wallets,
8737
- assets: assets2,
8738
- coinsPerAsset,
8739
- amountPerCoin
8740
- }) {
8741
- if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
8742
- throw new FuelError20(
8743
- FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8744
- "Number of wallets must be greater than zero."
8745
- );
8746
- }
8747
- if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
8748
- throw new FuelError20(
8749
- FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8750
- "Number of assets per wallet must be greater than zero."
8751
- );
8752
- }
8753
- if (coinsPerAsset <= 0) {
8754
- throw new FuelError20(
8755
- FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8756
- "Number of coins per asset must be greater than zero."
8757
- );
8758
- }
8759
- if (amountPerCoin <= 0) {
8760
- throw new FuelError20(
8761
- FuelError20.CODES.INVALID_INPUT_PARAMETERS,
8762
- "Amount per coin must be greater than zero."
8763
- );
8764
- }
8765
- }
8766
- };
8767
-
8768
- // src/test-utils/setup-test-provider-and-wallets.ts
8769
- var defaultWalletConfigOptions = {
8770
- count: 2,
8771
- assets: [AssetId.A, AssetId.B],
8772
- coinsPerAsset: 1,
8773
- amountPerCoin: 1e10,
8774
- messages: []
8775
- };
8776
- async function setupTestProviderAndWallets({
8777
- walletConfig: walletConfigOptions = {},
8778
- providerOptions,
8779
- nodeOptions = {}
8780
- } = {}) {
8781
- Symbol.dispose ??= Symbol("Symbol.dispose");
8782
- const walletConfig = new WalletConfig(
8783
- nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ?? defaultSnapshotConfigs3.chainConfig.consensus_parameters.V1.base_asset_id,
8784
- {
8785
- ...defaultWalletConfigOptions,
8786
- ...walletConfigOptions
8787
- }
8788
- );
8789
- const { cleanup, url } = await launchNode({
8790
- loggingEnabled: false,
8791
- ...nodeOptions,
8792
- snapshotConfig: mergeDeepRight(
8793
- defaultSnapshotConfigs3,
8794
- walletConfig.apply(nodeOptions?.snapshotConfig)
8795
- ),
8796
- port: "0"
8797
- });
8798
- let provider;
8799
- try {
8800
- provider = await Provider.create(url, providerOptions);
8801
- } catch (err) {
8802
- cleanup();
8803
- throw err;
8804
- }
8805
- const wallets = walletConfig.wallets;
8806
- wallets.forEach((wallet) => {
8807
- wallet.connect(provider);
8808
- });
8809
- return {
8810
- provider,
8811
- wallets,
8812
- cleanup,
8813
- [Symbol.dispose]: cleanup
8814
- };
8815
- }
8816
-
8817
- // src/test-utils/test-message.ts
8818
- import { Address as Address6 } from "@fuel-ts/address";
8819
- import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
8820
- import { bn as bn21 } from "@fuel-ts/math";
8821
- import { hexlify as hexlify21 } from "@fuel-ts/utils";
8822
- var TestMessage = class {
8823
- sender;
8824
- recipient;
8825
- nonce;
8826
- amount;
8827
- data;
8828
- da_height;
8829
- /**
8830
- * A helper class to create messages for testing purposes.
8831
- *
8832
- * Used in tandem with `WalletConfig`.
8833
- * It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
8834
- */
8835
- constructor({
8836
- sender = Address6.fromRandom(),
8837
- recipient = Address6.fromRandom(),
8838
- nonce = hexlify21(randomBytes9(32)),
8839
- amount = 1e6,
8840
- data = "02",
8841
- da_height = 0
8842
- } = {}) {
8843
- this.sender = sender;
8844
- this.recipient = recipient;
8845
- this.nonce = nonce;
8846
- this.amount = amount;
8847
- this.data = data;
8848
- this.da_height = da_height;
8849
- }
8850
- toChainMessage(recipient) {
8851
- return {
8852
- sender: this.sender.toB256(),
8853
- recipient: recipient?.toB256() ?? this.recipient.toB256(),
8854
- nonce: this.nonce,
8855
- amount: bn21(this.amount).toNumber(),
8856
- data: this.data,
8857
- da_height: this.da_height
8858
- };
8859
- }
8860
- };
8861
8689
  export {
8862
- AssetId,
8863
- TestMessage,
8864
- WalletConfig,
8865
8690
  generateTestWallet,
8866
8691
  killNode,
8867
8692
  launchNode,
8868
8693
  launchNodeAndGetWallets,
8869
- seedTestWallet,
8870
- setupTestProviderAndWallets
8694
+ seedTestWallet
8871
8695
  };
8872
8696
  //# sourceMappingURL=test-utils.mjs.map