From 2f734a68e3d3df75975085078a26d9bb0e9f5ab5 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Sat, 2 Jul 2016 10:54:43 +0300 Subject: [PATCH] changes that allow command messages to be sent over whisper --- src/cljs/status_im/protocol/api.cljs | 10 ++++++---- src/cljs/status_im/protocol/web3.cljs | 17 +++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/cljs/status_im/protocol/api.cljs b/src/cljs/status_im/protocol/api.cljs index ec762ec..16b0569 100644 --- a/src/cljs/status_im/protocol/api.cljs +++ b/src/cljs/status_im/protocol/api.cljs @@ -33,7 +33,8 @@ create-identity add-identity stop-listener - stop-watching-filters]] + stop-watching-filters] + :as web3] [status-im.protocol.handler :refer [handle-incoming-whisper-msg] :as handler] [status-im.protocol.user-handler :refer [invoke-user-handler]] [status-im.utils.encryption :refer [new-keypair]] @@ -116,13 +117,14 @@ (let [topic [(user-topic whisper-identity) discovery-topic]] (listen (connection) handle-incoming-whisper-msg {:topic topic}))) -(defn send-user-msg [{:keys [to content msg-id]}] +(defn send-user-msg [{:keys [to content msg-id content-type]}] (let [{:keys [msg-id msg] :as new-msg} (make-msg {:from (state/my-identity) :to to :msg-id msg-id :payload {:content content - :content-type default-content-type + :content-type (or content-type + default-content-type) :type :user-msg}})] (add-pending-message msg-id msg) (post-msg (connection) msg) @@ -239,4 +241,4 @@ (defn send-account-update [account] (let [topics [[(user-topic (my-identity)) discovery-topic]]] - (broadcast-account-update topics account))) \ No newline at end of file + (broadcast-account-update topics account))) diff --git a/src/cljs/status_im/protocol/web3.cljs b/src/cljs/status_im/protocol/web3.cljs index 4f47408..d474b40 100644 --- a/src/cljs/status_im/protocol/web3.cljs +++ b/src/cljs/status_im/protocol/web3.cljs @@ -1,21 +1,22 @@ (ns status-im.protocol.web3 (:require [cljs.core.async :refer [chan put! close! js))) (defn make-web3 [rpc-url] - (->> (js/Web3.providers.HttpProvider. rpc-url) - (js/Web3.))) + (->> (web3.providers.HttpProvider. rpc-url) + (web3.))) (defn make-callback [{:keys [error-msg result-channel]}] (fn [error result] @@ -40,8 +41,8 @@ (defn new-identity [web3] (let [result-channel (chan) - callback (make-callback {:error-msg "Call to newIdentity failed" - :result-channel result-channel})] + callback (make-callback {:error-msg "Call to newIdentity failed" + :result-channel result-channel})] (.newIdentity (.-shh web3) callback) result-channel))