Skip to content

Commit

Permalink
Remove FunctionResult as it was based on an old broken version of the…
Browse files Browse the repository at this point in the history
… JS SDK
  • Loading branch information
mehcode committed Jan 3, 2020
1 parent d16304f commit 85a9362
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 101 deletions.
80 changes: 0 additions & 80 deletions Sources/Hedera/FunctionResult.swift

This file was deleted.

36 changes: 18 additions & 18 deletions Sources/Hedera/TransactionRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public struct TransactionRecord {
let transactionId: TransactionId
let memo: String
let transactionFee: UInt64
let contractResult: ContractResultType?
// let contractResult: ContractResultType?
let transferList: [AccountAmount]

init(_ proto: Proto_TransactionRecord) {
Expand All @@ -18,7 +18,7 @@ public struct TransactionRecord {
self.transactionId = TransactionId(proto.transactionID)!
self.memo = proto.memo
self.transactionFee = UInt64(proto.transactionFee)
self.contractResult = ContractResultType(proto.body)
// self.contractResult = ContractResultType(proto.body)
self.transferList = proto.transferList.accountAmounts.map { AccountAmount($0) }
}
}
Expand All @@ -33,20 +33,20 @@ public struct AccountAmount {
}
}

public enum ContractResultType {
case call(FunctionResult)
case create(FunctionResult)
// public enum ContractResultType {
// case call(FunctionResult)
// case create(FunctionResult)

init?(_ body: Proto_TransactionRecord.OneOf_Body?) {
if let body = body {
switch body {
case .contractCallResult(let result):
self = ContractResultType.call(FunctionResult(result))
case .contractCreateResult(let result):
self = ContractResultType.create(FunctionResult(result))
}
} else {
return nil
}
}
}
// init?(_ body: Proto_TransactionRecord.OneOf_Body?) {
// if let body = body {
// switch body {
// case .contractCallResult(let result):
// self = ContractResultType.call(FunctionResult(result))
// case .contractCreateResult(let result):
// self = ContractResultType.create(FunctionResult(result))
// }
// } else {
// return nil
// }
// }
// }
6 changes: 3 additions & 3 deletions Sources/Hedera/contract/ContractCallLocalQuery.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Sodium
import Foundation

public class ContractCallLocalQuery: QueryBuilder<FunctionResult> {
public class ContractCallLocalQuery: QueryBuilder<Void> {
public override init(node: Node) {
super.init(node: node)

Expand All @@ -27,11 +27,11 @@ public class ContractCallLocalQuery: QueryBuilder<FunctionResult> {
return self
}

override func mapResponse(_ response: Proto_Response) -> Result<FunctionResult, HederaError> {
override func mapResponse(_ response: Proto_Response) -> Result<Void, HederaError> {
guard case .contractCallLocal(let response) = response.response else {
return .failure(HederaError(message: "query response was not of type 'contractCallLocal'"))
}

return .success(FunctionResult(response.functionResult))
return .success(())
}
}

0 comments on commit 85a9362

Please sign in to comment.