From ce3d5936ecf576d9b03ca3f271d0793a945d62a8 Mon Sep 17 00:00:00 2001 From: Oskar Thoren Date: Fri, 8 Dec 2017 12:37:50 +0100 Subject: [PATCH] Offline inboxing: End to end MVP - Turns on flag for dev and Jenkins - Change enode to peer in requestMessages arg - Upgrades status-go to get ssh_requestMessages - Use status-cluster enode - Fix Android AddPeer binding bug --- .env | 2 +- .env.jenkins | 2 +- modules/react-native-status/android/build.gradle | 2 +- .../java/im/status/ethereum/module/StatusModule.java | 2 +- modules/react-native-status/ios/RCTStatus/pom.xml | 2 +- src/status_im/protocol/core.cljs | 2 +- src/status_im/protocol/web3/inbox.cljs | 9 +++++++-- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.env b/.env index 33205cce06..0301af62a4 100644 --- a/.env +++ b/.env @@ -5,6 +5,6 @@ STUB_STATUS_GO=0 ETHEREUM_DEV_CLUSTER=1 MAINNET_NETWORKS_ENABLED=1 ERC20_ENABLED=1 -OFFLINE_INBOX_ENABLED=0 +OFFLINE_INBOX_ENABLED=1 LOG_LEVEL=debug JSC_ENABLED=1 diff --git a/.env.jenkins b/.env.jenkins index 7a1321fe7c..12717f88d4 100644 --- a/.env.jenkins +++ b/.env.jenkins @@ -5,6 +5,6 @@ STUB_STATUS_GO=0 ETHEREUM_DEV_CLUSTER=1 MAINNET_NETWORKS_ENABLED=1 ERC20_ENABLED=1 -OFFLINE_INBOX_ENABLED=0 +OFFLINE_INBOX_ENABLED=1 LOG_LEVEL=debug JSC_ENABLED=1 diff --git a/modules/react-native-status/android/build.gradle b/modules/react-native-status/android/build.gradle index f412a80b4e..2209b214c3 100644 --- a/modules/react-native-status/android/build.gradle +++ b/modules/react-native-status/android/build.gradle @@ -17,5 +17,5 @@ dependencies { compile 'com.instabug.library:instabug:3+' compile 'com.github.ericwlange:AndroidJSCore:3.0.1' compile 'status-im:function:0.0.1' - compile(group: 'status-im', name: 'status-go', version: 'develop-g5446a090', ext: 'aar') + compile(group: 'status-im', name: 'status-go', version: 'develop-gba6c9653', ext: 'aar') } diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java index 6a05921b67..d937498286 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java @@ -414,7 +414,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Thread thread = new Thread() { @Override public void run() { - String res = Statusgo.Notify(enode); + String res = Statusgo.AddPeer(enode); callback.invoke(res); } diff --git a/modules/react-native-status/ios/RCTStatus/pom.xml b/modules/react-native-status/ios/RCTStatus/pom.xml index 0a5daea5f9..76ee49584f 100644 --- a/modules/react-native-status/ios/RCTStatus/pom.xml +++ b/modules/react-native-status/ios/RCTStatus/pom.xml @@ -25,7 +25,7 @@ status-im status-go-ios-simulator - develop-g5446a090 + develop-gba6c9653 zip true ./ diff --git a/src/status_im/protocol/core.cljs b/src/status_im/protocol/core.cljs index 9d2f750e15..b214288e5e 100644 --- a/src/status_im/protocol/core.cljs +++ b/src/status_im/protocol/core.cljs @@ -102,7 +102,7 @@ (l/message-listener listener-options)) (inbox/request-messages! web3 - {} + {:enode inbox/cluster-enode} #(log/info "offline inbox: request-messages response" %))) (f/add-filter! web3 diff --git a/src/status_im/protocol/web3/inbox.cljs b/src/status_im/protocol/web3/inbox.cljs index 9914c3f498..ff042289a8 100644 --- a/src/status_im/protocol/web3/inbox.cljs +++ b/src/status_im/protocol/web3/inbox.cljs @@ -14,8 +14,10 @@ ;; TODO(oskarth): Hardcoded to local enode for preMVP, will be in bootnodes later (def default-enode "enode://0f51d75c9469de0852571c4618fe151265d4930ea35f968eb1a12e69c12f7cbabed856a12b31268a825ca2c9bafa47ef665b1b17be1ab71de83338c4b7439b24@127.0.0.1:30303") +;; adamb's status-cluster enode +(def cluster-enode "enode://08d8eb6177b187049f6c97ed3f6c74fbbefb94c7ad10bafcaf4b65ce89c314dcfee0a8bc4e7a5b824dfa08b45b360cc78f34f0aff981f8386caa07652d2e601b@163.172.177.138:40404") + ;; TODO(oskarth): Rewrite callback-heavy code with CSP and/or coeffects -;; NOTE(oskarth): Exact params still being determined ;; TODO(oskarth): Memoize addPeer and markTrusted, similar to keys/get-sym-key ;; TODO(oskarth): Actually deal with errors, all in same cb - outside scope of this (defn request-messages! [web3 {:keys [enode topic password] @@ -42,13 +44,16 @@ (let [args {:jsonrpc "2.0" :id 2 :method "shh_requestMessages" - :params [{:enode enode + :params [{:peer enode :topic topic :symKeyID sym-key-id :from 0 :to 1612505820}]} payload (.stringify js/JSON (clj->js args))] (log/info "offline inbox: request-messages request") + (log/info "offline inbox: request-messages args" (pr-str args)) + (log/info "offline inbox: request-messages payload" (pr-str payload)) + (status/call-web3 payload callback)))))))))) ;; TODO(oskarth): Use web3 binding to do (.markTrustedPeer web3 enode cb)