Instantly share code, notes, and snippets.

Embed
What would you like to do?
Save encrypted keystore into local storage
import localStore from 'store/dist/store.modern';
/* keystore will be saved to local storage under this key */
export const localStorageKey = 'ks';
/**
* Save wallet to localStorage
*/
export function* saveWalletS() {
try {
const ks = yield select(makeSelectKeystore());
// Add app specific metadeta such as version and date
const dump = {
ver: '1',
saved: new Date().toISOString(),
ks: ks.serialize(),
};
localStore.set(localStorageKey, dump);
yield put(saveWalletSuccess());
} catch (err) {
const errorString = `${err.message}`;
yield put(saveWalletError(errorString));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment