-
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 #50 from torusresearch/encapsulate_torusnetwork
refactor: implement web3authnetwork
- Loading branch information
Showing
11 changed files
with
110 additions
and
66 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
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,73 @@ | ||
public enum Web3AuthNetwork : Equatable, Hashable { | ||
case SAPPHIRE_DEVNET | ||
case SAPPHIRE_MAINNET | ||
case MAINNET | ||
case TESTNET | ||
case CYAN | ||
case AQUA | ||
case CELESTE | ||
|
||
public var path: String { | ||
return self.torusNetwork.path | ||
} | ||
|
||
public var name: String { | ||
return self.torusNetwork.name | ||
} | ||
|
||
public var signerMap: String { | ||
return self.torusNetwork.signerMap | ||
} | ||
|
||
public var isLegacy: Bool { | ||
if case .legacy(_) = torusNetwork { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
public var isSapphire: Bool { | ||
if case .sapphire(_) = torusNetwork { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
public var metadataMap: String { | ||
get throws { | ||
if case .legacy(let legacyNetwork) = torusNetwork { | ||
return legacyNetwork.metadataMap | ||
} | ||
|
||
if case .sapphire(let sapphireNetwork) = torusNetwork { | ||
if sapphireNetwork == .SAPPHIRE_MAINNET { | ||
return "https://node-1.node.web3auth.io/metadata" | ||
} else { | ||
return "https://node-1.dev-node.web3auth.io/metadata" | ||
} | ||
} | ||
|
||
throw FetchNodeError.InvalidNetwork(self.name) | ||
} | ||
} | ||
|
||
|
||
internal var torusNetwork: TorusNetwork { | ||
switch self { | ||
case .SAPPHIRE_DEVNET: | ||
return .sapphire(.SAPPHIRE_DEVNET) | ||
case .SAPPHIRE_MAINNET: | ||
return .sapphire(.SAPPHIRE_MAINNET) | ||
case .MAINNET: | ||
return .legacy(.MAINNET) | ||
case .TESTNET: | ||
return .legacy(.TESTNET) | ||
case .CYAN: | ||
return .legacy(.CYAN) | ||
case .AQUA: | ||
return .legacy(.AQUA) | ||
case .CELESTE: | ||
return .legacy(.CELESTE) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,35 +1,23 @@ | ||
PODS: | ||
- BigInt (5.0.0) | ||
- GenericJSON (2.0.2) | ||
- secp256k1.swift (0.1.4) | ||
- Torus-fetchNodeDetails (4.0.1): | ||
- web3.swift (~> 0.9.3) | ||
- web3.swift (0.9.3): | ||
- BigInt (~> 5.0.0) | ||
- GenericJSON (~> 2.0) | ||
- secp256k1.swift (~> 0.1) | ||
- BigInt (5.2.0) | ||
- Torus-fetchNodeDetails (7.0.0): | ||
- BigInt (~> 5.2.0) | ||
|
||
DEPENDENCIES: | ||
- Torus-fetchNodeDetails (from `../`) | ||
|
||
SPEC REPOS: | ||
trunk: | ||
- BigInt | ||
- GenericJSON | ||
- secp256k1.swift | ||
- web3.swift | ||
|
||
EXTERNAL SOURCES: | ||
Torus-fetchNodeDetails: | ||
:path: "../" | ||
|
||
SPEC CHECKSUMS: | ||
BigInt: 74b4d88367b0e819d9f77393549226d36faeb0d8 | ||
GenericJSON: 79a840eeb77030962e8cf02a62d36bd413b67626 | ||
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 | ||
Torus-fetchNodeDetails: a92d02f1bfe91bd61c90f92d64df023babaa5bfa | ||
web3.swift: c6c3bf1f853743f8a7a58d263e5f7e46545e22c7 | ||
BigInt: f668a80089607f521586bbe29513d708491ef2f7 | ||
Torus-fetchNodeDetails: d12f3511de52bdca33ccabf35f618c296edf94c5 | ||
|
||
PODFILE CHECKSUM: 33add72342a492adb43676625c404c97ced731da | ||
|
||
COCOAPODS: 1.11.3 | ||
COCOAPODS: 1.15.2 |
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