Skip to content

Commit

Permalink
Fix amount rounding error
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Vlasov committed Mar 31, 2020
1 parent de520f7 commit ba002a7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/status_im/hardwallet/sign.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.hardwallet.card :as card]
[status-im.utils.fx :as fx]
[status-im.utils.money :as money]
[status-im.utils.types :as types]
[taoensso.timbre :as log]
[status-im.hardwallet.common :as common]))
Expand Down Expand Up @@ -39,8 +40,7 @@
{:events [:hardwallet/sign-typed-data]}
[{:keys [db] :as cofx}]
(let [card-connected? (get-in db [:hardwallet :card-connected?])
hash (get-in db [:hardwallet :hash])
_ (log/info "###sign-typed-data" (get db :signing/sign))]
hash (get-in db [:hardwallet :hash])]
(if card-connected?
(do
(when @sign-typed-data-listener
Expand All @@ -65,7 +65,8 @@
{:events [:hardwallet/fetch-currency-decimals-on-success]}
[{:keys [db] :as cofx} decimals]
{:db (update-in db [:signing/sign :formatted-data :message]
#(assoc % :formatted-amount (/ (:amount %) (Math/pow 10 decimals))))})
#(assoc % :formatted-amount (.dividedBy (money/bignumber (:amount %))
(money/bignumber (money/from-decimal decimals)))))})

(fx/defn store-hash-and-sign-typed
{:events [:hardwallet/store-hash-and-sign-typed]}
Expand Down

0 comments on commit ba002a7

Please sign in to comment.