From 9b1e21db1fa218196ee19c0ebaf997dfb46c6c5d Mon Sep 17 00:00:00 2001 From: chyngyz Date: Sun, 31 Mar 2024 13:51:56 +0600 Subject: [PATCH] Add a new RPC source for the Fantom chain --- .../core/managers/EvmSyncSourceManager.kt | 86 +++++++++++-------- 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/EvmSyncSourceManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/EvmSyncSourceManager.kt index 53dc932ac63..4ff26998bb7 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/EvmSyncSourceManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/EvmSyncSourceManager.kt @@ -46,128 +46,142 @@ class EvmSyncSourceManager( get() = syncSourceSubject fun defaultSyncSources(blockchainType: BlockchainType): List { - return when (val type = blockchainType) { + return when (blockchainType) { BlockchainType.Ethereum -> listOf( evmSyncSource( - type, + blockchainType, "BlocksDecoded", RpcSource.Http(listOf(URI(appConfigProvider.blocksDecodedEthereumRpc)), null), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ), evmSyncSource( - type, + blockchainType, "LlamaNodes", RpcSource.Http(listOf(URI("https://eth.llamarpc.com")), null), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ) ) + BlockchainType.BinanceSmartChain -> listOf( evmSyncSource( - type, + blockchainType, "Binance", RpcSource.binanceSmartChainHttp(), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ), evmSyncSource( - type, + blockchainType, "BSC RPC", RpcSource.bscRpcHttp(), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ), evmSyncSource( - type, + blockchainType, "Omnia", RpcSource.Http(listOf(URI("https://endpoints.omniatech.io/v1/bsc/mainnet/public")), null), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ) ) + BlockchainType.Polygon -> listOf( evmSyncSource( - type, + blockchainType, "Polygon RPC", RpcSource.polygonRpcHttp(), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ), evmSyncSource( - type, + blockchainType, "LlamaNodes", RpcSource.Http(listOf(URI("https://polygon.llamarpc.com")), null), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ) ) + BlockchainType.Avalanche -> listOf( evmSyncSource( - type, + blockchainType, "Avax Network", RpcSource.avaxNetworkHttp(), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ), evmSyncSource( - type, + blockchainType, "PublicNode", RpcSource.Http(listOf(URI("https://avalanche-evm.publicnode.com")), null), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ) ) + BlockchainType.Optimism -> listOf( evmSyncSource( - type, + blockchainType, "Optimism", RpcSource.optimismRpcHttp(), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ), evmSyncSource( - type, + blockchainType, "Omnia", RpcSource.Http( listOf(URI("https://endpoints.omniatech.io/v1/op/mainnet/public")), null ), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ) ) + BlockchainType.ArbitrumOne -> listOf( evmSyncSource( - type, + blockchainType, "Arbitrum", RpcSource.arbitrumOneRpcHttp(), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ), evmSyncSource( - type, + blockchainType, "Omnia", RpcSource.Http(listOf(URI("https://endpoints.omniatech.io/v1/arbitrum/one/public")), null), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ) ) + BlockchainType.Gnosis -> listOf( evmSyncSource( - type, + blockchainType, "Gnosis Chain", RpcSource.gnosisRpcHttp(), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ), evmSyncSource( - type, + blockchainType, "Ankr", RpcSource.Http(listOf(URI("https://rpc.ankr.com/gnosis")), null), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ) ) + BlockchainType.Fantom -> listOf( evmSyncSource( - type, + blockchainType, "Fantom Chain", RpcSource.fantomRpcHttp(), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) + ), + evmSyncSource( + blockchainType, + "Fantom Chain (Mirror)", + RpcSource.Http(listOf(URI("https://rpcapi.fantom.network/")), null), + defaultTransactionSource(blockchainType) ), evmSyncSource( - type, + blockchainType, "Ankr", RpcSource.Http(listOf(URI("https://rpc.ankr.com/fantom")), null), - defaultTransactionSource(type) + defaultTransactionSource(blockchainType) ) ) + else -> listOf() } } @@ -180,8 +194,10 @@ class EvmSyncSourceManager( val rpcSource = when (uri.scheme) { "http", "https" -> RpcSource.Http(listOf(URI(record.url)), record.auth) + "ws", "wss" -> RpcSource.WebSocket(URI(record.url), record.auth) + else -> return@mapNotNull null } EvmSyncSource(