Store bounty balances as decimal instead of 0x string

This commit is contained in:
Teemu Patja 2017-02-25 14:44:29 +02:00
parent 9cb48b5183
commit 9149a5a985
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
3 changed files with 19 additions and 10 deletions

View File

@ -11,12 +11,21 @@
(defn execute (defn execute
[contract to value] [contract to value]
(log/debug "multisig.execute(contract, to, value)" 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 (defn find-confirmation-hash
[receipt] [receipt]
(let [logs (:logs 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-event (first (filter has-confirmation-event logs))
confirmation-data (:data confirmation-event)] confirmation-data (:data confirmation-event)]
(when confirmation-data (when confirmation-data

View File

@ -98,8 +98,8 @@
[(:issue_id b) [(:issue_id b)
(conj b (conj b
(let [claims (bounties-db/bounty-claims (:issue_id b)) (let [claims (bounties-db/bounty-claims (:issue_id b))
balance (:balance b)] balance-eth (:balance b)]
{:balance-eth (eth/hex->eth balance 6) {:balance-eth balance-eth ;; TODO: string expected?
:claims claims}))])))) :claims claims}))]))))

View File

@ -72,7 +72,7 @@
;; a string is a good idea ;; a string is a good idea
(db-bounties/update-payout-receipt issue-id (str receipt))))) (db-bounties/update-payout-receipt issue-id (str receipt)))))
(defn update-balance (defn update-balances
[] []
(doseq [{contract-address :contract_address (doseq [{contract-address :contract_address
owner :login owner :login
@ -82,11 +82,11 @@
old-balance :balance old-balance :balance
issue-number :issue_number} (db-bounties/open-bounty-contracts)] issue-number :issue_number} (db-bounties/open-bounty-contracts)]
(when comment-id (when comment-id
(let [current-balance-hex (eth/get-balance-hex contract-address) (let [current-balance-eth (-> (eth/get-balance-eth contract-address 8)
current-balance-eth (eth/hex->eth current-balance-hex 8) (read-string))
issue-url (str owner "/" repo "/issues/" (str issue-number))] issue-url (str owner "/" repo "/issues/" (str issue-number))]
(when-not (= old-balance current-balance-hex) (when-not (= old-balance (read-string current-balance-eth))
(issues/update-balance contract-address current-balance-hex) (issues/update-balance contract-address (read-string current-balance-eth))
(bounties/update-bounty-comment-image issue-id (bounties/update-bounty-comment-image issue-id
issue-url issue-url
contract-address contract-address
@ -141,5 +141,5 @@
update-confirm-hash update-confirm-hash
update-payout-receipt update-payout-receipt
self-sign-bounty self-sign-bounty
update-balance]) update-balances])
:stop (stop-scheduler)) :stop (stop-scheduler))