Skip to content

Instantly share code, notes, and snippets.

@vdhanan
Last active April 10, 2024 21:35
Show Gist options
  • Save vdhanan/3b45d98a1658e3d11b21dd2aea9df328 to your computer and use it in GitHub Desktop.
Save vdhanan/3b45d98a1658e3d11b21dd2aea9df328 to your computer and use it in GitHub Desktop.
timeout-alert.patch
diff --git a/lib/utils/services-utils.js b/lib/utils/services-utils.js
index 684f444314..c22609665e 100644
--- a/lib/utils/services-utils.js
+++ b/lib/utils/services-utils.js
@@ -7,7 +7,7 @@ import type { AuthMetadata } from '../shared/identity-client-context.js';
// If this is true then we're using the identity service for auth. After we
// auth, the identity service gives us a CSAT, which we can use to auth with
// other Comm services.
-const usingCommServicesAccessToken = false;
+const usingCommServicesAccessToken = true;
// If this is true, then the app is able to support multiple keyservers. This
// requires the use of Tunnelbroker and the backup service to persist and sync
diff --git a/native/account/fullscreen-siwe-panel.react.js b/native/account/fullscreen-siwe-panel.react.js
index a52807c513..15c7c33ac2 100644
--- a/native/account/fullscreen-siwe-panel.react.js
+++ b/native/account/fullscreen-siwe-panel.react.js
@@ -7,7 +7,7 @@ import { ActivityIndicator, View } from 'react-native';
import { setDataLoadedActionType } from 'lib/actions/client-db-store-actions.js';
import type { SIWEResult } from 'lib/types/siwe-types.js';
-import { ServerError } from 'lib/utils/errors.js';
+import { ServerError, getMessageForException } from 'lib/utils/errors.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
@@ -78,6 +78,7 @@ function FullscreenSIWEPanel(props: Props): React.Node {
async (result: SIWEResult) => {
successRef.current = true;
if (usingCommServicesAccessToken) {
+ let attemptingRegistration = false;
try {
const findUserIDResponse =
await commRustModule.findUserIDForWalletAddress(result.address);
@@ -86,15 +87,28 @@ function FullscreenSIWEPanel(props: Props): React.Node {
} else if (enableNewRegistrationMode) {
await onAccountDoesNotExist(result);
} else {
+ attemptingRegistration = true;
await identityWalletRegisterCall(result);
}
} catch (e) {
- Alert.alert(
- UnknownErrorAlertDetails.title,
- UnknownErrorAlertDetails.message,
- [{ text: 'OK', onPress: goBackToPrompt }],
- { cancelable: false },
- );
+ const messageForException = getMessageForException(e);
+ if (messageForException === 'nonce expired') {
+ Alert.alert(
+ attemptingRegistration
+ ? 'Registration attempt timed out'
+ : 'Login attempt timed out',
+ 'Please try again',
+ [{ text: 'OK', onPress: goBackToPrompt }],
+ { cancelable: false },
+ );
+ } else {
+ Alert.alert(
+ UnknownErrorAlertDetails.title,
+ UnknownErrorAlertDetails.message,
+ [{ text: 'OK', onPress: goBackToPrompt }],
+ { cancelable: false },
+ );
+ }
throw e;
}
} else {
diff --git a/native/account/registration/existing-ethereum-account.react.js b/native/account/registration/existing-ethereum-account.react.js
index 707af41afb..73f786aaa7 100644
--- a/native/account/registration/existing-ethereum-account.react.js
+++ b/native/account/registration/existing-ethereum-account.react.js
@@ -8,6 +8,7 @@ import { siweAuthActionTypes } from 'lib/actions/siwe-actions.js';
import { useENSName } from 'lib/hooks/ens-cache.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import type { SIWEResult } from 'lib/types/siwe-types.js';
+import { getMessageForException } from 'lib/utils/errors.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
@@ -46,14 +47,26 @@ function ExistingEthereumAccount(props: Props): React.Node {
try {
await identityWalletLogInCall(params);
} catch (e) {
- Alert.alert(
- UnknownErrorAlertDetails.title,
- UnknownErrorAlertDetails.message,
- [{ text: 'OK' }],
- {
- cancelable: false,
- },
- );
+ const messageForException = getMessageForException(e);
+ if (messageForException === 'nonce expired') {
+ Alert.alert(
+ 'Login attempt timed out',
+ 'Please reconnect your wallet',
+ [{ text: 'OK' }],
+ {
+ cancelable: false,
+ },
+ );
+ } else {
+ Alert.alert(
+ UnknownErrorAlertDetails.title,
+ UnknownErrorAlertDetails.message,
+ [{ text: 'OK' }],
+ {
+ cancelable: false,
+ },
+ );
+ }
throw e;
}
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment