Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32629660
D12093.1767480573.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D12093.1767480573.diff
View Options
diff --git a/native/account/registration/registration-server-call.js b/native/account/registration/registration-server-call.js
--- a/native/account/registration/registration-server-call.js
+++ b/native/account/registration/registration-server-call.js
@@ -30,6 +30,7 @@
import type {
RegistrationServerCallInput,
UsernameAccountSelection,
+ EthereumAccountSelection,
AvatarData,
} from './registration-types.js';
import { authoritativeKeyserverID } from '../../authoritative-keyserver.js';
@@ -223,7 +224,79 @@
);
const legacySiweServerCall = useLegacySIWEServerCall();
+ const legacyKeyserverRegisterEthereumAccount = React.useCallback(
+ async (
+ accountSelection: EthereumAccountSelection,
+ keyserverURL: string,
+ onAlertAcknowledged: ?() => mixed,
+ ) => {
+ try {
+ await legacySiweServerCall(accountSelection, {
+ urlPrefixOverride: keyserverURL,
+ });
+ } catch (e) {
+ const messageForException = getMessageForException(e);
+ if (messageForException === 'client_version_unsupported') {
+ Alert.alert(
+ appOutOfDateAlertDetails.title,
+ appOutOfDateAlertDetails.message,
+ [{ text: 'OK', onPress: onAlertAcknowledged }],
+ { cancelable: !onAlertAcknowledged },
+ );
+ } else {
+ Alert.alert(
+ unknownErrorAlertDetails.title,
+ unknownErrorAlertDetails.message,
+ [{ text: 'OK', onPress: onAlertAcknowledged }],
+ { cancelable: !onAlertAcknowledged },
+ );
+ }
+ throw e;
+ }
+ },
+ [legacySiweServerCall],
+ );
+
const identityWalletRegisterCall = useIdentityWalletRegisterCall();
+ const identityRegisterEthereumAccount = React.useCallback(
+ async (
+ accountSelection: EthereumAccountSelection,
+ farcasterID: ?string,
+ onNonceExpired: () => mixed,
+ onAlertAcknowledged: ?() => mixed,
+ ) => {
+ try {
+ await identityWalletRegisterCall({
+ address: accountSelection.address,
+ message: accountSelection.message,
+ signature: accountSelection.signature,
+ fid: farcasterID,
+ });
+ } catch (e) {
+ const messageForException = getMessageForException(e);
+ if (messageForException === 'nonce expired') {
+ onNonceExpired();
+ } else if (messageForException === 'Unsupported version') {
+ Alert.alert(
+ appOutOfDateAlertDetails.title,
+ appOutOfDateAlertDetails.message,
+ [{ text: 'OK', onPress: onAlertAcknowledged }],
+ { cancelable: !onAlertAcknowledged },
+ );
+ } else {
+ Alert.alert(
+ unknownErrorAlertDetails.title,
+ unknownErrorAlertDetails.message,
+ [{ text: 'OK', onPress: onAlertAcknowledged }],
+ { cancelable: !onAlertAcknowledged },
+ );
+ }
+ throw e;
+ }
+ },
+ [identityWalletRegisterCall],
+ );
+
const dispatch = useDispatch();
const returnedFunc = React.useCallback(
(input: RegistrationServerCallInput) =>
@@ -261,58 +334,18 @@
onAlertAcknowledged,
);
} else if (!usingCommServicesAccessToken) {
- try {
- await legacySiweServerCall(accountSelection, {
- urlPrefixOverride: keyserverURL,
- });
- } catch (e) {
- const messageForException = getMessageForException(e);
- if (messageForException === 'client_version_unsupported') {
- Alert.alert(
- appOutOfDateAlertDetails.title,
- appOutOfDateAlertDetails.message,
- [{ text: 'OK', onPress: onAlertAcknowledged }],
- { cancelable: !onAlertAcknowledged },
- );
- } else {
- Alert.alert(
- unknownErrorAlertDetails.title,
- unknownErrorAlertDetails.message,
- [{ text: 'OK', onPress: onAlertAcknowledged }],
- { cancelable: !onAlertAcknowledged },
- );
- }
- throw e;
- }
+ await legacyKeyserverRegisterEthereumAccount(
+ accountSelection,
+ keyserverURL,
+ onAlertAcknowledged,
+ );
} else {
- try {
- await identityWalletRegisterCall({
- address: accountSelection.address,
- message: accountSelection.message,
- signature: accountSelection.signature,
- fid: farcasterID,
- });
- } catch (e) {
- const messageForException = getMessageForException(e);
- if (messageForException === 'nonce expired') {
- onNonceExpired();
- } else if (messageForException === 'Unsupported version') {
- Alert.alert(
- appOutOfDateAlertDetails.title,
- appOutOfDateAlertDetails.message,
- [{ text: 'OK', onPress: onAlertAcknowledged }],
- { cancelable: !onAlertAcknowledged },
- );
- } else {
- Alert.alert(
- unknownErrorAlertDetails.title,
- unknownErrorAlertDetails.message,
- [{ text: 'OK', onPress: onAlertAcknowledged }],
- { cancelable: !onAlertAcknowledged },
- );
- }
- throw e;
- }
+ await identityRegisterEthereumAccount(
+ accountSelection,
+ farcasterID,
+ onNonceExpired,
+ onAlertAcknowledged,
+ );
}
if (passedKeyserverURL) {
dispatch({
@@ -368,9 +401,9 @@
currentStep,
legacyKeyserverRegisterUsernameAccount,
identityRegisterUsernameAccount,
- legacySiweServerCall,
+ legacyKeyserverRegisterEthereumAccount,
+ identityRegisterEthereumAccount,
dispatch,
- identityWalletRegisterCall,
],
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 3, 10:49 PM (20 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5883293
Default Alt Text
D12093.1767480573.diff (6 KB)
Attached To
Mode
D12093: [native] Factor out SIWE registration in registrationServerCall
Attached
Detach File
Event Timeline
Log In to Comment