Skip to content

Instantly share code, notes, and snippets.

@PaulLaux
Created August 29, 2018 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulLaux/c350554ae2f110b94b60748dd88b68ad to your computer and use it in GitHub Desktop.
Save PaulLaux/c350554ae2f110b94b60748dd88b68ad to your computer and use it in GitHub Desktop.
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