start reworking revoke route to not be responsible for confirm hash
This commit is contained in:
parent
8dc9836be2
commit
b865fad200
|
@ -486,7 +486,7 @@ SELECT
|
||||||
i.is_open AS is_open,
|
i.is_open AS is_open,
|
||||||
i.winner_login AS winner_login,
|
i.winner_login AS winner_login,
|
||||||
i.commit_sha AS commit_sha,
|
i.commit_sha AS commit_sha,
|
||||||
i.owner_address AS owner_address,
|
u.address AS owner_address,
|
||||||
i.contract_address AS contract_address,
|
i.contract_address AS contract_address,
|
||||||
i.confirm_hash AS confirm_hash,
|
i.confirm_hash AS confirm_hash,
|
||||||
i.title AS title,
|
i.title AS title,
|
||||||
|
@ -494,8 +494,9 @@ SELECT
|
||||||
i.repo_id AS repo_id,
|
i.repo_id AS repo_id,
|
||||||
r.owner AS owner,
|
r.owner AS owner,
|
||||||
r.repo AS repo
|
r.repo AS repo
|
||||||
FROM issues i, repositories r
|
FROM issues i, repositories r, users u
|
||||||
WHERE r.repo_id = i.repo_id
|
WHERE r.repo_id = i.repo_id
|
||||||
|
AND r.user_id = u.id
|
||||||
AND i.issue_id = :issue-id
|
AND i.issue_id = :issue-id
|
||||||
|
|
||||||
-- :name open-bounties :? :*
|
-- :name open-bounties :? :*
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
[commiteth.db.issues :as issues]
|
[commiteth.db.issues :as issues]
|
||||||
[commiteth.bounties :as bounties]
|
[commiteth.bounties :as bounties]
|
||||||
[commiteth.eth.core :as eth]
|
[commiteth.eth.core :as eth]
|
||||||
|
[commiteth.eth.tracker :as tracker]
|
||||||
[commiteth.github.core :as github]
|
[commiteth.github.core :as github]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[commiteth.config :refer [env]]
|
[commiteth.config :refer [env]]
|
||||||
|
@ -164,12 +165,16 @@
|
||||||
|
|
||||||
(defn execute-revocation [issue-id contract-address payout-address]
|
(defn execute-revocation [issue-id contract-address payout-address]
|
||||||
(log/info (str "executing revocation for " issue-id "at" contract-address))
|
(log/info (str "executing revocation for " issue-id "at" contract-address))
|
||||||
(let [execute-hash (multisig/send-all {:contract contract-address
|
;; todo set winnner login as the owner of the repo to which the issue belongs
|
||||||
:payout-address payout-address
|
;; (db-bounties/update-winner-login issue-id winner-login)
|
||||||
:internal-tx-id (str "payout-github-issue-" issue-id)})
|
(try
|
||||||
execute-write (db-bounties/update-execute-hash issue-id execute-hash)]
|
(let [tx-info (multisig/send-all {:contract contract-address
|
||||||
{:execute-hash execute-hash
|
:payout-address payout-address
|
||||||
:execute-write execute-write}))
|
:internal-tx-id (str "payout-github-issue-" issue-id)})]
|
||||||
|
(tracker/track-tx! tx-info)
|
||||||
|
{:execute-hash (:tx-hash tx-info)})
|
||||||
|
(catch Throwable ex
|
||||||
|
(log/errorf ex "error revoking funds for %s" issue-id))))
|
||||||
|
|
||||||
|
|
||||||
(defapi service-routes
|
(defapi service-routes
|
||||||
|
@ -258,18 +263,13 @@
|
||||||
:current-user user
|
:current-user user
|
||||||
(log/debug "/user/bounties")
|
(log/debug "/user/bounties")
|
||||||
(ok (user-bounties user)))
|
(ok (user-bounties user)))
|
||||||
(POST "/revoke" {{issue-id :issue-id
|
(POST "/revoke" {{issue-id :issue-id} :params}
|
||||||
contract-address :contract-address
|
;; :auth-rules authenticated?
|
||||||
owner-address :owner-address} :params}
|
|
||||||
:auth-rules authenticated?
|
|
||||||
:current-user user
|
:current-user user
|
||||||
(do (log/infof "calling revoke-initiate for %s with %s %s" issue-id contract-address owner-address)
|
(let [{contract-address :contract_address owner-address :owner_address} (issues/get-issue-by-id issue-id)]
|
||||||
(if-let [{:keys [execute-hash execute-write]} (execute-revocation issue-id contract-address owner-address)]
|
(do (log/infof "calling revoke-initiate for %s with %s %s" issue-id contract-address owner-address)
|
||||||
(if (scheduler/poll-transaction-logs execute-hash contract-address)
|
(if-let [{:keys [execute-hash]} (execute-revocation issue-id contract-address owner-address)]
|
||||||
;; TODO this is no longer explicity setting confirm_hash in db so may have to
|
(ok {:issue-id issue-id
|
||||||
;; perform an extra step. consult the tracker merge
|
:execute-hash execute-hash
|
||||||
(if-let [{confirm-hash :result} (scheduler/update-confirm-hash issue-id execute-hash)]
|
:contract-address contract-address})
|
||||||
(ok {:confirm-hash confirm-hash})
|
(bad-request (str "Unable to withdraw funds from " contract-address)))))))))
|
||||||
(bad-request "The confirm hash could not be updated"))
|
|
||||||
(bad-request "The transaction hash could not be confirmed in a reasonable amount of time"))
|
|
||||||
(bad-request (str "Unable to withdraw everything from " contract-address))))))))
|
|
||||||
|
|
|
@ -147,7 +147,7 @@
|
||||||
winner-login
|
winner-login
|
||||||
false))))
|
false))))
|
||||||
(catch Throwable ex
|
(catch Throwable ex
|
||||||
(log/error ex "issue %s: self-sign-bounty exception" issue-id)))))
|
(log/errorf ex "issue %s: self-sign-bounty exception" issue-id)))))
|
||||||
(log/info "Exit self-sign-bounty"))
|
(log/info "Exit self-sign-bounty"))
|
||||||
|
|
||||||
(defn update-confirm-hash
|
(defn update-confirm-hash
|
||||||
|
|
Loading…
Reference in New Issue