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

DAppKitProvider with custom nodeUrl does not detect genesis id #235

Open
ifavo opened this issue Apr 15, 2024 · 2 comments
Open

DAppKitProvider with custom nodeUrl does not detect genesis id #235

ifavo opened this issue Apr 15, 2024 · 2 comments

Comments

@ifavo
Copy link

ifavo commented Apr 15, 2024

When setting up a DAppKitProvider with react using only the nodeUrl, it will switch VeWorld to MainNet.

Example:

<DAppKitProvider
    // the network & node to connect to
    nodeUrl="https://testnet.vechain.org"
    // remember last connected address on page reload
    usePersistence={true}
>
    {children}
</DAppKitProvider>
  • Creating a transaction request within the providers context using the thor client from useConnex() will automatically switch to MainNet.
  • When the genesis is explicitly defined genesis="test", it will switch to TestNet.

My personal expected behavior is that it will automatically detect the network/genesis and use it, according to the nodeUrl.

If this is correct behavior, may I suggest to either detect the genesis id automatically using the given nodeUrl or make the genesis mandatory, to prevent confusion during setup?

@darrenvechain
Copy link
Member

If we were able to initiate connex without the genesis block this wouldn't be a problem, as we could then (async) fetch the genesis block prior to making the wallet interaction.

Automatically detecting the network could also have a potential problem. Its an async action, as we have to fetch the genesis block. If the dapp were to automatically request a wallet interaction on page load (weird use case, but possible), that could potentially request the action before the network is detected.

One approach could be to fetch the genesis inside the DAppKitProvider and don't return the child components until we have the genesis, but this could lead to lead to a bad UX if the API call fails.

@ifavo
Copy link
Author

ifavo commented Apr 15, 2024

I understand the impact on the UI, I would not want to delay a render, while a re-render might be acceptable.

In my scenario a transaction is built, which is where I am willing to pay for an additional network request before its requested for signing in the wallet.

Is the genesis id needed in other situations where a network request is not possible to lazily detect the id?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants