add gas price in gwei in transaction details
This commit is contained in:
parent
e2f36d4935
commit
998df74b10
|
@ -75,10 +75,11 @@
|
||||||
(fn [[transactions current-transaction network]]
|
(fn [[transactions current-transaction network]]
|
||||||
(let [{:keys [gas-used gas-price hash timestamp type] :as transaction} (get transactions current-transaction)]
|
(let [{:keys [gas-used gas-price hash timestamp type] :as transaction} (get transactions current-transaction)]
|
||||||
(merge transaction
|
(merge transaction
|
||||||
{:cost (money/wei->ether (money/fee-value gas-used gas-price))
|
{:cost (money/wei->ether (money/fee-value gas-used gas-price))
|
||||||
:gas-price-eth (str (.toFixed (money/wei->ether gas-price)) " ETH")
|
:gas-price-eth (money/wei->str :eth gas-price)
|
||||||
:date (datetime/timestamp->long-date timestamp)
|
:gas-price-gwei (money/wei->str :gwei gas-price)
|
||||||
:url (transactions/get-transaction-details-url network hash)}
|
:date (datetime/timestamp->long-date timestamp)
|
||||||
|
:url (transactions/get-transaction-details-url network hash)}
|
||||||
;; TODO (yenda) proper wallet logic when wallet switching is impletmented
|
;; TODO (yenda) proper wallet logic when wallet switching is impletmented
|
||||||
(if (= type :inbound)
|
(if (= type :inbound)
|
||||||
{:to-wallet "Main wallet"}
|
{:to-wallet "Main wallet"}
|
||||||
|
|
|
@ -234,14 +234,14 @@
|
||||||
[react/text {:style transactions.styles/transaction-details-item-value} (str value)]
|
[react/text {:style transactions.styles/transaction-details-item-value} (str value)]
|
||||||
[react/text {:style transactions.styles/transaction-details-item-extra-value} (str extra-value)]]]))
|
[react/text {:style transactions.styles/transaction-details-item-extra-value} (str extra-value)]]]))
|
||||||
|
|
||||||
(defn transaction-details-list [{:keys [block hash from from-wallet to to-wallet gas-limit gas-price-eth gas-used cost nonce data]}]
|
(defn transaction-details-list [{:keys [block hash from from-wallet to to-wallet gas-limit gas-price-gwei gas-price-eth gas-used cost nonce data]}]
|
||||||
[react/view {:style transactions.styles/transaction-details-block}
|
[react/view {:style transactions.styles/transaction-details-block}
|
||||||
[transaction-details-list-row :t/block block]
|
[transaction-details-list-row :t/block block]
|
||||||
[transaction-details-list-row :t/hash hash]
|
[transaction-details-list-row :t/hash hash]
|
||||||
[transaction-details-list-row :t/from (or from-wallet from) (when from-wallet from)]
|
[transaction-details-list-row :t/from (or from-wallet from) (when from-wallet from)]
|
||||||
[transaction-details-list-row :t/to (or to-wallet to) (when to-wallet to)]
|
[transaction-details-list-row :t/to (or to-wallet to) (when to-wallet to)]
|
||||||
[transaction-details-list-row :t/gas-limit gas-limit]
|
[transaction-details-list-row :t/gas-limit gas-limit]
|
||||||
[transaction-details-list-row :t/gas-price gas-price-eth]
|
[transaction-details-list-row :t/gas-price gas-price-gwei gas-price-eth]
|
||||||
[transaction-details-list-row :t/gas-used gas-used]
|
[transaction-details-list-row :t/gas-used gas-used]
|
||||||
[transaction-details-list-row :t/cost-fee (str cost " ETH")]
|
[transaction-details-list-row :t/cost-fee (str cost " ETH")]
|
||||||
[transaction-details-list-row :t/nonce nonce]
|
[transaction-details-list-row :t/nonce nonce]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(ns status-im.utils.money
|
(ns status-im.utils.money
|
||||||
(:require [status-im.js-dependencies :as dependencies]))
|
(:require [status-im.js-dependencies :as dependencies]
|
||||||
|
[clojure.string :as string]))
|
||||||
|
|
||||||
;; The BigNumber version included in web3 sometimes hangs when dividing large
|
;; The BigNumber version included in web3 sometimes hangs when dividing large
|
||||||
;; numbers Hence we want to use these functions instead of fromWei etc, which
|
;; numbers Hence we want to use these functions instead of fromWei etc, which
|
||||||
|
@ -22,10 +23,27 @@
|
||||||
(defn bignumber [n]
|
(defn bignumber [n]
|
||||||
(dependencies/Web3.prototype.toBigNumber (str n)))
|
(dependencies/Web3.prototype.toBigNumber (str n)))
|
||||||
|
|
||||||
(def ether-unit-value (bignumber "1000000000000000000"))
|
(def eth-units
|
||||||
|
{:wei (bignumber "1")
|
||||||
|
:kwei (bignumber "1000")
|
||||||
|
:mwei (bignumber "1000000")
|
||||||
|
:gwei (bignumber "1000000000")
|
||||||
|
:szabo (bignumber "1000000000000")
|
||||||
|
:finney (bignumber "1000000000000000")
|
||||||
|
:eth (bignumber "1000000000000000000")
|
||||||
|
:keth (bignumber "1000000000000000000000")
|
||||||
|
:meth (bignumber "1000000000000000000000000")
|
||||||
|
:geth (bignumber "1000000000000000000000000000")
|
||||||
|
:teth (bignumber "1000000000000000000000000000000")})
|
||||||
|
|
||||||
|
(defn wei-> [unit n]
|
||||||
|
(.dividedBy (bignumber n) (eth-units unit)))
|
||||||
|
|
||||||
|
(defn wei->str [unit n]
|
||||||
|
(str (.toFixed (wei-> unit n)) " " (string/upper-case (name unit))))
|
||||||
|
|
||||||
(defn wei->ether [n]
|
(defn wei->ether [n]
|
||||||
(.dividedBy (bignumber n) ether-unit-value))
|
(wei-> :eth n))
|
||||||
|
|
||||||
(defn fee-value [gas gas-price]
|
(defn fee-value [gas gas-price]
|
||||||
(.times (bignumber gas) (bignumber gas-price)))
|
(.times (bignumber gas) (bignumber gas-price)))
|
||||||
|
|
Loading…
Reference in New Issue