From bdf9a89d63ced416a986bb44f2c9741c09a2ac1a Mon Sep 17 00:00:00 2001 From: Pooya Raki Date: Mon, 25 Nov 2024 11:30:58 +0100 Subject: [PATCH] refactor typing of notification controller --- .../v1/notifications.controller.ts | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/routes/notifications/v1/notifications.controller.ts b/src/routes/notifications/v1/notifications.controller.ts index 427f83822e..55be550c32 100644 --- a/src/routes/notifications/v1/notifications.controller.ts +++ b/src/routes/notifications/v1/notifications.controller.ts @@ -12,10 +12,7 @@ import { RegisterDeviceDto } from '@/routes/notifications/v1/entities/register-d import { NotificationsService } from '@/routes/notifications/v1/notifications.service'; import { ValidationPipe } from '@/validation/pipes/validation.pipe'; import { AddressSchema } from '@/validation/entities/schemas/address.schema'; -import type { - UpsertSubscriptionsDto, - UpsertSubscriptionsSafesDto, -} from '@/routes/notifications/v2/entities/upsert-subscriptions.dto.entity'; +import type { UpsertSubscriptionsSafesDto } from '@/routes/notifications/v2/entities/upsert-subscriptions.dto.entity'; import { AuthPayload } from '@/domain/auth/entities/auth-payload.entity'; import { NotificationType } from '@/domain/notifications/v2/entities/notification.entity'; import type { UUID } from 'crypto'; @@ -71,26 +68,28 @@ export class NotificationsController { } } - private async createV2RegisterDto(args: RegisterDeviceDto): Promise< - Array<{ - upsertSubscriptionsDto: UpsertSubscriptionsDto; - authPayload: AuthPayload; - }> + private async createV2RegisterDto( + args: RegisterDeviceDto, + ): Promise< + Array[0]> > { - const safeV2Array: Array<{ - authPayload: AuthPayload; - upsertSubscriptionsDto: UpsertSubscriptionsDto & { - signature: `0x${string}`; - }; - }> = []; + const safeV2Array: Array< + Parameters[0] & { + upsertSubscriptionsDto: { + safes: Array; + signature: `0x${string}`; + }; + } + > = []; const safesV1Registrations = args.safeRegistrations; for (const safeV1Registration of safesV1Registrations) { if (safeV1Registration.safes.length) { - const safeV2: { - authPayload: AuthPayload; - upsertSubscriptionsDto: UpsertSubscriptionsDto & { + const safeV2: Parameters< + NotificationsServiceV2['upsertSubscriptions'] + >[0] & { + upsertSubscriptionsDto: { safes: Array; signature: `0x${string}`; };