Concordium / concordium-dapp-libraries

A coherent set of building blocks for making it as easy as possible for developers to build web-based dApps.
Apache License 2.0
7 stars 5 forks source link

wallet-connectors: Improve 'getConnections' #18

Closed bisgardo closed 1 year ago

bisgardo commented 1 year ago

Purpose

Ensure that BrowserWallet.getConnections only returns a connection if the user has asked for it to be "connected".

Changes

Add a field to BrowserWallet to indicate whether the connection is "established". Using the presence of an account like before is not enough as the account could be available on a fresh page load. But as the delegate's onConnected method isn't called until connect is called. This means that the account would be missing in any state maintained by the delegate.

This solution also allows the connection to be marked as disconnected later on.

As no implementations of getConnections are really asynchronous anymore, we also change the interface method to non-async. This makes sense as connectors really should be able to know about their connections directly.