Skip to content

Commit

Permalink
Merge pull request #11 from v-sharaev/release/3.7.2
Browse files Browse the repository at this point in the history
Release/3.7.2
  • Loading branch information
vl-px authored Nov 19, 2019
2 parents 8e2fee9 + 176dda1 commit 7469fdc
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 68 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion ECHO.podspec
Original file line number Diff line number Diff line change
@@ -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' }
Expand Down
4 changes: 2 additions & 2 deletions ECHO.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 4 additions & 21 deletions ECHO/Core/Classes/Objects/ECHOObjects/ECHOQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -53,7 +51,7 @@ extension ECHOQueueble {

func cancelAllOperationInQueues() {

for queue in queues {
for queue in queues.values {
queue.cancelAllOperations()
}
}
Expand Down Expand Up @@ -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()
}
}
12 changes: 6 additions & 6 deletions ECHO/Core/Facades/Implementations/AssetsFacadeImp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Bool>) {

let createAssetQueue = ECHOQueue()
queues.append(createAssetQueue)
addQueue(createAssetQueue)

// Accounts
let getAccountsNamesOrIdsWithKeys = GetAccountsNamesOrIdWithKeys([(nameOrId, CreateAssetKeys.account.rawValue)])
Expand Down Expand Up @@ -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
Expand All @@ -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),
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -142,7 +142,7 @@ final public class AuthentificationFacadeImp: AuthentificationFacade, ECHOQueueb
public func changeKeys(oldWIF: String, newWIF: String, name: String, completion: @escaping Completion<Bool>) {

let changeKeysQueue = ECHOQueue()
queues.append(changeKeysQueue)
addQueue(changeKeysQueue)

// Account
let checkAccountOperation = createCheckAccountOperation(changeKeysQueue, name, oldWIF, completion)
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions ECHO/Core/Facades/Implementations/ContractsFacadeImp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -266,7 +266,7 @@ final public class ContractsFacadeImp: ContractsFacade, ECHOQueueble {
createQueue.addOperation(noticeHandleOperation)
}

createQueue.setCompletionOperation(completionOperation)
createQueue.addOperation(completionOperation)
}

public func callContract(registrarNameOrId: String,
Expand Down Expand Up @@ -434,7 +434,7 @@ final public class ContractsFacadeImp: ContractsFacade, ECHOQueueble {
callQueue.addOperation(noticeHandleOperation)
}

callQueue.setCompletionOperation(completionOperation)
callQueue.addOperation(completionOperation)
}

public func queryContract(registrarNameOrId: String,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
}
Expand Down
16 changes: 8 additions & 8 deletions ECHO/Core/Facades/Implementations/EthFacadeImp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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)])
Expand Down Expand Up @@ -254,7 +254,7 @@ final public class EthFacadeImp: EthFacade, ECHOQueueble {
generateQueue.addOperation(noticeHandleOperation)
}

generateQueue.setCompletionOperation(completionOperation)
generateQueue.addOperation(completionOperation)
}

public func withdrawalEth(nameOrId: String,
Expand Down Expand Up @@ -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)])
Expand Down Expand Up @@ -364,7 +364,7 @@ final public class EthFacadeImp: EthFacade, ECHOQueueble {
withdrawalQueue.addOperation(noticeHandleOperation)
}

withdrawalQueue.setCompletionOperation(completionOperation)
withdrawalQueue.addOperation(completionOperation)
}
// swiftlint:enable function_body_length

Expand Down Expand Up @@ -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 {
Expand All @@ -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()
}
Expand Down
12 changes: 6 additions & 6 deletions ECHO/Core/Facades/Implementations/FeeFacadeImp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 7469fdc

Please sign in to comment.