-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement allocation logic and repository functions
Signed-off-by: Shota Jolbordi <shota.jolbordi@iohk.io>
- Loading branch information
Shota Jolbordi
committed
Dec 8, 2023
1 parent
5aa345b
commit 478a7cc
Showing
8 changed files
with
193 additions
and
44 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
14 changes: 13 additions & 1 deletion
14
.../src/main/scala/io/iohk/atala/pollux/core/repository/CredentialStatusListRepository.scala
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,13 +1,25 @@ | ||
package io.iohk.atala.pollux.core.repository | ||
|
||
import io.iohk.atala.castor.core.model.did.CanonicalPrismDID | ||
import io.iohk.atala.mercury.protocol.issuecredential.{IssueCredential, RequestCredential} | ||
import io.iohk.atala.pollux.anoncreds.CredentialRequestMetadata | ||
import io.iohk.atala.pollux.core.model.* | ||
import io.iohk.atala.pollux.core.model.IssueCredentialRecord.ProtocolState | ||
import io.iohk.atala.pollux.vc.jwt.Issuer | ||
import io.iohk.atala.shared.models.{WalletAccessContext, WalletId} | ||
import zio.* | ||
|
||
import java.util.UUID | ||
|
||
trait CredentialStatusListRepository { | ||
def getLatestOfTheWallet(walletId: WalletId): RIO[WalletAccessContext, CredentialStatusList] | ||
def getLatestOfTheWallet(walletId: WalletId): RIO[WalletAccessContext, Option[CredentialStatusList]] | ||
|
||
def createNewForTheWallet(walletId: WalletId, jwtIssuer: Issuer): RIO[WalletAccessContext, CredentialStatusList] | ||
|
||
def allocateSpaceForCredential( | ||
issueCredentialRecordId: DidCommID, | ||
credentialStatusListId: UUID, | ||
statusListIndex: Int | ||
): RIO[WalletAccessContext, Unit] | ||
|
||
} |
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
28 changes: 28 additions & 0 deletions
28
pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/repository/Implicits.scala
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.iohk.atala.pollux.sql.repository | ||
|
||
import doobie.util.{Get, Put} | ||
import io.iohk.atala.castor.core.model.did.{CanonicalPrismDID, PrismDID} | ||
import io.iohk.atala.pollux.core.model.* | ||
import io.iohk.atala.pollux.vc.jwt.StatusPurpose | ||
import io.iohk.atala.shared.models.WalletId | ||
|
||
given didCommIDGet: Get[DidCommID] = Get[String].map(DidCommID(_)) | ||
given didCommIDPut: Put[DidCommID] = Put[String].contramap(_.value) | ||
|
||
given walletIdGet: Get[WalletId] = Get[String].map(WalletId.fromUUIDString) | ||
given walletIdPut: Put[WalletId] = Put[String].contramap(_.toString) | ||
|
||
given prismDIDGet: Get[CanonicalPrismDID] = | ||
Get[String].map(s => PrismDID.fromString(s).fold(e => throw RuntimeException(e), _.asCanonical)) | ||
given prismDIDPut: Put[CanonicalPrismDID] = Put[String].contramap(_.toString) | ||
|
||
given statusPurposeGet: Get[StatusPurpose] = Get[String].map { | ||
case "Revocation" => StatusPurpose.Revocation | ||
case "Suspension" => StatusPurpose.Suspension | ||
case purpose => throw RuntimeException(s"Invalid status purpose - $purpose") | ||
} | ||
|
||
given statusPurposePut: Put[StatusPurpose] = Put[String].contramap { | ||
case StatusPurpose.Revocation => StatusPurpose.Revocation.str | ||
case StatusPurpose.Suspension => StatusPurpose.Suspension.str | ||
} |
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
118 changes: 102 additions & 16 deletions
118
...c/main/scala/io/iohk/atala/pollux/sql/repository/JdbcCredentialStatusListRepository.scala
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