File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
examples/wallet/app/components Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import Container from 'react-bootstrap/Container';
6
6
import Row from 'react-bootstrap/Row' ;
7
7
import typeof { setAccount as SetAccount } from '../actions/account' ;
8
8
import CreateUnlockWalletPassword from '../containers/CreateUnlockWalletPassword' ;
9
+ import { getAccountFromPrivateKey } from '../utils/wasmWrapper' ;
9
10
10
11
type Props = {
11
12
setAccount : SetAccount ,
@@ -30,6 +31,15 @@ export default ({
30
31
}
31
32
} ;
32
33
34
+ const checkValidPrivateKey = function checkValidPrivateKey ( ) {
35
+ getAccountFromPrivateKey ( newPrivateKey )
36
+ . then ( ( ) => setPrivateKeyErrorMessage ( '' ) )
37
+ . catch ( error => {
38
+ console . error ( error ) ;
39
+ setPrivateKeyErrorMessage ( 'Invalid private key' ) ;
40
+ } ) ;
41
+ } ;
42
+
33
43
const [ newPrivateKey , setNewPrivateKey ] = useState ( '' ) ;
34
44
const [ privateKeyErrorMessage , setPrivateKeyErrorMessage ] = useState ( '' ) ;
35
45
@@ -45,6 +55,7 @@ export default ({
45
55
value = { newPrivateKey }
46
56
isInvalid = { privateKeyErrorMessage }
47
57
onChange = { event => setNewPrivateKey ( event . target . value ) }
58
+ onBlur = { ( ) => checkValidPrivateKey ( ) }
48
59
/>
49
60
< Form . Control . Feedback type = "invalid" >
50
61
{ privateKeyErrorMessage }
You can’t perform that action at this time.
0 commit comments