bug #4402 and #4639 - showing failed transactions in transaction history

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
Goran Jovic 2018-06-09 11:26:21 +02:00 committed by Igor Mandrigin
parent 56ed407462
commit 6f209ec4c0
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
10 changed files with 108 additions and 68 deletions

View File

@ -1,3 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16">
<path fill="#FFF" fill-rule="evenodd" d="M8 8.5a1 1 0 0 1-1-1v-2a1 1 0 1 1 2 0v2a1 1 0 0 1-1 1zm0 3a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<g fill="none" fill-rule="evenodd">
<path d="M 11.984375,4.9863281 C 11.39553,4.9773036 10.929706,5.5513262 11,6.1227069 c 0.0024,2.6590444 -0.0048,5.3182601 0.0036,7.9771971 0.03107,0.659585 0.806234,1.118924 1.399703,0.829421 C 12.843904,14.75201 13.043232,14.264645 13,13.81594 c -0.0024,-2.638593 0.0048,-5.27736 -0.0036,-7.9158425 -0.0352,-0.511243 -0.499617,-0.9307501 -1.011996,-0.9137694 z" />
<rect width="2" height="2" x="11" y="16" rx="1"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 227 B

After

Width:  |  Height:  |  Size: 560 B

View File

@ -33,6 +33,7 @@
{:type [{:id :inbound :label (i18n/label :t/incoming) :checked? true}
{:id :outbound :label (i18n/label :t/outgoing) :checked? true}
{:id :pending :label (i18n/label :t/pending) :checked? true}
{:id :failed :label (i18n/label :t/failed) :checked? true}
;; TODO(jeluard) Restore once we support postponing transaction
#_{:id :postponed :label (i18n/label :t/postponed) :checked? true}]}})

View File

@ -405,6 +405,7 @@
:incoming "Incoming"
:outgoing "Outgoing"
:pending "Pending"
:failed "Failed"
:postponed "Postponed"
;;webview

View File

@ -24,6 +24,7 @@
(def text-light-gray "#212121") ;; Used for labels (home items)
(def cyan "#7adcfb") ;; Used by wallet transaction filtering icon
(def photo-border-color "#ccd3d6")
(def green "#44d058") ;; icon for successful inboud transaction
(def chat-colors ["#fa6565"
"#7cda00"

View File

@ -52,7 +52,7 @@
:icons/delete (components.svg/slurp-svg "./resources/icons/delete.svg")
:icons/dots-horizontal (components.svg/slurp-svg "./resources/icons/dots_horizontal.svg")
:icons/dots-vertical (components.svg/slurp-svg "./resources/icons/dots_vertical.svg")
:icons/exclamation_mark (components.svg/slurp-svg "./resources/icons/exclamation_mark.svg")
:icons/exclamation-mark (components.svg/slurp-svg "./resources/icons/exclamation_mark.svg")
:icons/filter (components.svg/slurp-svg "./resources/icons/filter.svg")
:icons/fullscreen (components.svg/slurp-svg "./resources/icons/fullscreen.svg")
:icons/group-big (components.svg/slurp-svg "./resources/icons/group_big.svg")

View File

@ -50,6 +50,9 @@
:ios {:padding-top 13}
:android {:padding-top 14}})
(def amount-text
{:color colors/text})
(def tx-amount
{:flex-grow 1
:flex-shrink 1
@ -185,13 +188,17 @@
:margin-vertical 10
:height 2})
(defn progress-bar-done [done]
(defn progress-bar-done [done failed?]
{:flex done
:background-color colors/blue})
:background-color (if failed?
colors/red
colors/blue)})
(defn progress-bar-todo [todo]
(defn progress-bar-todo [todo failed?]
{:flex todo
:background-color colors/blue
:background-color (if failed?
colors/red
colors/blue)
:opacity 0.30})
(def details-confirmations-count
@ -199,6 +206,11 @@
:font-size 15
:margin-vertical 2})
(def details-failed
{:color colors/red
:font-size 15
:margin-vertical 2})
(def details-confirmations-helper-text
{:color colors/gray
:font-size 14

View File

@ -78,16 +78,24 @@
(fn [{:keys [postponed]}]
(when postponed
{:title "Postponed"
:key :postponed
:data postponed})))
:key :postponed
:data postponed})))
(reg-sub :wallet.transactions/pending-transactions-list
:<- [:wallet.transactions/grouped-transactions]
(fn [{:keys [pending]}]
(when pending
{:title "Pending"
:key :pending
:data pending})))
:key :pending
:data pending})))
(reg-sub :wallet.transactions/failed-transactions-list
:<- [:wallet.transactions/grouped-transactions]
(fn [{:keys [failed]}]
(when failed
{:title "Failed"
:key :failed
:data failed})))
(defn group-transactions-by-date [transactions]
(->> transactions
@ -101,8 +109,8 @@
(reg-sub :wallet.transactions/completed-transactions-list
:<- [:wallet.transactions/grouped-transactions]
(fn [{:keys [inbound outbound]}]
(group-transactions-by-date (into inbound outbound))))
(fn [{:keys [inbound outbound failed]}]
(group-transactions-by-date (concat inbound outbound failed))))
(reg-sub :wallet.transactions/transactions-history-list
:<- [:wallet.transactions/postponed-transactions-list]

View File

@ -6,6 +6,7 @@
[status-im.ui.components.react :as react]
[status-im.ui.components.status-bar.view :as status-bar]
[status-im.ui.components.styles :as components.styles]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.toolbar.actions :as actions]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.components.status-bar.view :as status-bar]
@ -33,6 +34,7 @@
[(history-action (not (all-checked? filter-data)))]]])
(defn- inbound? [type] (= :inbound type))
(defn- failed? [type] (= :failed type))
(defn- transaction-icon [k background-color color]
{:icon k
@ -41,12 +43,13 @@
(defn- transaction-type->icon [k]
(case k
:inbound (transaction-icon :icons/arrow-left components.styles/color-green-3-light components.styles/color-green-3)
:outbound (transaction-icon :icons/arrow-right components.styles/color-blue4-transparent components.styles/color-blue4)
(:postponed :pending) (transaction-icon :icons/arrow-right components.styles/color-gray4-transparent components.styles/color-gray7)
:inbound (transaction-icon :icons/arrow-left (colors/alpha colors/green 0.2) colors/green)
:outbound (transaction-icon :icons/arrow-right (colors/alpha colors/blue 0.1) colors/blue)
:failed (transaction-icon :icons/exclamation-mark colors/gray-light colors/red)
(:postponed :pending) (transaction-icon :icons/arrow-right colors/gray-light colors/gray)
(throw (str "Unknown transaction type: " k))))
(defn render-transaction [{:keys [hash from-contact to-contact to from type value time-formatted symbol] :as transaction} network]
(defn render-transaction [{:keys [hash from-contact to-contact to from type value time-formatted symbol]} network]
(let [[label contact address
contact-accessibility-label
address-accessibility-label] (if (inbound? type)
@ -62,7 +65,8 @@
[react/text {:style styles/tx-amount
:ellipsize-mode "tail"
:number-of-lines 1}
[react/text {:accessibility-label :amount-text}
[react/text {:accessibility-label :amount-text
:style styles/amount-text}
(-> value (money/internal->formatted symbol decimals) money/to-fixed str)]
" "
[react/text {:accessibility-label :currency-text}
@ -170,16 +174,19 @@
(clojure.string/upper-case (name symbol))]]
[react/text {:style styles/details-header-date} date]]])
(defn progress-bar [progress]
(defn progress-bar [progress failed?]
[react/view {:style styles/progress-bar}
[react/view {:style (styles/progress-bar-done progress)}]
[react/view {:style (styles/progress-bar-todo (- 100 progress))}]])
[react/view {:style (styles/progress-bar-done progress failed?)}]
[react/view {:style (styles/progress-bar-todo (- 100 progress) failed?)}]])
(defn details-confirmations [confirmations confirmations-progress]
(defn details-confirmations [confirmations confirmations-progress type]
[react/view {:style styles/details-block}
[progress-bar confirmations-progress]
[react/text {:style styles/details-confirmations-count}
(str confirmations " " (i18n/label :t/confirmations))]
[progress-bar confirmations-progress (failed? type)]
(if (failed? type)
[react/text {:style styles/details-failed}
(i18n/label :t/failed)]
[react/text {:style styles/details-confirmations-count}
(str confirmations " " (i18n/label :t/confirmations))])
[react/text {:style styles/details-confirmations-helper-text}
(i18n/label :t/confirmations-helper-text)]])
@ -232,9 +239,9 @@
{:label (i18n/label :t/open-on-etherscan) :action #(.openURL react/linking url)}])])
(defview transaction-details []
(letsubs [{:keys [hash url] :as transaction} [:wallet.transactions/transaction-details]
confirmations [:wallet.transactions.details/confirmations]
confirmations-progress [:wallet.transactions.details/confirmations-progress]]
(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 components.styles/flex}
[status-bar/status-bar]
[toolbar/toolbar {}
@ -243,6 +250,6 @@
(when transaction [toolbar/actions (details-action hash url)])]
[react/scroll-view {:style components.styles/main-container}
[details-header transaction]
[details-confirmations confirmations confirmations-progress]
[details-confirmations confirmations confirmations-progress type]
[react/view {:style styles/details-separator}]
[details-list transaction]]]))

View File

@ -84,35 +84,39 @@
(defn- parse-transaction-entries [current-block-number block-info chain direction transfers]
(into {}
(for [transfer transfers]
(let [token (->> transfer :address (tokens/address->token chain))]
[(:transactionHash transfer)
{:block (-> block-info :number str)
:hash (:transactionHash transfer)
:symbol (:symbol token)
:from (-> transfer :topics second remove-padding)
:to (-> transfer :topics last remove-padding)
:value (-> transfer :data ethereum/hex->bignumber)
:type direction
(keep identity
(for [transfer transfers]
(if-let [token (->> transfer :address (tokens/address->token chain))]
[(:transactionHash transfer)
{:block (-> block-info :number str)
:hash (:transactionHash transfer)
:symbol (:symbol token)
:from (-> transfer :topics second remove-padding)
:to (-> transfer :topics last remove-padding)
:value (-> transfer :data ethereum/hex->bignumber)
:type direction
:confirmations (str (- current-block-number (-> transfer :blockNumber ethereum/hex->int)))
:confirmations (str (- current-block-number (-> transfer :blockNumber ethereum/hex->int)))
:gas-price nil
:nonce nil
:data nil
:gas-price nil
:nonce nil
:data nil
:gas-limit nil
:timestamp (-> block-info :timestamp (* 1000) str)
:gas-limit nil
:timestamp (-> block-info :timestamp (* 1000) str)
:gas-used nil
:gas-used nil
;; NOTE(goranjovic) - metadata on the type of token in question: contains name, symbol, decimas, address.
:token token
;; NOTE(goranjovic) - metadata on the type of token: contains name, symbol, decimas, address.
:token token
;; NOTE(goranjovic) - just a flag we need when we merge this entry with the existing entry in
;; the app, e.g. transaction info with gas details, or a previous transfer entry with old
;; confirmations count.
:transfer true}]))))
;; NOTE(goranjovic) - if an event has been emitted, we can say there was no error
:error? false
;; NOTE(goranjovic) - just a flag we need when we merge this entry with the existing entry in
;; the app, e.g. transaction info with gas details, or a previous transfer entry with old
;; confirmations count.
:transfer true}])))))
(defn add-block-info [web3 current-block-number chain direction result success-fn]
(let [transfers-by-block (group-by :blockNumber result)]

View File

@ -25,23 +25,26 @@
(str "https://" network-subdomain ".etherscan.io/api?module=account&action=txlist&address=0x"
account "&startblock=0&endblock=99999999&sort=desc&apikey=" etherscan-api-key "?q=json")))
(defn- format-transaction [account {:keys [value timeStamp blockNumber hash from to gas gasPrice gasUsed nonce confirmations input]}]
(let [inbound? (= (str "0x" account) to)]
{:value value
(defn- format-transaction [account {:keys [value timeStamp blockNumber hash from to gas gasPrice gasUsed nonce confirmations input isError]}]
(let [inbound? (= (str "0x" account) to)
error? (= "1" isError)]
{:value value
;; timestamp is in seconds, we convert it in ms
:timestamp (str timeStamp "000")
:symbol :ETH
:type (if inbound? :inbound :outbound)
:block blockNumber
:hash hash
:from from
:to to
:gas-limit gas
:gas-price gasPrice
:gas-used gasUsed
:nonce nonce
:timestamp (str timeStamp "000")
:symbol :ETH
:type (cond error? :failed
inbound? :inbound
:else :outbound)
:block blockNumber
:hash hash
:from from
:to to
:gas-limit gas
:gas-price gasPrice
:gas-used gasUsed
:nonce nonce
:confirmations confirmations
:data input}))
:data input}))
(defn- format-transactions-response [response account]
(->> response