Skip to content

Commit

Permalink
fix: module id in endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Amuhar committed Sep 10, 2023
1 parent ee32670 commit 065e590
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
14 changes: 9 additions & 5 deletions src/http/sr-modules-keys/sr-modules-keys.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ export class SRModulesKeysController {
description: 'Staking router module_id or contract address.',
})
@Get(':module_id/keys')
async getModuleKeys(@Param('module_id') moduleId: ModuleId, @Query() filters: KeyQuery, @Res() reply: FastifyReply) {
async getModuleKeys(@Param() module: ModuleId, @Query() filters: KeyQuery, @Res() reply: FastifyReply) {
await this.entityManager.transactional(
async () => {
const { keysGenerator, module, meta } = await this.srModulesKeysService.getModuleKeys(moduleId, filters);
const {
keysGenerator,
module: srModule,
meta,
} = await this.srModulesKeysService.getModuleKeys(module.module_id, filters);
const jsonStream = JSONStream.stringify(
'{ "meta": ' + JSON.stringify(meta) + ', "data": { "module": ' + JSON.stringify(module) + ', "keys": [',
'{ "meta": ' + JSON.stringify(meta) + ', "data": { "module": ' + JSON.stringify(srModule) + ', "keys": [',
',',
']}}',
);
Expand Down Expand Up @@ -102,7 +106,7 @@ export class SRModulesKeysController {
name: 'module_id',
description: 'Staking router module_id or contract address.',
})
getModuleKeysByPubkeys(@Param('module_id') moduleId: ModuleId, @Body() keys: KeysFindBody) {
return this.srModulesKeysService.getModuleKeysByPubKeys(moduleId, keys.pubkeys);
getModuleKeysByPubkeys(@Param() module: ModuleId, @Body() keys: KeysFindBody) {
return this.srModulesKeysService.getModuleKeysByPubKeys(module.module_id, keys.pubkeys);
}
}
4 changes: 2 additions & 2 deletions src/http/sr-modules-keys/sr-modules-keys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class SRModulesKeysService {
}

async getModuleKeys(
moduleId: ModuleId,
moduleId: string | number,
filters: KeyQuery,
): Promise<{
keysGenerator: AsyncGenerator<Key>;
Expand All @@ -52,7 +52,7 @@ export class SRModulesKeysService {
return { keysGenerator, module, meta: { elBlockSnapshot } };
}

async getModuleKeysByPubKeys(moduleId: ModuleId, pubKeys: string[]): Promise<SRModuleKeyListResponse> {
async getModuleKeysByPubKeys(moduleId: string | number, pubKeys: string[]): Promise<SRModuleKeyListResponse> {
const { keys, module, elBlockSnapshot } = await this.entityManager.transactional(
async () => {
const { module, elBlockSnapshot } = await this.stakingRouterService.getStakingModuleAndMeta(moduleId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,21 @@ export class SRModulesOperatorsKeysController {
description: 'Staking router module_id or contract address.',
})
@Get(':module_id/operators/keys')
async getOperatorsKeys(
@Param('module_id') moduleId: ModuleId,
@Query() filters: KeyQuery,
@Res() reply: FastifyReply,
) {
async getOperatorsKeys(@Param() module: ModuleId, @Query() filters: KeyQuery, @Res() reply: FastifyReply) {
await this.entityManager.transactional(
async () => {
const { operators, keysGenerator, module, meta } = await this.srModulesOperatorsKeys.get(moduleId, filters);
const {
operators,
keysGenerator,
module: srModule,
meta,
} = await this.srModulesOperatorsKeys.get(module.module_id, filters);

const jsonStream = JSONStream.stringify(
'{ "meta": ' +
JSON.stringify(meta) +
', "data": { "module": ' +
JSON.stringify(module) +
JSON.stringify(srModule) +
', "operators": ' +
JSON.stringify(operators) +
', "keys": [',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class SRModulesOperatorsKeysService {
) {}

public async get(
moduleId: ModuleId,
moduleId: string | number,
filters: KeyQuery,
): Promise<{
keysGenerator: AsyncGenerator<Key>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ export class SRModulesValidatorsController {
example: '0x55032650b14df07b85bF18A3a3eC8E0Af2e028d5',
description: 'Staking router module_id or contract address.',
})
getOldestValidators(
@Param('module_id') moduleId: ModuleId,
@Param() operator: OperatorIdParam,
@Query() query: ValidatorsQuery,
) {
return this.validatorsService.getOldestLidoValidators(moduleId, operator.operator_id, query);
getOldestValidators(@Param() module: ModuleId, @Param() operator: OperatorId, @Query() query: ValidatorsQuery) {
return this.validatorsService.getOldestLidoValidators(module.module_id, operator.operator_id, query);
}

@Version('1')
Expand Down Expand Up @@ -93,10 +89,10 @@ export class SRModulesValidatorsController {
description: 'Staking router module_id or contract address.',
})
getMessagesForOldestValidators(
@Param('module_id') moduleId: ModuleId,
@Param() module: ModuleId,
@Param() operator: OperatorId,
@Query() query: ValidatorsQuery,
) {
return this.validatorsService.getVoluntaryExitMessages(moduleId, operator.operator_id, query);
return this.validatorsService.getVoluntaryExitMessages(module.module_id, operator.operator_id, query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class SRModulesValidatorsService {
) {}

async getOldestLidoValidators(
moduleId: ModuleId,
moduleId: string | number,
operatorId: number,
filters: ValidatorsQuery,
): Promise<ExitValidatorListResponse> {
Expand All @@ -53,7 +53,7 @@ export class SRModulesValidatorsService {
}

async getVoluntaryExitMessages(
moduleId: ModuleId,
moduleId: string | number,
operatorId: number,
filters: ValidatorsQuery,
): Promise<ExitPresignMessageListResponse> {
Expand Down Expand Up @@ -86,7 +86,7 @@ export class SRModulesValidatorsService {
}

private async getOperatorOldestValidators(
moduleId: string,
moduleId: string | number,
operatorIndex: number,
filters: ValidatorsQuery,
): Promise<{ validators: Validator[]; clBlockSnapshot: CLBlockSnapshot }> {
Expand Down

0 comments on commit 065e590

Please sign in to comment.