Page MenuHomePhorge

D14785.1765361502.diff
No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None

D14785.1765361502.diff

diff --git a/native/account/restore-backup-screen.react.js b/native/account/restore-backup-screen.react.js
--- a/native/account/restore-backup-screen.react.js
+++ b/native/account/restore-backup-screen.react.js
@@ -21,6 +21,10 @@
networkErrorAlertDetails,
unknownErrorAlertDetails,
userNotFoundAlertDetails,
+ passwordLoginErrorAlertDetails,
+ siweLoginErrorAlertDetails,
+ userKeysRestoreErrorAlertDetails,
+ userDataRestoreErrorAlertDetails,
} from '../utils/alert-messages.js';
import Alert from '../utils/alert.js';
@@ -58,9 +62,18 @@
}
});
void (async () => {
+ let step;
+ const setStep = (newStep: string) => {
+ step = newStep;
+ };
try {
if (credentials.type === 'password') {
- await restore(userIdentifier, credentials.password);
+ await restore(
+ userIdentifier,
+ credentials.password,
+ undefined,
+ setStep,
+ );
await setNativeCredentials({
username: userIdentifier,
password: credentials.password,
@@ -71,6 +84,7 @@
userIdentifier,
credentials.backup.signature,
credentials.socialProof,
+ setStep,
);
}
} catch (e) {
@@ -103,7 +117,15 @@
getMessageForException(err) ?? ''
}`,
);
+ alertDetails =
+ credentials.type === 'password'
+ ? passwordLoginErrorAlertDetails
+ : siweLoginErrorAlertDetails;
}
+ } else if (step === 'user_keys_restore') {
+ alertDetails = userKeysRestoreErrorAlertDetails;
+ } else if (step === 'user_data_restore') {
+ alertDetails = userDataRestoreErrorAlertDetails;
}
Alert.alert(
alertDetails.title,
diff --git a/native/account/restore-password-account-screen.react.js b/native/account/restore-password-account-screen.react.js
--- a/native/account/restore-password-account-screen.react.js
+++ b/native/account/restore-password-account-screen.react.js
@@ -24,6 +24,8 @@
networkErrorAlertDetails,
unknownErrorAlertDetails,
userNotFoundAlertDetails,
+ backupInfoFetchErrorAlertDetails,
+ passwordLoginErrorAlertDetails,
} from '../utils/alert-messages.js';
import Alert from '../utils/alert.js';
@@ -94,11 +96,14 @@
return;
}
setIsProcessing(true);
+ let step;
try {
+ step = 'fetch_backup_info';
const latestBackupInfo = await retrieveLatestBackupInfo(
credentials.username,
);
if (!latestBackupInfo) {
+ step = 'v1_login';
await performV1Login(credentials.username, {
type: 'password',
password: credentials.password,
@@ -130,6 +135,10 @@
alertMessage = appOutOfDateAlertDetails;
} else if (messageForException === 'network_error') {
alertMessage = networkErrorAlertDetails;
+ } else if (step === 'fetch_backup_info') {
+ alertMessage = backupInfoFetchErrorAlertDetails;
+ } else if (step === 'v1_login') {
+ alertMessage = passwordLoginErrorAlertDetails;
}
Alert.alert(
alertMessage.title,
diff --git a/native/account/restore-prompt-screen.react.js b/native/account/restore-prompt-screen.react.js
--- a/native/account/restore-prompt-screen.react.js
+++ b/native/account/restore-prompt-screen.react.js
@@ -26,6 +26,8 @@
appOutOfDateAlertDetails,
networkErrorAlertDetails,
unknownErrorAlertDetails,
+ backupInfoFetchErrorAlertDetails,
+ siweLoginErrorAlertDetails,
} from '../utils/alert-messages.js';
import Alert from '../utils/alert.js';
import RestoreIcon from '../vectors/restore-icon.react.js';
@@ -51,11 +53,14 @@
const performV1Login = useV1Login();
const onSIWESuccess = React.useCallback(
async (result: SIWEResult) => {
+ let step;
try {
+ step = 'fetch_backup_info';
setAuthInProgress(true);
const { address, signature, message } = result;
const backupInfo = await retrieveLatestBackupInfo(address);
if (!backupInfo) {
+ step = 'v1_login';
await performV1Login(address, {
type: 'siwe',
socialProof: { message, signature },
@@ -101,6 +106,10 @@
};
} else if (messageForException === 'network_error') {
alertDetails = networkErrorAlertDetails;
+ } else if (step === 'fetch_backup_info') {
+ alertDetails = backupInfoFetchErrorAlertDetails;
+ } else if (step === 'v1_login') {
+ alertDetails = siweLoginErrorAlertDetails;
}
Alert.alert(
alertDetails.title,
diff --git a/native/account/restore.js b/native/account/restore.js
--- a/native/account/restore.js
+++ b/native/account/restore.js
@@ -173,6 +173,7 @@
userIdentifier: string,
secret: string,
siweSocialProof?: SignedMessage,
+ setStep?: (step: string) => void,
) => Promise<IdentityAuthResult> {
const restoreProtocol = useRestoreProtocol();
const dispatchActionPromise = useDispatchActionPromise();
@@ -236,10 +237,13 @@
userIdentifier: string,
secret: string,
siweSocialProof?: SignedMessage,
+ setStep,
) => {
+ setStep?.('user_keys_restore');
const identityAuthResult = await logIn(
restoreAuth(userIdentifier, secret, siweSocialProof),
);
+ setStep?.('user_data_restore');
await restoreUserData(identityAuthResult);
return identityAuthResult;
},

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 10, 10:11 AM (20 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5863170
Default Alt Text
D14785.1765361502.diff (5 KB)

Event Timeline