[#7897] fix navigation bug on keycard tx sign

Signed-off-by: Dmitry Novotochinov <dmitry.novot@gmail.com>
This commit is contained in:
Dmitry Novotochinov 2019-04-30 13:49:33 +03:00
parent ff39426e56
commit 1f24f1c4f6
No known key found for this signature in database
GPG Key ID: 43D1DAF5AD39C927
13 changed files with 127 additions and 76 deletions

View File

@ -263,9 +263,12 @@
(fx/defn open-keycard-login (fx/defn open-keycard-login
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [navigation-stack (:navigation-stack db)]
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :pin :enter-step] :login)} {:db (assoc-in db [:hardwallet :pin :enter-step] :login)}
(navigation/navigate-to-cofx :enter-pin nil))) (if (empty? navigation-stack)
(navigation/navigate-to-cofx :accounts nil)
(navigation/navigate-to-cofx :enter-pin-login nil)))))
(fx/defn get-user-password (fx/defn get-user-password
[_ address] [_ address]

View File

@ -309,6 +309,7 @@
:wallet-send-modal-stack-with-onboarding)] :wallet-send-modal-stack-with-onboarding)]
(fx/merge cofx (fx/merge cofx
{:db (-> db {:db (-> db
(assoc-in [:navigation/screen-params :wallet-send-modal-stack :modal?] true)
(update-in [:wallet :send-transaction] (update-in [:wallet :send-transaction]
assoc assoc
:amount (money/formatted->internal value symbol decimals) :amount (money/formatted->internal value symbol decimals)

View File

@ -43,17 +43,15 @@
(fx/defn navigate-back-button-clicked (fx/defn navigate-back-button-clicked
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [screen-before (second (get db :navigation-stack)) (let [screen-before (set (take 4 (:navigation-stack db)))
navigate-to-browser? (contains? #{:wallet-sign-message-modal navigate-to-browser? (contains? screen-before :browser-stack)]
:wallet-send-transaction-modal
:wallet-send-modal-stack} screen-before)]
(if (nil? screen-before)
(navigation/navigate-to-cofx cofx :accounts nil)
(if navigate-to-browser? (if navigate-to-browser?
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :on-card-connected] nil)} {:db (assoc-in db [:hardwallet :on-card-connected] nil)}
(models.wallet/discard-transaction) (models.wallet/discard-transaction)
(navigation/navigate-to-cofx :browser nil)) (navigation/navigate-to-cofx :browser nil))
(if (= :enter-pin-login (:view-id db))
(navigation/navigate-to-clean cofx :accounts nil)
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :on-card-connected] nil)} {:db (assoc-in db [:hardwallet :on-card-connected] nil)}
(navigation/navigate-back)))))) (navigation/navigate-back))))))
@ -174,7 +172,7 @@
(= keycard-instance-uid account-instance-uid))) (= keycard-instance-uid account-instance-uid)))
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :pin :current] [])} {:db (assoc-in db [:hardwallet :pin :current] [])}
(navigation/navigate-to-cofx :enter-pin nil)) (navigation/navigate-to-cofx :enter-pin-settings nil))
(unauthorized-operation cofx)))) (unauthorized-operation cofx))))
(fx/defn navigate-to-authentication-method (fx/defn navigate-to-authentication-method
@ -282,7 +280,7 @@
{:db (-> db {:db (-> db
(assoc :accounts/login (select-keys account [:address :name :photo-path])) (assoc :accounts/login (select-keys account [:address :name :photo-path]))
(assoc-in [:hardwallet :pin :enter-step] :login))} (assoc-in [:hardwallet :pin :enter-step] :login))}
(navigation/navigate-to-cofx :enter-pin nil)) (navigation/navigate-to-cofx :enter-pin-login nil))
:else :else
(get-keys-from-keycard cofx)))) (get-keys-from-keycard cofx))))
@ -395,7 +393,7 @@
:on-verified :hardwallet/proceed-to-change-pin}))} :on-verified :hardwallet/proceed-to-change-pin}))}
(if card-connected? (if card-connected?
(navigate-to-enter-pin-screen) (navigate-to-enter-pin-screen)
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (navigation/navigate-to-cofx :hardwallet-connect-settings nil)))))
(fx/defn proceed-to-change-pin (fx/defn proceed-to-change-pin
[{:keys [db]}] [{:keys [db]}]
@ -428,7 +426,7 @@
:on-verified :hardwallet/unpair}))} :on-verified :hardwallet/unpair}))}
(if card-connected? (if card-connected?
(navigate-to-enter-pin-screen) (navigate-to-enter-pin-screen)
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (navigation/navigate-to-cofx :hardwallet-connect-settings nil)))))
(defn- vector->string [v] (defn- vector->string [v]
"Converts numbers stored in vector into string, "Converts numbers stored in vector into string,
@ -459,7 +457,7 @@
:pairing pairing}} :pairing pairing}}
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/remove-key-with-unpair)} {:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/remove-key-with-unpair)}
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (navigation/navigate-to-cofx :hardwallet-connect-settings nil)))))
(fx/defn on-remove-key-success (fx/defn on-remove-key-success
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -493,7 +491,7 @@
(assoc-in [:hardwallet :pin :status] nil)) (assoc-in [:hardwallet :pin :status] nil))
:utils/show-popup {:title (i18n/label :t/error) :utils/show-popup {:title (i18n/label :t/error)
:content (i18n/label :t/cannot-read-card)}} :content (i18n/label :t/cannot-read-card)}}
(navigation/navigate-to-cofx :hardwallet-connect nil)) (navigation/navigate-to-cofx :hardwallet-connect-settings nil))
(show-wrong-keycard-alert cofx true))))) (show-wrong-keycard-alert cofx true)))))
(fx/defn on-delete-success (fx/defn on-delete-success
@ -535,7 +533,7 @@
(navigation/navigate-to-cofx cofx :reset-card nil) (navigation/navigate-to-cofx cofx :reset-card nil)
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/navigate-to-reset-card-screen)} {:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/navigate-to-reset-card-screen)}
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (navigation/navigate-to-cofx :hardwallet-connect-settings nil)))))
(fx/defn delete-card (fx/defn delete-card
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -572,7 +570,7 @@
:on-verified :hardwallet/remove-key-with-unpair}))} :on-verified :hardwallet/remove-key-with-unpair}))}
(if card-connected? (if card-connected?
(navigate-to-enter-pin-screen) (navigate-to-enter-pin-screen)
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (navigation/navigate-to-cofx :hardwallet-connect-settings nil)))))
(fx/defn error-button-pressed (fx/defn error-button-pressed
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -604,7 +602,9 @@
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (navigation/navigate-to-cofx :hardwallet-connect nil)))))
(fx/defn return-back-from-nfc-settings [{:keys [db]}] (fx/defn return-back-from-nfc-settings [{:keys [db]}]
(when (= :hardwallet-connect (:view-id db)) (when (contains? #{:hardwallet-connect
:hardwallet-connect-sign
:hardwallet-connect-settings} (:view-id db))
{:hardwallet/check-nfc-enabled nil})) {:hardwallet/check-nfc-enabled nil}))
(defn- proceed-to-pin-confirmation [fx] (defn- proceed-to-pin-confirmation [fx]
@ -651,7 +651,7 @@
:current [0 0 0 0 0 0] :current [0 0 0 0 0 0]
:puk [] :puk []
:error-label nil}))} :error-label nil}))}
(navigation/navigate-to-cofx :enter-pin nil)))) (navigation/navigate-to-cofx :enter-pin-settings nil))))
(defn on-unblock-pin-error (defn on-unblock-pin-error
[{:keys [db]} error] [{:keys [db]} error]
@ -760,7 +760,7 @@
:pairing pairing}} :pairing pairing}}
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/verify-pin)} {:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/verify-pin)}
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (navigation/navigate-to-cofx :hardwallet-connect-settings nil)))))
(defn- unblock-pin (defn- unblock-pin
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -775,7 +775,7 @@
:pairing pairing}} :pairing pairing}}
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/unblock-pin)} {:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/unblock-pin)}
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (navigation/navigate-to-cofx :hardwallet-connect-settings nil)))))
(def pin-code-length 6) (def pin-code-length 6)
(def puk-code-length 12) (def puk-code-length 12)
@ -837,7 +837,7 @@
{:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/sign)} {:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/sign)}
(when-not keycard-match? (when-not keycard-match?
(show-wrong-keycard-alert card-connected?)) (show-wrong-keycard-alert card-connected?))
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (navigation/navigate-to-cofx :hardwallet-connect-sign nil)))))
(fx/defn prepare-to-sign (fx/defn prepare-to-sign
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -847,7 +847,11 @@
(get-application-info cofx pairing :hardwallet/sign) (get-application-info cofx pairing :hardwallet/sign)
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/prepare-to-sign)} {:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/prepare-to-sign)}
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (navigation/navigate-to-cofx
(if (= (:view-id db) :enter-pin-modal)
:hardwallet-connect-modal
:hardwallet-connect-sign)
nil)))))
; PIN enter steps: ; PIN enter steps:
; login - PIN is used to login ; login - PIN is used to login
@ -1247,7 +1251,7 @@
:db (update-in db [:hardwallet :pin] merge {:status :error :db (update-in db [:hardwallet :pin] merge {:status :error
:login [] :login []
:error-label :t/pin-mismatch})} :error-label :t/pin-mismatch})}
(navigation/navigate-to-cofx :enter-pin nil))))) (navigation/navigate-to-cofx :enter-pin-login nil)))))
(fx/defn send-transaction-with-signature (fx/defn send-transaction-with-signature
[_ data] [_ data]
@ -1295,6 +1299,6 @@
{:db (update-in db [:hardwallet :pin] merge {:status :error {:db (update-in db [:hardwallet :pin] merge {:status :error
:sign [] :sign []
:error-label :t/pin-mismatch})} :error-label :t/pin-mismatch})}
(navigation/navigate-to-cofx :enter-pin nil) (navigation/navigate-to-cofx :enter-pin-sign nil)
(get-application-info (get-pairing db) nil)) (get-application-info (get-pairing db) nil))
(show-wrong-keycard-alert cofx true))) (show-wrong-keycard-alert cofx true)))

View File

@ -238,6 +238,7 @@
(let [{:keys [gas gas-price]} transaction (let [{:keys [gas gas-price]} transaction
{:keys [wallet-set-up-passed?]} (:account/account db)] {:keys [wallet-set-up-passed?]} (:account/account db)]
{:db (-> db {:db (-> db
(assoc-in [:navigation/screen-params :wallet-send-modal-stack :modal?] true)
(assoc-in [:wallet :send-transaction] transaction) (assoc-in [:wallet :send-transaction] transaction)
(assoc-in [:wallet :send-transaction :original-gas] gas)) (assoc-in [:wallet :send-transaction :original-gas] gas))
:dispatch-n [[:update-wallet] :dispatch-n [[:update-wallet]
@ -257,6 +258,7 @@
:wallet-send-modal-stack-with-onboarding)] :wallet-send-modal-stack-with-onboarding)]
(fx/merge cofx (fx/merge cofx
(cond-> {:db (-> db (cond-> {:db (-> db
(assoc-in [:navigation/screen-params :wallet-send-modal-stack :modal?] true)
(assoc-in [:wallet :send-transaction] (assoc-in [:wallet :send-transaction]
transaction) transaction)
(assoc-in [:wallet :send-transaction :original-gas] (assoc-in [:wallet :send-transaction :original-gas]
@ -274,3 +276,7 @@
:edit? false})) :edit? false}))
(update-wallet) (update-wallet)
(navigation/navigate-to-cofx go-to-view-id {})))) (navigation/navigate-to-cofx go-to-view-id {}))))
(defn send-transaction-screen-did-load
[{:keys [db]}]
{:db (assoc-in db [:navigation/screen-params :wallet-send-modal-stack :modal?] false)})

View File

@ -130,7 +130,9 @@
(minimize-bar new-view-id)))) (minimize-bar new-view-id))))
:reagent-render :reagent-render
(fn [keyboard-shown? view-id tab] (fn [keyboard-shown? view-id tab]
(when (not= view-id :enter-pin) (when-not (contains? #{:enter-pin-login
:enter-pin-sign
:enter-pin-settings} view-id)
(if platform/ios? (if platform/ios?
[tabs-animation-wrapper-ios [tabs-animation-wrapper-ios
[react/animated-view [react/animated-view

View File

@ -33,7 +33,8 @@
[status-im.utils.handlers :as handlers] [status-im.utils.handlers :as handlers]
[status-im.utils.http :as http] [status-im.utils.http :as http]
[status-im.utils.utils :as utils] [status-im.utils.utils :as utils]
[status-im.utils.fx :as fx])) [status-im.utils.fx :as fx]
[status-im.models.wallet :as wallet]))
(defn- http-get [{:keys [url response-validator success-event-creator failure-event-creator timeout-ms]}] (defn- http-get [{:keys [url response-validator success-event-creator failure-event-creator timeout-ms]}]
(let [on-success #(re-frame/dispatch (success-event-creator %)) (let [on-success #(re-frame/dispatch (success-event-creator %))
@ -188,9 +189,16 @@
#(case view-id #(case view-id
:keycard-settings (hardwallet/settings-screen-did-load %) :keycard-settings (hardwallet/settings-screen-did-load %)
:reset-card (hardwallet/reset-card-screen-did-load %) :reset-card (hardwallet/reset-card-screen-did-load %)
:enter-pin (hardwallet/enter-pin-screen-did-load %) :enter-pin-login (hardwallet/enter-pin-screen-did-load %)
:enter-pin-sign (hardwallet/enter-pin-screen-did-load %)
:enter-pin-settings (hardwallet/enter-pin-screen-did-load %)
:enter-pin-modal (hardwallet/enter-pin-screen-did-load %)
:hardwallet-connect (hardwallet/hardwallet-connect-screen-did-load %) :hardwallet-connect (hardwallet/hardwallet-connect-screen-did-load %)
:hardwallet-connect-sign (hardwallet/hardwallet-connect-screen-did-load %)
:hardwallet-connect-settings (hardwallet/hardwallet-connect-screen-did-load %)
:hardwallet-connect-modal (hardwallet/hardwallet-connect-screen-did-load %)
:hardwallet-authentication-method (hardwallet/authentication-method-screen-did-load %) :hardwallet-authentication-method (hardwallet/authentication-method-screen-did-load %)
:wallet-send-transaction (wallet/send-transaction-screen-did-load %)
:accounts (hardwallet/accounts-screen-did-load %) :accounts (hardwallet/accounts-screen-did-load %)
:chat (mark-messages-seen %) :chat (mark-messages-seen %)
nil)))) nil))))

View File

@ -1,9 +1,8 @@
(ns status-im.ui.screens.routing.chat-stack (ns status-im.ui.screens.routing.chat-stack)
(:require [status-im.utils.config :as config]))
(def chat-stack (def chat-stack
{:name :chat-stack {:name :chat-stack
:screens (cond-> [:home :screens [:home
:chat :chat
:profile :profile
:new :new
@ -17,6 +16,4 @@
:new-public-chat :new-public-chat
:stickers :stickers
:stickers-pack] :stickers-pack]
config/hardwallet-enabled?
(concat [:hardwallet-connect :enter-pin]))
:config {:initialRouteName :home}}) :config {:initialRouteName :home}})

View File

@ -10,7 +10,7 @@
:intro :intro
:hardwallet-authentication-method :hardwallet-authentication-method
:hardwallet-connect :hardwallet-connect
:enter-pin :enter-pin-login
:hardwallet-setup :hardwallet-setup
:hardwallet-success}) :hardwallet-success})
@ -25,13 +25,13 @@
config/hardwallet-enabled? config/hardwallet-enabled?
(concat [:hardwallet-authentication-method (concat [:hardwallet-authentication-method
:hardwallet-connect :hardwallet-connect
:enter-pin :enter-pin-login
:hardwallet-setup :hardwallet-setup
:hardwallet-success])) :hardwallet-success]))
:config (if :config (if
;; add view-id here if you'd like that view to be ;; add view-id here if you'd like that view to be
;; first view when app is started ;; first view when app is started
(#{:login :progress :accounts :enter-pin} view-id) (#{:login :progress :accounts :enter-pin-login} view-id)
{:initialRouteName view-id} {:initialRouteName view-id}
{:initialRouteName :login})}) {:initialRouteName :login})})

View File

@ -5,22 +5,24 @@
:screens [:wallet-send-transaction-modal :screens [:wallet-send-transaction-modal
:wallet-transaction-sent-modal :wallet-transaction-sent-modal
:wallet-transaction-fee :wallet-transaction-fee
:hardwallet-connect :hardwallet-connect-modal
:enter-pin] :enter-pin-modal]
:config {:initialRouteName :wallet-send-transaction-modal}} :config {:initialRouteName :wallet-send-transaction-modal}}
{:name :wallet-send-modal-stack-with-onboarding {:name :wallet-send-modal-stack-with-onboarding
:screens [:wallet-onboarding-setup-modal :screens [:wallet-onboarding-setup-modal
:wallet-send-transaction-modal :wallet-send-transaction-modal
:wallet-transaction-sent-modal :wallet-transaction-sent-modal
:wallet-transaction-fee :wallet-transaction-fee
:hardwallet-connect :hardwallet-connect-modal
:enter-pin] :enter-pin-modal]
:config {:initialRouteName :wallet-onboarding-setup-modal}} :config {:initialRouteName :wallet-onboarding-setup-modal}}
:chat-modal :chat-modal
:show-extension-modal :show-extension-modal
:stickers-pack-modal :stickers-pack-modal
:tribute-learn-more :tribute-learn-more
:wallet-sign-message-modal :wallet-sign-message-modal
:enter-pin-modal
:hardwallet-connect-modal
:selection-modal-screen :selection-modal-screen
:wallet-settings-assets :wallet-settings-assets
:wallet-transaction-fee :wallet-transaction-fee

View File

@ -32,11 +32,8 @@
:my-profile-ext-settings] :my-profile-ext-settings]
config/hardwallet-enabled? config/hardwallet-enabled?
(concat [:hardwallet-authentication-method (concat [:keycard-settings
:hardwallet-connect
:hardwallet-setup
:hardwallet-success
:keycard-settings
:reset-card :reset-card
:enter-pin])) :hardwallet-connect-settings
:enter-pin-settings]))
:config {:initialRouteName :my-profile}}) :config {:initialRouteName :my-profile}})

View File

@ -87,7 +87,13 @@
:intro intro/intro :intro intro/intro
:hardwallet-authentication-method hardwallet.authentication/hardwallet-authentication-method :hardwallet-authentication-method hardwallet.authentication/hardwallet-authentication-method
:hardwallet-connect hardwallet.connect/hardwallet-connect :hardwallet-connect hardwallet.connect/hardwallet-connect
:enter-pin hardwallet.pin/enter-pin :hardwallet-connect-settings hardwallet.connect/hardwallet-connect
:hardwallet-connect-sign hardwallet.connect/hardwallet-connect
:hardwallet-connect-modal [:modal hardwallet.connect/hardwallet-connect]
:enter-pin-login hardwallet.pin/enter-pin
:enter-pin-settings hardwallet.pin/enter-pin
:enter-pin-sign hardwallet.pin/enter-pin
:enter-pin-modal [:modal hardwallet.pin/enter-pin]
:hardwallet-setup hardwallet.setup/hardwallet-setup :hardwallet-setup hardwallet.setup/hardwallet-setup
:hardwallet-success hardwallet.success/hardwallet-success :hardwallet-success hardwallet.success/hardwallet-success
:home home/home-wrapper :home home/home-wrapper

View File

@ -11,8 +11,8 @@
:screens [:wallet-send-transaction :screens [:wallet-send-transaction
:recent-recipients :recent-recipients
:wallet-transaction-sent :wallet-transaction-sent
:enter-pin :enter-pin-sign
:hardwallet-connect :hardwallet-connect-sign
:recipient-qr-code :recipient-qr-code
:wallet-send-assets]} :wallet-send-assets]}
{:name :request-transaction-stack {:name :request-transaction-stack

View File

@ -117,7 +117,8 @@
(let [{:keys [id method public-key to symbol amount-text on-result on-error (let [{:keys [id method public-key to symbol amount-text on-result on-error
send-transaction-message?]} send-transaction-message?]}
(get-in db [:wallet :send-transaction]) (get-in db [:wallet :send-transaction])
db' (assoc-in db [:wallet :send-transaction :in-progress?] false)] db' (assoc-in db [:wallet :send-transaction :in-progress?] false)
modal-screen-was-used? (get-in db [:navigation/screen-params :wallet-send-modal-stack :modal?])]
(if error (if error
;; ERROR ;; ERROR
(models.wallet/handle-transaction-error (assoc cofx :db db') error) (models.wallet/handle-transaction-error (assoc cofx :db db') error)
@ -143,9 +144,9 @@
#(when-not on-result #(when-not on-result
(navigation/navigate-to-clean (navigation/navigate-to-clean
% %
(if (contains? #{:wallet-send-transaction :enter-pin :hardwallet-connect} (:view-id db)) (if modal-screen-was-used?
:wallet-transaction-sent :wallet-transaction-sent-modal
:wallet-transaction-sent-modal) :wallet-transaction-sent)
{}))))))) {})))))))
(re-frame/reg-fx (re-frame/reg-fx
@ -168,7 +169,8 @@
(handlers/register-handler-fx (handlers/register-handler-fx
::hash-message-completed ::hash-message-completed
(fn [{:keys [db] :as cofx} [_ {:keys [result error]}]] (fn [{:keys [db] :as cofx} [_ {:keys [result error]}]]
(let [db' (assoc-in db [:wallet :send-transaction :in-progress?] false)] (let [view-id (:view-id db)
db' (assoc-in db [:wallet :send-transaction :in-progress?] false)]
(if error (if error
;; ERROR ;; ERROR
(models.wallet/handle-transaction-error (assoc cofx :db db') error) (models.wallet/handle-transaction-error (assoc cofx :db db') error)
@ -177,7 +179,13 @@
{:db (-> db {:db (-> db
(assoc-in [:hardwallet :pin :enter-step] :sign) (assoc-in [:hardwallet :pin :enter-step] :sign)
(assoc-in [:hardwallet :hash] result))} (assoc-in [:hardwallet :hash] result))}
(navigation/navigate-to-cofx :enter-pin nil)))))) (navigation/navigate-to-cofx
(if (contains?
#{:wallet-sign-message-modal :wallet-send-transaction-modal :wallet-send-modal-stack}
view-id)
:enter-pin-modal
:enter-pin-sign)
nil))))))
;; DISCARD TRANSACTION ;; DISCARD TRANSACTION
(handlers/register-handler-fx (handlers/register-handler-fx
@ -345,7 +353,7 @@
(re-frame/reg-fx (re-frame/reg-fx
::hash-transaction ::hash-transaction
(fn [{:keys [transaction all-tokens symbol chain on-completed]}] (fn [{:keys [transaction on-completed]}]
(status/hash-transaction (types/clj->json transaction) on-completed))) (status/hash-transaction (types/clj->json transaction) on-completed)))
(re-frame/reg-fx (re-frame/reg-fx
@ -358,12 +366,23 @@
(fn [{:keys [data on-completed]}] (fn [{:keys [data on-completed]}]
(status/hash-typed-data data on-completed))) (status/hash-typed-data data on-completed)))
(defn- prepare-keycard-transaction
[transaction from symbol chain all-tokens]
(if (= :ETH symbol)
(models.wallet/prepare-send-transaction from transaction)
(let [contract (:address (tokens/symbol->token all-tokens (keyword chain) symbol))
{:keys [gas gasPrice to from value]} (models.wallet/prepare-send-transaction from transaction)]
(merge (ethereum/call-params contract "transfer(address,uint256)" to value)
{:from from
:gas gas
:gasPrice gasPrice}))))
(defn send-keycard-transaction (defn send-keycard-transaction
[{{:keys [chain] :as db} :db}] [{{:keys [chain] :as db} :db}]
(let [{:keys [symbol] :as transaction} (get-in db [:wallet :send-transaction]) (let [{:keys [symbol] :as transaction} (get-in db [:wallet :send-transaction])
all-tokens (:wallet/all-tokens db) all-tokens (:wallet/all-tokens db)
from (get-in db [:account/account :address])] from (get-in db [:account/account :address])]
{::hash-transaction {:transaction (models.wallet/prepare-send-transaction from transaction) {::hash-transaction {:transaction (prepare-keycard-transaction transaction from symbol chain all-tokens)
:all-tokens all-tokens :all-tokens all-tokens
:symbol symbol :symbol symbol
:chain chain :chain chain
@ -378,7 +397,13 @@
(assoc-in [:hardwallet :pin :enter-step] :sign) (assoc-in [:hardwallet :pin :enter-step] :sign)
(assoc-in [:hardwallet :transaction] transaction) (assoc-in [:hardwallet :transaction] transaction)
(assoc-in [:hardwallet :hash] hash))} (assoc-in [:hardwallet :hash] hash))}
(navigation/navigate-to-clean :enter-pin nil))))) (navigation/navigate-to-clean
(if (contains?
#{:wallet-sign-message-modal :wallet-send-transaction-modal :wallet-send-modal-stack}
(:view-id db))
:enter-pin-modal
:enter-pin-sign)
nil)))))
(handlers/register-handler-fx (handlers/register-handler-fx
:wallet.ui/sign-transaction-button-clicked :wallet.ui/sign-transaction-button-clicked