Use gomobile binaries for iOS and Android.

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
Adam Babik 2018-11-28 10:34:50 +01:00 committed by Igor Mandrigin
parent 852afa23cb
commit c47fc34127
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
10 changed files with 110 additions and 177 deletions

View File

@ -77,7 +77,7 @@ $(STATUS_GO_DRO_ARCH):
if [ $$? -ne 0 ]; then \ if [ $$? -ne 0 ]; then \
echo "Failed to download from DigitalOcean Bucket, checking GitHub..."; \ echo "Failed to download from DigitalOcean Bucket, checking GitHub..."; \
curl --fail --silent --location \ 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)"; \ --output "$(STATUS_GO_DRO_ARCH)"; \
if [ $$? -ne 0 ]; then \ if [ $$? -ne 0 ]; then \
echo "Failed to download from GitHub!"; \ echo "Failed to download from GitHub!"; \

View File

@ -1 +1 @@
0.20.0-beta.0 0.21.0g-beta.2

View File

@ -59,7 +59,7 @@
"react-native-svg": "6.5.2", "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-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-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", "react-navigation": "^2.12.1",
"realm": "2.21.0", "realm": "2.21.0",
"rn-snoopy": "git+https://github.com/status-im/rn-snoopy.git#v2.0.2-status", "rn-snoopy": "git+https://github.com/status-im/rn-snoopy.git#v2.0.2-status",

View File

@ -6059,9 +6059,9 @@ react-native-tab-view@^1.0.0:
ip-regex "^1.0.3" ip-regex "^1.0.3"
util "^0.10.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" 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: dependencies:
invariant "2.2.0" invariant "2.2.0"
keymirror "0.1.1" keymirror "0.1.1"

View File

@ -24,7 +24,9 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule; 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.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -48,7 +50,7 @@ import java.util.zip.ZipOutputStream;
import javax.annotation.Nullable; 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 TAG = "StatusModule";
private static final String logsZipFileName = "Status-debug-logs.zip"; private static final String logsZipFileName = "Status-debug-logs.zip";
@ -74,7 +76,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
@Override @Override
public void onHostResume() { // Activity `onResume` public void onHostResume() { // Activity `onResume`
module = this; module = this;
StatusService.INSTANCE.setSignalEventListener(this); Statusgo.setMobileSignalHandler(this);
} }
@Override @Override
@ -97,9 +99,8 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
} }
@Override public void handleSignal(String jsonEvent) {
public void handleEvent(String jsonEvent) { Log.d(TAG, "Signal event: " + jsonEvent);
Log.d(TAG, "[handleEvent] event: " + jsonEvent);
WritableMap params = Arguments.createMap(); WritableMap params = Arguments.createMap();
params.putString("jsonEvent", jsonEvent); params.putString("jsonEvent", jsonEvent);
this.getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("gethEvent", params); this.getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("gethEvent", params);
@ -242,7 +243,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
prettyPrintConfig(updatedJsonConfigString); prettyPrintConfig(updatedJsonConfigString);
String res = Statusgo.StartNode(updatedJsonConfigString); String res = Statusgo.startNode(updatedJsonConfigString);
if (res.startsWith("{\"error\":\"\"")) { if (res.startsWith("{\"error\":\"\"")) {
Log.d(TAG, "StartNode result: " + res); Log.d(TAG, "StartNode result: " + res);
Log.d(TAG, "Geth node started"); Log.d(TAG, "Geth node started");
@ -361,7 +362,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
@Override @Override
public void run() { public void run() {
Log.d(TAG, "stopNode"); 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() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String result = Statusgo.Login(address, password); String result = Statusgo.login(address, password);
callback.invoke(result); callback.invoke(result);
} }
@ -404,7 +405,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String result = Statusgo.VerifyAccountPassword(newKeystoreDir, address, password); String result = Statusgo.verifyAccountPassword(newKeystoreDir, address, password);
callback.invoke(result); callback.invoke(result);
} }
@ -424,7 +425,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String result = Statusgo.LoginWithKeycard(whisperPrivateKey, encryptionPublicKey); String result = Statusgo.loginWithKeycard(whisperPrivateKey, encryptionPublicKey);
callback.invoke(result); callback.invoke(result);
} }
@ -444,7 +445,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String res = Statusgo.CreateAccount(password); String res = Statusgo.createAccount(password);
callback.invoke(res); callback.invoke(res);
} }
@ -464,8 +465,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String res = Statusgo.SendDataNotification(dataPayloadJSON, tokensJSON); String res = Statusgo.sendDataNotification(dataPayloadJSON, tokensJSON);
callback.invoke(res); callback.invoke(res);
} }
}; };
@ -634,7 +634,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String res = Statusgo.AddPeer(enode); String res = Statusgo.addPeer(enode);
callback.invoke(res); callback.invoke(res);
} }
@ -654,7 +654,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String res = Statusgo.RecoverAccount(password, passphrase); String res = Statusgo.recoverAccount(password, passphrase);
callback.invoke(res); callback.invoke(res);
} }
@ -678,7 +678,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String res = Statusgo.SendTransaction(txArgsJSON, password); String res = Statusgo.sendTransaction(txArgsJSON, password);
callback.invoke(res); callback.invoke(res);
} }
}; };
@ -697,7 +697,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String res = Statusgo.SignMessage(rpcParams); String res = Statusgo.signMessage(rpcParams);
callback.invoke(res); callback.invoke(res);
} }
}; };
@ -795,7 +795,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String res = Statusgo.CallRPC(payload); String res = Statusgo.callRPC(payload);
callback.invoke(res); callback.invoke(res);
} }
}; };
@ -808,7 +808,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String res = Statusgo.CallPrivateRPC(payload); String res = Statusgo.callPrivateRPC(payload);
callback.invoke(res); callback.invoke(res);
} }
}; };
@ -824,13 +824,13 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
@ReactMethod @ReactMethod
public void connectionChange(final String type, final boolean isExpensive) { public void connectionChange(final String type, final boolean isExpensive) {
Log.d(TAG, "ConnectionChange: " + type + ", is expensive " + isExpensive); Log.d(TAG, "ConnectionChange: " + type + ", is expensive " + isExpensive);
Statusgo.ConnectionChange(type, isExpensive ? 1 : 0); Statusgo.connectionChange(type, isExpensive ? 1 : 0);
} }
@ReactMethod @ReactMethod
public void appStateChange(final String type) { public void appStateChange(final String type) {
Log.d(TAG, "AppStateChange: " + type); Log.d(TAG, "AppStateChange: " + type);
Statusgo.AppStateChange(type); Statusgo.appStateChange(type);
} }
private static String uniqueID = null; private static String uniqueID = null;
@ -867,7 +867,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String result = Statusgo.ExtractGroupMembershipSignatures(signaturePairs); String result = Statusgo.extractGroupMembershipSignatures(signaturePairs);
callback.invoke(result); callback.invoke(result);
} }
@ -887,7 +887,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String result = Statusgo.SignGroupMembership(content); String result = Statusgo.signGroupMembership(content);
callback.invoke(result); callback.invoke(result);
} }
@ -907,7 +907,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String result = Statusgo.EnableInstallation(installationId); String result = Statusgo.enableInstallation(installationId);
callback.invoke(result); callback.invoke(result);
} }
@ -927,7 +927,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String result = Statusgo.DisableInstallation(installationId); String result = Statusgo.disableInstallation(installationId);
callback.invoke(result); callback.invoke(result);
} }
@ -947,7 +947,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override @Override
public void run() { public void run() {
String res = Statusgo.UpdateMailservers(enodes); String res = Statusgo.updateMailservers(enodes);
callback.invoke(res); callback.invoke(res);
} }

View File

@ -1,5 +0,0 @@
package im.status.ethereum.module;
public interface StatusNodeEventHandler {
void handleEvent(String eventJson);
}

View File

@ -5,12 +5,12 @@ import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager; 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.Collections;
import java.util.List; import java.util.List;
import im.status.ethereum.function.Function; import im.status.ethereum.function.Function;
import statusgo.Statusgo;
public class StatusPackage implements ReactPackage { public class StatusPackage implements ReactPackage {
@ -22,12 +22,8 @@ public class StatusPackage implements ReactPackage {
@Override @Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>(); NativeModule statusModule = new StatusModule(reactContext, this.rootedDevice);
System.loadLibrary("statusgoraw"); return Collections.singletonList(statusModule);
System.loadLibrary("statusgo");
modules.add(new StatusModule(reactContext, this.rootedDevice));
return modules;
} }
@Override @Override
@ -39,7 +35,7 @@ public class StatusPackage implements ReactPackage {
return new Function<String, String>() { return new Function<String, String>() {
@Override @Override
public String apply(String payload) { public String apply(String payload) {
return Statusgo.CallRPC(payload); return Statusgo.callRPC(payload);
} }
}; };
} }

View File

@ -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 "<unknown object>";
}
return object.getClass().getCanonicalName();
}
private StatusNodeEventHandler getSignalEventListener() {
return this.signalEventListener;
}
}

View File

@ -1,10 +1,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h> #import <React/RCTBridgeModule.h>
#import "Statusgo/Statusgo.h"
#import "RCTLog.h" #import "RCTLog.h"
@interface Status : NSObject <RCTBridgeModule> @interface Status : NSObject <RCTBridgeModule, StatusgoSignalHandler>
+ (void)signalEvent:(const char *)signal; - (void)handleSignal:(NSString *)signal;
+ (void)jailEvent:(NSString *)chatId
data:(NSString *)data;
+ (BOOL)JSCEnabled;
@end @end

View File

@ -2,7 +2,7 @@
#import "ReactNativeConfig.h" #import "ReactNativeConfig.h"
#import "React/RCTBridge.h" #import "React/RCTBridge.h"
#import "React/RCTEventDispatcher.h" #import "React/RCTEventDispatcher.h"
#import <Statusgo/Statusgo.h> #import "Statusgo/Statusgo.h"
@interface NSDictionary (BVJSONString) @interface NSDictionary (BVJSONString)
-(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint; -(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint;
@ -45,9 +45,18 @@
} }
@end @end
static bool isStatusInitialized;
static RCTBridge *bridge; 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 -(RCTBridge *)bridge
@ -60,6 +69,25 @@ static RCTBridge *bridge;
bridge = newBridge; 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(); RCT_EXPORT_MODULE();
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -69,6 +97,7 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString) {
#if DEBUG #if DEBUG
NSLog(@"StartNode() method called"); NSLog(@"StartNode() method called");
#endif #endif
NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil; NSError *error = nil;
NSURL *rootUrl =[[fileManager NSURL *rootUrl =[[fileManager
@ -134,8 +163,8 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^(void) ^(void)
{ {
char *res = StartNode((char *) [resultingConfig UTF8String]); NSString *res = StatusgoStartNode(resultingConfig);
NSLog(@"StartNode result %@", [NSString stringWithUTF8String: res]); NSLog(@"StartNode result %@", res);
}); });
} }
@ -165,8 +194,8 @@ RCT_EXPORT_METHOD(stopNode) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^(void) ^(void)
{ {
char *res = StopNode(); NSString *res = StatusgoStopNode();
NSLog(@"StopNode result %@", [NSString stringWithUTF8String: res]); NSLog(@"StopNode result %@", res);
}); });
} }
@ -178,8 +207,8 @@ RCT_EXPORT_METHOD(createAccount:(NSString *)password
#if DEBUG #if DEBUG
NSLog(@"CreateAccount() method called"); NSLog(@"CreateAccount() method called");
#endif #endif
char * result = CreateAccount((char *) [password UTF8String]); NSString *result = StatusgoCreateAccount(password);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -188,8 +217,8 @@ RCT_EXPORT_METHOD(createAccount:(NSString *)password
RCT_EXPORT_METHOD(sendDataNotification:(NSString *)dataPayloadJSON RCT_EXPORT_METHOD(sendDataNotification:(NSString *)dataPayloadJSON
tokensJSON:(NSString *)tokensJSON tokensJSON:(NSString *)tokensJSON
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
char * result = SendDataNotification((char *) [dataPayloadJSON UTF8String], (char *) [tokensJSON UTF8String]); NSString* result = StatusgoSendDataNotification(dataPayloadJSON, tokensJSON);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
#if DEBUG #if DEBUG
NSLog(@"SendDataNotification() method called"); NSLog(@"SendDataNotification() method called");
#endif #endif
@ -208,8 +237,8 @@ RCT_EXPORT_METHOD(sendLogs:(NSString *)dbJson) {
//////////////////////////////////////////////////////////////////// addPeer //////////////////////////////////////////////////////////////////// addPeer
RCT_EXPORT_METHOD(addPeer:(NSString *)enode RCT_EXPORT_METHOD(addPeer:(NSString *)enode
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
char * result = AddPeer((char *) [enode UTF8String]); NSString *result = StatusgoAddPeer(enode);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
#if DEBUG #if DEBUG
NSLog(@"AddPeer() method called"); NSLog(@"AddPeer() method called");
#endif #endif
@ -218,8 +247,8 @@ RCT_EXPORT_METHOD(addPeer:(NSString *)enode
//////////////////////////////////////////////////////////////////// updateMailservers //////////////////////////////////////////////////////////////////// updateMailservers
RCT_EXPORT_METHOD(updateMailservers:(NSString *)enodes RCT_EXPORT_METHOD(updateMailservers:(NSString *)enodes
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
char * result = UpdateMailservers((char *) [enodes UTF8String]); NSString* result = StatusgoUpdateMailservers(enodes);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
#if DEBUG #if DEBUG
NSLog(@"UpdateMailservers() method called"); NSLog(@"UpdateMailservers() method called");
#endif #endif
@ -232,8 +261,8 @@ RCT_EXPORT_METHOD(recoverAccount:(NSString *)passphrase
#if DEBUG #if DEBUG
NSLog(@"RecoverAccount() method called"); NSLog(@"RecoverAccount() method called");
#endif #endif
char * result = RecoverAccount((char *) [password UTF8String], (char *) [passphrase UTF8String]); NSString *result = StatusgoRecoverAccount(password, passphrase);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
} }
//////////////////////////////////////////////////////////////////// login //////////////////////////////////////////////////////////////////// login
@ -243,8 +272,8 @@ RCT_EXPORT_METHOD(login:(NSString *)address
#if DEBUG #if DEBUG
NSLog(@"Login() method called"); NSLog(@"Login() method called");
#endif #endif
char * result = Login((char *) [address UTF8String], (char *) [password UTF8String]); NSString *result = StatusgoLogin(address, password);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
} }
//////////////////////////////////////////////////////////////////// login //////////////////////////////////////////////////////////////////// login
@ -260,10 +289,8 @@ RCT_EXPORT_METHOD(verify:(NSString *)address
lastObject]; lastObject];
NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:@"keystore"]; NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:@"keystore"];
char * result = VerifyAccountPassword((char *) [absKeystoreUrl.path UTF8String], NSString *result = StatusgoVerifyAccountPassword(absKeystoreUrl.path, address, password);
(char *) [address UTF8String], callback(@[result]);
(char *) [password UTF8String]);
callback(@[[NSString stringWithUTF8String: result]]);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -275,8 +302,8 @@ RCT_EXPORT_METHOD(sendTransaction:(NSString *)txArgsJSON
#if DEBUG #if DEBUG
NSLog(@"SendTransaction() method called"); NSLog(@"SendTransaction() method called");
#endif #endif
char * result = SendTransaction((char *) [txArgsJSON UTF8String], (char *) [password UTF8String]); NSString *result = StatusgoSendTransaction(txArgsJSON, password);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -287,8 +314,8 @@ RCT_EXPORT_METHOD(signMessage:(NSString *)message
#if DEBUG #if DEBUG
NSLog(@"SignMessage() method called"); NSLog(@"SignMessage() method called");
#endif #endif
char * result = SignMessage((char *) [message UTF8String]); NSString *result = StatusgoSignMessage(message);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -299,8 +326,8 @@ RCT_EXPORT_METHOD(signGroupMembership:(NSString *)content
#if DEBUG #if DEBUG
NSLog(@"SignGroupMembership() method called"); NSLog(@"SignGroupMembership() method called");
#endif #endif
char * result = SignGroupMembership((char *) [content UTF8String]); NSString *result = StatusgoSignGroupMembership(content);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -311,8 +338,8 @@ RCT_EXPORT_METHOD(extractGroupMembershipSignatures:(NSString *)content
#if DEBUG #if DEBUG
NSLog(@"ExtractGroupMembershipSignatures() method called"); NSLog(@"ExtractGroupMembershipSignatures() method called");
#endif #endif
char * result = ExtractGroupMembershipSignatures((char *) [content UTF8String]); NSString *result = StatusgoExtractGroupMembershipSignatures(content);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -323,8 +350,8 @@ RCT_EXPORT_METHOD(enableInstallation:(NSString *)content
#if DEBUG #if DEBUG
NSLog(@"EnableInstallation() method called"); NSLog(@"EnableInstallation() method called");
#endif #endif
char * result = EnableInstallation((char *) [content UTF8String]); NSString *result = StatusgoEnableInstallation(content);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -335,8 +362,8 @@ RCT_EXPORT_METHOD(disableInstallation:(NSString *)content
#if DEBUG #if DEBUG
NSLog(@"DisableInstallation() method called"); NSLog(@"DisableInstallation() method called");
#endif #endif
char * result = DisableInstallation((char *) [content UTF8String]); NSString *result = StatusgoDisableInstallation(content);
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -383,9 +410,9 @@ RCT_EXPORT_METHOD(clearStorageAPIs) {
RCT_EXPORT_METHOD(callRPC:(NSString *)payload RCT_EXPORT_METHOD(callRPC:(NSString *)payload
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
char * result = CallRPC((char *) [payload UTF8String]); NSString *result = StatusgoCallRPC(payload);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
}); });
}); });
} }
@ -393,9 +420,9 @@ RCT_EXPORT_METHOD(callRPC:(NSString *)payload
RCT_EXPORT_METHOD(callPrivateRPC:(NSString *)payload RCT_EXPORT_METHOD(callPrivateRPC:(NSString *)payload
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
char * result = CallPrivateRPC((char *) [payload UTF8String]); NSString *result = StatusgoCallPrivateRPC(payload);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
callback(@[[NSString stringWithUTF8String: result]]); callback(@[result]);
}); });
}); });
} }
@ -410,14 +437,14 @@ RCT_EXPORT_METHOD(connectionChange:(NSString *)type
#if DEBUG #if DEBUG
NSLog(@"ConnectionChange() method called"); NSLog(@"ConnectionChange() method called");
#endif #endif
ConnectionChange((char *) [type UTF8String], isExpensive? 1 : 0); StatusgoConnectionChange(type, isExpensive ? 1 : 0);
} }
RCT_EXPORT_METHOD(appStateChange:(NSString *)type) { RCT_EXPORT_METHOD(appStateChange:(NSString *)type) {
#if DEBUG #if DEBUG
NSLog(@"AppStateChange() method called"); NSLog(@"AppStateChange() method called");
#endif #endif
AppStateChange((char *) [type UTF8String]); StatusgoAppStateChange(type);
} }
RCT_EXPORT_METHOD(getDeviceUUID:(RCTResponseSenderBlock)callback) { RCT_EXPORT_METHOD(getDeviceUUID:(RCTResponseSenderBlock)callback) {
@ -429,26 +456,6 @@ RCT_EXPORT_METHOD(getDeviceUUID:(RCTResponseSenderBlock)callback) {
callback(@[Identifier]); 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 - (bool) is24Hour
{ {
NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 locale:[NSLocale currentLocale]]; NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 locale:[NSLocale currentLocale]];