Skip to content

Instantly share code, notes, and snippets.

@trsathya
Created January 13, 2018 13:30
Show Gist options
  • Save trsathya/1ee672de3933b1b4b56891c3baf4212c to your computer and use it in GitHub Desktop.
Save trsathya/1ee672de3933b1b4b56891c3baf4212c to your computer and use it in GitHub Desktop.
An example implementation of CurrencyStoreType in github.com/trsathya/cryptex
import Foundation
import Cryptex
struct CurrencyStore: CurrencyStoreType {
static let shared: CurrencyStore = {
return CurrencyStore(currencies: CurrencyStore.currencies)
}()
let currencies: [Currency]
private init(currencies: [Currency]) {
self.currencies = currencies
}
func isKnown(code: String) -> Bool {
return currencies.filter { $0.code.lowercased() == code.lowercased() }.count > 0
}
func forCode(_ code: String) -> Currency {
if let currency = (currencies.filter { $0.code.lowercased() == code.lowercased() }).first {
return currency
} else {
return Currency(name: code, code: code)
}
}
static let bitcoinCash = Currency(name: "Bitcoin Cash", code: "BCH")
static let binanceBitcoinCash = Currency(name: "Bitcoin Cash", code: "BCC")
static let bitcoinGold = Currency(name: "Bitcoin Gold", code: "BTG")
static let zcash = Currency(name: "ZCash", code: "ZEC")
static let ethereumClassic = Currency(name: "Ethereum Classic", code: "ETC")
static let stellar = Currency(name: "Stellar", code: "STR")
static let dash = Currency(name: "Dash", code: "DASH")
static let nxt = Currency(name: "NXT", code: "NXT")
static let monero = Currency(name: "Monero", code: "XMR")
static let augur = Currency(name: "Augur", code: "REP")
static let bytecoin = Currency(name: "Bytecoin", code: "BCN")
static let bitcoinDark = Currency(name: "BitcoinDark", code: "BTCD")
static let mainSafeCoin = Currency(name: "MainSafeCoin", code: "MAID")
static let blackCoin = Currency(name: "BlackCoin", code: "BLK")
static let golem = Currency(name: "Golem", code: "GNT")
static let lisk = Currency(name: "Lisk", code: "LSK")
static let gnosis = Currency(name: "Gnosis", code: "GNO")
static let steem = Currency(name: "STEEM", code: "STEEM")
static let siacoin = Currency(name: "Siacoin", code: "SC")
static let digiByte = Currency(name: "DigiByte", code: "DGB")
static let bitShares = Currency(name: "BitShares", code: "BTS")
static let stratis = Currency(name: "Stratis", code: "STRAT")
static let factom = Currency(name: "Factom", code: "FCT")
static let syscoin = Currency(name: "Syscoin", code: "SYS")
static let dogecoin = Currency(name: "Dogecoin", code: "DOGE")
static let gameCredits = Currency(name: "GameCredits", code: "GAME")
static let lbryCredits = Currency(name: "LBRY Credits", code: "LBC")
static let decred = Currency(name: "Decred", code: "DCR")
static let neoscoin = Currency(name: "Neoscoin", code: "NEOS")
static let viacoin = Currency(name: "Viacoin", code: "VIA")
static let omni = Currency(name: "Omni", code: "OMNI")
static let synereoAMP = Currency(name: "Synereo AMP", code: "AMP")
static let vertcoin = Currency(name: "Vertcoin", code: "VTC")
static let counterparty = Currency(name: "Counterparty", code: "XCP")
static let clams = Currency(name: "CLAMS", code: "CLAM")
static let pascalCoin = Currency(name: "PascalCoin", code: "PASC")
static let gridcoinResearch = Currency(name: "GridCoin Research", code: "GRC")
static let storjcoinX = Currency(name: "Storjcoin X", code: "SJCX")
static let potCoin = Currency(name: "PotCoin", code: "POT")
static let burst = Currency(name: "Burst", code: "BURST")
static let huntercoin = Currency(name: "Huntercoin", code: "HUC")
static let bitmark = Currency(name: "Bitmark", code: "BTM")
static let bitCrystals = Currency(name: "BitCrystals", code: "BCY")
static let primecoin = Currency(name: "Primecoin", code: "XPM")
static let belacoin = Currency(name: "Belacoin", code: "BELA")
static let peercoin = Currency(name: "Peercoin", code: "PPC")
static let einsteinium = Currency(name: "Einsteinium", code: "EMC2")
static let expanse = Currency(name: "Expanse", code: "EXP")
static let dnotes = Currency(name: "DNotes", code: "NOTE")
static let radium = Currency(name: "Radium", code: "RADS")
static let veriCoin = Currency(name: "VeriCoin", code: "VRC")
static let navCoin = Currency(name: "NAVCoin", code: "NAV")
static let florincoin = Currency(name: "Florincoin", code: "FLO")
static let pinkcoin = Currency(name: "Pinkcoin", code: "PINK")
static let namecoin = Currency(name: "Namecoin", code: "NMC")
static let nautiluscoin = Currency(name: "Nautiluscoin", code: "NAUT")
static let foldingCoin = Currency(name: "FoldingCoin", code: "FLDC")
static let nexium = Currency(name: "Nexium", code: "NXC")
static let vcash = Currency(name: "Vcash", code: "XVC")
static let riecoin = Currency(name: "Riecoin", code: "RIC")
static let bitcoinPlus = Currency(name: "BitcoinPlus", code: "XBC")
static let steemDollars = Currency(name: "Steem Dollars", code: "SBD")
static let digixDAO = Currency(name: "DigixDAO", code: "DGD")
static let neo = Currency(name: "Neo", code: "NEO")
static let zCoin = Currency(name: "ZCoin", code: "XZC")
static let qtum = Currency(name: "Qtum", code: "QTUM")
static let gas = Currency(name: "Gas", code: "GAS")
static let populous = Currency(name: "Populous", code: "PPT")
static let binanceCoin = Currency(name: "Binance Coin", code: "BNB")
static let bitcoinDiamond = Currency(name: "Bitcoin Diamond", code: "BCD")
static var currencies: [Currency] = {
var array = [
bitcoinCash,
binanceBitcoinCash,
bitcoinGold,
zcash,
ethereumClassic,
stellar,
dash,
nxt,
monero,
augur,
bytecoin,
bitcoinDark,
mainSafeCoin,
blackCoin,
golem,
lisk,
gnosis,
steem,
siacoin,
digiByte,
bitShares,
stratis,
factom,
syscoin,
dogecoin,
gameCredits,
lbryCredits,
decred,
neoscoin,
viacoin,
omni,
synereoAMP,
vertcoin,
counterparty,
clams,
pascalCoin,
gridcoinResearch,
storjcoinX,
potCoin,
burst,
huntercoin,
bitmark,
bitCrystals,
primecoin,
belacoin,
peercoin,
einsteinium,
expanse,
dnotes,
radium,
veriCoin,
navCoin,
florincoin,
pinkcoin,
namecoin,
nautiluscoin,
foldingCoin,
nexium,
vcash,
riecoin,
bitcoinPlus,
steemDollars,
digixDAO,
neo,
zCoin,
qtum,
gas,
populous,
binanceCoin,
bitcoinDiamond
]
array.append(contentsOf: Currency.currencies)
return array
}()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment