From fc75701c6cf401434f600fee7e64100729e10734 Mon Sep 17 00:00:00 2001 From: Rafael Date: Wed, 13 Mar 2024 16:02:51 +0600 Subject: [PATCH] Remove Infura options from RpcSource --- .../ethereumkit/sample/Configuration.kt | 3 +-- .../addresswatch/AddressWatchViewModel.kt | 13 ++-------- .../sample/modules/main/MainViewModel.kt | 14 ++--------- .../ethereumkit/models/RpcSource.kt | 24 ------------------- 4 files changed, 5 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/io/horizontalsystems/ethereumkit/sample/Configuration.kt b/app/src/main/java/io/horizontalsystems/ethereumkit/sample/Configuration.kt index a6c4913f..897dbf63 100644 --- a/app/src/main/java/io/horizontalsystems/ethereumkit/sample/Configuration.kt +++ b/app/src/main/java/io/horizontalsystems/ethereumkit/sample/Configuration.kt @@ -11,8 +11,7 @@ object Configuration { val watchAddress: String? = null const val defaultsWords = "apart approve black comfort steel spin real renew tone primary key cherry" - const val infuraProjectId = "2a1306f1d12f4c109a4d4fb9be46b02e" - const val infuraSecret = "fc479a9290b64a84a15fa6544a130218" + const val ethereumRpc = "https://api-dev.blocksdecoded.com/v1/ethereum-rpc/mainnet" const val etherscanKey = "GKNHXT22ED7PRVCKZATFZQD1YI7FK9AAYE" const val arbiscanApiKey = "Z43JN5434XVNA5D73UGPWKF26G5D9MGDPZ" const val bscScanKey = "5ZGSHWYHZVA8XZHB8PF6UUTRNNB4KT43ZZ" diff --git a/app/src/main/java/io/horizontalsystems/ethereumkit/sample/modules/addresswatch/AddressWatchViewModel.kt b/app/src/main/java/io/horizontalsystems/ethereumkit/sample/modules/addresswatch/AddressWatchViewModel.kt index 8243fe7e..a2082274 100644 --- a/app/src/main/java/io/horizontalsystems/ethereumkit/sample/modules/addresswatch/AddressWatchViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/ethereumkit/sample/modules/addresswatch/AddressWatchViewModel.kt @@ -17,6 +17,7 @@ import io.horizontalsystems.ethereumkit.sample.modules.main.ShowTxType import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import io.reactivex.schedulers.Schedulers +import java.net.URI class AddressWatchViewModel : ViewModel() { @@ -133,17 +134,7 @@ class AddressWatchViewModel : ViewModel() { } Chain.Ethereum -> { transactionSource = TransactionSource.ethereumEtherscan(Configuration.etherscanKey) - rpcSource = if (Configuration.webSocket) - RpcSource.ethereumInfuraWebSocket(Configuration.infuraProjectId, Configuration.infuraSecret) - else - RpcSource.ethereumInfuraHttp(Configuration.infuraProjectId, Configuration.infuraSecret) - } - Chain.EthereumGoerli -> { - transactionSource = TransactionSource.goerliEtherscan(Configuration.etherscanKey) - rpcSource = if (Configuration.webSocket) - RpcSource.goerliInfuraWebSocket(Configuration.infuraProjectId, Configuration.infuraSecret) - else - RpcSource.goerliInfuraHttp(Configuration.infuraProjectId, Configuration.infuraSecret) + rpcSource = RpcSource.Http(listOf(URI(Configuration.ethereumRpc)), null) } else -> { rpcSource = null diff --git a/app/src/main/java/io/horizontalsystems/ethereumkit/sample/modules/main/MainViewModel.kt b/app/src/main/java/io/horizontalsystems/ethereumkit/sample/modules/main/MainViewModel.kt index cc8771ea..891c145f 100644 --- a/app/src/main/java/io/horizontalsystems/ethereumkit/sample/modules/main/MainViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/ethereumkit/sample/modules/main/MainViewModel.kt @@ -32,6 +32,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import io.reactivex.schedulers.Schedulers import java.math.BigDecimal +import java.net.URI import java.util.logging.Logger class MainViewModel : ViewModel() { @@ -198,10 +199,7 @@ class MainViewModel : ViewModel() { Chain.Ethereum -> { transactionSource = TransactionSource.ethereumEtherscan(Configuration.etherscanKey) - rpcSource = if (Configuration.webSocket) - RpcSource.ethereumInfuraWebSocket(Configuration.infuraProjectId, Configuration.infuraSecret) - else - RpcSource.ethereumInfuraHttp(Configuration.infuraProjectId, Configuration.infuraSecret) + rpcSource = RpcSource.Http(listOf(URI(Configuration.ethereumRpc)), null) } Chain.ArbitrumOne -> { @@ -209,14 +207,6 @@ class MainViewModel : ViewModel() { rpcSource = RpcSource.arbitrumOneRpcHttp() } - Chain.EthereumGoerli -> { - transactionSource = TransactionSource.goerliEtherscan(Configuration.etherscanKey) - rpcSource = if (Configuration.webSocket) - RpcSource.goerliInfuraWebSocket(Configuration.infuraProjectId, Configuration.infuraSecret) - else - RpcSource.goerliInfuraHttp(Configuration.infuraProjectId, Configuration.infuraSecret) - } - else -> { throw Exception("Could not get rpcSource & transactionSource!") } diff --git a/ethereumkit/src/main/java/io/horizontalsystems/ethereumkit/models/RpcSource.kt b/ethereumkit/src/main/java/io/horizontalsystems/ethereumkit/models/RpcSource.kt index aa323670..80485bcc 100644 --- a/ethereumkit/src/main/java/io/horizontalsystems/ethereumkit/models/RpcSource.kt +++ b/ethereumkit/src/main/java/io/horizontalsystems/ethereumkit/models/RpcSource.kt @@ -7,30 +7,6 @@ sealed class RpcSource { data class WebSocket(val uri: URI, val auth: String?) : RpcSource() companion object { - private fun infuraHttp(subdomain: String, projectId: String, projectSecret: String? = null): Http { - return Http(listOf(URI("https://$subdomain.infura.io/v3/$projectId")), projectSecret) - } - - private fun infuraWebSocket(subdomain: String, projectId: String, projectSecret: String? = null): WebSocket { - return WebSocket(URI("https://$subdomain.infura.io/ws/v3/$projectId"), projectSecret) - } - - fun ethereumInfuraHttp(projectId: String, projectSecret: String? = null): Http { - return infuraHttp("mainnet", projectId, projectSecret) - } - - fun goerliInfuraHttp(projectId: String, projectSecret: String? = null): Http { - return infuraHttp("goerli", projectId, projectSecret) - } - - fun ethereumInfuraWebSocket(projectId: String, projectSecret: String? = null): WebSocket { - return infuraWebSocket("mainnet", projectId, projectSecret) - } - - fun goerliInfuraWebSocket(projectId: String, projectSecret: String? = null): WebSocket { - return infuraWebSocket("goerli", projectId, projectSecret) - } - fun bscRpcHttp(): Http { return Http(listOf(URI("https://bscrpc.com")), null) }