1
- import { getAddress , verifyMessage } from 'ethers' ;
2
- import { ChangeEvent , FC , useEffect , useState } from 'react' ;
3
- import { useTranslation } from 'react-i18next' ;
4
- import { useSignMessage } from 'wagmi' ;
5
- import addClassString from '../../../utilities/addClassString' ;
6
- import { ValidatorCandidate } from '../../types' ;
7
- import Button , { ButtonFace } from '../Button/Button' ;
8
- import Typography from '../Typography/Typography' ;
9
- import ValidatorCandidateRow from '../ValidatorCandidateRow/ValidatorCandidateRow' ;
10
- import WalletActionBtn from '../WalletActionBtn/WalletActionBtn' ;
1
+ import { getAddress , verifyMessage } from 'ethers'
2
+ import { ChangeEvent , FC , useEffect , useState } from 'react'
3
+ import { useTranslation } from 'react-i18next'
4
+ import { useSignMessage } from 'wagmi'
5
+ import addClassString from '../../../utilities/addClassString'
6
+ import { ValidatorCandidate } from '../../types'
7
+ import Button , { ButtonFace } from '../Button/Button'
8
+ import Typography from '../Typography/Typography'
9
+ import ValidatorCandidateRow from '../ValidatorCandidateRow/ValidatorCandidateRow'
10
+ import WalletActionBtn from '../WalletActionBtn/WalletActionBtn'
11
11
12
12
export interface ValidatorCredentialRowProps {
13
13
validatorCandidate : ValidatorCandidate
@@ -16,7 +16,7 @@ export interface ValidatorCredentialRowProps {
16
16
17
17
const ValidatorCredentialRow : FC < ValidatorCredentialRowProps > = ( {
18
18
validatorCandidate,
19
- onUpdateCandidate
19
+ onUpdateCandidate,
20
20
} ) => {
21
21
const { t } = useTranslation ( )
22
22
const { id, index, isVerifiedCredentials } = validatorCandidate
@@ -28,18 +28,22 @@ const ValidatorCredentialRow: FC<ValidatorCredentialRowProps> = ({
28
28
29
29
const { data, signMessage, error, reset } = useSignMessage ( )
30
30
31
- const handleError = ( e ) => {
31
+ const handleError = ( e : any ) => {
32
32
let message = 'error.unexpectedAddressError'
33
33
34
- if ( e ?. code === " INVALID_ARGUMENT" ) {
34
+ if ( e ?. code === ' INVALID_ARGUMENT' ) {
35
35
message = 'error.invalidAddressFormat'
36
36
}
37
37
38
38
setError ( t ( message ) )
39
39
}
40
40
41
41
const setCredential = ( e : ChangeEvent < HTMLInputElement > ) => {
42
- onUpdateCandidate ( id , { ...validatorCandidate , withdrawalCredentials : '' , isVerifiedCredentials : false } )
42
+ onUpdateCandidate ( id , {
43
+ ...validatorCandidate ,
44
+ withdrawalCredentials : undefined ,
45
+ isVerifiedCredentials : false ,
46
+ } )
43
47
setError ( '' )
44
48
setIsValidAddress ( false )
45
49
reset ( )
@@ -48,7 +52,7 @@ const ValidatorCredentialRow: FC<ValidatorCredentialRowProps> = ({
48
52
const value = e . target . value
49
53
setCredentialInput ( value )
50
54
const checkSumAddress = getAddress ( value )
51
- onUpdateCandidate ( id , { ...validatorCandidate , withdrawalCredentials : checkSumAddress } )
55
+ onUpdateCandidate ( id , { ...validatorCandidate , withdrawalCredentials : checkSumAddress } )
52
56
setIsValidAddress ( true )
53
57
} catch ( e ) {
54
58
handleError ( e )
@@ -69,12 +73,11 @@ const ValidatorCredentialRow: FC<ValidatorCredentialRowProps> = ({
69
73
const checkSumAddress = getAddress ( credentialInput )
70
74
const isVerifiedCredentials = signedAddress === checkSumAddress
71
75
72
- onUpdateCandidate ( id , { ...validatorCandidate , isVerifiedCredentials } )
76
+ onUpdateCandidate ( id , { ...validatorCandidate , isVerifiedCredentials } )
73
77
74
- if ( ! isVerifiedCredentials ) {
78
+ if ( ! isVerifiedCredentials ) {
75
79
setError ( t ( 'validatorManagement.withdrawalCredentials.incorrectSignature' ) )
76
80
}
77
-
78
81
} catch ( e ) {
79
82
handleError ( e )
80
83
} finally {
0 commit comments