Skip to content

Commit

Permalink
fix: do not setNonce for default values, keep SafeTxProvider in sync …
Browse files Browse the repository at this point in the history
…with form
  • Loading branch information
schmanu committed Aug 14, 2023
1 parent 76d7e6f commit f246ee7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/components/tx-flow/common/TxNonce/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo, type ReactElement, useContext, useMemo, useEffect } from 'react'
import { memo, type ReactElement, useContext, useMemo } from 'react'
import {
Autocomplete,
Box,
Expand Down Expand Up @@ -102,18 +102,16 @@ const TxNonceForm = ({ nonce, recommendedNonce }: { nonce: string; recommendedNo
defaultValues: {
[TxNonceFormFieldNames.NONCE]: nonce,
},
mode: 'all',
mode: 'onChange',
values: {
[TxNonceFormFieldNames.NONCE]: nonce,
},
})

const resetNonce = () => {
formMethods.setValue(TxNonceFormFieldNames.NONCE, recommendedNonce)
}

// keep the formdata up-to-date when the actually used nonce updates
useEffect(() => {
formMethods.setValue(TxNonceFormFieldNames.NONCE, nonce)
}, [nonce, formMethods])

return (
<Controller
name={TxNonceFormFieldNames.NONCE}
Expand Down

0 comments on commit f246ee7

Please sign in to comment.