-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: conanoc <conanoc@gmail.com>
- Loading branch information
Showing
17 changed files
with
392 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
excluded: | ||
- AriesFramework/Pods | ||
- .build | ||
- Sample | ||
disabled_rules: | ||
- line_length | ||
|
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
51 changes: 51 additions & 0 deletions
51
Sources/AriesFramework/anoncreds/storage/RevocationRegistryRecord.swift
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,51 @@ | ||
|
||
import Foundation | ||
|
||
public struct RevocationRegistryRecord: BaseRecord { | ||
public var id: String | ||
var createdAt: Date | ||
var updatedAt: Date? | ||
public var tags: Tags? | ||
|
||
public var credDefId: String | ||
public var revocRegId: String | ||
public var revocRegDef: String | ||
public var revocRegPrivate: String | ||
public var revocStatusList: String | ||
public var registryIndex: Int = 0 | ||
|
||
public static let type = "RevocationRegistryRecord" | ||
} | ||
|
||
extension RevocationRegistryRecord: Codable { | ||
enum CodingKeys: String, CodingKey { | ||
case id, createdAt, updatedAt, tags, credDefId, revocRegId, revocRegDef, revocRegPrivate, revocStatusList, registryIndex | ||
} | ||
|
||
init( | ||
tags: Tags? = nil, | ||
credDefId: String, | ||
revocRegId: String, | ||
revocRegDef: String, | ||
revocRegPrivate: String, | ||
revocStatusList: String) { | ||
|
||
self.id = RevocationRegistryRecord.generateId() | ||
self.createdAt = Date() | ||
self.tags = tags | ||
self.credDefId = credDefId | ||
self.revocRegId = revocRegId | ||
self.revocRegDef = revocRegDef | ||
self.revocRegPrivate = revocRegPrivate | ||
self.revocStatusList = revocStatusList | ||
} | ||
|
||
public func getTags() -> Tags { | ||
var tags = self.tags ?? [:] | ||
|
||
tags["credDefId"] = self.credDefId | ||
tags["revocRegId"] = self.revocRegId | ||
|
||
return tags | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Sources/AriesFramework/anoncreds/storage/RevocationRegistryRepository.swift
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,16 @@ | ||
|
||
import Foundation | ||
|
||
public class RevocationRegistryRepository: Repository<RevocationRegistryRecord> { | ||
public func findByCredDefId(_ credDefId: String) async throws -> RevocationRegistryRecord? { | ||
return try await findSingleByQuery("{\"credDefId\": \"\(credDefId)\"}") | ||
} | ||
|
||
// We don't need lock here because this is for testing only. | ||
public func incrementRegistryIndex(credDefId: String) async throws -> Int { | ||
var record = try await getSingleByQuery("{\"credDefId\": \"\(credDefId)\"}") | ||
record.registryIndex += 1 | ||
try await update(record) | ||
return record.registryIndex | ||
} | ||
} |
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
Oops, something went wrong.