From a8600d1cbdf31017eb38dc6cecf6e7700d4c3575 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Tue, 22 May 2018 18:57:16 +0300 Subject: [PATCH] Fix claim handling --- src/clj/commiteth/github/core.clj | 2 +- src/clj/commiteth/routes/webhooks.clj | 16 ++++++------- src/clj/commiteth/scheduler.clj | 34 +++++++++++++-------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/clj/commiteth/github/core.clj b/src/clj/commiteth/github/core.clj index 0edb34c..8d31b5d 100644 --- a/src/clj/commiteth/github/core.clj +++ b/src/clj/commiteth/github/core.clj @@ -356,7 +356,7 @@ balance-eth tokens winner-login) - :else nil)] + nil)] (log/info (str "Updating " owner "/" repo "/" issue-number " comment #" comment-id " with contents: " comment)) (if (= state :deploying) diff --git a/src/clj/commiteth/routes/webhooks.clj b/src/clj/commiteth/routes/webhooks.clj index dff53a7..f6b9351 100644 --- a/src/clj/commiteth/routes/webhooks.clj +++ b/src/clj/commiteth/routes/webhooks.clj @@ -125,8 +125,8 @@ :pr_number pr-number :title pr-title :user_id user-id - :issue_number (:issue_number issue) - :issue_id (:issue_id issue) + :issue_number (:issue-number issue) + :issue_id (:issue-id issue) :state event-type}] ;; TODO: in the opened case if the submitting user has no ;; Ethereum address stored, we could post a comment to the @@ -134,17 +134,17 @@ ;; merged (cond open-or-edit? (do - (log/infof "issue %s: PR with reference to bounty issue opened" (:issue_number issue)) + (log/infof "issue %s: PR with reference to bounty issue opened" (:issue-number issue)) (pull-requests/save (merge pr-data {:state :opened :commit_sha head-sha}))) close? (if merged? - (do (log/infof "issue %s: PR with reference to bounty issue merged" (:issue_number issue)) + (do (log/infof "issue %s: PR with reference to bounty issue merged" (:issue-number issue)) (pull-requests/save (merge pr-data {:state :merged :commit_sha head-sha})) - (issues/update-commit-sha (:issue_id issue) head-sha) - (db-bounties/update-winner-login (:issue_id issue) login)) - (do (log/infof "issue %s: PR with reference to bounty issue closed with no merge" (:issue_number issue)) + (issues/update-commit-sha (:issue-id issue) head-sha) + (db-bounties/update-winner-login (:issue-id issue) login)) + (do (log/infof "issue %s: PR with reference to bounty issue closed with no merge" (:issue-number issue)) (pull-requests/save (merge pr-data {:state :closed :commit_sha head-sha}))))))) @@ -177,7 +177,7 @@ (doseq [issue issues] (if-not (:commit_sha issue) ; no PR has been merged yet referencing this issue (do - (log/info "Referenced bounty issue found" owner repo (:issue_number issue)) + (log/info "Referenced bounty issue found" owner repo (:issue-number issue)) (handle-claim issue user-id login name diff --git a/src/clj/commiteth/scheduler.clj b/src/clj/commiteth/scheduler.clj index 86461a8..0b7404e 100644 --- a/src/clj/commiteth/scheduler.clj +++ b/src/clj/commiteth/scheduler.clj @@ -103,26 +103,26 @@ (defn update-confirm-hash "Gets transaction receipt for each pending payout and updates DB confirm_hash with tranaction ID of commiteth bot account's confirmation." - [] + [issue-id execute-hash] (log/info "In update-confirm-hash") (p :update-confirm-hash - (doseq [{:keys [issue-id execute-hash]} (db-bounties/pending-payouts)] + (try (log/infof "issue %s: pending payout: %s" issue-id execute-hash) - (try - (when-let [receipt (eth/get-transaction-receipt execute-hash)] - (log/infof "issue %s: execution receipt for issue " issue-id receipt) - (when-let [confirm-hash (multisig/find-confirmation-tx-id receipt)] - (log/infof "issue %s: confirm hash:" issue-id confirm-hash) - (bounties/transition {:issue-id issue-id - :tx-info {:issue-id issue-id - :tx-hash execute-hash - :result confirm-hash - :type :execute}} - :pending-maintainer-confirmation) - - )) - (catch Throwable ex - (log/errorf ex "issue %s: update-confirm-hash exception:" issue-id))) ) + (when-let [receipt (eth/get-transaction-receipt execute-hash)] + (log/infof "issue %s: execution receipt for issue " issue-id receipt) + (when-let [confirm-hash (multisig/find-confirmation-tx-id receipt)] + (log/infof "issue %s: confirm hash: %s" issue-id confirm-hash) + (bounties/transition {:issue-id issue-id + :confirm-hash confirm-hash + :tx-info {:issue-id issue-id + :tx-hash execute-hash + :result confirm-hash + :type :execute}} + :pending-maintainer-confirmation) + + )) + (catch Throwable ex + (log/errorf ex "issue %s: update-confirm-hash exception:" issue-id))) (log/info "Exit update-confirm-hash"))) (defn update-confirm-hashes