Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nonce related changes #272

Merged
merged 3 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add method getNonce to EthereumKit
  • Loading branch information
omurovch committed Feb 10, 2023
commit a89f49eecdc06d24d5089219ec6b7b6cda2c93d2
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ class RpcBlockchain(
.map { transaction }
}

override fun getNonce(): Single<Long> {
return syncer.single(GetTransactionCountJsonRpc(address, DefaultBlockParameter.Pending))
override fun getNonce(defaultBlockParameter: DefaultBlockParameter): Single<Long> {
return syncer.single(GetTransactionCountJsonRpc(address, defaultBlockParameter))
}

override fun estimateGas(to: Address?, amount: BigInteger?, gasLimit: Long?, gasPrice: GasPrice, data: ByteArray?): Single<Long> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class EthereumKit(
transactionSyncManager.sync()
}

fun getNonce(defaultBlockParameter: DefaultBlockParameter): Single<Long> {
return blockchain.getNonce(defaultBlockParameter)
}
fun getFullTransactionsFlowable(tags: List<List<String>>): Flowable<List<FullTransaction>> {
return transactionManager.getFullTransactionsFlowable(tags)
}
Expand Down Expand Up @@ -194,7 +197,7 @@ class EthereumKit(
gasLimit: Long,
nonce: Long? = null
): Single<RawTransaction> {
val nonceSingle = nonce?.let { Single.just(it) } ?: blockchain.getNonce()
val nonceSingle = nonce?.let { Single.just(it) } ?: blockchain.getNonce(DefaultBlockParameter.Pending)

return nonceSingle.flatMap { nonce ->
Single.just(RawTransaction(gasPrice, gasLimit, address, value, nonce, transactionInput))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ interface IBlockchain {
val accountState: AccountState?

fun send(rawTransaction: RawTransaction, signature: Signature): Single<Transaction>
fun getNonce(): Single<Long>
fun getNonce(defaultBlockParameter: DefaultBlockParameter): Single<Long>
fun estimateGas(to: Address?, amount: BigInteger?, gasLimit: Long?, gasPrice: GasPrice, data: ByteArray?): Single<Long>
fun getTransactionReceipt(transactionHash: ByteArray): Single<RpcTransactionReceipt>
fun getTransaction(transactionHash: ByteArray): Single<RpcTransaction>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SpvBlockchain(
}
}

override fun getNonce(): Single<Long> {
override fun getNonce(defaultBlockParameter: DefaultBlockParameter): Single<Long> {
TODO("not implemented")
}

Expand Down