changes corresponding to refactor of local pair of status-go (PR #3248) (#15412)

This commit is contained in:
frank 2023-03-23 20:23:26 +08:00 committed by GitHub
parent 8d166a3a52
commit 45da51bea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 23 deletions

View File

@ -801,9 +801,10 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
@ReactMethod @ReactMethod
public void getConnectionStringForBootstrappingAnotherDevice(final String configJSON, final Callback callback) throws JSONException { public void getConnectionStringForBootstrappingAnotherDevice(final String configJSON, final Callback callback) throws JSONException {
final JSONObject jsonConfig = new JSONObject(configJSON); final JSONObject jsonConfig = new JSONObject(configJSON);
final String keyUID = jsonConfig.getString("keyUID"); final JSONObject senderConfig = jsonConfig.getJSONObject("senderConfig");
final String keyUID = senderConfig.getString("keyUID");
final String keyStorePath = this.getKeyStorePath(keyUID); final String keyStorePath = this.getKeyStorePath(keyUID);
jsonConfig.put("keystorePath", keyStorePath); senderConfig.put("keystorePath", keyStorePath);
executeRunnableStatusGoMethod(() -> Statusgo.getConnectionStringForBootstrappingAnotherDevice(jsonConfig.toString()), callback); executeRunnableStatusGoMethod(() -> Statusgo.getConnectionStringForBootstrappingAnotherDevice(jsonConfig.toString()), callback);
} }
@ -811,9 +812,10 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
@ReactMethod @ReactMethod
public void inputConnectionStringForBootstrapping(final String connectionString, final String configJSON, final Callback callback) throws JSONException { public void inputConnectionStringForBootstrapping(final String connectionString, final String configJSON, final Callback callback) throws JSONException {
final JSONObject jsonConfig = new JSONObject(configJSON); final JSONObject jsonConfig = new JSONObject(configJSON);
final JSONObject receiverConfig = jsonConfig.getJSONObject("receiverConfig");
final String keyStorePath = pathCombine(this.getNoBackupDirectory(), "/keystore"); final String keyStorePath = pathCombine(this.getNoBackupDirectory(), "/keystore");
jsonConfig.put("keystorePath", keyStorePath); receiverConfig.put("keystorePath", keyStorePath);
jsonConfig.put("rootDataDir", this.getNoBackupDirectory()); receiverConfig.getJSONObject("nodeConfig").put("rootDataDir", this.getNoBackupDirectory());
executeRunnableStatusGoMethod(() -> Statusgo.inputConnectionStringForBootstrapping(connectionString, jsonConfig.toString()), callback); executeRunnableStatusGoMethod(() -> Statusgo.inputConnectionStringForBootstrapping(connectionString, jsonConfig.toString()), callback);
} }

View File

@ -309,12 +309,14 @@ RCT_EXPORT_METHOD(getConnectionStringForBootstrappingAnotherDevice:(NSString *)c
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
NSData *configData = [configJSON dataUsingEncoding:NSUTF8StringEncoding]; NSData *configData = [configJSON dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *configDict = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:nil]; NSError *error;
NSString *keyUID = [configDict objectForKey:@"keyUID"]; NSMutableDictionary *configDict = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:&error];
NSMutableDictionary *senderConfig = configDict[@"senderConfig"];
NSString *keyUID = senderConfig[@"keyUID"];
NSURL *multiaccountKeystoreDir = [self getKeyStoreDir:keyUID]; NSURL *multiaccountKeystoreDir = [self getKeyStoreDir:keyUID];
NSString *keystoreDir = multiaccountKeystoreDir.path; NSString *keystoreDir = multiaccountKeystoreDir.path;
[configDict setValue:keystoreDir forKey:@"keystorePath"]; [senderConfig setValue:keystoreDir forKey:@"keystorePath"];
NSString *modifiedConfigJSON = [configDict bv_jsonStringWithPrettyPrint:NO]; NSString *modifiedConfigJSON = [configDict bv_jsonStringWithPrettyPrint:NO];
NSString *result = StatusgoGetConnectionStringForBootstrappingAnotherDevice(modifiedConfigJSON); NSString *result = StatusgoGetConnectionStringForBootstrappingAnotherDevice(modifiedConfigJSON);
@ -326,17 +328,20 @@ RCT_EXPORT_METHOD(inputConnectionStringForBootstrapping:(NSString *)cs
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
NSData *configData = [configJSON dataUsingEncoding:NSUTF8StringEncoding]; NSData *configData = [configJSON dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *configDict = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:nil]; NSError *error;
NSMutableDictionary *configDict = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:&error];
NSMutableDictionary *receiverConfig = configDict[@"receiverConfig"];
NSMutableDictionary *nodeConfig = receiverConfig[@"nodeConfig"];
NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *rootUrl =[[fileManager URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; NSURL *rootUrl =[[fileManager URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject];
NSURL *rootDataDir = rootUrl.path;
NSURL *multiaccountKeystoreDir = [rootUrl URLByAppendingPathComponent:@"keystore"]; NSURL *multiaccountKeystoreDir = [rootUrl URLByAppendingPathComponent:@"keystore"];
NSString *keystoreDir = multiaccountKeystoreDir.path; NSString *keystoreDir = multiaccountKeystoreDir.path;
NSString *rootDataDir = rootUrl.path;
[configDict setValue:keystoreDir forKey:@"keystorePath"]; [receiverConfig setValue:keystoreDir forKey:@"keystorePath"];
[configDict setValue:rootDataDir forKey:@"rootDataDir"]; [nodeConfig setValue:rootDataDir forKey:@"rootDataDir"];
NSString *modifiedConfigJSON = [configDict bv_jsonStringWithPrettyPrint:NO]; NSString *modifiedConfigJSON = [configDict bv_jsonStringWithPrettyPrint:NO];
NSString *result = StatusgoInputConnectionStringForBootstrapping(cs,modifiedConfigJSON); NSString *result = StatusgoInputConnectionStringForBootstrapping(cs, modifiedConfigJSON);
callback(@[result]); callback(@[result]);
} }

View File

@ -31,10 +31,11 @@
callback callback
(fn [final-node-config] (fn [final-node-config]
(let [config-map (.stringify js/JSON (let [config-map (.stringify js/JSON
(clj->js {:kdfIterations config/default-kdf-iterations (clj->js
{:receiverConfig {:kdfIterations config/default-kdf-iterations
:nodeConfig final-node-config :nodeConfig final-node-config
:settingCurrentNetwork config/default-network :settingCurrentNetwork config/default-network
:deviceType utils.platform/os}))] :deviceType utils.platform/os}}))]
(status/input-connection-string-for-bootstrapping (status/input-connection-string-for-bootstrapping
connection-string connection-string
config-map config-map
@ -49,10 +50,11 @@
(let [sha3-pwd (status/sha3 (str (security/safe-unmask-data entered-password))) (let [sha3-pwd (status/sha3 (str (security/safe-unmask-data entered-password)))
key-uid (get-in db [:multiaccount :key-uid]) key-uid (get-in db [:multiaccount :key-uid])
config-map (.stringify js/JSON config-map (.stringify js/JSON
(clj->js {:keyUID key-uid (clj->js {:senderConfig {:keyUID key-uid
:keystorePath "" :keystorePath ""
:password sha3-pwd :password sha3-pwd
:deviceType utils.platform/os}))] :deviceType utils.platform/os}
:serverConfig {:timeout 0}}))]
(status/get-connection-string-for-bootstrapping-another-device (status/get-connection-string-for-bootstrapping-another-device
config-map config-map
(fn [connection-string] (fn [connection-string]

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>", "_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.139.1", "version": "v0.140.0",
"commit-sha1": "48eb7052848a17ab7f972112a3653f0b4cc8537a", "commit-sha1": "7cd7430d3141b08f7c455d7918f4160ea8fd0559",
"src-sha256": "0ipmjs6kmdpzyqrxw3nmrzpcmw478mnn1kv97i8khsvfvldlsjga" "src-sha256": "0lgkzrl7zas9mxpngksmh5r26j5811x9xxx9byrcqnyirmks3622"
} }