fixed error on invalid utf-8 from dapp

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2018-05-03 13:04:42 +03:00
parent b7a92505bc
commit de03fc2d6a
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
3 changed files with 13 additions and 8 deletions

View File

@ -20,7 +20,9 @@
(.toAscii dependencies/Web3.prototype s))
(defn to-utf8 [s]
(.toUtf8 dependencies/Web3.prototype (str s)))
(try
(.toUtf8 dependencies/Web3.prototype (str s))
(catch :default err nil)))
(defn sha3 [s]
(.sha3 dependencies/Web3.prototype s))

View File

@ -13,7 +13,8 @@
[status-im.utils.money :as money]
[status-im.utils.types :as types]
[status-im.utils.utils :as utils]
[status-im.constants :as constants]))
[status-im.constants :as constants]
[status-im.transport.utils :as transport.utils]))
;;;; FX
@ -158,11 +159,13 @@
(= method constants/web3-personal-sign)
(let [{:keys [data]} args]
(let [{:keys [data]} args
data' (transport.utils/to-utf8 data)]
(when data'
{:db (-> db
(assoc-in [:wallet :transactions-unsigned id] {:data data :id id})
(assoc-in [:wallet :transactions-unsigned id] {:data data' :id id})
(assoc-in [:wallet :send-transaction] {:id id :method method}))
:dispatch [:navigate-to-modal :wallet-sign-message-modal]}))))
:dispatch [:navigate-to-modal :wallet-sign-message-modal]})))))
(defn this-transaction-signing? [id signing-id view-id modal]
(and (= signing-id id)

View File

@ -273,7 +273,7 @@
(i18n/label :t/message)
[components/amount-input {:disabled? true
:input-options {:multiline true
:default-value (transport.utils/to-utf8 data)}}]]]]
:default-value data}}]]]]
[signing-buttons
#(re-frame/dispatch [:wallet/discard-transaction-navigate-back])
#(re-frame/dispatch [:wallet/sign-transaction-modal])