From 748f1c6772d18ef777a9615b15597b2acbb941ca Mon Sep 17 00:00:00 2001 From: Eric Dvorsak Date: Tue, 10 Oct 2017 19:38:38 +0200 Subject: [PATCH] fix unsigned transaction expiring while user checks details previously one would get a red screen in develop and probably a white screen in the app now it shows a label indicating that the transaction has expired --- src/status_im/translations/en.cljs | 3 ++- .../ui/screens/wallet/transactions/subs.cljs | 27 ++++++++++--------- .../ui/screens/wallet/transactions/views.cljs | 16 ++++++----- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index 09a9a442d1..6902f9bbff 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -325,6 +325,7 @@ :transaction "Transaction" :unsigned-transactions "Unsigned transactions" :no-unsigned-transactions "No unsigned transactions" + :unsigned-transaction-expired "Unsigned transaction expired" :enter-password-transactions {:one "Confirm transaction by entering your password" :other "Confirm transactions by entering your password"} :status "Status" @@ -420,7 +421,7 @@ - ;network settings + ;; network settings :new-network "New network" :add-network "Add network" :add-new-network "Add new network" diff --git a/src/status_im/ui/screens/wallet/transactions/subs.cljs b/src/status_im/ui/screens/wallet/transactions/subs.cljs index 46cc881c19..7e8e0c140f 100644 --- a/src/status_im/ui/screens/wallet/transactions/subs.cljs +++ b/src/status_im/ui/screens/wallet/transactions/subs.cljs @@ -132,19 +132,20 @@ (fn [[unsigned-transactions transactions current-transaction network]] (let [transactions (merge transactions unsigned-transactions) {:keys [gas-used gas-price hash timestamp type] :as transaction} (get transactions current-transaction)] - (merge transaction - {:gas-price-eth (money/wei->str :eth gas-price) - :gas-price-gwei (money/wei->str :gwei gas-price) - :date (datetime/timestamp->long-date timestamp)} - (if (= type :unsigned) - {:block (i18n/label :not-applicable) - :cost (i18n/label :not-applicable) - :gas-limit (i18n/label :not-applicable) - :gas-used (i18n/label :not-applicable) - :nonce (i18n/label :not-applicable) - :hash (i18n/label :not-applicable)} - {:cost (money/wei->str :eth (money/fee-value gas-used gas-price)) - :url (transactions/get-transaction-details-url network hash)}))))) + (when transaction + (merge transaction + {:gas-price-eth (money/wei->str :eth gas-price) + :gas-price-gwei (money/wei->str :gwei gas-price) + :date (datetime/timestamp->long-date timestamp)} + (if (= type :unsigned) + {:block (i18n/label :not-applicable) + :cost (i18n/label :not-applicable) + :gas-limit (i18n/label :not-applicable) + :gas-used (i18n/label :not-applicable) + :nonce (i18n/label :not-applicable) + :hash (i18n/label :not-applicable)} + {:cost (money/wei->str :eth (money/fee-value gas-used gas-price)) + :url (transactions/get-transaction-details-url network hash)})))))) (reg-sub :wallet.transactions.details/confirmations :<- [:wallet.transactions/transaction-details] diff --git a/src/status_im/ui/screens/wallet/transactions/views.cljs b/src/status_im/ui/screens/wallet/transactions/views.cljs index a468edde0f..a450d065f6 100644 --- a/src/status_im/ui/screens/wallet/transactions/views.cljs +++ b/src/status_im/ui/screens/wallet/transactions/views.cljs @@ -250,7 +250,7 @@ {:text (i18n/label :t/open-on-etherscan) :value #(.openURL react/linking url)}])]) (defview transaction-details [] - (letsubs [{:keys [hash url type] :as transactions} [:wallet.transactions/transaction-details] + (letsubs [{:keys [hash url type] :as transaction} [:wallet.transactions/transaction-details] confirmations [:wallet.transactions.details/confirmations] confirmations-progress [:wallet.transactions.details/confirmations-progress]] [react/view {:style styles/flex} @@ -258,9 +258,11 @@ [toolbar/toolbar2 {} toolbar/default-nav-back [toolbar/content-title (i18n/label :t/transaction-details)] - [toolbar/actions (details-action hash url)]] - [react/scroll-view {:style styles/main-container} - [details-header transactions] - [details-confirmations confirmations confirmations-progress] - [react/view {:style transactions.styles/details-separator}] - [details-list transactions]]])) + (when transaction [toolbar/actions (details-action hash url)])] + (if transaction + [react/scroll-view {:style styles/main-container} + [details-header transaction] + [details-confirmations confirmations confirmations-progress] + [react/view {:style transactions.styles/details-separator}] + [details-list transaction]] + [empty-text (i18n/label :t/unsigned-transaction-expired)])]))