show tx data in keycard web3 request screen

Signed-off-by: Andrea Franz <andrea@gravityblast.com>
This commit is contained in:
Andrea Franz 2020-11-18 11:37:39 +01:00
parent ae2d9b996c
commit 22c6635d93
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
2 changed files with 35 additions and 36 deletions

View File

@ -15,6 +15,7 @@
[status-im.utils.security :as security] [status-im.utils.security :as security]
[status-im.ui.screens.signing.sheets :as sheets] [status-im.ui.screens.signing.sheets :as sheets]
[status-im.ethereum.tokens :as tokens] [status-im.ethereum.tokens :as tokens]
[status-im.utils.types :as types]
[clojure.string :as string] [clojure.string :as string]
[quo.core :as quo] [quo.core :as quo]
[quo.gesture-handler :as gh] [quo.gesture-handler :as gh]
@ -192,20 +193,12 @@
(defn signature-request-footer [keycard-step small-screen?] (defn signature-request-footer [keycard-step small-screen?]
(fn [] (fn []
[react/view {:style {:padding-horizontal 16}} [react/view {:style {:padding 16 :align-items :center}}
[react/view {:style {:flex-direction :row}} [react/view {:style {:flex-direction :row}}
[terminal-button {:disabled? (= keycard-step :success) [terminal-button {:disabled? (= keycard-step :success)
:height (if small-screen? 52 64) :height (if small-screen? 52 64)
:on-press #(re-frame/dispatch [:show-popover {:view :transaction-data}])} :on-press #(re-frame/dispatch [:show-popover {:view :transaction-data}])}
(i18n/label :t/show-transaction-data)]] (i18n/label :t/show-transaction-data)]]]))
[react/view {:margin-top 8
:flex-direction :row
:margin-bottom 16}
[terminal-button {:theme :negative
:disabled? (= keycard-step :success)
:height 64
:on-press #(re-frame/dispatch [:signing.ui/cancel-is-pressed])}
(i18n/label :t/decline)]]]))
(defn signature-request [{:keys [formatted-data account fiat-amount fiat-currency keycard-step]} (defn signature-request [{:keys [formatted-data account fiat-amount fiat-currency keycard-step]}
connected? connected?
@ -218,30 +211,34 @@
:connected? connected? :connected? connected?
:on-cancel #(re-frame/dispatch [:signing.ui/cancel-is-pressed]) :on-cancel #(re-frame/dispatch [:signing.ui/cancel-is-pressed])
:params :params
(if (:receiver message) (cond
{:header (redeem-tx-header account (:receiver message) small-screen?) (:receiver message) {:title (i18n/label :t/confirmation-request)
:title (i18n/label :t/confirmation-request) :header (redeem-tx-header account (:receiver message) small-screen?)
:footer (signature-request-footer keycard-step small-screen?)
:small-screen? small-screen? :small-screen? small-screen?
:state-translations {:init {:title :t/keycard-redeem-tx :state-translations {:init {:title :t/keycard-redeem-tx
:description :t/keycard-redeem-tx-desc}}} :description :t/keycard-redeem-tx-desc}}}
{:title (i18n/label :t/confirmation-request) (:currency message) {:title (i18n/label :t/confirmation-request)
:header (signature-request-header (:formatted-amount message) :header (signature-request-header (:formatted-amount message)
(:formatted-currency message) (:formatted-currency message)
small-screen? fiat-amount fiat-currency) small-screen? fiat-amount fiat-currency)
:footer (signature-request-footer keycard-step small-screen?) :footer (signature-request-footer keycard-step small-screen?)
:small-screen? small-screen?}
:else {:title (i18n/label :t/confirmation-request)
:header (signature-request-header (:formatted-amount message)
(:formatted-currency message)
small-screen? fiat-amount fiat-currency)
:footer (signature-request-footer keycard-step small-screen?)
:small-screen? small-screen?})}]])) :small-screen? small-screen?})}]]))
(defn- transaction-data-item [{:keys [label data]}] (defn- transaction-data-item [data]
(let [text (types/clj->pretty-json data 2)]
[react/view [react/view
[react/text {:style {:font-size 17
:line-height 20
:margin-bottom 8
:color colors/gray}}
label]
[react/text {:style {:font-size 17 [react/text {:style {:font-size 17
:line-height 20 :line-height 20
:margin-bottom 24}} :margin-bottom 24}}
data]]) text]]))
(views/defview transaction-data [] (views/defview transaction-data []
(views/letsubs (views/letsubs
@ -257,8 +254,7 @@
:padding-horizontal 16 :padding-horizontal 16
:padding-vertical 10 :padding-vertical 10
:margin-vertical 14}} :margin-vertical 14}}
[transaction-data-item {:label "Label" [transaction-data-item formatted-data]]
:data formatted-data}]]
[separator] [separator]
[react/view {:style {:margin-horizontal 8 [react/view {:style {:margin-horizontal 8
:margin-vertical 16}} :margin-vertical 16}}

View File

@ -10,8 +10,11 @@
(defn js->clj [data] (defn js->clj [data]
(cljs.core/js->clj data :keywordize-keys true)) (cljs.core/js->clj data :keywordize-keys true))
(defn clj->pretty-json [data spaces]
(.stringify js/JSON (clj-bean/->js data) nil spaces))
(defn clj->json [data] (defn clj->json [data]
(.stringify js/JSON (clj-bean/->js data))) (clj->pretty-json data 0))
(defn json->clj [json] (defn json->clj [json]
(when-not (= json "undefined") (when-not (= json "undefined")