-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zachery Gyurkovitz
committed
Nov 8, 2019
1 parent
4a4fe88
commit 40bc68e
Showing
1 changed file
with
25 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Foundation | ||
|
||
public class ContractGetRecordsQuery: QueryBuilder<[TransactionRecord]> { | ||
public override init(client: Client) { | ||
super.init(client: client) | ||
|
||
body.contractGetRecords = Proto_ContractGetRecordsQuery() | ||
} | ||
|
||
/// Set the contract id to get the records of. | ||
@discardableResult | ||
public func setContract(_ id: ContractId) -> Self { | ||
body.contractGetRecords.contractID = id.toProto() | ||
|
||
return self | ||
} | ||
|
||
override func mapResponse(_ response: Proto_Response) throws -> [TransactionRecord] { | ||
guard case .contractGetRecordsResponse(let response) = response.response else { | ||
throw HederaError(message: "query response was not of type 'contractGetRecords'") | ||
} | ||
|
||
return response.records.map(TransactionRecord.init) | ||
} | ||
} |