Skip to content

Commit

Permalink
Make signatures non-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBCarter committed Nov 23, 2024
1 parent 5488547 commit a6f3270
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
13 changes: 5 additions & 8 deletions Sources/XyoClient/BoundWitness/BoundWitness.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []

Expand All @@ -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
Expand All @@ -50,19 +49,17 @@ public class BoundWitness: Payload, XyoBoundWitnessBodyProtocol, XyoBoundWitness
}

func encodeMetaFields(_ container: inout KeyedEncodingContainer<CodingKeys>) 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<CodingKeys>) throws {
try container.encode(addresses, forKey: .addresses)
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)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/XyoClient/BoundWitness/BoundWitnessBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XyoClient/BoundWitness/BoundWitnessJson.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

0 comments on commit a6f3270

Please sign in to comment.