Add Sokol network support

pull/2/head
Michael Scoff 7 years ago
parent d4097ca4a9
commit 22a9432ccb
  1. 4
      Trust/Core/ViewModels/InCoordinatorViewModel.swift
  2. 4
      Trust/Exchange/Types/ExchangeConfig.swift
  3. 2
      Trust/Exchange/Types/ExchangeTokens.swift
  4. 2
      Trust/Settings/Types/Config.swift
  5. 4
      Trust/Settings/Types/ConfigExplorer.swift
  6. 9
      Trust/Settings/Types/RPCServers.swift
  7. 2
      Trust/Settings/ViewControllers/SettingsViewController.swift
  8. 1
      Trust/Settings/ViewModels/SettingsViewModel.swift
  9. 2
      Trust/Tokens/Types/TokensDataStore.swift
  10. 2
      Trust/Transactions/ViewModels/TransactionDetailsViewModel.swift
  11. 2
      Trust/Transactions/ViewModels/TransactionsViewModel.swift

@ -12,7 +12,7 @@ struct InCoordinatorViewModel {
var tokensAvailable: Bool { var tokensAvailable: Bool {
switch config.server { switch config.server {
case .main, .classic, .kovan, .ropsten, .poa: return true case .main, .classic, .kovan, .ropsten, .poa, .sokol: return true
} }
} }
@ -22,7 +22,7 @@ struct InCoordinatorViewModel {
var exchangeAvailable: Bool { var exchangeAvailable: Bool {
switch config.server { switch config.server {
case .main, .classic, .ropsten, .poa: return false case .main, .classic, .ropsten, .poa, .sokol: return false
case .kovan: return false //config.isDebugEnabled case .kovan: return false //config.isDebugEnabled
} }
} }

@ -13,7 +13,7 @@ struct ExchangeConfig {
var contract: Address? { var contract: Address? {
switch server { switch server {
case .main, .classic, .poa, .ropsten: case .main, .classic, .poa, .ropsten, .sokol:
return nil return nil
case .kovan: case .kovan:
return Address(string: "0x9044968086e365216cc9e441a8e2cea300dd7228") return Address(string: "0x9044968086e365216cc9e441a8e2cea300dd7228")
@ -22,7 +22,7 @@ struct ExchangeConfig {
var tokenAddress: Address { var tokenAddress: Address {
switch server { switch server {
case .main, .classic, .poa, .ropsten: case .main, .classic, .poa, .ropsten, .sokol:
return Address(string: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") return Address(string: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
case .kovan: case .kovan:
return Address(string: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") return Address(string: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")

@ -6,7 +6,7 @@ import TrustKeystore
struct ExchangeTokens { struct ExchangeTokens {
static func get(for server: RPCServer) -> [ExchangeToken] { static func get(for server: RPCServer) -> [ExchangeToken] {
switch server { switch server {
case .main, .classic, .ropsten, .poa: case .main, .classic, .ropsten, .poa, .sokol:
return [ return [
ExchangeToken(name: "Ethereum", address: Address(string: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"), symbol: "ETH", image: R.image.token_eth(), decimals: 18), ExchangeToken(name: "Ethereum", address: Address(string: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"), symbol: "ETH", image: R.image.token_eth(), decimals: 18),
] ]

@ -69,6 +69,7 @@ struct Config {
case .kovan: return "https://kovan.infura.io/llyrtzQ3YhkdESt2Fzrk" case .kovan: return "https://kovan.infura.io/llyrtzQ3YhkdESt2Fzrk"
case .ropsten: return "https://ropsten.infura.io/llyrtzQ3YhkdESt2Fzrk" case .ropsten: return "https://ropsten.infura.io/llyrtzQ3YhkdESt2Fzrk"
case .poa: return "https://core.poa.network" case .poa: return "https://core.poa.network"
case .sokol: return "https://sokol.poa.network"
} }
}() }()
return URL(string: urlString)! return URL(string: urlString)!
@ -82,6 +83,7 @@ struct Config {
case .kovan: return "https://kovan.trustwalletapp.com" case .kovan: return "https://kovan.trustwalletapp.com"
case .ropsten: return "https://ropsten.trustwalletapp.com" case .ropsten: return "https://ropsten.trustwalletapp.com"
case .poa: return "https://poa.trustwalletapp.com" case .poa: return "https://poa.trustwalletapp.com"
case .sokol: return "https://trust-sokol.herokuapp.com"
} }
}() }()
return URL(string: urlString)! return URL(string: urlString)!

@ -26,6 +26,8 @@ struct ConfigExplorer {
return endpoint + "/tx/" + ID return endpoint + "/tx/" + ID
case .poa: case .poa:
return endpoint + "/tx/" + ID return endpoint + "/tx/" + ID
case .sokol:
return endpoint + "/txid/search/" + ID
} }
}() }()
return URL(string: urlString)! return URL(string: urlString)!
@ -42,6 +44,8 @@ struct ConfigExplorer {
case .ropsten: case .ropsten:
return "https://ropsten.etherscan.io" return "https://ropsten.etherscan.io"
case .poa: case .poa:
return "https://poaexplorer.com"
case .sokol:
return "http://testnet.oracles.org:4000" return "http://testnet.oracles.org:4000"
} }
} }

@ -7,6 +7,7 @@ enum RPCServer: String {
case kovan case kovan
case ropsten case ropsten
case poa case poa
case sokol
case classic case classic
var chainID: Int { var chainID: Int {
@ -15,6 +16,7 @@ enum RPCServer: String {
case .kovan: return 42 case .kovan: return 42
case .ropsten: return 3 case .ropsten: return 3
case .poa: return 99 case .poa: return 99
case .sokol: return 77
case .classic: return 61 case .classic: return 61
} }
} }
@ -25,6 +27,7 @@ enum RPCServer: String {
case .kovan: return "Kovan" case .kovan: return "Kovan"
case .ropsten: return "Ropsten" case .ropsten: return "Ropsten"
case .poa: return "POA Network" case .poa: return "POA Network"
case .sokol: return "Sokol"
case .classic: return "Ethereum Classic" case .classic: return "Ethereum Classic"
} }
} }
@ -32,7 +35,7 @@ enum RPCServer: String {
var isTestNetwork: Bool { var isTestNetwork: Bool {
switch self { switch self {
case .main, .poa, .classic: return false case .main, .poa, .classic: return false
case .kovan, .ropsten: return true case .kovan, .ropsten, .sokol: return true
} }
} }
@ -41,7 +44,7 @@ enum RPCServer: String {
case .main: return "ETH" case .main: return "ETH"
case .classic: return "ETC" case .classic: return "ETC"
case .kovan, .ropsten: return "ETH" case .kovan, .ropsten: return "ETH"
case .poa: return "POA" case .poa, .sokol: return "POA"
} }
} }
@ -57,6 +60,7 @@ enum RPCServer: String {
case RPCServer.kovan.name: return .kovan case RPCServer.kovan.name: return .kovan
case RPCServer.ropsten.name: return .ropsten case RPCServer.ropsten.name: return .ropsten
case RPCServer.poa.name: return .poa case RPCServer.poa.name: return .poa
case RPCServer.sokol.name: return .sokol
default: return .main default: return .main
} }
}() }()
@ -70,6 +74,7 @@ enum RPCServer: String {
case RPCServer.kovan.chainID: return .kovan case RPCServer.kovan.chainID: return .kovan
case RPCServer.ropsten.chainID: return .ropsten case RPCServer.ropsten.chainID: return .ropsten
case RPCServer.poa.chainID: return .poa case RPCServer.poa.chainID: return .poa
case RPCServer.sokol.chainID: return .sokol
default: return .main default: return .main
} }
}() }()

@ -72,7 +72,7 @@ class SettingsViewController: FormViewController {
selectorController.sectionKeyForValue = { option in selectorController.sectionKeyForValue = { option in
switch option { switch option {
case .main, .classic, .poa: return "" case .main, .classic, .poa: return ""
case .kovan, .ropsten: return NSLocalizedString("settings.network.test.label.title", value: "Test", comment: "") case .kovan, .ropsten, .sokol: return NSLocalizedString("settings.network.test.label.title", value: "Test", comment: "")
} }
} }
}.cellSetup { cell, _ in }.cellSetup { cell, _ in

@ -19,6 +19,7 @@ struct SettingsViewModel {
RPCServer.poa, RPCServer.poa,
RPCServer.kovan, RPCServer.kovan,
RPCServer.ropsten, RPCServer.ropsten,
RPCServer.sokol,
] ]
} }

@ -89,7 +89,7 @@ class TokensDataStore {
} }
} }
updatePrices() updatePrices()
case .classic, .kovan, .poa, .ropsten: case .classic, .kovan, .poa, .ropsten, .sokol:
updatePrices() updatePrices()
refreshBalance() refreshBalance()
} }

@ -52,7 +52,7 @@ struct TransactionDetailsViewModel {
var detailsAvailable: Bool { var detailsAvailable: Bool {
switch config.server { switch config.server {
case .main, .classic, .kovan, .ropsten: return true case .main, .classic, .kovan, .ropsten: return true
case .poa: return false case .poa, .sokol: return false
} }
} }

@ -83,7 +83,7 @@ struct TransactionsViewModel {
var isBuyActionAvailable: Bool { var isBuyActionAvailable: Bool {
switch config.server { switch config.server {
case .main: return true case .main: return true
case .kovan, .classic, .ropsten, .poa: return false case .kovan, .classic, .ropsten, .poa, .sokol: return false
} }
} }
} }

Loading…
Cancel
Save