-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Wallet] Change redux storage implementation to file system (#6273)
### Description AsyncStorage has a 6MB limit on Android. It can be modified, and we should not even be close to 6MB, but when the limit is reached the whole storage is deleted, no backup is used. Given the risk of losing the whole state even if it's unlikely we're changing the implementation to use the file system which has no such limitation. Also added 2 analytics events: - One which uploads every app open or once a day (if it's kept in background) the size of the redux store - One which represents an error in the case that there's no account stored on the redux store but there is one on the geth keychain. ### Other changes - On one of my tests, I noticed that the size of the Redux store was getting bigger and bigger. Upon closer inspection, it was the history we use for the CELO/cUSD exchange rate that was growing at a rate of ~100kb sometimes when restarting the app. It was not consistent, it happened for around an hour and then completely stopped happening and couldn't reproduce it anymore. In the time where it was happening I managed to see that the starting time to fetch the rates was being sent as a month ago, which is the default. It sounds like some race condition, but we're already waiting for the store to be populated before starting the sagas, so it's unlikely to be that. I changed the implementation to use the value of `lastTimeUpdated`, which is a value that we were storing but not using. Not completely sure this will fix the issue, but it is definitely possible that this was causing the resetting of the accounts that we saw. We'll be able to confirm if this is the issue with the analytics event that uploads the size of the store. - When testing the case where the redux store doesn't match the geth keychain I got an error when trying to re-import the address. We were checking `e === ErrorMessages.GETH_ACCOUNT_ALREADY_EXISTS` when we needed to compare against `e.message`. ### Tested Manually ### Related issues - Part of #5792 ### Backwards compatibility Yes
- Loading branch information
Showing
12 changed files
with
114 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const DocumentDirectoryPath = jest.fn() | ||
|
||
export default () => {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { UnlockableWallet } from '@celo/wallet-base' | ||
import { call, select } from 'redux-saga/effects' | ||
import { AppEvents } from 'src/analytics/Events' | ||
import ValoraAnalytics from 'src/analytics/ValoraAnalytics' | ||
import { getWallet } from 'src/web3/contracts' | ||
import { currentAccountSelector } from 'src/web3/selectors' | ||
|
||
export function* checkAccountExistenceSaga() { | ||
const wallet: UnlockableWallet = yield call(getWallet) | ||
if (!wallet) { | ||
return | ||
} | ||
const gethAccounts: string[] = yield wallet.getAccounts() | ||
const reduxAddress: string = yield select(currentAccountSelector) | ||
if (!reduxAddress && gethAccounts.length > 0) { | ||
// TODO: Try to recover access to the account. | ||
ValoraAnalytics.track(AppEvents.redux_keychain_mismatch, { | ||
account: gethAccounts[0], | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters