diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js --- a/native/account/siwe-panel.react.js +++ b/native/account/siwe-panel.react.js @@ -80,7 +80,14 @@ const [primaryIdentityPublicKey, setPrimaryIdentityPublicKey] = React.useState(null); + // This is set if we either succeed or fail, at which point we expect + // to be unmounted/remounted by our parent component prior to a retry + const nonceNotNeededRef = React.useRef(false); + React.useEffect(() => { + if (nonceNotNeededRef.current) { + return; + } const generateNonce = async (nonceFunction: () => Promise) => { try { const response = await nonceFunction(); @@ -89,7 +96,15 @@ Alert.alert( UnknownErrorAlertDetails.title, UnknownErrorAlertDetails.message, - [{ text: 'OK', onPress: onClosing }], + [ + { + text: 'OK', + onPress: () => { + nonceNotNeededRef.current = true; + onClosing(); + }, + }, + ], { cancelable: false }, ); throw e; @@ -158,10 +173,12 @@ if (data.type === 'siwe_success') { const { address, message, signature } = data; if (address && signature) { + nonceNotNeededRef.current = true; closeBottomSheet?.(); await onSuccessfulWalletSignature({ address, message, signature }); } } else if (data.type === 'siwe_closed') { + nonceNotNeededRef.current = true; onClosing(); closeBottomSheet?.(); } else if (data.type === 'walletconnect_modal_update') { @@ -181,6 +198,7 @@ const prevClosingRef = React.useRef(); React.useEffect(() => { if (closing && !prevClosingRef.current) { + nonceNotNeededRef.current = true; closeBottomSheet?.(); } prevClosingRef.current = closing;