   (fn [error js-message]
     ;; todo handle error
     (when error
-      (debug :listener-error error))
+      (log/debug :listener-error error))
     (when-not error
-      (debug :message-received (js->clj js-message))
+      (log/debug :message-received (js->clj js-message))
       (let [{:keys [sig payload recipientPublicKey] :as message}
             (js->clj js-message :keywordize-keys true)
 

                                                            (not= "" recipientPublicKey)
                                                            (not (nil? recipientPublicKey))))]
            (if error
              (debug :failed-to-handle-message error)
              (let [payload'' (assoc payload' :content content)
                    message'  (assoc message :payload payload''
                                             :to recipientPublicKey

            [status-im.protocol.ack :as ack]
            [status-im.protocol.web3.utils :as u]
            [status-im.protocol.encryption :as e]
            [taoensso.timbre :as log]
            [status-im.utils.hex :as i]))

(defn create-error [description]
  (log/debug :parse-payload-error description)
  {:error description})

(defn- parse-payload [payload]
  (log/debug :parse-payload)
  (try
    ;; todo figure why we have to call to-utf8 twice
    (let [payload'   (u/to-utf8 payload)
          payload''  (r/read-string payload')
          payload''' (if (map? payload'')
                       payload''
                       (r/read-string (u/to-utf8 payload')))]
      (if (map? payload''')
        {:payload payload'''}
        (create-error (str "Invalid payload type " (type payload''')))))
    (catch :default err
      (create-error err))))

(defn- decrypt [key content]
  (try
    {:content (r/read-string (e/decrypt key content))}
    (catch :default err
      (log/debug :decrypt-error err)
      {:error err})))

(defn- parse-content [key {:keys [content]} was-encrypted?]
  (log/debug :parse-content
         "Key exists:" (not (nil? key))
         "Content exists:" (not (nil? content)))
  (if (and (not was-encrypted?) key content)
