Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeModules: Unable to import ‘generateTestWallet’ #2617

Closed
goheesheng opened this issue Jun 25, 2024 · 3 comments
Closed

NodeModules: Unable to import ‘generateTestWallet’ #2617

goheesheng opened this issue Jun 25, 2024 · 3 comments
Assignees
Labels
awaiting We need further input from the author bug Issue is a bug stale Issue is now stale

Comments

@goheesheng
Copy link

goheesheng commented Jun 25, 2024

What version of fuels-ts are you using?

^0.89.2

Steps to Reproduce

Hi, is there an update going on? Not sure why it doesn't work and the documentation page is down https://docs.fuel.network/docs/fuels-ts/wallets/test-wallets/#setting-up-test-wallets

This is the code and I am running the local fuel node.

import { NODE_URL } from "../../lib";
import { Provider, Wallet, WalletUnlocked, Signer, CoinQuantity,  } from "fuels";
import { generateTestWallet } from '@fuel-ts/account/test-utils';
import { useState } from "react";
import useAsync from "react-use/lib/useAsync";
export const useFaucet = () => {
  const [faucetWallet, setFaucetWallet] = useState<WalletUnlocked>();

  useAsync(async () => {
    if (!faucetWallet) {
      const provider = await Provider.create(NODE_URL);
      const baseAssetId = provider.getBaseAssetId();
      const myWallet: WalletUnlocked = await generateTestWallet(provider, [[10, baseAssetId]]);
      const signer = new Signer("0x01");
      const balances: CoinQuantity[] = await myWallet.getBalances();
      console.log('Local Provider address', signer)
      console.log('Local Provider Balances', balances)

      setFaucetWallet(myWallet);
    }
  }, [faucetWallet]);

  return {
    faucetWallet,
  };
};

This is the forum post: https://forum.fuel.network/t/nodemodules-unable-to-import-generatetestwallet/5859

Expected Behavior

Able to use generateTestWallet and create a test wallet variable

Actual Behavior

Error:

 Property '#private' in type 'Provider' refers to a different member that cannot be accessed from within type 'Provider'.ts(2345)
@goheesheng goheesheng added the bug Issue is a bug label Jun 25, 2024
@maschad maschad added the triage Issue needs to be triaged label Jun 25, 2024
@maschad maschad self-assigned this Jun 25, 2024
@maschad
Copy link
Member

maschad commented Jun 26, 2024

Hey @goheesheng thanks for raising this issue.

I'm sorry for the inconvenience caused here, we removed that documentation in release 0.90.0 but I think was an error on our part. So we should re-introduce it.

That being said, we use the generateTestWallet utility for test suites in node. If you would like to generate a test wallet in the browser I would recommend that you use the Wallet.generate method. e.g.

 	const provider = await Provider.create(NODE_URL);
    wallet = Wallet.generate({ provider });

    localStorage.setItem('my-wallet-pk', wallet.privateKey);

For more information, you can read here

I was able to reproduce the issue you are facing locally, the error you're encountering is due to a version mismatch between the Provider types from different versions of the @fuel-ts/account package i.e. you're using fuels@0.89.2 and @fuel-ts/account@0.90.0 ( since there was previously this issue in @fuel-ts/account@0.89.2) .

Regardless your setup is correct if you are testing in node, you can find a code snippet here

Please let me know if this resolves your issue.

@maschad maschad added the awaiting We need further input from the author label Jun 26, 2024
Copy link
Contributor

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

@github-actions github-actions bot added the stale Issue is now stale label Jul 16, 2024
@arboleya arboleya changed the title NodeModules:Unable to import ‘generateTestWallet’ NodeModules: Unable to import ‘generateTestWallet’ Jul 19, 2024
@github-actions github-actions bot removed the stale Issue is now stale label Jul 20, 2024
@maschad maschad added the stale Issue is now stale label Jul 22, 2024
Copy link
Contributor

This issue was closed because it is missing author input.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2024
@arboleya arboleya removed the triage Issue needs to be triaged label Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting We need further input from the author bug Issue is a bug stale Issue is now stale
Projects
None yet
Development

No branches or pull requests

3 participants