diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -901,7 +901,7 @@ } | { +type: 'SIWE_AUTH_SUCCESS', - +payload?: void, + +payload?: boolean, +loadingInfo: LoadingInfo, } | { diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js --- a/native/account/siwe-panel.react.js +++ b/native/account/siwe-panel.react.js @@ -9,8 +9,9 @@ import { getSIWENonce, getSIWENonceActionTypes, + siweAuth, + siweAuthActionTypes, } from 'lib/actions/siwe-actions'; -import { registerActionTypes, register } from 'lib/actions/user-actions'; import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors'; import type { LogInStartingPayload } from 'lib/types/account-types'; import type { SIWEWebViewMessage } from 'lib/types/siwe-types'; @@ -24,7 +25,6 @@ import { nativeLogInExtraInfoSelector } from '../selectors/account-selectors'; import { defaultLandingURLPrefix } from '../utils/url-utils'; import type { LoggedOutMode } from './logged-out-modal.react'; -import { setNativeCredentials } from './native-credentials'; const commSIWE = `${defaultLandingURLPrefix}/siwe`; @@ -39,8 +39,8 @@ function SIWEPanel(props: Props): React.Node { const navContext = React.useContext(NavContext); const dispatchActionPromise = useDispatchActionPromise(); - const registerAction = useServerCall(register); const getSIWENonceCall = useServerCall(getSIWENonce); + const siweAuthCall = useServerCall(siweAuth); const logInExtraInfo = useSelector(state => nativeLogInExtraInfoSelector({ @@ -92,22 +92,21 @@ }, [snapToIndex, snapPoints]); const handleSIWE = React.useCallback( - ({ address, signature }) => { - // this is all mocked from register-panel + ({ address, message, signature }) => { const extraInfo = logInExtraInfo(); dispatchActionPromise( - registerActionTypes, - registerAction({ - username: address, - password: signature, + siweAuthActionTypes, + siweAuthCall({ + address, + message, + signature, ...extraInfo, }), undefined, ({ calendarQuery: extraInfo.calendarQuery }: LogInStartingPayload), ); - setNativeCredentials({ username: address, password: signature }); }, - [logInExtraInfo, dispatchActionPromise, registerAction], + [logInExtraInfo, dispatchActionPromise, siweAuthCall], ); const closeBottomSheet = bottomSheetRef.current?.close; const { onClose, nextMode } = props; @@ -115,9 +114,9 @@ event => { const data: SIWEWebViewMessage = JSON.parse(event.nativeEvent.data); if (data.type === 'siwe_success') { - const { address, signature } = data; + const { address, message, signature } = data; if (address && signature) { - handleSIWE({ address, signature }); + handleSIWE({ address, message, signature }); } } else if (data.type === 'siwe_closed') { onClose();