Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3408355
D11638.id39292.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D11638.id39292.diff
View Options
diff --git a/native/account/registration/registration-server-call.js b/native/account/registration/registration-server-call.js
--- a/native/account/registration/registration-server-call.js
+++ b/native/account/registration/registration-server-call.js
@@ -29,6 +29,7 @@
useNativeSetUserAvatar,
useUploadSelectedMedia,
} from '../../avatars/avatar-hooks.js';
+import { commCoreModule } from '../../native-modules.js';
import { useSelector } from '../../redux/redux-utils.js';
import { nativeLogInExtraInfoSelector } from '../../selectors/account-selectors.js';
import {
@@ -58,6 +59,7 @@
| { +step: 'inactive' }
| {
+step: 'waiting_for_registration_call',
+ +clearCachedSelections: () => void,
+avatarData: ?AvatarData,
+resolve: () => void,
+reject: Error => void,
@@ -199,8 +201,14 @@
if (currentStep.step !== 'inactive') {
return;
}
- const { accountSelection, avatarData, keyserverURL, farcasterID } =
- input;
+ const {
+ accountSelection,
+ avatarData,
+ keyserverURL,
+ farcasterID,
+ siweBackupSecrets,
+ clearCachedSelections,
+ } = input;
if (
accountSelection.accountType === 'username' &&
!usingCommServicesAccessToken
@@ -255,9 +263,13 @@
},
});
}
+ if (siweBackupSecrets) {
+ await commCoreModule.setSIWEBackupSecrets(siweBackupSecrets);
+ }
setCurrentStep({
step: 'waiting_for_registration_call',
avatarData,
+ clearCachedSelections,
resolve,
reject,
});
@@ -295,7 +307,7 @@
return;
}
avatarBeingSetRef.current = true;
- const { avatarData, resolve } = currentStep;
+ const { avatarData, resolve, clearCachedSelections } = currentStep;
void (async () => {
try {
if (!avatarData) {
@@ -319,6 +331,7 @@
dataLoaded: true,
},
});
+ clearCachedSelections();
setCurrentStep(inactiveStep);
avatarBeingSetRef.current = false;
resolve();
diff --git a/native/account/registration/registration-terms.react.js b/native/account/registration/registration-terms.react.js
--- a/native/account/registration/registration-terms.react.js
+++ b/native/account/registration/registration-terms.react.js
@@ -4,6 +4,8 @@
import * as React from 'react';
import { Text, View, Image, Linking } from 'react-native';
+import type { SIWEBackupSecrets } from 'lib/types/siwe-types.js';
+
import RegistrationButtonContainer from './registration-button-container.react.js';
import RegistrationButton from './registration-button.react.js';
import RegistrationContainer from './registration-container.react.js';
@@ -26,6 +28,7 @@
+farcasterID: ?string,
+accountSelection: AccountSelection,
+avatarData: ?AvatarData,
+ +siweBackupSecrets?: ?SIWEBackupSecrets,
},
};
@@ -44,20 +47,25 @@
function RegistrationTerms(props: Props): React.Node {
const registrationContext = React.useContext(RegistrationContext);
invariant(registrationContext, 'registrationContext should be set');
- const { register } = registrationContext;
+ const { register, setCachedSelections } = registrationContext;
const [registrationInProgress, setRegistrationInProgress] =
React.useState(false);
const { userSelections } = props.route.params;
+
+ const clearCachedSelections = React.useCallback(() => {
+ setCachedSelections({});
+ }, [setCachedSelections]);
+
const onProceed = React.useCallback(async () => {
setRegistrationInProgress(true);
try {
- await register(userSelections);
+ await register({ ...userSelections, clearCachedSelections });
} finally {
setRegistrationInProgress(false);
}
- }, [register, userSelections]);
+ }, [register, userSelections, clearCachedSelections]);
const styles = useStyles(unboundStyles);
diff --git a/native/account/registration/registration-types.js b/native/account/registration/registration-types.js
--- a/native/account/registration/registration-types.js
+++ b/native/account/registration/registration-types.js
@@ -43,6 +43,8 @@
+farcasterID: ?string,
+accountSelection: AccountSelection,
+avatarData: ?AvatarData,
+ +siweBackupSecrets?: ?SIWEBackupSecrets,
+ +clearCachedSelections: () => void,
};
export type CachedUserSelections = {
diff --git a/native/account/registration/siwe-backup-message-creation.react.js b/native/account/registration/siwe-backup-message-creation.react.js
--- a/native/account/registration/siwe-backup-message-creation.react.js
+++ b/native/account/registration/siwe-backup-message-creation.react.js
@@ -44,6 +44,7 @@
function CreateSIWEBackupMessage(props: Props): React.Node {
const { navigate } = props.navigation;
const { params } = props.route;
+ const { userSelections } = params;
const styles = useStyles(unboundStyles);
@@ -76,24 +77,36 @@
const onSuccessfulWalletSignature = React.useCallback(
(result: SIWEResult) => {
const { message, signature } = result;
+ const newUserSelections = {
+ ...userSelections,
+ siweBackupSecrets: { message, signature },
+ };
setCachedSelections(oldUserSelections => ({
...oldUserSelections,
siweBackupSecrets: { message, signature },
}));
navigate<'RegistrationTerms'>({
name: RegistrationTermsRouteName,
- params,
+ params: { userSelections: newUserSelections },
});
},
- [navigate, params, setCachedSelections],
+ [navigate, setCachedSelections, userSelections],
);
+ const { siweBackupSecrets } = cachedSelections;
const onExistingWalletSignature = React.useCallback(() => {
+ const registrationTermsParams = {
+ userSelections: {
+ ...userSelections,
+ siweBackupSecrets,
+ },
+ };
+
navigate<'RegistrationTerms'>({
name: RegistrationTermsRouteName,
- params,
+ params: registrationTermsParams,
});
- }, [params, navigate]);
+ }, [navigate, siweBackupSecrets, userSelections]);
let siwePanel;
if (panelState !== 'closed') {
@@ -109,8 +122,6 @@
);
}
- const { siweBackupSecrets } = cachedSelections;
-
const newSignatureButtonText = siweBackupSecrets
? 'Encrypt with new signature'
: 'Encrypt with Ethereum signature';
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 5, 10:57 AM (16 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2615258
Default Alt Text
D11638.id39292.diff (6 KB)
Attached To
Mode
D11638: Persist SIWE backup secrets to SQLite after succesfull registration process
Attached
Detach File
Event Timeline
Log In to Comment