From 66cd3edf7fd1e9009004bb28f960d236d57f8876 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Wed, 24 May 2023 16:04:04 +0100 Subject: [PATCH] Use new login endpoint https://github.com/status-im/status-go/compare/47711c4f...47711c4f This commit changes the login endpoint so that it uses LoginAccount. The main difference is that is consistent with the two others we use for creation/importing, and this will override the networks and use the secrets provided. --- .../im/status/ethereum/module/StatusModule.java | 11 +++++++++++ .../react-native-status/ios/RCTStatus/RCTStatus.m | 8 ++++++++ src/native_module/core.cljs | 9 +++++++++ src/status_im/multiaccounts/login/core.cljs | 15 ++++++++++++--- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java index 9a06de2aa2..17addc28ba 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java @@ -414,6 +414,17 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL } } + @ReactMethod + public void loginAccount(final String request) { + Log.d(TAG, "loginAccount"); + String result = Statusgo.loginAccount(request); + if (result.startsWith("{\"error\":\"\"")) { + Log.d(TAG, "loginAccount result: " + result); + } else { + Log.e(TAG, "loginAccount failed: " + result); + } + } + @ReactMethod public void exportUnencryptedDatabase(final String accountData, final String password, final Callback callback) { Log.d(TAG, "login"); diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.m b/modules/react-native-status/ios/RCTStatus/RCTStatus.m index c28ec0b262..fa09b3b092 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.m +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.m @@ -623,6 +623,14 @@ RCT_EXPORT_METHOD(loginWithConfig:(NSString *)accountData NSLog(@"%@", result); } +RCT_EXPORT_METHOD(loginAccount:(NSString *)request) { +#if DEBUG + NSLog(@"LoginAccount() method called"); +#endif + NSString *result = StatusgoLoginAccount(request); + NSLog(@"%@", result); +} + RCT_EXPORT_METHOD(loginWithKeycard:(NSString *)accountData password:(NSString *)password chatKey:(NSString *)chatKey) { diff --git a/src/native_module/core.cljs b/src/native_module/core.cljs index c0e1c75964..729306892b 100644 --- a/src/native_module/core.cljs +++ b/src/native_module/core.cljs @@ -82,6 +82,15 @@ key-uid #(.loginWithConfig ^js (status) account-data hashed-password config)))) +(defn login-account + "NOTE: beware, the password has to be sha3 hashed" + [{:keys [keyUid] :as request}] + (log/debug "[native-module] loginWithConfig") + (clear-web-data) + (init-keystore + keyUid + #(.loginAccount ^js (status) (types/clj->json request)))) + (defn create-account-and-login [request] (.createAccountAndLogin ^js (status) (types/clj->json request))) diff --git a/src/status_im/multiaccounts/login/core.cljs b/src/status_im/multiaccounts/login/core.cljs index ade14df617..52d506ce50 100644 --- a/src/status_im/multiaccounts/login/core.cljs +++ b/src/status_im/multiaccounts/login/core.cljs @@ -21,7 +21,6 @@ [status-im.multiaccounts.biometric.core :as biometric] [status-im.multiaccounts.core :as multiaccounts] [native-module.core :as native-module] - [status-im.node.core :as node] [status-im.notifications.core :as notifications] [status-im.popover.core :as popover] [status-im.signing.eip1559 :as eip1559] @@ -58,8 +57,18 @@ (re-frame/reg-fx ::login - (fn [[key-uid account-data hashed-password]] - (native-module/login-with-config key-uid account-data hashed-password node/login-node-config))) + (fn [[key-uid _ hashed-password]] + (native-module/login-account {:keyUid key-uid + :password hashed-password + :openseaAPIKey config/opensea-api-key + + :poktToken config/POKT_TOKEN + :infuraToken config/INFURA_TOKEN + + :alchemyOptimismMainnetToken config/ALCHEMY_OPTIMISM_MAINNET_TOKEN + :alchemyOptimismGoerliToken config/ALCHEMY_OPTIMISM_GOERLI_TOKEN + :alchemyArbitrumMainnetToken config/ALCHEMY_ARBITRUM_MAINNET_TOKEN + :alchemyArbitrumGoerliToken config/ALCHEMY_ARBITRUM_GOERLI_TOKEN}))) (re-frame/reg-fx ::export-db