diff --git a/web/account/siwe-login-form.react.js b/web/account/siwe-login-form.react.js index ddde2b622..e8af31ff3 100644 --- a/web/account/siwe-login-form.react.js +++ b/web/account/siwe-login-form.react.js @@ -1,178 +1,178 @@ // @flow import '@rainbow-me/rainbowkit/dist/index.css'; import olm from '@matrix-org/olm'; -import { ConnectButton } from '@rainbow-me/rainbowkit'; import invariant from 'invariant'; import * as React from 'react'; import { useDispatch } from 'react-redux'; import { useAccount, useSigner } from 'wagmi'; import { getSIWENonce, getSIWENonceActionTypes, siweAuth, siweAuthActionTypes, } from 'lib/actions/siwe-actions'; import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors'; import type { LogInStartingPayload } from 'lib/types/account-types.js'; import { useDispatchActionPromise, useServerCall, } from 'lib/utils/action-utils'; import { createSIWEMessage, getSIWEStatementForPublicKey, siweMessageSigningExplanationStatements, } from 'lib/utils/siwe-utils.js'; import Button from '../components/button.react'; import OrBreak from '../components/or-break.react.js'; import LoadingIndicator from '../loading-indicator.react'; import { setPrimaryIdentityPublicKey } from '../redux/primary-identity-public-key-reducer'; import { useSelector } from '../redux/redux-utils'; import { webLogInExtraInfoSelector } from '../selectors/account-selectors.js'; import SWMansionIcon from '../SWMansionIcon.react.js'; import ConnectedWalletInfo from './connected-wallet-info.react.js'; import HeaderSeparator from './header-separator.react.js'; import css from './siwe.css'; type SIWELoginFormProps = { +cancelSIWEAuthFlow: () => void, }; const getSIWENonceLoadingStatusSelector = createLoadingStatusSelector( getSIWENonceActionTypes, ); function SIWELoginForm(props: SIWELoginFormProps): React.Node { const { address } = useAccount(); const { data: signer } = useSigner(); const dispatch = useDispatch(); const dispatchActionPromise = useDispatchActionPromise(); const getSIWENonceCall = useServerCall(getSIWENonce); const getSIWENonceCallLoadingStatus = useSelector( getSIWENonceLoadingStatusSelector, ); const siweAuthCall = useServerCall(siweAuth); const logInExtraInfo = useSelector(webLogInExtraInfoSelector); const [siweNonce, setSIWENonce] = React.useState(null); const siweNonceShouldBeFetched = !siweNonce && getSIWENonceCallLoadingStatus !== 'loading'; React.useEffect(() => { if (!siweNonceShouldBeFetched) { return; } dispatchActionPromise( getSIWENonceActionTypes, (async () => { const response = await getSIWENonceCall(); setSIWENonce(response); })(), ); }, [dispatchActionPromise, getSIWENonceCall, siweNonceShouldBeFetched]); const primaryIdentityPublicKey = useSelector( state => state.primaryIdentityPublicKey, ); React.useEffect(() => { (async () => { await olm.init(); const account = new olm.Account(); account.create(); const { ed25519 } = JSON.parse(account.identity_keys()); dispatch({ type: setPrimaryIdentityPublicKey, payload: ed25519, }); })(); }, [dispatch]); const callSIWEAuthEndpoint = React.useCallback( (message: string, signature: string, extraInfo) => siweAuthCall({ message, signature, ...extraInfo, }), [siweAuthCall], ); const attemptSIWEAuth = React.useCallback( (message: string, signature: string) => { const extraInfo = logInExtraInfo(); dispatchActionPromise( siweAuthActionTypes, callSIWEAuthEndpoint(message, signature, extraInfo), undefined, ({ calendarQuery: extraInfo.calendarQuery }: LogInStartingPayload), ); }, [callSIWEAuthEndpoint, dispatchActionPromise, logInExtraInfo], ); const onSignInButtonClick = React.useCallback(async () => { invariant(signer, 'signer must be present during SIWE attempt'); invariant(siweNonce, 'nonce must be present during SIWE attempt'); invariant( primaryIdentityPublicKey, 'primaryIdentityPublicKey must be present during SIWE attempt', ); const statement = getSIWEStatementForPublicKey(primaryIdentityPublicKey); const message = createSIWEMessage(address, statement, siweNonce); const signature = await signer.signMessage(message); attemptSIWEAuth(message, signature); }, [address, attemptSIWEAuth, primaryIdentityPublicKey, signer, siweNonce]); const { cancelSIWEAuthFlow } = props; const backButtonColor = React.useMemo( () => ({ backgroundColor: '#211E2D' }), [], ); if (!siweNonce || !primaryIdentityPublicKey) { return (
); } return (

Sign in with Ethereum

- -
+
+

Wallet Connected

+
- +

{siweMessageSigningExplanationStatements}

By signing up, you agree to our{' '} Terms of Use &{' '} Privacy Policy.

); } export default SIWELoginForm; diff --git a/web/account/siwe.css b/web/account/siwe.css index 97baf4b3c..5e4526891 100644 --- a/web/account/siwe.css +++ b/web/account/siwe.css @@ -1,39 +1,40 @@ div.ethereumLogoContainer { display: flex; justify-content: center; align-content: center; margin: 0 4px; } div.siweLoginFormContainer p { color: white; font-family: sans-serif; font-size: 15px; } div.messageSigningStatements p { padding-bottom: 20px; } div.siweLoginFormContainer { display: flex; flex-direction: column; } +div.walletConnectedText p { + font-weight: bold; +} + div.connectButtonContainer { - width: 100%; - display: flex; - justify-content: center; - align-content: center; - padding-bottom: 20px; + padding-top: 4px; + padding-bottom: 12px; } div.loadingIndicator { display: flex; justify-content: center; } div.siweContainer { display: flex; flex-direction: column; }