Skip to content
Snippets Groups Projects
Verified Commit ad857d4c authored by Konstantin Tsabolov's avatar Konstantin Tsabolov
Browse files

chore(ssi): correctly initialize endorser did

parent 1fcefb28
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ import { ...@@ -24,7 +24,7 @@ import {
KeyType, KeyType,
TypedArrayEncoder, TypedArrayEncoder,
} from '@credo-ts/core'; } from '@credo-ts/core';
import { Injectable } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import { LEDGERS } from '../../config/ledger.js'; import { LEDGERS } from '../../config/ledger.js';
...@@ -34,6 +34,8 @@ import { WithTenantService } from '../withTenantService.js'; ...@@ -34,6 +34,8 @@ import { WithTenantService } from '../withTenantService.js';
@Injectable() @Injectable()
export class DidsService { export class DidsService {
private readonly logger = new Logger(this.constructor.name);
public constructor( public constructor(
private agentService: AgentService, private agentService: AgentService,
private withTenantService: WithTenantService, private withTenantService: WithTenantService,
...@@ -138,9 +140,14 @@ export class DidsService { ...@@ -138,9 +140,14 @@ export class DidsService {
}; };
try { try {
this.logger.log('Registering wallet key for endorser dids');
await this.agentService.agent.wallet.createKey(privKey); await this.agentService.agent.wallet.createKey(privKey);
} catch { } catch (e) {
// Key already exists, but we don't care if (e instanceof Error && e.constructor.name === 'WalletKeyExistsError') {
this.logger.log('Wallet key already exists');
} else {
throw e;
}
} }
for (const indyDid of indyDids) { for (const indyDid of indyDids) {
......
...@@ -93,12 +93,8 @@ export class Application implements OnApplicationBootstrap { ...@@ -93,12 +93,8 @@ export class Application implements OnApplicationBootstrap {
public async onApplicationBootstrap() { public async onApplicationBootstrap() {
await this.natsClient.connect(); await this.natsClient.connect();
try { await firstValueFrom(
await firstValueFrom( this.natsClient.send(EventDidsRegisterEndorserDid.token, {}),
this.natsClient.send(EventDidsRegisterEndorserDid.token, {}), );
);
} catch {
// If there was an error, we don't want to crash the application
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment