Skip to content

Commit

Permalink
Ensure chainId is returned correctly during notification errors (#2201)
Browse files Browse the repository at this point in the history
  • Loading branch information
PooyaRaki authored Dec 17, 2024
1 parent 2f1af10 commit 86d7302
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/routes/notifications/v1/notifications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,14 @@ export class NotificationsService {
registrationResults: PromiseSettledResult<DomainSafeRegistration>[],
safeRegistrations: SafeRegistration[],
): string {
const successChainIds = (
registrationResults.filter(
({ status }) => status === 'fulfilled',
) as PromiseFulfilledResult<DomainSafeRegistration>[]
).map((registrationResult) => registrationResult.value.chainId);
const failedRegistrationChainIds = registrationResults
.map((result, index) => ({
result,
safeRegistration: safeRegistrations[index],
}))
.filter(({ result }) => result.status === 'rejected')
.map(({ safeRegistration }) => safeRegistration.chainId);

const erroredChainIds = safeRegistrations
.map((safeRegistration) => safeRegistration.chainId)
.filter((chainId) => !successChainIds.includes(chainId));

return `Push notification registration failed for chain IDs: ${erroredChainIds}`;
return `Push notification registration failed for chain IDs: ${failedRegistrationChainIds}`;
}
}

0 comments on commit 86d7302

Please sign in to comment.