From 02d45fa06f2004a7729c8010ac6e564221cd4ba3 Mon Sep 17 00:00:00 2001 From: frank Date: Tue, 25 Jul 2023 15:03:57 +0800 Subject: [PATCH] discard backup message when recovering account (#16748) * discard backup message when recovering account * fix test failed * update status-go-version.json --- .../java/im/status/ethereum/module/StatusModule.java | 4 ++-- modules/react-native-status/ios/RCTStatus/RCTStatus.m | 5 +++-- modules/react-native-status/nodejs/status.cpp | 11 +++++++++-- src/native_module/core.cljs | 4 ++-- src/status_im/keycard/real_keycard.cljs | 2 +- src/status_im/keycard/recovery.cljs | 3 ++- status-go-version.json | 6 +++--- 7 files changed, 22 insertions(+), 13 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 9a2f02305f..95b48481bc 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 @@ -626,10 +626,10 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL } @ReactMethod - public void loginWithKeycard(final String accountData, final String password, final String chatKey) { + public void loginWithKeycard(final String accountData, final String password, final String chatKey, final String nodeConfigJSON) { Log.d(TAG, "loginWithKeycard"); this.migrateKeyStoreDir(accountData, password); - String result = Statusgo.loginWithKeycard(accountData, password, chatKey); + String result = Statusgo.loginWithKeycard(accountData, password, chatKey, nodeConfigJSON); if (result.startsWith("{\"error\":\"\"")) { Log.d(TAG, "LoginWithKeycard result: " + result); } else { diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.m b/modules/react-native-status/ios/RCTStatus/RCTStatus.m index 803c20afc5..4e1279ffba 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.m +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.m @@ -633,14 +633,15 @@ RCT_EXPORT_METHOD(loginAccount:(NSString *)request) { RCT_EXPORT_METHOD(loginWithKeycard:(NSString *)accountData password:(NSString *)password - chatKey:(NSString *)chatKey) { + chatKey:(NSString *)chatKey + nodeConfigJSON:(NSString *)nodeConfigJSON) { #if DEBUG NSLog(@"LoginWithKeycard() method called"); #endif [self getExportDbFilePath]; [self migrateKeystore:accountData password:password]; - NSString *result = StatusgoLoginWithKeycard(accountData, password, chatKey); + NSString *result = StatusgoLoginWithKeycard(accountData, password, chatKey, nodeConfigJSON); NSLog(@"%@", result); } diff --git a/modules/react-native-status/nodejs/status.cpp b/modules/react-native-status/nodejs/status.cpp index 335921a1d2..2db082a3d0 100644 --- a/modules/react-native-status/nodejs/status.cpp +++ b/modules/react-native-status/nodejs/status.cpp @@ -1041,7 +1041,7 @@ void _LoginWithKeycard(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); Local context = isolate->GetCurrentContext(); - if (args.Length() != 3) { + if (args.Length() != 4) { // Throw an Error that is passed back to JavaScript isolate->ThrowException(Exception::TypeError( String::NewFromUtf8Literal(isolate, "Wrong number of arguments for LoginWithKeycard"))); @@ -1065,6 +1065,11 @@ void _LoginWithKeycard(const FunctionCallbackInfo& args) { String::NewFromUtf8Literal(isolate, "Wrong argument type for 'keyHex'"))); return; } + if (!args[3]->IsString()) { + isolate->ThrowException(Exception::TypeError( + String::NewFromUtf8Literal(isolate, "Wrong argument type for 'nodeConfigJSON'"))); + return; + } String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked()); @@ -1073,9 +1078,11 @@ void _LoginWithKeycard(const FunctionCallbackInfo& args) { char *arg1 = *arg1Obj; String::Utf8Value arg2Obj(isolate, args[2]->ToString(context).ToLocalChecked()); char *arg2 = *arg2Obj; + String::Utf8Value arg3Obj(isolate, args[3]->ToString(context).ToLocalChecked()); + char *arg3 = *arg3Obj; // Call exported Go function, which returns a C string - char *c = LoginWithKeycard(arg0, arg1, arg2); + char *c = LoginWithKeycard(arg0, arg1, arg2, arg3); Local ret = String::NewFromUtf8(isolate, c).ToLocalChecked(); args.GetReturnValue().Set(ret); diff --git a/src/native_module/core.cljs b/src/native_module/core.cljs index 17b66f0b5c..bc7ee9a8c2 100644 --- a/src/native_module/core.cljs +++ b/src/native_module/core.cljs @@ -225,12 +225,12 @@ (.verifyDatabasePassword ^js (status) key-uid hashed-password callback)) (defn login-with-keycard - [{:keys [key-uid multiaccount-data password chat-key]}] + [{:keys [key-uid multiaccount-data password chat-key node-config]}] (log/debug "[native-module] login-with-keycard") (clear-web-data) (init-keystore key-uid - #(.loginWithKeycard ^js (status) multiaccount-data password chat-key))) + #(.loginWithKeycard ^js (status) multiaccount-data password chat-key (types/clj->json node-config)))) (defn set-soft-input-mode [mode] diff --git a/src/status_im/keycard/real_keycard.cljs b/src/status_im/keycard/real_keycard.cljs index 372e7c0a34..1ab65938c4 100644 --- a/src/status_im/keycard/real_keycard.cljs +++ b/src/status_im/keycard/real_keycard.cljs @@ -307,7 +307,7 @@ (defn login [args] - (native-module/login-with-keycard args)) + (native-module/login-with-keycard (assoc args :node-config {:ProcessBackedupMessages false}))) (defn send-transaction-with-signature [{:keys [transaction signature on-completed]}] diff --git a/src/status_im/keycard/recovery.cljs b/src/status_im/keycard/recovery.cljs index cb43107e3e..0447e1d3a5 100644 --- a/src/status_im/keycard/recovery.cljs +++ b/src/status_im/keycard/recovery.cljs @@ -253,7 +253,8 @@ encryption-pass #(let [{:keys [error]} (types/json->clj %)] (if (string/blank? error) - (native-module/login-with-keycard login-params) + (native-module/login-with-keycard + (assoc login-params :node-config {:ProcessBackedupMessages true})) (throw (js/Error. "Please shake the phone to report this error and restart the app. Migration failed unexpectedly."))))))) diff --git a/status-go-version.json b/status-go-version.json index bcbee8c00b..1013ac1233 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,7 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", - "version": "v0.162.5", - "commit-sha1": "cf2d72bfa83f094719a93b7b7fd5a68e3a68ab47", - "src-sha256": "0x79nm1n6gbgz2lzsky29laap7m0r0hggrb2fsn07bf0xw0364qn" + "version": "v0.162.9", + "commit-sha1": "6085a05f77354a26d879f476e67aa85cac1e1414", + "src-sha256": "0lb87lnfi49fk7ijppppr79rzkg8xzpwb3xxxmmq6wca2nb1pqp5" }