From 9149a5a985ab1adfa285b0c7bea362ffc8eedbbf Mon Sep 17 00:00:00 2001 From: Teemu Patja Date: Sat, 25 Feb 2017 14:44:29 +0200 Subject: [PATCH] Store bounty balances as decimal instead of 0x string --- src/clj/commiteth/eth/multisig_wallet.clj | 13 +++++++++++-- src/clj/commiteth/routes/services.clj | 4 ++-- src/clj/commiteth/scheduler.clj | 12 ++++++------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/clj/commiteth/eth/multisig_wallet.clj b/src/clj/commiteth/eth/multisig_wallet.clj index 935ea55..6cc3a2b 100644 --- a/src/clj/commiteth/eth/multisig_wallet.clj +++ b/src/clj/commiteth/eth/multisig_wallet.clj @@ -11,12 +11,21 @@ (defn execute [contract to value] (log/debug "multisig.execute(contract, to, value)" contract to value) - (eth/execute (eth/eth-account) contract "0xb61d27f6" to value "0x60" "0x0" "0x0")) + (eth/execute (eth/eth-account) + contract + "0xb61d27f6" + to + value + "0x60" + "0x0" + "0x0")) (defn find-confirmation-hash [receipt] (let [logs (:logs receipt) - has-confirmation-event #(some (fn [topic] (= topic confirmation-topic)) (:topics %)) + has-confirmation-event #(some (fn [topic] (= topic + confirmation-topic)) + (:topics %)) confirmation-event (first (filter has-confirmation-event logs)) confirmation-data (:data confirmation-event)] (when confirmation-data diff --git a/src/clj/commiteth/routes/services.clj b/src/clj/commiteth/routes/services.clj index ca4d9a0..e828565 100644 --- a/src/clj/commiteth/routes/services.clj +++ b/src/clj/commiteth/routes/services.clj @@ -98,8 +98,8 @@ [(:issue_id b) (conj b (let [claims (bounties-db/bounty-claims (:issue_id b)) - balance (:balance b)] - {:balance-eth (eth/hex->eth balance 6) + balance-eth (:balance b)] + {:balance-eth balance-eth ;; TODO: string expected? :claims claims}))])))) diff --git a/src/clj/commiteth/scheduler.clj b/src/clj/commiteth/scheduler.clj index 9e267f5..f51dce0 100644 --- a/src/clj/commiteth/scheduler.clj +++ b/src/clj/commiteth/scheduler.clj @@ -72,7 +72,7 @@ ;; a string is a good idea (db-bounties/update-payout-receipt issue-id (str receipt))))) -(defn update-balance +(defn update-balances [] (doseq [{contract-address :contract_address owner :login @@ -82,11 +82,11 @@ old-balance :balance issue-number :issue_number} (db-bounties/open-bounty-contracts)] (when comment-id - (let [current-balance-hex (eth/get-balance-hex contract-address) - current-balance-eth (eth/hex->eth current-balance-hex 8) + (let [current-balance-eth (-> (eth/get-balance-eth contract-address 8) + (read-string)) issue-url (str owner "/" repo "/issues/" (str issue-number))] - (when-not (= old-balance current-balance-hex) - (issues/update-balance contract-address current-balance-hex) + (when-not (= old-balance (read-string current-balance-eth)) + (issues/update-balance contract-address (read-string current-balance-eth)) (bounties/update-bounty-comment-image issue-id issue-url contract-address @@ -141,5 +141,5 @@ update-confirm-hash update-payout-receipt self-sign-bounty - update-balance]) + update-balances]) :stop (stop-scheduler))