Skip to content

Commit

Permalink
fix: schema download optional (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
goncalo-frade-iohk authored Jan 27, 2024
1 parent 5be41d3 commit 37655c1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct AnonCredentialDefinition: Codable {
let z: String
}

let issuerId: String
let issuerId: String?
let schemaId: String
let type: String
let tag: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
struct AnonCredentialSchema: Codable {
let name: String
let version: String
let attrNames: [String]
let attrNames: [String]?
let issuerId: String
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Domain
import Foundation

struct AnoncredsCredentialStack: Codable {
let schema: AnonCredentialSchema
let schema: AnonCredentialSchema?
let definition: AnonCredentialDefinition
let credential: AnonCredential
}
Expand All @@ -20,7 +20,7 @@ extension AnoncredsCredentialStack: Domain.Credential {
}

var issuer: String {
definition.issuerId
definition.issuerId ?? ""
}

var subject: String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ struct AnoncredsPresentation {
)

let credential = stack.credential

guard let stackSchema = stack.schema else {
throw PolluxError.invalidCredentialError
}
let schema = Schema.init(
name: stack.schema.name,
version: stack.schema.version,
attrNames: AttributeNames(stack.schema.attrNames),
issuerId: stack.schema.issuerId
name: stackSchema.name,
version: stackSchema.version,
attrNames: AttributeNames(stackSchema.attrNames ?? []),
issuerId: stackSchema.issuerId
)

let credentialDefinition = try stack.definition.getAnoncred()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct ParseAnoncredsCredentialFromMessage {
let processedCredentialJson = try processedCredential.getJson().tryData(using: .utf8)
let finalCredential = try JSONDecoder().decode(AnonCredential.self, from: processedCredentialJson)
return AnoncredsCredentialStack(
schema: try JSONDecoder.didComm().decode(AnonCredentialSchema.self, from: schemaData),
schema: try? JSONDecoder.didComm().decode(AnonCredentialSchema.self, from: schemaData),
definition: try JSONDecoder.didComm().decode(AnonCredentialDefinition.self, from: credentialDefinitionData),
credential: finalCredential
)
Expand Down

0 comments on commit 37655c1

Please sign in to comment.