forked from BitCoinONE1/trust-wallet-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove of the additional operation with transaction parsing. * We prefetch 5 pages of the latest transactions. * Add new property to fetch trust wallet token images. * Add decodable TokenObject. * Remove of the unused wrapper. * Add operations for tokens list. * Add usage of the operations. * Code cleaning. * Remove of the additional operation. * Code cleaning. * Update with realm interaction. * Add new operation for the eth balance. * Code cleaning. * Update of the transaction update * Update balance coordinator. * Add lover case style for contract. * Add handling of the contracts. * Update of the image path generation. * Code cleaning. * Add method for timer. * Temp fix for the transactions.
- Loading branch information
Showing
16 changed files
with
309 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright SIX DAY LLC. All rights reserved. | ||
|
||
import UIKit | ||
import BigInt | ||
|
||
class EthBalanceOperation: TrustOperation { | ||
private var network: TokensNetworkProtocol | ||
var balance: Balance = Balance(value: BigInt(0)) | ||
|
||
init(network: TokensNetworkProtocol) { | ||
self.network = network | ||
} | ||
|
||
override func main() { | ||
guard isCancelled == false else { | ||
finish(true) | ||
return | ||
} | ||
fetchBalance() | ||
} | ||
|
||
private func fetchBalance() { | ||
executing(true) | ||
network.ethBalance { [weak self] result in | ||
self?.balance = result ?? Balance(value: BigInt(0)) | ||
self?.executing(false) | ||
self?.finish(true) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright SIX DAY LLC. All rights reserved. | ||
|
||
import UIKit | ||
import TrustKeystore | ||
|
||
class TokensBalanceOperation: TrustOperation { | ||
private var network: TokensNetworkProtocol | ||
private let address: Address | ||
var tokens: [TokenObject] = [TokenObject]() | ||
private var pos = 0 | ||
|
||
init( | ||
network: TokensNetworkProtocol, | ||
address: Address | ||
) { | ||
self.network = network | ||
self.address = address | ||
} | ||
|
||
override func main() { | ||
guard isCancelled == false, !tokens.isEmpty else { | ||
finish(true) | ||
return | ||
} | ||
executing(true) | ||
updateTokens() | ||
} | ||
|
||
private func updateTokens() { | ||
updateBalance(for: tokens[pos]) {[weak self] token in | ||
guard let strongSelf = self else { | ||
self?.executing(false) | ||
self?.finish(true) | ||
return | ||
} | ||
let currentPos = strongSelf.pos | ||
strongSelf.tokens[currentPos] = token | ||
strongSelf.pos += 1 | ||
if strongSelf.pos < strongSelf.tokens.count { | ||
strongSelf.updateTokens() | ||
} else { | ||
self?.executing(false) | ||
self?.finish(true) | ||
} | ||
} | ||
} | ||
|
||
private func updateBalance(for token: TokenObject, completion: @escaping ((TokenObject) -> Void)) { | ||
network.tokenBalance(for: token) { result in | ||
guard let balance = result.1 else { | ||
completion(token) | ||
return | ||
} | ||
let tempToken = token | ||
tempToken.value = balance.value.description | ||
completion(tempToken) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright SIX DAY LLC. All rights reserved. | ||
|
||
import TrustKeystore | ||
|
||
class TokensOperation: TrustOperation { | ||
private var network: TokensNetworkProtocol | ||
private let address: Address | ||
var tokens: [TokenObject] = [TokenObject]() | ||
|
||
init( | ||
network: TokensNetworkProtocol, | ||
address: Address | ||
) { | ||
self.network = network | ||
self.address = address | ||
} | ||
|
||
override func main() { | ||
guard isCancelled == false else { | ||
finish(true) | ||
return | ||
} | ||
fetchTokensList() | ||
} | ||
|
||
private func fetchTokensList() { | ||
executing(true) | ||
network.tokensList(for: address) { result in | ||
guard let tokensList = result else { | ||
self.executing(false) | ||
self.finish(true) | ||
return | ||
} | ||
self.tokens.append(contentsOf: tokensList) | ||
self.executing(false) | ||
self.finish(true) | ||
} | ||
} | ||
} |
Oops, something went wrong.