@@ -23,7 +23,8 @@ import {
23
23
} from '../dto/register-credential.dto' ;
24
24
import { getAppVault , getAppMenemonic } from '../../utils/app-vault-service' ;
25
25
import { TxSendModuleService } from 'src/tx-send-module/tx-send-module.service' ;
26
-
26
+ import * as NodeCache from 'node-cache' ;
27
+ const myCache = new NodeCache ( ) ;
27
28
@Injectable ( )
28
29
export class CredentialService {
29
30
constructor (
@@ -112,7 +113,16 @@ export class CredentialService {
112
113
) ;
113
114
const seed = await this . hidWallet . getSeedFromMnemonic ( issuerMnemonic ) ;
114
115
const hypersignDid = new HypersignDID ( ) ;
115
- const { didDocument } = await hypersignDid . resolve ( { did : issuerDid } ) ;
116
+ let didDocument ;
117
+ if ( myCache . has ( issuerDid ) ) {
118
+ didDocument = myCache . get ( issuerDid ) ;
119
+ console . log ( 'Getting from Cache' ) ;
120
+ } else {
121
+ const resp = await hypersignDid . resolve ( { did : issuerDid } ) ;
122
+ didDocument = resp . didDocument ;
123
+ myCache . set ( issuerDid , didDocument ) ;
124
+ Logger . log ( 'Setting Cache' ) ;
125
+ }
116
126
const verificationMethod = didDocument . verificationMethod . find (
117
127
( vm ) => vm . id === verificationMethodId ,
118
128
) ;
@@ -192,6 +202,7 @@ export class CredentialService {
192
202
} = await hypersignVC . issue ( {
193
203
credential,
194
204
issuerDid,
205
+ issuerDidDoc : didDocument ,
195
206
verificationMethodId,
196
207
privateKeyMultibase,
197
208
registerCredential : false ,
0 commit comments