-
-
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.
Merge pull request #185 from palladians/feat/add-block-validators-list
feat(staking): add validators list
- Loading branch information
Showing
23 changed files
with
150 additions
and
81 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
VITE_APP_MODE=web | ||
VITE_APP_DEFAULT_NETWORK=Devnet | ||
|
||
VITE_APP_MINA_PROXY_MAINNET_URL=https://api.minascan.io/node/mainnet/v1/graphql | ||
VITE_APP_MINA_PROXY_MAINNET_URL=https://pallad.co/api/obscura/mainnet.json | ||
|
||
VITE_APP_MINA_PROXY_DEVNET_URL=https://api.minascan.io/node/devnet/v1/graphql | ||
VITE_APP_MINA_PROXY_DEVNET_URL=https://pallad.co/api/obscura/devnet.json |
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
58 changes: 45 additions & 13 deletions
58
packages/features/src/staking/components/block-producer-tile.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 |
---|---|---|
@@ -1,41 +1,73 @@ | ||
import PlaceholderImage from "@/common/assets/placeholder.svg?react" | ||
import { useNavigate } from "react-router-dom" | ||
|
||
import { formatCompact } from "@/common/lib/numbers" | ||
import { useState } from "react" | ||
import type { BlockProducer } from "../types" | ||
|
||
type BlockProducer = { | ||
const Avatar = ({ | ||
img, | ||
name, | ||
setShowPlaceholder, | ||
}: { | ||
img: string | undefined | ||
name: string | ||
publicKey: string | ||
stake: number | ||
delegatorsCount: number | ||
setShowPlaceholder: (show: boolean) => void | ||
}) => { | ||
if (!img) return <PlaceholderImage width={24} height={24} /> | ||
return ( | ||
<img | ||
src={img} | ||
alt={name} | ||
onError={() => setShowPlaceholder(true)} | ||
className="rounded-full" | ||
/> | ||
) | ||
} | ||
|
||
interface BlockProducerTileProps { | ||
producer: BlockProducer | ||
} | ||
|
||
export const BlockProducerTile = ({ producer }: BlockProducerTileProps) => { | ||
const [showPlaceholder, setShowPlaceholder] = useState(false) | ||
const navigate = useNavigate() | ||
return ( | ||
<div | ||
className="flex flex-1 justify-between items-center p-2" | ||
<button | ||
type="button" | ||
className="card bg-secondary flex flex-row justify-between items-center p-2" | ||
onClick={() => | ||
navigate("/staking/delegate", { | ||
state: { address: producer.publicKey }, | ||
state: { address: producer.pk }, | ||
}) | ||
} | ||
> | ||
<div className="flex items-center gap-4"> | ||
<div>{producer.name?.[0]}</div> | ||
<div className="font-semibold">{producer.name}</div> | ||
<div className="flex flex-1 gap-4 items-center"> | ||
<div className="avatar placeholder"> | ||
<div className="bg-neutral text-neutral-content w-12 rounded-full"> | ||
{showPlaceholder ? ( | ||
<PlaceholderImage width={24} height={24} /> | ||
) : ( | ||
<Avatar | ||
img={producer.img} | ||
name={producer.name ?? producer.pk} | ||
setShowPlaceholder={setShowPlaceholder} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
<div className="font-semibold flex-1 truncate text-left break-all max-w-[7rem] w-full"> | ||
{producer.name ?? producer.pk} | ||
</div> | ||
</div> | ||
<div className="gap-1"> | ||
<div className="font-semibold"> | ||
{formatCompact({ value: producer.stake })} MINA | ||
{formatCompact({ value: producer.amountStaked })} MINA | ||
</div> | ||
<div className="text-right text-sm"> | ||
{formatCompact({ value: producer.delegatorsCount })} Delegators | ||
{formatCompact({ value: producer.delegators })} Delegators | ||
</div> | ||
</div> | ||
</div> | ||
</button> | ||
) | ||
} |
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
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
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 |
---|---|---|
@@ -1,28 +1,23 @@ | ||
import { useNavigate } from "react-router-dom" | ||
|
||
import { fetcher } from "@/common/lib/fetch" | ||
import useSWR from "swr" | ||
import type { BlockProducer } from "../types" | ||
import { BlockProducersView } from "../views/block-producers" | ||
|
||
const MOCKED_PRODUCERS = [ | ||
{ | ||
name: "Pallad", | ||
publicKey: "B62qkYa1o6Mj6uTTjDQCob7FYZspuhkm4RRQhgJg9j4koEBWiSrTQrS", | ||
stake: 24000, | ||
delegatorsCount: 6000, | ||
}, | ||
{ | ||
name: "Pallad 2", | ||
publicKey: "B62qkYa1o6Mj6uTTjDQCob7FYZspuhkm4RRQhgJg9j4koEBWiSrTQrS", | ||
stake: 12000, | ||
delegatorsCount: 3000, | ||
}, | ||
] | ||
const STAKEPOOLS_URL = "https://pallad.co/api/stakepools.json" | ||
|
||
type StakePoolsResponse = { | ||
content: BlockProducer[] | ||
} | ||
|
||
export const BlockProducersRoute = () => { | ||
const { data } = useSWR<StakePoolsResponse>(STAKEPOOLS_URL, fetcher) | ||
const navigate = useNavigate() | ||
return ( | ||
<BlockProducersView | ||
onGoBack={() => navigate(-1)} | ||
blockProducers={MOCKED_PRODUCERS} | ||
blockProducers={data?.content ?? []} | ||
/> | ||
) | ||
} |
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,7 @@ | ||
export type BlockProducer = { | ||
name?: string | ||
pk: string | ||
delegators: number | ||
amountStaked: number | ||
img?: string | ||
} |
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
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
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
2 changes: 1 addition & 1 deletion
2
...s/providers/test/mina-node/l1-mina-node/individual-providers/node-status-provider.test.ts
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
Oops, something went wrong.