Andrey Shovkoplyas 2017-05-30 14:45:38 +02:00 committed by Roman Volosovskyi
parent 034ff3e413
commit 1a3e346543
5 changed files with 13 additions and 10 deletions

View File

@ -116,18 +116,21 @@
(fn [db [_ message-id]] (fn [db [_ message-id]]
(remove-pending-message db message-id))) (remove-pending-message db message-id)))
(defn transaction-valid? [{{:keys [to data]} :args}]
(or (and to (valid-hex? to)) (and data (not= data "0x"))))
(register-handler :transaction-queued (register-handler :transaction-queued
(u/side-effect! (u/side-effect!
(fn [_ [_ {:keys [id args] :as transaction}]] (fn [_ [_ {:keys [id] :as transaction}]]
(if (:to args) (if (transaction-valid? transaction)
(dispatch [::transaction-queued transaction]) (dispatch [::transaction-queued transaction])
(status/discard-transaction id))))) (status/discard-transaction id)))))
(register-handler ::transaction-queued (register-handler ::transaction-queued
(after #(dispatch [:navigate-to-modal :unsigned-transactions])) (after #(dispatch [:navigate-to-modal :unsigned-transactions]))
(fn [db [_ {:keys [id message_id args]}]] (fn [db [_ {:keys [id message_id args] :as transaction}]]
(let [{:keys [from to value data gas gasPrice]} args] (let [{:keys [from to value data gas gasPrice]} args]
(if (valid-hex? to) (if (transaction-valid? transaction)
(let [transaction {:id id (let [transaction {:id id
:from from :from from
:to to :to to

View File

@ -39,7 +39,7 @@
(defview details [{:keys [to data gas gas-price] :as transaction}] (defview details [{:keys [to data gas gas-price] :as transaction}]
[current-account [:get-current-account] [current-account [:get-current-account]
recipient [:contact-by-address to]] recipient [:contact-by-address to]]
(let [recipient-name (or (:name recipient) to) (let [recipient-name (or (:name recipient) to (i18n/label :t/contract-creation))
gas-price (.fromWei js/Web3.prototype gas-price "ether") gas-price (.fromWei js/Web3.prototype gas-price "ether")
fee-value (* gas gas-price) fee-value (* gas gas-price)
estimated-fee (str fee-value " ETH")] estimated-fee (str fee-value " ETH")]

View File

@ -10,10 +10,9 @@
(register-sub :contacts-by-address (register-sub :contacts-by-address
(fn [db] (fn [db]
(reaction (into {} (map (fn [[_ {:keys [address] :as contact}]] (reaction (into {} (map (fn [[_ {:keys [address] :as contact}]]
[address contact]) (when address
[address contact]))
(:contacts @db) (:contacts @db))))))
)))))
(register-sub :contact-by-address (register-sub :contact-by-address
(fn [_ [_ address]] (fn [_ [_ address]]

View File

@ -32,7 +32,7 @@
[recipient [:contact-by-address to]] [recipient [:contact-by-address to]]
(let [eth-value (.fromWei js/Web3.prototype value "ether") (let [eth-value (.fromWei js/Web3.prototype value "ether")
value (str (i18n/label-number eth-value) " ETH") value (str (i18n/label-number eth-value) " ETH")
recipient-name (or (:name recipient) to)] recipient-name (or (:name recipient) to (i18n/label :t/contract-creation))]
[rn/view {:style st/item} [rn/view {:style st/item}
[item-image recipient] [item-image recipient]
[item-info recipient-name value] [item-info recipient-name value]

View File

@ -309,6 +309,7 @@
:from "From" :from "From"
:data "Data" :data "Data"
:got-it "Got it" :got-it "Got it"
:contract-creation "Contract Creation"
;:webview ;:webview
:web-view-error "oops, error"}) :web-view-error "oops, error"})