-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b238391
commit 9ef3aef
Showing
13 changed files
with
166 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
src/app/components/Staking/FinalityProviders/v2/FinalityProviderFilter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const FinalityProviderFilter = () => { | ||
return <div>FinalityProviderFilter</div>; | ||
}; |
3 changes: 3 additions & 0 deletions
3
src/app/components/Staking/FinalityProviders/v2/FinalityProviderSearch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const FinalityProviderSearch = () => { | ||
return <div>FinalityProviderSearch</div>; | ||
}; |
5 changes: 5 additions & 0 deletions
5
src/app/components/Staking/FinalityProviders/v2/FinalityProviderSubtitle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Heading } from "@babylonlabs-io/bbn-core-ui"; | ||
|
||
export const FinalityProviderSubtitle = () => { | ||
return <Heading variant="h3">Select a Finality Provider</Heading>; | ||
}; |
93 changes: 93 additions & 0 deletions
93
src/app/components/Staking/FinalityProviders/v2/FinalityProviderTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Table } from "@babylonlabs-io/bbn-core-ui"; | ||
import { useMemo } from "react"; | ||
|
||
import { Hash } from "@/app/components/Hash/Hash"; | ||
import { useFinalityProviderService } from "@/app/hooks/services/useFinalityProviderService"; | ||
import { | ||
FinalityProvider, | ||
FinalityProviderState, | ||
} from "@/app/types/finalityProviders"; | ||
import { getNetworkConfig } from "@/config/network.config"; | ||
import { satoshiToBtc } from "@/utils/btc"; | ||
import { maxDecimals } from "@/utils/maxDecimals"; | ||
|
||
import { FPInfo } from "./components/FPInfo"; | ||
|
||
export const FinalityProviderTable = () => { | ||
const { isLoading, finalityProviders, hasNextPage, fetchNextPage } = | ||
useFinalityProviderService(); | ||
|
||
const { coinName } = getNetworkConfig(); | ||
|
||
const columns = useMemo( | ||
() => [ | ||
{ | ||
key: "moniker", | ||
header: "Finality Provider", | ||
render: (_: unknown, row: FinalityProvider) => ( | ||
<FPInfo | ||
moniker={row.description?.moniker} | ||
website={row.description?.website} | ||
/> | ||
), | ||
sorter: (a: FinalityProvider, b: FinalityProvider) => | ||
(a.description?.moniker || "").localeCompare( | ||
b.description?.moniker || "", | ||
), | ||
}, | ||
{ | ||
key: "btcPk", | ||
header: "BTC PK", | ||
render: (_: unknown, row: FinalityProvider) => ( | ||
<Hash value={row.btcPk} address small noFade /> | ||
), | ||
}, | ||
{ | ||
key: "activeTVLSat", | ||
header: "Total Delegation", | ||
render: (value: unknown) => | ||
`${maxDecimals(satoshiToBtc(value as number), 8)} ${coinName}`, | ||
sorter: (a: FinalityProvider, b: FinalityProvider) => | ||
a.activeTVLSat - b.activeTVLSat, | ||
}, | ||
{ | ||
key: "commission", | ||
header: "Commission", | ||
render: (value: unknown) => `${maxDecimals(Number(value) * 100, 2)}%`, | ||
sorter: (a: FinalityProvider, b: FinalityProvider) => | ||
Number(a.commission) - Number(b.commission), | ||
}, | ||
{ | ||
key: "state", | ||
header: "Status", | ||
render: (value: unknown) => | ||
(value as FinalityProviderState).replace( | ||
"FINALITY_PROVIDER_STATUS_", | ||
"", | ||
), | ||
}, | ||
], | ||
[coinName], | ||
); | ||
|
||
const tableData = useMemo( | ||
() => | ||
finalityProviders?.map((fp) => ({ | ||
...fp, | ||
id: fp.btcPk, | ||
})) || [], | ||
[finalityProviders], | ||
); | ||
|
||
return ( | ||
<Table | ||
data={tableData} | ||
columns={columns} | ||
loading={isLoading} | ||
hasMore={hasNextPage} | ||
onLoadMore={fetchNextPage} | ||
onRowSelect={() => {}} | ||
className="max-h-[21rem] overflow-y-auto" | ||
/> | ||
); | ||
}; |
5 changes: 5 additions & 0 deletions
5
src/app/components/Staking/FinalityProviders/v2/FinalityProviderTitle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Heading } from "@babylonlabs-io/bbn-core-ui"; | ||
|
||
export const FinalityProviderTitle = () => { | ||
return <Heading variant="h2">Step 1</Heading>; | ||
}; |
17 changes: 17 additions & 0 deletions
17
src/app/components/Staking/FinalityProviders/v2/FinalityProviders.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { FinalityProviderFilter } from "./FinalityProviderFilter"; | ||
import { FinalityProviderSearch } from "./FinalityProviderSearch"; | ||
import { FinalityProviderSubtitle } from "./FinalityProviderSubtitle"; | ||
import { FinalityProviderTable } from "./FinalityProviderTable"; | ||
import { FinalityProviderTitle } from "./FinalityProviderTitle"; | ||
|
||
export const FinalityProviders = () => { | ||
return ( | ||
<div className="flex flex-col gap-4"> | ||
<FinalityProviderTitle /> | ||
<FinalityProviderSubtitle /> | ||
<FinalityProviderSearch /> | ||
<FinalityProviderFilter /> | ||
<FinalityProviderTable /> | ||
</div> | ||
); | ||
}; |
34 changes: 34 additions & 0 deletions
34
src/app/components/Staking/FinalityProviders/v2/components/FPInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Image from "next/image"; | ||
import { FiExternalLink } from "react-icons/fi"; | ||
|
||
import blue from "@/app/assets/blue-check.svg"; | ||
|
||
interface FPInfoProps { | ||
moniker?: string; | ||
website?: string; | ||
} | ||
|
||
export const FPInfo = ({ moniker, website }: FPInfoProps) => { | ||
if (!moniker) { | ||
return <span>No data provided</span>; | ||
} | ||
|
||
return ( | ||
<div className="flex items-center gap-1"> | ||
<Image src={blue} alt="verified" /> | ||
<span> | ||
{moniker} | ||
{website && ( | ||
<a | ||
href={website} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="text-primary inline-flex ml-1 relative top-[1px]" | ||
> | ||
<FiExternalLink /> | ||
</a> | ||
)} | ||
</span> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters