diff --git a/native/account/registration/registration-navigator.react.js b/native/account/registration/registration-navigator.react.js --- a/native/account/registration/registration-navigator.react.js +++ b/native/account/registration/registration-navigator.react.js @@ -17,7 +17,7 @@ import KeyserverSelection from './keyserver-selection.react.js'; import PasswordSelection from './password-selection.react.js'; import RegistrationTerms from './registration-terms.react.js'; -import CreateSIWEBackupMessage from './siwe-backup-message-creation.react.js'; +import { CreateSIWEBackupMessage } from './siwe-backup-message-creation.react.js'; import UsernameSelection from './username-selection.react.js'; import RegistrationUserAvatarCameraModal from '../../media/registration-user-avatar-camera-modal.react.js'; import type { RootNavigationProp } from '../../navigation/root-navigator.react.js'; 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 @@ -24,26 +24,16 @@ import { useStyles } from '../../themes/colors.js'; import SIWEPanel from '../siwe-panel.react.js'; -export type CreateSIWEBackupMessageParams = { - +userSelections: { - +coolOrNerdMode: CoolOrNerdMode, - +keyserverURL: string, - +farcasterID: ?string, - +accountSelection: AccountSelection, - +avatarData: ?AvatarData, - }, -}; - type PanelState = 'closed' | 'opening' | 'open' | 'closing'; -type Props = { - +navigation: RegistrationNavigationProp<'CreateSIWEBackupMessage'>, - +route: NavigationRoute<'CreateSIWEBackupMessage'>, +type CreateSIWEBackupMessageBaseProps = { + +onSuccessfulWalletSignature: (result: SIWEResult) => Promise, }; -function CreateSIWEBackupMessage(props: Props): React.Node { - const { navigate } = props.navigation; - const { params } = props.route; +function CreateSIWEBackupMessageBase( + props: CreateSIWEBackupMessageBaseProps, +): React.Node { + const { onSuccessfulWalletSignature } = props; const styles = useStyles(unboundStyles); const secureWithEthereumWalletText = 'Secure with Ethereum Wallet'; @@ -70,25 +60,6 @@ [panelState], ); - const registrationContext = React.useContext(RegistrationContext); - invariant(registrationContext, 'registrationContext should be set'); - const { setSIWEBackupSecrets } = registrationContext; - - const onSuccessfulWalletSignature = React.useCallback( - async (result: SIWEResult) => { - const { message, signature } = result; - setSIWEBackupSecrets({ - message, - signature, - }); - navigate<'RegistrationTerms'>({ - name: RegistrationTermsRouteName, - params, - }); - }, - [navigate, params, setSIWEBackupSecrets], - ); - let siwePanel; if (panelState !== 'closed') { siwePanel = ( @@ -129,6 +100,50 @@ ); } +export type CreateSIWEBackupMessageParams = { + +userSelections: { + +coolOrNerdMode: CoolOrNerdMode, + +keyserverURL: string, + +farcasterID: ?string, + +accountSelection: AccountSelection, + +avatarData: ?AvatarData, + }, +}; + +type Props = { + +navigation: RegistrationNavigationProp<'CreateSIWEBackupMessage'>, + +route: NavigationRoute<'CreateSIWEBackupMessage'>, +}; +function CreateSIWEBackupMessage(props: Props): React.Node { + const { navigate } = props.navigation; + const { params } = props.route; + + const registrationContext = React.useContext(RegistrationContext); + invariant(registrationContext, 'registrationContext should be set'); + const { setSIWEBackupSecrets } = registrationContext; + + const onSuccessfulWalletSignature = React.useCallback( + async (result: SIWEResult) => { + const { message, signature } = result; + setSIWEBackupSecrets({ + message, + signature, + }); + navigate<'RegistrationTerms'>({ + name: RegistrationTermsRouteName, + params, + }); + }, + [navigate, params, setSIWEBackupSecrets], + ); + + return ( + + ); +} + const unboundStyles = { scrollViewContentContainer: { flexGrow: 1, @@ -147,4 +162,4 @@ }, }; -export default CreateSIWEBackupMessage; +export { CreateSIWEBackupMessage, CreateSIWEBackupMessageBase };