Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3281752
D10881.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D10881.diff
View Options
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
@@ -10,11 +10,16 @@
getSIWENonceActionTypes,
siweAuthActionTypes,
} from 'lib/actions/siwe-actions.js';
+import {
+ identityGenerateNonceActionTypes,
+ useIdentityGenerateNonce,
+} from 'lib/actions/user-actions.js';
import type { ServerCallSelectorParams } from 'lib/keyserver-conn/call-keyserver-endpoint-provider.react.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import type { SIWEWebViewMessage, SIWEResult } from 'lib/types/siwe-types.js';
import { useLegacyAshoatKeyserverCall } from 'lib/utils/action-utils.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
+import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
import { useKeyboardHeight } from '../keyboard/keyboard-hooks.js';
import { useSelector } from '../redux/redux-utils.js';
@@ -29,6 +34,9 @@
const getSIWENonceLoadingStatusSelector = createLoadingStatusSelector(
getSIWENonceActionTypes,
);
+const identityGenerateNonceLoadingStatusSelector = createLoadingStatusSelector(
+ identityGenerateNonceActionTypes,
+);
const siweAuthLoadingStatusSelector =
createLoadingStatusSelector(siweAuthActionTypes);
@@ -54,10 +62,14 @@
getSIWENonce,
props.keyserverCallParamOverride,
);
+ const identityGenerateNonce = useIdentityGenerateNonce();
- const getSIWENonceCallFailed = useSelector(
+ const legacyGetSIWENonceCallFailed = useSelector(
state => getSIWENonceLoadingStatusSelector(state) === 'error',
);
+ const identityGenerateNonceFailed = useSelector(
+ state => identityGenerateNonceLoadingStatusSelector(state) === 'error',
+ );
const { onClosing } = props;
@@ -70,28 +82,43 @@
React.useState<?string>(null);
React.useEffect(() => {
+ const generateNonce = async (nonceFunction: () => Promise<string>) => {
+ try {
+ const response = await nonceFunction();
+ setNonce(response);
+ } catch (e) {
+ Alert.alert(
+ UnknownErrorAlertDetails.title,
+ UnknownErrorAlertDetails.message,
+ [{ text: 'OK', onPress: onClosing }],
+ { cancelable: false },
+ );
+ throw e;
+ }
+ };
+
void (async () => {
- void dispatchActionPromise(
- getSIWENonceActionTypes,
- (async () => {
- try {
- const response = await getSIWENonceCall();
- setNonce(response);
- } catch (e) {
- Alert.alert(
- UnknownErrorAlertDetails.title,
- UnknownErrorAlertDetails.message,
- [{ text: 'OK', onPress: onClosing }],
- { cancelable: false },
- );
- throw e;
- }
- })(),
- );
+ if (usingCommServicesAccessToken) {
+ void dispatchActionPromise(
+ identityGenerateNonceActionTypes,
+ generateNonce(identityGenerateNonce),
+ );
+ } else {
+ void dispatchActionPromise(
+ getSIWENonceActionTypes,
+ generateNonce(getSIWENonceCall),
+ );
+ }
+
const ed25519 = await getContentSigningKey();
setPrimaryIdentityPublicKey(ed25519);
})();
- }, [dispatchActionPromise, getSIWENonceCall, onClosing]);
+ }, [
+ dispatchActionPromise,
+ getSIWENonceCall,
+ identityGenerateNonce,
+ onClosing,
+ ]);
const [isLoading, setLoading] = React.useState(true);
const [walletConnectModalHeight, setWalletConnectModalHeight] =
@@ -216,7 +243,10 @@
}
const setLoadingProp = props.setLoading;
- const loading = !getSIWENonceCallFailed && (isLoading || siweAuthCallLoading);
+ const loading =
+ !legacyGetSIWENonceCallFailed &&
+ !identityGenerateNonceFailed &&
+ (isLoading || siweAuthCallLoading);
React.useEffect(() => {
setLoadingProp(loading);
}, [setLoadingProp, loading]);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 10:10 AM (21 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2522137
Default Alt Text
D10881.diff (3 KB)
Attached To
Mode
D10881: [native] use identityGenerateNonce in SIWEPanel component
Attached
Detach File
Event Timeline
Log In to Comment