-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pluto): hide pluto codable implementation for messages and did
- Loading branch information
1 parent
dd9f924
commit 85180b4
Showing
10 changed files
with
128 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,36 @@ | ||
import Domain | ||
import Foundation | ||
|
||
extension DID: Codable { | ||
struct CodableDID: Codable { | ||
enum CodingKeys: String, CodingKey { | ||
case schema | ||
case method | ||
case methodId | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
let did: DID | ||
|
||
init(did: DID) { | ||
self.did = did | ||
} | ||
|
||
func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(schema, forKey: .schema) | ||
try container.encode(method, forKey: .method) | ||
try container.encode(methodId, forKey: .methodId) | ||
try container.encode(did.schema, forKey: .schema) | ||
try container.encode(did.method, forKey: .method) | ||
try container.encode(did.methodId, forKey: .methodId) | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let schema = try container.decode(String.self, forKey: .schema) | ||
let method = try container.decode(DIDMethod.self, forKey: .method) | ||
let methodId = try container.decode(DIDMethodId.self, forKey: .methodId) | ||
|
||
self.init(schema: schema, method: method, methodId: methodId) | ||
self.init(did: .init( | ||
schema: schema, | ||
method: method, | ||
methodId: methodId | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters