diff --git a/Sources/Hedera/Client.swift b/Sources/Hedera/Client.swift index fd6ba271..8279b789 100644 --- a/Sources/Hedera/Client.swift +++ b/Sources/Hedera/Client.swift @@ -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) { @@ -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. @@ -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 { diff --git a/Sources/Hedera/Date.swift b/Sources/Hedera/Date.swift index 43002a8e..8532b6f8 100644 --- a/Sources/Hedera/Date.swift +++ b/Sources/Hedera/Date.swift @@ -54,7 +54,6 @@ extension Date: LosslessStringConvertible { } } -// TODO: move to its own file? extension TimeInterval: ProtoConvertible { typealias Proto = Proto_Duration diff --git a/Sources/Hedera/HederaError.swift b/Sources/Hedera/HederaError.swift index 79f40143..720c20e9 100644 --- a/Sources/Hedera/HederaError.swift +++ b/Sources/Hedera/HederaError.swift @@ -1,4 +1,3 @@ -// TODO: this should probably be an enum instead public struct HederaError: Error { let message: String } diff --git a/Sources/Hedera/Transaction.swift b/Sources/Hedera/Transaction.swift index 7f4f4f1f..fe10f244 100644 --- a/Sources/Hedera/Transaction.swift +++ b/Sources/Hedera/Transaction.swift @@ -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) @@ -103,7 +103,6 @@ public class Transaction { * Double.random(in: 0.. TransactionReceipt { try executeAndWaitFor { $0 } } - - // TODO: public func executeForReceiptAsync that takes a callback function } diff --git a/Sources/Hedera/TransactionBuilder.swift b/Sources/Hedera/TransactionBuilder.swift index 823231de..f805f200 100644 --- a/Sources/Hedera/TransactionBuilder.swift +++ b/Sources/Hedera/TransactionBuilder.swift @@ -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() diff --git a/Sources/Hedera/TransactionKind.swift b/Sources/Hedera/TransactionKind.swift index 73ca8259..c8e80cf4 100644 --- a/Sources/Hedera/TransactionKind.swift +++ b/Sources/Hedera/TransactionKind.swift @@ -15,7 +15,6 @@ enum TransactionKind { case fileUpdate case systemUndelete case systemDelete - // TODO: Freeze service // case freeze init(_ body: Proto_TransactionBody.OneOf_Data) { diff --git a/Sources/Hedera/account/AccountDeleteClaimTransaction.swift b/Sources/Hedera/account/AccountDeleteClaimTransaction.swift deleted file mode 100644 index 70b786d1..00000000 --- a/Sources/Hedera/account/AccountDeleteClaimTransaction.swift +++ /dev/null @@ -1 +0,0 @@ -// TODO diff --git a/Sources/Hedera/account/AccountInfo.swift b/Sources/Hedera/account/AccountInfo.swift index 32e4d658..2fd970ff 100644 --- a/Sources/Hedera/account/AccountInfo.swift +++ b/Sources/Hedera/account/AccountInfo.swift @@ -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? diff --git a/Sources/Hedera/crypto/KeyList.swift b/Sources/Hedera/crypto/KeyList.swift index 645689fb..cb676b4a 100644 --- a/Sources/Hedera/crypto/KeyList.swift +++ b/Sources/Hedera/crypto/KeyList.swift @@ -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() diff --git a/Sources/Hedera/crypto/PublicKey.swift b/Sources/Hedera/crypto/PublicKey.swift index 9e36eaf4..e4a594a8 100644 --- a/Sources/Hedera/crypto/PublicKey.swift +++ b/Sources/Hedera/crypto/PublicKey.swift @@ -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 } } diff --git a/Sources/Hedera/crypto/ed25519/Ed25519PrivateKey.swift b/Sources/Hedera/crypto/ed25519/Ed25519PrivateKey.swift index 83b3d9e2..73de238a 100644 --- a/Sources/Hedera/crypto/ed25519/Ed25519PrivateKey.swift +++ b/Sources/Hedera/crypto/ed25519/Ed25519PrivateKey.swift @@ -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 diff --git a/Sources/Hedera/file/FileInfoQuery.swift b/Sources/Hedera/file/FileInfoQuery.swift index d0f0c4ff..33c2a552 100644 --- a/Sources/Hedera/file/FileInfoQuery.swift +++ b/Sources/Hedera/file/FileInfoQuery.swift @@ -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)! } }