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
|
||||
INNER JOIN users o
|
||||
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 :? :*
|
||||
-- :doc lists all not yet fixed issues in a given owner's repository
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
(defn send-transaction
|
||||
[from to value & [params]]
|
||||
;; todo: estimate gas instead of hardcoding
|
||||
(let [gas 1248650]
|
||||
(let [gas 2100000]
|
||||
(eth-rpc "personal_signAndSendTransaction" [(merge params {:from from
|
||||
:to to
|
||||
:value value
|
||||
|
@ -68,17 +68,21 @@
|
|||
[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
|
||||
[param]
|
||||
(if (number? param)
|
||||
(format "%064x" param)
|
||||
(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
|
||||
[method-id & params]
|
||||
(let [params (join (map format-param params))]
|
||||
|
|
|
@ -2,25 +2,11 @@
|
|||
(:require [commiteth.eth.core :as eth]
|
||||
[clojure.tools.logging :as log]))
|
||||
|
||||
(defn is-owner?
|
||||
[contract address]
|
||||
(eth/call contract "0x0ed5bc12" address))
|
||||
|
||||
(defn get-owner
|
||||
[contract 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
|
||||
[contract to value]
|
||||
(log/debug "multisig.execute(contract, to, value)" contract 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-number :number
|
||||
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))
|
||||
(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
|
||||
[{{{user :login} :owner repo :name} :repository
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
(defn update-issue-contract-address
|
||||
"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
|
||||
transaction-hash :transaction_hash} (issues/list-pending-deployments)]
|
||||
|
@ -24,14 +24,10 @@
|
|||
(let [issue (issues/update-contract-address issue-id contract-address)
|
||||
{user :login
|
||||
repo :repo
|
||||
repo-id :repo_id
|
||||
issue-number :issue_number} issue
|
||||
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)]
|
||||
(issues/update-comment-id issue-id comment-id)
|
||||
(wallet/add-owner contract-address (eth/eth-account))
|
||||
(wallet/add-owner contract-address repo-owner-address))))))
|
||||
(issues/update-comment-id issue-id comment-id))))))
|
||||
|
||||
(defn self-sign-bounty
|
||||
"Walks through all issues eligible for bounty payout and signs corresponding transaction"
|
||||
|
|
|
@ -27,20 +27,23 @@
|
|||
[:div
|
||||
(map repository-row @repos)])))
|
||||
|
||||
(defn- send-transaction-callback
|
||||
[e]
|
||||
(println e))
|
||||
|
||||
(defn send-transaction
|
||||
[issue]
|
||||
(fn []
|
||||
(let [{owner-address :owner_address
|
||||
contract-address :contract_address
|
||||
confirm-hash :confirm_hash} issue
|
||||
eth (.-eth js/web3)
|
||||
send-transaction-fn (aget js/web3 "eth" "sendTransaction")
|
||||
payload {:from owner-address
|
||||
:to contract-address
|
||||
:value 1
|
||||
:data (str "0x797af627" confirm-hash)}]
|
||||
(println "sending transaction" payload)
|
||||
(.sendTransaction eth (clj->js payload)
|
||||
#(println "send-transaction callback" %)))))
|
||||
(apply send-transaction-fn [(clj->js payload) send-transaction-callback]))))
|
||||
|
||||
(defn issue-row [{title :issue_title
|
||||
issue-id :issue_id
|
||||
|
|
Loading…
Reference in New Issue