Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Adds a new StellarAccountService framework for the app
* Moves Stellar SDK integration from the iOS target to a new StellarAccountService * Bumps version to 2.4.0 * Implements account migrator for old keychain data format * Implements new StellarTradeService + app structural updates to support integrating it * Integrated new StellarAccountService with app * Refactor WalletViewController / WalletPickingViewController * Updates tests to compile / pass with StellarAccountService integration * Converted static operation methods for fetching data into Asynchornous operation subclasses * Correct presentation of inflation view controller * Correct view controller containment + starting to add response delegates * Refactor ContactViewController apart into VC / DataSource * Removing lazy properties for view controllers we know always should be loaded * Fix copy button image after setting copy as a template image * Fix trade view controller segmented colours
- Loading branch information
Showing
129 changed files
with
6,178 additions
and
3,068 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// AddressResolver.swift | ||
// BlockEQ | ||
// | ||
// Created by Nick DiZazzo on 2018-10-24. | ||
// Copyright © 2018 BlockEQ. All rights reserved. | ||
// | ||
|
||
import StellarAccountService | ||
|
||
final class AddressResolver { | ||
enum AddressType { | ||
case exchange | ||
case contact | ||
} | ||
|
||
static let shared = AddressResolver() | ||
|
||
private var mappedExchanges: [String: Exchange] = [:] | ||
private var mappedContacts: [String: LocalContact] = [:] | ||
|
||
private init() { | ||
loadExchangeData() | ||
|
||
let contacts: [LocalContact] = [] | ||
mappedContacts = contacts.reduce(into: [:]) { map, contact in | ||
map[contact.address] = contact | ||
} | ||
} | ||
|
||
static func lookup(address: StellarAddress) -> AddressType { | ||
return .exchange | ||
} | ||
|
||
static func resolve(address: StellarAddress) -> LocalContact? { | ||
let type = lookup(address: address) | ||
guard type == .contact else { return nil } | ||
|
||
if let contact = shared.mappedContacts[address.string] { | ||
return contact | ||
} | ||
|
||
return nil | ||
} | ||
|
||
static func resolve(address: StellarAddress) -> Exchange? { | ||
let type = lookup(address: address) | ||
guard type == .exchange else { return nil } | ||
|
||
if let exchange = shared.mappedExchanges[address.string] { | ||
return exchange | ||
} | ||
|
||
return nil | ||
} | ||
|
||
private func loadExchangeData() { | ||
let decoder = JSONDecoder() | ||
guard let path = Bundle.main.path(forResource: "exchanges", ofType: "json") else { return } | ||
|
||
if let localExchangeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe), | ||
let decodedExchanges = try? decoder.decode([Exchange].self, from: localExchangeData) { | ||
mappedExchanges = decodedExchanges.reduce(into: [:]) { map, exchange in | ||
map[exchange.address] = exchange | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.