Skip to content

Commit

Permalink
feat: add slug field in ValidatorWithStats
Browse files Browse the repository at this point in the history
  • Loading branch information
grikomsn committed Dec 4, 2023
1 parent 91f8771 commit 3c4df2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hooks/validator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getValidatorStats, getValidators } from "@/api";
import { stringOrUndefined } from "@/lib/string";
import { Validator, ValidatorWithStats } from "@/types/base";
import { slugifyWithCounter } from "@sindresorhus/slugify";
import { useQuery } from "@tanstack/react-query";
import { useRouter } from "next/router";
import { useMemo } from "react";
Expand Down Expand Up @@ -67,9 +68,12 @@ export function useValidatorsWithStatsQuery<T = ValidatorWithStats[]>(
toHeight: args.toHeight,
});

const slugify = slugifyWithCounter();

function withStats(validator: Validator): ValidatorWithStats {
return {
...validator,
slug: slugify(validator.moniker),
averageMev: parseFloat(stats[validator.pubkey]) || 0.0,
};
}
Expand Down
1 change: 1 addition & 0 deletions src/types/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type Validator = {
};

export type ValidatorWithStats = Validator & {
slug: string;
averageMev: number;
};

Expand Down

0 comments on commit 3c4df2d

Please sign in to comment.