diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fcde25..7ec7dae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## Changelog 3.7.2 - 2019-11-19 + +### Fixed +* Fixed ECHOQueue completion operation + ## Changelog 3.7.1 - 2019-11-18 ### Fixed diff --git a/ECHO.podspec b/ECHO.podspec index 3fbd9e7..5430b4d 100755 --- a/ECHO.podspec +++ b/ECHO.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ECHO" - spec.version = "3.7.1" + spec.version = "3.7.2" spec.summary = "Echo iOS Framework" spec.homepage = "https://github.com/echoprotocol/echo-ios-framework" spec.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/ECHO.xcodeproj/project.pbxproj b/ECHO.xcodeproj/project.pbxproj index e76abfb..c1354bc 100644 --- a/ECHO.xcodeproj/project.pbxproj +++ b/ECHO.xcodeproj/project.pbxproj @@ -1858,7 +1858,7 @@ "$(SRCROOT)/Libraries/openssl/lib", "$(SRCROOT)/Libraries/ed25519/lib/SimulatorRelease/", ); - MARKETING_VERSION = 3.7.1; + MARKETING_VERSION = 3.7.2; MODULEMAP_FILE = "./ECHO/Supports Files/ECHO.modulemap"; PRODUCT_BUNDLE_IDENTIFIER = org.echo.mobile.framework; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; @@ -1906,7 +1906,7 @@ "$(SRCROOT)/Libraries/openssl/lib", "$(SRCROOT)/Libraries/ed25519/lib/SimulatorRelease/", ); - MARKETING_VERSION = 3.7.1; + MARKETING_VERSION = 3.7.2; MODULEMAP_FILE = "./ECHO/Supports Files/ECHO.modulemap"; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = org.echo.mobile.framework; diff --git a/ECHO/Core/Classes/Objects/ECHOObjects/ECHOQueue.swift b/ECHO/Core/Classes/Objects/ECHOObjects/ECHOQueue.swift index 3ddf45b..c430fbf 100644 --- a/ECHO/Core/Classes/Objects/ECHOObjects/ECHOQueue.swift +++ b/ECHO/Core/Classes/Objects/ECHOObjects/ECHOQueue.swift @@ -15,7 +15,7 @@ */ protocol ECHOQueueble: class { - var queues: [ECHOQueue] { get set } + var queues: [String: ECHOQueue] { get set } func addQueue(_ queue: ECHOQueue) func removeQueue(_ queue: ECHOQueue) @@ -28,14 +28,12 @@ extension ECHOQueueble { func addQueue(_ queue: ECHOQueue) { - queues.append(queue) + queues[queue.uuid] = queue } func removeQueue(_ queue: ECHOQueue) { - if let index = queues.index(where: { return queue.uuid == $0.uuid }) { - queues.remove(at: index) - } + queues.removeValue(forKey: queue.uuid) } func createCompletionOperation(queue: ECHOQueue) -> Operation { @@ -53,7 +51,7 @@ extension ECHOQueueble { func cancelAllOperationInQueues() { - for queue in queues { + for queue in queues.values { queue.cancelAllOperations() } } @@ -121,26 +119,11 @@ public final class ECHOQueue: NSObject { // MARK: Operations - public func setCompletionOperation(_ completionOperation: Operation) { - - self.completionOperation = completionOperation - - obs = workingQueue.observe(\.operationCount) { [weak self] (queue, _) in - - if queue.operationCount == 0, - let completionOperation = self?.completionOperation, - completionOperation.isFinished == false { - queue.addOperation(completionOperation) - } - } - } - public func addOperation(_ operation: Operation) { workingQueue.addOperation(operation) } public func cancelAllOperations() { - workingQueue.cancelAllOperations() } } diff --git a/ECHO/Core/Facades/Implementations/AssetsFacadeImp.swift b/ECHO/Core/Facades/Implementations/AssetsFacadeImp.swift index 110b0bb..8c1cc2b 100644 --- a/ECHO/Core/Facades/Implementations/AssetsFacadeImp.swift +++ b/ECHO/Core/Facades/Implementations/AssetsFacadeImp.swift @@ -16,7 +16,7 @@ public struct AssetsServices { */ final public class AssetsFacadeImp: AssetsFacade, ECHOQueueble { - var queues: [ECHOQueue] + var queues: [String: ECHOQueue] let services: AssetsServices let cryptoCore: CryptoCoreComponent let network: ECHONetwork @@ -47,12 +47,12 @@ final public class AssetsFacadeImp: AssetsFacade, ECHOQueueble { self.services = services self.cryptoCore = cryptoCore self.network = network - self.queues = [ECHOQueue]() + self.queues = [String: ECHOQueue]() } public func createAsset(nameOrId: String, wif: String, asset: Asset, completion: @escaping Completion) { let createAssetQueue = ECHOQueue() - queues.append(createAssetQueue) + addQueue(createAssetQueue) // Accounts let getAccountsNamesOrIdsWithKeys = GetAccountsNamesOrIdWithKeys([(nameOrId, CreateAssetKeys.account.rawValue)]) @@ -118,7 +118,7 @@ final public class AssetsFacadeImp: AssetsFacade, ECHOQueueble { createAssetQueue.addOperation(bildTransactionOperation) createAssetQueue.addOperation(sendTransactionOperation) - createAssetQueue.setCompletionOperation(completionOperation) + createAssetQueue.addOperation(completionOperation) } // swiftlint:disable function_body_length @@ -140,7 +140,7 @@ final public class AssetsFacadeImp: AssetsFacade, ECHOQueueble { } let issueAssetQueue = ECHOQueue() - queues.append(issueAssetQueue) + addQueue(issueAssetQueue) // Accounts let getAccountsNamesOrIdsWithKeys = GetAccountsNamesOrIdWithKeys([(issuerNameOrId, IssueAssetKeys.issuerAccount.rawValue), @@ -207,7 +207,7 @@ final public class AssetsFacadeImp: AssetsFacade, ECHOQueueble { issueAssetQueue.addOperation(bildTransactionOperation) issueAssetQueue.addOperation(sendTransactionOperation) - issueAssetQueue.setCompletionOperation(completionOperation) + issueAssetQueue.addOperation(completionOperation) } // swiftlint:enable function_body_length diff --git a/ECHO/Core/Facades/Implementations/AuthentificationFacadeImp.swift b/ECHO/Core/Facades/Implementations/AuthentificationFacadeImp.swift index 3dcbf3a..bf66df2 100644 --- a/ECHO/Core/Facades/Implementations/AuthentificationFacadeImp.swift +++ b/ECHO/Core/Facades/Implementations/AuthentificationFacadeImp.swift @@ -16,7 +16,7 @@ struct AuthentificationFacadeServices { */ final public class AuthentificationFacadeImp: AuthentificationFacade, ECHOQueueble { - var queues: [ECHOQueue] + var queues: [String: ECHOQueue] let services: AuthentificationFacadeServices let cryptoCore: CryptoCoreComponent let network: ECHONetwork @@ -25,7 +25,7 @@ final public class AuthentificationFacadeImp: AuthentificationFacade, ECHOQueueb self.services = services self.cryptoCore = cryptoCore self.network = network - self.queues = [ECHOQueue]() + self.queues = [String: ECHOQueue]() } public func generateRandomWIF() -> String { @@ -142,7 +142,7 @@ final public class AuthentificationFacadeImp: AuthentificationFacade, ECHOQueueb public func changeKeys(oldWIF: String, newWIF: String, name: String, completion: @escaping Completion) { let changeKeysQueue = ECHOQueue() - queues.append(changeKeysQueue) + addQueue(changeKeysQueue) // Account let checkAccountOperation = createCheckAccountOperation(changeKeysQueue, name, oldWIF, completion) @@ -203,7 +203,7 @@ final public class AuthentificationFacadeImp: AuthentificationFacade, ECHOQueueb changeKeysQueue.addOperation(bildTransactionOperation) changeKeysQueue.addOperation(sendTransactionOperation) - changeKeysQueue.setCompletionOperation(completionOperation) + changeKeysQueue.addOperation(completionOperation) } fileprivate func createCheckAccountOperation(_ queue: ECHOQueue, diff --git a/ECHO/Core/Facades/Implementations/ContractsFacadeImp.swift b/ECHO/Core/Facades/Implementations/ContractsFacadeImp.swift index 94e8529..d7fdc26 100644 --- a/ECHO/Core/Facades/Implementations/ContractsFacadeImp.swift +++ b/ECHO/Core/Facades/Implementations/ContractsFacadeImp.swift @@ -37,7 +37,7 @@ final public class ContractsFacadeImp: ContractsFacade, ECHOQueueble { case noticeError } - var queues: [ECHOQueue] + var queues: [String: ECHOQueue] let services: ContractsFacadeServices let network: ECHONetwork let cryptoCore: CryptoCoreComponent @@ -56,7 +56,7 @@ final public class ContractsFacadeImp: ContractsFacade, ECHOQueueble { self.cryptoCore = cryptoCore self.abiCoderCore = abiCoder self.settings = settings - self.queues = [ECHOQueue]() + self.queues = [String: ECHOQueue]() noticeDelegateHandler.delegate = self } @@ -266,7 +266,7 @@ final public class ContractsFacadeImp: ContractsFacade, ECHOQueueble { createQueue.addOperation(noticeHandleOperation) } - createQueue.setCompletionOperation(completionOperation) + createQueue.addOperation(completionOperation) } public func callContract(registrarNameOrId: String, @@ -434,7 +434,7 @@ final public class ContractsFacadeImp: ContractsFacade, ECHOQueueble { callQueue.addOperation(noticeHandleOperation) } - callQueue.setCompletionOperation(completionOperation) + callQueue.addOperation(completionOperation) } public func queryContract(registrarNameOrId: String, @@ -519,7 +519,7 @@ final public class ContractsFacadeImp: ContractsFacade, ECHOQueueble { queryQueue.addOperation(byteCodeOperation) } queryQueue.addOperation(callContractNoChangigState) - queryQueue.setCompletionOperation(completionOperation) + queryQueue.addOperation(completionOperation) } fileprivate func createBildCallContractOperation(_ queue: ECHOQueue, @@ -690,7 +690,7 @@ extension ContractsFacadeImp: NoticeEventDelegate { case .array(let array): if let noticeOperationId = array.first as? Int { - for queue in queues { + for queue in queues.values { if let queueTransferOperationId: Int = queue.getValue(ContractKeys.operationId.rawValue), queueTransferOperationId == noticeOperationId { @@ -705,7 +705,7 @@ extension ContractsFacadeImp: NoticeEventDelegate { } public func didAllNoticesLost() { - for queue in queues { + for queue in queues.values { queue.saveValue(ECHOError.connectionLost, forKey: ContractKeys.noticeError.rawValue) queue.startNextOperation() } diff --git a/ECHO/Core/Facades/Implementations/EthFacadeImp.swift b/ECHO/Core/Facades/Implementations/EthFacadeImp.swift index 7512f22..fbb2fe4 100644 --- a/ECHO/Core/Facades/Implementations/EthFacadeImp.swift +++ b/ECHO/Core/Facades/Implementations/EthFacadeImp.swift @@ -19,7 +19,7 @@ public struct EthFacadeServices { */ final public class EthFacadeImp: EthFacade, ECHOQueueble { - var queues: [ECHOQueue] + var queues: [String: ECHOQueue] let services: EthFacadeServices let network: ECHONetwork let cryptoCore: CryptoCoreComponent @@ -32,7 +32,7 @@ final public class EthFacadeImp: EthFacade, ECHOQueueble { self.services = services self.network = network self.cryptoCore = cryptoCore - self.queues = [ECHOQueue]() + self.queues = [String: ECHOQueue]() noticeDelegateHandler.delegate = self } @@ -177,7 +177,7 @@ final public class EthFacadeImp: EthFacade, ECHOQueueble { } let generateQueue = ECHOQueue() - queues.append(generateQueue) + addQueue(generateQueue) // Accounts let getAccountsNamesOrIdsWithKeys = GetAccountsNamesOrIdWithKeys([(nameOrId, EthFacadeResultKeys.loadedAccount.rawValue)]) @@ -254,7 +254,7 @@ final public class EthFacadeImp: EthFacade, ECHOQueueble { generateQueue.addOperation(noticeHandleOperation) } - generateQueue.setCompletionOperation(completionOperation) + generateQueue.addOperation(completionOperation) } public func withdrawalEth(nameOrId: String, @@ -287,7 +287,7 @@ final public class EthFacadeImp: EthFacade, ECHOQueueble { } let withdrawalQueue = ECHOQueue() - queues.append(withdrawalQueue) + addQueue(withdrawalQueue) // Accounts let getAccountsNamesOrIdsWithKeys = GetAccountsNamesOrIdWithKeys([(nameOrId, EthFacadeResultKeys.loadedAccount.rawValue)]) @@ -364,7 +364,7 @@ final public class EthFacadeImp: EthFacade, ECHOQueueble { withdrawalQueue.addOperation(noticeHandleOperation) } - withdrawalQueue.setCompletionOperation(completionOperation) + withdrawalQueue.addOperation(completionOperation) } // swiftlint:enable function_body_length @@ -472,7 +472,7 @@ extension EthFacadeImp: NoticeEventDelegate { case .array(let array): if let noticeOperationId = array.first as? Int { - for queue in queues { + for queue in queues.values { if let queueTransferOperationId: Int = queue.getValue(EthFacadeResultKeys.operationId.rawValue), queueTransferOperationId == noticeOperationId { @@ -487,7 +487,7 @@ extension EthFacadeImp: NoticeEventDelegate { } public func didAllNoticesLost() { - for queue in queues { + for queue in queues.values { queue.saveValue(ECHOError.connectionLost, forKey: EthFacadeResultKeys.noticeError.rawValue) queue.startNextOperation() } diff --git a/ECHO/Core/Facades/Implementations/FeeFacadeImp.swift b/ECHO/Core/Facades/Implementations/FeeFacadeImp.swift index c4c3623..429420a 100644 --- a/ECHO/Core/Facades/Implementations/FeeFacadeImp.swift +++ b/ECHO/Core/Facades/Implementations/FeeFacadeImp.swift @@ -20,7 +20,7 @@ public struct FeeFacadeServices { // swiftlint:disable type_body_length final public class FeeFacadeImp: FeeFacade, ECHOQueueble { - var queues: [ECHOQueue] + var queues: [String: ECHOQueue] let services: FeeFacadeServices let network: ECHONetwork let cryptoCore: CryptoCoreComponent @@ -38,7 +38,7 @@ final public class FeeFacadeImp: FeeFacade, ECHOQueueble { self.cryptoCore = cryptoCore self.abiCoderCore = abiCoderCore self.settings = settings - self.queues = [ECHOQueue]() + self.queues = [String: ECHOQueue]() } private enum FeeResultsKeys: String { @@ -74,7 +74,7 @@ final public class FeeFacadeImp: FeeFacade, ECHOQueueble { } let feeQueue = ECHOQueue() - queues.append(feeQueue) + addQueue(feeQueue) // Account let getAccountsNamesOrIdsWithKeys = GetAccountsNamesOrIdWithKeys([(fromNameOrId, FeeResultsKeys.loadedFromAccount.rawValue), @@ -109,7 +109,7 @@ final public class FeeFacadeImp: FeeFacade, ECHOQueueble { feeQueue.addOperation(getRequiredFeeOperation) feeQueue.addOperation(feeCompletionOperation) - feeQueue.setCompletionOperation(completionOperation) + feeQueue.addOperation(completionOperation) } public func getFeeForCreateContract(registrarNameOrId: String, @@ -208,7 +208,7 @@ final public class FeeFacadeImp: FeeFacade, ECHOQueueble { createQueue.addOperation(getRequiredFeeOperation) createQueue.addOperation(feeCompletionOperation) - createQueue.setCompletionOperation(completionOperation) + createQueue.addOperation(completionOperation) } public func getFeeForCallContractOperation(registrarNameOrId: String, @@ -319,7 +319,7 @@ final public class FeeFacadeImp: FeeFacade, ECHOQueueble { callQueue.addOperation(getRequiredFeeOperation) callQueue.addOperation(feeCompletionOperation) - callQueue.setCompletionOperation(completionOperation) + callQueue.addOperation(completionOperation) } fileprivate func createBildTransferOperation(_ queue: ECHOQueue, diff --git a/ECHO/Core/Facades/Implementations/InformationFacadeImp.swift b/ECHO/Core/Facades/Implementations/InformationFacadeImp.swift index 939aa22..f3a46a6 100644 --- a/ECHO/Core/Facades/Implementations/InformationFacadeImp.swift +++ b/ECHO/Core/Facades/Implementations/InformationFacadeImp.swift @@ -20,7 +20,7 @@ struct InformationFacadeServices { // swiftlint:disable type_body_length final public class InformationFacadeImp: InformationFacade, ECHOQueueble { - var queues: [ECHOQueue] + var queues: [String: ECHOQueue] let services: InformationFacadeServices let network: ECHONetwork let cryptoCore: CryptoCoreComponent @@ -33,7 +33,7 @@ final public class InformationFacadeImp: InformationFacade, ECHOQueueble { self.services = services self.network = network self.cryptoCore = cryptoCore - self.queues = [ECHOQueue]() + self.queues = [String: ECHOQueue]() noticeDelegateHandler.delegate = self } @@ -64,7 +64,7 @@ final public class InformationFacadeImp: InformationFacade, ECHOQueueble { public func registerAccount(name: String, wif: String, completion: @escaping Completion, noticeHandler: NoticeHandler?) { let createAccountQueue = ECHOQueue() - queues.append(createAccountQueue) + addQueue(createAccountQueue) // Get Account let getAccountsOperationInitParams = (createAccountQueue, @@ -98,7 +98,7 @@ final public class InformationFacadeImp: InformationFacade, ECHOQueueble { createAccountQueue.addOperation(noticeHandleOperation) } - createAccountQueue.setCompletionOperation(completionOperation) + createAccountQueue.addOperation(completionOperation) } fileprivate func createRequestRegistrationTask(_ queue: ECHOQueue, @@ -428,7 +428,7 @@ final public class InformationFacadeImp: InformationFacade, ECHOQueueble { accountHistoryQueue.addOperation(mergeWithdrawEthInHistoryOperation) accountHistoryQueue.addOperation(historyCompletionOperation) - accountHistoryQueue.setCompletionOperation(completionOperation) + accountHistoryQueue.addOperation(completionOperation) } fileprivate func createGetHistoryOperation(_ queue: ECHOQueue, @@ -1192,7 +1192,7 @@ extension InformationFacadeImp: NoticeEventDelegate { case .array(let array): if let noticeOperationId = array.first as? Int { - for queue in queues { + for queue in queues.values { if let queueTransferOperationId: Int = queue.getValue(CreationAccountResultsKeys.operationID.rawValue), queueTransferOperationId == noticeOperationId { @@ -1207,7 +1207,7 @@ extension InformationFacadeImp: NoticeEventDelegate { } public func didAllNoticesLost() { - for queue in queues { + for queue in queues.values { queue.saveValue(ECHOError.connectionLost, forKey: CreationAccountResultsKeys.noticeError.rawValue) queue.startNextOperation() } diff --git a/ECHO/Core/Facades/Implementations/TransactionFacadeImp.swift b/ECHO/Core/Facades/Implementations/TransactionFacadeImp.swift index 5baf668..fd556bf 100644 --- a/ECHO/Core/Facades/Implementations/TransactionFacadeImp.swift +++ b/ECHO/Core/Facades/Implementations/TransactionFacadeImp.swift @@ -19,7 +19,7 @@ public struct TransactionFacadeServices { */ final public class TransactionFacadeImp: TransactionFacade, ECHOQueueble { - var queues: [ECHOQueue] + var queues: [String: ECHOQueue] let services: TransactionFacadeServices let network: ECHONetwork let cryptoCore: CryptoCoreComponent @@ -32,7 +32,7 @@ final public class TransactionFacadeImp: TransactionFacade, ECHOQueueble { self.services = services self.network = network self.cryptoCore = cryptoCore - self.queues = [ECHOQueue]() + self.queues = [String: ECHOQueue]() noticeDelegateHandler.delegate = self } @@ -76,7 +76,7 @@ final public class TransactionFacadeImp: TransactionFacade, ECHOQueueble { } let transferQueue = ECHOQueue() - queues.append(transferQueue) + addQueue(transferQueue) // Accounts let getAccountsNamesOrIdsWithKeys = GetAccountsNamesOrIdWithKeys([(fromNameOrId, TransferResultsKeys.loadedFromAccount.rawValue), @@ -151,7 +151,7 @@ final public class TransactionFacadeImp: TransactionFacade, ECHOQueueble { transferQueue.addOperation(noticeHandleOperation) } - transferQueue.setCompletionOperation(completionOperation) + transferQueue.addOperation(completionOperation) } // swiftlint:enable function_body_length @@ -232,7 +232,7 @@ extension TransactionFacadeImp: NoticeEventDelegate { case .array(let array): if let noticeOperationId = array.first as? Int { - for queue in queues { + for queue in queues.values { if let queueTransferOperationId: Int = queue.getValue(TransferResultsKeys.operationId.rawValue), queueTransferOperationId == noticeOperationId { @@ -247,7 +247,7 @@ extension TransactionFacadeImp: NoticeEventDelegate { } public func didAllNoticesLost() { - for queue in queues { + for queue in queues.values { queue.saveValue(ECHOError.connectionLost, forKey: TransferResultsKeys.noticeError.rawValue) queue.startNextOperation() }