Perform various cleanup tasks (#24)
This commit is contained in:
parent
bee2fc177f
commit
46a14affe7
@ -7,6 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [1.0.0] - 2021-04-05
|
||||
|
||||
## 1.0.0-pre1 - 2021-04-05
|
||||
## 1.0.0-pre1 - 2021-03-15
|
||||
|
||||
[1.0.0]: https://github.com/mobilecoinofficial/MobileCoin-Swift/compare/1.0.0-pre1...1.0.0
|
||||
|
||||
@ -139,7 +139,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1140;
|
||||
LastUpgradeCheck = 1240;
|
||||
LastUpgradeCheck = 1250;
|
||||
ORGANIZATIONNAME = "MobileCoin Inc.";
|
||||
TargetAttributes = {
|
||||
270686882474C4D800B82C57 = {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1240"
|
||||
LastUpgradeVersion = "1250"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1240"
|
||||
LastUpgradeVersion = "1250"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1240"
|
||||
LastUpgradeVersion = "1250"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@ -8,9 +8,6 @@ GIT
|
||||
fourflusher (~> 2.0)
|
||||
xcpretty (~> 0.3.0)
|
||||
|
||||
GEM
|
||||
specs:
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
|
||||
@ -50,40 +50,12 @@ final class Account {
|
||||
return Balance(values: txOutValues, blockCount: blockCount)
|
||||
}
|
||||
|
||||
func cachedBalance(atBlockCount blockCount: UInt64) -> Balance? {
|
||||
logger.info("atBlockCount: \(blockCount)")
|
||||
guard blockCount <= knowableBlockCount else {
|
||||
logger.info("""
|
||||
error - blockCount: \(blockCount) > \
|
||||
knowableBlockCount: \(knowableBlockCount)
|
||||
""")
|
||||
return nil
|
||||
}
|
||||
let txOutValues = allTxOutTrackers
|
||||
.filter { $0.receivedAndUnspent(asOfBlockCount: blockCount) }
|
||||
.map { $0.knownTxOut.value }
|
||||
return Balance(values: txOutValues, blockCount: blockCount)
|
||||
}
|
||||
|
||||
var cachedAccountActivity: AccountActivity {
|
||||
let blockCount = knowableBlockCount
|
||||
let txOuts = allTxOutTrackers.compactMap { OwnedTxOut($0, atBlockCount: blockCount) }
|
||||
return AccountActivity(txOuts: txOuts, blockCount: blockCount)
|
||||
}
|
||||
|
||||
func cachedAccountActivity(asOfBlockCount blockCount: UInt64) -> AccountActivity? {
|
||||
logger.info("asOfBlockCount: \(blockCount)")
|
||||
guard blockCount <= knowableBlockCount else {
|
||||
logger.info("""
|
||||
error - blockCount: \(blockCount) > \
|
||||
knowableBlockCount: \(knowableBlockCount)
|
||||
""")
|
||||
return nil
|
||||
}
|
||||
let txOuts = allTxOutTrackers.compactMap { OwnedTxOut($0, atBlockCount: blockCount) }
|
||||
return AccountActivity(txOuts: txOuts, blockCount: blockCount)
|
||||
}
|
||||
|
||||
var ownedTxOuts: [KnownTxOut] {
|
||||
ownedTxOutsAndBlockCount.txOuts
|
||||
}
|
||||
@ -108,20 +80,6 @@ final class Account {
|
||||
return (txOuts: txOuts, blockCount: knowableBlockCount)
|
||||
}
|
||||
|
||||
func receivedAndUnspentTxOuts(atBlockCount blockCount: UInt64) -> [KnownTxOut]? {
|
||||
logger.info("atBlockCount: \(blockCount)")
|
||||
guard blockCount <= knowableBlockCount else {
|
||||
logger.info("""
|
||||
error - blockCount: \(blockCount) > \
|
||||
knowableBlockCount: \(knowableBlockCount)
|
||||
""")
|
||||
return nil
|
||||
}
|
||||
return allTxOutTrackers
|
||||
.filter { $0.receivedAndUnspent(asOfBlockCount: blockCount) }
|
||||
.map { $0.knownTxOut }
|
||||
}
|
||||
|
||||
func addTxOuts(_ txOuts: [KnownTxOut]) {
|
||||
allTxOutTrackers.append(contentsOf: txOuts.map { TxOutTracker($0) })
|
||||
}
|
||||
|
||||
@ -181,19 +181,14 @@ extension AccountKey.FogInfo: Hashable {}
|
||||
|
||||
struct AccountKeyWithFog {
|
||||
let accountKey: AccountKey
|
||||
let fogInfo: AccountKey.FogInfo
|
||||
|
||||
init?(accountKey: AccountKey) {
|
||||
guard accountKey.fogInfo != nil else {
|
||||
guard let fogInfo = accountKey.fogInfo else {
|
||||
return nil
|
||||
}
|
||||
self.accountKey = accountKey
|
||||
}
|
||||
|
||||
var fogInfo: AccountKey.FogInfo {
|
||||
guard let fogInfo = accountKey.fogInfo else {
|
||||
// Safety: accountKey is guaranteed to have fogInfo.
|
||||
logger.fatalError("accountKey doesn't have fogInfo")
|
||||
}
|
||||
return fogInfo
|
||||
self.accountKey = accountKey
|
||||
self.fogInfo = fogInfo
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ public enum MobUri {
|
||||
guard let scheme = uri.scheme else {
|
||||
logger.info("MobUri scheme cannot be empty.")
|
||||
return .failure(InvalidInputError("MobUri scheme cannot be empty."))
|
||||
|
||||
}
|
||||
guard scheme == McConstants.MOB_URI_SCHEME else {
|
||||
logger.info(
|
||||
|
||||
@ -94,65 +94,5 @@ struct MobileCoinUrl<Scheme: MobileCoin.Scheme>: MobileCoinUrlProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
struct AnyMobileCoinUrl: MobileCoinUrlProtocol {
|
||||
static func make(string: String) -> Result<AnyMobileCoinUrl, InvalidInputError> {
|
||||
make(string: string, useTlsOverride: nil)
|
||||
}
|
||||
|
||||
static func make(string: String, useTls: Bool) -> Result<AnyMobileCoinUrl, InvalidInputError> {
|
||||
make(string: string, useTlsOverride: useTls)
|
||||
}
|
||||
|
||||
// swiftlint:disable discouraged_optional_boolean
|
||||
private static func make(string: String, useTlsOverride: Bool?)
|
||||
-> Result<AnyMobileCoinUrl, InvalidInputError>
|
||||
{
|
||||
// swiftlint:enable discouraged_optional_boolean
|
||||
guard let url = URL(string: string) else {
|
||||
return .failure(InvalidInputError("Could not parse url: \(string)"))
|
||||
}
|
||||
|
||||
guard let host = url.host, !host.isEmpty else {
|
||||
return .failure(InvalidInputError("Invalid host: \(string)"))
|
||||
}
|
||||
|
||||
return .success(AnyMobileCoinUrl(url: url, host: host, useTlsOverride: useTlsOverride))
|
||||
}
|
||||
|
||||
let url: URL
|
||||
|
||||
let useTls: Bool
|
||||
let host: String
|
||||
let port: Int
|
||||
|
||||
// swiftlint:disable discouraged_optional_boolean
|
||||
private init(url: URL, host: String, useTlsOverride: Bool?) {
|
||||
// swiftlint:enable discouraged_optional_boolean
|
||||
self.url = url
|
||||
self.host = host
|
||||
|
||||
if let useTls = useTlsOverride {
|
||||
self.useTls = useTls
|
||||
} else {
|
||||
switch url.scheme {
|
||||
case "http":
|
||||
self.useTls = false
|
||||
case "https":
|
||||
self.useTls = true
|
||||
default:
|
||||
self.useTls = true
|
||||
}
|
||||
}
|
||||
|
||||
if let port = url.port {
|
||||
self.port = port
|
||||
} else if !self.useTls {
|
||||
self.port = 80
|
||||
} else {
|
||||
self.port = 443
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension MobileCoinUrl: Equatable {}
|
||||
extension MobileCoinUrl: Hashable {}
|
||||
|
||||
@ -12,10 +12,6 @@ struct ReceiptStatusChecker {
|
||||
}
|
||||
|
||||
func status(_ receipt: Receipt) -> Result<ReceiptStatus, InvalidInputError> {
|
||||
receivedStatus(receipt).map { ReceiptStatus($0) }
|
||||
}
|
||||
|
||||
func receivedStatus(_ receipt: Receipt) -> Result<Receipt.ReceivedStatus, InvalidInputError> {
|
||||
account.readSync { $0.cachedReceivedStatus(of: receipt) }
|
||||
account.readSync { $0.cachedReceivedStatus(of: receipt) }.map { ReceiptStatus($0) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ extension ConnectionSession.Fixtures {
|
||||
extension ConnectionSession.Fixtures.Default {
|
||||
|
||||
fileprivate static func url() throws -> MobileCoinUrlProtocol {
|
||||
try AnyMobileCoinUrl.make(string: "mc://node1.fake.mobilecoin.com").get()
|
||||
try ConsensusUrl.make(string: "mc://node1.fake.mobilecoin.com").get()
|
||||
}
|
||||
|
||||
fileprivate static let credentials = BasicCredentials(username: "user1", password: "password1")
|
||||
@ -107,8 +107,7 @@ extension ConnectionSession.Fixtures.Default {
|
||||
extension ConnectionSession.Fixtures.Insecure {
|
||||
|
||||
fileprivate static func url() throws -> MobileCoinUrlProtocol {
|
||||
try AnyMobileCoinUrl.make(string: "insecure-mc://node1.fake.mobilecoin.com", useTls: false)
|
||||
.get()
|
||||
try ConsensusUrl.make(string: "insecure-mc://node1.fake.mobilecoin.com").get()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user