-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Create & Store Presentation #794
feat: Create & Store Presentation #794
Conversation
7e18b6a
to
36c83d1
Compare
474c547
to
c4154df
Compare
def createPresentation( | ||
presentationRequest: PresentationRequest, | ||
credentials: Seq[Credential], | ||
credentialRequests: Seq[CredentialAndRequestedAttributesPredicates], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be a good naming:
presentationRequest
: AnonCredsPresentationRequest?
@@ -159,8 +163,17 @@ object AnoncredLib { | |||
) | |||
} | |||
|
|||
// TODO FIX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CryptoKnightIOG, can you create a test for this issue and a ticket in the jira or add any other documentation that describes this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added by Fabio. Will follow up with him.
) | ||
|
||
object CredentialAndRequestedAttributesPredicates { | ||
given Conversion[CredentialAndRequestedAttributesPredicates, UniffiCredentialRequests] with { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my personal opinion a good name for CredentialAndRequestedAttributesPredicates
is CredentialRequests
or AnonCredsV1.CredentialRequests (if we can isolate the types the corresponds to the V1)
for { | ||
maybeRecord <- presentationRepository | ||
.getPresentationRecord(recordId) | ||
.mapError(RepositoryError.apply) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, it's a good practice to call logError
as well before mapError
, so we can track what exactly is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best way to handle this should defined in the ADR part of the Error Management
value brief. I'll add this specific case - call to mapError()
- to the list 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted
schemaMap <- | ||
ZIO | ||
.collectAll(schemaIds.map { schemaId => | ||
for { | ||
uri <- ZIO.attempt(new URI(schemaId)).mapError(e => UnexpectedError(e.getMessage)) | ||
content <- uriDereferencer.dereference(uri).mapError(e => UnexpectedError(e.error)) | ||
vcSchema <- parseCredentialSchema(content).mapError(e => UnexpectedError(e.message)) | ||
anoncredSchema <- AnoncredSchemaSerDesV1.schemaSerDes | ||
.deserialize(vcSchema.schema) | ||
.mapError(e => UnexpectedError(e.error)) | ||
anoncredLibSchema = | ||
SchemaDef( | ||
schemaId, | ||
anoncredSchema.version, | ||
anoncredSchema.attrNames, | ||
anoncredSchema.issuerId | ||
) | ||
} yield (schemaId, anoncredLibSchema) | ||
}) | ||
.map(_.toMap) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend extracting this logic into the method. Something like resolveSchema(schemaId)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
).toEither | ||
) | ||
.mapError((t: Throwable) => AnoncredPresentationCreationError(t)) | ||
} yield presentation | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the method is tooooo long :)
try to refactor it to a sequence of smaller functions next time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted
): ZIO[WalletAccessContext, PresentationError, PresentationRecord] = { | ||
val anoncredPresentationRequestV1 = AnoncredPresentationRequestV1( | ||
requested_attributes = Map( | ||
"sex" -> AnoncredRequestedAttributeV1( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, a good idea for refactoring is to create a package or object AnoncredsV1
and all corresponding domain classes. RequestedAttribute
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, @CryptoKnightIOG! Keep codding 👍
mediaType = Some("prism/jwt") | ||
presentation <- | ||
credentialFormat match { | ||
case CredentialFormat.JWT => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to what we did for the IssueBackgroundJobs
class, I propose to move the logic for each case
to the PresentationService
implementation. It initially leaked to the background job class because Pollux had no access to the ManagedDIDService
, which is now solved.
Note that it implies a bit of refactoring (also at the unit tests level!), so we could handle this as a tech-debt item if we don't want to hamper the delivery of this verification Epic 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will do a refactor. In the end, because there are patterns forming.
// TODO FIX | ||
// [info] uniffi.anoncreds.AnoncredsException$CreatePresentationException: Create Presentation: Error: Error: Invalid structure | ||
// [info] Caused by: Predicate is not satisfied | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need any help with those errors (e.g. from Fabio)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bvoiturier these were added by Fabio. Could be great if someone can have a look at them.
for { | ||
maybeRecord <- presentationRepository | ||
.getPresentationRecord(recordId) | ||
.mapError(RepositoryError.apply) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best way to handle this should defined in the ADR part of the Error Management
value brief. I'll add this specific case - call to mapError()
- to the list 👍
36c83d1
to
5376b74
Compare
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
0ea2a88
to
62d3dee
Compare
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
62d3dee
to
ebae28a
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Overview
Fixes https://input-output.atlassian.net/browse/ATL-6019
Checklist
My PR contains...
My changes...
Documentation
Tests