Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Kiryakov <stepan.kiryakov@envisionblockchain.com>
  • Loading branch information
Stepan-Kirjakov committed Jan 30, 2025
1 parent d9c5e29 commit 5192673
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 57 deletions.
6 changes: 3 additions & 3 deletions indexer-api-gateway/src/api/services/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ApiTags,
ApiUnprocessableEntityResponse,
} from '@nestjs/swagger';
import { IndexerMessageAPI, Message } from '@indexer/common';
import { IndexerMessageAPI } from '@indexer/common';
import { ApiClient } from '../api-client.js';
import {
InternalServerErrorDTO,
Expand Down Expand Up @@ -47,7 +47,7 @@ export class AnalyticsApi extends ApiClient {
body
);
}

@ApiOperation({
summary: 'Search contract retirements',
description: 'Returns contract retirements result',
Expand Down Expand Up @@ -75,7 +75,7 @@ export class AnalyticsApi extends ApiClient {
body
);
}

@Get('/checkAvailability')
@ApiOperation({
summary: 'Get indexer availability',
Expand Down
1 change: 0 additions & 1 deletion indexer-api-gateway/src/api/services/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,6 @@ export class EntityApi extends ApiClient {
}
//#endregion


//#region FORMULAS
@Get('/formulas')
@ApiOperation({
Expand Down
5 changes: 5 additions & 0 deletions indexer-api-gateway/src/dto/details/policy.details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ export class PolicyActivityDTO implements PolicyActivity {
example: 10,
})
roles: number;
@ApiProperty({
description: 'Formulas',
example: 10,
})
formulas: number;
}

export class PolicyDTO
Expand Down
5 changes: 5 additions & 0 deletions indexer-api-gateway/src/dto/details/vc.details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,9 @@ export class VCDetailsDTO
},
})
schema?: any;

@ApiProperty({
description: 'Formulas data',
})
formulasData?: any;
}
6 changes: 3 additions & 3 deletions indexer-common/src/messages/message-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ export enum IndexerMessageAPI {

UPDATE_FILES = 'INDEXER_API_UPDATE_FILES',

GET_INDEXER_AVAILABILITY = "INDEXER_API_GET_INDEXER_AVAILABILITY",
GET_RETIRE_DOCUMENTS = "INDEXER_API_GET_RETIRE_DOCUMENTS"
}
GET_INDEXER_AVAILABILITY = 'INDEXER_API_GET_INDEXER_AVAILABILITY',
GET_RETIRE_DOCUMENTS = 'INDEXER_API_GET_RETIRE_DOCUMENTS'
}
5 changes: 2 additions & 3 deletions indexer-interfaces/src/interfaces/details/formula.details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,11 @@ export interface FormulaRelationships {
formulas?: Formula[];
}


/**
* Formula activity
*/
export interface FormulaActivity {
}
// tslint:disable-next-line:no-empty-interface
export interface FormulaActivity {}

/**
* Formula
Expand Down
4 changes: 2 additions & 2 deletions indexer-interfaces/src/models/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export class Schema {
}

/**
* Get all fields
*/
* Get all fields
*/
private _getFields(result: SchemaField[], fields?: SchemaField[]): SchemaField[] {
if (Array.isArray(fields)) {
for (const field of fields) {
Expand Down
9 changes: 5 additions & 4 deletions indexer-service/src/api/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class AnalyticsService {
try {
const { topicId } = msg;
const em = DataBaseHelper.getEntityManager();
const [messages, count] = (await em.findAndCount(
const [messages] = (await em.findAndCount(
Message,
{
topicId,
Expand All @@ -152,22 +152,23 @@ export class AnalyticsService {
)) as any;

for (const message of messages) {
let VCdocuments: VCDetails[] = [];
const VCdocuments: VCDetails[] = [];
for (const fileName of message.files) {
try {
const file = await DataBaseHelper.loadFile(fileName);
VCdocuments.push(JSON.parse(file) as VCDetails);
// tslint:disable-next-line:no-empty
} catch (error) {
}
}
message.documents = VCdocuments;

var messageCache = messagesCache.find((cache: MessageCache) => cache.consensusTimestamp == message.consensusTimestamp);
const messageCache = messagesCache.find((cache: MessageCache) => cache.consensusTimestamp === message.consensusTimestamp);
if (messageCache) {
message.sequenceNumber = messageCache.sequenceNumber;
}
}

return new MessageResponse<Message[]>(messages);
} catch (error) {
return new MessageError(error);
Expand Down
6 changes: 2 additions & 4 deletions indexer-service/src/api/entities.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ export class EntityService {
try {
const { messageId } = msg;
const em = DataBaseHelper.getEntityManager();
let item = await em.findOne(Message, {
const item = await em.findOne(Message, {
consensusTimestamp: messageId,
type: MessageType.FORMULA,
action: MessageAction.PublishFormula
Expand Down Expand Up @@ -1448,7 +1448,7 @@ export class EntityService {
try {
const { messageId } = msg;
const em = DataBaseHelper.getEntityManager();
let item = await em.findOne(Message, {
const item = await em.findOne(Message, {
consensusTimestamp: messageId,
type: MessageType.FORMULA,
action: MessageAction.PublishFormula
Expand Down Expand Up @@ -1787,8 +1787,6 @@ export class EntityService {
});
}



item = await loadDocuments(item, true);

const schema = await loadSchema(item, true);
Expand Down
19 changes: 1 addition & 18 deletions indexer-service/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,7 @@ import { EntityService } from './api/entities.service.js';
import { FiltersService } from './api/filters.service.js';
import { LandingService } from './api/landing.service.js';
import { AnalyticsService } from './api/analytics.service.js';
import {
SynchronizationAnalytics,
SynchronizationContracts,
SynchronizationDid,
SynchronizationModules,
SynchronizationPolicy,
SynchronizationProjects,
SynchronizationRegistries,
SynchronizationRoles,
SynchronizationSchemas,
SynchronizationTools,
SynchronizationTopics,
SynchronizationVCs,
SynchronizationVPs,
SynchronizationLabels,
SynchronizationFormulas,
SynchronizationAll
} from './helpers/synchronizers/index.js';
import { SynchronizationAll } from './helpers/synchronizers/index.js';
import { fixtures } from './helpers/fixtures.js';

const channelName = (
Expand Down
4 changes: 2 additions & 2 deletions indexer-service/src/helpers/synchronizers/synchronize-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ export class SynchronizationAll extends SynchronizationTask {

public static createAllTasks() {
if (process.env.SYNC_ALL_MASK) {
this.createSyncTasks();
SynchronizationAll.createSyncTasks();
} else {
this.createAsyncTasks();
SynchronizationAll.createAsyncTasks();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export class SynchronizationFormulas extends SynchronizationTask {
}
analytics.config = formulaData.formula;


const policyMessage = policyMap.get(document.options?.policyInstanceTopicId);
if (policyMessage) {
analytics.policyId = policyMessage.consensusTimestamp;
Expand Down
8 changes: 4 additions & 4 deletions indexer-worker-service/src/loaders/hedera-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export class HederaService {
public static readonly REST_API_MAX_LIMIT: number = 100;

public static async init() {
this.mirrorNodeUrl = Environment.mirrorNode;
HederaService.mirrorNodeUrl = Environment.mirrorNode;
}

public static async getMessages(topicId: string, lastNumber: number): Promise<TopicInfo | null> {
try {
const url = this.mirrorNodeUrl + 'topics/' + topicId + '/messages';
const url = HederaService.mirrorNodeUrl + 'topics/' + topicId + '/messages';
const option: any = {
params: {
limit: HederaService.REST_API_MAX_LIMIT
Expand Down Expand Up @@ -44,7 +44,7 @@ export class HederaService {

public static async getToken(tokenId: string): Promise<TokenInfo | null> {
try {
const url = this.mirrorNodeUrl + 'tokens/' + tokenId;
const url = HederaService.mirrorNodeUrl + 'tokens/' + tokenId;
const option: any = {
responseType: 'json',
timeout: 2 * 60 * 1000,
Expand All @@ -63,7 +63,7 @@ export class HederaService {
}

public static async getSerials(tokenId: string, lastNumber: number): Promise<TokenInstances | null> {
const url = this.mirrorNodeUrl + 'tokens/' + tokenId + '/nfts';
const url = HederaService.mirrorNodeUrl + 'tokens/' + tokenId + '/nfts';
const option: any = {
params: {
order: 'asc',
Expand Down
12 changes: 6 additions & 6 deletions indexer-worker-service/src/loaders/ipfs-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export class IPFSService {
public static node: BaseNode;

public static async init() {
this.node = new HttpNode();
await this.node.start();
IPFSService.node = new HttpNode();
await IPFSService.node.start();
}

public static parseCID(file: string): CID | null {
Expand All @@ -28,14 +28,14 @@ export class IPFSService {
}

private static async loadFile(cid: string): Promise<Buffer | undefined> {
const check = await this.node.check(cid);
const check = await IPFSService.node.check(cid);
if (check.check === true) {
const file = await this.node.get(cid);
const file = await IPFSService.node.get(cid);
console.log(`IPFS loaded: ${cid}`);
return file;
} else if (check.check === undefined) {
console.log(`IPFS check: ${cid}`, check.error);
const file = await this.node.get(cid);
const file = await IPFSService.node.get(cid);
console.log(`IPFS loaded: ${cid}`);
return file;
} else {
Expand All @@ -52,7 +52,7 @@ export class IPFSService {
reject(new Error('Timeout exceeded'));
}, IPFSService.LOAD_TIMEOUT);
});
return await Promise.race([this.loadFile(cid), timeoutPromise]);
return await Promise.race([IPFSService.loadFile(cid), timeoutPromise]);
} catch (error) {
console.log(`IPFS error: ${cid}`, error.message);
return undefined;
Expand Down
6 changes: 1 addition & 5 deletions indexer-worker-service/src/loaders/ipfs/http-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ export class HttpNode implements BaseNode {
private readonly LOAD_TIMEOUT: number = 60 * 1000;
private readonly CHECK_TIMEOUT: number = 15 * 1000;

constructor() {

}

private parseCID(cid: string): string {
return new CID(cid).toV1().toString('base32');
}
Expand All @@ -24,7 +20,7 @@ export class HttpNode implements BaseNode {
}

public async stop() {

return;
}

public async get(cid: string, timeout?: number): Promise<Buffer> {
Expand Down
1 change: 0 additions & 1 deletion worker-service/src/api/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function rejectTimeout(t: number): Promise<void> {
})
}


function getAnalytycsHeaders() {
const headers: any = {};
const token = process.env.ANALYTICS_SERVICE_TOKEN;
Expand Down

0 comments on commit 5192673

Please sign in to comment.