apibara / starknet-react

A collection of React providers and hooks for StarkNet
https://starknet-react.com
MIT License
369 stars 147 forks source link

Expose useStarknet from the context #401

Closed WiseMrMusa closed 9 months ago

WiseMrMusa commented 9 months ago

Expose useStarknet from the context so there will be an API to get the configuration used for the starknet app

The cupported chains and connectors can easily be got from this

If it's approved, I can work on it. it's just a little change

fracek commented 9 months ago

That hook is supposed to be internal and subject to change. What information do you need that's not available by other hooks?

WiseMrMusa commented 9 months ago

I need to get the chains and connectors configured by the user

The API is exposed by wagmi with WagmiContext and I can also use it to validate that a component is wrapped inside the StarknetProvider

even the useStarknet (it's consumed version) that gives some contexts information too is not exposed and the two APIs are exposed in wagmi which is used in designing wallet connectors

fracek commented 9 months ago

Wagmi can expose it because they have wagmi core that abstract everything away, but starknet react doesn't.

You can get configured chains with useNetwork. For connectors: all available connectors are available in useConnect. Do you need the configured connectors (e.g. connectors configured by the dapp but maybe not available).

WiseMrMusa commented 9 months ago

alright then. Thanks

fracek commented 9 months ago

If you find you need user provided connectors (not just detected connectors) feel free to reopen (describing the use case) and i think we can add a hook just for that.