Various bugfixes:
* extra newline in contract data * insufficient gas * wrong headless image generation * stop scheduler threads on exit etc.
This commit is contained in:
parent
c0e4f51069
commit
bce7ef436a
|
@ -141,7 +141,8 @@ SELECT
|
||||||
issue_id,
|
issue_id,
|
||||||
transaction_hash
|
transaction_hash
|
||||||
FROM issues
|
FROM issues
|
||||||
WHERE contract_address IS NULL;
|
WHERE contract_address IS NULL
|
||||||
|
AND issues.transaction_hash IS NOT NULL;
|
||||||
|
|
||||||
-- Pull Requests -------------------------------------------------------------------
|
-- Pull Requests -------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,12 @@
|
||||||
(log/error "Method: " method ", error: " error))
|
(log/error "Method: " method ", error: " error))
|
||||||
(:result result)))
|
(:result result)))
|
||||||
|
|
||||||
|
(defn estimate-gas
|
||||||
|
[from to value & [params]]
|
||||||
|
(eth-rpc "eth_estimateGas" [(merge params {:from from
|
||||||
|
:to to
|
||||||
|
:value value})]))
|
||||||
|
|
||||||
(defn hex->big-integer
|
(defn hex->big-integer
|
||||||
[hex]
|
[hex]
|
||||||
(new BigInteger (subs hex 2) 16))
|
(new BigInteger (subs hex 2) 16))
|
||||||
|
@ -50,10 +56,13 @@
|
||||||
|
|
||||||
(defn send-transaction
|
(defn send-transaction
|
||||||
[from to value & [params]]
|
[from to value & [params]]
|
||||||
(eth-rpc "personal_signAndSendTransaction" [(merge params {:from from
|
;; todo: estimate gas instead of hardcoding
|
||||||
:to to
|
(let [gas 1248650]
|
||||||
:value value})
|
(eth-rpc "personal_signAndSendTransaction" [(merge params {:from from
|
||||||
(eth-password)]))
|
:to to
|
||||||
|
:value value
|
||||||
|
:gas gas})
|
||||||
|
(eth-password)])))
|
||||||
|
|
||||||
(defn get-transaction-receipt
|
(defn get-transaction-receipt
|
||||||
[hash]
|
[hash]
|
||||||
|
@ -62,9 +71,7 @@
|
||||||
(defn deploy-contract
|
(defn deploy-contract
|
||||||
[]
|
[]
|
||||||
(let [contract-code (-> "contracts/wallet.data" io/resource slurp)]
|
(let [contract-code (-> "contracts/wallet.data" io/resource slurp)]
|
||||||
(send-transaction (eth-account) nil 1
|
(send-transaction (eth-account) nil 1 {:data contract-code})))
|
||||||
{:gas 1248650
|
|
||||||
:data contract-code})))
|
|
||||||
|
|
||||||
(defn- format-param
|
(defn- format-param
|
||||||
[param]
|
[param]
|
||||||
|
|
|
@ -120,13 +120,13 @@
|
||||||
(defn post-comment
|
(defn post-comment
|
||||||
[user repo issue-number balance]
|
[user repo issue-number balance]
|
||||||
(let [comment (generate-comment user repo issue-number balance)]
|
(let [comment (generate-comment user repo issue-number balance)]
|
||||||
(log/debug "Posting comment to" (str user "/" repo) ":" comment)
|
(log/debug "Posting comment to" (str user "/" repo "/" issue-number) ":" comment)
|
||||||
(issues/create-comment user repo issue-number comment (self-auth-params))))
|
(issues/create-comment user repo issue-number comment (self-auth-params))))
|
||||||
|
|
||||||
(defn update-comment
|
(defn update-comment
|
||||||
[user repo comment-id issue-number balance]
|
[user repo comment-id issue-number balance]
|
||||||
(let [comment (generate-comment user repo issue-number balance)]
|
(let [comment (generate-comment user repo issue-number balance)]
|
||||||
(log/debug (str "Updating " user "/" repo " comment #" comment-id " with contents: " comment))
|
(log/debug (str "Updating " user "/" repo "/" issue-number " comment #" comment-id " with contents: " comment))
|
||||||
(issues/edit-comment user repo comment-id comment (self-auth-params))))
|
(issues/edit-comment user repo comment-id comment (self-auth-params))))
|
||||||
|
|
||||||
(defn get-issue
|
(defn get-issue
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
[commiteth.db.issues :as issues]
|
[commiteth.db.issues :as issues]
|
||||||
[commiteth.db.users :as users]
|
[commiteth.db.users :as users]
|
||||||
[commiteth.db.bounties :as bounties]
|
[commiteth.db.bounties :as bounties]
|
||||||
[overtone.at-at :refer [every mk-pool]]
|
[overtone.at-at :refer [every mk-pool stop-and-reset-pool!]]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[mount.core :as mount]))
|
[mount.core :as mount]))
|
||||||
|
|
||||||
|
@ -15,8 +15,9 @@
|
||||||
"For each pending deployment:
|
"For each pending deployment:
|
||||||
gets transasction receipt, updates db state, posts github comment and adds owners to the wallet"
|
gets transasction receipt, updates db state, posts github comment and adds owners to the wallet"
|
||||||
[]
|
[]
|
||||||
(for [{issue-id :issue_id
|
(doseq [{issue-id :issue_id
|
||||||
transaction-hash :transaction_hash} (issues/list-pending-deployments)]
|
transaction-hash :transaction_hash} (issues/list-pending-deployments)]
|
||||||
|
(log/debug "pending deployment:" transaction-hash)
|
||||||
(when-let [receipt (eth/get-transaction-receipt transaction-hash)]
|
(when-let [receipt (eth/get-transaction-receipt transaction-hash)]
|
||||||
(log/info "transaction receipt for issue #" issue-id ": " receipt)
|
(log/info "transaction receipt for issue #" issue-id ": " receipt)
|
||||||
(when-let [contract-address (:contractAddress receipt)]
|
(when-let [contract-address (:contractAddress receipt)]
|
||||||
|
@ -35,31 +36,34 @@
|
||||||
(defn self-sign-bounty
|
(defn self-sign-bounty
|
||||||
"Walks through all issues eligible for bounty payout and signs corresponding transaction"
|
"Walks through all issues eligible for bounty payout and signs corresponding transaction"
|
||||||
[]
|
[]
|
||||||
(for [{contract-address :contract_address
|
(doseq [{contract-address :contract_address
|
||||||
issue-id :issue_id
|
issue-id :issue_id
|
||||||
payout-address :payout_address} (bounties/pending-bounties-list)]
|
payout-address :payout_address} (bounties/pending-bounties-list)
|
||||||
(let [value (eth/get-balance-hex contract-address)]
|
:let [value (eth/get-balance-hex contract-address)]]
|
||||||
(->>
|
(->>
|
||||||
(wallet/execute contract-address payout-address value)
|
(wallet/execute contract-address payout-address value)
|
||||||
(bounties/update-confirm-hash issue-id)))))
|
(bounties/update-confirm-hash issue-id))))
|
||||||
|
|
||||||
(defn update-balance
|
(defn update-balance
|
||||||
[]
|
[]
|
||||||
(for [{contract-address :contract_address
|
(doseq [{contract-address :contract_address
|
||||||
login :login
|
login :login
|
||||||
repo :repo
|
repo :repo
|
||||||
comment-id :comment_id
|
comment-id :comment_id
|
||||||
issue-number :issue_number} (bounties/list-wallets)]
|
issue-number :issue_number} (bounties/list-wallets)]
|
||||||
(when comment-id
|
(when comment-id
|
||||||
(let [old-balance (issues/get-balance contract-address)
|
(let [{old-balance :balance} (issues/get-balance contract-address)
|
||||||
current-balance-hex (eth/get-balance-hex contract-address)
|
current-balance-hex (eth/get-balance-hex contract-address)
|
||||||
current-balance-eth (eth/hex->eth current-balance-hex 8)]
|
current-balance-eth (eth/hex->eth current-balance-hex 8)]
|
||||||
(when-not (= old-balance current-balance-hex)
|
(when-not (= old-balance current-balance-hex)
|
||||||
(issues/update-balance contract-address current-balance-hex)
|
(issues/update-balance contract-address current-balance-hex)
|
||||||
(github/update-comment login repo comment-id issue-number current-balance-eth))))))
|
(github/update-comment login repo comment-id issue-number current-balance-eth))))))
|
||||||
|
|
||||||
(mount/defstate scheduler :start
|
(mount/defstate scheduler
|
||||||
(do
|
:start (do
|
||||||
(every (* 5 60 1000) update-issue-contract-address pool)
|
(every (* 1 60 1000) update-issue-contract-address pool)
|
||||||
(every (* 60 1000) self-sign-bounty pool)
|
(every (* 1 60 1000) self-sign-bounty pool)
|
||||||
(every (* 5 60 1000) update-balance pool)))
|
(every (* 1 60 1000) update-balance pool))
|
||||||
|
:stop (do
|
||||||
|
(log/info "Stopping scheduler pool")
|
||||||
|
(stop-and-reset-pool! pool)))
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
|
|
||||||
(defn ^BufferedImage create-image
|
(defn ^BufferedImage create-image
|
||||||
[width height]
|
[width height]
|
||||||
(.. GraphicsEnvironment getLocalGraphicsEnvironment getDefaultScreenDevice getDefaultConfiguration
|
(new BufferedImage width height BufferedImage/TYPE_INT_ARGB))
|
||||||
(createCompatibleImage width height)))
|
|
||||||
|
|
||||||
(defn html->image
|
(defn html->image
|
||||||
[html width height]
|
[html width height]
|
||||||
|
|
Loading…
Reference in New Issue