OperationUnknown
public class OperationUnknown : Operation
A subclass of Operation
meant to catch any, currently, unsupported operations. The Tezos protocol can add new operations at any time. If not Codable
struct / class is present to parse it, then that operation can’t be performed.
This class allows for clients to parse the JSON, capturing all of the data, enabling the ability to add counter, source and fees, without needing to know what type of operation it is.
Class can be encoded as JSON and presented to the user to confirm if they want to trust it or not
-
We need to capture and return whatever
kind
value is supplied. But due to the fact thatOperation
will parse this as an enum, with a fixed number of cases we need to capture it seperately and overwritekind
during the encode processDeclaration
Swift
public let unknownKind: String
-
A dicitoanry containing all the top level keys and values. May contain string, decimal, bool, array of type Any, or dictionary of type [String: Any]
Declaration
Swift
public let allOtherProperties: [String : Any]
-
Iterate through every key in the JSON and capture them all. Pass the object up to the super to pull out source, counter, fees etc
Declaration
Swift
public required init(from decoder: Decoder) throws
-
Encode all values from
allOtherProperties
into a JSON dictionary, use unknownKind as thekind
value, and then add anything applied to the super classDeclaration
Swift
public override func encode(to encoder: Encoder) throws