From bc2b82378119ed98173e1a5acd23801597afbef3 Mon Sep 17 00:00:00 2001 From: EA Date: Fri, 6 Sep 2024 18:09:51 +0600 Subject: [PATCH] Integrate listener for TonKit --- .../UnstoppableWallet.xcodeproj/project.pbxproj | 2 +- UnstoppableWallet/UnstoppableWallet/Core/App.swift | 3 ++- .../UnstoppableWallet/Core/Managers/AdapterManager.swift | 4 +++- .../UnstoppableWallet/Core/Managers/AppManager.swift | 8 +++++++- .../UnstoppableWallet/Core/Managers/TonKitManager.swift | 3 ++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj b/UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj index 5e7bfe1f4f..e1ff9a2d38 100644 --- a/UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj +++ b/UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj @@ -12874,7 +12874,7 @@ repositoryURL = "https://github.com/horizontalsystems/TonKit.Swift"; requirement = { kind = exactVersion; - version = 1.0.2; + version = 1.0.4; }; }; 6BF66DD82BA1A73300963242 /* XCRemoteSwiftPackageReference "ObjectMapper" */ = { diff --git a/UnstoppableWallet/UnstoppableWallet/Core/App.swift b/UnstoppableWallet/UnstoppableWallet/Core/App.swift index 71af97cfc3..3719ea663f 100644 --- a/UnstoppableWallet/UnstoppableWallet/Core/App.swift +++ b/UnstoppableWallet/UnstoppableWallet/Core/App.swift @@ -334,7 +334,8 @@ class App { balanceHiddenManager: balanceHiddenManager, statManager: statManager, walletConnectSocketConnectionService: walletConnectSocketConnectionService, - nftMetadataSyncer: nftMetadataSyncer + nftMetadataSyncer: nftMetadataSyncer, + tonKitManager: tonKitManager ) } diff --git a/UnstoppableWallet/UnstoppableWallet/Core/Managers/AdapterManager.swift b/UnstoppableWallet/UnstoppableWallet/Core/Managers/AdapterManager.swift index eba1bbc68e..406acf9ec2 100644 --- a/UnstoppableWallet/UnstoppableWallet/Core/Managers/AdapterManager.swift +++ b/UnstoppableWallet/UnstoppableWallet/Core/Managers/AdapterManager.swift @@ -164,7 +164,7 @@ extension AdapterManager { } self.tronKitManager.tronKitWrapper?.tronKit.refresh() - self.tonKitManager.tonKit?.refresh() + self.tonKitManager.tonKit?.sync() } } @@ -174,6 +174,8 @@ extension AdapterManager { self.evmBlockchainManager.evmKitManager(blockchainType: blockchainType).evmKitWrapper?.evmKit.refresh() } else if wallet.token.blockchainType == .tron { self.tronKitManager.tronKitWrapper?.tronKit.refresh() + } else if wallet.token.blockchainType == .ton { + self.tonKitManager.tonKit?.sync() } else { self._adapterData.adapterMap[wallet]?.refresh() } diff --git a/UnstoppableWallet/UnstoppableWallet/Core/Managers/AppManager.swift b/UnstoppableWallet/UnstoppableWallet/Core/Managers/AppManager.swift index b34740f5b4..352ff056fb 100644 --- a/UnstoppableWallet/UnstoppableWallet/Core/Managers/AppManager.swift +++ b/UnstoppableWallet/UnstoppableWallet/Core/Managers/AppManager.swift @@ -23,6 +23,7 @@ class AppManager { private let statManager: StatManager private let walletConnectSocketConnectionService: WalletConnectSocketConnectionService private let nftMetadataSyncer: NftMetadataSyncer + private let tonKitManager: TonKitManager private let didBecomeActiveSubject = PublishSubject() private let willEnterForegroundSubjectOld = PublishSubject() @@ -35,7 +36,7 @@ class AppManager { appVersionManager: AppVersionManager, rateAppManager: RateAppManager, logRecordManager: LogRecordManager, deepLinkManager: DeepLinkManager, evmLabelManager: EvmLabelManager, balanceHiddenManager: BalanceHiddenManager, statManager: StatManager, - walletConnectSocketConnectionService: WalletConnectSocketConnectionService, nftMetadataSyncer: NftMetadataSyncer) + walletConnectSocketConnectionService: WalletConnectSocketConnectionService, nftMetadataSyncer: NftMetadataSyncer, tonKitManager: TonKitManager) { self.accountManager = accountManager self.walletManager = walletManager @@ -55,6 +56,7 @@ class AppManager { self.statManager = statManager self.walletConnectSocketConnectionService = walletConnectSocketConnectionService self.nftMetadataSyncer = nftMetadataSyncer + self.tonKitManager = tonKitManager } private func warmUp() { @@ -103,6 +105,8 @@ extension AppManager { lockManager.didEnterBackground() walletConnectSocketConnectionService.didEnterBackground() balanceHiddenManager.didEnterBackground() + + tonKitManager.tonKit?.stopListener() } func willEnterForeground() { @@ -123,6 +127,8 @@ extension AppManager { nftMetadataSyncer.sync() + tonKitManager.tonKit?.startListener() + AppWidgetConstants.allKinds.forEach { WidgetCenter.shared.reloadTimelines(ofKind: $0) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Core/Managers/TonKitManager.swift b/UnstoppableWallet/UnstoppableWallet/Core/Managers/TonKitManager.swift index 5a50d8e498..b8c2801a0a 100644 --- a/UnstoppableWallet/UnstoppableWallet/Core/Managers/TonKitManager.swift +++ b/UnstoppableWallet/UnstoppableWallet/Core/Managers/TonKitManager.swift @@ -45,7 +45,8 @@ class TonKitManager { minLogLevel: .error ) - tonKit.refresh() + tonKit.sync() + tonKit.startListener() _tonKit = tonKit currentAccount = account