Skip to content

Commit

Permalink
fix(unlock-app): fixing setting a password in the password hook UI (#…
Browse files Browse the repository at this point in the history
…13354)

* fixing setting a passwod in the password hook UI

* linting
  • Loading branch information
julien51 committed Feb 16, 2024
1 parent 9b8f623 commit 6100af3
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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'}
</Button>
Expand Down

0 comments on commit 6100af3

Please sign in to comment.