Skip to content

Commit

Permalink
Implement ContractLogInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
janaakhterov authored and qtbeee committed Nov 6, 2019
1 parent b7b3d5a commit a1716ca
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Sources/Hedera/FunctionResult.swift
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import Foundation

public class FunctionResult {
public struct FunctionResult {
let contractId: ContractId
let contractCallResult: Data
let errorMessage: String
let bloom: Data
let gasUsed: UInt64
// todo let logInfoList: [ContractLogInfo]
let logInfoList: [ContractLogInfo]

init(_ proto: Proto_ContractFunctionResult) {
self.contractId = ContractId(proto.contractID)
self.contractCallResult = proto.contractCallResult
self.errorMessage = proto.errorMessage
self.bloom = proto.bloom
self.gasUsed = UInt64(proto.gasUsed)
self.logInfoList = proto.logInfo.map { ContractLogInfo($0) }
}

public func getString(_ index: Int) -> String? {
Expand Down Expand Up @@ -63,3 +64,17 @@ public class FunctionResult {
return Array(contractCallResult[(index * 32 + 12)..<((index + 1) * 32)])
}
}

public struct ContractLogInfo {
let contractId: ContractId
let bloom: Data
let topicList: [Data]
let data: Data

init(_ proto: Proto_ContractLoginfo) {
self.contractId = ContractId(proto.contractID)
self.bloom = proto.bloom
self.topicList = proto.topic
self.data = proto.data
}
}

0 comments on commit a1716ca

Please sign in to comment.