-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from tangem/feature/AND-4852_external_link_pr…
…ovider AND-4852 Added ExternalLinkProvider's
- Loading branch information
Showing
43 changed files
with
829 additions
and
129 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
11 changes: 11 additions & 0 deletions
11
blockchain/src/main/java/com/tangem/blockchain/externallinkprovider/ExternalLinkProvider.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,11 @@ | ||
package com.tangem.blockchain.externallinkprovider | ||
|
||
interface ExternalLinkProvider { | ||
|
||
val explorerBaseUrl: String | ||
val testNetTopUpUrl: String? get() = null | ||
|
||
fun explorerUrl(walletAddress: String, contractAddress: String?): String | ||
|
||
fun explorerTransactionUrl(transactionHash: String): String | ||
} |
56 changes: 56 additions & 0 deletions
56
...n/src/main/java/com/tangem/blockchain/externallinkprovider/ExternalLinkProviderFactory.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,56 @@ | ||
package com.tangem.blockchain.externallinkprovider | ||
|
||
import com.tangem.blockchain.common.Blockchain | ||
import com.tangem.blockchain.externallinkprovider.providers.* | ||
|
||
internal object ExternalLinkProviderFactory { | ||
|
||
fun makeProvider(blockchain: Blockchain): ExternalLinkProvider { | ||
val isTestnet = blockchain.isTestnet() | ||
return when (blockchain) { | ||
Blockchain.Unknown -> error("There is no ExternalLinkProvider for Blockchain.Unknown") | ||
Blockchain.Arbitrum, Blockchain.ArbitrumTestnet -> ArbitrumExternalLinkProvider(isTestnet) | ||
Blockchain.Avalanche, Blockchain.AvalancheTestnet -> AvalancheExternalLinkProvider(isTestnet) | ||
Blockchain.Binance, Blockchain.BinanceTestnet -> BinanceExternalLinkProvider(isTestnet) | ||
Blockchain.BSC, Blockchain.BSCTestnet -> BSCExternalLinkProvider(isTestnet) | ||
Blockchain.Bitcoin, Blockchain.BitcoinTestnet -> BitcoinExternalLinkProvider(isTestnet) | ||
Blockchain.BitcoinCash, Blockchain.BitcoinCashTestnet -> BitcoinCashExternalLinkProvider(isTestnet) | ||
Blockchain.Cardano -> CardanoExternalLinkProvider() | ||
Blockchain.Cosmos, Blockchain.CosmosTestnet -> CosmosExternalLinkProvider(isTestnet) | ||
Blockchain.Dogecoin -> DogecoinExternalLinkProvider() | ||
Blockchain.Ducatus -> DucatusExternalLinkProvider() | ||
Blockchain.Ethereum, Blockchain.EthereumTestnet -> EthereumExternalLinkProvider(isTestnet) | ||
Blockchain.EthereumClassic, Blockchain.EthereumClassicTestnet -> EthereumClassicExternalLinkProvider(isTestnet) | ||
Blockchain.Fantom, Blockchain.FantomTestnet -> FantomExternalLinkProvider(isTestnet) | ||
Blockchain.Litecoin -> LitecoinExternalLinkProvider() | ||
Blockchain.Near, Blockchain.NearTestnet -> NearExternalLinkProvider(isTestnet) | ||
Blockchain.Polkadot, Blockchain.PolkadotTestnet -> PolkadotExternalLinkProvider(isTestnet) | ||
Blockchain.Kava, Blockchain.KavaTestnet -> KavaExternalLinkProvider(isTestnet) | ||
Blockchain.Kusama -> KusamaExternalLinkProvider() | ||
Blockchain.Polygon, Blockchain.PolygonTestnet -> PolygonExternalLinkProvider(isTestnet) | ||
Blockchain.RSK -> RSKExternalLinkProvider() | ||
Blockchain.Stellar, Blockchain.StellarTestnet -> StellarExternalLinkProvider(isTestnet) | ||
Blockchain.Solana, Blockchain.SolanaTestnet -> SolanaExternalLinkProvider(isTestnet) | ||
Blockchain.Tezos -> TezosExternalLinkProvider() | ||
Blockchain.Tron, Blockchain.TronTestnet -> TronExternalLinkProvider(isTestnet) | ||
Blockchain.XRP -> XRPExternalLinkProvider() | ||
Blockchain.Gnosis -> GnosisExternalLinkProvider() | ||
Blockchain.Dash -> DashExternalLinkProvider() | ||
Blockchain.Optimism, Blockchain.OptimismTestnet -> OptimismExternalLinkProvider(isTestnet) | ||
Blockchain.EthereumFair -> EthereumFairExternalLinkProvider() | ||
Blockchain.EthereumPow, Blockchain.EthereumPowTestnet -> EthereumPowExternalLinkProvider(isTestnet) | ||
Blockchain.Kaspa -> KaspaExternalLinkProvider() | ||
Blockchain.Telos, Blockchain.TelosTestnet -> TelosExternalLinkProvider(isTestnet) | ||
Blockchain.TON, Blockchain.TONTestnet -> TONExternalLinkProvider(isTestnet) | ||
Blockchain.Ravencoin, Blockchain.RavencoinTestnet -> RavencoinExternalLinkProvider(isTestnet) | ||
Blockchain.TerraV1 -> TerraV1ExternalLinkProvider() | ||
Blockchain.TerraV2 -> TerraV2ExternalLinkProvider() | ||
Blockchain.Cronos -> CronosExternalLinkProvider() | ||
Blockchain.AlephZero -> AlephZeroExternalLinkProvider() | ||
Blockchain.AlephZeroTestnet -> throw Exception("unsupported blockchain") | ||
Blockchain.OctaSpace -> OctaSpaceExternalLinkProvider() | ||
Blockchain.OctaSpaceTestnet -> throw Exception("unsupported blockchain") | ||
Blockchain.Chia, Blockchain.ChiaTestnet -> ChiaExternalLinkProvider(isTestnet) | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ava/com/tangem/blockchain/externallinkprovider/providers/AlephZeroExternalLinkProvider.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,16 @@ | ||
package com.tangem.blockchain.externallinkprovider.providers | ||
|
||
import com.tangem.blockchain.externallinkprovider.ExternalLinkProvider | ||
|
||
internal class AlephZeroExternalLinkProvider : ExternalLinkProvider { | ||
|
||
override val explorerBaseUrl: String = "https://alephzero.subscan.io/" | ||
|
||
override fun explorerUrl(walletAddress: String, contractAddress: String?): String { | ||
return explorerBaseUrl + "account/$walletAddress" | ||
} | ||
|
||
override fun explorerTransactionUrl(transactionHash: String): String { | ||
return explorerBaseUrl + "extrinsic/$transactionHash" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...java/com/tangem/blockchain/externallinkprovider/providers/ArbitrumExternalLinkProvider.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,22 @@ | ||
package com.tangem.blockchain.externallinkprovider.providers | ||
|
||
import com.tangem.blockchain.externallinkprovider.ExternalLinkProvider | ||
|
||
internal class ArbitrumExternalLinkProvider(isTestnet: Boolean) : ExternalLinkProvider { | ||
|
||
override val explorerBaseUrl: String = if (isTestnet) "https://testnet.arbiscan.io/" else "https://arbiscan.io/" | ||
|
||
override val testNetTopUpUrl: String? = if (isTestnet) "https://nileex.io/join/getJoinPage" else null | ||
|
||
override fun explorerUrl(walletAddress: String, contractAddress: String?): String { | ||
return if (contractAddress != null) { | ||
explorerBaseUrl + "token/$contractAddress?a=$walletAddress" | ||
} else { | ||
explorerBaseUrl + "address/$walletAddress" | ||
} | ||
} | ||
|
||
override fun explorerTransactionUrl(transactionHash: String): String { | ||
return explorerBaseUrl + "tx/$transactionHash" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ava/com/tangem/blockchain/externallinkprovider/providers/AvalancheExternalLinkProvider.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,22 @@ | ||
package com.tangem.blockchain.externallinkprovider.providers | ||
|
||
import com.tangem.blockchain.externallinkprovider.ExternalLinkProvider | ||
|
||
internal class AvalancheExternalLinkProvider(isTestnet: Boolean) : ExternalLinkProvider { | ||
|
||
override val explorerBaseUrl: String = if (isTestnet) "https://testnet.snowtrace.io/" else "https://snowtrace.io/" | ||
|
||
override val testNetTopUpUrl: String? = if (isTestnet) "https://faucet.avax-test.network/" else null | ||
|
||
override fun explorerUrl(walletAddress: String, contractAddress: String?): String { | ||
return if (contractAddress != null) { | ||
explorerBaseUrl + "token/$contractAddress?a=$walletAddress" | ||
} else { | ||
explorerBaseUrl + "address/$walletAddress" | ||
} | ||
} | ||
|
||
override fun explorerTransactionUrl(transactionHash: String): String { | ||
return explorerBaseUrl + "tx/$transactionHash" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...main/java/com/tangem/blockchain/externallinkprovider/providers/BSCExternalLinkProvider.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,22 @@ | ||
package com.tangem.blockchain.externallinkprovider.providers | ||
|
||
import com.tangem.blockchain.externallinkprovider.ExternalLinkProvider | ||
|
||
internal class BSCExternalLinkProvider(isTestnet: Boolean) : ExternalLinkProvider { | ||
|
||
override val explorerBaseUrl: String = if (isTestnet) "https://testnet.bscscan.com/" else "https://bscscan.com/" | ||
|
||
override val testNetTopUpUrl: String? = if (isTestnet) "https://testnet.binance.org/faucet-smart" else null | ||
|
||
override fun explorerUrl(walletAddress: String, contractAddress: String?): String { | ||
return if (contractAddress != null) { | ||
explorerBaseUrl + "token/$contractAddress?a=$walletAddress" | ||
} else { | ||
explorerBaseUrl + "address/$walletAddress" | ||
} | ||
} | ||
|
||
override fun explorerTransactionUrl(transactionHash: String): String { | ||
return explorerBaseUrl + "tx/$transactionHash" | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../java/com/tangem/blockchain/externallinkprovider/providers/BinanceExternalLinkProvider.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,20 @@ | ||
package com.tangem.blockchain.externallinkprovider.providers | ||
|
||
import com.tangem.blockchain.externallinkprovider.ExternalLinkProvider | ||
|
||
internal class BinanceExternalLinkProvider(isTestnet: Boolean) : ExternalLinkProvider { | ||
|
||
override val explorerBaseUrl: String = | ||
if (isTestnet) "https://testnet-explorer.binance.org/" else "https://explorer.binance.org/" | ||
|
||
override val testNetTopUpUrl: String? = | ||
if (isTestnet) "https://docs.binance.org/smart-chain/wallet/binance.html" else null | ||
|
||
override fun explorerUrl(walletAddress: String, contractAddress: String?): String { | ||
return explorerBaseUrl + "address/$walletAddress" | ||
} | ||
|
||
override fun explorerTransactionUrl(transactionHash: String): String { | ||
return explorerBaseUrl + "tx/$transactionHash" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...a/com/tangem/blockchain/externallinkprovider/providers/BitcoinCashExternalLinkProvider.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,23 @@ | ||
package com.tangem.blockchain.externallinkprovider.providers | ||
|
||
import com.tangem.blockchain.externallinkprovider.ExternalLinkProvider | ||
|
||
internal class BitcoinCashExternalLinkProvider(private val isTestnet: Boolean) : ExternalLinkProvider { | ||
|
||
override val explorerBaseUrl: String = | ||
if (isTestnet) "https://blockexplorer.one/bitcoin-cash/testnet/" else "https://www.blockchair.com/bitcoin-cash/" | ||
|
||
override val testNetTopUpUrl: String? = if (isTestnet) "https://coinfaucet.eu/en/bch-testnet/" else null | ||
|
||
override fun explorerUrl(walletAddress: String, contractAddress: String?): String { | ||
return explorerBaseUrl + "address/$walletAddress" | ||
} | ||
|
||
override fun explorerTransactionUrl(transactionHash: String): String { | ||
return if (isTestnet) { | ||
explorerBaseUrl + "tx/$transactionHash" | ||
} else { | ||
explorerBaseUrl + "transaction/$transactionHash" | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../java/com/tangem/blockchain/externallinkprovider/providers/BitcoinExternalLinkProvider.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,19 @@ | ||
package com.tangem.blockchain.externallinkprovider.providers | ||
|
||
import com.tangem.blockchain.externallinkprovider.ExternalLinkProvider | ||
|
||
internal class BitcoinExternalLinkProvider(isTestnet: Boolean) : ExternalLinkProvider { | ||
|
||
override val explorerBaseUrl: String = | ||
if (isTestnet) "https://www.blockchair.com/bitcoin/" else "https://www.blockchair.com/bitcoin/testnet/" | ||
|
||
override val testNetTopUpUrl: String? = if (isTestnet) "https://coinfaucet.eu/en/btc-testnet/" else null | ||
|
||
override fun explorerUrl(walletAddress: String, contractAddress: String?): String { | ||
return explorerBaseUrl + "address/$walletAddress" | ||
} | ||
|
||
override fun explorerTransactionUrl(transactionHash: String): String { | ||
return explorerBaseUrl + "transaction/$transactionHash" | ||
} | ||
} |
Oops, something went wrong.