Initialize a standardized function to load data from storage and pass it to wallet context on app startup. Initialize a standardized function to update state (and localforage) when this data changes.
Implement with contactList localforage key.
We have too many getter and setter functions for the various keys. Should have one. All state and storage mgmt should be handled the same way.
This will make migration and updates to the storage schema easier. Will also make it easier to migrate the extension to use the extension storage API instead of indexedDb.
Arguably we should just store cashtabState itself as a key in localforage. Consideration for a later diff. However, hard to say this would optimize, and could complicate the validation / migration functions specific to each key.
Background
Existing functions that get and set data from localforage and wallet context have been added incrementally and diverge in quality and purpose. We should have consistent primitives here.
We only want to get items from localforage on Cashtab startup. We then set these items in state to be used by the app while the user has Cashtab open.
We periodically write to localforage as state items change to ensure they will be available to the user if the browser closes.