Changeset View
Changeset View
Standalone View
Standalone View
native/account/registration/connect-ethereum.react.js
Show All 16 Lines | |||||
import RegistrationButton from './registration-button.react.js'; | import RegistrationButton from './registration-button.react.js'; | ||||
import RegistrationContainer from './registration-container.react.js'; | import RegistrationContainer from './registration-container.react.js'; | ||||
import RegistrationContentContainer from './registration-content-container.react.js'; | import RegistrationContentContainer from './registration-content-container.react.js'; | ||||
import type { RegistrationNavigationProp } from './registration-navigator.react.js'; | import type { RegistrationNavigationProp } from './registration-navigator.react.js'; | ||||
import type { CoolOrNerdMode } from './registration-types.js'; | import type { CoolOrNerdMode } from './registration-types.js'; | ||||
import { | import { | ||||
type NavigationRoute, | type NavigationRoute, | ||||
ExistingEthereumAccountRouteName, | ExistingEthereumAccountRouteName, | ||||
UsernameSelectionRouteName, | |||||
} from '../../navigation/route-names.js'; | } from '../../navigation/route-names.js'; | ||||
import { useStyles } from '../../themes/colors.js'; | import { useStyles } from '../../themes/colors.js'; | ||||
import EthereumLogoDark from '../../vectors/ethereum-logo-dark.react.js'; | import EthereumLogoDark from '../../vectors/ethereum-logo-dark.react.js'; | ||||
import SIWEPanel from '../siwe-panel.react.js'; | import SIWEPanel from '../siwe-panel.react.js'; | ||||
export type ConnectEthereumParams = { | export type ConnectEthereumParams = { | ||||
+userSelections: { | +userSelections: { | ||||
+coolOrNerdMode: CoolOrNerdMode, | +coolOrNerdMode: CoolOrNerdMode, | ||||
+keyserverUsername: string, | +keyserverUsername: string, | ||||
}, | }, | ||||
}; | }; | ||||
type PanelState = 'closed' | 'opening' | 'open' | 'closing'; | type PanelState = 'closed' | 'opening' | 'open' | 'closing'; | ||||
type Props = { | type Props = { | ||||
+navigation: RegistrationNavigationProp<'ConnectEthereum'>, | +navigation: RegistrationNavigationProp<'ConnectEthereum'>, | ||||
+route: NavigationRoute<'ConnectEthereum'>, | +route: NavigationRoute<'ConnectEthereum'>, | ||||
}; | }; | ||||
function ConnectEthereum(props: Props): React.Node { | function ConnectEthereum(props: Props): React.Node { | ||||
const isNerdMode = | const { params } = props.route; | ||||
props.route.params.userSelections.coolOrNerdMode === 'nerd'; | const { userSelections } = props.route.params; | ||||
const isNerdMode = userSelections.coolOrNerdMode === 'nerd'; | |||||
const styles = useStyles(unboundStyles); | const styles = useStyles(unboundStyles); | ||||
let body; | let body; | ||||
if (!isNerdMode) { | if (!isNerdMode) { | ||||
body = ( | body = ( | ||||
<Text style={styles.body}> | <Text style={styles.body}> | ||||
Connecting your Ethereum wallet allows you to use your ENS name and | Connecting your Ethereum wallet allows you to use your ENS name and | ||||
avatar in the app. You’ll also be able to log in with your wallet | avatar in the app. You’ll also be able to log in with your wallet | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | (loading: boolean) => { | ||||
if (panelState === 'closing' || panelState === 'closed') { | if (panelState === 'closing' || panelState === 'closed') { | ||||
return; | return; | ||||
} | } | ||||
setPanelState(loading ? 'opening' : 'open'); | setPanelState(loading ? 'opening' : 'open'); | ||||
}, | }, | ||||
[panelState], | [panelState], | ||||
); | ); | ||||
const { navigate } = props.navigation; | |||||
const onSkip = React.useCallback(() => { | const onSkip = React.useCallback(() => { | ||||
// show username selection screen | navigate<'UsernameSelection'>({ | ||||
}, []); | name: UsernameSelectionRouteName, | ||||
params, | |||||
}); | |||||
}, [navigate, params]); | |||||
const exactSearchUserCall = useServerCall(exactSearchUser); | const exactSearchUserCall = useServerCall(exactSearchUser); | ||||
const dispatchActionPromise = useDispatchActionPromise(); | const dispatchActionPromise = useDispatchActionPromise(); | ||||
const { navigate } = props.navigation; | |||||
const onSuccessfulWalletSignature = React.useCallback( | const onSuccessfulWalletSignature = React.useCallback( | ||||
async (result: SIWEResult) => { | async (result: SIWEResult) => { | ||||
const searchPromise = exactSearchUserCall(result.address); | const searchPromise = exactSearchUserCall(result.address); | ||||
dispatchActionPromise(exactSearchUserActionTypes, searchPromise); | dispatchActionPromise(exactSearchUserActionTypes, searchPromise); | ||||
const { userInfo } = await searchPromise; | const { userInfo } = await searchPromise; | ||||
if (userInfo) { | if (userInfo) { | ||||
navigate<'ExistingEthereumAccount'>({ | navigate<'ExistingEthereumAccount'>({ | ||||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |