Skip to content

Commit

Permalink
add v13 support
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Apr 15, 2024
1 parent 0d2b539 commit 56c127a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 32 deletions.
21 changes: 16 additions & 5 deletions Sources/CommonSources/TorusNetwork.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,24 @@ public enum LegacyNetwork: Equatable, Hashable {

public var signerMap : String {
switch self {
case .MAINNET: return "https://signer.tor.us"
case .TESTNET: return "https://signer.tor.us"
case .CYAN: return "https://signer-polygon.tor.us"
case .AQUA: return "https://signer-polygon.tor.us"
case .CELESTE: return "https://signer-polygon.tor.us"
case .MAINNET: return "https://signer.web3auth.io"
case .TESTNET: return "https://signer.web3auth.io"
case .CYAN: return "https://signer-polygon.web3auth.io"
case .AQUA: return "https://signer-polygon.web3auth.io"
case .CELESTE: return "https://signer-polygon.web3auth.io"
case .CUSTOM(let path) : return path
}
}

public var metadataMap: String {
switch self {
case .MAINNET: return "https://metadata.web3auth.io"
case .TESTNET: return "https://metadata.web3auth.io"
case .CYAN: return "https://metadata.web3auth.io"
case .AQUA: return "https://metadata.web3auth.io"
case .CELESTE: return "https://metadata.web3auth.io"
case .CUSTOM(let path): return path
}
}
}

16 changes: 0 additions & 16 deletions Sources/FetchNodeDetails/Constants/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,3 @@ public typealias TORUS_NETWORK_TYPE = String


let MULTI_CLUSTER_NETWORKS: [LegacyNetwork] = [.CELESTE]

let NETWORK_MAP: [LegacyNetwork: String] = [
.MAINNET: "mainnet",
.TESTNET: "goerli",
.CYAN: "polygon-mainnet",
.AQUA: "polygon-mainnet",
.CELESTE: "polygon-mainnet"
]

let SIGNER_MAP: [LegacyNetwork: String] = [
.MAINNET: "https://signer.tor.us",
.TESTNET: "https://signer.tor.us",
.CYAN: "https://signer-polygon.tor.us",
.AQUA: "https://signer-polygon.tor.us",
.CELESTE: "https://signer-polygon.tor.us"
]
11 changes: 10 additions & 1 deletion Sources/FetchNodeDetails/NodeDetailManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var fndLogType = OSLogType.default

open class NodeDetailManager {

private var fndServerEndpoint = "https://fnd.tor.us/node-details"
private var fndServerEndpoint = "https://fnd.web3auth.io/node-details"
private var currentEpoch: String = "0"
private var torusNodeEndpoints = [String]()
private var torusNodePub: [TorusNodePubModel] = []
Expand Down Expand Up @@ -67,5 +67,14 @@ open class NodeDetailManager {
return fndResult
}

public func getMetadataUrl() async throws -> String {
switch network {
case .legacy(let legacyNetwork):
return legacyNetwork.metadataMap
case .sapphire(_):
return try await self.getNodeDetails(verifier: "test-verifier", verifierID: "test-verifier-id").torusNodeEndpoints[0].replacingOccurrences(of: "/sss/jrpc", with: "/metadata")
}
}

// setNodeDetails is defined in AllNodeDetailsModel because of accessibility of variables
}
20 changes: 10 additions & 10 deletions Sources/FndBase/Endpoints/Endpoints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import CommonSources

let SAPPHIRE_NETWORK_URLS: [SapphireNetwork: [String]] = [
.SAPPHIRE_DEVNET: [
"https://sapphire-dev-2-1.authnetwork.dev",
"https://sapphire-dev-2-2.authnetwork.dev",
"https://sapphire-dev-2-3.authnetwork.dev",
"https://sapphire-dev-2-4.authnetwork.dev",
"https://sapphire-dev-2-5.authnetwork.dev",
"https://node-1.dev-node.web3auth.io",
"https://node-2.dev-node.web3auth.io",
"https://node-3.dev-node.web3auth.io",
"https://node-4.dev-node.web3auth.io",
"https://node-5.dev-node.web3auth.io",
],
.SAPPHIRE_MAINNET: [
"https://sapphire-1.auth.network",
"https://sapphire-2.auth.network",
"https://sapphire-3.auth.network",
"https://sapphire-4.auth.network",
"https://sapphire-5.auth.network",
"https://node-1.node.web3auth.io",
"https://node-2.node.web3auth.io",
"https://node-3.node.web3auth.io",
"https://node-4.node.web3auth.io",
"https://node-5.node.web3auth.io",
],
]

Expand Down
12 changes: 12 additions & 0 deletions Tests/FetchNodeDetailsTests/fetchNodeDetailsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ class fetchNodeDetailsTests: XCTestCase {
let result = try await fnd.getNodeDetails(verifier: "google", verifierID: "[email protected]")
XCTAssertEqual(result, SampleOutputCeleste().val)
}

func test_getMetadata_Mainnet() async throws {
let fnd = NodeDetailManager(network: .legacy(.MAINNET))
let result = try await fnd.getMetadataUrl()
XCTAssertEqual(result, "https://metadata.web3auth.io")
}

func test_getMetadata_SapphireMainnet() async throws {
let fnd = NodeDetailManager(network: .sapphire(.SAPPHIRE_MAINNET))
let result = try await fnd.getMetadataUrl()
XCTAssertEqual(result, SampleOutputSAPPHIREMAINNET().val.torusNodeEndpoints[0].replacingOccurrences(of: "/sss/jrpc", with: "/metadata"))
}
}

0 comments on commit 56c127a

Please sign in to comment.