mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-11 11:34:26 +00:00
af2e0b69e1
1. Attempt an empty password every time a keystore is uploaded. 2. Delegate scrypt decryption (ie ethereumjs-wallet.fromV3) to its own web worker and interface with it through an async typescript function that gets handled in the wallet saga. This keeps the UI unblocked when scrypt takes a long time to decrypt. 3. Add logic to show a spinner x number of milliseconds after file upload so the user will understand when a wallet is being decrypted.
24 lines
676 B
TypeScript
24 lines
676 B
TypeScript
import { IFullWallet, fromPrivateKey } from 'ethereumjs-wallet';
|
|
import { toBuffer } from 'ethereumjs-util';
|
|
import Worker from 'worker-loader!./workers/scrypt-worker.worker.ts';
|
|
|
|
export const fromV3 = (
|
|
keystore: string,
|
|
password: string,
|
|
nonStrict: boolean
|
|
): Promise<IFullWallet> => {
|
|
return new Promise((resolve, reject) => {
|
|
const scryptWorker = new Worker();
|
|
scryptWorker.postMessage({ keystore, password, nonStrict });
|
|
scryptWorker.onmessage = event => {
|
|
const data: string = event.data;
|
|
try {
|
|
const wallet = fromPrivateKey(toBuffer(data));
|
|
resolve(wallet);
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
});
|
|
};
|