Skip to content

Commit

Permalink
adopt fp endpoint (#318)
Browse files Browse the repository at this point in the history
* adopt fp endpoint

* resolve comments
  • Loading branch information
jeremy-babylonlabs authored Nov 8, 2024
1 parent 98859da commit 4dcd1f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/app/api/getFinalityProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { encode } from "url-safe-base64";
import { isValidUrl } from "@/utils/url";

import { Pagination } from "../types/api";
import { FinalityProvider } from "../types/finalityProviders";
import {
FinalityProvider,
FinalityProviderState,
} from "../types/finalityProviders";

import { apiWrapper } from "./apiWrapper";

Expand All @@ -19,7 +22,7 @@ interface FinalityProvidersAPIResponse {

interface FinalityProviderAPI {
description: DescriptionAPI;
state: "active" | "standby";
state: FinalityProviderState;
commission: string;
btc_pk: string;
active_tvl: number;
Expand Down Expand Up @@ -64,7 +67,7 @@ export const getFinalityProviders = async ({

const response = await apiWrapper(
"GET",
"/v1/finality-providers",
"/v2/finality-providers",
"Error getting finality providers",
params,
);
Expand Down
13 changes: 10 additions & 3 deletions src/app/components/Staking/FinalityProviders/FinalityProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,31 @@ import { twJoin } from "tailwind-merge";

import blue from "@/app/assets/blue-check.svg";
import { Hash } from "@/app/components/Hash/Hash";
import { FinalityProviderState } from "@/app/types/finalityProviders";
import { getNetworkConfig } from "@/config/network.config";
import { satoshiToBtc } from "@/utils/btcConversions";
import { maxDecimals } from "@/utils/maxDecimals";

interface FinalityProviderProps {
moniker: string;
pkHex: string;
state: "active" | "standby";
state: FinalityProviderState;
stakeSat: number;
commission: string;
onClick: () => void;
selected: boolean;
website?: string;
}
const stateMap = {
FINALITY_PROVIDER_STATUS_INACTIVE: "Inactive",
FINALITY_PROVIDER_STATUS_ACTIVE: "Active",
FINALITY_PROVIDER_STATUS_JAILED: "Jailed",
FINALITY_PROVIDER_STATUS_SLASHED: "Slashed",
} as const;

export const FinalityProvider: React.FC<FinalityProviderProps> = ({
moniker,
state = "active",
state,
pkHex,
stakeSat,
commission,
Expand Down Expand Up @@ -130,7 +137,7 @@ export const FinalityProvider: React.FC<FinalityProviderProps> = ({
/>
</div>
<div className="flex justify-start gap-1 capitalize lg:justify-end">
<span className="lg:hidden">Status:</span> {state}
<span className="lg:hidden">Status:</span> {stateMap[state]}
</div>
</div>
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/app/types/finalityProviders.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface FinalityProvider {
description: Description;
state: "active" | "standby";
state: FinalityProviderState;
commission: string;
btcPk: string;
activeTVLSat: number;
Expand All @@ -16,3 +16,9 @@ export interface Description {
securityContact: string;
details: string;
}

export type FinalityProviderState =
| "FINALITY_PROVIDER_STATUS_INACTIVE"
| "FINALITY_PROVIDER_STATUS_ACTIVE"
| "FINALITY_PROVIDER_STATUS_JAILED"
| "FINALITY_PROVIDER_STATUS_SLASHED";

0 comments on commit 4dcd1f3

Please sign in to comment.