Skip to content

Commit 84a2f47

Browse files
feat(proofs): add getter methods to ProofService
Signed-off-by: NB-Karim <karim.northernblock@gmail.com>
1 parent bf824d4 commit 84a2f47

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

packages/core/src/modules/proofs/ProofService.ts

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
RequestProofOptions,
1111
} from './models/ServiceOptions'
1212
import type { RetrievedCredentials } from './protocol/v1/models'
13-
import type { ProofRecord } from './repository'
13+
import type { ProofRecord, ProofRepository } from './repository'
1414
import type { PresentationRecordType } from './repository/PresentationExchangeRecord'
1515

1616
import { ConsoleLogger, LogLevel } from '../../logger'
@@ -22,7 +22,14 @@ const logger = new ConsoleLogger(LogLevel.debug)
2222
* - stores records
2323
* - returns records & messages
2424
*/
25+
2526
export abstract class ProofService {
27+
private proofRepository: ProofRepository
28+
29+
public constructor(proofRepository: ProofRepository) {
30+
this.proofRepository = proofRepository
31+
}
32+
2633
abstract getVersion(): ProofProtocolVersion
2734

2835
/**
@@ -101,7 +108,45 @@ export abstract class ProofService {
101108
throw Error('Not Implemented')
102109
}
103110

104-
public getById(proofRecordId: string): Promise<ProofRecord> {
111+
/**
112+
* Retrieve all proof records
113+
*
114+
* @returns List containing all proof records
115+
*/
116+
public async getAll(): Promise<ProofRecord[]> {
117+
return this.proofRepository.getAll()
118+
}
119+
120+
/**
121+
* Retrieve a proof record by id
122+
*
123+
* @param proofRecordId The proof record id
124+
* @throws {RecordNotFoundError} If no record is found
125+
* @return The proof record
126+
*
127+
*/
128+
public async getById(proofRecordId: string): Promise<ProofRecord> {
105129
return this.proofRepository.getById(proofRecordId)
106130
}
131+
132+
/**
133+
* Retrieve a proof record by id
134+
*
135+
* @param proofRecordId The proof record id
136+
* @return The proof record or null if not found
137+
*
138+
*/
139+
public async findById(proofRecordId: string): Promise<ProofRecord | null> {
140+
return this.proofRepository.findById(proofRecordId)
141+
}
142+
143+
/**
144+
* Delete a proof record by id
145+
*
146+
* @param proofId the proof record id
147+
*/
148+
public async deleteById(proofId: string) {
149+
const proofRecord = await this.getById(proofId)
150+
return this.proofRepository.delete(proofRecord)
151+
}
107152
}

0 commit comments

Comments
 (0)