From a2af83f0340abe89e6437479fc1eedf95a597ade Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Thu, 30 Jan 2020 12:39:22 +0100 Subject: [PATCH] Add option to enable waku-mode This commit adds an option to enable waku mode through ENV settings. Signed-off-by: Andrea Maria Piana --- .../status/ethereum/module/StatusModule.java | 20 ------- .../react-native-status/desktop/rctstatus.cpp | 12 ---- .../react-native-status/desktop/rctstatus.h | 1 - .../ios/RCTStatus/RCTStatus.m | 10 ---- src/status_im/chat/models/message.cljs | 5 +- src/status_im/commands/core.cljs | 13 ++++- src/status_im/contact/core.cljs | 4 +- src/status_im/data_store/chats.cljs | 9 ++- src/status_im/data_store/contacts.cljs | 13 ++++- src/status_im/data_store/messages.cljs | 29 +++++++--- src/status_im/ens/core.cljs | 5 +- src/status_im/ethereum/json_rpc.cljs | 56 ++++++++++++++++++- src/status_im/group_chats/core.cljs | 29 +++++++--- src/status_im/mailserver/core.cljs | 21 ++++--- src/status_im/multiaccounts/update/core.cljs | 5 +- .../multiaccounts/update/publisher.cljs | 5 +- src/status_im/node/core.cljs | 7 ++- src/status_im/pairing/core.cljs | 24 ++++++-- src/status_im/signing/core.cljs | 9 ++- src/status_im/transport/core.cljs | 4 +- src/status_im/transport/filters/core.cljs | 9 ++- src/status_im/transport/message/protocol.cljs | 5 +- src/status_im/transport/shh.cljs | 9 ++- src/status_im/utils/config.cljs | 1 + src/status_im/wallet/core.cljs | 8 ++- status-go-version.json | 6 +- 26 files changed, 218 insertions(+), 101 deletions(-) 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 a29f2a6507..804bc184d3 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 @@ -1106,26 +1106,6 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL } - @ReactMethod - public void updateMailservers(final String enodes, final Callback callback) { - Log.d(TAG, "updateMailservers"); - if (!checkAvailability()) { - callback.invoke(false); - return; - } - - Runnable r = new Runnable() { - @Override - public void run() { - String res = Statusgo.updateMailservers(enodes); - - callback.invoke(res); - } - }; - - StatusThreadPoolExecutor.getInstance().execute(r); - } - @ReactMethod public void chaosModeUpdate(final boolean on, final Callback callback) { Log.d(TAG, "chaosModeUpdate"); diff --git a/modules/react-native-status/desktop/rctstatus.cpp b/modules/react-native-status/desktop/rctstatus.cpp index c09b1558fb..332e518269 100644 --- a/modules/react-native-status/desktop/rctstatus.cpp +++ b/modules/react-native-status/desktop/rctstatus.cpp @@ -610,18 +610,6 @@ void RCTStatus::logStatusGoResult(const char *methodName, const char *result) { } } -void RCTStatus::updateMailservers(QString enodes, double callbackId) { - Q_D(RCTStatus); - qCDebug(RCTSTATUS) << "::updateMailservers call - callbackId:" << callbackId; - QtConcurrent::run( - [&](QString enodes, double callbackId) { - const char *result = UpdateMailservers(enodes.toUtf8().data()); - logStatusGoResult("::updateMailservers UpdateMailservers", result); - d->bridge->invokePromiseCallback(callbackId, QVariantList{result}); - }, - enodes, callbackId); -} - void RCTStatus::getNodesFromContract(QString url, QString address, double callbackId) { Q_D(RCTStatus); diff --git a/modules/react-native-status/desktop/rctstatus.h b/modules/react-native-status/desktop/rctstatus.h index 603d88b82b..c85a930998 100644 --- a/modules/react-native-status/desktop/rctstatus.h +++ b/modules/react-native-status/desktop/rctstatus.h @@ -72,7 +72,6 @@ public: Q_INVOKABLE void signGroupMembership(QString content, double callbackId); Q_INVOKABLE void extractGroupMembershipSignatures(QString signatures, double callbackId); - Q_INVOKABLE void updateMailservers(QString enodes, double callbackId); Q_INVOKABLE void getNodesFromContract(QString url, QString address, double callbackId); Q_INVOKABLE void chaosModeUpdate(bool on, double callbackId); diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.m b/modules/react-native-status/ios/RCTStatus/RCTStatus.m index eabfb17050..8071ce20c8 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.m +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.m @@ -196,16 +196,6 @@ RCT_EXPORT_METHOD(addPeer:(NSString *)enode #endif } -//////////////////////////////////////////////////////////////////// updateMailservers -RCT_EXPORT_METHOD(updateMailservers:(NSString *)enodes - callback:(RCTResponseSenderBlock)callback) { - NSString* result = StatusgoUpdateMailservers(enodes); - callback(@[result]); -#if DEBUG - NSLog(@"UpdateMailservers() method called"); -#endif -} - //////////////////////////////////////////////////////////////////// getNodesFromContract RCT_EXPORT_METHOD(getNodesFromContract:(NSString *)url address:(NSString *) address diff --git a/src/status_im/chat/models/message.cljs b/src/status_im/chat/models/message.cljs index c1fa3c60fe..88d8499e37 100644 --- a/src/status_im/chat/models/message.cljs +++ b/src/status_im/chat/models/message.cljs @@ -2,6 +2,7 @@ (:require [re-frame.core :as re-frame] [status-im.multiaccounts.model :as multiaccounts.model] [status-im.ethereum.json-rpc :as json-rpc] + [status-im.utils.config :as config] [status-im.chat.db :as chat.db] [status-im.chat.models :as chat-model] [status-im.chat.models.loading :as chat-loading] @@ -208,7 +209,9 @@ (fx/defn resend-message [{:keys [db] :as cofx} chat-id message-id] (fx/merge cofx - {::json-rpc/call [{:method "shhext_reSendChatMessage" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_reSendChatMessage" + "shhext_reSendChatMessage") :params [message-id] :on-success #(log/debug "re-sent message successfully") :on-error #(log/error "failed to re-send message" %)}]} diff --git a/src/status_im/commands/core.cljs b/src/status_im/commands/core.cljs index 415b870f11..a41ce13020 100644 --- a/src/status_im/commands/core.cljs +++ b/src/status_im/commands/core.cljs @@ -2,6 +2,7 @@ (:require [re-frame.core :as re-frame] [status-im.ethereum.core :as ethereum] + [status-im.utils.config :as config] [status-im.ethereum.json-rpc :as json-rpc] [status-im.utils.fx :as fx])) @@ -23,20 +24,26 @@ {:events [::accept-request-address-for-transaction]} [{:keys [db]} message-id address] {:db (dissoc db :commands/select-account) - ::json-rpc/call [{:method "shhext_acceptRequestAddressForTransaction" + ::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_acceptRequestAddressForTransaction" + "shhext_acceptRequestAddressForTransaction") :params [message-id address] :on-success #(re-frame/dispatch [:transport/message-sent % 1])}]}) (fx/defn handle-decline-request-address-for-transaction {:events [::decline-request-address-for-transaction]} [cofx message-id] - {::json-rpc/call [{:method "shhext_declineRequestAddressForTransaction" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_declineRequestAddressForTransaction" + "shhext_declineRequestAddressForTransaction") :params [message-id] :on-success #(re-frame/dispatch [:transport/message-sent % 1])}]}) (fx/defn handle-decline-request-transaction {:events [::decline-request-transaction]} [cofx message-id] - {::json-rpc/call [{:method "shhext_declineRequestTransaction" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_declineRequestTransaction" + "shhext_declineRequestTransaction") :params [message-id] :on-success #(re-frame/dispatch [:transport/message-sent % 1])}]}) diff --git a/src/status_im/contact/core.cljs b/src/status_im/contact/core.cljs index 68b4d47764..731d31880c 100644 --- a/src/status_im/contact/core.cljs +++ b/src/status_im/contact/core.cljs @@ -86,7 +86,9 @@ (fx/defn send-contact-request [{:keys [db] :as cofx} {:keys [public-key] :as contact}] (let [{:keys [name profile-image]} (own-info db)] - {::json-rpc/call [{:method "shhext_sendContactUpdate" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_sendContactUpdate" + "shhext_sendContactUpdate") :params [public-key name profile-image] :on-success #(log/debug "contact request sent" public-key)}]})) diff --git a/src/status_im/data_store/chats.cljs b/src/status_im/data_store/chats.cljs index 821c30081a..ec80bb8fbe 100644 --- a/src/status_im/data_store/chats.cljs +++ b/src/status_im/data_store/chats.cljs @@ -2,6 +2,7 @@ (:require [goog.object :as object] [re-frame.core :as re-frame] [status-im.data-store.messages :as messages] + [status-im.utils.config :as config] [status-im.utils.fx :as fx] [status-im.ethereum.json-rpc :as json-rpc] [status-im.ethereum.core :as ethereum] @@ -113,13 +114,17 @@ (dissoc :chatType :members))) (fx/defn save-chat [cofx {:keys [chat-id] :as chat}] - {::json-rpc/call [{:method "shhext_saveChat" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_saveChat" + "shhext_saveChat") :params [(->rpc chat)] :on-success #(log/debug "saved chat" chat-id "successfuly") :on-failure #(log/error "failed to save chat" chat-id %)}]}) (fx/defn fetch-chats-rpc [cofx {:keys [on-success]}] - {::json-rpc/call [{:method "shhext_chats" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_chats" + "shhext_chats") :params [] :on-success #(on-success (map <-rpc %)) :on-failure #(log/error "failed to fetch chats" 0 -1 %)}]}) diff --git a/src/status_im/data_store/contacts.cljs b/src/status_im/data_store/contacts.cljs index e3382d8897..d6bb45f4d3 100644 --- a/src/status_im/data_store/contacts.cljs +++ b/src/status_im/data_store/contacts.cljs @@ -1,6 +1,7 @@ (ns status-im.data-store.contacts (:require [re-frame.core :as re-frame] [status-im.utils.fx :as fx] + [status-im.utils.config :as config] [status-im.data-store.chats :as data-store.chats] [status-im.ethereum.json-rpc :as json-rpc] [taoensso.timbre :as log] @@ -45,20 +46,26 @@ (fx/defn fetch-contacts-rpc [cofx on-success] - {::json-rpc/call [{:method "shhext_contacts" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_contacts" + "shhext_contacts") :params [] :on-success #(on-success (map <-rpc %)) :on-failure #(log/error "failed to fetch contacts" %)}]}) (fx/defn save-contact [cofx {:keys [public-key] :as contact}] - {::json-rpc/call [{:method "shhext_saveContact" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_saveContact" + "shhext_saveContact") :params [(->rpc contact)] :on-success #(log/debug "saved contact" public-key "successfuly") :on-failure #(log/error "failed to save contact" public-key %)}]}) (fx/defn block [cofx contact on-success] - {::json-rpc/call [{:method "shhext_blockContact" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_blockContact" + "shhext_blockContact") :params [(->rpc contact)] :on-success on-success :on-failure #(log/error "failed to block contact" % contact)}]}) diff --git a/src/status_im/data_store/messages.cljs b/src/status_im/data_store/messages.cljs index cb6102f700..ba3c863e57 100644 --- a/src/status_im/data_store/messages.cljs +++ b/src/status_im/data_store/messages.cljs @@ -6,6 +6,7 @@ [taoensso.timbre :as log] [re-frame.core :as re-frame] [status-im.utils.types :as utils.types] + [status-im.utils.config :as config] [status-im.ethereum.json-rpc :as json-rpc] [status-im.constants :as constants] [status-im.utils.core :as utils])) @@ -46,13 +47,17 @@ (dissoc :ensName :chatId :text :rtl :responseTo :sticker :lineCount :parsedText))) (defn update-outgoing-status-rpc [message-id status] - {::json-rpc/call [{:method "shhext_updateMessageOutgoingStatus" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_updateMessageOutgoingStatus" + "shhext_updateMessageOutgoingStatus") :params [message-id status] :on-success #(log/debug "updated message outgoing stauts" message-id status) :on-failure #(log/error "failed to update message outgoing status" message-id status %)}]}) (defn save-system-messages-rpc [messages] - (json-rpc/call {:method "shhext_addSystemMessages" + (json-rpc/call {:method (if config/waku-enabled? + "wakuext_addSystemMessages" + "shhext_addSystemMessages") :params [(map ->rpc messages)] :on-success #(re-frame/dispatch [:messages/system-messages-saved (map <-rpc %)]) :on-failure #(log/error "failed to save messages" %)})) @@ -62,32 +67,42 @@ limit on-success on-failure] - {::json-rpc/call [{:method "shhext_chatMessages" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_chatMessages" + "shhext_chatMessages") :params [chat-id cursor limit] :on-success (fn [result] (on-success (update result :messages #(map <-rpc %)))) :on-failure on-failure}]}) (defn mark-seen-rpc [chat-id ids] - {::json-rpc/call [{:method "shhext_markMessagesSeen" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_markMessagesSeen" + "shhext_markMessagesSeen") :params [chat-id ids] :on-success #(log/debug "successfully marked as seen") :on-failure #(log/error "failed to get messages" %)}]}) (defn delete-message-rpc [id] - {::json-rpc/call [{:method "shhext_deleteMessage" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_deleteMessage" + "shhext_deleteMessage") :params [id] :on-success #(log/debug "successfully deleted message" id) :on-failure #(log/error "failed to delete message" % id)}]}) (defn delete-messages-from-rpc [author] - {::json-rpc/call [{:method "shhext_deleteMessagesFrom" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_deleteMessagesFrom" + "shhext_deleteMessagesFrom") :params [author] :on-success #(log/debug "successfully deleted messages from" author) :on-failure #(log/error "failed to delete messages from" % author)}]}) (defn delete-messages-by-chat-id-rpc [chat-id] - {::json-rpc/call [{:method "shhext_deleteMessagesByChatID" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_deleteMessagesByChatID" + "shhext_deleteMessagesByChatID") :params [chat-id] :on-success #(log/debug "successfully deleted messages by chat-id" chat-id) :on-failure #(log/error "failed to delete messages by chat-id" % chat-id)}]}) diff --git a/src/status_im/ens/core.cljs b/src/status_im/ens/core.cljs index c97b2a4de3..1216f9ad6e 100644 --- a/src/status_im/ens/core.cljs +++ b/src/status_im/ens/core.cljs @@ -6,6 +6,7 @@ [status-im.utils.datetime :as datetime] [status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.multiaccounts.model :as multiaccounts.model] + [status-im.utils.config :as config] [status-im.ethereum.abi-spec :as abi-spec] [status-im.ethereum.contracts :as contracts] [status-im.ethereum.core :as ethereum] @@ -292,7 +293,9 @@ (navigation/navigate-to-cofx :ens-search {}))) (defn verify-names [names] - (json-rpc/call {:method "shhext_verifyENSNames" + (json-rpc/call {:method (if config/waku-enabled? + "wakuext_verifyENSNames" + "shhext_verifyENSNames") :params [names] :on-success #(re-frame/dispatch [:contacts/ens-names-verified %]) :on-failure #(log/error "failed to resolve ens names" % names)})) diff --git a/src/status_im/ethereum/json_rpc.cljs b/src/status_im/ethereum/json_rpc.cljs index 261a2c2d13..137a150310 100644 --- a/src/status_im/ethereum/json_rpc.cljs +++ b/src/status_im/ethereum/json_rpc.cljs @@ -27,10 +27,13 @@ "eth_syncing" {} "net_version" {} "web3_clientVersion" {} - "shhext_post" {} "shh_generateSymKeyFromPassword" {} "shh_getSymKey" {} "shh_markTrustedPeer" {} + "waku_generateSymKeyFromPassword" {} + "waku_getSymKey" {} + "waku_markTrustedPeer" {} + "shhext_post" {} "shhext_startMessenger" {} "shhext_sendPairInstallation" {} "shhext_syncDevices" {} @@ -68,6 +71,7 @@ "shhext_contacts" {} "shhext_prepareContent" {} "shhext_blockContact" {} + "shhext_updateMailservers" {} ;;TODO not used anywhere? "shhext_deleteChat" {} "shhext_saveContact" {} @@ -79,6 +83,56 @@ "shhext_declineRequestTransaction" {} "shhext_sendTransaction" {} "shhext_acceptRequestTransaction" {} + "wakuext_post" {} + "wakuext_startMessenger" {} + "wakuext_sendPairInstallation" {} + "wakuext_syncDevices" {} + "wakuext_requestMessages" {} + "wakuext_sendDirectMessage" {} + "wakuext_sendPublicMessage" {} + "wakuext_enableInstallation" {} + "wakuext_disableInstallation" {} + "wakuext_sendChatMessage" {} + "wakuext_confirmJoiningGroup" {} + "wakuext_addAdminsToGroupChat" {} + "wakuext_addMembersToGroupChat" {} + "wakuext_removeMemberFromGroupChat" {} + "wakuext_leaveGroupChat" {} + "wakuext_changeGroupChatName" {} + "wakuext_createGroupChatWithMembers" {} + "wakuext_reSendChatMessage" {} + "wakuext_getOurInstallations" {} + "wakuext_setInstallationMetadata" {} + "wakuext_loadFilters" {} + "wakuext_loadFilter" {} + "wakuext_removeFilters" {} + "wakuext_sendContactUpdate" {} + "wakuext_sendContactUpdates" {} + "wakuext_chats" {} + "wakuext_addSystemMessages" {} + "wakuext_deleteMessagesFrom" {} + "wakuext_deleteMessagesByChatID" {} + "wakuext_deleteMessage" {} + "wakuext_markMessagesSeen" {} + "wakuext_confirmMessagesProcessedByID" {} + "wakuext_updateMessageOutgoingStatus" {} + "wakuext_chatMessages" {} + "wakuext_saveChat" {} + "wakuext_contacts" {} + "wakuext_prepareContent" {} + "wakuext_blockContact" {} + "wakuext_updateMailservers" {} + ;;TODO not used anywhere? + "wakuext_deleteChat" {} + "wakuext_saveContact" {} + "wakuext_verifyENSNames" {} + "wakuext_requestAddressForTransaction" {} + "wakuext_requestTransaction" {} + "wakuext_acceptRequestAddressForTransaction" {} + "wakuext_declineRequestAddressForTransaction" {} + "wakuext_declineRequestTransaction" {} + "wakuext_sendTransaction" {} + "wakuext_acceptRequestTransaction" {} "status_chats" {} "wallet_getTransfers" {} "wallet_getTokensBalances" {} diff --git a/src/status_im/group_chats/core.cljs b/src/status_im/group_chats/core.cljs index a842023319..81091bb05c 100644 --- a/src/status_im/group_chats/core.cljs +++ b/src/status_im/group_chats/core.cljs @@ -5,6 +5,7 @@ [clojure.string :as string] [status-im.ethereum.json-rpc :as json-rpc] [re-frame.core :as re-frame] + [status-im.utils.config :as config] [status-im.constants :as constants] [status-im.chat.models.message-content :as message-content] [status-im.ui.screens.navigation :as navigation] @@ -30,7 +31,9 @@ (fx/defn remove-member "Format group update message and sign membership" [{:keys [db] :as cofx} chat-id member] - {::json-rpc/call [{:method "shhext_removeMemberFromGroupChat" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_removeMemberFromGroupChat" + "shhext_removeMemberFromGroupChat") :params [nil chat-id member] :on-success #(re-frame/dispatch [::chat-updated %])}]}) @@ -73,33 +76,43 @@ (fx/defn join-chat [cofx chat-id] - {::json-rpc/call [{:method "shhext_confirmJoiningGroup" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_confirmJoiningGroup" + "shhext_confirmJoiningGroup") :params [chat-id] :on-success #(re-frame/dispatch [::chat-updated %])}]}) (fx/defn create [{:keys [db] :as cofx} group-name] (let [selected-contacts (:group/selected-contacts db)] - {::json-rpc/call [{:method "shhext_createGroupChatWithMembers" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_createGroupChatWithMembers" + "shhext_createGroupChatWithMembers") :params [nil group-name (into [] selected-contacts)] :on-success #(re-frame/dispatch [::chat-updated %])}]})) (fx/defn make-admin [{:keys [db] :as cofx} chat-id member] - {::json-rpc/call [{:method "shhext_addAdminsToGroupChat" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_addAdminsToGroupChat" + "shhext_addAdminsToGroupChat") :params [nil chat-id [member]] :on-success #(re-frame/dispatch [::chat-updated %])}]}) (fx/defn add-members "Add members to a group chat" [{{:keys [current-chat-id selected-participants]} :db :as cofx}] - {::json-rpc/call [{:method "shhext_addMembersToGroupChat" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_addMembersToGroupChat" + "shhext_addMembersToGroupChat") :params [nil current-chat-id selected-participants] :on-success #(re-frame/dispatch [::chat-updated %])}]}) (fx/defn remove "Remove & leave chat" [{:keys [db] :as cofx} chat-id] - {::json-rpc/call [{:method "shhext_leaveGroupChat" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_leaveGroupChat" + "shhext_leaveGroupChat") :params [nil chat-id] :on-success #(re-frame/dispatch [::chat-updated %])}]}) @@ -122,7 +135,9 @@ (let [new-name (get-in cofx [:db :group-chat-profile/profile :name]) current-chat-id (:current-chat-id db)] (when (valid-name? new-name) - {::json-rpc/call [{:method "shhext_changeGroupChatName" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_changeGroupChatName" + "shhext_changeGroupChatName") :params [nil current-chat-id new-name] :on-success #(re-frame/dispatch [::chat-updated %])}]}))) diff --git a/src/status_im/mailserver/core.cljs b/src/status_im/mailserver/core.cljs index 6c10cb8183..318dc15c6a 100644 --- a/src/status_im/mailserver/core.cljs +++ b/src/status_im/mailserver/core.cljs @@ -87,13 +87,14 @@ ;; We now wait for a confirmation from the mailserver before marking the message ;; as sent. - (defn update-mailservers! [enodes] - (status/update-mailservers - (.stringify js/JSON (clj->js enodes)) - (handlers/response-handler - #(log/debug "mailserver: update-mailservers success" %) - #(log/error "mailserver: update-mailservers error" %)))) + (json-rpc/call + {:method (if config/waku-enabled? + "wakuext_updateMailservers" + "shhext_updateMailservers") + :params [enodes] + :on-success #(log/debug "mailserver: update-mailservers success" %) + :on-error #(log/error "mailserver: update-mailservers error" %)})) (defn remove-peer! [enode] (let [args {:jsonrpc "2.0" @@ -147,7 +148,9 @@ (defn mark-trusted-peer! [enode] (json-rpc/call - {:method "shh_markTrustedPeer" + {:method (if config/waku-enabled? + "waku_markTrustedPeer" + "shh_markTrustedPeer") :params [enode] :on-success #(re-frame/dispatch [:mailserver.callback/mark-trusted-peer-success %]) @@ -360,7 +363,9 @@ " cursor " cursor " limit " actual-limit) (json-rpc/call - {:method "shhext_requestMessages" + {:method (if config/waku-enabled? + "wakuext_requestMessages" + "shhext_requestMessages") :params [(cond-> {:topics topics :mailServerPeer address :symKeyID sym-key-id diff --git a/src/status_im/multiaccounts/update/core.cljs b/src/status_im/multiaccounts/update/core.cljs index 93ac77c98f..0de9deccb9 100644 --- a/src/status_im/multiaccounts/update/core.cljs +++ b/src/status_im/multiaccounts/update/core.cljs @@ -1,5 +1,6 @@ (ns status-im.multiaccounts.update.core (:require [status-im.contact.db :as contact.db] + [status-im.utils.config :as config] [status-im.ethereum.json-rpc :as json-rpc] [status-im.transport.message.protocol :as protocol] [status-im.utils.fx :as fx] @@ -9,7 +10,9 @@ (fx/defn send-multiaccount-update [{:keys [db]}] (let [multiaccount (:multiaccount db) {:keys [name preferred-name photo-path address]} multiaccount] - {::json-rpc/call [{:method "shhext_sendContactUpdates" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_sendContactUpdates" + "shhext_sendContactUpdates") :params [(or preferred-name name) photo-path] :on-success #(log/debug "sent contact update")}]})) diff --git a/src/status_im/multiaccounts/update/publisher.cljs b/src/status_im/multiaccounts/update/publisher.cljs index c12631a162..01330ed691 100644 --- a/src/status_im/multiaccounts/update/publisher.cljs +++ b/src/status_im/multiaccounts/update/publisher.cljs @@ -1,6 +1,7 @@ (ns status-im.multiaccounts.update.publisher (:require [taoensso.timbre :as log] [re-frame.core :as re-frame] + [status-im.utils.config :as config] [status-im.constants :as constants] [status-im.multiaccounts.update.core :as multiaccounts] [status-im.ethereum.json-rpc :as json-rpc] @@ -24,7 +25,9 @@ {:keys [name preferred-name photo-path address]} multiaccount] (log/debug "sending contact updates") - (json-rpc/call {:method "shhext_sendContactUpdates" + (json-rpc/call {:method (if config/waku-enabled? + "wakuext_sendContactUpdates" + "shhext_sendContactUpdates") :params [(or preferred-name name) photo-path] :on-failure #(do (log/warn "failed to send contact updates") diff --git a/src/status_im/node/core.cljs b/src/status_im/node/core.cljs index 1f891f1237..cae49c0a0f 100644 --- a/src/status_im/node/core.cljs +++ b/src/status_im/node/core.cljs @@ -122,9 +122,10 @@ :PermissionsConfig {:Enabled true} :MailserversConfig {:Enabled true} :EnableNTPSync true - :WhisperConfig {:Enabled true - :LightClient true - :MinimumPoW 0.001} + (if config/waku-enabled? :WakuConfig :WhisperConfig) + {:Enabled true + :LightClient true + :MinimumPoW 0.001} :ShhextConfig {:BackupDisabledDataDir (utils.platform/no-backup-directory) :InstallationID installation-id diff --git a/src/status_im/pairing/core.cljs b/src/status_im/pairing/core.cljs index 9eaed94ec3..788325e281 100644 --- a/src/status_im/pairing/core.cljs +++ b/src/status_im/pairing/core.cljs @@ -19,25 +19,33 @@ [status-im.utils.types :as types])) (defn enable-installation-rpc [installation-id on-success on-failure] - (json-rpc/call {:method "shhext_enableInstallation" + (json-rpc/call {:method (if config/waku-enabled? + "wakuext_enableInstallation" + "shhext_enableInstallation") :params [installation-id] :on-success on-success :on-failure on-failure})) (defn disable-installation-rpc [installation-id on-success on-failure] - (json-rpc/call {:method "shhext_disableInstallation" + (json-rpc/call {:method (if config/waku-enabled? + "wakuext_disableInstallation" + "shhext_disableInstallation") :params [installation-id] :on-success on-success :on-failure on-failure})) (defn set-installation-metadata-rpc [installation-id metadata on-success on-failure] - (json-rpc/call {:method "shhext_setInstallationMetadata" + (json-rpc/call {:method (if config/waku-enabled? + "wakuext_setInstallationMetadata" + "shhext_setInstallationMetadata") :params [installation-id metadata] :on-success on-success :on-failure on-failure})) (defn get-our-installations-rpc [on-success on-failure] - (json-rpc/call {:method "shhext_getOurInstallations" + (json-rpc/call {:method (if config/waku-enabled? + "wakuext_getOurInstallations" + "shhext_getOurInstallations") :params [] :on-success on-success :on-failure on-failure})) @@ -65,7 +73,9 @@ (defn send-pair-installation [cofx] - {::json-rpc/call [{:method "shhext_sendPairInstallation" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_sendPairInstallation" + "shhext_sendPairInstallation") :params [] :on-success #(log/info "sent pair installation message")}]}) @@ -189,7 +199,9 @@ (defn send-installation-messages [{:keys [db]}] (let [multiaccount (:multiaccount db) {:keys [name preferred-name photo-path]} multiaccount] - {::json-rpc/call [{:method "shhext_syncDevices" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_syncDevices" + "shhext_syncDevices") :params [(or preferred-name name) photo-path] :on-success #(log/debug "successfully synced devices")}]})) diff --git a/src/status_im/signing/core.cljs b/src/status_im/signing/core.cljs index 089b45af80..c226770313 100644 --- a/src/status_im/signing/core.cljs +++ b/src/status_im/signing/core.cljs @@ -2,6 +2,7 @@ (:require [clojure.string :as string] [re-frame.core :as re-frame] [status-im.constants :as constants] + [status-im.utils.config :as config] [status-im.ethereum.abi-spec :as abi-spec] [status-im.ethereum.json-rpc :as json-rpc] [status-im.ethereum.core :as ethereum] @@ -211,7 +212,9 @@ (fx/defn send-transaction-message {:events [::send-transaction-message]} [cofx chat-id value contract transaction-hash signature] - {::json-rpc/call [{:method "shhext_sendTransaction" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_sendTransaction" + "shhext_sendTransaction") :params [chat-id value contract transaction-hash (:result (types/json->clj signature))] :on-success @@ -220,7 +223,9 @@ (fx/defn send-accept-request-transaction-message {:events [::send-accept-transaction-message]} [cofx message-id transaction-hash signature] - {::json-rpc/call [{:method "shhext_acceptRequestTransaction" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_acceptRequestTransaction" + "shhext_acceptRequestTransaction") :params [transaction-hash message-id (:result (types/json->clj signature))] :on-success diff --git a/src/status_im/transport/core.cljs b/src/status_im/transport/core.cljs index 6d4f2f19a3..20d5eadc84 100644 --- a/src/status_im/transport/core.cljs +++ b/src/status_im/transport/core.cljs @@ -40,7 +40,9 @@ initializiation is completed, otherwise we might receive messages/topics when the state has not been properly initialized." [cofx] - {::json-rpc/call [{:method "shhext_startMessenger" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_startMessenger" + "shhext_startMessenger") :on-success #(do (log/debug "messenger initialized") (re-frame/dispatch [::init-whisper])) diff --git a/src/status_im/transport/filters/core.cljs b/src/status_im/transport/filters/core.cljs index 49ce298842..0af0f0895e 100644 --- a/src/status_im/transport/filters/core.cljs +++ b/src/status_im/transport/filters/core.cljs @@ -7,6 +7,7 @@ [status-im.contact.db :as contact.db] [status-im.ethereum.json-rpc :as json-rpc] [status-im.utils.fx :as fx] + [status-im.utils.config :as config] [status-im.utils.handlers :as handlers] [status-im.mailserver.topics :as mailserver.topics] [status-im.mailserver.core :as mailserver] @@ -17,13 +18,17 @@ (string/starts-with? k "0x")) (defn load-filters-rpc [chats on-success on-failure] - (json-rpc/call {:method "shhext_loadFilters" + (json-rpc/call {:method (if config/waku-enabled? + "wakuext_loadFilters" + "shhext_loadFilters") :params [chats] :on-success on-success :on-failure on-failure})) (defn remove-filters-rpc [chats on-success on-failure] - (json-rpc/call {:method "shhext_removeFilters" + (json-rpc/call {:method (if config/waku-enabled? + "wakuext_removeFilters" + "shhext_removeFilters") :params [chats] :on-success on-success :on-failure on-failure})) diff --git a/src/status_im/transport/message/protocol.cljs b/src/status_im/transport/message/protocol.cljs index e2c885d79b..0663b0c89b 100644 --- a/src/status_im/transport/message/protocol.cljs +++ b/src/status_im/transport/message/protocol.cljs @@ -2,6 +2,7 @@ status-im.transport.message.protocol (:require [re-frame.core :as re-frame] [status-im.ethereum.json-rpc :as json-rpc] + [status-im.utils.config :as config] [status-im.utils.fx :as fx] [taoensso.timbre :as log])) @@ -13,7 +14,9 @@ sticker content-type] :as message}] - {::json-rpc/call [{:method "shhext_sendChatMessage" + {::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_sendChatMessage" + "shhext_sendChatMessage") :params [{:chatId chat-id :text text :responseTo response-to diff --git a/src/status_im/transport/shh.cljs b/src/status_im/transport/shh.cljs index 8c79982d47..c6374ffafc 100644 --- a/src/status_im/transport/shh.cljs +++ b/src/status_im/transport/shh.cljs @@ -3,19 +3,24 @@ (:require [re-frame.core :as re-frame] [status-im.ethereum.core :as ethereum] [status-im.transport.utils :as transport.utils] + [status-im.utils.config :as config] [taoensso.timbre :as log] [status-im.ethereum.json-rpc :as json-rpc])) (defn generate-sym-key-from-password [{:keys [password on-success on-error]}] - (json-rpc/call {:method "shh_generateSymKeyFromPassword" + (json-rpc/call {:method (if config/waku-enabled? + "waku_generateSymKeyFromPassword" + "shh_generateSymKeyFromPassword") :params [password] :on-success on-success :on-error on-error})) (defn get-sym-key [{:keys [sym-key-id on-success on-error]}] - (json-rpc/call {:method "shh_getSymKey" + (json-rpc/call {:method (if config/waku-enabled? + "waku_getSymKey" + "shh_getSymKey") :params [sym-key-id] :on-success on-success :on-error on-error})) diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index 608f55efa5..644b711d57 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -37,6 +37,7 @@ (def group-chat-enabled? (enabled? (get-config :GROUP_CHATS_ENABLED "0"))) (def tooltip-events? (enabled? (get-config :TOOLTIP_EVENTS "0"))) (def nimbus-enabled? (enabled? (get-config :STATUS_GO_ENABLE_NIMBUS "0"))) +(def waku-enabled? (enabled? (get-config :WAKU_ENABLED "0"))) ;; CONFIG VALUES (def log-level diff --git a/src/status_im/wallet/core.cljs b/src/status_im/wallet/core.cljs index 3ebe512826..ae03a00d12 100644 --- a/src/status_im/wallet/core.cljs +++ b/src/status_im/wallet/core.cljs @@ -422,7 +422,9 @@ [to-norm amount-hex])})})) {:db db ::json-rpc/call - [{:method "shhext_requestAddressForTransaction" + [{:method (if config/waku-enabled? + "wakuext_requestAddressForTransaction" + "shhext_requestAddressForTransaction") :params [(:current-chat-id db) from-address amount @@ -441,7 +443,9 @@ {:db (-> db (update-in [:chat-ui-props identity] dissoc :input-bottom-sheet) (dissoc db :wallet/prepare-transaction)) - ::json-rpc/call [{:method "shhext_requestTransaction" + ::json-rpc/call [{:method (if config/waku-enabled? + "wakuext_requestTransaction" + "shhext_requestTransaction") :params [(:public-key to) amount (when-not (= symbol :ETH) diff --git a/status-go-version.json b/status-go-version.json index 743569d3c8..95716797df 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.44.2", - "commit-sha1": "fdcefb8dc298b334be601ad7e330f14bdb066fc5", - "src-sha256": "19shkxqqwdz218d436fkbfcp8n257r55mnbr467kdm2ac973pnv1" + "version": "v0.45.1", + "commit-sha1": "9c2c08d44c839895f7e98a0c8f652d094d53cb2f", + "src-sha256": "0b03q4znblj737bgdbxi7qqpxqamii5ja8hw8rk1br0lll4i1jcr" }