terra-money / wallet-kit

new version of wallet-provider
7 stars 9 forks source link

Avoid non-initializing wallets #26

Open Kayanski opened 10 months ago

Kayanski commented 10 months ago

This PR aims at avoiding initialization errors caused by wallets.

Rationale

On a webpage that was already connected to a wallet (if __wallet_kit_connected_wallet is set in localstorage), when refreshing the page, the connection to this wallet is triggered on page startup. However, if anything in this startup fails, wallet-kit stays in INITIALIZED mode and the loading of any other wallet won't work.

Proposed solution

If an error is thrown during wallet startup or info query on initial wallet connection, the wallet is not connected but the WalletProvider startup is not interrupted and can continue. This allows errors during first initialization (for instance if the wallet password is not indicated correctly)

Current Use case where it's needed

I implemented a local wallet for my Webapp (for easier on-boarding). Once my user is connected, if they fail to give their password (for instance if it's forgotten), the webpage won't be able to connect any wallet anymore. They are facing a blocked state due to wallet-kit not being able to initialize correctly.