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

Cannot select and connect in one function #45

Open
the-fool opened this issue Sep 29, 2022 · 3 comments
Open

Cannot select and connect in one function #45

the-fool opened this issue Sep 29, 2022 · 3 comments

Comments

@the-fool
Copy link

The new wallet adapter does not allow .select(NAME) and .connect() in one function call.

It throws a WalletNotSelectedError.

https://socket.dev/npm/package/@manahippo/aptos-wallet-adapter/files/0.4.2/src/WalletProviders/WalletProvider.tsx#L212

wallet.select(NAME)
wallet.connect() // throws

I think the issue is that .select() uses setName from a useState hook, and this state update does not happen synchronously. The only way I can get this to work is by breaking up the flow into 2 separate React updates.

@tom-hippo
Copy link
Contributor

@gnocchi6
Copy link
Contributor

gnocchi6 commented Oct 1, 2022

I seem to be getting this in the wallet-nextjs example. Does the example need to be updated?

@the-fool
Copy link
Author

the-fool commented Oct 4, 2022

If I'm reading this right, it looks lke we need to force another turn of the event-loop after the wallet gets selected:

}, [autoConnect, currentWallet, connect]);

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

3 participants