Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ class EthereumKit(
}

val transactionBuilder = TransactionBuilder(address, chain.id)
val transactionProvider = transactionProvider(transactionSource, address)
val transactionProvider = transactionProvider(transactionSource, address, chain.id)

val apiDatabase = EthereumDatabaseManager.getEthereumApiDatabase(application, walletId, chain)
val storage = ApiStorage(apiDatabase)
Expand Down Expand Up @@ -516,10 +516,10 @@ class EthereumKit(
EthereumDatabaseManager.clear(context, chain, walletId)
}

private fun transactionProvider(transactionSource: TransactionSource, address: Address): ITransactionProvider {
private fun transactionProvider(transactionSource: TransactionSource, address: Address, chainId: Int): ITransactionProvider {
when (transactionSource.type) {
is TransactionSource.SourceType.Etherscan -> {
val service = EtherscanService(transactionSource.type.apiBaseUrl, transactionSource.type.apiKeys)
val service = EtherscanService(transactionSource.type.apiBaseUrl, transactionSource.type.apiKeys, chainId)
return EtherscanTransactionProvider(service, address)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TransactionSource(val name: String, val type: SourceType) {
private fun etherscan(apiSubdomain: String, txSubdomain: String?, apiKeys: List<String>): TransactionSource {
return TransactionSource(
"etherscan.io",
SourceType.Etherscan("https://$apiSubdomain.etherscan.io", "https://${txSubdomain?.let { "$it." } ?: ""}etherscan.io", apiKeys)
SourceType.Etherscan("https://$apiSubdomain.etherscan.io/v2/", "https://${txSubdomain?.let { "$it." } ?: ""}etherscan.io", apiKeys)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import java.util.logging.Logger

class EtherscanService(
baseUrl: String,
private val apiKeys: List<String>
private val apiKeys: List<String>,
private val chainId: Int,
) {
private val apiKeysSize = apiKeys.size
private var apiKeyIndex = 0
Expand All @@ -43,6 +44,7 @@ class EtherscanService(

val url = originalUrl.newBuilder()
.addQueryParameter("apikey", getNextApiKey())
.addQueryParameter("chainid", chainId.toString())
.build()

val request = originalRequest.newBuilder()
Expand Down Expand Up @@ -161,7 +163,7 @@ class EtherscanService(
}

private interface EtherscanServiceAPI {
@GET("/api")
@GET("api")
fun accountApi(
@Query("module") module: String = "account",
@Query("action") action: String,
Expand Down