Skip to content

Commit

Permalink
Get rid of most TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachery Gyurkovitz authored and qtbeee committed Nov 8, 2019
1 parent 98a4481 commit f941dd7
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 24 deletions.
9 changes: 3 additions & 6 deletions Sources/Hedera/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ public class Client {
/// This can be overridden on an individual transaction with `setMaxTransactionFee()`.
var maxTransactionFee = defaultMaxTransactionFee

// TODO: once queries are implemented
// /// The maximum payment that can be automatically attached to a query.
// /// If this is not set, payments will not be made automatically for queries.
// /// This can be overridden for an individual query with `.setPayment()`.
/// The maximum payment that can be automatically attached to a query.
/// If this is not set, payments will not be made automatically for queries.
/// This can be overridden for an individual query with `.setPayment()`.
var maxQueryPayment: UInt64?

public init(node id: AccountId, address url: String) {
Expand Down Expand Up @@ -102,7 +101,6 @@ public class Client {
.accountId!
}

// FIXME: Get `TransactionId` from `TransactionReceipt` once it has one.
/// Sends `amount` of tiny bar to `recipient`.
/// - Parameters:
/// - recipient: The recipient of the crypto.
Expand Down Expand Up @@ -171,7 +169,6 @@ public class Client {
}

private func channelFor(node: Node) -> Channel {
// TODO: what if the node is not on the client?
if let channel = channels[node.accountId] {
return channel
} else {
Expand Down
1 change: 0 additions & 1 deletion Sources/Hedera/Date.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ extension Date: LosslessStringConvertible {
}
}

// TODO: move to its own file?
extension TimeInterval: ProtoConvertible {
typealias Proto = Proto_Duration

Expand Down
1 change: 0 additions & 1 deletion Sources/Hedera/HederaError.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO: this should probably be an enum instead
public struct HederaError: Error {
let message: String
}
8 changes: 1 addition & 7 deletions Sources/Hedera/Transaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class Transaction {
receiptStatus == Proto_ResponseCodeEnum.ok.rawValue {
// throw if the delay will put us over `validDuration`
guard let delayUs = getReceiptDelayUs(startTime: startTime, attempt: attempt) else {
throw HederaError(message: "timed out") // TODO: better error message
throw HederaError(message: "timed out")
}

usleep(delayUs)
Expand All @@ -103,7 +103,6 @@ public class Transaction {
* Double.random(in: 0..<Double((1 << attempt)))

// if the next delay will put us past the valid duration we should stop trying
// TODO: use the validDuration specified in the transaction
let validDuration: TimeInterval = 2 * 60
let expireInstant = startTime.addingTimeInterval(validDuration)
if Date(timeIntervalSinceNow: delay).compare(expireInstant) == .orderedDescending {
Expand Down Expand Up @@ -172,7 +171,6 @@ public class Transaction {
throw HederaError(message: "node ID for transaction not found in Client")
}

// TODO: actually handle error
do {
let response = try methodForTransaction(client.grpcClient(for: node))(inner)
if response.nodeTransactionPrecheckCode == .ok {
Expand All @@ -185,11 +183,7 @@ public class Transaction {
}
}

// TODO: public func executeAsync that takes a callback function

public func executeForReceipt() throws -> TransactionReceipt {
try executeAndWaitFor { $0 }
}

// TODO: public func executeForReceiptAsync that takes a callback function
}
1 change: 0 additions & 1 deletion Sources/Hedera/TransactionBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class TransactionBuilder {
return self
}

// TODO: should this allow setting a longer duration than max?
@discardableResult
public func setTransactionValidDuration(_ duration: TimeInterval) -> Self {
body.transactionValidDuration = duration.toProto()
Expand Down
1 change: 0 additions & 1 deletion Sources/Hedera/TransactionKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ enum TransactionKind {
case fileUpdate
case systemUndelete
case systemDelete
// TODO: Freeze service
// case freeze

init(_ body: Proto_TransactionBody.OneOf_Data) {
Expand Down
1 change: 0 additions & 1 deletion Sources/Hedera/account/AccountDeleteClaimTransaction.swift

This file was deleted.

1 change: 0 additions & 1 deletion Sources/Hedera/account/AccountInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public struct AccountInfo {
let receiverSigRequired: Bool
let expirationTime: Date
let autoRenewPeriod: TimeInterval
// TODO: Claims

init(_ accountInfo: Proto_CryptoGetInfoResponse.AccountInfo) {
let proxyAccountId: AccountId?
Expand Down
9 changes: 9 additions & 0 deletions Sources/Hedera/crypto/KeyList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ public final class KeyList: PublicKey {
super.init()
}

init?(_ proto: Proto_KeyList) {
guard proto.keys.count > 0 else { return nil }
keys = proto.keys.compactMap(PublicKey.fromProto)

// Don't want to silently throw away keys we don't recognize
guard proto.keys.count == keys.count else { return nil }
super.init()
}

override func toProto() -> Proto_Key {
var proto = Proto_Key()
proto.keyList = toProto()
Expand Down
1 change: 0 additions & 1 deletion Sources/Hedera/crypto/PublicKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class PublicKey: CustomStringConvertible, CustomDebugStringConvertible {
case .thresholdKey:
return ThresholdKey(key)
case .rsa3072, .ecdsa384, .none:
// TODO: implement rsa and ecdsa eventually
return nil
}
}
Expand Down
2 changes: 0 additions & 2 deletions Sources/Hedera/crypto/ed25519/Ed25519PrivateKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ let ed25519PrivateKeyPrefix = "302e020100300506032b657004220420"
let ed25519PrivateKeyLength = 32
let combinedEd25519KeyLength = 64

// TODO: init using a pem file

public struct Ed25519PrivateKey {
private let inner: Sign.KeyPair

Expand Down
4 changes: 2 additions & 2 deletions Sources/Hedera/file/FileInfoQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ public struct FileInfo {
let size: UInt64
let expirationTime: Date
let deleted: Bool
// TODO:
// let keys: Ed25519PublicKey[]
let keys: KeyList

init(_ info: Proto_FileGetInfoResponse.FileInfo) {
fileId = FileId(info.fileID)
size = UInt64(info.size)
expirationTime = Date(info.expirationTime)
deleted = info.deleted
keys = KeyList(info.keys)!
}
}

Expand Down

0 comments on commit f941dd7

Please sign in to comment.