Last active
August 15, 2017 10:30
-
-
Save jrtapsell/a6e2c3e13616c8ccd7aaefd1a8e7fa17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ParityManager(val web3: Parity): TransactionManager(web3) { | |
val from: String | |
init { | |
val accounts = DataProvider.web3.ethAccounts().send().accounts!! | |
if (accounts.size == 0) { | |
throw AssertionError("No accounts :(") | |
} | |
if (accounts.size > 1) { | |
throw AssertionError("Too many accounts, please only use 1") | |
} | |
from = accounts[0] | |
} | |
override fun sendTransaction( | |
gasPrice: BigInteger?, | |
gasLimit: BigInteger?, | |
to: String?, data: String?, | |
value: BigInteger?): EthSendTransaction { | |
val ethGetTransactionCount = web3.ethGetTransactionCount( | |
from, DefaultBlockParameterName.PENDING).send().transactionCount!! | |
val transaction = Transaction(from, ethGetTransactionCount, gasPrice, gasLimit, to, value, data) | |
return web3.personalSignAndSendTransaction(transaction, "password").send() | |
} | |
override fun getFromAddress() = from | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment