From 6100af39c75700c8b33d4010a67c18b983741d36 Mon Sep 17 00:00:00 2001 From: Julien Genestoux Date: Fri, 16 Feb 2024 06:22:28 -0500 Subject: [PATCH] fix(unlock-app): fixing setting a password in the password hook UI (#13354) * fixing setting a passwod in the password hook UI * linting --- .../hooksComponents/PasswordContractHook.tsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/unlock-app/src/components/interface/locks/Settings/forms/hooksComponents/PasswordContractHook.tsx b/unlock-app/src/components/interface/locks/Settings/forms/hooksComponents/PasswordContractHook.tsx index 56225bcc797..6c56b0fe129 100644 --- a/unlock-app/src/components/interface/locks/Settings/forms/hooksComponents/PasswordContractHook.tsx +++ b/unlock-app/src/components/interface/locks/Settings/forms/hooksComponents/PasswordContractHook.tsx @@ -1,5 +1,5 @@ import { Button, Input, Placeholder } from '@unlock-protocol/ui' -import { useEffect, useState } from 'react' +import { useState } from 'react' import { DEFAULT_USER_ACCOUNT_ADDRESS } from '~/constants' import { CustomComponentProps } from '../UpdateHooksForm' import { useAuth } from '~/contexts/AuthenticationContext' @@ -20,21 +20,16 @@ export const PasswordContractHook = ({ const { getWalletService } = useAuth() const web3Service = useWeb3Service() const [hookValue, setHookValue] = useState('') - const [signer, setSigner] = useState('') - - useEffect(() => { - if (hookValue.length === 0) return - const { address } = getEthersWalletFromPassword(hookValue) ?? {} - setSigner(address) - }, [hookValue]) const onSavePassword = async () => { + const { address: signerAddress } = + getEthersWalletFromPassword(hookValue) ?? {} const walletService = await getWalletService(network) const tx = await walletService.setPasswordHookSigner( { lockAddress, contractAddress: hookAddress, - signerAddress: signer, + signerAddress, network, }, walletService.signer @@ -131,7 +126,7 @@ export const PasswordContractHook = ({ loading={ savePasswordMutation.isLoading || setEventsHooksMutation.isLoading } - disabled={savePasswordMutation.isLoading || hookValue.length === 0} + disabled={savePasswordMutation.isLoading} > {hasSigner ? 'Update password' : 'Set password'}