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'
1111
1212export interface ValidatorCredentialRowProps {
1313 validatorCandidate : ValidatorCandidate
@@ -16,7 +16,7 @@ export interface ValidatorCredentialRowProps {
1616
1717const ValidatorCredentialRow : FC < ValidatorCredentialRowProps > = ( {
1818 validatorCandidate,
19- onUpdateCandidate
19+ onUpdateCandidate,
2020} ) => {
2121 const { t } = useTranslation ( )
2222 const { id, index, isVerifiedCredentials } = validatorCandidate
@@ -28,18 +28,22 @@ const ValidatorCredentialRow: FC<ValidatorCredentialRowProps> = ({
2828
2929 const { data, signMessage, error, reset } = useSignMessage ( )
3030
31- const handleError = ( e ) => {
31+ const handleError = ( e : any ) => {
3232 let message = 'error.unexpectedAddressError'
3333
34- if ( e ?. code === " INVALID_ARGUMENT" ) {
34+ if ( e ?. code === ' INVALID_ARGUMENT' ) {
3535 message = 'error.invalidAddressFormat'
3636 }
3737
3838 setError ( t ( message ) )
3939 }
4040
4141 const setCredential = ( e : ChangeEvent < HTMLInputElement > ) => {
42- onUpdateCandidate ( id , { ...validatorCandidate , withdrawalCredentials : '' , isVerifiedCredentials : false } )
42+ onUpdateCandidate ( id , {
43+ ...validatorCandidate ,
44+ withdrawalCredentials : undefined ,
45+ isVerifiedCredentials : false ,
46+ } )
4347 setError ( '' )
4448 setIsValidAddress ( false )
4549 reset ( )
@@ -48,7 +52,7 @@ const ValidatorCredentialRow: FC<ValidatorCredentialRowProps> = ({
4852 const value = e . target . value
4953 setCredentialInput ( value )
5054 const checkSumAddress = getAddress ( value )
51- onUpdateCandidate ( id , { ...validatorCandidate , withdrawalCredentials : checkSumAddress } )
55+ onUpdateCandidate ( id , { ...validatorCandidate , withdrawalCredentials : checkSumAddress } )
5256 setIsValidAddress ( true )
5357 } catch ( e ) {
5458 handleError ( e )
@@ -69,12 +73,11 @@ const ValidatorCredentialRow: FC<ValidatorCredentialRowProps> = ({
6973 const checkSumAddress = getAddress ( credentialInput )
7074 const isVerifiedCredentials = signedAddress === checkSumAddress
7175
72- onUpdateCandidate ( id , { ...validatorCandidate , isVerifiedCredentials } )
76+ onUpdateCandidate ( id , { ...validatorCandidate , isVerifiedCredentials } )
7377
74- if ( ! isVerifiedCredentials ) {
78+ if ( ! isVerifiedCredentials ) {
7579 setError ( t ( 'validatorManagement.withdrawalCredentials.incorrectSignature' ) )
7680 }
77-
7881 } catch ( e ) {
7982 handleError ( e )
8083 } finally {
0 commit comments