-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
2,692 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,7 @@ | |
.build | ||
|
||
Package.resolved | ||
|
||
UI/Pods | ||
UI/Podfile.lock | ||
xcuserdata |
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,59 @@ | ||
// | ||
// API.swift | ||
// CryptExUI | ||
// | ||
// Created by Sathyakumar Rajaraman on 3/17/18. | ||
// Copyright © 2018 Sathyakumar. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct API { | ||
|
||
struct Gemini { | ||
static let key = "" | ||
static let secret = "" | ||
} | ||
|
||
struct Poloniex { | ||
static let key = "" | ||
static let secret = "" | ||
} | ||
|
||
struct GDAX { | ||
static let key = "" | ||
static let secret = "" | ||
static let passphrase = "" | ||
} | ||
|
||
struct Binance { | ||
static let key = "" | ||
static let secret = "" | ||
} | ||
|
||
struct Cryptopia { | ||
static let key = "" | ||
static let secret = "" | ||
} | ||
|
||
struct BitGrail { | ||
static let key = "" | ||
static let secret = "" | ||
} | ||
|
||
struct Bitfinex { | ||
static let key = "" | ||
static let secret = "" | ||
} | ||
|
||
struct Kraken { | ||
static let key = "" | ||
static let secret = "" | ||
} | ||
|
||
struct KuCoin { | ||
static let key = "" | ||
static let secret = "" | ||
} | ||
} | ||
|
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,119 @@ | ||
// | ||
// Services.swift | ||
// CryptEx | ||
// | ||
// Created by Sathyakumar Rajaraman on 3/17/18. | ||
// Copyright © 2018 Sathyakumar. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class Services { | ||
static let shared = Services() | ||
|
||
private init() { } | ||
|
||
lazy var coinMarketCap: CoinMarketCap.Service = { | ||
return CoinMarketCap.Service(key: nil, secret: nil, session: URLSession.shared, userPreference: .USD_BTC, currencyOverrides: nil) | ||
}() | ||
|
||
lazy var gemini: Gemini.Service = { | ||
return Gemini.Service(key: API.Gemini.key, secret: API.Gemini.secret, session: URLSession.shared, userPreference: .USD_BTC, currencyOverrides: nil) | ||
}() | ||
|
||
lazy var poloniex: Poloniex.Service = { | ||
return Poloniex.Service(key: API.Poloniex.key, secret: API.Poloniex.secret, session: URLSession.shared, userPreference: .USDT_BTC, currencyOverrides: nil) | ||
}() | ||
|
||
lazy var gdax: GDAX.Service = { | ||
let userPreference = UserPreference(fiat: .USD, crypto: .Bitcoin, ignoredFiats: [.EUR, .GBP]) | ||
return GDAX.Service(key: API.GDAX.key, secret: API.GDAX.secret, passphrase: API.GDAX.passphrase, session: URLSession.shared, userPreference: userPreference, currencyOverrides: nil) | ||
}() | ||
|
||
lazy var binance: Binance.Service = { | ||
return Binance.Service(key: API.Binance.key, secret: API.Binance.secret, session: URLSession.shared, userPreference: .USDT_BTC, currencyOverrides: ["BCC": Currency(name: "Bitcoin Cash", code: "BCC")]) | ||
}() | ||
|
||
lazy var cryptopia: Cryptopia.Service = { | ||
return Cryptopia.Service(key: API.Cryptopia.key, secret: API.Cryptopia.secret, session: URLSession.shared, userPreference: .USDT_BTC, currencyOverrides: nil) | ||
}() | ||
|
||
lazy var bitGrail: BitGrail.Service = { | ||
return BitGrail.Service(key: API.Binance.key, secret: API.Binance.secret, session: URLSession.shared, userPreference: .USD_BTC, currencyOverrides: nil) | ||
}() | ||
|
||
lazy var coinExchange: CoinExchange.Service = { | ||
let userPreference = UserPreference(fiat: .USDT, crypto: .Bitcoin, ignoredFiats: [.EUR]) | ||
return CoinExchange.Service(key: nil, secret: nil, session: URLSession.shared, userPreference: userPreference, currencyOverrides: nil) | ||
}() | ||
|
||
lazy var bitfinex: Bitfinex.Service = { | ||
return Bitfinex.Service(key: API.Bitfinex.key, secret: API.Bitfinex.secret, session: URLSession.shared, userPreference: .USD_BTC, currencyOverrides: nil) | ||
}() | ||
|
||
lazy var koinex: Koinex.Service = { | ||
let userPreference = UserPreference(fiat: .INR, crypto: .Bitcoin, ignoredFiats: []) | ||
return Koinex.Service(key: nil, secret: nil, session: URLSession.shared, userPreference: userPreference, currencyOverrides: nil) | ||
}() | ||
|
||
lazy var kraken: Kraken.Service = { | ||
return Kraken.Service(key: API.Kraken.key, secret: API.Kraken.secret, session: URLSession.shared, userPreference: .USD_BTC, currencyOverrides: nil) | ||
}() | ||
|
||
/* lazy var kuCoin: KuCoin.Service = { | ||
return KuCoin.Service(key: API.KuCoin.key, secret: API.KuCoin.secret, session: URLSession.shared, userPreference: .USDT_BTC, currencyOverrides: nil) | ||
}()*/ | ||
|
||
|
||
func balance() -> NSDecimalNumber { | ||
|
||
var totalBalance = NSDecimalNumber.zero | ||
|
||
totalBalance = totalBalance.adding(gemini.store.getTotalBalance()) | ||
totalBalance = totalBalance.adding(poloniex.store.getTotalBalance()) | ||
totalBalance = totalBalance.adding(gdax.store.getTotalBalance()) | ||
totalBalance = totalBalance.adding(binance.store.getTotalBalance()) | ||
totalBalance = totalBalance.adding(cryptopia.store.getTotalBalance()) | ||
if let btcPrice = gemini.store.tickersDictionary["BTCUSD"]?.price { | ||
let xrbValueInUSD = btcPrice.multiplying(by: bitGrail.store.getTotalBalance()) | ||
totalBalance = totalBalance.adding(xrbValueInUSD) | ||
} | ||
return totalBalance | ||
} | ||
|
||
func fetchAllBalances(completion: (() -> Void)?, failure: ((String?, String?) -> Void)?, captcha: ((String) -> Void)?) { | ||
coinMarketCap.getGlobal { (_) in | ||
completion?() | ||
} | ||
gemini.getBalances(completion: { _ in | ||
completion?() | ||
}) | ||
poloniex.getBalances(completion: { (_) in | ||
completion?() | ||
}) | ||
gdax.getBalances(completion: { (_) in | ||
completion?() | ||
}) | ||
binance.getBalances(completion: { (_) in | ||
completion?() | ||
}) | ||
cryptopia.getCurrencies { (_) in | ||
self.cryptopia.getTickers { (_) in | ||
self.cryptopia.getBalances(completion: { (_) in | ||
completion?() | ||
}) | ||
} | ||
} | ||
bitGrail.getBalances { (_) in | ||
completion?() | ||
} | ||
coinExchange.getCurrencyPairs { (_) in | ||
self.coinExchange.getTickers(completion: { (_) in | ||
completion?() | ||
}) | ||
} | ||
bitfinex.getBalances { (_) in | ||
completion?() | ||
} | ||
} | ||
} |
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,58 @@ | ||
// | ||
// AppDelegate.swift | ||
// CryptEx | ||
// | ||
// Created by Sathyakumar Rajaraman on 3/17/18. | ||
// Copyright © 2018 Sathyakumar. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import UserNotifications | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
var window: UIWindow? | ||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | ||
// Override point for customization after application launch. | ||
|
||
application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum) | ||
|
||
let center = UNUserNotificationCenter.current() | ||
center.requestAuthorization(options: [.sound, .sound, .badge]) { (granted, error) in | ||
if let error = error { | ||
print(error) | ||
} | ||
} | ||
return true | ||
} | ||
|
||
func applicationWillResignActive(_ application: UIApplication) { | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. | ||
} | ||
|
||
func applicationDidEnterBackground(_ application: UIApplication) { | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
|
||
func applicationWillEnterForeground(_ application: UIApplication) { | ||
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. | ||
BackgroundService.shared.pause() | ||
} | ||
|
||
func applicationDidBecomeActive(_ application: UIApplication) { | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
|
||
func applicationWillTerminate(_ application: UIApplication) { | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
|
||
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { | ||
BackgroundService.shared.resume(completionHandler: completionHandler) | ||
} | ||
} | ||
|
53 changes: 53 additions & 0 deletions
53
UI/CryptEx/Assets.xcassets/AppIcon.appiconset/Contents.json
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,53 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "20x20", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "20x20", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "ios-marketing", | ||
"size" : "1024x1024", | ||
"scale" : "1x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
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,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "Pixel.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
UI/CryptEx/Assets.xcassets/TransparentPixel.imageset/Contents.json
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,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "TransparentPixel.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+107 Bytes
UI/CryptEx/Assets.xcassets/TransparentPixel.imageset/TransparentPixel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.