blockset-corp / walletkit

MIT License
80 stars 47 forks source link

Wrong wallet manager state after `system.pause()`/`system.resume()` #362

Open mindhacker42 opened 3 years ago

mindhacker42 commented 3 years ago

The first time I create System, create wallet managers and connect them, I get all the relevant events for wallets and walletManager.state gets to CONNECTED state. I imagine that's how I know that syncing has finished.

In our app we don't want to sync wallet managers all the time in the background, I noticed that WalletManagerBlockUpdatedEvent event gets called a lot so I assume that wallet managers get updated in the background still. That is why when user leaves the screen we call system.pause() and when he returns we call system.resume(). The problem is that after these 2 calls walletManager.state is SYNCING all the time. No WalletManagerSync*Event are even called, just WalletManagerChangedEvent and then WalletManagerBlockUpdatedEvent events.

It seems like this is a bug in the library, but it might be just my lack of understanding of the library. I am working with master version 513c0ee1b8a01d07018bc164f938289213e15daf.

Reproductions steps:

  1. Create system, create and connect wallet managers. Wallet managers go to CONNECTED state. Syncing is finished.
  2. Navigate offscreen and call system.pause().
  3. Navigate to WalletKit screen and call system.resume.
  4. Wallet managers go to SYNCING state and stay in this state.
mindhacker42 commented 3 years ago

@DrewCarlson or @EBGToo could you help with that? If it would help, I could also create a sample app with reproduced issue.

mindhacker42 commented 3 years ago

I found a workaround for this bug. If you call system.resume() 2x in a row or actually just connect wallet managers 2x in a row then wallet managers go correctly to CONNECTED state.