Skip to content

Commit

Permalink
chore: handle missing identicons lib
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Aug 21, 2024
1 parent 0b44389 commit 2c30fe4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/database/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { gte, inArray, lte } from 'drizzle-orm'
import type { Range, ScoreParams, ValidatorsActivities } from 'nimiq-vts'
// @ts-expect-error no types in the package
import Identicons from '@nimiq/identicons'
import { consola } from 'consola'
import type { NewScore, NewValidator } from '../utils/drizzle'

/**
Expand Down Expand Up @@ -38,7 +39,9 @@ export async function storeValidator(address: string, rest: Omit<NewValidator, '
return validatorId
}

const icon = await Identicons.default.toDataUrl(address) as string
const icon = await Identicons.default?.toDataUrl(address) || '' as string
if (!icon)
consola.error(`The identicon for ${address} is empty. This should not happen. Identicons lib: ${JSON.stringify(Identicons)}`)
const newValidator = await useDrizzle().insert(tables.validators).values({ ...rest, address, icon }).returning().get()
validators.set(address, newValidator.id)
return newValidator.id
Expand Down

0 comments on commit 2c30fe4

Please sign in to comment.