From ff995f1a9dec9a30f52675e374097b926a457318 Mon Sep 17 00:00:00 2001 From: Teemu Patja Date: Tue, 31 Oct 2017 19:11:13 +0200 Subject: [PATCH] Configurable style for :base field in token registry Parity's token registry uses eg. :base 1000000000, while the Status token reg uses eg. :base 16. Now both are supported, default is Status style and Parity style can be enabled with a config param. --- src/clj/commiteth/eth/multisig_wallet.clj | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/clj/commiteth/eth/multisig_wallet.clj b/src/clj/commiteth/eth/multisig_wallet.clj index c197134..4b3b2b9 100644 --- a/src/clj/commiteth/eth/multisig_wallet.clj +++ b/src/clj/commiteth/eth/multisig_wallet.clj @@ -31,6 +31,11 @@ (defn factory-contract-addr [] (env :contract-factory-addr "0x47F56FD26EEeCda4FdF5DB5843De1fe75D2A64A6")) +(defn tokenreg-base-format + ;; status tokenreg uses eg :base 18, while parity uses :base 1000000000000 + [] + (env :tokenreg-base-format :status)) + (defn create-new [owner1 owner2 required] (eth/execute (eth/eth-account) @@ -131,10 +136,12 @@ "Convert given value to decimal using given token's base." [value token] (let [token-details (token-data/token-info token) - token-base (:base token-details)] - (assert (> token-base 0)) - (-> value - (/ (Math/pow 10 token-base))))) + token-base (:base token-details) + base (if (= (tokenreg-base-format) :status) + (Math/pow 10 token-base) + token-base)] + (assert (> base 0)) + (/ value base))) (defn token-balance-in-bounty