Include token balances in Github issue comment
This commit is contained in:
parent
31d8a07b97
commit
5b639e1f20
|
@ -188,34 +188,47 @@
|
|||
"Mainnet")
|
||||
"\n"))
|
||||
|
||||
(defn token-balances-text [token-balances]
|
||||
(when-not (empty? token-balances)
|
||||
(str "Tokens: "
|
||||
(str/join "\n\t" (map (fn [[tla balance]] (format "%s: %.2f"
|
||||
(subs (str tla) 1)
|
||||
(float balance)))
|
||||
token-balances))
|
||||
"\n")))
|
||||
|
||||
(defn generate-open-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))
|
||||
[owner repo issue-number contract-address eth-balance balance-str tokens]
|
||||
(let [image-url (md-image "QR Code" (get-qr-url owner repo issue-number eth-balance))
|
||||
site-url (md-url (server-address) (server-address))]
|
||||
(format (str "Current balance: %s ETH\n"
|
||||
(token-balances-text tokens)
|
||||
"Contract address: %s\n"
|
||||
"%s\n"
|
||||
(network-text)
|
||||
"To claim this bounty sign up at %s")
|
||||
balance contract-address image-url site-url)))
|
||||
"To claim this bounty sign up at %s\n"
|
||||
"To fund it, send ETH or ERC20 tokens to the contract address.")
|
||||
eth-balance contract-address image-url site-url)))
|
||||
|
||||
|
||||
(defn generate-merged-comment
|
||||
[contract-address balance-str winner-login]
|
||||
[contract-address eth-balance-str tokens winner-login]
|
||||
(format (str "Balance: %s ETH\n"
|
||||
(token-balances-text tokens)
|
||||
"Contract address: %s\n"
|
||||
(network-text)
|
||||
"Status: pending maintainer confirmation\n"
|
||||
"Winner: %s\n")
|
||||
balance-str contract-address winner-login))
|
||||
eth-balance-str contract-address winner-login))
|
||||
|
||||
(defn generate-paid-comment
|
||||
[contract-address balance-str payee-login]
|
||||
[contract-address eth-balance-str tokens payee-login]
|
||||
(format (str "Balance: %s ETH\n"
|
||||
(token-balances-text tokens)
|
||||
"Contract address: %s\n"
|
||||
(network-text)
|
||||
"Paid to: %s\n")
|
||||
balance-str contract-address payee-login))
|
||||
eth-balance-str contract-address payee-login))
|
||||
|
||||
|
||||
(defn post-deploying-comment
|
||||
|
@ -244,8 +257,14 @@
|
|||
|
||||
(defn update-comment
|
||||
"Update comment for an open bounty issue"
|
||||
[owner repo comment-id issue-number contract-address balance balance-str]
|
||||
(let [comment (generate-open-comment owner repo issue-number contract-address balance balance-str)]
|
||||
[owner repo comment-id issue-number contract-address eth-balance eth-balance-str tokens]
|
||||
(let [comment (generate-open-comment owner
|
||||
repo
|
||||
issue-number
|
||||
contract-address
|
||||
eth-balance
|
||||
eth-balance-str
|
||||
tokens)]
|
||||
(log/debug (str "Updating " owner "/" repo "/" issue-number
|
||||
" comment #" comment-id " with contents: " comment))
|
||||
(let [req (make-patch-request "repos/%s/%s/issues/comments/%s"
|
||||
|
@ -256,8 +275,11 @@
|
|||
(defn update-merged-issue-comment
|
||||
"Update comment for a bounty issue with winning claim (waiting to be
|
||||
signed off by maintainer)"
|
||||
[owner repo comment-id contract-address balance-str winner-login]
|
||||
(let [comment (generate-merged-comment contract-address balance-str winner-login)]
|
||||
[owner repo comment-id contract-address eth-balance-str tokens winner-login]
|
||||
(let [comment (generate-merged-comment contract-address
|
||||
eth-balance-str
|
||||
tokens
|
||||
winner-login)]
|
||||
(log/debug (str "Updating merged bounty issue (" owner "/" repo ")"
|
||||
" comment#" comment-id " with contents: " comment))
|
||||
(let [req (make-patch-request "repos/%s/%s/issues/comments/%s"
|
||||
|
@ -267,8 +289,11 @@
|
|||
|
||||
(defn update-paid-issue-comment
|
||||
"Update comment for a paid out bounty issue"
|
||||
[owner repo comment-id contract-address balance-str payee-login]
|
||||
(let [comment (generate-paid-comment contract-address balance-str payee-login)]
|
||||
[owner repo comment-id contract-address eth-balance-str tokens payee-login]
|
||||
(let [comment (generate-paid-comment contract-address
|
||||
eth-balance-str
|
||||
tokens
|
||||
payee-login)]
|
||||
(log/debug (str "Updating paid bounty (" owner "/" repo ")"
|
||||
" comment#" comment-id " with contents: " comment))
|
||||
(let [req (make-patch-request "repos/%s/%s/issues/comments/%s"
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
issue-number
|
||||
contract-address
|
||||
balance
|
||||
balance-str))))))
|
||||
balance-str
|
||||
{}))))))
|
||||
|
||||
|
||||
(defn deploy-contract [owner-address issue-id]
|
||||
|
@ -86,6 +87,7 @@
|
|||
comment-id :comment_id
|
||||
issue-number :issue_number
|
||||
balance :balance
|
||||
tokens :tokens
|
||||
winner-login :winner_login} (db-bounties/pending-bounties)
|
||||
:let [value (eth/get-balance-hex contract-address)]]
|
||||
(if (empty? payout-address)
|
||||
|
@ -97,6 +99,7 @@
|
|||
comment-id
|
||||
contract-address
|
||||
(decimal->str balance)
|
||||
tokens
|
||||
winner-login)))))
|
||||
|
||||
(defn update-confirm-hash
|
||||
|
@ -121,6 +124,7 @@
|
|||
comment-id :comment_id
|
||||
issue-number :issue_number
|
||||
balance :balance
|
||||
tokens :tokens
|
||||
payee-login :payee_login} (db-bounties/confirmed-payouts)]
|
||||
(log/debug "confirmed payout:" payout-hash)
|
||||
(when-let [receipt (eth/get-transaction-receipt payout-hash)]
|
||||
|
@ -131,6 +135,7 @@
|
|||
comment-id
|
||||
contract-address
|
||||
(decimal->str balance)
|
||||
tokens
|
||||
payee-login))))
|
||||
|
||||
|
||||
|
@ -229,7 +234,8 @@
|
|||
issue-number
|
||||
contract-address
|
||||
balance-eth
|
||||
balance-eth-str))))))
|
||||
balance-eth-str
|
||||
token-balances))))))
|
||||
|
||||
|
||||
(defn run-1-min-interval-tasks [time]
|
||||
|
|
Loading…
Reference in New Issue