Skip to content

Commit

Permalink
Merge branch 'feature/stability_improvements' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Jun 27, 2024
2 parents 20bd38d + 6393d10 commit 1cabdaa
Show file tree
Hide file tree
Showing 22 changed files with 49 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Kukai Mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2792,7 +2792,7 @@
repositoryURL = "https://github.com/WalletConnect/WalletConnectSwiftV2";
requirement = {
kind = exactVersion;
version = 1.18.8;
version = 1.19.4;
};
};
C07A2DEE2AEA76BF00550E32 /* XCRemoteSwiftPackageReference "Starscream" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"location" : "https://github.com/kukai-wallet/kukai-core-swift",
"state" : {
"branch" : "develop",
"revision" : "b5f65d9e8f9a4041f74a7265be3e2e3a07212148"
"revision" : "f1b5a0cbac1b55fa78813f697f13b3f2f700cfae"
}
},
{
Expand Down Expand Up @@ -177,8 +177,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/WalletConnect/WalletConnectSwiftV2",
"state" : {
"revision" : "d819f76df8664a7550e31c03e9c4e68e990d7e91",
"version" : "1.18.8"
"revision" : "4736c2be84dcb136aeccf7111e67ab7cff513a7e",
"version" : "1.19.4"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
if DependencyManager.shared.currentNetworkType == .mainnet {
DependencyManager.shared.setDefaultMainnetURLs()
} else {
DependencyManager.shared.setDefaultTestnetURLs()
DependencyManager.shared.setDefaultGhostnetURLs()
}

return true
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Modules/Account/AccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ extension AccountViewController: UITableViewCellButtonDelegate {
func tableViewCellButtonTapped(sender: UIButton) {
switch sender.accessibilityIdentifier {
case AccountViewModel.accessibilityIdentifiers.onramp:
if DependencyManager.shared.currentNetworkType == .testnet {
if DependencyManager.shared.currentNetworkType == .ghostnet {
UIApplication.shared.open(DependencyManager.ghostnetFaucetLink)

} else {
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Modules/Account/AccountViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class AccountViewModel: ViewModel, UITableViewDiffableDataSourceHandler {

let metadata = DependencyManager.shared.selectedWalletMetadata
let parentMetadata = metadata?.isChild == true ? DependencyManager.shared.walletList.parentMetadata(forChildAddress: metadata?.address ?? "") : nil
let isTestnet = DependencyManager.shared.currentNetworkType == .testnet
let isTestnet = DependencyManager.shared.currentNetworkType == .ghostnet
var snapshot = NSDiffableDataSourceSnapshot<Int, AnyHashable>()
var data: [AnyHashable] = []

Expand Down
4 changes: 2 additions & 2 deletions Kukai Mobile/Modules/Account/TokenDetailsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public class TokenDetailsViewModel: ViewModel, TokenDetailsChartCellDelegate {
]

// TODO: remove testnet check in future when remote serivce supports ghostnet
if balanceAndBakerData?.isDelegationPossible == true && balanceAndBakerData?.isDelegated == true && DependencyManager.shared.currentNetworkType != .testnet {
if balanceAndBakerData?.isDelegationPossible == true && balanceAndBakerData?.isDelegated == true && DependencyManager.shared.currentNetworkType != .ghostnet {
data.append(stakingRewardLoadingData)
}

Expand Down Expand Up @@ -285,7 +285,7 @@ public class TokenDetailsViewModel: ViewModel, TokenDetailsChartCellDelegate {
}

// TODO: remove testnet check in future when remote serivce supports ghostnet
if balanceAndBakerData?.isDelegationPossible == true && balanceAndBakerData?.isDelegated == true && DependencyManager.shared.currentNetworkType != .testnet {
if balanceAndBakerData?.isDelegationPossible == true && balanceAndBakerData?.isDelegated == true && DependencyManager.shared.currentNetworkType != .ghostnet {
loadBakerData { [weak self] result in
guard let self = self else { return }

Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Modules/Activity/ActivityViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class ActivityViewModel: ViewModel, UITableViewDiffableDataSourceHandler {
}

// Build snapshot
let isTestnet = DependencyManager.shared.currentNetworkType == .testnet
let isTestnet = DependencyManager.shared.currentNetworkType == .ghostnet
currentSnapshot = NSDiffableDataSourceSnapshot<Int, AnyHashable>()
var data: [[AnyHashable]] = [[]]

Expand Down
8 changes: 2 additions & 6 deletions Kukai Mobile/Modules/Activity/Cells/ActivityToolbarCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import UIKit
class ActivityToolbarCell: UITableViewCell {

@IBAction func viewInExplorerTapped(_ sender: CustomisableButton) {
let tzktAPIURLString = DependencyManager.shared.tezosClientConfig.tzktURL.absoluteString
let stripAPI = tzktAPIURLString.replacingOccurrences(of: "api.", with: "")

if let websiteURL = URL(string: stripAPI)?.appending(path: DependencyManager.shared.selectedWalletAddress ?? "").appending(path: "operations") {
UIApplication.shared.open(websiteURL)
}
let tzktAPIURLString = DependencyManager.shared.currentExplorerURL
UIApplication.shared.open(tzktAPIURLString.appending(path: DependencyManager.shared.selectedWalletAddress ?? "").appending(path: "operations"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class CollectiblesViewController: UIViewController {
}

private func displayGhostnet() {
if DependencyManager.shared.currentNetworkType != .testnet {
if DependencyManager.shared.currentNetworkType != .ghostnet {
ghostnetStackview.isHidden = true

} else {
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Modules/Discover/DiscoverViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class DiscoverViewModel: ViewModel, UITableViewDiffableDataSourceHandler {
if groups.count == 0 { return }


if DependencyManager.shared.currentNetworkType == .testnet {
if DependencyManager.shared.currentNetworkType == .ghostnet {
currentSnapshot.appendSections(Array(0..<groups.count))
currentSnapshot.appendItems([GhostnetWarningCellObj(), menu, groups[0]], toSection: 0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class WelcomeViewController: UIViewController {


if (UIApplication.shared.delegate as? AppDelegate)?.shouldLaunchGhostnet() == true {
DependencyManager.shared.setDefaultTestnetURLs(supressUpdateNotification: true)
DependencyManager.shared.setDefaultGhostnetURLs(supressUpdateNotification: true)

} else if DependencyManager.shared.currentNetworkType != .mainnet {
DependencyManager.shared.setDefaultMainnetURLs(supressUpdateNotification: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SendBatchConfirmViewController: SendAbstractConfirmViewController, SlideBu
feeButton.accessibilityIdentifier = "fee-button"
toBatchCountLabel.accessibilityIdentifier = "contract-count-label"

if DependencyManager.shared.currentNetworkType != .testnet {
if DependencyManager.shared.currentNetworkType != .ghostnet {
testnetWarningView.isHidden = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SendCollectibleConfirmViewController: SendAbstractConfirmViewController, S

feeButton.accessibilityIdentifier = "fee-button"

if DependencyManager.shared.currentNetworkType != .testnet {
if DependencyManager.shared.currentNetworkType != .ghostnet {
testnetWarningView.isHidden = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SendGenericConfirmViewController: SendAbstractConfirmViewController, Slide

feeButton.accessibilityIdentifier = "fee-button"

if DependencyManager.shared.currentNetworkType != .testnet {
if DependencyManager.shared.currentNetworkType != .ghostnet {
testnetWarningView.isHidden = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class SendTokenConfirmViewController: SendAbstractConfirmViewController, SlideBu

feeButton.accessibilityIdentifier = "fee-button"

if DependencyManager.shared.currentNetworkType != .testnet {
if DependencyManager.shared.currentNetworkType != .ghostnet {
testnetWarningView.isHidden = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class NetworkChooserViewController: UIViewController, UITableViewDelegate, UITab
if indexPath.row == 0 {
DependencyManager.shared.setDefaultMainnetURLs()
} else {
DependencyManager.shared.setDefaultTestnetURLs()
DependencyManager.shared.setDefaultGhostnetURLs()
}

self.dismissBottomSheet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class SideMenuViewController: UIViewController {
@IBAction func getTezTapped(_ sender: Any) {
self.closeTapped(self)

if DependencyManager.shared.currentNetworkType == .testnet {
if DependencyManager.shared.currentNetworkType == .ghostnet {
UIApplication.shared.open(DependencyManager.ghostnetFaucetLink)

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ extension WalletConnectViewController: UITableViewDelegate {
for session in Sign.instance.getSessions().filter({ $0.pairingTopic == forPair.topic }) {
try await Sign.instance.disconnect(topic: session.topic)
}

DispatchQueue.main.async { [weak self] in
self?.viewModel.refresh(animate: true)
}
} catch {
DispatchQueue.main.async { [weak self] in
self?.windowError(withTitle: "error".localized(), description: error.localizedDescription)
}
}

DispatchQueue.main.async { [weak self] in
self?.viewModel.refresh(animate: true)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ConfirmStakeViewController: SendAbstractConfirmViewController, SlideButton
super.viewDidLoad()
let _ = self.view.addGradientBackgroundFull()

if DependencyManager.shared.currentNetworkType != .testnet {
if DependencyManager.shared.currentNetworkType != .ghostnet {
testnetWarningView.isHidden = true
}

Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Services/BalanceService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public class BalanceService {
// MARK: - Cache

public static func addressCacheKey(forAddress address: String) -> String {
if DependencyManager.shared.currentNetworkType == .testnet {
if DependencyManager.shared.currentNetworkType == .ghostnet {
return address + "-ghostnet"
}

Expand Down
33 changes: 21 additions & 12 deletions Kukai Mobile/Services/DependencyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ class DependencyManager {

static let defaultNodeURLs_mainnet = [URL(string: "https://mainnet.kukai.network")!, URL(string: "https://rpc.tzbeta.net")!, URL(string: "https://mainnet.smartpy.io")!]
static let defaultTzktURL_mainnet = URL(string: "https://kukai.api.tzkt.io")!
static let defaultExplorerURL_mainnet = URL(string: "https://tzkt.io")!
static let defaultBcdURL_mainnet = URL(string: "https://api.better-call.dev")!
static let defaultTezosDomainsURL_mainnet = URL(string: "https://api.tezos.domains/graphql")!
static let defaultObjktURL_mainnet = URL(string: "https://data.objkt.com/v3/graphql")!

static let defaultNodeURLs_testnet = [URL(string: "https://ghostnet.ecadinfra.com")!, URL(string: "https://rpc.ghostnet.tzboot.net")!, URL(string: "https://ghostnet.smartpy.io")!]
static let defaultTzktURL_testnet = URL(string: "https://api.ghostnet.tzkt.io")!
static let defaultBcdURL_testnet = URL(string: "https://api.better-call.dev")!
static let defaultTezosDomainsURL_testnet = URL(string: "https://ghostnet-api.tezos.domains/graphql")!
static let defaultObjktURL_testnet = URL(string: "https://data.ghostnet.objkt.com/v3/graphql")!
static let defaultNodeURLs_ghostnet = [URL(string: "https://ghostnet.ecadinfra.com")!, URL(string: "https://rpc.ghostnet.tzboot.net")!, URL(string: "https://ghostnet.smartpy.io")!]
static let defaultTzktURL_ghostnet = URL(string: "https://api.ghostnet.tzkt.io")!
static let defaultExplorerURL_ghostnet = URL(string: "https://ghostnet.tzkt.io")!
static let defaultBcdURL_ghostnet = URL(string: "https://api.better-call.dev")!
static let defaultTezosDomainsURL_ghostnet = URL(string: "https://ghostnet-api.tezos.domains/graphql")!
static let defaultObjktURL_ghostnet = URL(string: "https://data.ghostnet.objkt.com/v3/graphql")!

static let ghostnetFaucetLink = URL(string: "https://faucet.ghostnet.teztnets.com/")!

Expand Down Expand Up @@ -89,6 +91,11 @@ class DependencyManager {
get { return URL(string: UserDefaults.standard.string(forKey: "app.kukai.mobile.tzkt.url") ?? "") ?? DependencyManager.defaultTzktURL_mainnet }
}

var currentExplorerURL: URL {
set { UserDefaults.standard.setValue(newValue.absoluteString, forKey: "app.kukai.mobile.explorer.url") }
get { return URL(string: UserDefaults.standard.string(forKey: "app.kukai.mobile.explorer.url") ?? "") ?? DependencyManager.defaultExplorerURL_mainnet }
}

var currentBcdURL: URL {
set { UserDefaults.standard.setValue(newValue.absoluteString, forKey: "app.kukai.mobile.bcd.url") }
get { return URL(string: UserDefaults.standard.string(forKey: "app.kukai.mobile.bcd.url") ?? "") ?? DependencyManager.defaultBcdURL_mainnet }
Expand Down Expand Up @@ -239,6 +246,7 @@ class DependencyManager {
func setDefaultMainnetURLs(supressUpdateNotification: Bool = false) {
currentNodeURLs = DependencyManager.defaultNodeURLs_mainnet
currentTzktURL = DependencyManager.defaultTzktURL_mainnet
currentExplorerURL = DependencyManager.defaultExplorerURL_mainnet
currentBcdURL = DependencyManager.defaultBcdURL_mainnet
currentTezosDomainsURL = DependencyManager.defaultTezosDomainsURL_mainnet
currentObjktURL = DependencyManager.defaultObjktURL_mainnet
Expand All @@ -247,13 +255,14 @@ class DependencyManager {
updateKukaiCoreClients(supressUpdateNotification: supressUpdateNotification)
}

func setDefaultTestnetURLs(supressUpdateNotification: Bool = false) {
currentNodeURLs = DependencyManager.defaultNodeURLs_testnet
currentTzktURL = DependencyManager.defaultTzktURL_testnet
currentBcdURL = DependencyManager.defaultBcdURL_testnet
currentTezosDomainsURL = DependencyManager.defaultTezosDomainsURL_testnet
currentObjktURL = DependencyManager.defaultObjktURL_testnet
currentNetworkType = .testnet
func setDefaultGhostnetURLs(supressUpdateNotification: Bool = false) {
currentNodeURLs = DependencyManager.defaultNodeURLs_ghostnet
currentTzktURL = DependencyManager.defaultTzktURL_ghostnet
currentExplorerURL = DependencyManager.defaultExplorerURL_ghostnet
currentBcdURL = DependencyManager.defaultBcdURL_ghostnet
currentTezosDomainsURL = DependencyManager.defaultTezosDomainsURL_ghostnet
currentObjktURL = DependencyManager.defaultObjktURL_ghostnet
currentNetworkType = .ghostnet

updateKukaiCoreClients(supressUpdateNotification: supressUpdateNotification)
}
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Services/WalletConnectService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class WalletConnectService {
description: "Kukai iOS",
url: "https://wallet.kukai.app",
icons: ["https://wallet.kukai.app/assets/img/header-logo.svg"],
redirect: AppMetadata.Redirect(native: "kukai://", universal: nil))
redirect: (try! AppMetadata.Redirect(native: "kukai://", universal: nil)) )

private var pairingTimer: Timer? = nil
private var requestOrProposalInProgress = false
Expand Down

0 comments on commit 1cabdaa

Please sign in to comment.