Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed May 20, 2024
1 parent 93c9360 commit e40c769
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import Foundation

internal struct NonceMetadataParams: Codable {
internal struct NonceMetadataParams {
public var namespace: String?
public var pub_key_X: String
public var pub_key_Y: String
public var set_data: SetNonceData
public var key_type: TorusKeyType
public var signature: String
public var encodedData: String
public var seed: String
public var seed: String?

public init(pub_key_X: String, pub_key_Y: String, setData: SetNonceData, encodedData: String, signature: String, namespace: String? = nil, key_type: TorusKeyType = .secp256k1, seed: String = "") {
public init(pub_key_X: String, pub_key_Y: String, setData: SetNonceData, encodedData: String, signature: String, namespace: String? = nil, key_type: TorusKeyType = .secp256k1, seed: String? = nil) {
self.namespace = namespace
self.pub_key_X = pub_key_X
self.pub_key_Y = pub_key_Y
Expand Down
16 changes: 15 additions & 1 deletion Sources/TorusUtils/Helpers/jsonRPC/Requests/SetNonceData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ internal struct SetNonceData: Codable {
public var timestamp: String?
public var seed: String?

public init(operation: String? = nil, data: String? = nil, timestamp: String? = nil, seed: String = "") {
public init(operation: String? = nil, data: String? = nil, timestamp: String? = nil, seed: String? = nil) {
self.operation = operation
self.data = data
self.timestamp = timestamp
self.seed = seed
}

public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(self.operation, forKey: .operation)
try container.encodeIfPresent(self.data, forKey: .data)
try container.encodeIfPresent(self.timestamp, forKey: .timestamp)
// There is a bug in the server that expects seed to be empty and not optional, when it checks signatures. It is optional in the interface as such.
if (seed == nil) {
try container.encode("", forKey: .seed)
} else {
try container.encode(self.seed, forKey: .seed)
}

}
}

0 comments on commit e40c769

Please sign in to comment.