Skip to content

Commit

Permalink
Add ZKsync blockchain support
Browse files Browse the repository at this point in the history
  • Loading branch information
abdrasulov committed Feb 21, 2025
1 parent 97f3eec commit ffb678d
Show file tree
Hide file tree
Showing 26 changed files with 83 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ android {
resValue "string", "gnosisscanApiKey", "V2J8YU15ZX9S1W3GTUV2HXM11TP2TUBRW4"
resValue "string", "ftmscanApiKey", "57YQ2GIRAZNV6M5HIJYYG3XQGGNIPVV8MF"
resValue "string", "basescanApiKey", "AKEWS351FN9P9E2CFPWRWQVGHYUP7W8SUF"
resValue "string", "eraZkSyncApiKey", "NCUEZ2NFQHW7TG7J7J4MTG4VNG2V4Z2Z48"
resValue "string", "is_release", "false"
resValue "string", "guidesUrl", "https://raw.githubusercontent.com/horizontalsystems/Unstoppable-Wallet-Website/refs/tags/v1.4/src/edu.json"
resValue "string", "faqUrl", "https://raw.githubusercontent.com/horizontalsystems/Unstoppable-Wallet-Website/master/src/faq.json"
Expand Down Expand Up @@ -139,6 +140,7 @@ android {
resValue "string", "gnosisscanApiKey", "KEXFAQKDUENZ5U9CW3ZKYJEJ84ZIHH9QTY"
resValue "string", "ftmscanApiKey", "JAWRPW27KEMVXMJJ9UKY63CVPH3X5V9SMP"
resValue "string", "basescanApiKey", "QU4RJVJXQCW812J3234EW9EV815TA6XC55"
resValue "string", "eraZkSyncApiKey", "NCUEZ2NFQHW7TG7J7J4MTG4VNG2V4Z2Z48"
resValue "string", "is_release", "true"
resValue "string", "guidesUrl", "https://raw.githubusercontent.com/horizontalsystems/Unstoppable-Wallet-Website/refs/tags/v1.4/src/edu.json"
resValue "string", "faqUrl", "https://raw.githubusercontent.com/horizontalsystems/Unstoppable-Wallet-Website/v1.3/src/faq.json"
Expand Down Expand Up @@ -303,9 +305,9 @@ dependencies {
// Wallet kits
implementation 'com.github.horizontalsystems:ton-kit-android:1cb4c1e'
implementation 'com.github.horizontalsystems:bitcoin-kit-android:3f3194f'
implementation 'com.github.horizontalsystems:ethereum-kit-android:201296c'
implementation 'com.github.horizontalsystems:ethereum-kit-android:d423acf'
implementation 'com.github.horizontalsystems:blockchain-fee-rate-kit-android:1d3bd49'
implementation 'com.github.horizontalsystems:market-kit-android:fdbf841'
implementation 'com.github.horizontalsystems:market-kit-android:988d5a3'
implementation 'com.github.horizontalsystems:solana-kit-android:ce738d8'
implementation 'com.github.horizontalsystems:tron-kit-android:dc3dca7'
// Zcash SDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ val Token.swappable: Boolean
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Gnosis,
BlockchainType.Fantom,
BlockchainType.ArbitrumOne -> true
Expand Down Expand Up @@ -144,6 +145,7 @@ val TokenQuery.isSupported: Boolean
BlockchainType.Polygon,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne,
BlockchainType.Gnosis,
BlockchainType.Fantom,
Expand Down Expand Up @@ -176,6 +178,7 @@ val Blockchain.description: String
BlockchainType.Avalanche -> "AVAX, ERC20 tokens"
BlockchainType.Optimism -> "L2 chain"
BlockchainType.Base -> "L2 chain"
BlockchainType.ZkSync -> "L2 chain"
BlockchainType.ArbitrumOne -> "L2 chain"
BlockchainType.Solana -> "SOL, SPL tokens"
BlockchainType.Gnosis -> "xDAI, ERC20 tokens"
Expand Down Expand Up @@ -210,6 +213,7 @@ private val blockchainOrderMap: Map<BlockchainType, Int> by lazy {
BlockchainType.Polygon,
BlockchainType.Base,
BlockchainType.Avalanche,
BlockchainType.ZkSync,
BlockchainType.Zcash,
BlockchainType.BitcoinCash,
BlockchainType.ECash,
Expand All @@ -236,6 +240,7 @@ val BlockchainType.tokenIconPlaceholder: Int
BlockchainType.Polygon -> R.drawable.polygon_erc20
BlockchainType.Optimism -> R.drawable.optimism_erc20
BlockchainType.Base -> R.drawable.base_erc20
BlockchainType.ZkSync -> R.drawable.zksync_erc20
BlockchainType.ArbitrumOne -> R.drawable.arbitrum_erc20
BlockchainType.Gnosis -> R.drawable.gnosis_erc20
BlockchainType.Fantom -> R.drawable.fantom_erc20
Expand All @@ -259,6 +264,7 @@ val BlockchainType.title: String
BlockchainType.ArbitrumOne -> "ArbitrumOne"
BlockchainType.Optimism -> "Optimism"
BlockchainType.Base -> "Base"
BlockchainType.ZkSync -> "ZKsync"
BlockchainType.Solana -> "Solana"
BlockchainType.Gnosis -> "Gnosis"
BlockchainType.Fantom -> "Fantom"
Expand All @@ -285,6 +291,7 @@ val BlockchainType.brandColor: Color?
BlockchainType.Avalanche -> Color(0xFFD74F49)
BlockchainType.Optimism -> Color(0xFFEB3431)
BlockchainType.Base -> Color(0xFF2759F6)
BlockchainType.ZkSync -> Color(0xFF8D8FF0)
BlockchainType.ArbitrumOne -> Color(0xFF96BEDC)
else -> null
}
Expand Down Expand Up @@ -321,6 +328,7 @@ fun BlockchainType.supports(accountType: AccountType): Boolean {
|| this == BlockchainType.Avalanche
|| this == BlockchainType.Optimism
|| this == BlockchainType.Base
|| this == BlockchainType.ZkSync
|| this == BlockchainType.ArbitrumOne
|| this == BlockchainType.Gnosis
|| this == BlockchainType.Fantom
Expand All @@ -331,6 +339,7 @@ fun BlockchainType.supports(accountType: AccountType): Boolean {
|| this == BlockchainType.Avalanche
|| this == BlockchainType.Optimism
|| this == BlockchainType.Base
|| this == BlockchainType.ZkSync
|| this == BlockchainType.ArbitrumOne
|| this == BlockchainType.Gnosis
|| this == BlockchainType.Fantom
Expand Down Expand Up @@ -565,6 +574,7 @@ val BlockchainType.Companion.supported: List<BlockchainType>
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne,
BlockchainType.Gnosis,
BlockchainType.Fantom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class AdapterFactory(
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Gnosis,
BlockchainType.Fantom,
BlockchainType.ArbitrumOne -> {
Expand Down Expand Up @@ -225,6 +226,7 @@ class AdapterFactory(
BlockchainType.Polygon,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne -> {
val evmKitManager = evmBlockchainManager.getEvmKitManager(blockchainType)
evmKitManager.unlink(wallet.account)
Expand All @@ -249,6 +251,7 @@ class AdapterFactory(
BlockchainType.Polygon,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne -> {
val evmKitManager = evmBlockchainManager.getEvmKitManager(blockchainType)
evmKitManager.unlink(transactionSource.account)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ object AddressValidatorFactory {
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Gnosis,
BlockchainType.Fantom,
BlockchainType.ArbitrumOne -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class EvmBlockchainManager(
BlockchainType.Avalanche -> Chain.Avalanche
BlockchainType.Optimism -> Chain.Optimism
BlockchainType.Base -> Chain.Base
BlockchainType.ZkSync -> Chain.ZkSync
BlockchainType.ArbitrumOne -> Chain.ArbitrumOne
BlockchainType.Gnosis -> Chain.Gnosis
BlockchainType.Fantom -> Chain.Fantom
Expand Down Expand Up @@ -85,6 +86,7 @@ class EvmBlockchainManager(
BlockchainType.Gnosis,
BlockchainType.Fantom,
BlockchainType.Base,
BlockchainType.ZkSync,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class EvmSyncSourceManager(
BlockchainType.Gnosis -> TransactionSource.gnosis(appConfigProvider.gnosisscanApiKey)
BlockchainType.Fantom -> TransactionSource.fantom(appConfigProvider.ftmscanApiKey)
BlockchainType.Base -> TransactionSource.basescan(appConfigProvider.basescanApiKey)
BlockchainType.ZkSync -> TransactionSource.eraZkSync(appConfigProvider.eraZkSyncApiKey)
else -> throw Exception("Non-supported EVM blockchain")
}
}
Expand Down Expand Up @@ -159,6 +160,15 @@ class EvmSyncSourceManager(
)
)

BlockchainType.ZkSync -> listOf(
evmSyncSource(
blockchainType,
"ZKsync",
RpcSource.zkSyncRpcHttp(),
defaultTransactionSource(blockchainType)
)
)

BlockchainType.ArbitrumOne -> listOf(
evmSyncSource(
blockchainType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class TransactionAdapterManager(
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Gnosis,
BlockchainType.Fantom,
BlockchainType.ArbitrumOne -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class AppConfigProvider(localStorage: ILocalStorage) {
val basescanApiKey by lazy {
Translator.getString(R.string.basescanApiKey).split(",")
}
val eraZkSyncApiKey by lazy {
Translator.getString(R.string.eraZkSyncApiKey).split(",")
}
val guidesUrl by lazy {
Translator.getString(R.string.guidesUrl)
}
Expand Down Expand Up @@ -141,6 +144,7 @@ class AppConfigProvider(localStorage: ILocalStorage) {
BlockchainType.Avalanche to "0x731352dcF66014156B1560B832B56069e7b38ab1",
BlockchainType.Optimism to "0x731352dcF66014156B1560B832B56069e7b38ab1",
BlockchainType.Base to "0x731352dcF66014156B1560B832B56069e7b38ab1",
BlockchainType.ZkSync to "0x731352dcF66014156B1560B832B56069e7b38ab1",
BlockchainType.ArbitrumOne to "0x731352dcF66014156B1560B832B56069e7b38ab1",
BlockchainType.Solana to "ELFQmFXqdS6C1zVqZifs7WAmLKovdEPbWSnqomhZoK3B",
BlockchainType.Gnosis to "0x731352dcF66014156B1560B832B56069e7b38ab1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ val BitcoinAddress.tokenType: TokenType
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne,
BlockchainType.Solana,
BlockchainType.Gnosis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class AddressHandlerFactory(
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Gnosis,
BlockchainType.Fantom,
BlockchainType.ArbitrumOne -> {
Expand Down Expand Up @@ -90,6 +91,7 @@ class AddressHandlerFactory(
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Gnosis,
BlockchainType.Fantom,
BlockchainType.ArbitrumOne -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ object AddressInputModule {
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Gnosis,
BlockchainType.Fantom,
BlockchainType.ArbitrumOne -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class AddressHandlerUdn(
BlockchainType.Polygon,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Avalanche,
BlockchainType.Gnosis,
BlockchainType.Fantom,
Expand Down Expand Up @@ -138,6 +139,7 @@ class AddressHandlerUdn(
BlockchainType.Ethereum,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne,
BlockchainType.Gnosis,
BlockchainType.Fantom -> "ERC20"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class AddTokenService(
BlockchainType.ArbitrumOne,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Solana
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class BalanceViewItemFactory {
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Solana,
BlockchainType.Gnosis,
BlockchainType.Fantom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class MarketFiltersService(
BlockchainType.Unsupported("okex-chain"),
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Polygon,
BlockchainType.Unsupported("solana"),
BlockchainType.Unsupported("sora"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ abstract class BaseUniswapV3Provider(dexType: DexType) : EvmSwapProvider() {
BlockchainType.Polygon,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne -> uniswapV3Kit.etherToken(chain)
else -> throw Exception("Invalid coin for swap: $token")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ object UniswapV3Provider : BaseUniswapV3Provider(DexType.Uniswap) {
BlockchainType.Polygon,
BlockchainType.BinanceSmartChain,
BlockchainType.Base,
BlockchainType.ZkSync,
-> true
else -> false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ object SendTransactionServiceFactory {
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne,
BlockchainType.Gnosis,
BlockchainType.Fantom -> SendTransactionServiceEvm(blockchainType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class SendFragment : BaseFragment() {
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.Gnosis,
BlockchainType.Fantom,
BlockchainType.ArbitrumOne -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ data class TransactionInfoItem(
val BlockchainType.resendable: Boolean
get() =
when (this) {
BlockchainType.Optimism, BlockchainType.Base, BlockchainType.ArbitrumOne -> false
BlockchainType.Optimism, BlockchainType.Base, BlockchainType.ZkSync, BlockchainType.ArbitrumOne -> false
else -> true
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class TransactionRecordRepository(
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne,
BlockchainType.Gnosis,
BlockchainType.Fantom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ data class TransactionViewItem(
BlockchainType.Avalanche -> R.drawable.logo_chain_avalanche_trx_24
BlockchainType.Optimism -> R.drawable.logo_chain_optimism_trx_24
BlockchainType.Base -> R.drawable.logo_chain_base_trx_24
BlockchainType.ZkSync -> R.drawable.logo_chain_zksync_trx_32
BlockchainType.ArbitrumOne -> R.drawable.logo_chain_arbitrum_one_trx_24
BlockchainType.Gnosis -> R.drawable.logo_chain_gnosis_trx_32
BlockchainType.Fantom -> R.drawable.logo_chain_fantom_trx_32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class WatchAddressViewModel(
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne,
BlockchainType.Gnosis,
BlockchainType.Fantom -> Type.EvmAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ private fun openTransactionOptionsModule(
BlockchainType.Avalanche,
BlockchainType.Optimism,
BlockchainType.Base,
BlockchainType.ZkSync,
BlockchainType.ArbitrumOne -> {
navController.slideFromRight(
R.id.transactionSpeedUpCancelFragment,
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/drawable/logo_chain_zksync_trx_32.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<group>
<clip-path
android:pathData="M0,0h32v32h-32z"/>
<path
android:pathData="M2,15.846L9.686,8V11.923H17.372L9.686,17.808V23.693L2,15.846Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M22.314,20.41V24.333L30,16.487L22.314,8.641V14.525L14.627,20.41H22.314Z"
android:fillColor="#ffffff"/>
</group>
</vector>
14 changes: 14 additions & 0 deletions app/src/main/res/drawable/zksync_erc20.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<group>
<clip-path
android:pathData="M16,0L16,0A16,16 0,0 1,32 16L32,16A16,16 0,0 1,16 32L16,32A16,16 0,0 1,0 16L0,16A16,16 0,0 1,16 0z"/>
<path
android:pathData="M0,8C0,3.582 3.582,0 8,0H24C28.418,0 32,3.582 32,8V24C32,28.418 28.418,32 24,32H8C3.582,32 0,28.418 0,24V8ZM6.521,24V19.772H9.258V20.408H7.277V21.554H9.149V22.154H7.277V23.364H9.258V24H6.521ZM10.195,24V19.772H11.903C12.811,19.772 13.356,20.279 13.356,21.085V21.091C13.356,21.65 13.061,22.113 12.56,22.295L13.482,24H12.618L11.789,22.409H10.951V24H10.195ZM10.951,21.829H11.824C12.302,21.829 12.58,21.563 12.58,21.108V21.103C12.58,20.66 12.29,20.385 11.81,20.385H10.951V21.829ZM16.037,24.105C14.839,24.105 14.095,23.256 14.095,21.891V21.885C14.095,20.514 14.836,19.667 16.034,19.667C16.995,19.667 17.725,20.276 17.824,21.141V21.164H17.083L17.08,21.152C16.972,20.651 16.567,20.32 16.034,20.32C15.316,20.32 14.868,20.921 14.868,21.882V21.888C14.868,22.852 15.316,23.452 16.037,23.452C16.573,23.452 16.972,23.153 17.08,22.688L17.083,22.673H17.824V22.693C17.713,23.54 17.013,24.105 16.037,24.105ZM18.589,24V23.49L19.978,22.072C20.552,21.492 20.713,21.278 20.713,20.953V20.944C20.713,20.555 20.446,20.273 20.007,20.273C19.559,20.273 19.257,20.569 19.257,21.006L19.254,21.018L18.551,21.015L18.548,21.006C18.548,20.218 19.163,19.667 20.045,19.667C20.868,19.667 21.46,20.168 21.46,20.88V20.889C21.46,21.369 21.229,21.75 20.458,22.491L19.611,23.312V23.373H21.524V24H18.589ZM23.912,24.105C22.907,24.105 22.304,23.253 22.304,21.888V21.882C22.304,20.517 22.907,19.667 23.912,19.667C24.917,19.667 25.526,20.517 25.526,21.882V21.888C25.526,23.253 24.917,24.105 23.912,24.105ZM23.912,23.493C24.451,23.493 24.765,22.89 24.765,21.888V21.882C24.765,20.88 24.451,20.282 23.912,20.282C23.373,20.282 23.065,20.88 23.065,21.882V21.888C23.065,22.89 23.373,23.493 23.912,23.493ZM11.941,6L7,10.804L11.941,15.608V12.005L16.882,8.402H11.941V6ZM20.059,16V13.598H15.118L20.059,9.995V6.392L25,11.196L20.059,16Z"
android:fillColor="#8D8FF0"
android:fillType="evenOdd"/>
</group>
</vector>

0 comments on commit ffb678d

Please sign in to comment.