2016-09-07 17:35:04 +00:00
|
|
|
#import "RCTStatus.h"
|
2017-10-17 10:56:14 +00:00
|
|
|
#import "ReactNativeConfig.h"
|
2017-04-24 14:50:16 +00:00
|
|
|
#import "React/RCTBridge.h"
|
|
|
|
#import "React/RCTEventDispatcher.h"
|
2021-03-29 16:23:40 +00:00
|
|
|
#import "Statusgo.h"
|
|
|
|
#import "SSZipArchive.h"
|
2017-05-22 08:43:13 +00:00
|
|
|
|
|
|
|
@interface NSDictionary (BVJSONString)
|
|
|
|
-(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSDictionary (BVJSONString)
|
|
|
|
|
|
|
|
-(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint {
|
|
|
|
NSError *error;
|
|
|
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self
|
|
|
|
options:(NSJSONWritingOptions) (prettyPrint ? NSJSONWritingPrettyPrinted : 0)
|
|
|
|
error:&error];
|
2018-05-23 08:41:59 +00:00
|
|
|
|
2017-05-22 08:43:13 +00:00
|
|
|
if (! jsonData) {
|
|
|
|
NSLog(@"bv_jsonStringWithPrettyPrint: error: %@", error.localizedDescription);
|
|
|
|
return @"{}";
|
|
|
|
} else {
|
|
|
|
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSArray (BVJSONString)
|
|
|
|
- (NSString *)bv_jsonStringWithPrettyPrint:(BOOL)prettyPrint;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSArray (BVJSONString)
|
|
|
|
-(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint {
|
|
|
|
NSError *error;
|
|
|
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self
|
|
|
|
options:(NSJSONWritingOptions) (prettyPrint ? NSJSONWritingPrettyPrinted : 0)
|
|
|
|
error:&error];
|
2018-05-23 08:41:59 +00:00
|
|
|
|
2017-05-22 08:43:13 +00:00
|
|
|
if (! jsonData) {
|
|
|
|
NSLog(@"bv_jsonStringWithPrettyPrint: error: %@", error.localizedDescription);
|
|
|
|
return @"[]";
|
|
|
|
} else {
|
|
|
|
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
2016-09-07 17:35:04 +00:00
|
|
|
|
2016-10-11 14:24:52 +00:00
|
|
|
static RCTBridge *bridge;
|
2019-02-12 11:35:26 +00:00
|
|
|
|
|
|
|
@implementation Status
|
|
|
|
|
|
|
|
- (instancetype)init {
|
|
|
|
self = [super init];
|
|
|
|
if (!self) {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
// Subscribing to the signals from Status-Go
|
|
|
|
StatusgoSetMobileSignalHandler(self);
|
|
|
|
return self;
|
2016-09-12 08:16:07 +00:00
|
|
|
}
|
|
|
|
|
2016-10-11 14:24:52 +00:00
|
|
|
-(RCTBridge *)bridge
|
|
|
|
{
|
|
|
|
return bridge;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setBridge:(RCTBridge *)newBridge
|
|
|
|
{
|
|
|
|
bridge = newBridge;
|
|
|
|
}
|
2016-09-07 17:35:04 +00:00
|
|
|
|
2019-02-12 11:35:26 +00:00
|
|
|
- (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;
|
|
|
|
}
|
|
|
|
|
2016-09-07 17:35:04 +00:00
|
|
|
RCT_EXPORT_MODULE();
|
|
|
|
|
2017-03-07 17:29:59 +00:00
|
|
|
#pragma mark - shouldMoveToInternalStorage
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2017-03-07 17:29:59 +00:00
|
|
|
RCT_EXPORT_METHOD(shouldMoveToInternalStorage:(RCTResponseSenderBlock)onResultCallback) {
|
|
|
|
// Android only
|
|
|
|
onResultCallback(@[[NSNull null]]);
|
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2017-03-07 17:29:59 +00:00
|
|
|
#pragma mark - moveToInternalStorage
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2017-03-07 17:29:59 +00:00
|
|
|
RCT_EXPORT_METHOD(moveToInternalStorage:(RCTResponseSenderBlock)onResultCallback) {
|
|
|
|
// Android only
|
|
|
|
onResultCallback(@[[NSNull null]]);
|
|
|
|
}
|
|
|
|
|
2016-09-12 08:16:07 +00:00
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2019-07-31 16:10:38 +00:00
|
|
|
#pragma mark - InitKeystore method
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2020-07-09 10:14:38 +00:00
|
|
|
RCT_EXPORT_METHOD(initKeystore:(NSString *)keyUID
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
2019-07-31 16:10:38 +00:00
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"initKeystore() method called");
|
|
|
|
#endif
|
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
NSURL *rootUrl =[[fileManager
|
2019-08-26 07:39:13 +00:00
|
|
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
2019-07-31 16:10:38 +00:00
|
|
|
lastObject];
|
|
|
|
|
2020-07-09 10:14:38 +00:00
|
|
|
NSURL *commonKeystoreDir = [rootUrl URLByAppendingPathComponent:@"keystore"];
|
|
|
|
NSURL *keystoreDir = [commonKeystoreDir URLByAppendingPathComponent:keyUID];
|
2020-11-25 09:30:00 +00:00
|
|
|
|
2019-07-31 16:10:38 +00:00
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
|
|
|
|
^(void)
|
|
|
|
{
|
|
|
|
NSString *res = StatusgoInitKeystore(keystoreDir.path);
|
2020-01-08 14:41:07 +00:00
|
|
|
NSLog(@"InitKeyStore result %@", res);
|
2020-07-09 10:14:38 +00:00
|
|
|
callback(@[]);
|
2019-07-31 16:10:38 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2018-12-15 18:57:00 +00:00
|
|
|
#pragma mark - SendLogs method
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2019-05-03 14:22:43 +00:00
|
|
|
RCT_EXPORT_METHOD(sendLogs:(NSString *)dbJson
|
2019-04-30 11:49:45 +00:00
|
|
|
jsLogs:(NSString *)jsLogs
|
2019-05-03 14:22:43 +00:00
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
2018-12-15 18:57:00 +00:00
|
|
|
// TODO: Implement SendLogs for iOS
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"SendLogs() method called, not implemented");
|
|
|
|
#endif
|
2019-05-03 14:22:43 +00:00
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
NSError *error = nil;
|
|
|
|
NSURL *rootUrl =[[fileManager
|
2019-08-26 07:39:13 +00:00
|
|
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
2019-05-03 14:22:43 +00:00
|
|
|
lastObject];
|
2019-04-30 11:49:45 +00:00
|
|
|
|
2019-05-03 14:22:43 +00:00
|
|
|
NSURL *zipFile = [rootUrl URLByAppendingPathComponent:@"logs.zip"];
|
|
|
|
[fileManager removeItemAtPath:zipFile.path error:nil];
|
2019-04-30 11:49:45 +00:00
|
|
|
|
2019-05-03 14:22:43 +00:00
|
|
|
NSURL *logsFolderName = [rootUrl URLByAppendingPathComponent:@"logs"];
|
2019-04-30 11:49:45 +00:00
|
|
|
|
2019-05-03 14:22:43 +00:00
|
|
|
if (![fileManager fileExistsAtPath:logsFolderName.path])
|
|
|
|
[fileManager createDirectoryAtPath:logsFolderName.path withIntermediateDirectories:YES attributes:nil error:&error];
|
2019-04-30 11:49:45 +00:00
|
|
|
|
2019-05-03 14:22:43 +00:00
|
|
|
NSURL *dbFile = [logsFolderName URLByAppendingPathComponent:@"db.json"];
|
2019-04-30 11:49:45 +00:00
|
|
|
NSURL *jsLogsFile = [logsFolderName URLByAppendingPathComponent:@"Status.log"];
|
2019-05-03 14:22:43 +00:00
|
|
|
#if DEBUG
|
|
|
|
NSString *networkDirPath = @"ethereum/mainnet_rpc_dev";
|
|
|
|
#else
|
|
|
|
NSString *networkDirPath = @"ethereum/mainnet_rpc";
|
|
|
|
#endif
|
2019-04-30 11:49:45 +00:00
|
|
|
|
2022-10-04 11:33:25 +00:00
|
|
|
#if DEBUG
|
|
|
|
NSString *goerliNetworkDirPath = @"ethereum/goerli_rpc_dev";
|
|
|
|
#else
|
|
|
|
NSString *goerliNetworkDirPath = @"ethereum/goerli_rpc";
|
|
|
|
#endif
|
|
|
|
|
2019-05-03 14:22:43 +00:00
|
|
|
NSURL *networkDir = [rootUrl URLByAppendingPathComponent:networkDirPath];
|
|
|
|
NSURL *originalGethLogsFile = [networkDir URLByAppendingPathComponent:@"geth.log"];
|
2022-10-09 14:09:18 +00:00
|
|
|
NSURL *gethLogsFile = [logsFolderName URLByAppendingPathComponent:@"mainnet_geth.log"];
|
2019-04-30 11:49:45 +00:00
|
|
|
|
2022-10-04 11:33:25 +00:00
|
|
|
NSURL *goerliNetworkDir = [rootUrl URLByAppendingPathComponent:goerliNetworkDirPath];
|
|
|
|
NSURL *goerliGethLogsFile = [goerliNetworkDir URLByAppendingPathComponent:@"geth.log"];
|
|
|
|
NSURL *goerliLogsFile = [logsFolderName URLByAppendingPathComponent:@"goerli_geth.log"];
|
|
|
|
|
2022-10-09 14:09:18 +00:00
|
|
|
NSURL *mainGethLogsFile = [rootUrl URLByAppendingPathComponent:@"geth.log"];
|
|
|
|
NSURL *mainLogsFile = [logsFolderName URLByAppendingPathComponent:@"geth.log"];
|
|
|
|
|
2019-05-03 14:22:43 +00:00
|
|
|
[dbJson writeToFile:dbFile.path atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
2019-04-30 11:49:45 +00:00
|
|
|
[jsLogs writeToFile:jsLogsFile.path atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
|
|
|
|
2019-05-03 14:22:43 +00:00
|
|
|
//NSString* gethLogs = StatusgoExportNodeLogs();
|
|
|
|
//[gethLogs writeToFile:gethLogsFile.path atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
|
|
|
[fileManager copyItemAtPath:originalGethLogsFile.path toPath:gethLogsFile.path error:nil];
|
2022-10-04 11:33:25 +00:00
|
|
|
[fileManager copyItemAtPath:goerliGethLogsFile.path toPath:goerliLogsFile.path error:nil];
|
2022-10-09 14:09:18 +00:00
|
|
|
[fileManager copyItemAtPath:mainGethLogsFile.path toPath:mainLogsFile.path error:nil];
|
2019-04-30 11:49:45 +00:00
|
|
|
|
2019-05-03 14:22:43 +00:00
|
|
|
[SSZipArchive createZipFileAtPath:zipFile.path withContentsOfDirectory:logsFolderName.path];
|
|
|
|
[fileManager removeItemAtPath:logsFolderName.path error:nil];
|
2019-04-30 11:49:45 +00:00
|
|
|
|
2021-09-02 12:24:09 +00:00
|
|
|
callback(@[zipFile.absoluteString]);
|
2019-05-03 14:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(exportLogs:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"exportLogs() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoExportNodeLogs();
|
|
|
|
callback(@[result]);
|
2018-12-15 18:57:00 +00:00
|
|
|
}
|
|
|
|
|
2017-12-05 10:18:30 +00:00
|
|
|
RCT_EXPORT_METHOD(addPeer:(NSString *)enode
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
2019-02-12 11:35:26 +00:00
|
|
|
NSString *result = StatusgoAddPeer(enode);
|
|
|
|
callback(@[result]);
|
2017-12-05 10:18:30 +00:00
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"AddPeer() method called");
|
|
|
|
#endif
|
|
|
|
}
|
2017-09-16 07:08:47 +00:00
|
|
|
|
2020-07-14 13:33:59 +00:00
|
|
|
RCT_EXPORT_METHOD(deleteMultiaccount:(NSString *)keyUID
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
2021-08-13 07:53:40 +00:00
|
|
|
NSLog(@"DeleteMultiaccount() method called");
|
2020-07-14 13:33:59 +00:00
|
|
|
#endif
|
|
|
|
NSURL *multiaccountKeystoreDir = [self getKeyStoreDir:keyUID];
|
|
|
|
NSString *result = StatusgoDeleteMultiaccount(keyUID, multiaccountKeystoreDir.path);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2021-08-13 07:53:40 +00:00
|
|
|
RCT_EXPORT_METHOD(deleteImportedKey:(NSString *)keyUID
|
|
|
|
address:(NSString *)address
|
|
|
|
password:(NSString *)password
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"DeleteImportedKey() method called");
|
|
|
|
#endif
|
|
|
|
NSURL *multiaccountKeystoreDir = [self getKeyStoreDir:keyUID];
|
|
|
|
NSString *result = StatusgoDeleteImportedKey(address, password, multiaccountKeystoreDir.path);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2019-07-19 14:11:10 +00:00
|
|
|
RCT_EXPORT_METHOD(multiAccountGenerateAndDeriveAddresses:(NSString *)json
|
2019-05-13 07:58:41 +00:00
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
2019-07-19 14:11:10 +00:00
|
|
|
NSLog(@"MultiAccountGenerateAndDeriveAddresses() method called");
|
2019-05-13 07:58:41 +00:00
|
|
|
#endif
|
2019-07-19 14:11:10 +00:00
|
|
|
NSString *result = StatusgoMultiAccountGenerateAndDeriveAddresses(json);
|
2019-05-13 07:58:41 +00:00
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2019-08-12 08:53:31 +00:00
|
|
|
RCT_EXPORT_METHOD(multiAccountStoreAccount:(NSString *)json
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"MultiAccountStoreAccount() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoMultiAccountStoreAccount(json);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(multiAccountLoadAccount:(NSString *)json
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"MultiAccountLoadAccount() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoMultiAccountLoadAccount(json);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(multiAccountReset:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"MultiAccountReset() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoMultiAccountReset();
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2019-07-19 14:11:10 +00:00
|
|
|
RCT_EXPORT_METHOD(multiAccountStoreDerived:(NSString *)json
|
2019-05-13 07:58:41 +00:00
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
2019-07-19 14:11:10 +00:00
|
|
|
NSLog(@"MultiAccountStoreDerived() method called");
|
2019-05-13 07:58:41 +00:00
|
|
|
#endif
|
2019-07-19 14:11:10 +00:00
|
|
|
NSString *result = StatusgoMultiAccountStoreDerivedAccounts(json);
|
2019-05-13 07:58:41 +00:00
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2020-02-28 11:37:16 +00:00
|
|
|
RCT_EXPORT_METHOD(multiAccountImportPrivateKey:(NSString *)json
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"MultiAccountImportPrivateKey() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoMultiAccountImportPrivateKey(json);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2020-05-07 10:57:10 +00:00
|
|
|
RCT_EXPORT_METHOD(hashTransaction:(NSString *)txArgsJSON
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"HashTransaction() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoHashTransaction(txArgsJSON);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2020-11-25 09:30:00 +00:00
|
|
|
RCT_EXPORT_METHOD(hashMessage:(NSString *)message
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"hashMessage() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoHashMessage(message);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2022-12-16 13:10:56 +00:00
|
|
|
RCT_EXPORT_METHOD(getConnectionStringForBootstrappingAnotherDevice:(NSString *)configJSON
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
|
|
|
|
NSData *configData = [configJSON dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
NSDictionary *configDict = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:nil];
|
|
|
|
NSString *keyUID = [configDict objectForKey:@"keyUID"];
|
|
|
|
NSURL *multiaccountKeystoreDir = [self getKeyStoreDir:keyUID];
|
|
|
|
NSString *keystoreDir = multiaccountKeystoreDir.path;
|
|
|
|
|
|
|
|
[configDict setValue:keystoreDir forKey:@"keystorePath"];
|
|
|
|
NSString *modifiedConfigJSON = [configDict bv_jsonStringWithPrettyPrint:NO];
|
|
|
|
|
|
|
|
NSString *result = StatusgoGetConnectionStringForBootstrappingAnotherDevice(modifiedConfigJSON);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(inputConnectionStringForBootstrapping:(NSString *)cs
|
|
|
|
configJSON:(NSString *)configJSON
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
|
|
|
|
NSData *configData = [configJSON dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
NSDictionary *configDict = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:nil];
|
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
NSURL *rootUrl =[[fileManager URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject];
|
|
|
|
NSURL *multiaccountKeystoreDir = [rootUrl URLByAppendingPathComponent:@"keystore"];
|
|
|
|
NSString *keystoreDir = multiaccountKeystoreDir.path;
|
|
|
|
|
|
|
|
[configDict setValue:keystoreDir forKey:@"keystorePath"];
|
|
|
|
NSString *modifiedConfigJSON = [configDict bv_jsonStringWithPrettyPrint:NO];
|
|
|
|
|
|
|
|
NSString *result = StatusgoInputConnectionStringForBootstrapping(cs,modifiedConfigJSON);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2023-01-04 12:54:11 +00:00
|
|
|
RCT_EXPORT_METHOD(multiformatSerializePublicKey:(NSString *)multiCodecKey
|
|
|
|
base58btc:(NSString *)base58btc
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
NSString *result = StatusgoMultiformatSerializePublicKey(multiCodecKey,base58btc);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(multiformatDeserializePublicKey:(NSString *)multiCodecKey
|
|
|
|
base58btc:(NSString *)base58btc
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
NSString *result = StatusgoMultiformatDeserializePublicKey(multiCodecKey,base58btc);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(decompressPublicKey:(NSString *)multiCodecKey
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
NSString *result = StatusgoDecompressPublicKey(multiCodecKey);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(compressPublicKey:(NSString *)multiCodecKey
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
NSString *result = StatusgoCompressPublicKey(multiCodecKey);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(deserializeAndCompressKey:(NSString *)desktopKey
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
NSString *result = StatusgoDeserializeAndCompressKey(desktopKey);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2020-11-25 09:30:00 +00:00
|
|
|
RCT_EXPORT_METHOD(hashTypedData:(NSString *)data
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"hashTypedData() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoHashTypedData(data);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2021-05-12 08:13:41 +00:00
|
|
|
RCT_EXPORT_METHOD(hashTypedDataV4:(NSString *)data
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"hashTypedDataV4() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoHashTypedDataV4(data);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2020-11-25 09:30:00 +00:00
|
|
|
RCT_EXPORT_METHOD(sendTransactionWithSignature:(NSString *)txArgsJSON
|
|
|
|
signature:(NSString *)signature
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"sendTransactionWithSignature() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoSendTransactionWithSignature(txArgsJSON, signature);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2019-08-01 15:49:33 +00:00
|
|
|
RCT_EXPORT_METHOD(multiAccountImportMnemonic:(NSString *)json
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"MultiAccountImportMnemonic() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoMultiAccountImportMnemonic(json);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2019-08-12 08:53:31 +00:00
|
|
|
RCT_EXPORT_METHOD(multiAccountDeriveAddresses:(NSString *)json
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"MultiAccountDeriveAddresses() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoMultiAccountDeriveAddresses(json);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
2019-05-13 07:58:41 +00:00
|
|
|
|
2020-07-09 10:14:38 +00:00
|
|
|
-(NSString *) getKeyUID:(NSString *)jsonString {
|
|
|
|
NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
NSDictionary *json = [NSJSONSerialization
|
|
|
|
JSONObjectWithData:data
|
|
|
|
options:NSJSONReadingMutableContainers
|
|
|
|
error:nil];
|
2020-11-25 09:30:00 +00:00
|
|
|
|
2020-07-09 10:14:38 +00:00
|
|
|
return [json valueForKey:@"key-uid"];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NSString *) prepareDirAndUpdateConfig:(NSString *)config
|
|
|
|
withKeyUID:(NSString *)keyUID {
|
2019-08-01 20:11:59 +00:00
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
NSError *error = nil;
|
|
|
|
NSURL *rootUrl =[[fileManager
|
2019-08-26 07:39:13 +00:00
|
|
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
2019-08-01 20:11:59 +00:00
|
|
|
lastObject];
|
|
|
|
NSURL *absTestnetFolderName = [rootUrl URLByAppendingPathComponent:@"ethereum/testnet"];
|
|
|
|
|
|
|
|
if (![fileManager fileExistsAtPath:absTestnetFolderName.path])
|
|
|
|
[fileManager createDirectoryAtPath:absTestnetFolderName.path withIntermediateDirectories:YES attributes:nil error:&error];
|
|
|
|
|
|
|
|
NSURL *flagFolderUrl = [rootUrl URLByAppendingPathComponent:@"ropsten_flag"];
|
|
|
|
|
|
|
|
if(![fileManager fileExistsAtPath:flagFolderUrl.path]){
|
|
|
|
NSLog(@"remove lightchaindata");
|
|
|
|
NSURL *absLightChainDataUrl = [absTestnetFolderName URLByAppendingPathComponent:@"StatusIM/lightchaindata"];
|
|
|
|
if([fileManager fileExistsAtPath:absLightChainDataUrl.path]) {
|
|
|
|
[fileManager removeItemAtPath:absLightChainDataUrl.path
|
|
|
|
error:nil];
|
|
|
|
}
|
|
|
|
[fileManager createDirectoryAtPath:flagFolderUrl.path
|
|
|
|
withIntermediateDirectories:NO
|
|
|
|
attributes:nil
|
|
|
|
error:&error];
|
|
|
|
}
|
|
|
|
|
|
|
|
NSLog(@"after remove lightchaindata");
|
|
|
|
|
2020-01-31 12:43:32 +00:00
|
|
|
NSString *keystore = @"keystore";
|
|
|
|
NSURL *absTestnetKeystoreUrl = [absTestnetFolderName URLByAppendingPathComponent:keystore];
|
|
|
|
NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:keystore];
|
2019-08-01 20:11:59 +00:00
|
|
|
if([fileManager fileExistsAtPath:absTestnetKeystoreUrl.path]){
|
|
|
|
NSLog(@"copy keystore");
|
|
|
|
[fileManager copyItemAtPath:absTestnetKeystoreUrl.path toPath:absKeystoreUrl.path error:nil];
|
|
|
|
[fileManager removeItemAtPath:absTestnetKeystoreUrl.path error:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
NSLog(@"after lightChainData");
|
|
|
|
|
|
|
|
NSLog(@"preconfig: %@", config);
|
|
|
|
NSData *configData = [config dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
NSDictionary *configJSON = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:nil];
|
|
|
|
NSString *relativeDataDir = [configJSON objectForKey:@"DataDir"];
|
|
|
|
NSString *absDataDir = [rootUrl.path stringByAppendingString:relativeDataDir];
|
|
|
|
NSURL *absDataDirUrl = [NSURL fileURLWithPath:absDataDir];
|
2020-07-09 10:14:38 +00:00
|
|
|
NSString *keystoreDir = [@"/keystore/" stringByAppendingString:keyUID];
|
|
|
|
[configJSON setValue:keystoreDir forKey:@"KeyStoreDir"];
|
2020-01-31 12:43:32 +00:00
|
|
|
[configJSON setValue:@"" forKey:@"LogDir"];
|
2022-10-09 14:09:18 +00:00
|
|
|
[configJSON setValue:@"geth.log" forKey:@"LogFile"];
|
2019-08-01 20:11:59 +00:00
|
|
|
|
|
|
|
NSString *resultingConfig = [configJSON bv_jsonStringWithPrettyPrint:NO];
|
|
|
|
NSLog(@"node config %@", resultingConfig);
|
|
|
|
|
2020-01-31 12:43:32 +00:00
|
|
|
if(![fileManager fileExistsAtPath:absDataDir]) {
|
|
|
|
[fileManager createDirectoryAtPath:absDataDir
|
|
|
|
withIntermediateDirectories:YES attributes:nil error:nil];
|
2019-08-01 20:11:59 +00:00
|
|
|
}
|
|
|
|
|
2022-10-09 14:09:18 +00:00
|
|
|
NSLog(@"logUrlPath %@ rootDir %@", @"geth.log", rootUrl.path);
|
2020-01-31 12:43:32 +00:00
|
|
|
NSURL *absLogUrl = [absDataDirUrl URLByAppendingPathComponent:@"geth.log"];
|
2019-08-01 20:11:59 +00:00
|
|
|
if(![fileManager fileExistsAtPath:absLogUrl.path]) {
|
|
|
|
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
|
|
[dict setObject:[NSNumber numberWithInt:511] forKey:NSFilePosixPermissions];
|
|
|
|
[fileManager createFileAtPath:absLogUrl.path contents:nil attributes:dict];
|
|
|
|
}
|
|
|
|
|
|
|
|
return resultingConfig;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-09 10:14:38 +00:00
|
|
|
RCT_EXPORT_METHOD(prepareDirAndUpdateConfig:(NSString *)keyUID
|
|
|
|
config:(NSString *)config
|
2019-08-01 20:11:59 +00:00
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"PrepareDirAndUpdateConfig() method called");
|
|
|
|
#endif
|
2020-07-09 10:14:38 +00:00
|
|
|
NSString *updatedConfig = [self prepareDirAndUpdateConfig:config
|
|
|
|
withKeyUID:keyUID];
|
2019-08-01 20:11:59 +00:00
|
|
|
callback(@[updatedConfig]);
|
|
|
|
}
|
|
|
|
|
2019-12-18 12:35:57 +00:00
|
|
|
RCT_EXPORT_METHOD(saveAccountAndLogin:(NSString *)multiaccountData
|
2019-08-01 20:11:59 +00:00
|
|
|
password:(NSString *)password
|
2019-12-10 11:31:22 +00:00
|
|
|
settings:(NSString *)settings
|
2019-08-01 20:11:59 +00:00
|
|
|
config:(NSString *)config
|
2019-12-18 12:35:57 +00:00
|
|
|
accountsData:(NSString *)accountsData) {
|
2019-08-01 20:11:59 +00:00
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"SaveAccountAndLogin() method called");
|
|
|
|
#endif
|
2021-11-01 10:00:17 +00:00
|
|
|
[self getExportDbFilePath];
|
2020-07-09 10:14:38 +00:00
|
|
|
NSString *keyUID = [self getKeyUID:multiaccountData];
|
|
|
|
NSString *finalConfig = [self prepareDirAndUpdateConfig:config
|
|
|
|
withKeyUID:keyUID];
|
2019-12-10 11:31:22 +00:00
|
|
|
NSString *result = StatusgoSaveAccountAndLogin(multiaccountData, password, settings, finalConfig, accountsData);
|
2019-08-01 20:11:59 +00:00
|
|
|
NSLog(@"%@", result);
|
|
|
|
}
|
|
|
|
|
2019-12-18 12:35:57 +00:00
|
|
|
RCT_EXPORT_METHOD(saveAccountAndLoginWithKeycard:(NSString *)multiaccountData
|
2019-08-15 14:44:25 +00:00
|
|
|
password:(NSString *)password
|
2019-12-10 11:31:22 +00:00
|
|
|
settings:(NSString *)settings
|
2019-08-15 14:44:25 +00:00
|
|
|
config:(NSString *)config
|
2019-12-18 12:35:57 +00:00
|
|
|
accountsData:(NSString *)accountsData
|
2019-08-15 14:44:25 +00:00
|
|
|
chatKey:(NSString *)chatKey) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"SaveAccountAndLoginWithKeycard() method called");
|
|
|
|
#endif
|
2021-11-01 10:00:17 +00:00
|
|
|
[self getExportDbFilePath];
|
2020-07-09 10:14:38 +00:00
|
|
|
NSString *keyUID = [self getKeyUID:multiaccountData];
|
|
|
|
NSString *finalConfig = [self prepareDirAndUpdateConfig:config
|
|
|
|
withKeyUID:keyUID];
|
2019-12-10 11:31:22 +00:00
|
|
|
NSString *result = StatusgoSaveAccountAndLoginWithKeycard(multiaccountData, password, settings, finalConfig, accountsData, chatKey);
|
2019-08-15 14:44:25 +00:00
|
|
|
NSLog(@"%@", result);
|
|
|
|
}
|
2019-08-01 20:11:59 +00:00
|
|
|
|
2021-11-01 10:00:17 +00:00
|
|
|
- (NSString *) getExportDbFilePath {
|
|
|
|
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"export.db"];
|
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
2022-12-16 13:10:56 +00:00
|
|
|
|
2021-11-01 10:00:17 +00:00
|
|
|
if ([fileManager fileExistsAtPath:filePath]) {
|
|
|
|
[fileManager removeItemAtPath:filePath error:nil];
|
|
|
|
}
|
2022-12-16 13:10:56 +00:00
|
|
|
|
2021-11-01 10:00:17 +00:00
|
|
|
return filePath;
|
|
|
|
}
|
|
|
|
|
2020-07-14 13:33:59 +00:00
|
|
|
- (NSURL *) getKeyStoreDir:(NSString *)keyUID {
|
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
NSURL *rootUrl =[[fileManager
|
|
|
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
|
|
|
lastObject];
|
2020-11-25 09:30:00 +00:00
|
|
|
|
2020-07-14 13:33:59 +00:00
|
|
|
NSURL *oldKeystoreDir = [rootUrl URLByAppendingPathComponent:@"keystore"];
|
|
|
|
NSURL *multiaccountKeystoreDir = [oldKeystoreDir URLByAppendingPathComponent:keyUID];
|
2020-11-25 09:30:00 +00:00
|
|
|
|
2020-07-14 13:33:59 +00:00
|
|
|
return multiaccountKeystoreDir;
|
|
|
|
}
|
|
|
|
|
2020-07-09 10:14:38 +00:00
|
|
|
- (void) migrateKeystore:(NSString *)accountData
|
|
|
|
password:(NSString *)password {
|
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
NSURL *rootUrl =[[fileManager
|
|
|
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
|
|
|
lastObject];
|
|
|
|
|
|
|
|
NSString *keyUID = [self getKeyUID:accountData];
|
|
|
|
NSURL *oldKeystoreDir = [rootUrl URLByAppendingPathComponent:@"keystore"];
|
2020-07-14 13:33:59 +00:00
|
|
|
NSURL *multiaccountKeystoreDir = [self getKeyStoreDir:keyUID];
|
2020-11-25 09:30:00 +00:00
|
|
|
|
2020-07-09 10:14:38 +00:00
|
|
|
NSArray *keys = [fileManager contentsOfDirectoryAtPath:multiaccountKeystoreDir.path error:nil];
|
|
|
|
if (keys.count == 0) {
|
|
|
|
NSString *migrationResult = StatusgoMigrateKeyStoreDir(accountData, password, oldKeystoreDir.path, multiaccountKeystoreDir.path);
|
|
|
|
NSLog(@"keystore migration result %@", migrationResult);
|
2020-11-25 09:30:00 +00:00
|
|
|
|
2020-07-09 10:14:38 +00:00
|
|
|
NSString *initKeystoreResult = StatusgoInitKeystore(multiaccountKeystoreDir.path);
|
|
|
|
NSLog(@"InitKeyStore result %@", initKeystoreResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 20:11:59 +00:00
|
|
|
RCT_EXPORT_METHOD(login:(NSString *)accountData
|
|
|
|
password:(NSString *)password) {
|
2016-09-12 08:16:07 +00:00
|
|
|
#if DEBUG
|
2016-09-23 14:14:43 +00:00
|
|
|
NSLog(@"Login() method called");
|
2016-09-12 08:16:07 +00:00
|
|
|
#endif
|
2021-11-01 10:00:17 +00:00
|
|
|
[self getExportDbFilePath];
|
2020-07-09 10:14:38 +00:00
|
|
|
[self migrateKeystore:accountData password:password];
|
2019-08-01 20:11:59 +00:00
|
|
|
NSString *result = StatusgoLogin(accountData, password);
|
2019-09-18 09:38:43 +00:00
|
|
|
NSLog(@"%@", result);
|
|
|
|
}
|
|
|
|
|
2022-06-09 12:42:36 +00:00
|
|
|
RCT_EXPORT_METHOD(loginWithConfig:(NSString *)accountData
|
|
|
|
password:(NSString *)password
|
|
|
|
configJSON:(NSString *)configJSON) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"LoginWithConfig() method called");
|
|
|
|
#endif
|
|
|
|
[self getExportDbFilePath];
|
|
|
|
[self migrateKeystore:accountData password:password];
|
|
|
|
NSString *result = StatusgoLoginWithConfig(accountData, password, configJSON);
|
|
|
|
NSLog(@"%@", result);
|
|
|
|
}
|
|
|
|
|
2019-09-18 09:38:43 +00:00
|
|
|
RCT_EXPORT_METHOD(loginWithKeycard:(NSString *)accountData
|
|
|
|
password:(NSString *)password
|
|
|
|
chatKey:(NSString *)chatKey) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"LoginWithKeycard() method called");
|
|
|
|
#endif
|
2021-11-01 10:00:17 +00:00
|
|
|
[self getExportDbFilePath];
|
2020-07-09 10:14:38 +00:00
|
|
|
[self migrateKeystore:accountData password:password];
|
2020-11-25 09:30:00 +00:00
|
|
|
|
2019-09-18 09:38:43 +00:00
|
|
|
NSString *result = StatusgoLoginWithKeycard(accountData, password, chatKey);
|
|
|
|
|
2019-08-01 20:11:59 +00:00
|
|
|
NSLog(@"%@", result);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(logout) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"Logout() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoLogout();
|
2020-01-08 14:41:07 +00:00
|
|
|
|
2019-08-01 20:11:59 +00:00
|
|
|
NSLog(@"%@", result);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(openAccounts:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"OpenAccounts() method called");
|
|
|
|
#endif
|
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
NSURL *rootUrl =[[fileManager
|
2019-08-26 07:39:13 +00:00
|
|
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
2019-08-01 20:11:59 +00:00
|
|
|
lastObject];
|
|
|
|
|
|
|
|
NSString *result = StatusgoOpenAccounts(rootUrl.path);
|
2019-02-12 11:35:26 +00:00
|
|
|
callback(@[result]);
|
2016-09-12 08:16:07 +00:00
|
|
|
}
|
|
|
|
|
2018-11-26 15:52:29 +00:00
|
|
|
RCT_EXPORT_METHOD(verify:(NSString *)address
|
|
|
|
password:(NSString *)password
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"VerifyAccountPassword() method called");
|
|
|
|
#endif
|
|
|
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
NSURL *rootUrl =[[fileManager
|
2021-05-26 08:55:01 +00:00
|
|
|
URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]
|
|
|
|
lastObject];
|
2018-11-26 15:52:29 +00:00
|
|
|
NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:@"keystore"];
|
2019-04-30 11:49:45 +00:00
|
|
|
|
2019-02-12 11:35:26 +00:00
|
|
|
NSString *result = StatusgoVerifyAccountPassword(absKeystoreUrl.path, address, password);
|
|
|
|
callback(@[result]);
|
2018-11-26 15:52:29 +00:00
|
|
|
}
|
|
|
|
|
2021-07-13 13:41:45 +00:00
|
|
|
RCT_EXPORT_METHOD(verifyDatabasePassword:(NSString *)keyUID
|
|
|
|
password:(NSString *)password
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"VerifyDatabasePassword() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoVerifyDatabasePassword(keyUID, password);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2021-05-26 08:55:01 +00:00
|
|
|
RCT_EXPORT_METHOD(reEncryptDbAndKeystore:(NSString *)keyUID
|
|
|
|
currentPassword:(NSString *)currentPassword
|
|
|
|
newPassword:(NSString *)newPassword
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"reEncryptDbAndKeystore() method called");
|
|
|
|
#endif
|
|
|
|
// changes password and re-encrypts keystore
|
|
|
|
NSString *result = StatusgoChangeDatabasePassword(keyUID, currentPassword, newPassword);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2021-07-13 13:41:45 +00:00
|
|
|
RCT_EXPORT_METHOD(convertToKeycardAccount:(NSString *)keyUID
|
|
|
|
accountData:(NSString *)accountData
|
|
|
|
settings:(NSString *)settings
|
|
|
|
currentPassword:(NSString *)currentPassword
|
|
|
|
newPassword:(NSString *)newPassword
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"convertToKeycardAccount() method called");
|
|
|
|
#endif
|
|
|
|
NSURL *multiaccountKeystoreDir = [self getKeyStoreDir:keyUID];
|
2023-02-02 11:05:21 +00:00
|
|
|
StatusgoInitKeystore(multiaccountKeystoreDir.path);
|
2023-01-30 16:45:23 +00:00
|
|
|
NSString *result = StatusgoConvertToKeycardAccount(accountData, settings, currentPassword, newPassword);
|
2021-07-13 13:41:45 +00:00
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2018-08-10 17:15:16 +00:00
|
|
|
#pragma mark - SendTransaction
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2018-08-10 17:15:16 +00:00
|
|
|
RCT_EXPORT_METHOD(sendTransaction:(NSString *)txArgsJSON
|
2016-09-12 08:16:07 +00:00
|
|
|
password:(NSString *)password
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
2018-08-10 17:15:16 +00:00
|
|
|
NSLog(@"SendTransaction() method called");
|
2016-09-12 08:16:07 +00:00
|
|
|
#endif
|
2019-02-12 11:35:26 +00:00
|
|
|
NSString *result = StatusgoSendTransaction(txArgsJSON, password);
|
|
|
|
callback(@[result]);
|
2018-06-03 10:25:14 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2018-08-10 17:15:16 +00:00
|
|
|
#pragma mark - SignMessage
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2018-08-10 17:15:16 +00:00
|
|
|
RCT_EXPORT_METHOD(signMessage:(NSString *)message
|
2018-06-03 10:25:14 +00:00
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
2018-08-10 17:15:16 +00:00
|
|
|
NSLog(@"SignMessage() method called");
|
2018-06-03 10:25:14 +00:00
|
|
|
#endif
|
2019-02-12 11:35:26 +00:00
|
|
|
NSString *result = StatusgoSignMessage(message);
|
|
|
|
callback(@[result]);
|
2019-03-05 14:44:50 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2022-01-06 13:54:18 +00:00
|
|
|
#pragma mark - Recover
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2022-01-06 13:54:18 +00:00
|
|
|
RCT_EXPORT_METHOD(recover:(NSString *)message
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"Recover() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoRecover(message);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2019-03-05 14:44:50 +00:00
|
|
|
#pragma mark - SignTypedData
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2019-03-05 14:44:50 +00:00
|
|
|
RCT_EXPORT_METHOD(signTypedData:(NSString *)data
|
2019-07-19 14:11:10 +00:00
|
|
|
account:(NSString *)account
|
2019-03-05 14:44:50 +00:00
|
|
|
password:(NSString *)password
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"SignTypedData() method called");
|
|
|
|
#endif
|
2019-07-19 14:11:10 +00:00
|
|
|
NSString *result = StatusgoSignTypedData(data, account, password);
|
2019-03-05 14:44:50 +00:00
|
|
|
callback(@[result]);
|
2016-09-07 17:35:04 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2021-04-06 07:42:01 +00:00
|
|
|
#pragma mark - SignTypedDataV4
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2021-04-06 07:42:01 +00:00
|
|
|
RCT_EXPORT_METHOD(signTypedDataV4:(NSString *)data
|
|
|
|
account:(NSString *)account
|
|
|
|
password:(NSString *)password
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"SignTypedDataV4() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoSignTypedDataV4(data, account, password);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2018-07-19 15:51:06 +00:00
|
|
|
#pragma mark - SignGroupMembership
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2018-07-19 15:51:06 +00:00
|
|
|
RCT_EXPORT_METHOD(signGroupMembership:(NSString *)content
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"SignGroupMembership() method called");
|
|
|
|
#endif
|
2019-02-12 11:35:26 +00:00
|
|
|
NSString *result = StatusgoSignGroupMembership(content);
|
|
|
|
callback(@[result]);
|
2018-07-19 15:51:06 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2018-10-01 08:47:20 +00:00
|
|
|
#pragma mark - ExtractGroupMembershipSignatures
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2018-10-01 08:47:20 +00:00
|
|
|
RCT_EXPORT_METHOD(extractGroupMembershipSignatures:(NSString *)content
|
2018-07-19 15:51:06 +00:00
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
2018-10-01 08:47:20 +00:00
|
|
|
NSLog(@"ExtractGroupMembershipSignatures() method called");
|
2018-07-19 15:51:06 +00:00
|
|
|
#endif
|
2019-02-12 11:35:26 +00:00
|
|
|
NSString *result = StatusgoExtractGroupMembershipSignatures(content);
|
|
|
|
callback(@[result]);
|
2018-07-19 15:51:06 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2021-05-31 13:10:54 +00:00
|
|
|
#pragma mark - GetNodeConfig
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2021-05-31 13:10:54 +00:00
|
|
|
RCT_EXPORT_METHOD(getNodeConfig:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"GetNodeConfig() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoGetNodeConfig();
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2016-09-12 08:16:07 +00:00
|
|
|
#pragma mark - only android methods
|
2022-12-16 17:09:39 +00:00
|
|
|
|
2016-09-07 17:35:04 +00:00
|
|
|
RCT_EXPORT_METHOD(setAdjustResize) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"setAdjustResize() works only on Android");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(setAdjustPan) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"setAdjustPan() works only on Android");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(setSoftInputMode: (NSInteger) i) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"setSoftInputMode() works only on Android");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-01-16 21:16:55 +00:00
|
|
|
RCT_EXPORT_METHOD(clearCookies) {
|
|
|
|
NSHTTPCookie *cookie;
|
|
|
|
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
|
2019-05-13 07:58:41 +00:00
|
|
|
|
2017-01-16 21:16:55 +00:00
|
|
|
for (cookie in [storage cookies]) {
|
|
|
|
[storage deleteCookie:cookie];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(clearStorageAPIs) {
|
|
|
|
[[NSURLCache sharedURLCache] removeAllCachedResponses];
|
2018-05-23 08:41:59 +00:00
|
|
|
|
2017-01-16 21:16:55 +00:00
|
|
|
NSString *path = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
|
|
|
|
NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
|
|
|
|
for (NSString *string in array) {
|
|
|
|
NSLog(@"Removing %@", [path stringByAppendingPathComponent:string]);
|
2017-10-09 09:34:29 +00:00
|
|
|
if ([[string pathExtension] isEqualToString:@"localstorage"])
|
|
|
|
[[NSFileManager defaultManager] removeItemAtPath:[path stringByAppendingPathComponent:string] error:nil];
|
2017-01-16 21:16:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-10 17:15:16 +00:00
|
|
|
RCT_EXPORT_METHOD(callRPC:(NSString *)payload
|
2017-04-18 14:22:05 +00:00
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
2017-08-01 18:42:16 +00:00
|
|
|
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
2019-02-12 11:35:26 +00:00
|
|
|
NSString *result = StatusgoCallRPC(payload);
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
callback(@[result]);
|
2017-08-01 18:42:16 +00:00
|
|
|
});
|
|
|
|
});
|
2017-04-18 14:22:05 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 09:41:25 +00:00
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(generateAlias:(NSString *)publicKey) {
|
|
|
|
return StatusgoGenerateAlias(publicKey);
|
|
|
|
}
|
|
|
|
|
2019-11-28 10:00:29 +00:00
|
|
|
RCT_EXPORT_METHOD(generateAliasAsync:(NSString *)publicKey
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"generateAliasAsync() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoGenerateAlias(publicKey);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2023-02-10 11:02:46 +00:00
|
|
|
RCT_EXPORT_METHOD(emojiHash:(NSString *)publicKey
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
NSString *result = StatusgoEmojiHash(publicKey);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2019-09-12 09:41:25 +00:00
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(identicon:(NSString *)publicKey) {
|
|
|
|
return StatusgoIdenticon(publicKey);
|
|
|
|
}
|
|
|
|
|
2022-08-26 08:43:04 +00:00
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(encodeTransfer:(NSString *)to
|
|
|
|
value:(NSString *)value) {
|
|
|
|
return StatusgoEncodeTransfer(to,value);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(encodeFunctionCall:(NSString *)method
|
|
|
|
paramsJSON:(NSString *)paramsJSON) {
|
|
|
|
return StatusgoEncodeFunctionCall(method,paramsJSON);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(decodeParameters:(NSString *)decodeParamJSON) {
|
|
|
|
return StatusgoDecodeParameters(decodeParamJSON);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(hexToNumber:(NSString *)hex) {
|
|
|
|
return StatusgoHexToNumber(hex);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(numberToHex:(NSString *)numString) {
|
|
|
|
return StatusgoNumberToHex(numString);
|
|
|
|
}
|
|
|
|
|
2022-10-18 16:05:07 +00:00
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(sha3:(NSString *)str) {
|
|
|
|
return StatusgoSha3(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(utf8ToHex:(NSString *)str) {
|
|
|
|
return StatusgoUtf8ToHex(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(hexToUtf8:(NSString *)str) {
|
|
|
|
return StatusgoHexToUtf8(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(checkAddressChecksum:(NSString *)address) {
|
|
|
|
return StatusgoCheckAddressChecksum(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isAddress:(NSString *)address) {
|
|
|
|
return StatusgoIsAddress(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(toChecksumAddress:(NSString *)address) {
|
|
|
|
return StatusgoToChecksumAddress(address);
|
|
|
|
}
|
|
|
|
|
2019-12-31 10:50:45 +00:00
|
|
|
RCT_EXPORT_METHOD(validateMnemonic:(NSString *)seed
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"validateMnemonic() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoValidateMnemonic(seed);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
2019-11-28 10:00:29 +00:00
|
|
|
RCT_EXPORT_METHOD(identiconAsync:(NSString *)publicKey
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"identiconAsync() method called");
|
|
|
|
#endif
|
|
|
|
NSString *result = StatusgoIdenticon(publicKey);
|
|
|
|
callback(@[result]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(generateAliasAndIdenticonAsync:(NSString *)publicKey
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"generateAliasAndIdenticonAsync() method called");
|
|
|
|
#endif
|
|
|
|
NSString *identiconResult = StatusgoIdenticon(publicKey);
|
|
|
|
NSString *aliasResult = StatusgoGenerateAlias(publicKey);
|
|
|
|
callback(@[aliasResult, identiconResult]);
|
|
|
|
}
|
|
|
|
|
2018-08-10 17:15:16 +00:00
|
|
|
RCT_EXPORT_METHOD(callPrivateRPC:(NSString *)payload
|
2018-04-18 08:49:15 +00:00
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
|
|
|
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
2019-02-12 11:35:26 +00:00
|
|
|
NSString *result = StatusgoCallPrivateRPC(payload);
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
callback(@[result]);
|
2018-04-18 08:49:15 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-05 11:23:25 +00:00
|
|
|
RCT_EXPORT_METHOD(closeApplication) {
|
|
|
|
exit(0);
|
|
|
|
}
|
2017-04-18 14:22:05 +00:00
|
|
|
|
2018-02-26 02:27:29 +00:00
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(connectionChange:(NSString *)type
|
|
|
|
isExpensive:(BOOL)isExpensive) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"ConnectionChange() method called");
|
|
|
|
#endif
|
2019-02-12 11:35:26 +00:00
|
|
|
StatusgoConnectionChange(type, isExpensive ? 1 : 0);
|
2018-02-26 02:27:29 +00:00
|
|
|
}
|
|
|
|
|
2018-03-16 12:01:10 +00:00
|
|
|
RCT_EXPORT_METHOD(appStateChange:(NSString *)type) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"AppStateChange() method called");
|
|
|
|
#endif
|
2019-02-12 11:35:26 +00:00
|
|
|
StatusgoAppStateChange(type);
|
2018-03-16 12:01:10 +00:00
|
|
|
}
|
|
|
|
|
2020-09-25 12:35:10 +00:00
|
|
|
RCT_EXPORT_METHOD(stopLocalNotifications) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"StopLocalNotifications() method called");
|
|
|
|
#endif
|
|
|
|
StatusgoStopLocalNotifications();
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(startLocalNotifications) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"StartLocalNotifications() method called");
|
|
|
|
#endif
|
|
|
|
StatusgoStartLocalNotifications();
|
|
|
|
}
|
|
|
|
|
2021-01-18 13:01:57 +00:00
|
|
|
RCT_EXPORT_METHOD(exportUnencryptedDatabase:(NSString *)accountData
|
2021-11-01 12:08:54 +00:00
|
|
|
password:(NSString *)password
|
|
|
|
callback:(RCTResponseSenderBlock)callback) {
|
2021-01-18 13:01:57 +00:00
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"exportUnencryptedDatabase() method called");
|
|
|
|
#endif
|
2022-12-16 13:10:56 +00:00
|
|
|
|
2021-11-01 10:00:17 +00:00
|
|
|
NSString *filePath = [self getExportDbFilePath];
|
2021-11-01 12:08:54 +00:00
|
|
|
StatusgoExportUnencryptedDatabase(accountData, password, filePath);
|
2022-12-16 13:10:56 +00:00
|
|
|
|
2021-11-01 12:08:54 +00:00
|
|
|
callback(@[filePath]);
|
2021-01-18 13:01:57 +00:00
|
|
|
}
|
2020-09-25 12:35:10 +00:00
|
|
|
|
2021-01-18 13:01:57 +00:00
|
|
|
RCT_EXPORT_METHOD(importUnencryptedDatabase:(NSString *)accountData
|
|
|
|
password:(NSString *)password) {
|
|
|
|
#if DEBUG
|
|
|
|
NSLog(@"importUnencryptedDatabase() method called");
|
|
|
|
#endif
|
|
|
|
"";
|
|
|
|
}
|
2020-09-25 12:35:10 +00:00
|
|
|
|
2019-05-08 12:26:39 +00:00
|
|
|
RCT_EXPORT_METHOD(setBlankPreviewFlag:(BOOL *)newValue)
|
|
|
|
{
|
|
|
|
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
|
|
|
[userDefaults setBool:newValue forKey:@"BLANK_PREVIEW"];
|
|
|
|
|
|
|
|
[userDefaults synchronize];
|
|
|
|
}
|
|
|
|
|
2020-07-28 11:06:58 +00:00
|
|
|
RCT_EXPORT_METHOD(activateKeepAwake)
|
|
|
|
{
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_METHOD(deactivateKeepAwake)
|
|
|
|
{
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-16 17:09:39 +00:00
|
|
|
#pragma mark - deviceinfo
|
2019-05-30 14:01:20 +00:00
|
|
|
|
2018-08-03 16:43:37 +00:00
|
|
|
- (bool) is24Hour
|
|
|
|
{
|
|
|
|
NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 locale:[NSLocale currentLocale]];
|
|
|
|
return ([format rangeOfString:@"a"].location == NSNotFound);
|
|
|
|
}
|
|
|
|
|
2019-05-30 14:01:20 +00:00
|
|
|
- (NSString *)getBuildId {
|
|
|
|
return @"not available";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*) deviceId
|
|
|
|
{
|
|
|
|
struct utsname systemInfo;
|
|
|
|
|
|
|
|
uname(&systemInfo);
|
|
|
|
|
|
|
|
NSString* deviceId = [NSString stringWithCString:systemInfo.machine
|
|
|
|
encoding:NSUTF8StringEncoding];
|
|
|
|
|
|
|
|
if ([deviceId isEqualToString:@"i386"] || [deviceId isEqualToString:@"x86_64"] ) {
|
|
|
|
deviceId = [NSString stringWithFormat:@"%s", getenv("SIMULATOR_MODEL_IDENTIFIER")];
|
|
|
|
}
|
|
|
|
|
|
|
|
return deviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*) deviceName
|
|
|
|
{
|
|
|
|
|
|
|
|
NSString* deviceName = nil;
|
|
|
|
|
|
|
|
if ([self.deviceId rangeOfString:@"iPod"].location != NSNotFound) {
|
|
|
|
deviceName = @"iPod Touch";
|
|
|
|
}
|
|
|
|
else if([self.deviceId rangeOfString:@"iPad"].location != NSNotFound) {
|
|
|
|
deviceName = @"iPad";
|
|
|
|
}
|
|
|
|
else if([self.deviceId rangeOfString:@"iPhone"].location != NSNotFound){
|
|
|
|
deviceName = @"iPhone";
|
|
|
|
}
|
|
|
|
else if([self.deviceId rangeOfString:@"AppleTV"].location != NSNotFound){
|
|
|
|
deviceName = @"Apple TV";
|
|
|
|
}
|
|
|
|
|
|
|
|
return deviceName;
|
|
|
|
}
|
|
|
|
|
2018-08-03 16:43:37 +00:00
|
|
|
- (NSDictionary *)constantsToExport
|
|
|
|
{
|
|
|
|
return @{
|
|
|
|
@"is24Hour": @(self.is24Hour),
|
2019-05-30 14:01:20 +00:00
|
|
|
@"model": self.deviceName ?: [NSNull null],
|
|
|
|
@"brand": @"Apple",
|
|
|
|
@"buildId": [self getBuildId],
|
|
|
|
@"deviceId": self.deviceId ?: [NSNull null],
|
2018-08-03 16:43:37 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-08-23 01:54:29 +00:00
|
|
|
+ (BOOL)requiresMainQueueSetup
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2016-09-07 17:35:04 +00:00
|
|
|
@end
|