27 changed files with 177 additions and 433 deletions
+2
View File
@@ -62,3 +62,5 @@ android/keystores/debug.keystore
# generated by bob
lib/
tmp/
View File
Binary file not shown.
Binary file not shown.
@@ -64,6 +64,11 @@ class ReactNativeModule(reactContext: ReactApplicationContext) : ReactContextBas
promise.resolve(Gowaku.stop())
}
@ReactMethod
fun isStarted(promise: Promise) {
promise.resolve(Gowaku.isStarted())
}
@ReactMethod
fun peerID(promise: Promise) {
promise.resolve(Gowaku.peerID())
+73
View File
@@ -0,0 +1,73 @@
#!/bin/sh
VERSION=`cat ./go-waku.VERSION`
ANDROID_TAR=gowaku-${VERSION}-android.tar.gz
IOS_TAR=gowaku-${VERSION}-ios.tar.gz
SHA_FILE=gowaku-${VERSION}.sha256
echo "Verifying go-waku libs..."
DOWNLOAD_IOS=false
DOWNLOAD_ANDROID=false
if [ "$1" = "--force" ]; then
DOWNLOAD_IOS=true
DOWNLOAD_ANDROID=true
fi
if ! test -f "./android/libs/gowaku.aar"; then
echo "android does not exists."
DOWNLOAD_ANDROID=true
fi
if ! test -d "./ios/Gowaku.xcframework"; then
echo "ios does not exists."
DOWNLOAD_IOS=true
fi
mkdir -p tmp
cd tmp
rm -f ${SHA_FILE}
wget "https://github.com/status-im/go-waku/releases/download/v${VERSION}/${SHA_FILE}"
if [ "$DOWNLOAD_ANDROID" = true ]; then
rm -f ${ANDROID_TAR}
wget "https://github.com/status-im/go-waku/releases/download/v${VERSION}/${ANDROID_TAR}"
if ! sha256sum --status --ignore-missing -c gowaku-0.1.0.sha256; then
echo "checksum failed - verify download"
exit 1
fi
rm -f ../android/libs/gowaku*
tar xvfz ${ANDROID_TAR} -C ../android/libs
fi
if [ "$DOWNLOAD_IOS" = true ]; then
rm -f ${IOS_TAR}
wget "https://github.com/status-im/go-waku/releases/download/v${VERSION}/${IOS_TAR}"
if ! sha256sum --status --ignore-missing -c gowaku-0.1.0.sha256; then
echo "checksum failed - verify download"
exit 1
fi
rm -rf ../ios/Gowaku.xcframework
tar xvfz ${IOS_TAR} -C ../ios
unlink ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/Gowaku
unlink ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/Resources
unlink ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/Versions/Current
unlink ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/Headers
unlink ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/Modules
unlink ../ios/Gowaku.xcframework/ios-arm64/Gowaku.framework/Gowaku
unlink ../ios/Gowaku.xcframework/ios-arm64/Gowaku.framework/Resources
unlink ../ios/Gowaku.xcframework/ios-arm64/Gowaku.framework/Versions/Current
unlink ../ios/Gowaku.xcframework/ios-arm64/Gowaku.framework/Headers
unlink ../ios/Gowaku.xcframework/ios-arm64/Gowaku.framework/Modules
mv -f ../ios/Gowaku.xcframework/ios-arm64/Gowaku.framework/Versions/A/* ../ios/Gowaku.xcframework/ios-arm64/Gowaku.framework/
mv -f ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/Versions/A/* ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/
rm -rf ../ios/Gowaku.xcframework/ios-arm64_x86_64-simulator/Gowaku.framework/Versions/A
rm -rf ../ios/Gowaku.xcframework/ios-arm64/Gowaku.framework/Versions/A
fi
+22 -6
View File
@@ -1,17 +1,21 @@
import * as React from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { defaultPubsubTopic, newNode, start, stop, peerID, relayEnoughPeers, listenAddresses, connect, peerCnt, peers, relayPublish, relayUnsubscribe, relaySubscribe, WakuMessage, onMessage } from '@waku/react-native';
import { defaultPubsubTopic, newNode, start, isStarted, stop, peerID, relayEnoughPeers, listenAddresses, connect, peerCnt, peers, relayPublish, relayUnsubscribe, relaySubscribe, WakuMessage, onMessage, storeQuery, StoreQuery } from '@waku/react-native';
export default function App() {
const [result, setResult] = React.useState<string | undefined>();
const delay = ms => new Promise(res => setTimeout(res, ms));
React.useEffect(() => {
(async () => {
await newNode(null); // TODO: This must be called only once
await start(); // // TODO: This must be called only once
const nodeStarted = await isStarted();
if (!nodeStarted) {
await newNode(null);
await start();
}
console.log("The node ID:", await peerID())
await relaySubscribe()
@@ -26,7 +30,7 @@ export default function App() {
await connect("/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/30303/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm", 5000)
console.log("connected!")
console.log("connected!")
console.log("PeerCNT", await peerCnt())
console.log("Peers", await peers())
@@ -41,9 +45,21 @@ export default function App() {
console.log("The messageID", messageID)
await relayUnsubscribe();
/*
console.log("Retrieving messages from store node")
const query = new StoreQuery();
//query.contentFilters.push("/toy-chat/2/luzhou/proto")
const queryResult = await storeQuery(query, "16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm")
console.log(queryResult)
*/
// await delay(5000) // Waiting 5s before unsubscribing
// console.log("Unsubscribing and stopping node...")
// await relayUnsubscribe();
await stop(); // TODO: This must be called only once
// await stop(); // TODO: This must be called only once
})();
defaultPubsubTopic().then(setResult);
+1
View File
@@ -0,0 +1 @@
0.2.0
-40
View File
@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>Gowaku.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>Gowaku.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
@@ -1,13 +0,0 @@
// Objective-C API for talking to the following Go packages
//
// github.com/status-im/go-waku/mobile
//
// File is generated by gomobile bind. Do not edit.
#ifndef __Gowaku_FRAMEWORK_H__
#define __Gowaku_FRAMEWORK_H__
#include "Gowaku.objc.h"
#include "Universe.objc.h"
#endif
@@ -1,98 +0,0 @@
// Objective-C API for talking to github.com/status-im/go-waku/mobile Go package.
// gobind -lang=objc github.com/status-im/go-waku/mobile
//
// File is generated by gobind. Do not edit.
#ifndef __Gowaku_H__
#define __Gowaku_H__
@import Foundation;
#include "ref.h"
#include "Universe.objc.h"
@protocol GowakuSignalHandler;
@class GowakuSignalHandler;
@protocol GowakuSignalHandler <NSObject>
- (void)handleSignal:(NSString* _Nullable)p0;
@end
FOUNDATION_EXPORT NSString* _Nonnull GowakuAddPeer(NSString* _Nullable address, NSString* _Nullable protocolID);
FOUNDATION_EXPORT NSString* _Nonnull GowakuConnect(NSString* _Nullable address, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuConnectPeerID(NSString* _Nullable peerID, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuContentTopic(NSString* _Nullable applicationName, long applicationVersion, NSString* _Nullable contentTopicName, NSString* _Nullable encoding);
FOUNDATION_EXPORT NSString* _Nonnull GowakuDecodeAsymmetric(NSString* _Nullable messageJSON, NSString* _Nullable privateKey);
FOUNDATION_EXPORT NSString* _Nonnull GowakuDecodeSymmetric(NSString* _Nullable messageJSON, NSString* _Nullable symmetricKey);
FOUNDATION_EXPORT NSString* _Nonnull GowakuDefaultPubsubTopic(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuDisconnect(NSString* _Nullable peerID);
FOUNDATION_EXPORT NSString* _Nonnull GowakuLightpushPublish(NSString* _Nullable messageJSON, NSString* _Nullable topic, NSString* _Nullable peerID, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuLightpushPublishEncodeAsymmetric(NSString* _Nullable messageJSON, NSString* _Nullable topic, NSString* _Nullable peerID, NSString* _Nullable publicKey, NSString* _Nullable optionalSigningKey, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuLightpushPublishEncodeSymmetric(NSString* _Nullable messageJSON, NSString* _Nullable topic, NSString* _Nullable peerID, NSString* _Nullable symmetricKey, NSString* _Nullable optionalSigningKey, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuListenAddresses(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuNewNode(NSString* _Nullable configJSON);
FOUNDATION_EXPORT NSString* _Nonnull GowakuPeerCnt(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuPeerID(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuPeers(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuPubsubTopic(NSString* _Nullable name, NSString* _Nullable encoding);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelayEnoughPeers(NSString* _Nullable topic);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelayPublish(NSString* _Nullable messageJSON, NSString* _Nullable topic, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelayPublishEncodeAsymmetric(NSString* _Nullable messageJSON, NSString* _Nullable topic, NSString* _Nullable publicKey, NSString* _Nullable optionalSigningKey, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelayPublishEncodeSymmetric(NSString* _Nullable messageJSON, NSString* _Nullable topic, NSString* _Nullable symmetricKey, NSString* _Nullable optionalSigningKey, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelaySubscribe(NSString* _Nullable topic);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelayUnsubscribe(NSString* _Nullable topic);
// skipped function SetEventCallback with unsupported parameter or return types
/**
* SetMobileSignalHandler setup geth callback to notify about new signal
used for gomobile builds
nolint
*/
FOUNDATION_EXPORT void GowakuSetMobileSignalHandler(id<GowakuSignalHandler> _Nullable handler);
FOUNDATION_EXPORT NSString* _Nonnull GowakuStart(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuStop(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuStoreQuery(NSString* _Nullable queryJSON, NSString* _Nullable peerID, long ms);
@class GowakuSignalHandler;
/**
* SignalHandler defines a minimal interface
a signal handler needs to implement.
nolint
*/
@interface GowakuSignalHandler : NSObject <goSeqRefInterface, GowakuSignalHandler> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (void)handleSignal:(NSString* _Nullable)p0;
@end
#endif
@@ -1,29 +0,0 @@
// Objective-C API for talking to Go package.
// gobind -lang=objc
//
// File is generated by gobind. Do not edit.
#ifndef __Universe_H__
#define __Universe_H__
@import Foundation;
#include "ref.h"
@protocol Universeerror;
@class Universeerror;
@protocol Universeerror <NSObject>
- (NSString* _Nonnull)error;
@end
@class Universeerror;
@interface Universeerror : NSError <goSeqRefInterface, Universeerror> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (NSString* _Nonnull)error;
@end
#endif
@@ -1,35 +0,0 @@
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#ifndef __GO_REF_HDR__
#define __GO_REF_HDR__
#include <Foundation/Foundation.h>
// GoSeqRef is an object tagged with an integer for passing back and
// forth across the language boundary. A GoSeqRef may represent either
// an instance of a Go object, or an Objective-C object passed to Go.
// The explicit allocation of a GoSeqRef is used to pin a Go object
// when it is passed to Objective-C. The Go seq package maintains a
// reference to the Go object in a map keyed by the refnum along with
// a reference count. When the reference count reaches zero, the Go
// seq package will clear the corresponding entry in the map.
@interface GoSeqRef : NSObject {
}
@property(readonly) int32_t refnum;
@property(strong) id obj; // NULL when representing a Go object.
// new GoSeqRef object to proxy a Go object. The refnum must be
// provided from Go side.
- (instancetype)initWithRefnum:(int32_t)refnum obj:(id)obj;
- (int32_t)incNum;
@end
@protocol goSeqRefInterface
-(GoSeqRef*) _ref;
@end
#endif
@@ -1,8 +0,0 @@
framework module "Gowaku" {
header "ref.h"
header "Gowaku.objc.h"
header "Universe.objc.h"
header "Gowaku.h"
export *
}
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
@@ -1,13 +0,0 @@
// Objective-C API for talking to the following Go packages
//
// github.com/status-im/go-waku/mobile
//
// File is generated by gomobile bind. Do not edit.
#ifndef __Gowaku_FRAMEWORK_H__
#define __Gowaku_FRAMEWORK_H__
#include "Gowaku.objc.h"
#include "Universe.objc.h"
#endif
@@ -1,98 +0,0 @@
// Objective-C API for talking to github.com/status-im/go-waku/mobile Go package.
// gobind -lang=objc github.com/status-im/go-waku/mobile
//
// File is generated by gobind. Do not edit.
#ifndef __Gowaku_H__
#define __Gowaku_H__
@import Foundation;
#include "ref.h"
#include "Universe.objc.h"
@protocol GowakuSignalHandler;
@class GowakuSignalHandler;
@protocol GowakuSignalHandler <NSObject>
- (void)handleSignal:(NSString* _Nullable)p0;
@end
FOUNDATION_EXPORT NSString* _Nonnull GowakuAddPeer(NSString* _Nullable address, NSString* _Nullable protocolID);
FOUNDATION_EXPORT NSString* _Nonnull GowakuConnect(NSString* _Nullable address, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuConnectPeerID(NSString* _Nullable peerID, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuContentTopic(NSString* _Nullable applicationName, long applicationVersion, NSString* _Nullable contentTopicName, NSString* _Nullable encoding);
FOUNDATION_EXPORT NSString* _Nonnull GowakuDecodeAsymmetric(NSString* _Nullable messageJSON, NSString* _Nullable privateKey);
FOUNDATION_EXPORT NSString* _Nonnull GowakuDecodeSymmetric(NSString* _Nullable messageJSON, NSString* _Nullable symmetricKey);
FOUNDATION_EXPORT NSString* _Nonnull GowakuDefaultPubsubTopic(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuDisconnect(NSString* _Nullable peerID);
FOUNDATION_EXPORT NSString* _Nonnull GowakuLightpushPublish(NSString* _Nullable messageJSON, NSString* _Nullable topic, NSString* _Nullable peerID, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuLightpushPublishEncodeAsymmetric(NSString* _Nullable messageJSON, NSString* _Nullable topic, NSString* _Nullable peerID, NSString* _Nullable publicKey, NSString* _Nullable optionalSigningKey, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuLightpushPublishEncodeSymmetric(NSString* _Nullable messageJSON, NSString* _Nullable topic, NSString* _Nullable peerID, NSString* _Nullable symmetricKey, NSString* _Nullable optionalSigningKey, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuListenAddresses(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuNewNode(NSString* _Nullable configJSON);
FOUNDATION_EXPORT NSString* _Nonnull GowakuPeerCnt(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuPeerID(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuPeers(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuPubsubTopic(NSString* _Nullable name, NSString* _Nullable encoding);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelayEnoughPeers(NSString* _Nullable topic);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelayPublish(NSString* _Nullable messageJSON, NSString* _Nullable topic, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelayPublishEncodeAsymmetric(NSString* _Nullable messageJSON, NSString* _Nullable topic, NSString* _Nullable publicKey, NSString* _Nullable optionalSigningKey, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelayPublishEncodeSymmetric(NSString* _Nullable messageJSON, NSString* _Nullable topic, NSString* _Nullable symmetricKey, NSString* _Nullable optionalSigningKey, long ms);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelaySubscribe(NSString* _Nullable topic);
FOUNDATION_EXPORT NSString* _Nonnull GowakuRelayUnsubscribe(NSString* _Nullable topic);
// skipped function SetEventCallback with unsupported parameter or return types
/**
* SetMobileSignalHandler setup geth callback to notify about new signal
used for gomobile builds
nolint
*/
FOUNDATION_EXPORT void GowakuSetMobileSignalHandler(id<GowakuSignalHandler> _Nullable handler);
FOUNDATION_EXPORT NSString* _Nonnull GowakuStart(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuStop(void);
FOUNDATION_EXPORT NSString* _Nonnull GowakuStoreQuery(NSString* _Nullable queryJSON, NSString* _Nullable peerID, long ms);
@class GowakuSignalHandler;
/**
* SignalHandler defines a minimal interface
a signal handler needs to implement.
nolint
*/
@interface GowakuSignalHandler : NSObject <goSeqRefInterface, GowakuSignalHandler> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (void)handleSignal:(NSString* _Nullable)p0;
@end
#endif
@@ -1,29 +0,0 @@
// Objective-C API for talking to Go package.
// gobind -lang=objc
//
// File is generated by gobind. Do not edit.
#ifndef __Universe_H__
#define __Universe_H__
@import Foundation;
#include "ref.h"
@protocol Universeerror;
@class Universeerror;
@protocol Universeerror <NSObject>
- (NSString* _Nonnull)error;
@end
@class Universeerror;
@interface Universeerror : NSError <goSeqRefInterface, Universeerror> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (NSString* _Nonnull)error;
@end
#endif
@@ -1,35 +0,0 @@
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#ifndef __GO_REF_HDR__
#define __GO_REF_HDR__
#include <Foundation/Foundation.h>
// GoSeqRef is an object tagged with an integer for passing back and
// forth across the language boundary. A GoSeqRef may represent either
// an instance of a Go object, or an Objective-C object passed to Go.
// The explicit allocation of a GoSeqRef is used to pin a Go object
// when it is passed to Objective-C. The Go seq package maintains a
// reference to the Go object in a map keyed by the refnum along with
// a reference count. When the reference count reaches zero, the Go
// seq package will clear the corresponding entry in the map.
@interface GoSeqRef : NSObject {
}
@property(readonly) int32_t refnum;
@property(strong) id obj; // NULL when representing a Go object.
// new GoSeqRef object to proxy a Go object. The refnum must be
// provided from Go side.
- (instancetype)initWithRefnum:(int32_t)refnum obj:(id)obj;
- (int32_t)incNum;
@end
@protocol goSeqRefInterface
-(GoSeqRef*) _ref;
@end
#endif
@@ -1,8 +0,0 @@
framework module "Gowaku" {
header "ref.h"
header "Gowaku.objc.h"
header "Universe.objc.h"
header "Gowaku.h"
export *
}
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
+10
View File
@@ -21,6 +21,10 @@ RCT_EXTERN_METHOD(stop:
(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(isStarted:
(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(peerID:
(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
@@ -125,4 +129,10 @@ RCT_EXTERN_METHOD(decodeAsymmetric:(NSString *)msg
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(storeQuery:(NSString *)query
withPeerID:(NSString *)peerID
withMs:(nonnull NSNumber *)ms
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
@end
+10
View File
@@ -62,6 +62,11 @@ class ReactNative: RCTEventEmitter {
resolve(GowakuStop())
}
@objc(isStarted:withRejecter:)
func isStarted(_ resolve:RCTPromiseResolveBlock, withRejecter reject:RCTPromiseRejectBlock) -> Void {
resolve(GowakuIsStarted())
}
@objc(peerID:withRejecter:)
func peerID(_ resolve:RCTPromiseResolveBlock, withRejecter reject:RCTPromiseRejectBlock) -> Void {
resolve(GowakuPeerID())
@@ -157,4 +162,9 @@ class ReactNative: RCTEventEmitter {
resolve(GowakuDecodeAsymmetric(msg, privateKey))
}
@objc(storeQuery:withPeerID:withMs:withResolver:withRejecter:)
func storeQuery(queryJSON: String, peerID: String, ms: Int, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
resolve(GowakuStoreQuery(queryJSON, peerID, ms))
}
}
+8 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@waku/react-native",
"version": "0.0.1-test1",
"version": "0.0.4",
"description": "Waku React Native",
"author": "Status Research & Development GMBH",
"authors": [
@@ -33,11 +33,16 @@
"test": "jest",
"typescript": "tsc --noEmit",
"lint": "eslint \"**/*.{js,ts,tsx}\"",
"check-gowaku": "./download-gowaku.sh",
"download-gowaku": "./download-gowaku.sh --force",
"prepare": "bob build",
"prerelease": "yarn check-gowaku",
"release": "release-it",
"example": "yarn --cwd example",
"prepods": "yarn check-gowaku",
"pods": "cd example && pod-install --quiet",
"bootstrap": "yarn example && yarn && yarn pods"
"bootstrap": "yarn check-gowaku && yarn example && yarn && yarn pods",
"prepublish": "yarn check-gowaku"
},
"keywords": [
"react-native",
@@ -51,6 +56,7 @@
},
"homepage": "https://github.com/status-im/waku-react-native#readme",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
+46 -7
View File
@@ -45,7 +45,7 @@ export function onMessage(cb: (arg0:any) => void) {
signal.event.wakuMessage.timestamp = msg.timestamp;
signal.event.wakuMessage.version = msg.version || 0;
signal.event.wakuMessage.contentTopic = msg.contentTopic;
signal.event.wakuMessage.payload = new Uint8Array(decode(msg.payload).split("").map((c:any) => c.charCodeAt(0)));
signal.event.wakuMessage.payload = new Uint8Array(decode(msg.payload ?? []).split("").map((c:any) => c.charCodeAt(0)));
cb(signal.event);
})
}
@@ -93,6 +93,17 @@ export function stop(): Promise<void> {
});
}
export function isStarted(): Promise<Boolean> {
return new Promise<Boolean>(async (resolve, reject) => {
let response = JSON.parse(await ReactNative.isStarted());
if(response.error){
reject(response.error);
} else {
resolve(response.result);
}
});
}
export function peerID(): Promise<string> {
return new Promise<string>(async (resolve, reject) => {
let response = JSON.parse(await ReactNative.peerID());
@@ -295,11 +306,6 @@ export function relayUnsubscribe(topic: String = ""): Promise<void> {
});
}
export function lightpushPublish(msg: WakuMessage, topic: String = "", peerID: String = "", ms: Number = 0): Promise<string> {
return new Promise<string>(async (resolve, reject) => {
let messageJSON = JSON.stringify(msg)
@@ -361,4 +367,37 @@ export function peers(): Promise<Array<Peer>> {
})
}
// TODO: storeQuery
export class Index {
digest: Uint8Array = new Uint8Array();
receiverTime: Number = 0
senderTime: Number = 0
pubsubTopic: String = ""
}
export class PagingOptions {
pageSize: Number = 0
cursor: Index | null = null
forward: Boolean = false
}
export class StoreQuery {
pubsubTopic: String = ""
contentFilters: Array<String> = Array()
startTime: Number = 0
endTime: Number = 0
pagingOptions: PagingOptions | null = null
}
export function storeQuery(query: StoreQuery, peerID: String = "", ms: Number = 0): Promise<string> {
return new Promise<string>(async (resolve, reject) => {
let queryJSON = JSON.stringify(query)
let response = JSON.parse(await ReactNative.storeQuery(queryJSON, peerID, ms));
console.log("STORE RESPONSE:")
console.log(response)
if(response.error){
reject(response.error);
} else {
resolve(response.result);
}
});
}