Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intermediate Full transaction data provider selector (#398)
- Loading branch information
1 parent
f5f509e
commit 4fa655b
Showing
28 changed files
with
714 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...main/java/io/horizontalsystems/bankwallet/core/managers/TransactionDataProviderManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package io.horizontalsystems.bankwallet.core.managers | ||
|
||
import io.horizontalsystems.bankwallet.core.ILocalStorage | ||
import io.horizontalsystems.bankwallet.core.ITransactionDataProviderManager | ||
import io.horizontalsystems.bankwallet.modules.fulltransactioninfo.FullTransactionInfoModule | ||
import io.horizontalsystems.bankwallet.modules.fulltransactioninfo.providers.* | ||
import io.horizontalsystems.bankwallet.modules.transactions.CoinCode | ||
import io.reactivex.subjects.PublishSubject | ||
|
||
class TransactionDataProviderManager(val localStorage: ILocalStorage) : ITransactionDataProviderManager { | ||
|
||
override val baseProviderUpdatedSignal = PublishSubject.create<Unit>() | ||
|
||
// | ||
// For interactor | ||
// | ||
override fun providers(coinCode: CoinCode): List<FullTransactionInfoModule.Provider> { | ||
return when { | ||
coinCode.contains("BTC") -> bitcoinProviders | ||
coinCode.contains("BCH") -> bitcoinCashProviders | ||
else -> ethereumProviders | ||
} | ||
} | ||
|
||
override fun baseProvider(coinCode: CoinCode): FullTransactionInfoModule.Provider { | ||
if (coinCode.contains("ETH")) { | ||
return ethereum(localStorage.baseEthereumProvider ?: ethereumProviders[0].name) | ||
} | ||
|
||
return bitcoin(localStorage.baseBitcoinProvider ?: bitcoinProviders[0].name) | ||
} | ||
|
||
override fun setBaseProvider(name: String, coinCode: CoinCode) { | ||
if (coinCode.contains("ETH")) { | ||
localStorage.baseEthereumProvider = name | ||
} else { | ||
localStorage.baseBitcoinProvider = name | ||
} | ||
|
||
baseProviderUpdatedSignal.onNext(Unit) | ||
} | ||
|
||
// | ||
// Providers | ||
// | ||
override fun bitcoin(name: String): FullTransactionInfoModule.BitcoinForksProvider { | ||
return bitcoinProviders.find { it.name == name } | ||
?: HorsysBitcoinProvider(testMode = false) | ||
} | ||
|
||
override fun bitcoinCash(name: String): FullTransactionInfoModule.BitcoinForksProvider { | ||
return bitcoinCashProviders.find { it.name == name } | ||
?: HorsysBitcoinCashProvider(testMode = false) | ||
} | ||
|
||
override fun ethereum(name: String): FullTransactionInfoModule.EthereumForksProvider { | ||
return ethereumProviders.find { it.name == name } | ||
?: HorsysEthereumProvider(testMode = false) | ||
} | ||
|
||
companion object { | ||
val bitcoinProviders = arrayListOf( | ||
HorsysBitcoinProvider(testMode = false), | ||
BlockChairBitcoinProvider(), | ||
BlockExplorerBitcoinProvider(), | ||
BtcComBitcoinProvider() | ||
) | ||
|
||
val bitcoinCashProviders = arrayListOf( | ||
HorsysBitcoinCashProvider(testMode = false), | ||
BlockChairBitcoinCashProvider(), | ||
BlockExplorerBitcoinCashProvider(), | ||
BtcComBitcoinCashProvider() | ||
) | ||
|
||
val ethereumProviders = arrayListOf( | ||
HorsysEthereumProvider(testMode = false), | ||
EtherscanEthereumProvider(), | ||
BlockChairEthereumProvider() | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.