Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3567529
D11005.id36897.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D11005.id36897.diff
View Options
diff --git a/native/account/fullscreen-siwe-panel.react.js b/native/account/fullscreen-siwe-panel.react.js
--- a/native/account/fullscreen-siwe-panel.react.js
+++ b/native/account/fullscreen-siwe-panel.react.js
@@ -9,11 +9,15 @@
import type { SIWEResult } from 'lib/types/siwe-types.js';
import { ServerError } from 'lib/utils/errors.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
+import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
import { useGetEthereumAccountFromSIWEResult } from './registration/ethereum-utils.js';
import { RegistrationContext } from './registration/registration-context.js';
import { enableNewRegistrationMode } from './registration/registration-types.js';
-import { useLegacySIWEServerCall } from './siwe-hooks.js';
+import {
+ useLegacySIWEServerCall,
+ useIdentitySIWEServerCall,
+} from './siwe-hooks.js';
import SIWEPanel from './siwe-panel.react.js';
import {
AccountDoesNotExistRouteName,
@@ -64,40 +68,61 @@
);
const legacySiweServerCall = useLegacySIWEServerCall();
+ const identitySiweServerCall = useIdentitySIWEServerCall();
const successRef = React.useRef(false);
const dispatch = useDispatch();
const onSuccess = React.useCallback(
async (result: SIWEResult) => {
successRef.current = true;
- try {
- await legacySiweServerCall({
- ...result,
- doNotRegister: enableNewRegistrationMode,
- });
- } catch (e) {
- if (
- e instanceof ServerError &&
- e.message === 'account_does_not_exist'
- ) {
- await onAccountDoesNotExist(result);
- return;
+ if (usingCommServicesAccessToken) {
+ try {
+ await identitySiweServerCall(result);
+ } catch (e) {
+ Alert.alert(
+ UnknownErrorAlertDetails.title,
+ UnknownErrorAlertDetails.message,
+ [{ text: 'OK', onPress: goBackToPrompt }],
+ { cancelable: false },
+ );
+ throw e;
}
- Alert.alert(
- UnknownErrorAlertDetails.title,
- UnknownErrorAlertDetails.message,
- [{ text: 'OK', onPress: goBackToPrompt }],
- { cancelable: false },
- );
- throw e;
+ } else {
+ try {
+ await legacySiweServerCall({
+ ...result,
+ doNotRegister: enableNewRegistrationMode,
+ });
+ } catch (e) {
+ if (
+ e instanceof ServerError &&
+ e.message === 'account_does_not_exist'
+ ) {
+ await onAccountDoesNotExist(result);
+ return;
+ }
+ Alert.alert(
+ UnknownErrorAlertDetails.title,
+ UnknownErrorAlertDetails.message,
+ [{ text: 'OK', onPress: goBackToPrompt }],
+ { cancelable: false },
+ );
+ throw e;
+ }
+ dispatch({
+ type: setDataLoadedActionType,
+ payload: {
+ dataLoaded: true,
+ },
+ });
}
- dispatch({
- type: setDataLoadedActionType,
- payload: {
- dataLoaded: true,
- },
- });
},
- [legacySiweServerCall, dispatch, goBackToPrompt, onAccountDoesNotExist],
+ [
+ identitySiweServerCall,
+ goBackToPrompt,
+ dispatch,
+ legacySiweServerCall,
+ onAccountDoesNotExist,
+ ],
);
const ifBeforeSuccessGoBackToPrompt = React.useCallback(() => {
diff --git a/native/account/siwe-hooks.js b/native/account/siwe-hooks.js
--- a/native/account/siwe-hooks.js
+++ b/native/account/siwe-hooks.js
@@ -3,11 +3,16 @@
import * as React from 'react';
import { siweAuth, siweAuthActionTypes } from 'lib/actions/siwe-actions.js';
+import {
+ identityLogInActionTypes,
+ useIdentityWalletLogIn,
+} from 'lib/actions/user-actions.js';
import { useInitialNotificationsEncryptedMessage } from 'lib/shared/crypto-utils.js';
import type {
LogInStartingPayload,
LogInExtraInfo,
} from 'lib/types/account-types.js';
+import type { SIWEResult } from 'lib/types/siwe-types.js';
import { useLegacyAshoatKeyserverCall } from 'lib/utils/action-utils.js';
import type { CallSingleKeyserverEndpointOptions } from 'lib/utils/call-single-keyserver-endpoint.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
@@ -93,4 +98,18 @@
);
}
-export { useLegacySIWEServerCall };
+function useIdentitySIWEServerCall(): SIWEResult => Promise<void> {
+ const identityWalletLogIn = useIdentityWalletLogIn();
+ const dispatchActionPromise = useDispatchActionPromise();
+ return React.useCallback(
+ async ({ address, message, signature }) => {
+ const siwePromise = identityWalletLogIn(address, message, signature);
+ void dispatchActionPromise(identityLogInActionTypes, siwePromise);
+
+ await siwePromise;
+ },
+ [dispatchActionPromise, identityWalletLogIn],
+ );
+}
+
+export { useLegacySIWEServerCall, useIdentitySIWEServerCall };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 28, 9:03 PM (8 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2728945
Default Alt Text
D11005.id36897.diff (4 KB)
Attached To
Mode
D11005: [native] use identity wallet login in fullscreen-siwe-panel
Attached
Detach File
Event Timeline
Log In to Comment