-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from torusresearch/alpha
Release 5.0.0
- Loading branch information
Showing
27 changed files
with
747 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by CW Lee on 10/07/2023. | ||
// | ||
|
||
import Foundation | ||
|
||
/// An error that occurs during the decoding of a value. | ||
public enum FetchNodeError : Error { | ||
case InvalidNetwork(String) | ||
case InvalidMigrationNetwork(String) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by CW Lee on 10/07/2023. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
public struct LegacyNetworkMigrationInfo { | ||
public var migrationCompleted: Bool | ||
public var networkIdentifier: String | ||
public var networkMigratedTo: SapphireNetwork | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import Foundation | ||
import BigInt | ||
|
||
public struct AllNodeDetailsModel:Equatable, Decodable { | ||
public static func == (lhs : AllNodeDetailsModel, rhs : AllNodeDetailsModel) -> Bool { | ||
return lhs.currentEpoch == rhs.currentEpoch && lhs.torusNodeEndpoints == rhs.torusNodeEndpoints && lhs.torusNodePub == rhs.torusNodePub && lhs.currentEpoch == rhs.currentEpoch && lhs.torusIndexes == rhs.torusIndexes && lhs.updated == rhs.updated | ||
} | ||
|
||
public var currentEpoch : String | ||
public var torusNodeEndpoints : Array<String> | ||
public var torusNodeSSSEndpoints : Array<String> | ||
public var torusNodeRSSEndpoints : Array<String> | ||
public var torusNodeTSSEndpoints : Array<String> | ||
public var torusIndexes : Array<BigUInt> | ||
public var torusNodePub : Array<TorusNodePubModel> | ||
public var updated = false | ||
|
||
public enum CodingKeys: String, CodingKey { | ||
case currentEpoch = "currentEpoch" | ||
case torusNodeEndpoints = "torusNodeEndpoints" | ||
case torusNodeSSSEndpoints = "torusNodeSSSEndpoints" | ||
case torusNodeRSSEndpoints = "torusNodeRSSEndpoints" | ||
case torusNodeTSSEndpoints = "torusNodeTSSEndpoints" | ||
case torusIndexes = "torusIndexes" | ||
case torusNodePub = "torusNodePub" | ||
case updated = "updated" | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
currentEpoch = try container.decode(String.self, forKey: .currentEpoch) | ||
torusNodeEndpoints = try container.decode([String].self, forKey: .torusNodeEndpoints) | ||
torusNodeSSSEndpoints = try container.decodeIfPresent([String].self, forKey: .torusNodeSSSEndpoints) ?? [] | ||
torusNodeRSSEndpoints = try container.decodeIfPresent([String].self, forKey: .torusNodeRSSEndpoints) ?? [] | ||
torusNodeTSSEndpoints = try container.decodeIfPresent([String].self, forKey: .torusNodeTSSEndpoints) ?? [] | ||
// Decode torusIndexes as [Int] | ||
let torusIndexesInt = try container.decode([Int].self, forKey: .torusIndexes) | ||
|
||
// Convert [Int] to Array<BigUInt> | ||
torusIndexes = torusIndexesInt.map { BigUInt($0) } | ||
torusNodePub = try container.decode([TorusNodePubModel].self, forKey: .torusNodePub) | ||
updated = try container.decodeIfPresent(Bool.self, forKey: .updated) ?? false | ||
} | ||
|
||
public init(_currentEpoch : String, _torusNodeEndpoints : Array<String>, _torusNodeSSSEndpoints : Array<String> = [], _torusNodeRSSEndpoints : Array<String> = [], _torusNodeTSSEndpoints : Array<String> = [], _torusIndexes : Array<BigUInt>, _torusNodePub : Array<TorusNodePubModel>, _updated : Bool = false) { | ||
self.currentEpoch = _currentEpoch; | ||
self.torusNodeSSSEndpoints = _torusNodeSSSEndpoints; | ||
self.torusNodeRSSEndpoints = _torusNodeRSSEndpoints; | ||
self.torusNodeTSSEndpoints = _torusNodeTSSEndpoints; | ||
self.torusNodeEndpoints = _torusNodeEndpoints; | ||
self.torusIndexes = _torusIndexes; | ||
self.torusNodePub = _torusNodePub; | ||
self.updated = _updated; | ||
} | ||
|
||
public func getTorusIndexes() -> Array<BigUInt> { | ||
return self.torusIndexes; | ||
} | ||
|
||
public mutating func setTorusIndexes(torusIndexes : Array<BigUInt>){ | ||
self.torusIndexes = torusIndexes | ||
} | ||
|
||
public func getUpdated() -> Bool { | ||
return updated | ||
} | ||
|
||
public mutating func setUpdated(updated : Bool){ | ||
self.updated = updated | ||
} | ||
|
||
public mutating func getCurrentEpoch() -> String{ | ||
return currentEpoch | ||
} | ||
|
||
public mutating func setCurrentEpoch( currentEpoch : String) { | ||
self.currentEpoch = currentEpoch; | ||
} | ||
|
||
public func getTorusNodeEndpoints() -> Array<String> { | ||
return torusNodeEndpoints | ||
} | ||
|
||
public mutating func setTorusNodeEndpoints(torusNodeEndpoints : Array<String>) { | ||
self.torusNodeEndpoints = torusNodeEndpoints | ||
} | ||
|
||
public func getTorusNodePub() -> Array<TorusNodePubModel> { | ||
return torusNodePub | ||
} | ||
|
||
public mutating func setTorusNodePub(torusNodePub : Array<TorusNodePubModel>) { | ||
self.torusNodePub = torusNodePub | ||
} | ||
|
||
public func getTorusNodeSSSEndpoints() -> Array<String> { | ||
return torusNodeSSSEndpoints | ||
} | ||
|
||
public mutating func setTorusNodeSSSEndpoints(torusNodeSSSEndpoints : Array<String>) { | ||
self.torusNodeSSSEndpoints = torusNodeSSSEndpoints | ||
} | ||
|
||
public func getTorusNodeRSSEndpoints() -> Array<String> { | ||
return torusNodeRSSEndpoints | ||
} | ||
|
||
public mutating func setTorusNodeRSSEndpoints(torusNodeRSSEndpoints : Array<String>) { | ||
self.torusNodeRSSEndpoints = torusNodeRSSEndpoints | ||
} | ||
|
||
public func getTorusNodeTSSEndpoints() -> Array<String> { | ||
return torusNodeTSSEndpoints | ||
} | ||
|
||
public mutating func setTorusNodeTSSEndpoints(torusNodeTSSEndpoints : Array<String>) { | ||
self.torusNodeTSSEndpoints = torusNodeTSSEndpoints | ||
} | ||
|
||
public mutating func setNodeDetails(nodeDetails: AllNodeDetailsModel) { | ||
self.torusNodeEndpoints = nodeDetails.torusNodeEndpoints | ||
self.torusNodeSSSEndpoints = nodeDetails.torusNodeSSSEndpoints | ||
self.torusNodeRSSEndpoints = nodeDetails.torusNodeRSSEndpoints | ||
self.torusNodeTSSEndpoints = nodeDetails.torusNodeTSSEndpoints | ||
self.torusNodePub = nodeDetails.torusNodePub | ||
self.torusIndexes = nodeDetails.torusIndexes | ||
self.currentEpoch = nodeDetails.currentEpoch | ||
self.updated = true | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
public struct NodeDetailsResponse: Decodable { | ||
private let nodeDetails: AllNodeDetailsModel | ||
|
||
public init(nodeDetails: AllNodeDetailsModel) { | ||
self.nodeDetails = nodeDetails | ||
} | ||
|
||
public func getNodeDetails() -> AllNodeDetailsModel { | ||
return nodeDetails | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...odeDetails/Models/TorusNodePubModel.swift → ...monSources/Models/TorusNodePubModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import Foundation | ||
|
||
public enum TorusNetwork : Equatable, Hashable { | ||
case legacy(LegacyNetwork) | ||
case sapphire(SapphireNetwork) | ||
|
||
public var name : String { | ||
switch self { | ||
case .legacy(let network) : | ||
return network.name | ||
case .sapphire(let network) : | ||
return network.name | ||
} | ||
} | ||
|
||
public var path : String { | ||
switch self { | ||
case .legacy(let network) : | ||
return network.path | ||
case .sapphire(let network) : | ||
return network.path | ||
} | ||
} | ||
} | ||
|
||
public enum SapphireNetwork: Equatable, Hashable { | ||
case SAPPHIRE_DEVNET | ||
case SAPPHIRE_MAINNET | ||
|
||
public var path: String { | ||
switch self { | ||
case .SAPPHIRE_DEVNET: | ||
return "sapphire_devnet" | ||
case .SAPPHIRE_MAINNET: | ||
return "sapphire_mainnet" | ||
} | ||
} | ||
|
||
public var name: String { | ||
switch self { | ||
case .SAPPHIRE_DEVNET: | ||
return "sapphire_devnet" | ||
case .SAPPHIRE_MAINNET: | ||
return "sapphire_mainnet" | ||
} | ||
} | ||
} | ||
|
||
public enum LegacyNetwork: Equatable, Hashable { | ||
case MAINNET | ||
case TESTNET | ||
case CYAN | ||
case AQUA | ||
case CELESTE | ||
case CUSTOM(path: String) | ||
|
||
public var path: String { | ||
switch self { | ||
case .MAINNET: | ||
return "mainnet" | ||
case .TESTNET: | ||
return "goerli" | ||
case .CYAN, .AQUA, .CELESTE: | ||
return "polygon-mainnet" | ||
case let .CUSTOM(path): | ||
return path | ||
} | ||
} | ||
|
||
public var name: String { | ||
switch self { | ||
case .MAINNET: | ||
return "mainnet" | ||
case .TESTNET: | ||
return "testnet" | ||
case .CYAN : | ||
return "cyan" | ||
case .AQUA : | ||
return "aqua" | ||
case .CELESTE: | ||
return "celeste" | ||
case .CUSTOM(_): | ||
return "custom" | ||
} | ||
} | ||
|
||
public var migration_map: LegacyNetworkMigrationInfo { | ||
switch self { | ||
case .MAINNET: | ||
return LegacyNetworkMigrationInfo(migrationCompleted: true, networkIdentifier: self.name, networkMigratedTo: SapphireNetwork.SAPPHIRE_MAINNET) | ||
case .TESTNET: | ||
return LegacyNetworkMigrationInfo(migrationCompleted: true, networkIdentifier: "teal", networkMigratedTo: SapphireNetwork.SAPPHIRE_DEVNET) | ||
case .CYAN : | ||
return LegacyNetworkMigrationInfo(migrationCompleted: false, networkIdentifier: self.name, networkMigratedTo: SapphireNetwork.SAPPHIRE_MAINNET) | ||
case .AQUA : | ||
return LegacyNetworkMigrationInfo(migrationCompleted: false, networkIdentifier: self.name, networkMigratedTo: SapphireNetwork.SAPPHIRE_MAINNET) | ||
case .CELESTE: | ||
return LegacyNetworkMigrationInfo(migrationCompleted: false, networkIdentifier: self.name, networkMigratedTo: SapphireNetwork.SAPPHIRE_MAINNET) | ||
case .CUSTOM(_): | ||
return LegacyNetworkMigrationInfo(migrationCompleted: false, networkIdentifier: self.name, networkMigratedTo: SapphireNetwork.SAPPHIRE_MAINNET) | ||
} | ||
} | ||
|
||
public var networkMap : String { | ||
switch self { | ||
case .MAINNET: return "mainnet" | ||
case .TESTNET: return "goerli" | ||
case .CYAN: return "polygon-mainnet" | ||
case .AQUA: return "polygon-mainnet" | ||
case .CELESTE: return "polygon-mainnet" | ||
case .CUSTOM(let path) : return path | ||
} | ||
} | ||
|
||
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 .CUSTOM(let path) : return path | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.