diff --git a/Sources/XyoClient/BoundWitness/Body/BoundWitnessBodyProtocol.swift b/Sources/XyoClient/BoundWitness/Body/BoundWitnessBodyProtocol.swift index 3643030..ed5f3da 100644 --- a/Sources/XyoClient/BoundWitness/Body/BoundWitnessBodyProtocol.swift +++ b/Sources/XyoClient/BoundWitness/Body/BoundWitnessBodyProtocol.swift @@ -5,4 +5,5 @@ public protocol XyoBoundWitnessBodyProtocol { var payload_hashes: [String] { get set } var payload_schemas: [String] { get set } var previous_hashes: [String?] { get set } + var query: String? { get set } } diff --git a/Sources/XyoClient/BoundWitness/BoundWitness.swift b/Sources/XyoClient/BoundWitness/BoundWitness.swift index 3112a9e..8f9a858 100644 --- a/Sources/XyoClient/BoundWitness/BoundWitness.swift +++ b/Sources/XyoClient/BoundWitness/BoundWitness.swift @@ -10,7 +10,7 @@ public class BoundWitness: Payload, XyoBoundWitnessBodyProtocol, XyoBoundWitness public var _hash: String? = nil - public var _signatures: [String?]? = nil + public var _signatures: [String]? = nil public var addresses: [String] = [] @@ -29,7 +29,6 @@ public class BoundWitness: Payload, XyoBoundWitnessBodyProtocol, XyoBoundWitness enum CodingKeys: String, CodingKey { case _client case _hash - case _previous_hash case _signatures case addresses case payload_hashes @@ -50,9 +49,9 @@ public class BoundWitness: Payload, XyoBoundWitnessBodyProtocol, XyoBoundWitness } func encodeMetaFields(_ container: inout KeyedEncodingContainer) throws { - try container.encode(_client, forKey: ._client) - try container.encode(_hash, forKey: ._hash) - try container.encode(_signatures, forKey: ._signatures) + try container.encodeIfNotNil(_client, forKey: ._client) + try container.encodeIfNotNil(_hash, forKey: ._hash) + try container.encodeIfNotNil(_signatures, forKey: ._signatures) } func encodeBodyFields(_ container: inout KeyedEncodingContainer) throws { @@ -60,9 +59,7 @@ public class BoundWitness: Payload, XyoBoundWitnessBodyProtocol, XyoBoundWitness try container.encode(payload_hashes, forKey: .payload_hashes) try container.encode(payload_schemas, forKey: .payload_schemas) try container.encode(previous_hashes, forKey: .previous_hashes) - if query != nil { - try container.encode(query, forKey: .query) - } + try container.encodeIfNotNil(query, forKey: .query) try container.encode(schema, forKey: .schema) } diff --git a/Sources/XyoClient/BoundWitness/BoundWitnessBuilder.swift b/Sources/XyoClient/BoundWitness/BoundWitnessBuilder.swift index d9c0e73..5aec07d 100644 --- a/Sources/XyoClient/BoundWitness/BoundWitnessBuilder.swift +++ b/Sources/XyoClient/BoundWitness/BoundWitnessBuilder.swift @@ -61,7 +61,7 @@ public class BoundWitnessBuilder { return self } - public func sign(hash: String) throws -> [String?] { + public func sign(hash: String) throws -> [String] { return try self._accounts.map { try $0.sign(hash: hash) } diff --git a/Sources/XyoClient/BoundWitness/BoundWitnessJson.swift b/Sources/XyoClient/BoundWitness/BoundWitnessJson.swift index ae0af91..cf31514 100644 --- a/Sources/XyoClient/BoundWitness/BoundWitnessJson.swift +++ b/Sources/XyoClient/BoundWitness/BoundWitnessJson.swift @@ -16,7 +16,7 @@ public class XyoBoundWitnessJson: XyoBoundWitnessBodyJson, XyoBoundWitnessMetaPr public var _client: String? public var _hash: String? - public var _signatures: [String?]? + public var _signatures: [String]? public var _previous_hash: String? public var _query: String? diff --git a/Sources/XyoClient/BoundWitness/Meta/BoundWitnessMetaProtocol.swift b/Sources/XyoClient/BoundWitness/Meta/BoundWitnessMetaProtocol.swift index 46f74ca..989b906 100644 --- a/Sources/XyoClient/BoundWitness/Meta/BoundWitnessMetaProtocol.swift +++ b/Sources/XyoClient/BoundWitness/Meta/BoundWitnessMetaProtocol.swift @@ -3,5 +3,5 @@ import Foundation public protocol XyoBoundWitnessMetaProtocol { var _client: String? { get set } var _hash: String? { get set } - var _signatures: [String?]? { get set } + var _signatures: [String]? { get set } }