Checking transaction recepient validity (#780)
This commit is contained in:
parent
e2f31aae00
commit
947dcfba37
|
@ -4,6 +4,7 @@
|
||||||
[status-im.navigation.handlers :as nav]
|
[status-im.navigation.handlers :as nav]
|
||||||
[status-im.utils.handlers :as u]
|
[status-im.utils.handlers :as u]
|
||||||
[status-im.utils.types :as t]
|
[status-im.utils.types :as t]
|
||||||
|
[status-im.utils.hex :refer [valid-hex?]]
|
||||||
[status-im.components.status :as status]
|
[status-im.components.status :as status]
|
||||||
[clojure.string :as s]
|
[clojure.string :as s]
|
||||||
[taoensso.timbre :as log]))
|
[taoensso.timbre :as log]))
|
||||||
|
@ -120,13 +121,15 @@
|
||||||
(register-handler ::transaction-queued
|
(register-handler ::transaction-queued
|
||||||
(after #(dispatch [:navigate-to-modal :confirm]))
|
(after #(dispatch [:navigate-to-modal :confirm]))
|
||||||
(fn [db [_ {:keys [id message_id args]}]]
|
(fn [db [_ {:keys [id message_id args]}]]
|
||||||
(let [{:keys [from to value]} args
|
(let [{:keys [from to value]} args]
|
||||||
transaction {:id id
|
(if (valid-hex? to)
|
||||||
|
(let [transaction {:id id
|
||||||
:from from
|
:from from
|
||||||
:to to
|
:to to
|
||||||
:value (.toDecimal js/Web3.prototype value)
|
:value (.toDecimal js/Web3.prototype value)
|
||||||
:message-id message_id}]
|
:message-id message_id}]
|
||||||
(assoc-in db [:transactions-queue id] transaction))))
|
(assoc-in db [:transactions-queue id] transaction))
|
||||||
|
db))))
|
||||||
|
|
||||||
(register-handler :transaction-completed
|
(register-handler :transaction-completed
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
|
|
|
@ -5,3 +5,8 @@
|
||||||
(if (and hex (s/starts-with? hex "0x"))
|
(if (and hex (s/starts-with? hex "0x"))
|
||||||
(subs hex 2)
|
(subs hex 2)
|
||||||
hex))
|
hex))
|
||||||
|
|
||||||
|
(defn valid-hex? [hex]
|
||||||
|
(let [hex (normalize-hex hex)]
|
||||||
|
(and (re-matches #"^[0-9a-fA-F]+$" hex)
|
||||||
|
(not= (js/parseInt hex 16) 0))))
|
Loading…
Reference in New Issue