From c75084381c29baf94f6fb2eed1cd8adec33736b4 Mon Sep 17 00:00:00 2001 From: "Albin \"albinek\" Sadowski" Date: Sat, 27 Apr 2019 13:42:42 +0200 Subject: [PATCH] Add pairs with GBP and USDC --- BitBay Ticker Widget/Info.plist | 2 +- BitBay-Ticker/Info.plist | 2 +- BitBay-Ticker/Model/Ticker.swift | 29 ++++++++++++++++------ BitBay-Ticker/Model/TickerStore.swift | 12 +++++---- BitBay-TickerTests/Model/TickerTests.swift | 20 +++++++++++++++ 5 files changed, 51 insertions(+), 14 deletions(-) diff --git a/BitBay Ticker Widget/Info.plist b/BitBay Ticker Widget/Info.plist index 60fbfd3..8cad856 100644 --- a/BitBay Ticker Widget/Info.plist +++ b/BitBay Ticker Widget/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 1.12 CFBundleVersion - 30 + 31 NSExtension NSExtensionMainStoryboard diff --git a/BitBay-Ticker/Info.plist b/BitBay-Ticker/Info.plist index 1428939..c3df7f1 100644 --- a/BitBay-Ticker/Info.plist +++ b/BitBay-Ticker/Info.plist @@ -28,7 +28,7 @@ CFBundleVersion - 30 + 31 Fabric APIKey diff --git a/BitBay-Ticker/Model/Ticker.swift b/BitBay-Ticker/Model/Ticker.swift index 517d1bb..6194cdc 100644 --- a/BitBay-Ticker/Model/Ticker.swift +++ b/BitBay-Ticker/Model/Ticker.swift @@ -4,18 +4,23 @@ struct Ticker { enum Name: String { case btcpln + case btcgbp case btcusd case btceur + case btcusdc case ltcpln + case ltcgbp case ltcusd case ltceur case ltcbtc case ethpln + case ethgbp case ethusd case etheur case ethbtc + case ethusdc case lskpln case lskusd @@ -23,9 +28,11 @@ struct Ticker { case lskbtc case bccpln + case bccgbp case bccusd case bcceur case bccbtc + case bccusdc case dashpln case dashusd @@ -48,6 +55,7 @@ struct Ticker { case kzcbtc case xrppln + case xrpgbp case xrpusd case xrpeur case xrpbtc @@ -144,16 +152,18 @@ struct Ticker { case bsveur case bsvbtc + case usdcusd + var baseCurrencyNameLength: Int { switch self { - case .btcpln, .btcusd, .btceur, - .ltcpln, .ltcusd, .ltceur, .ltcbtc, - .ethpln, .ethusd, .etheur, .ethbtc, + case .btcpln, .btcgbp, .btcusd, .btceur, .btcusdc, + .ltcpln, .ltcgbp, .ltcusd, .ltceur, .ltcbtc, + .ethpln, .ethgbp, .ethusd, .etheur, .ethbtc, .ethusdc, .lskpln, .lskusd, .lskeur, .lskbtc, - .bccpln, .bccusd, .bcceur, .bccbtc, + .bccpln, .bccgbp, .bccusd, .bcceur, .bccbtc, .bccusdc, .btgpln, .btgusd, .btgeur, .btgbtc, .kzcpln, .kzcusd, .kzceur, .kzcbtc, - .xrppln, .xrpusd, .xrpeur, .xrpbtc, + .xrppln, .xrpgbp, .xrpusd, .xrpeur, .xrpbtc, .xinpln, .xinusd, .xineur, .xinbtc, .xmrpln, .xmrusd, .xmreur, .xmrbtc, .zecpln, .zecusd, .zeceur, .zecbtc, @@ -177,13 +187,18 @@ struct Ticker { case .dashpln, .dashusd, .dasheur, .dashbtc, .gamepln, .gameusd, .gameeur, .gamebtc, - .amltpln, .amltusd, .amlteur, .amltbtc: + .amltpln, .amltusd, .amlteur, .amltbtc, + .usdcusd: return 4 } } var counterCurrencyNameLength: Int { - return 3 + if self == .btcusdc || self == .ethusdc || self == .bccusdc { + return 4 + } else { + return 3 + } } } diff --git a/BitBay-Ticker/Model/TickerStore.swift b/BitBay-Ticker/Model/TickerStore.swift index a99704d..d25ff84 100644 --- a/BitBay-Ticker/Model/TickerStore.swift +++ b/BitBay-Ticker/Model/TickerStore.swift @@ -25,14 +25,16 @@ final class TickerStore { let refreshingSubject = PublishSubject() private let allAvailableTickersNames: [Ticker.Name] = [ - .btcpln, .ethpln, .ltcpln, .lskpln, .bccpln, .dashpln, .gamepln, .btgpln, .kzcpln, .xrppln, .xinpln, .xmrpln, .zecpln, .gntpln, .omgpln, .ftopln, .reppln, .batpln, .zrxpln, .paypln, .neupln, .trxpln, .amltpln, .exypln, .bobpln, .lmlpln, .xlmpln, .bcppln, .bsvpln, - .btceur, .etheur, .ltceur, .lskeur, .bcceur, .dasheur, .gameeur, .btgeur, .kzceur, .xrpeur, .xineur, .xmreur, .zeceur, .gnteur, .omgeur, .ftoeur, .repeur, .bateur, .zrxeur, .payeur, .neueur, .trxeur, .amlteur, .exyeur, .bobeur, .xlmeur, .bsveur, - .btcusd, .ethusd, .ltcusd, .lskusd, .bccusd, .dashusd, .gameusd, .btgusd, .kzcusd, .xrpusd, .xinusd, .xmrusd, .zecusd, .gntusd, .omgusd, .ftousd, .repusd, .batusd, .zrxusd, .payusd, .neuusd, .trxusd, .amltusd, .exyusd, .bobusd, .xlmusd, .bsvusd, - .ethbtc, .ltcbtc, .lskbtc, .bccbtc, .dashbtc, .gamebtc, .btgbtc, .kzcbtc, .xrpbtc, .xinbtc, .xmrbtc, .zecbtc, .gntbtc, .omgbtc, .ftobtc, .repbtc, .batbtc, .zrxbtc, .paybtc, .neubtc, .trxbtc, .amltbtc, .exybtc, .bobbtc, .lmlbtc, .xlmbtc, .xbxbtc, .bsvbtc + .btcpln, .ethpln, .ltcpln, .lskpln, .bccpln, .dashpln, .gamepln, .btgpln, .kzcpln, .xrppln, .xinpln, .xmrpln, .zecpln, .gntpln, .omgpln, .ftopln, .reppln, .batpln, .zrxpln, .paypln, .neupln, .trxpln, .amltpln, .exypln, .bobpln, .lmlpln, .xlmpln, .bcppln, .bsvpln, + .btcgbp, .ethgbp, .ltcgbp, .bccgbp, .xrpgbp, + .btceur, .etheur, .ltceur, .lskeur, .bcceur, .dasheur, .gameeur, .btgeur, .kzceur, .xrpeur, .xineur, .xmreur, .zeceur, .gnteur, .omgeur, .ftoeur, .repeur, .bateur, .zrxeur, .payeur, .neueur, .trxeur, .amlteur, .exyeur, .bobeur, .xlmeur, .bsveur, + .btcusd, .ethusd, .ltcusd, .lskusd, .bccusd, .dashusd, .gameusd, .btgusd, .kzcusd, .xrpusd, .xinusd, .xmrusd, .zecusd, .gntusd, .omgusd, .ftousd, .repusd, .batusd, .zrxusd, .payusd, .neuusd, .trxusd, .amltusd, .exyusd, .bobusd, .xlmusd, .bsvusd, + .ethbtc, .ltcbtc, .lskbtc, .bccbtc, .dashbtc, .gamebtc, .btgbtc, .kzcbtc, .xrpbtc, .xinbtc, .xmrbtc, .zecbtc, .gntbtc, .omgbtc, .ftobtc, .repbtc, .batbtc, .zrxbtc, .paybtc, .neubtc, .trxbtc, .amltbtc, .exybtc, .bobbtc, .lmlbtc, .xlmbtc, .xbxbtc, .bsvbtc, + .btcusdc, .ethusdc, .bccusdc, .usdcusd ] private let defaultTickersNames: [Ticker.Name] = [ - .btcpln, .ethpln, .ltcpln, .lskpln, .bccpln, .dashpln, .gamepln, .btgpln, .kzcpln, .xrppln, .xinpln, .xmrpln, .zecpln, .gntpln, .omgpln, .ftopln, .reppln, .batpln, .zrxpln, .paypln, .neupln, .trxpln, .amltpln, .exypln, .bobpln, .lmlpln + .btcpln, .ethpln, .ltcpln, .lskpln, .bccpln, .dashpln, .gamepln, .btgpln, .kzcpln, .xrppln, .xinpln, .xmrpln, .zecpln, .gntpln, .omgpln, .ftopln, .reppln, .batpln, .zrxpln, .paypln, .neupln, .trxpln, .amltpln, .exypln, .bobpln, .lmlpln, .xlmpln, .bcppln, .bsvpln ] func refreshTickers(refreshingType: RefreshingType, completion: ((Error?) -> Void)? = nil) { diff --git a/BitBay-TickerTests/Model/TickerTests.swift b/BitBay-TickerTests/Model/TickerTests.swift index 79d6d34..afa7539 100644 --- a/BitBay-TickerTests/Model/TickerTests.swift +++ b/BitBay-TickerTests/Model/TickerTests.swift @@ -5,18 +5,23 @@ final class TickerTests: XCTestCase { func testBaseCurrencyNameLength() { XCTAssertEqual(3, Ticker.Name.btcpln.baseCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.btcgbp.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.btcusd.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.btceur.baseCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.btcusdc.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ltcpln.baseCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.ltcgbp.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ltcusd.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ltceur.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ltcbtc.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ethpln.baseCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.ethgbp.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ethusd.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.etheur.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ethbtc.baseCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.ethusdc.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.lskpln.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.lskusd.baseCurrencyNameLength) @@ -24,9 +29,11 @@ final class TickerTests: XCTestCase { XCTAssertEqual(3, Ticker.Name.lskbtc.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.bccpln.baseCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.bccgbp.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.bccusd.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.bcceur.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.bccbtc.baseCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.bccusdc.baseCurrencyNameLength) XCTAssertEqual(4, Ticker.Name.dashpln.baseCurrencyNameLength) XCTAssertEqual(4, Ticker.Name.dashusd.baseCurrencyNameLength) @@ -49,6 +56,7 @@ final class TickerTests: XCTestCase { XCTAssertEqual(3, Ticker.Name.kzcbtc.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.xrppln.baseCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.xrpgbp.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.xrpusd.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.xrpeur.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.xrpbtc.baseCurrencyNameLength) @@ -144,22 +152,29 @@ final class TickerTests: XCTestCase { XCTAssertEqual(3, Ticker.Name.bsvusd.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.bsveur.baseCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.bsvbtc.baseCurrencyNameLength) + + XCTAssertEqual(4, Ticker.Name.usdcusd.baseCurrencyNameLength) } func testCounterCurrencyNameLength() { XCTAssertEqual(3, Ticker.Name.btcpln.counterCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.btcgbp.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.btcusd.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.btceur.counterCurrencyNameLength) + XCTAssertEqual(4, Ticker.Name.btcusdc.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ltcpln.counterCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.ltcgbp.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ltcusd.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ltceur.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ltcbtc.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ethpln.counterCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.ethgbp.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ethusd.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.etheur.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.ethbtc.counterCurrencyNameLength) + XCTAssertEqual(4, Ticker.Name.ethusdc.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.lskpln.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.lskusd.counterCurrencyNameLength) @@ -167,9 +182,11 @@ final class TickerTests: XCTestCase { XCTAssertEqual(3, Ticker.Name.lskbtc.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.bccpln.counterCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.bccgbp.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.bccusd.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.bcceur.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.bccbtc.counterCurrencyNameLength) + XCTAssertEqual(4, Ticker.Name.bccusdc.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.dashpln.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.dashusd.counterCurrencyNameLength) @@ -192,6 +209,7 @@ final class TickerTests: XCTestCase { XCTAssertEqual(3, Ticker.Name.kzcbtc.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.xrppln.counterCurrencyNameLength) + XCTAssertEqual(3, Ticker.Name.xrpgbp.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.xrpusd.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.xrpeur.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.xrpbtc.counterCurrencyNameLength) @@ -273,6 +291,8 @@ final class TickerTests: XCTestCase { XCTAssertEqual(3, Ticker.Name.lmlpln.counterCurrencyNameLength) XCTAssertEqual(3, Ticker.Name.lmlbtc.counterCurrencyNameLength) + + XCTAssertEqual(3, Ticker.Name.usdcusd.counterCurrencyNameLength) } func testKeys() {