Skip to content

Commit

Permalink
Add Base blockchain support
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev committed Sep 27, 2024
1 parent f74c026 commit ff09959
Show file tree
Hide file tree
Showing 28 changed files with 109 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy_appstore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
XCCONFIG_PROD_ETHERSCAN_API_KEY: ${{ secrets.XCCONFIG_PROD_ETHERSCAN_API_KEY }}
XCCONFIG_PROD_ARBISCAN_API_KEY: ${{ secrets.XCCONFIG_PROD_ARBISCAN_API_KEY }}
XCCONFIG_PROD_OPTIMISM_ETHERSCAN_API_KEY: ${{ secrets.XCCONFIG_PROD_OPTIMISM_ETHERSCAN_API_KEY }}
XCCONFIG_PROD_BASESCAN_API_KEY: ${{ secrets.XCCONFIG_PROD_BASESCAN_API_KEY }}
XCCONFIG_PROD_BSCSCAN_API_KEY: ${{ secrets.XCCONFIG_PROD_BSCSCAN_API_KEY }}
XCCONFIG_PROD_POLYGONSCAN_API_KEY: ${{ secrets.XCCONFIG_PROD_POLYGONSCAN_API_KEY }}
XCCONFIG_PROD_SNOWTRACE_API_KEY: ${{ secrets.XCCONFIG_PROD_SNOWTRACE_API_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
XCCONFIG_DEV_ETHERSCAN_API_KEY: ${{ secrets.XCCONFIG_DEV_ETHERSCAN_API_KEY }}
XCCONFIG_DEV_ARBISCAN_API_KEY: ${{ secrets.XCCONFIG_DEV_ARBISCAN_API_KEY }}
XCCONFIG_DEV_OPTIMISM_ETHERSCAN_API_KEY: ${{ secrets.XCCONFIG_DEV_OPTIMISM_ETHERSCAN_API_KEY }}
XCCONFIG_DEV_BASESCAN_API_KEY: ${{ secrets.XCCONFIG_DEV_BASESCAN_API_KEY }}
XCCONFIG_DEV_BSCSCAN_API_KEY: ${{ secrets.XCCONFIG_DEV_BSCSCAN_API_KEY }}
XCCONFIG_DEV_POLYGONSCAN_API_KEY: ${{ secrets.XCCONFIG_DEV_POLYGONSCAN_API_KEY }}
XCCONFIG_DEV_SNOWTRACE_API_KEY: ${{ secrets.XCCONFIG_DEV_SNOWTRACE_API_KEY }}
Expand Down
8 changes: 4 additions & 4 deletions UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12883,7 +12883,7 @@
repositoryURL = "https://github.com/horizontalsystems/EvmKit.Swift";
requirement = {
kind = exactVersion;
version = 2.0.20;
version = 2.0.21;
};
};
D3604E4828F02A8B0066C366 /* XCRemoteSwiftPackageReference "Eip20Kit" */ = {
Expand All @@ -12907,15 +12907,15 @@
repositoryURL = "https://github.com/horizontalsystems/UniswapKit.Swift";
requirement = {
kind = exactVersion;
version = 3.0.1;
version = 3.0.2;
};
};
D3604E5128F02B150066C366 /* XCRemoteSwiftPackageReference "OneInchKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/horizontalsystems/OneInchKit.Swift";
requirement = {
kind = exactVersion;
version = 3.0.3;
version = 3.0.4;
};
};
D3604E6428F02D9A0066C366 /* XCRemoteSwiftPackageReference "BitcoinKit" */ = {
Expand Down Expand Up @@ -12947,7 +12947,7 @@
repositoryURL = "https://github.com/horizontalsystems/MarketKit.Swift";
requirement = {
kind = exactVersion;
version = 3.0.12;
version = 3.0.13;
};
};
D3604E7D28F03C1D0066C366 /* XCRemoteSwiftPackageReference "Chart" */ = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
etherscan_api_key =
arbiscan_api_key =
optimism_etherscan_api_key =
basescan_api_key =
bscscan_api_key =
polygonscan_api_key =
gnosisscan_api_key =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
etherscan_api_key =
arbiscan_api_key =
optimism_etherscan_api_key =
basescan_api_key
bscscan_api_key =
polygonscan_api_key =
gnosisscan_api_key =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ extension UdnAddressParserItem {
case .tron: return "TRX"
case .solana: return "SOL"
case .ton: return "TON"
case .base: return "ETH"
case let .unsupported(uid): return uid
}
}

static func chain(token: Token) -> String? {
switch (token.blockchainType, token.type) {
case (.ethereum, .eip20), (.optimism, .eip20), (.arbitrumOne, .eip20), (.gnosis, .eip20), (.fantom, .eip20): return "ERC20"
case (.ethereum, .eip20), (.optimism, .eip20), (.arbitrumOne, .eip20), (.gnosis, .eip20), (.fantom, .eip20), (.base, .eip20): return "ERC20"
case (.binanceSmartChain, .native), (.binanceSmartChain, .eip20): return "BEP20"
case (.polygon, .native), (.polygon, .eip20): return "MATIC"
case (.avalanche, .native), (.avalanche, .eip20): return "AVAX"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ extension AdapterFactory {
return BinanceAdapter(binanceKit: binanceKit, feeToken: feeToken, wallet: wallet)
}

case (.native, .ethereum), (.native, .binanceSmartChain), (.native, .polygon), (.native, .avalanche), (.native, .optimism), (.native, .arbitrumOne), (.native, .gnosis), (.native, .fantom):
case (.native, .ethereum), (.native, .binanceSmartChain), (.native, .polygon), (.native, .avalanche), (.native, .optimism), (.native, .arbitrumOne), (.native, .gnosis), (.native, .fantom), (.native, .base):
return evmAdapter(wallet: wallet)

case let (.eip20(address), .ethereum), let (.eip20(address), .binanceSmartChain), let (.eip20(address), .polygon), let (.eip20(address), .avalanche), let (.eip20(address), .optimism), let (.eip20(address), .arbitrumOne), let (.eip20(address), .gnosis), let (.eip20(address), .fantom):
case let (.eip20(address), .ethereum), let (.eip20(address), .binanceSmartChain), let (.eip20(address), .polygon), let (.eip20(address), .avalanche), let (.eip20(address), .optimism), let (.eip20(address), .arbitrumOne), let (.eip20(address), .gnosis), let (.eip20(address), .fantom), let (.eip20(address), .base):
return eip20Adapter(address: address, wallet: wallet, coinManager: coinManager)

case (.native, .tron):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ enum AddressParserFactory {
}

return handlers
case .ethereum, .gnosis, .fantom, .polygon, .arbitrumOne, .avalanche, .optimism, .binanceSmartChain:
case .ethereum, .gnosis, .fantom, .polygon, .arbitrumOne, .avalanche, .optimism, .binanceSmartChain, .base:
let evmAddressParserItem = EvmAddressParser(blockchainType: blockchainType)

var handlers = [IAddressParserItem]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class EvmBlockchainManager {
.arbitrumOne,
.gnosis,
.fantom,
.base,
]

private let syncSourceManager: EvmSyncSourceManager
Expand Down Expand Up @@ -99,6 +100,7 @@ extension EvmBlockchainManager {
case .arbitrumOne: return .arbitrumOne
case .gnosis: return .gnosis
case .fantom: return .fantom
case .base: return .base
default: fatalError("Unsupported blockchain type")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class EvmSyncSourceManager {
case .arbitrumOne: return .arbiscan(apiKey: AppConfig.arbiscanKey)
case .gnosis: return .gnosis(apiKey: AppConfig.gnosisscanKey)
case .fantom: return .fantom(apiKey: AppConfig.ftmscanKey)
case .base: return .basescan(apiKey: AppConfig.basescanKey)
default: fatalError("Non-supported EVM blockchain")
}
}
Expand Down Expand Up @@ -184,6 +185,24 @@ extension EvmSyncSourceManager {
transactionSource: defaultTransactionSource(blockchainType: blockchainType)
),
]
case .base:
return [
EvmSyncSource(
name: "Base",
rpcSource: .baseRpcHttp(),
transactionSource: defaultTransactionSource(blockchainType: blockchainType)
),
EvmSyncSource(
name: "LlamaNodes",
rpcSource: .http(urls: [URL(string: "https://base.llamarpc.com")!], auth: nil),
transactionSource: defaultTransactionSource(blockchainType: blockchainType)
),
EvmSyncSource(
name: "Omnia",
rpcSource: .http(urls: [URL(string: "https://endpoints.omniatech.io/v1/base/mainnet/public")!], auth: nil),
transactionSource: defaultTransactionSource(blockchainType: blockchainType)
),
]
default:
return []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum AppConfig {
.polygon: "0xA24c159C7f1E4A04dab7c364C2A8b87b3dBa4cd1",
.avalanche: "0xA24c159C7f1E4A04dab7c364C2A8b87b3dBa4cd1",
.optimism: "0xA24c159C7f1E4A04dab7c364C2A8b87b3dBa4cd1",
.base: "0xA24c159C7f1E4A04dab7c364C2A8b87b3dBa4cd1",
.arbitrumOne: "0xA24c159C7f1E4A04dab7c364C2A8b87b3dBa4cd1",
.gnosis: "0xA24c159C7f1E4A04dab7c364C2A8b87b3dBa4cd1",
.fantom: "0xA24c159C7f1E4A04dab7c364C2A8b87b3dBa4cd1",
Expand Down Expand Up @@ -84,6 +85,10 @@ enum AppConfig {
(Bundle.main.object(forInfoDictionaryKey: "OptimismEtherscanApiKey") as? String) ?? ""
}

static var basescanKey: String {
(Bundle.main.object(forInfoDictionaryKey: "BasescanApiKey") as? String) ?? ""
}

static var bscscanKey: String {
(Bundle.main.object(forInfoDictionaryKey: "BscscanApiKey") as? String) ?? ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension BlockchainType {
.arbitrumOne,
.gnosis,
.fantom,
.base,
.binanceSmartChain,
.binanceChain,
.tron,
Expand Down Expand Up @@ -53,6 +54,7 @@ extension BlockchainType {
.tron,
.ton,
.polygon,
.base,
.avalanche,
.zcash,
.bitcoinCash,
Expand All @@ -71,14 +73,14 @@ extension BlockchainType {

var resendable: Bool {
switch self {
case .optimism, .arbitrumOne: return false
case .optimism, .arbitrumOne, .base: return false
default: return true
}
}

var rollupFeeContractAddress: EvmKit.Address? {
switch self {
case .optimism: return try? EvmKit.Address(hex: "0x420000000000000000000000000000000000000F")
case .optimism, .base: return try? EvmKit.Address(hex: "0x420000000000000000000000000000000000000F")
default: return nil
}
}
Expand Down Expand Up @@ -114,7 +116,7 @@ extension BlockchainType {
}
case .evmPrivateKey, .evmAddress:
switch self {
case .ethereum, .binanceSmartChain, .polygon, .avalanche, .optimism, .arbitrumOne, .gnosis, .fantom: return true
case .ethereum, .binanceSmartChain, .polygon, .avalanche, .optimism, .arbitrumOne, .gnosis, .fantom, .base: return true
default: return false
}
case .tronAddress:
Expand Down Expand Up @@ -143,6 +145,7 @@ extension BlockchainType {
case .gnosis: return "xDAI, ERC20 tokens"
case .fantom: return "FTM, ERC20 tokens"
case .optimism: return "L2 chain"
case .base: return "L2 chain"
case .arbitrumOne: return "L2 chain"
case .zcash: return "ZEC"
case .dash: return "DASH"
Expand All @@ -163,6 +166,7 @@ extension BlockchainType {
case .polygon: return UIColor(hex: 0x8247E5)
case .avalanche: return UIColor(hex: 0xD74F49)
case .optimism: return UIColor(hex: 0xEB3431)
case .base: return UIColor(hex: 0x2759F6)
case .arbitrumOne: return UIColor(hex: 0x96BEDC)
default: return nil
}
Expand All @@ -175,6 +179,7 @@ extension BlockchainType {
case .polygon: return Color(hex: 0x8247E5)
case .avalanche: return Color(hex: 0xD74F49)
case .optimism: return Color(hex: 0xEB3431)
case .base: return Color(hex: 0x2759F6)
case .arbitrumOne: return Color(hex: 0x96BEDC)
default: return nil
}
Expand Down
1 change: 1 addition & 0 deletions UnstoppableWallet/UnstoppableWallet/Extensions/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extension Token {
case .arbitrumOne: return true
case .gnosis: return true
case .fantom: return true
case .base: return true
default: return false
}
}
Expand Down
2 changes: 2 additions & 0 deletions UnstoppableWallet/UnstoppableWallet/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>ArbiscanApiKey</key>
<string>${arbiscan_api_key}</string>
<key>BasescanApiKey</key>
<string>${basescan_api_key}</string>
<key>BscscanApiKey</key>
<string>${bscscan_api_key}</string>
<key>CFBundleDevelopmentRegion</key>
Expand Down
2 changes: 2 additions & 0 deletions UnstoppableWallet/UnstoppableWallet/Models/AccountType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ enum AccountType {
case (.fantom, .native), (.fantom, .eip20): return true
case (.arbitrumOne, .native), (.arbitrumOne, .eip20): return true
case (.optimism, .native), (.optimism, .eip20): return true
case (.base, .native), (.base, .eip20): return true
case (.tron, .native), (.tron, .eip20): return true
case (.ton, .native), (.ton, .jetton): return true
default: return false
Expand Down Expand Up @@ -113,6 +114,7 @@ enum AccountType {
case (.fantom, .native), (.fantom, .eip20): return true
case (.arbitrumOne, .native), (.arbitrumOne, .eip20): return true
case (.optimism, .native), (.optimism, .eip20): return true
case (.base, .native), (.base, .eip20): return true
default: return false
}
case .tronAddress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MarketAdvancedSearchViewModel: ObservableObject {
.unsupported(uid: "moonriver"),
.unsupported(uid: "okex-chain"),
.optimism,
.base,
.polygon,
.unsupported(uid: "solana"),
.unsupported(uid: "sora"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class OneInchMultiSwapProvider: BaseEvmMultiSwapProvider {
}

switch tokenIn.blockchainType {
case .ethereum, .binanceSmartChain, .polygon, .avalanche, .optimism, .arbitrumOne, .gnosis, .fantom: return true
case .ethereum, .binanceSmartChain, .polygon, .avalanche, .optimism, .arbitrumOne, .gnosis, .fantom, .base: return true
default: return false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PancakeV3MultiSwapProvider: BaseUniswapV3MultiSwapProvider {
}

switch tokenIn.blockchainType {
case .ethereum, .binanceSmartChain: return true
case .ethereum, .binanceSmartChain, .base: return true
default: return false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class UniswapV2MultiSwapProvider: BaseUniswapV2MultiSwapProvider {
override func supports(tokenIn: MarketKit.Token, tokenOut: MarketKit.Token) -> Bool {
switch (tokenIn.blockchainType, tokenOut.blockchainType) {
case (.ethereum, .ethereum): return true
case (.base, .base): return true
default: return false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UniswapV3MultiSwapProvider: BaseUniswapV3MultiSwapProvider {
}

switch tokenIn.blockchainType {
case .ethereum, .binanceSmartChain, .polygon, .arbitrumOne: return true
case .ethereum, .binanceSmartChain, .polygon, .arbitrumOne, .base: return true
default: return false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ extension BlockchainType {
case .arbitrumOne: return [.oneInch, .uniswapV3]
case .gnosis: return [.oneInch]
case .fantom: return [.oneInch]
case .base: return [.oneInch, .uniswap, .uniswapV3]
default: return []
}
}
Expand Down Expand Up @@ -182,9 +183,9 @@ extension SwapModule.Dex {

var allowedBlockchainTypes: [BlockchainType] {
switch self {
case .uniswap: return [.ethereum]
case .uniswapV3: return [.ethereum, .binanceSmartChain, .arbitrumOne, .polygon]
case .oneInch: return [.ethereum, .binanceSmartChain, .polygon, .avalanche, .optimism, .arbitrumOne, .gnosis, .fantom]
case .uniswap: return [.ethereum, .base]
case .uniswapV3: return [.ethereum, .binanceSmartChain, .arbitrumOne, .polygon, .base]
case .oneInch: return [.ethereum, .binanceSmartChain, .polygon, .avalanche, .optimism, .arbitrumOne, .gnosis, .fantom, .base]
case .pancake: return [.binanceSmartChain]
case .pancakeV3: return [.ethereum, .binanceSmartChain]
case .quickSwap: return [.polygon]
Expand Down
Loading

0 comments on commit ff09959

Please sign in to comment.