Skip to content

Commit

Permalink
[WIP] Add WSS Links for Infura (trustwallet#762)
Browse files Browse the repository at this point in the history
* add wss links for Infura

* remove trailing whitespace

* Make WSS switch exhaustive
  • Loading branch information
mishfit authored and vikmeup committed Jun 12, 2018
1 parent 4b6fb9a commit 12c5158
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Trust/Browser/Factory/WKWebViewConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ extension WKWebViewConfiguration {
"""
const addressHex = "\(address)"
const rpcURL = "\(sessionConfig.server.rpcURL.absoluteString)"
const wssURL = "\(sessionConfig.server.wssURL.absoluteString)"
const chainID = "\(sessionConfig.chainID)"
function executeCallback (id, error, value) {
Trust.executeCallback(id, error, value)
}
Trust.init(rpcURL, {
Trust.init({
rpcURL,
wssURL,
getAccounts: function (cb) { cb(null, [addressHex]) },
processTransaction: function (tx, cb){
console.log('signing a transaction', tx)
Expand Down
2 changes: 1 addition & 1 deletion Trust/Settings/Types/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Config {
static let testNetworkWarningOff = "testNetworkWarningOff"
}

static let dbMigrationSchemaVersion: UInt64 = 53
static let dbMigrationSchemaVersion: UInt64 = 54

static let current: Config = Config()

Expand Down
13 changes: 8 additions & 5 deletions Trust/Settings/Types/CustomRPC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ class CustomRPC: Object {
@objc dynamic var name: String = ""
@objc dynamic var symbol: String = ""
@objc dynamic var endpoint: String = ""
@objc dynamic var wssEndpoint: String = ""
@objc dynamic var id: String = UUID().uuidString

convenience init(
chainID: Int = 0,
name: String = "",
symbol: String = "",
endpoint: String = ""
) {
chainID: Int = 0,
name: String = "",
symbol: String = "",
endpoint: String = "",
wssEndpoint: String = ""
) {
self.init()
self.chainID = chainID
self.name = name
self.symbol = symbol
self.endpoint = endpoint
self.wssEndpoint = wssEndpoint
}

override class func primaryKey() -> String? {
Expand Down
15 changes: 15 additions & 0 deletions Trust/Settings/Types/RPCServers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ enum RPCServer {
}()
return URL(string: urlString)!
}

var wssURL: URL {
let urlString: String = {
switch self {
case .main: return "wss://mainnet.infura.io/ws/llyrtzQ3YhkdESt2Fzrk"
case .ropsten: return "wss://ropsten.infura.io/ws/llyrtzQ3YhkdESt2Fzrk"
case .rinkeby: return "wss://rinkeby.infura.io/ws/llyrtzQ3YhkdESt2Fzrk"
case .kovan: return "wss://kovan.infura.io/ws/llyrtzQ3YhkdESt2Fzrk"
case .poa, .sokol: return ""
case .classic, .callisto: return ""
case .custom(let custom): return custom.wssEndpoint
}
}()
return URL(string: urlString)!
}

var remoteURL: URL {
let urlString: String = {
Expand Down

0 comments on commit 12c5158

Please sign in to comment.