Created
August 29, 2018 06:35
-
-
Save PaulLaux/c350554ae2f110b94b60748dd88b68ad to your computer and use it in GitHub Desktop.
Save encrypted keystore into local storage
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
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