set current account nonce to be independent from user input (#10863)

This commit is contained in:
Alberto Nicolas Penayo 2024-08-23 12:19:28 -03:00 committed by GitHub
parent 9e24bc45df
commit 05cce0e999
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,12 +22,16 @@ function SignFields ({ address, onChange, signedTx }: Props): React.ReactElement
const { api } = useApi();
const [blocks, setBlocks] = useState(() => new BN(64));
const [nonce, setNonce] = useState(BN_ZERO);
const [currentNonce, setCurrentNonce] = useState(BN_ZERO);
const { t } = useTranslation();
useEffect((): void => {
address && api.derive.balances
.account(address)
.then(({ accountNonce }) => setNonce(accountNonce))
.then(({ accountNonce }) => {
setNonce(accountNonce);
setCurrentNonce(accountNonce);
})
.catch(console.error);
}, [address, api]);
@ -52,7 +56,7 @@ function SignFields ({ address, onChange, signedTx }: Props): React.ReactElement
isDisabled={!!signedTx}
isZeroable
label={t('Nonce')}
labelExtra={t('Current account nonce: {{accountNonce}}', { replace: { accountNonce: nonce } })}
labelExtra={t('Current account nonce: {{accountNonce}}', { replace: { accountNonce: currentNonce } })}
onChange={_setNonce}
value={nonce}
/>