Skip to content

Commit

Permalink
- change testnet networktype to ghostnet
Browse files Browse the repository at this point in the history
- add a new network type for protocolnet, update references and logic
- bump sdwebimage cache
  • Loading branch information
simonmcl committed Jun 26, 2024
1 parent b5f65d9 commit 40d7e18
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
.package(name: "KukaiCryptoSwift", url: "https://github.com/kukai-wallet/kukai-crypto-swift", from: "1.0.23" /*.branch("develop")*/),
.package(name: "CustomAuth", url: "https://github.com/torusresearch/customauth-swift-sdk", from: "10.0.1"),
.package(name: "SignalRClient", url: "https://github.com/moozzyk/SignalR-Client-Swift", from: "0.8.0"),
.package(url: "https://github.com/SDWebImage/SDWebImage.git", from: "5.18.10")
.package(url: "https://github.com/SDWebImage/SDWebImage.git", from: "5.19.3")
],
targets: [
.target(
Expand Down
4 changes: 2 additions & 2 deletions Sources/KukaiCoreSwift/Clients/TezosDomainsClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class TezosDomainsClient {
dispatchGroup.leave()
}

getDomainFor(address: address, url: TezosNodeClientConfig.defaultTestnetURLs.tezosDomainsURL) { result in
getDomainFor(address: address, url: TezosNodeClientConfig.defaultGhostnetURLs.tezosDomainsURL) { result in
guard let res = try? result.get() else {
errorGhost = result.getFailure()
dispatchGroup.leave()
Expand Down Expand Up @@ -172,7 +172,7 @@ public class TezosDomainsClient {
dispatchGroup.leave()
}

getDomainsFor(addresses: addresses, url: TezosNodeClientConfig.defaultTestnetURLs.tezosDomainsURL) { result in
getDomainsFor(addresses: addresses, url: TezosNodeClientConfig.defaultGhostnetURLs.tezosDomainsURL) { result in
guard let res = try? result.get() else {
errorGhost = result.getFailure()
dispatchGroup.leave()
Expand Down
20 changes: 12 additions & 8 deletions Sources/KukaiCoreSwift/Models/Config/TezosNodeClientConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public struct TezosNodeClientConfig {
/// An enum indicating whether the network is mainnet or testnet
public enum NetworkType: String {
case mainnet
case testnet
case ghostnet
case protocolnet
}

/// Allow switching between local forging or remote forging+parsing
Expand Down Expand Up @@ -49,7 +50,7 @@ public struct TezosNodeClientConfig {
}

/// Preconfigured struct with all the URL's needed to work with Tezos testnet
public struct defaultTestnetURLs {
public struct defaultGhostnetURLs {

/// The default testnet URLs to use for estimating and injecting operations
public static let nodeURLs = [URL(string: "https://ghostnet.smartpy.io")!, URL(string: "https://rpc.ghostnet.tzboot.net")!]
Expand Down Expand Up @@ -141,13 +142,16 @@ public struct TezosNodeClientConfig {
tezosDomainsURL = TezosNodeClientConfig.defaultMainnetURLs.tezosDomainsURL
objktApiURL = TezosNodeClientConfig.defaultMainnetURLs.objktApiURL

case .testnet:
nodeURLs = TezosNodeClientConfig.defaultTestnetURLs.nodeURLs
case .ghostnet:
nodeURLs = TezosNodeClientConfig.defaultGhostnetURLs.nodeURLs
forgingType = .local
tzktURL = TezosNodeClientConfig.defaultTestnetURLs.tzktURL
betterCallDevURL = TezosNodeClientConfig.defaultTestnetURLs.betterCallDevURL
tezosDomainsURL = TezosNodeClientConfig.defaultTestnetURLs.tezosDomainsURL
objktApiURL = TezosNodeClientConfig.defaultTestnetURLs.objktApiURL
tzktURL = TezosNodeClientConfig.defaultGhostnetURLs.tzktURL
betterCallDevURL = TezosNodeClientConfig.defaultGhostnetURLs.betterCallDevURL
tezosDomainsURL = TezosNodeClientConfig.defaultGhostnetURLs.tezosDomainsURL
objktApiURL = TezosNodeClientConfig.defaultGhostnetURLs.objktApiURL

case .protocolnet:
fatalError("No defaults for networkType protocolnet. Must be user supplied")
}
}

Expand Down
10 changes: 5 additions & 5 deletions Sources/KukaiCoreSwift/Services/TorusAuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ public class TorusAuthService: NSObject {
aggregateVerifierType: verifierWrapper.verifierType,
aggregateVerifier: verifierWrapper.aggregateVerifierName ?? verifierWrapper.subverifier.verifier,
subVerifierDetails: [verifierWrapper.subverifier],
network: verifierWrapper.networkType == .testnet ? .legacy(.TESTNET) : .legacy(.MAINNET),
network: verifierWrapper.networkType == .mainnet ? .legacy(.MAINNET) : .legacy(.TESTNET),
loglevel: .error,
urlSession: self.networkService.urlSession,
networkUrl: verifierWrapper.networkType == .testnet ? "https://www.ankr.com/rpc/eth/eth_goerli" : nil)
networkUrl: verifierWrapper.networkType == .mainnet ? nil : "https://www.ankr.com/rpc/eth/eth_goerli")
}


Expand Down Expand Up @@ -317,7 +317,7 @@ public class TorusAuthService: NSObject {

/// Private wrapper to avoid duplication in the previous function
private func getPublicAddress(verifierName: String, verifierWrapper: SubverifierWrapper, socialUserId: String, completion: @escaping ((Result<String, KukaiError>) -> Void)) {
let isTestnet = (verifierWrapper.networkType == .testnet)
let isTestnet = (verifierWrapper.networkType != .mainnet)
self.fetchNodeDetails = NodeDetailManager(network: (isTestnet ? .legacy(.TESTNET) : .legacy(.MAINNET)), urlSession: networkService.urlSession)

Task {
Expand Down Expand Up @@ -457,10 +457,10 @@ extension TorusAuthService: ASAuthorizationControllerDelegate, ASAuthorizationCo
aggregateVerifierType: verifierWrapper.verifierType,
aggregateVerifier: verifierWrapper.aggregateVerifierName ?? verifierWrapper.subverifier.verifier,
subVerifierDetails: [verifierWrapper.subverifier],
network: verifierWrapper.networkType == .testnet ? .legacy(.TESTNET) : .legacy(.MAINNET),
network: verifierWrapper.networkType == .mainnet ? .legacy(.MAINNET) : .legacy(.TESTNET),
loglevel: .error,
urlSession: self.networkService.urlSession,
networkUrl: verifierWrapper.networkType == .testnet ? "https://www.ankr.com/rpc/eth/eth_goerli" : nil)
networkUrl: verifierWrapper.networkType == .mainnet ? nil : "https://www.ankr.com/rpc/eth/eth_goerli")

Task { @MainActor in
do {
Expand Down
2 changes: 1 addition & 1 deletion Tests/KukaiCoreSwiftTests/MockConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public struct MockConstants {
// MARK: - Init

private init() {
config = TezosNodeClientConfig(withDefaultsForNetworkType: .testnet)
config = TezosNodeClientConfig(withDefaultsForNetworkType: .ghostnet)
loggingConfig = LoggingConfig(logNetworkFailures: true, logNetworkSuccesses: true)

let sessionConfig = URLSessionConfiguration.ephemeral // Uses no caching / storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TezosNodeClientConfigTests: XCTestCase {
}

func testDefaults() {
let config1 = TezosNodeClientConfig(withDefaultsForNetworkType: .testnet)
let config1 = TezosNodeClientConfig(withDefaultsForNetworkType: .ghostnet)
XCTAssert(config1.nodeURLs[0].absoluteString == "https://ghostnet.smartpy.io", config1.nodeURLs[0].absoluteString)
XCTAssert(config1.nodeURLs[1].absoluteString == "https://rpc.ghostnet.tzboot.net", config1.nodeURLs[1].absoluteString)
XCTAssert(config1.betterCallDevURL.absoluteString == "https://api.better-call.dev/", config1.betterCallDevURL.absoluteString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ class WalletCacheServiceTests: XCTestCase {
XCTAssert(metadata1.hasMainnetDomain())
XCTAssert(metadata1.hasGhostnetDomain())
XCTAssert(metadata1.hasDomain(onNetwork: TezosNodeClientConfig.NetworkType.mainnet))
XCTAssert(metadata1.hasDomain(onNetwork: TezosNodeClientConfig.NetworkType.testnet))
XCTAssert(metadata1.hasDomain(onNetwork: TezosNodeClientConfig.NetworkType.ghostnet))
XCTAssert(metadata1.mainnetDomains?.first?.domain.name == "blah.tez")
XCTAssert(metadata1.ghostnetDomains?.first?.domain.name == "blah.gho")
XCTAssert(metadata1.primaryMainnetDomain()?.domain.name == "blah.tez")
XCTAssert(metadata1.primaryGhostnetDomain()?.domain.name == "blah.gho")
XCTAssert(metadata1.primaryDomain(onNetwork: .mainnet)?.domain.name == "blah.tez")
XCTAssert(metadata1.primaryDomain(onNetwork: .testnet)?.domain.name == "blah.gho")
XCTAssert(metadata1.primaryDomain(onNetwork: .ghostnet)?.domain.name == "blah.gho")



Expand Down

0 comments on commit 40d7e18

Please sign in to comment.