diff --git a/src/app/api/getFinalityProviders.ts b/src/app/api/getFinalityProviders.ts index 2dd30538..f483dcd9 100644 --- a/src/app/api/getFinalityProviders.ts +++ b/src/app/api/getFinalityProviders.ts @@ -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"; @@ -19,7 +22,7 @@ interface FinalityProvidersAPIResponse { interface FinalityProviderAPI { description: DescriptionAPI; - state: "active" | "standby"; + state: FinalityProviderState; commission: string; btc_pk: string; active_tvl: number; @@ -64,7 +67,7 @@ export const getFinalityProviders = async ({ const response = await apiWrapper( "GET", - "/v1/finality-providers", + "/v2/finality-providers", "Error getting finality providers", params, ); diff --git a/src/app/components/Staking/FinalityProviders/FinalityProvider.tsx b/src/app/components/Staking/FinalityProviders/FinalityProvider.tsx index 425c1295..4a6069f4 100644 --- a/src/app/components/Staking/FinalityProviders/FinalityProvider.tsx +++ b/src/app/components/Staking/FinalityProviders/FinalityProvider.tsx @@ -6,6 +6,7 @@ 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"; @@ -13,17 +14,23 @@ 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 = ({ moniker, - state = "active", + state, pkHex, stakeSat, commission, @@ -130,7 +137,7 @@ export const FinalityProvider: React.FC = ({ />
- Status: {state} + Status: {stateMap[state]}
diff --git a/src/app/types/finalityProviders.ts b/src/app/types/finalityProviders.ts index 244e3d0c..6e53e52e 100644 --- a/src/app/types/finalityProviders.ts +++ b/src/app/types/finalityProviders.ts @@ -1,6 +1,6 @@ export interface FinalityProvider { description: Description; - state: "active" | "standby"; + state: FinalityProviderState; commission: string; btcPk: string; activeTVLSat: number; @@ -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";