Skip to content

Commit 2d9dadd

Browse files
committed
Add defaultBlockParameter to allowance() method
1 parent 28bfe37 commit 2d9dadd

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

erc20kit/src/main/java/io/horizontalsystems/erc20kit/core/AllowanceManager.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import io.horizontalsystems.erc20kit.contract.ApproveMethod
55
import io.horizontalsystems.erc20kit.models.Transaction
66
import io.horizontalsystems.ethereumkit.core.EthereumKit
77
import io.horizontalsystems.ethereumkit.models.Address
8+
import io.horizontalsystems.ethereumkit.models.DefaultBlockParameter
89
import io.horizontalsystems.ethereumkit.models.TransactionData
910
import io.reactivex.Single
1011
import java.math.BigInteger
@@ -16,10 +17,12 @@ class AllowanceManager(
1617
private val storage: ITransactionStorage
1718
) {
1819

19-
fun allowance(spenderAddress: Address): Single<BigInteger> {
20-
return ethereumKit.call(contractAddress, AllowanceMethod(address, spenderAddress).encodedABI()).map { result ->
21-
BigInteger(result.sliceArray(0..31))
22-
}
20+
fun allowance(spenderAddress: Address, defaultBlockParameter: DefaultBlockParameter): Single<BigInteger> {
21+
return ethereumKit
22+
.call(contractAddress, AllowanceMethod(address, spenderAddress).encodedABI(), defaultBlockParameter)
23+
.map { result ->
24+
BigInteger(result.sliceArray(0..31))
25+
}
2326
}
2427

2528
fun approveTransactionData(spenderAddress: Address, amount: BigInteger): TransactionData {

erc20kit/src/main/java/io/horizontalsystems/erc20kit/core/Erc20Kit.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import io.horizontalsystems.ethereumkit.models.TransactionData
77
import io.horizontalsystems.ethereumkit.core.EthereumKit
88
import io.horizontalsystems.ethereumkit.models.Address
99
import io.horizontalsystems.ethereumkit.models.BloomFilter
10+
import io.horizontalsystems.ethereumkit.models.DefaultBlockParameter
1011
import io.horizontalsystems.ethereumkit.network.EtherscanService
1112
import io.reactivex.BackpressureStrategy
1213
import io.reactivex.Flowable
@@ -90,8 +91,8 @@ class Erc20Kit(
9091
return ethereumKit.estimateGas(contractAddress, null, gasPrice, transactionInput)
9192
}
9293

93-
fun allowance(spenderAddress: Address): Single<BigInteger> {
94-
return allowanceManager.allowance(spenderAddress)
94+
fun allowance(spenderAddress: Address, defaultBlockParameter: DefaultBlockParameter = DefaultBlockParameter.Latest): Single<BigInteger> {
95+
return allowanceManager.allowance(spenderAddress, defaultBlockParameter)
9596
}
9697

9798
fun approve(spenderAddress: Address, amount: BigInteger, gasPrice: Long, gasLimit: Long): Single<Transaction> {

0 commit comments

Comments
 (0)