Skip to content

Commit

Permalink
schema status fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishwas1 committed Jan 15, 2025
1 parent 7d4a9c6 commit 9267716
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/schema/schema.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@ import { TrimMiddleware } from 'src/utils/middleware/trim.middleware';
import { schemaProviders } from './providers/schema.provider';
import { databaseProviders } from '../mongoose/tenant-mongoose-connections';
import { TxSendModuleModule } from 'src/tx-send-module/tx-send-module.module';
import { StatusService } from 'src/status/status.service';
import { StatusModule } from 'src/status/status.module';
import { TxnStatusRepository } from 'src/status/repository/status.repository';
import { statusProviders } from 'src/status/providers/registration-status.provider';

@Module({
imports: [DidModule, TxSendModuleModule],
imports: [DidModule, TxSendModuleModule, StatusModule],
controllers: [SchemaController],
providers: [
SchemaService,
SchemaSSIService,
DidService,
HidWalletService,
SchemaRepository,
StatusService,
TxnStatusRepository,
...databaseProviders,
...schemaProviders,
...statusProviders,
],
exports: [SchemaModule],
})
Expand Down
14 changes: 14 additions & 0 deletions src/schema/services/schema.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { RegisterSchemaDto } from '../dto/register-schema.dto';
import { Namespace } from 'src/did/dto/create-did.dto';
import { getAppVault, getAppMenemonic } from '../../utils/app-vault-service';
import { TxSendModuleService } from 'src/tx-send-module/tx-send-module.service';
import { StatusService } from 'src/status/status.service';

@Injectable({ scope: Scope.REQUEST })
export class SchemaService {
Expand All @@ -31,6 +32,7 @@ export class SchemaService {
private readonly hidWallet: HidWalletService,
private readonly didRepositiory: DidRepository,
private readonly txnService: TxSendModuleService,
private readonly statusService: StatusService,
) {}

async checkAllowence(address) {
Expand Down Expand Up @@ -201,6 +203,18 @@ export class SchemaService {
'resolveSchema() method: resolving schema from blockchain',
'SchemaService',
);

const statusResponse = await this.statusService.findBySsiId(schemaId);
Logger.log(statusResponse);
if (statusResponse) {
const firstResponse = statusResponse[0];
if (firstResponse && firstResponse.data) {
if (firstResponse.data.findIndex((x) => x['status'] != 0) >= 0) {
throw new BadRequestException([firstResponse]);
}
}
}

let resolvedSchema;
try {
resolvedSchema = await hypersignSchema.resolve({ schemaId });
Expand Down
8 changes: 7 additions & 1 deletion src/status/status.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { RegistrationStatusList } from './dto/registration-status.response.dto';
@Injectable()
export class StatusService {
constructor(private readonly txnStatusRepository: TxnStatusRepository) {}
findBySsiId(id: string, option): Promise<RegistrationStatusList> {
findBySsiId(id: string, option?): Promise<RegistrationStatusList> {
if (!option) {
option = {
page: 1,
limit: 10,
};
}
const skip = (option.page - 1) * option.limit;
option['skip'] = skip;
return this.txnStatusRepository.find(
Expand Down

0 comments on commit 9267716

Please sign in to comment.