feat: export react context, return wallet session on wallet connect and break circular deps #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR does a couple of things:
SolanaClientContextfor external use casesWalletSessionobject after a connector connects.Why was it implemented this way?
Exporting
SolanaClientContextWe needed this in a widget use case. The widget has it's internal wallet management. However, we want our partners to be able bring their own wallet management solution and the widget to use the external wallet management when available.
We do this by checking if there is an existing
SolanaClientContextin the tree, and reusing it if there is, else, we create a new context.Returning the
WalletSessionafter connectionAlthough there is a
useSessionhook to fetch when the session. In our use case, we have a synchronous flow where onConnect, we show the user he a connecting modal and after connection, our internal state is updated, and the we close the modal. Doing this with the hook would work but would not be a linear flow.Break circular dependencies in the repo.
After making the above updates, I discovered there were circular dependencies in the repo.
src/types.tsfiles into smallertypes.tsfiles for each module / folder.madgeto the devDependencies to help check for circular dependencies.