Fix crash in token-balances, fix update-balances
* fix null pointer crash in token-balances * fix bug in periodic update-balances
This commit is contained in:
parent
f8d00196d6
commit
e4124d6bc2
|
@ -61,7 +61,7 @@
|
||||||
correct-topic? (fn [topic]
|
correct-topic? (fn [topic]
|
||||||
(= topic topic-id))
|
(= topic topic-id))
|
||||||
has-correct-event? #(some correct-topic?
|
has-correct-event? #(some correct-topic?
|
||||||
(:topics %))
|
(:topics %))
|
||||||
event (first (filter has-correct-event? logs))]
|
event (first (filter has-correct-event? logs))]
|
||||||
(:data event)))
|
(:data event)))
|
||||||
|
|
||||||
|
@ -157,11 +157,14 @@
|
||||||
"Get a given bounty contract's token balances. Assumes contract's internal balances have been updated"
|
"Get a given bounty contract's token balances. Assumes contract's internal balances have been updated"
|
||||||
[bounty-addr]
|
[bounty-addr]
|
||||||
(let [bounty-contract (load-bounty-contract bounty-addr)
|
(let [bounty-contract (load-bounty-contract bounty-addr)
|
||||||
token-addresses (map str (-> bounty-contract
|
token-addresses (-> bounty-contract
|
||||||
(.getTokenList)
|
(.getTokenList)
|
||||||
.get
|
.get)]
|
||||||
.getValue))]
|
(if token-addresses
|
||||||
(into {}
|
(let [addrs (map str
|
||||||
(map (fn [addr] (let [tla (first (token-data/token-info-by-addr addr))]
|
(.getValue token-addresses))]
|
||||||
(assert tla)
|
(into {}
|
||||||
[tla (token-balance bounty-addr tla)])) token-addresses))))
|
(map (fn [addr] (let [tla (first (token-data/token-info-by-addr addr))]
|
||||||
|
(assert tla)
|
||||||
|
[tla (token-balance bounty-addr tla)])) addrs)))
|
||||||
|
{})))
|
||||||
|
|
|
@ -49,11 +49,11 @@
|
||||||
|
|
||||||
(defn deploy-contract [owner-address issue-id]
|
(defn deploy-contract [owner-address issue-id]
|
||||||
(let [transaction-hash (multisig/deploy-multisig owner-address)]
|
(let [transaction-hash (multisig/deploy-multisig owner-address)]
|
||||||
(if (nil? transaction-hash)
|
(if (nil? transaction-hash)
|
||||||
(log/error "Failed to deploy contract to" owner-address)
|
(log/error "Failed to deploy contract to" owner-address)
|
||||||
(log/info "Contract deployed, transaction-hash:"
|
(log/info "Contract deployed, transaction-hash:"
|
||||||
transaction-hash ))
|
transaction-hash ))
|
||||||
(issues/update-transaction-hash issue-id transaction-hash)))
|
(issues/update-transaction-hash issue-id transaction-hash)))
|
||||||
|
|
||||||
|
|
||||||
(defn redeploy-failed-contracts
|
(defn redeploy-failed-contracts
|
||||||
|
@ -161,33 +161,32 @@
|
||||||
db-tokens :tokens
|
db-tokens :tokens
|
||||||
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-eth-str (eth/get-balance-eth contract-address 6)
|
(let [balance-eth-str (eth/get-balance-eth contract-address 6)
|
||||||
current-balance-eth (read-string current-balance-eth-str)
|
balance-eth (read-string balance-eth-str)
|
||||||
current-token-balances (multisig/token-balances contract-address)]
|
token-balances (multisig/token-balances contract-address)]
|
||||||
(log/debug "update-balances" current-balance-eth
|
(log/debug "update-balances" balance-eth
|
||||||
current-balance-eth-str owner repo issue-number)
|
balance-eth-str token-balances owner repo issue-number)
|
||||||
(when (or
|
(when (or
|
||||||
(not (float= db-balance-eth current-balance-eth))
|
(not (float= db-balance-eth balance-eth))
|
||||||
(not= db-tokens current-token-balances))
|
(not= db-tokens token-balances))
|
||||||
(log/debug "balances differ")
|
(log/debug "balances differ")
|
||||||
(-> contract-address
|
(issues/update-eth-balance contract-address balance-eth)
|
||||||
(issues/update-eth-balance current-balance-eth)
|
(issues/update-token-balances contract-address token-balances)
|
||||||
(issues/update-token-balances current-token-balances))
|
|
||||||
;; TODO: comment and comment image will show tokens and USD value
|
;; TODO: comment and comment image will show tokens and USD value
|
||||||
(bounties/update-bounty-comment-image issue-id
|
(bounties/update-bounty-comment-image issue-id
|
||||||
owner
|
owner
|
||||||
repo
|
repo
|
||||||
issue-number
|
issue-number
|
||||||
contract-address
|
contract-address
|
||||||
current-balance-eth
|
balance-eth
|
||||||
current-balance-eth-str)
|
balance-eth-str)
|
||||||
(github/update-comment owner
|
(github/update-comment owner
|
||||||
repo
|
repo
|
||||||
comment-id
|
comment-id
|
||||||
issue-number
|
issue-number
|
||||||
contract-address
|
contract-address
|
||||||
current-balance-eth
|
balance-eth
|
||||||
current-balance-eth-str))))))
|
balance-eth-str))))))
|
||||||
|
|
||||||
|
|
||||||
(defn update-bounty-token-balances
|
(defn update-bounty-token-balances
|
||||||
|
|
Loading…
Reference in New Issue