From c47fc34127600cf08d2e21cec52af8ca79c52546 Mon Sep 17 00:00:00 2001 From: Adam Babik Date: Wed, 28 Nov 2018 10:34:50 +0100 Subject: [PATCH] Use gomobile binaries for iOS and Android. Signed-off-by: Igor Mandrigin --- Makefile | 2 +- STATUS_GO_VERSION | 2 +- mobile_files/package.json.orig | 2 +- mobile_files/yarn.lock | 4 +- .../status/ethereum/module/StatusModule.java | 54 +++---- .../module/StatusNodeEventHandler.java | 5 - .../status/ethereum/module/StatusPackage.java | 14 +- .../status/ethereum/module/StatusService.java | 63 --------- .../ios/RCTStatus/RCTStatus.h | 8 +- .../ios/RCTStatus/RCTStatus.m | 133 +++++++++--------- 10 files changed, 110 insertions(+), 177 deletions(-) delete mode 100644 modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusNodeEventHandler.java delete mode 100644 modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusService.java diff --git a/Makefile b/Makefile index 03717ccd84..6f81f6c2f6 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ $(STATUS_GO_DRO_ARCH): if [ $$? -ne 0 ]; then \ echo "Failed to download from DigitalOcean Bucket, checking GitHub..."; \ curl --fail --silent --location \ - "$(GITHUB_URL)/$(STATUS_GO_VER)/status-go-android.aar" \ + "$(GITHUB_URL)/download/$(STATUS_GO_VER)/status-go-android.aar" \ --output "$(STATUS_GO_DRO_ARCH)"; \ if [ $$? -ne 0 ]; then \ echo "Failed to download from GitHub!"; \ diff --git a/STATUS_GO_VERSION b/STATUS_GO_VERSION index eeb6eac346..9c411507e4 100644 --- a/STATUS_GO_VERSION +++ b/STATUS_GO_VERSION @@ -1 +1 @@ -0.20.0-beta.0 +0.21.0g-beta.2 diff --git a/mobile_files/package.json.orig b/mobile_files/package.json.orig index 056248846e..62aeec7bc3 100644 --- a/mobile_files/package.json.orig +++ b/mobile_files/package.json.orig @@ -59,7 +59,7 @@ "react-native-svg": "6.5.2", "react-native-tcp": "git+https://github.com/status-im/react-native-tcp.git#v3.3.0-1-status", "react-native-udp": "git+https://github.com/status-im/react-native-udp.git#2.3.1-1", - "react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#0.33.16-3-status", + "react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#0.33.16-4", "react-navigation": "^2.12.1", "realm": "2.21.0", "rn-snoopy": "git+https://github.com/status-im/rn-snoopy.git#v2.0.2-status", diff --git a/mobile_files/yarn.lock b/mobile_files/yarn.lock index c93dd3e645..30c3407a6a 100644 --- a/mobile_files/yarn.lock +++ b/mobile_files/yarn.lock @@ -6059,9 +6059,9 @@ react-native-tab-view@^1.0.0: ip-regex "^1.0.3" util "^0.10.3" -"react-native-webview-bridge@git+https://github.com/status-im/react-native-webview-bridge.git#0.33.16-3-status": +"react-native-webview-bridge@git+https://github.com/status-im/react-native-webview-bridge.git#0.33.16-4": version "0.33.16" - resolved "git+https://github.com/status-im/react-native-webview-bridge.git#2e1735a1d512ad7505e55b055e36b80bfe780ba6" + resolved "git+https://github.com/status-im/react-native-webview-bridge.git#db39ab2719dd0e0d33324643820619f3e75960b4" dependencies: invariant "2.2.0" keymirror "0.1.1" 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 e482c143c0..7312bffdb2 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 @@ -24,7 +24,9 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.WritableMap; import com.facebook.react.modules.core.DeviceEventManagerModule; -import com.github.status_im.status_go.Statusgo; + +import statusgo.SignalHandler; +import statusgo.Statusgo; import org.json.JSONException; import org.json.JSONObject; @@ -48,7 +50,7 @@ import java.util.zip.ZipOutputStream; import javax.annotation.Nullable; -class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventListener, StatusNodeEventHandler { +class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventListener, SignalHandler { private static final String TAG = "StatusModule"; private static final String logsZipFileName = "Status-debug-logs.zip"; @@ -74,7 +76,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @Override public void onHostResume() { // Activity `onResume` module = this; - StatusService.INSTANCE.setSignalEventListener(this); + Statusgo.setMobileSignalHandler(this); } @Override @@ -97,9 +99,8 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL } - @Override - public void handleEvent(String jsonEvent) { - Log.d(TAG, "[handleEvent] event: " + jsonEvent); + public void handleSignal(String jsonEvent) { + Log.d(TAG, "Signal event: " + jsonEvent); WritableMap params = Arguments.createMap(); params.putString("jsonEvent", jsonEvent); this.getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("gethEvent", params); @@ -242,7 +243,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL prettyPrintConfig(updatedJsonConfigString); - String res = Statusgo.StartNode(updatedJsonConfigString); + String res = Statusgo.startNode(updatedJsonConfigString); if (res.startsWith("{\"error\":\"\"")) { Log.d(TAG, "StartNode result: " + res); Log.d(TAG, "Geth node started"); @@ -361,7 +362,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @Override public void run() { Log.d(TAG, "stopNode"); - String res = Statusgo.StopNode(); + String res = Statusgo.stopNode(); } }; @@ -379,7 +380,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.Login(address, password); + String result = Statusgo.login(address, password); callback.invoke(result); } @@ -404,7 +405,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.VerifyAccountPassword(newKeystoreDir, address, password); + String result = Statusgo.verifyAccountPassword(newKeystoreDir, address, password); callback.invoke(result); } @@ -424,7 +425,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.LoginWithKeycard(whisperPrivateKey, encryptionPublicKey); + String result = Statusgo.loginWithKeycard(whisperPrivateKey, encryptionPublicKey); callback.invoke(result); } @@ -444,7 +445,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.CreateAccount(password); + String res = Statusgo.createAccount(password); callback.invoke(res); } @@ -464,8 +465,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.SendDataNotification(dataPayloadJSON, tokensJSON); - + String res = Statusgo.sendDataNotification(dataPayloadJSON, tokensJSON); callback.invoke(res); } }; @@ -634,7 +634,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.AddPeer(enode); + String res = Statusgo.addPeer(enode); callback.invoke(res); } @@ -654,7 +654,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.RecoverAccount(password, passphrase); + String res = Statusgo.recoverAccount(password, passphrase); callback.invoke(res); } @@ -678,7 +678,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.SendTransaction(txArgsJSON, password); + String res = Statusgo.sendTransaction(txArgsJSON, password); callback.invoke(res); } }; @@ -697,7 +697,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.SignMessage(rpcParams); + String res = Statusgo.signMessage(rpcParams); callback.invoke(res); } }; @@ -795,7 +795,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.CallRPC(payload); + String res = Statusgo.callRPC(payload); callback.invoke(res); } }; @@ -808,7 +808,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.CallPrivateRPC(payload); + String res = Statusgo.callPrivateRPC(payload); callback.invoke(res); } }; @@ -824,13 +824,13 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void connectionChange(final String type, final boolean isExpensive) { Log.d(TAG, "ConnectionChange: " + type + ", is expensive " + isExpensive); - Statusgo.ConnectionChange(type, isExpensive ? 1 : 0); + Statusgo.connectionChange(type, isExpensive ? 1 : 0); } @ReactMethod public void appStateChange(final String type) { Log.d(TAG, "AppStateChange: " + type); - Statusgo.AppStateChange(type); + Statusgo.appStateChange(type); } private static String uniqueID = null; @@ -867,7 +867,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.ExtractGroupMembershipSignatures(signaturePairs); + String result = Statusgo.extractGroupMembershipSignatures(signaturePairs); callback.invoke(result); } @@ -887,7 +887,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.SignGroupMembership(content); + String result = Statusgo.signGroupMembership(content); callback.invoke(result); } @@ -907,7 +907,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.EnableInstallation(installationId); + String result = Statusgo.enableInstallation(installationId); callback.invoke(result); } @@ -927,7 +927,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.DisableInstallation(installationId); + String result = Statusgo.disableInstallation(installationId); callback.invoke(result); } @@ -947,7 +947,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.UpdateMailservers(enodes); + String res = Statusgo.updateMailservers(enodes); callback.invoke(res); } diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusNodeEventHandler.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusNodeEventHandler.java deleted file mode 100644 index 1e29d63b1a..0000000000 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusNodeEventHandler.java +++ /dev/null @@ -1,5 +0,0 @@ -package im.status.ethereum.module; - -public interface StatusNodeEventHandler { - void handleEvent(String eventJson); -} diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java index e5e3ef77d2..b47df7c76c 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java @@ -5,12 +5,12 @@ import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; -import com.github.status_im.status_go.Statusgo; -import java.util.ArrayList; import java.util.Collections; import java.util.List; + import im.status.ethereum.function.Function; +import statusgo.Statusgo; public class StatusPackage implements ReactPackage { @@ -22,12 +22,8 @@ public class StatusPackage implements ReactPackage { @Override public List createNativeModules(ReactApplicationContext reactContext) { - List modules = new ArrayList<>(); - System.loadLibrary("statusgoraw"); - System.loadLibrary("statusgo"); - modules.add(new StatusModule(reactContext, this.rootedDevice)); - - return modules; + NativeModule statusModule = new StatusModule(reactContext, this.rootedDevice); + return Collections.singletonList(statusModule); } @Override @@ -39,7 +35,7 @@ public class StatusPackage implements ReactPackage { return new Function() { @Override public String apply(String payload) { - return Statusgo.CallRPC(payload); + return Statusgo.callRPC(payload); } }; } diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusService.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusService.java deleted file mode 100644 index ce5a59787a..0000000000 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusService.java +++ /dev/null @@ -1,63 +0,0 @@ -package im.status.ethereum.module; - -import android.app.Service; -import android.content.Intent; -import android.os.*; -import android.support.annotation.Nullable; -import android.util.Log; -import java.util.concurrent.CountDownLatch; - -import java.lang.ref.WeakReference; - - -/** - * StatusService has nothing to do with Android services anymore. - * The name "StatusService" is kept to keep backward compatibility with status-go. - * Hopefully, it will be replaced when GoMobile - */ -public class StatusService { - static final StatusService INSTANCE = new StatusService(); - - private static final String TAG = "StatusService"; - - /** - * signalEvent is called by Statusgo JNI module to pass events from the node. - * @param jsonEvent - */ - public static void signalEvent(String jsonEvent) { - Log.d(TAG, "[signalEvent] event: " + jsonEvent); - StatusNodeEventHandler listener = StatusService.INSTANCE.getSignalEventListener(); - - if (listener == null) { - Log.w(TAG, "[signalEvent] no listener is set (module is missing?) ignoring event: " + jsonEvent); - return; - } - - Log.d(TAG, "[signalEvent] passing event to the listener: " + jsonEvent); - listener.handleEvent(jsonEvent); - } - - private StatusNodeEventHandler signalEventListener; - - void setSignalEventListener(StatusNodeEventHandler listener) { - Log.d(TAG, "[setSignalEventListener], setting listener to: " + this.safeClassName(listener)); - this.signalEventListener = listener; - } - - private String safeClassName(Object object) { - if (object == null) { - return "null"; - } - - if (object.getClass() == null) { - return ""; - } - - return object.getClass().getCanonicalName(); - } - - private StatusNodeEventHandler getSignalEventListener() { - return this.signalEventListener; - } - -} diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.h b/modules/react-native-status/ios/RCTStatus/RCTStatus.h index 9ce5e5b22a..f09d7fe841 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.h +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.h @@ -1,10 +1,8 @@ #import #import +#import "Statusgo/Statusgo.h" #import "RCTLog.h" -@interface Status : NSObject -+ (void)signalEvent:(const char *)signal; -+ (void)jailEvent:(NSString *)chatId - data:(NSString *)data; -+ (BOOL)JSCEnabled; +@interface Status : NSObject +- (void)handleSignal:(NSString *)signal; @end diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.m b/modules/react-native-status/ios/RCTStatus/RCTStatus.m index f6bd8ab603..d773aafa09 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.m +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.m @@ -2,7 +2,7 @@ #import "ReactNativeConfig.h" #import "React/RCTBridge.h" #import "React/RCTEventDispatcher.h" -#import +#import "Statusgo/Statusgo.h" @interface NSDictionary (BVJSONString) -(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint; @@ -45,9 +45,18 @@ } @end -static bool isStatusInitialized; static RCTBridge *bridge; -@implementation Status{ + +@implementation Status + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + // Subscribing to the signals from Status-Go + StatusgoSetMobileSignalHandler(self); + return self; } -(RCTBridge *)bridge @@ -60,6 +69,25 @@ static RCTBridge *bridge; bridge = newBridge; } +- (void)handleSignal:(NSString *)signal +{ + if(!signal){ +#if DEBUG + NSLog(@"SignalEvent nil"); +#endif + return; + } + +#if DEBUG + NSLog(@"[handleSignal] Received an event from Status-Go: %@", signal); +#endif + [bridge.eventDispatcher sendAppEventWithName:@"gethEvent" + body:@{@"jsonEvent": signal}]; + + return; +} + + RCT_EXPORT_MODULE(); //////////////////////////////////////////////////////////////////// @@ -69,6 +97,7 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString) { #if DEBUG NSLog(@"StartNode() method called"); #endif + NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error = nil; NSURL *rootUrl =[[fileManager @@ -134,8 +163,8 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { - char *res = StartNode((char *) [resultingConfig UTF8String]); - NSLog(@"StartNode result %@", [NSString stringWithUTF8String: res]); + NSString *res = StatusgoStartNode(resultingConfig); + NSLog(@"StartNode result %@", res); }); } @@ -165,8 +194,8 @@ RCT_EXPORT_METHOD(stopNode) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { - char *res = StopNode(); - NSLog(@"StopNode result %@", [NSString stringWithUTF8String: res]); + NSString *res = StatusgoStopNode(); + NSLog(@"StopNode result %@", res); }); } @@ -178,8 +207,8 @@ RCT_EXPORT_METHOD(createAccount:(NSString *)password #if DEBUG NSLog(@"CreateAccount() method called"); #endif - char * result = CreateAccount((char *) [password UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoCreateAccount(password); + callback(@[result]); } //////////////////////////////////////////////////////////////////// @@ -188,8 +217,8 @@ RCT_EXPORT_METHOD(createAccount:(NSString *)password RCT_EXPORT_METHOD(sendDataNotification:(NSString *)dataPayloadJSON tokensJSON:(NSString *)tokensJSON callback:(RCTResponseSenderBlock)callback) { - char * result = SendDataNotification((char *) [dataPayloadJSON UTF8String], (char *) [tokensJSON UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString* result = StatusgoSendDataNotification(dataPayloadJSON, tokensJSON); + callback(@[result]); #if DEBUG NSLog(@"SendDataNotification() method called"); #endif @@ -208,8 +237,8 @@ RCT_EXPORT_METHOD(sendLogs:(NSString *)dbJson) { //////////////////////////////////////////////////////////////////// addPeer RCT_EXPORT_METHOD(addPeer:(NSString *)enode callback:(RCTResponseSenderBlock)callback) { - char * result = AddPeer((char *) [enode UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoAddPeer(enode); + callback(@[result]); #if DEBUG NSLog(@"AddPeer() method called"); #endif @@ -218,8 +247,8 @@ RCT_EXPORT_METHOD(addPeer:(NSString *)enode //////////////////////////////////////////////////////////////////// updateMailservers RCT_EXPORT_METHOD(updateMailservers:(NSString *)enodes callback:(RCTResponseSenderBlock)callback) { - char * result = UpdateMailservers((char *) [enodes UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString* result = StatusgoUpdateMailservers(enodes); + callback(@[result]); #if DEBUG NSLog(@"UpdateMailservers() method called"); #endif @@ -232,8 +261,8 @@ RCT_EXPORT_METHOD(recoverAccount:(NSString *)passphrase #if DEBUG NSLog(@"RecoverAccount() method called"); #endif - char * result = RecoverAccount((char *) [password UTF8String], (char *) [passphrase UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoRecoverAccount(password, passphrase); + callback(@[result]); } //////////////////////////////////////////////////////////////////// login @@ -243,8 +272,8 @@ RCT_EXPORT_METHOD(login:(NSString *)address #if DEBUG NSLog(@"Login() method called"); #endif - char * result = Login((char *) [address UTF8String], (char *) [password UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoLogin(address, password); + callback(@[result]); } //////////////////////////////////////////////////////////////////// login @@ -260,10 +289,8 @@ RCT_EXPORT_METHOD(verify:(NSString *)address lastObject]; NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:@"keystore"]; - char * result = VerifyAccountPassword((char *) [absKeystoreUrl.path UTF8String], - (char *) [address UTF8String], - (char *) [password UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoVerifyAccountPassword(absKeystoreUrl.path, address, password); + callback(@[result]); } //////////////////////////////////////////////////////////////////// @@ -275,8 +302,8 @@ RCT_EXPORT_METHOD(sendTransaction:(NSString *)txArgsJSON #if DEBUG NSLog(@"SendTransaction() method called"); #endif - char * result = SendTransaction((char *) [txArgsJSON UTF8String], (char *) [password UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoSendTransaction(txArgsJSON, password); + callback(@[result]); } //////////////////////////////////////////////////////////////////// @@ -287,8 +314,8 @@ RCT_EXPORT_METHOD(signMessage:(NSString *)message #if DEBUG NSLog(@"SignMessage() method called"); #endif - char * result = SignMessage((char *) [message UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoSignMessage(message); + callback(@[result]); } //////////////////////////////////////////////////////////////////// @@ -299,8 +326,8 @@ RCT_EXPORT_METHOD(signGroupMembership:(NSString *)content #if DEBUG NSLog(@"SignGroupMembership() method called"); #endif - char * result = SignGroupMembership((char *) [content UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoSignGroupMembership(content); + callback(@[result]); } //////////////////////////////////////////////////////////////////// @@ -311,8 +338,8 @@ RCT_EXPORT_METHOD(extractGroupMembershipSignatures:(NSString *)content #if DEBUG NSLog(@"ExtractGroupMembershipSignatures() method called"); #endif - char * result = ExtractGroupMembershipSignatures((char *) [content UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoExtractGroupMembershipSignatures(content); + callback(@[result]); } //////////////////////////////////////////////////////////////////// @@ -323,8 +350,8 @@ RCT_EXPORT_METHOD(enableInstallation:(NSString *)content #if DEBUG NSLog(@"EnableInstallation() method called"); #endif - char * result = EnableInstallation((char *) [content UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoEnableInstallation(content); + callback(@[result]); } //////////////////////////////////////////////////////////////////// @@ -335,8 +362,8 @@ RCT_EXPORT_METHOD(disableInstallation:(NSString *)content #if DEBUG NSLog(@"DisableInstallation() method called"); #endif - char * result = DisableInstallation((char *) [content UTF8String]); - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoDisableInstallation(content); + callback(@[result]); } //////////////////////////////////////////////////////////////////// @@ -383,9 +410,9 @@ RCT_EXPORT_METHOD(clearStorageAPIs) { RCT_EXPORT_METHOD(callRPC:(NSString *)payload callback:(RCTResponseSenderBlock)callback) { dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - char * result = CallRPC((char *) [payload UTF8String]); - dispatch_async( dispatch_get_main_queue(), ^{ - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoCallRPC(payload); + dispatch_async(dispatch_get_main_queue(), ^{ + callback(@[result]); }); }); } @@ -393,9 +420,9 @@ RCT_EXPORT_METHOD(callRPC:(NSString *)payload RCT_EXPORT_METHOD(callPrivateRPC:(NSString *)payload callback:(RCTResponseSenderBlock)callback) { dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - char * result = CallPrivateRPC((char *) [payload UTF8String]); - dispatch_async( dispatch_get_main_queue(), ^{ - callback(@[[NSString stringWithUTF8String: result]]); + NSString *result = StatusgoCallPrivateRPC(payload); + dispatch_async(dispatch_get_main_queue(), ^{ + callback(@[result]); }); }); } @@ -410,14 +437,14 @@ RCT_EXPORT_METHOD(connectionChange:(NSString *)type #if DEBUG NSLog(@"ConnectionChange() method called"); #endif - ConnectionChange((char *) [type UTF8String], isExpensive? 1 : 0); + StatusgoConnectionChange(type, isExpensive ? 1 : 0); } RCT_EXPORT_METHOD(appStateChange:(NSString *)type) { #if DEBUG NSLog(@"AppStateChange() method called"); #endif - AppStateChange((char *) [type UTF8String]); + StatusgoAppStateChange(type); } RCT_EXPORT_METHOD(getDeviceUUID:(RCTResponseSenderBlock)callback) { @@ -429,26 +456,6 @@ RCT_EXPORT_METHOD(getDeviceUUID:(RCTResponseSenderBlock)callback) { callback(@[Identifier]); } -+ (void)signalEvent:(const char *) signal -{ - if(!signal){ -#if DEBUG - NSLog(@"SignalEvent nil"); -#endif - return; - } - - NSString *sig = [NSString stringWithUTF8String:signal]; -#if DEBUG - NSLog(@"SignalEvent"); - NSLog(sig); -#endif - [bridge.eventDispatcher sendAppEventWithName:@"gethEvent" - body:@{@"jsonEvent": sig}]; - - return; -} - - (bool) is24Hour { NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 locale:[NSLocale currentLocale]];