Update multisig wallet contract code
This commit is contained in:
parent
49dcdc0515
commit
833953edc6
File diff suppressed because one or more lines are too long
|
@ -227,7 +227,8 @@ FROM issues i
|
||||||
ON r.repo_id = i.repo_id
|
ON r.repo_id = i.repo_id
|
||||||
INNER JOIN users o
|
INNER JOIN users o
|
||||||
ON r.user_id = o.id
|
ON r.user_id = o.id
|
||||||
WHERE r.user_id = :owner_id;
|
WHERE r.user_id = :owner_id
|
||||||
|
AND i.confirm_hash IS NOT NULL;
|
||||||
|
|
||||||
-- :name owner-issues-list :? :*
|
-- :name owner-issues-list :? :*
|
||||||
-- :doc lists all not yet fixed issues in a given owner's repository
|
-- :doc lists all not yet fixed issues in a given owner's repository
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
(defn send-transaction
|
(defn send-transaction
|
||||||
[from to value & [params]]
|
[from to value & [params]]
|
||||||
;; todo: estimate gas instead of hardcoding
|
;; todo: estimate gas instead of hardcoding
|
||||||
(let [gas 1248650]
|
(let [gas 2100000]
|
||||||
(eth-rpc "personal_signAndSendTransaction" [(merge params {:from from
|
(eth-rpc "personal_signAndSendTransaction" [(merge params {:from from
|
||||||
:to to
|
:to to
|
||||||
:value value
|
:value value
|
||||||
|
@ -68,17 +68,21 @@
|
||||||
[hash]
|
[hash]
|
||||||
(eth-rpc "eth_getTransactionReceipt" [hash]))
|
(eth-rpc "eth_getTransactionReceipt" [hash]))
|
||||||
|
|
||||||
(defn deploy-contract
|
|
||||||
[]
|
|
||||||
(let [contract-code (-> "contracts/wallet.data" io/resource slurp)]
|
|
||||||
(send-transaction (eth-account) nil 1 {:data contract-code})))
|
|
||||||
|
|
||||||
(defn- format-param
|
(defn- format-param
|
||||||
[param]
|
[param]
|
||||||
(if (number? param)
|
(if (number? param)
|
||||||
(format "%064x" param)
|
(format "%064x" param)
|
||||||
(clojure.string/replace (format "%64s" (subs param 2)) " " "0")))
|
(clojure.string/replace (format "%64s" (subs param 2)) " " "0")))
|
||||||
|
|
||||||
|
(defn deploy-contract
|
||||||
|
[owner]
|
||||||
|
(let [contract-code (-> "contracts/wallet.data" io/resource slurp)
|
||||||
|
owner1 (format-param (eth-account))
|
||||||
|
owner2 (format-param owner)
|
||||||
|
data (str contract-code owner1 owner2)]
|
||||||
|
(println data)
|
||||||
|
(send-transaction (eth-account) nil 1 {:data data})))
|
||||||
|
|
||||||
(defn- format-call-params
|
(defn- format-call-params
|
||||||
[method-id & params]
|
[method-id & params]
|
||||||
(let [params (join (map format-param params))]
|
(let [params (join (map format-param params))]
|
||||||
|
|
|
@ -2,25 +2,11 @@
|
||||||
(:require [commiteth.eth.core :as eth]
|
(:require [commiteth.eth.core :as eth]
|
||||||
[clojure.tools.logging :as log]))
|
[clojure.tools.logging :as log]))
|
||||||
|
|
||||||
(defn is-owner?
|
|
||||||
[contract address]
|
|
||||||
(eth/call contract "0x0ed5bc12" address))
|
|
||||||
|
|
||||||
(defn get-owner
|
(defn get-owner
|
||||||
[contract index]
|
[contract index]
|
||||||
(eth/call contract "0xc41a360a" index))
|
(eth/call contract "0xc41a360a" index))
|
||||||
|
|
||||||
(defn add-owner
|
|
||||||
[contract owner]
|
|
||||||
(log/debug "multiowned.addOwner(contract, owner)" contract owner)
|
|
||||||
(eth/execute (eth/eth-account) contract "0x7065cb48" owner))
|
|
||||||
|
|
||||||
(defn execute
|
(defn execute
|
||||||
[contract to value]
|
[contract to value]
|
||||||
(log/debug "multisig.execute(contract, to, value)" contract to value)
|
(log/debug "multisig.execute(contract, to, value)" contract to value)
|
||||||
(eth/execute (eth/eth-account) contract "0xb61d27f6" to value))
|
(eth/execute (eth/eth-account) contract "0xb61d27f6" to value))
|
||||||
|
|
||||||
(defn confirm
|
|
||||||
[contract hash]
|
|
||||||
(log/debug "multisig.confirm(contract, hash)")
|
|
||||||
(eth/execute (eth/eth-account) contract "0x797af627" hash))
|
|
||||||
|
|
|
@ -35,10 +35,11 @@
|
||||||
{issue-id :id
|
{issue-id :id
|
||||||
issue-number :number
|
issue-number :number
|
||||||
issue-title :title} (:issue issue)
|
issue-title :title} (:issue issue)
|
||||||
created-issue (issues/create repo-id issue-id issue-number issue-title)]
|
created-issue (issues/create repo-id issue-id issue-number issue-title)
|
||||||
|
repo-owner (:address (users/get-repo-owner repo-id))]
|
||||||
(log/debug (format "Issue %s/%s/%s labeled as bounty" user repo issue-number))
|
(log/debug (format "Issue %s/%s/%s labeled as bounty" user repo issue-number))
|
||||||
(when (= 1 created-issue)
|
(when (= 1 created-issue)
|
||||||
(issues/update-transaction-hash issue-id (eth/deploy-contract)))))
|
(issues/update-transaction-hash issue-id (eth/deploy-contract repo-owner)))))
|
||||||
|
|
||||||
(defn handle-issue-closed
|
(defn handle-issue-closed
|
||||||
[{{{user :login} :owner repo :name} :repository
|
[{{{user :login} :owner repo :name} :repository
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
(defn update-issue-contract-address
|
(defn update-issue-contract-address
|
||||||
"For each pending deployment:
|
"For each pending deployment:
|
||||||
gets transasction receipt, updates db state, posts github comment and adds owners to the wallet"
|
gets transasction receipt, updates db state and posts github comment"
|
||||||
[]
|
[]
|
||||||
(doseq [{issue-id :issue_id
|
(doseq [{issue-id :issue_id
|
||||||
transaction-hash :transaction_hash} (issues/list-pending-deployments)]
|
transaction-hash :transaction_hash} (issues/list-pending-deployments)]
|
||||||
|
@ -21,17 +21,13 @@
|
||||||
(when-let [receipt (eth/get-transaction-receipt transaction-hash)]
|
(when-let [receipt (eth/get-transaction-receipt transaction-hash)]
|
||||||
(log/info "transaction receipt for issue #" issue-id ": " receipt)
|
(log/info "transaction receipt for issue #" issue-id ": " receipt)
|
||||||
(when-let [contract-address (:contractAddress receipt)]
|
(when-let [contract-address (:contractAddress receipt)]
|
||||||
(let [issue (issues/update-contract-address issue-id contract-address)
|
(let [issue (issues/update-contract-address issue-id contract-address)
|
||||||
{user :login
|
{user :login
|
||||||
repo :repo
|
repo :repo
|
||||||
repo-id :repo_id
|
|
||||||
issue-number :issue_number} issue
|
issue-number :issue_number} issue
|
||||||
balance (eth/get-balance-eth contract-address 4)
|
balance (eth/get-balance-eth contract-address 4)
|
||||||
repo-owner-address (:address (users/get-repo-owner repo-id))
|
|
||||||
{comment-id :id} (github/post-comment user repo issue-number balance)]
|
{comment-id :id} (github/post-comment user repo issue-number balance)]
|
||||||
(issues/update-comment-id issue-id comment-id)
|
(issues/update-comment-id issue-id comment-id))))))
|
||||||
(wallet/add-owner contract-address (eth/eth-account))
|
|
||||||
(wallet/add-owner contract-address repo-owner-address))))))
|
|
||||||
|
|
||||||
(defn self-sign-bounty
|
(defn self-sign-bounty
|
||||||
"Walks through all issues eligible for bounty payout and signs corresponding transaction"
|
"Walks through all issues eligible for bounty payout and signs corresponding transaction"
|
||||||
|
|
|
@ -27,20 +27,23 @@
|
||||||
[:div
|
[:div
|
||||||
(map repository-row @repos)])))
|
(map repository-row @repos)])))
|
||||||
|
|
||||||
|
(defn- send-transaction-callback
|
||||||
|
[e]
|
||||||
|
(println e))
|
||||||
|
|
||||||
(defn send-transaction
|
(defn send-transaction
|
||||||
[issue]
|
[issue]
|
||||||
(fn []
|
(fn []
|
||||||
(let [{owner-address :owner_address
|
(let [{owner-address :owner_address
|
||||||
contract-address :contract_address
|
contract-address :contract_address
|
||||||
confirm-hash :confirm_hash} issue
|
confirm-hash :confirm_hash} issue
|
||||||
eth (.-eth js/web3)
|
send-transaction-fn (aget js/web3 "eth" "sendTransaction")
|
||||||
payload {:from owner-address
|
payload {:from owner-address
|
||||||
:to contract-address
|
:to contract-address
|
||||||
:value 1
|
:value 1
|
||||||
:data (str "0x797af627" confirm-hash)}]
|
:data (str "0x797af627" confirm-hash)}]
|
||||||
(println "sending transaction" payload)
|
(println "sending transaction" payload)
|
||||||
(.sendTransaction eth (clj->js payload)
|
(apply send-transaction-fn [(clj->js payload) send-transaction-callback]))))
|
||||||
#(println "send-transaction callback" %)))))
|
|
||||||
|
|
||||||
(defn issue-row [{title :issue_title
|
(defn issue-row [{title :issue_title
|
||||||
issue-id :issue_id
|
issue-id :issue_id
|
||||||
|
|
Loading…
Reference in New Issue