From 56c127a9adbb6dbbe5afd99bf6f447afc1a8f8b2 Mon Sep 17 00:00:00 2001 From: Chaitanya Potti Date: Mon, 15 Apr 2024 22:15:23 +0800 Subject: [PATCH] add v13 support --- Sources/CommonSources/TorusNetwork.swift | 21 ++++++++++++++----- .../Constants/Constants.swift | 16 -------------- .../FetchNodeDetails/NodeDetailManager.swift | 11 +++++++++- Sources/FndBase/Endpoints/Endpoints.swift | 20 +++++++++--------- .../fetchNodeDetailsTests.swift | 12 +++++++++++ 5 files changed, 48 insertions(+), 32 deletions(-) diff --git a/Sources/CommonSources/TorusNetwork.swift b/Sources/CommonSources/TorusNetwork.swift index 582e4c2..32e2e66 100644 --- a/Sources/CommonSources/TorusNetwork.swift +++ b/Sources/CommonSources/TorusNetwork.swift @@ -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 + } + } } diff --git a/Sources/FetchNodeDetails/Constants/Constants.swift b/Sources/FetchNodeDetails/Constants/Constants.swift index 8b9ded3..22a005c 100644 --- a/Sources/FetchNodeDetails/Constants/Constants.swift +++ b/Sources/FetchNodeDetails/Constants/Constants.swift @@ -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" -] diff --git a/Sources/FetchNodeDetails/NodeDetailManager.swift b/Sources/FetchNodeDetails/NodeDetailManager.swift index db77171..de0681d 100644 --- a/Sources/FetchNodeDetails/NodeDetailManager.swift +++ b/Sources/FetchNodeDetails/NodeDetailManager.swift @@ -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] = [] @@ -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 } diff --git a/Sources/FndBase/Endpoints/Endpoints.swift b/Sources/FndBase/Endpoints/Endpoints.swift index bd6e52f..4a7a651 100644 --- a/Sources/FndBase/Endpoints/Endpoints.swift +++ b/Sources/FndBase/Endpoints/Endpoints.swift @@ -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", ], ] diff --git a/Tests/FetchNodeDetailsTests/fetchNodeDetailsTests.swift b/Tests/FetchNodeDetailsTests/fetchNodeDetailsTests.swift index 64e3eea..b859ddb 100644 --- a/Tests/FetchNodeDetailsTests/fetchNodeDetailsTests.swift +++ b/Tests/FetchNodeDetailsTests/fetchNodeDetailsTests.swift @@ -64,4 +64,16 @@ class fetchNodeDetailsTests: XCTestCase { let result = try await fnd.getNodeDetails(verifier: "google", verifierID: "hello@tor.us") 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")) + } }