diff --git a/resources/public/img/deploying_contract.png b/resources/public/img/deploying_contract.png new file mode 100644 index 0000000..761a2cf Binary files /dev/null and b/resources/public/img/deploying_contract.png differ diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql index 37a175b..9e7742a 100644 --- a/resources/sql/queries.sql +++ b/resources/sql/queries.sql @@ -147,6 +147,7 @@ WITH t AS ( i.title AS title, i.transaction_hash AS transaction_hash, i.contract_address AS contract_address, + i.comment_id AS comment_id, i.repo_id AS repo_id, r.owner AS owner, r.repo AS repo @@ -159,7 +160,7 @@ SET contract_address = :contract_address, updated = timezone('utc'::text, now()) FROM t WHERE i.issue_id = :issue_id -RETURNING t.issue_id, t.issue_number, t.title, t.transaction_hash, i.contract_address, t.owner, t.repo, t.repo_id; +RETURNING t.issue_id, t.issue_number, t.title, t.transaction_hash, t.comment_id, i.contract_address, t.owner, t.repo, t.repo_id; -- :name update-comment-id :! :n -- :doc updates comment-id for a given issue diff --git a/src/clj/commiteth/bounties.clj b/src/clj/commiteth/bounties.clj index e85667d..86d72e7 100644 --- a/src/clj/commiteth/bounties.clj +++ b/src/clj/commiteth/bounties.clj @@ -23,17 +23,24 @@ issue-number :number issue-title :title} issue created-issue (issues/create repo-id issue-id issue-number issue-title) - repo-owner-address (:address (users/get-repo-owner repo-id))] - (log/debug "Adding bounty for issue " repo issue-number "owner address: " repo-owner-address) + {owner-address :address + owner :owner} (users/get-repo-owner repo-id)] + (log/debug "Adding bounty for issue " repo issue-number "owner address: " owner-address) (if (= 1 created-issue) - (if (empty? repo-owner-address) + (if (empty? owner-address) (log/error "Unable to deploy bounty contract because" "repo owner has no Ethereum addres") (do - (log/debug "deploying contract to " repo-owner-address) - (let [transaction-hash (eth/deploy-contract repo-owner-address)] + (->> (github/post-deploying-comment owner + repo + issue-number) + :id + (issues/update-comment-id issue-id)) + (log/debug "Posting dep") + (log/debug "deploying contract to " owner-address) + (let [transaction-hash (eth/deploy-contract owner-address)] (if (nil? transaction-hash) - (log/error "Failed to deploy contract to" repo-owner-address) + (log/error "Failed to deploy contract to" owner-address) (log/info "Contract deployed, transaction-hash:" transaction-hash )) (issues/update-transaction-hash issue-id transaction-hash)))) diff --git a/src/clj/commiteth/github/core.clj b/src/clj/commiteth/github/core.clj index 3a63f62..ae88318 100644 --- a/src/clj/commiteth/github/core.clj +++ b/src/clj/commiteth/github/core.clj @@ -162,6 +162,11 @@ [alt src] (str "!" (md-url alt src))) + +(defn generate-deploying-comment + [owner repo issue-number] + (md-image "Contract deploying" (str (server-address) "/img/deploying_contract.png"))) + (defn generate-comment [owner repo issue-number contract-address balance balance-str] (let [image-url (md-image "QR Code" (get-qr-url owner repo issue-number balance)) @@ -174,9 +179,9 @@ "%s") balance-str contract-address image-url site-url))) -(defn post-comment - [owner repo issue-number contract-address balance balance-str] - (let [comment (generate-comment owner repo issue-number contract-address balance balance-str)] +(defn post-deploying-comment + [owner repo issue-number] + (let [comment (generate-deploying-comment owner repo issue-number)] (log/debug "Posting comment to" (str owner "/" repo "/" issue-number) ":" comment) (issues/create-comment owner repo issue-number comment (self-auth-params)))) diff --git a/src/clj/commiteth/scheduler.clj b/src/clj/commiteth/scheduler.clj index 02a7c0b..1e39b91 100644 --- a/src/clj/commiteth/scheduler.clj +++ b/src/clj/commiteth/scheduler.clj @@ -24,6 +24,7 @@ (let [issue (issues/update-contract-address issue-id contract-address) {owner :owner repo :repo + comment-id :comment_id issue-number :issue_number} issue balance-str (eth/get-balance-eth contract-address 8) balance (read-string balance-str)] @@ -34,14 +35,13 @@ contract-address balance balance-str) - (->> (github/post-comment owner - repo - issue-number - contract-address - balance - balance-str) - :id - (issues/update-comment-id issue-id))))))) + (github/update-comment owner + repo + comment-id + issue-number + contract-address + balance + balance-str)))))) (defn self-sign-bounty "Walks through all issues eligible for bounty payout and signs corresponding transaction"