-
Notifications
You must be signed in to change notification settings - Fork 0
Proposed improvement definition for the core mobile library implementation #133
Comments
Like this object oriented approach. Some comments:
Tickets in this context are used to inform that there is a claim request that is not resolved yet. When tickets are resolved an event is produced. You could get the claim in the event, but not before. In this case the event already includes the ID of the claim, so it's very easy to fetch the claim within the event. In general tickets are used to track pending actions (both internally and to provide info to the user). |
Markdown tip: when you want to add code snippets, you can do it using:
Just make sure that the accent quotes are on separated lines, here I've putted it together so it renders |
Id3IdentitySettings is an object to setup the identity, so each path will be specific for the identity that is going to be created with that IdentitySettings object, like this we save having an identity constructor with too many parameters. About getting the claim with the ticket, thanks for making it more clear how it works. I'd suggest then to change the method to this: // Get Claim from Id
String claim = Identity.getClaim(claimID) |
I think it make sense to have a method to set parameters that are common to all identities and then methods to create / load that only have the ones that are Identity specific. For instance: Id3IdentitySettings idSettings = new Id3Settings() {
“sharedPath” : sharedPath,
“web3Url”: web3Url,
“checkTicketsPeriod”: checkTicketsPeriod,
“extraGenesisClaims”: extraGenesisClaims
}
Id3Identity identity1 = Id3IdentityFactory.createIdentity("/path/1", "pass_1", idSettings) { event, exception ->
Log.i("EVENT RECEIVED”)
}
Id3Identity identity2 = Id3IdentityFactory.createIdentity("/path/2", "pass_2", idSettings) { event, exception ->
Log.i("EVENT RECEIVED”)
} Sorry that first time I read the code I misunderstood that you were creating two different identities, and since this is not the case that should work. But with that being said I think that what I'm porpoising makes sense as it would be very clean for scenarios were multiple identities are required. Id3Settings sharedSettings = new Id3Settings() {
“sharedPath” : sharedPath,
“web3Url”: web3Url,
“checkTicketsPeriod”: checkTicketsPeriod,
“extraGenesisClaims”: extraGenesisClaims
}
Id3IdentitySettings idSettings = new Id3IdentitySettings() {
“path” : path,
“password”: password,
}
Id3Identity identity = Id3IdentityFactory.createIdentity(sharedSettings, idSettings) { event, exception ->
Log.i("EVENT RECEIVED”)
} |
I like the third option, but passing it as a parameter of the method createIdentity seems odd. What about this? Id3Settings sharedSettings = new Id3Settings() {
“sharedPath” : sharedPath,
“web3Url”: web3Url,
“checkTicketsPeriod”: checkTicketsPeriod,
“extraGenesisClaims”: extraGenesisClaims
}
Id3IdentitySettings idSettings = new Id3IdentitySettings() {
“path” : path,
“password”: password,
}
Id3IdentityFactory.init(sharedSettings) // this static method could be called also initialize or setup
Id3Identity identity = Id3IdentityFactory.createIdentity(idSettings) { event, exception ->
Log.i("EVENT RECEIVED”)
} |
// Setup identity settings (mandatory and optional as defined in documentation for integrator)
Id3IdentitySettings idSettings = new Id3IdentitySettings() {
“path” : path,
“sharedPath” : sharedPath,
“password”: password,
“web3Url”: web3Url,
“checkTicketsPeriod”: checkTicketsPeriod,
“extraGenesisClaims”: extraGenesisClaims
}
// Create Identity (IdentityFactory will manage errors for not sending correctly parameters inside idSettings
Id3Identity identity = Id3IdentityFactory.createIdentity(idSettings) { event, exception ->
Log.i("EVENT RECEIVED”)
}
// Load Identity
Id3Identity identity2 = Id3IdentityFactory.loadIdentity(idSettings)
Identity2.setEventListener(new Sender() {
override fun send(event: Event, exception: Exception) {
Log.i("EVENT RECEIVED”)
}
})
// Delete Identity
Boolean isDeleted = Id3IdentityFactory.deleteIdentity(identity2)
// Request Claim and receive ticket
Identity.requestClaim(issuerUrl) {
ticket, exception ->
Log.i(”CLAIM TICKET RECEIVED”)
}
// Get Claim from Id
String claim = Identity.getClaim(claimId)
// Get all claims of the identity
List claims = Identity.getClaims()
// Prove Claim with or without Zero Knowledge Proof
Identity.proveClaim(verifierUrl, claim, usingZK) {
success, exception ->
if (success) {
Log.i(”CLAIM PROOF RECEIVED”)
}
}
The text was updated successfully, but these errors were encountered: