Add function wrapping multisig executeTransaction

* support for calling executeTransaction for a give tx-id in a
  deployed bounty contract
* minor cleanup
This commit is contained in:
Teemu Patja 2017-08-28 19:58:53 +03:00
parent 245b9e1e2a
commit 45526810e7
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
1 changed files with 17 additions and 1 deletions

View File

@ -200,14 +200,30 @@
(mapv #(.toString %) (.getValue owner-addresses))
[])))
(defn uint256 [x]
(org.web3j.abi.datatypes.generated.Uint256. x))
(defn is-confirmed?
"Returns true if given internal transaction is confirmed in bounty
contract."
[bounty-addr tx-id]
(let [bounty-contract (load-bounty-contract bounty-addr)
tx-id-web3j (org.web3j.abi.datatypes.generated.Uint256. tx-id)
tx-id-web3j (uint256 tx-id)
ret (-> bounty-contract
(.isConfirmed tx-id-web3j)
.get)]
(assert ret)
(.getValue ret)))
(defn execute-tx
"Execute internal transaction inside contract, identified by
tx-id. Returns transaction ID. Synchronous, blocks until transaction
is mined."
[bounty-addr tx-id]
(let [bounty-contract (load-bounty-contract bounty-addr)
tx-id-web3j (uint256 tx-id)
ret (-> bounty-contract
(.executeTransaction tx-id-web3j)
.get)]
(assert ret)
(.getTransactionHash ret)))