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
1 merge request!47Tenant manager
......@@ -24,7 +24,7 @@ import {
KeyType,
TypedArrayEncoder,
} from '@credo-ts/core';
import { Injectable } from '@nestjs/common';
import { Injectable, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { LEDGERS } from '../../config/ledger.js';
......@@ -34,6 +34,8 @@ import { WithTenantService } from '../withTenantService.js';
@Injectable()
export class DidsService {
private readonly logger = new Logger(this.constructor.name);
public constructor(
private agentService: AgentService,
private withTenantService: WithTenantService,
......@@ -138,9 +140,14 @@ export class DidsService {
};
try {
this.logger.log('Registering wallet key for endorser dids');
await this.agentService.agent.wallet.createKey(privKey);
} catch {
// Key already exists, but we don't care
} catch (e) {
if (e instanceof Error && e.constructor.name === 'WalletKeyExistsError') {
this.logger.log('Wallet key already exists');
} else {
throw e;
}
}
for (const indyDid of indyDids) {
......
......@@ -93,12 +93,8 @@ export class Application implements OnApplicationBootstrap {
public async onApplicationBootstrap() {
await this.natsClient.connect();
try {
await firstValueFrom(
this.natsClient.send(EventDidsRegisterEndorserDid.token, {}),
);
} catch {
// If there was an error, we don't want to crash the application
}
await firstValueFrom(
this.natsClient.send(EventDidsRegisterEndorserDid.token, {}),
);
}
}
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