From 67754abaf18d637ce117c412753ba78e4b74c1e1 Mon Sep 17 00:00:00 2001 From: Teemu Patja Date: Mon, 9 Oct 2017 17:09:26 +0300 Subject: [PATCH] Include link to etherscan.io for deployment transaction * include a link to etherscan.io for a bounty contract's "deploying" comment Fixes: #99 --- src/clj/commiteth/bounties.clj | 18 ++++++++++-------- src/clj/commiteth/github/core.clj | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/clj/commiteth/bounties.clj b/src/clj/commiteth/bounties.clj index 1057d15..8ed0795 100644 --- a/src/clj/commiteth/bounties.clj +++ b/src/clj/commiteth/bounties.clj @@ -31,18 +31,20 @@ (log/error "Unable to deploy bounty contract because" "repo owner has no Ethereum addres") (do - (->> (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" owner-address) - (log/info "Contract deployed, transaction-hash:" - transaction-hash )) + (do + (log/info "Contract deployed, transaction-hash:" + transaction-hash) + (->> (github/post-deploying-comment owner + repo + issue-number + transaction-hash) + :id + (issues/update-comment-id issue-id))) +) (issues/update-transaction-hash issue-id transaction-hash)))) (log/debug "Issue already exists in DB, ignoring")))) diff --git a/src/clj/commiteth/github/core.clj b/src/clj/commiteth/github/core.clj index 23f27fc..8859eeb 100644 --- a/src/clj/commiteth/github/core.clj +++ b/src/clj/commiteth/github/core.clj @@ -182,10 +182,21 @@ [alt src] (str "!" (md-url alt src))) +(defn etherscan-tx-url [tx-id] + (str "https://" + (when (on-testnet?) "ropsten.") + "etherscan.io/tx/" tx-id)) (defn generate-deploying-comment - [owner repo issue-number] - (md-image "Contract deploying" (str (server-address) "/img/deploying_contract.png"))) + [owner repo issue-number tx-id] + (let [deploying-image (md-image + "Contract deploying" + (str (server-address) "/img/deploying_contract.png")) + tx-link (md-url tx-id (etherscan-tx-url tx-id))] + (format (str "%s\n" + "Transaction: %s\n") + deploying-image + tx-link))) (defn network-text [] (str "Network: " (if (on-testnet?) @@ -225,8 +236,8 @@ (defn post-deploying-comment - [owner repo issue-number] - (let [comment (generate-deploying-comment owner repo issue-number)] + [owner repo issue-number tx-id] + (let [comment (generate-deploying-comment owner repo issue-number tx-id)] (log/debug "Posting comment to" (str owner "/" repo "/" issue-number) ":" comment) (issues/create-comment owner repo issue-number comment (self-auth-params))))