2021-06-29 15:32:29 +10:00
|
|
|
import { Button } from '@material-ui/core';
|
|
|
|
|
import React from 'react';
|
2021-06-29 11:56:49 +10:00
|
|
|
import { loadKeyPairFromStorage } from './key_pair_storage';
|
2021-06-29 11:52:48 +10:00
|
|
|
import { KeyPair } from '../crypto';
|
2021-06-28 15:09:32 +10:00
|
|
|
|
|
|
|
|
export interface Props {
|
|
|
|
|
setEthDmKeyPair: (keyPair: KeyPair) => void;
|
|
|
|
|
disabled: boolean;
|
2021-06-29 15:32:29 +10:00
|
|
|
password: string | undefined;
|
2021-06-28 15:09:32 +10:00
|
|
|
}
|
|
|
|
|
|
2021-06-29 15:32:29 +10:00
|
|
|
export function LoadKeyPair({ password, disabled, setEthDmKeyPair }: Props) {
|
2021-06-28 15:09:32 +10:00
|
|
|
const loadKeyPair = () => {
|
|
|
|
|
if (disabled) return;
|
|
|
|
|
if (!password) return;
|
|
|
|
|
loadKeyPairFromStorage(password).then((keyPair: KeyPair | undefined) => {
|
|
|
|
|
if (!keyPair) return;
|
|
|
|
|
console.log('EthDm KeyPair loaded from storage');
|
2021-06-29 12:10:24 +10:00
|
|
|
setEthDmKeyPair(keyPair);
|
2021-06-28 15:09:32 +10:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2021-06-29 15:32:29 +10:00
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
color="primary"
|
|
|
|
|
onClick={loadKeyPair}
|
|
|
|
|
disabled={!password || disabled}
|
2021-06-28 15:09:32 +10:00
|
|
|
>
|
2021-06-29 15:32:29 +10:00
|
|
|
Load Eth-DM Key Pair from storage
|
|
|
|
|
</Button>
|
2021-06-28 15:09:32 +10:00
|
|
|
);
|
|
|
|
|
}
|