Post "deploying contract" image

Post a PNG image informing that the bounty contract is being deployed
immediately after bounty label.

Fixes: #26
This commit is contained in:
Teemu Patja 2017-03-06 20:33:42 +02:00
parent a3a7ac915b
commit c93326e874
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
5 changed files with 31 additions and 18 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -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

View File

@ -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))))

View File

@ -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))))

View File

@ -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"