From 59b14c6ea9fa6b836f4027ba6e774b81d23e00d6 Mon Sep 17 00:00:00 2001 From: Connor Prussin Date: Tue, 8 Oct 2024 18:14:35 -0700 Subject: [PATCH] feat(staking): expose publisher names for pubs who wish to be public --- .../public/publisher-icons/blocksize.png | Bin 0 -> 152681 bytes apps/staking/src/api.ts | 13 +- .../src/components/CopyButton/index.tsx | 8 +- .../Header/current-stake-account.tsx | 2 +- .../OracleIntegrityStaking/index.tsx | 118 ++++++++++++------ apps/staking/src/components/Tooltip/index.tsx | 9 +- apps/staking/src/known-publishers.ts | 6 + 7 files changed, 106 insertions(+), 50 deletions(-) create mode 100644 apps/staking/public/publisher-icons/blocksize.png create mode 100644 apps/staking/src/known-publishers.ts diff --git a/apps/staking/public/publisher-icons/blocksize.png b/apps/staking/public/publisher-icons/blocksize.png new file mode 100644 index 0000000000000000000000000000000000000000..f93928d89e1d510ec48d6bb0afd6beedc01f8f8b GIT binary patch literal 152681 zcmeI54~!Jm9mnUEh5G}C$4TI@f~&#WCTP!63&}~{t5<<&)i$J|MdLvmsUaZLmb2P; zi=+i3wS*?sq+&@(Oxl!+ZK|N5tV(kvO_1~-f4nGK6`Nkc*b4afy0h$i@3(W`jhCAH z2OkphzO#3`GxM2wpLz4{z1jP2ynb$d-FbCU6xGk4*Y?#Yn!GapUo)og%0CvYyE;lO zXrABJy5P>kJ>8GjKYQcEbn6RMa~k${-nM>x!+qc1G^^v?wNw6i-j3AjtGdQSzwVjy z-p;DRTZ{iz?7DT`C!+SR|KiYrdiUD)Ik(<0E6P8$x~jvyR9@!(^m3~F6}ObTKiA@N zd6`Xj`<0geYkyvQBNGvp5Bo-Pj5(^C%i6x@pBDtI` z4VP2DyQ8bvC9?MYZ70WV&C2ePTy3Q;kWW_XgLtS?e@1(%Qr`?K5oaQ}1eA!gOHrXR z3M#luK#94e8DyNGyy%kXRUjAh9q4L1Lld zBC*hL(OACo-Kyxi4eK`R0aS`kptih?pQT3K?=_}X}F=?^-WuZkbzQuePn-epq!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9k|D*_6=>kQ=nMazJoC>JW=CU_TQZ?iAIth&g?T~QbaySo*koXyZAsw&Vo1G(x83 z9axw|%iF*Rk(PI0VG=EG10%$d(DFX@+v;`22h`sC;qE79`wQ^to%mUlm@kyB)Pcc# ztZ>+U`sn#s{#RXK60sv;OU^D!qm((j1QaF_D=17NmQ>J+z=Bo;6ttqCpcP34tq3e= zMLt=VEW`!OIxY0T#rBP&S~iI*8&tf(-$ zSW#gZprC?Q1QfKQpfI{vQb8*M3tACS(29bBRwNa)BCwzp0R^onC}>4e849grP8=yd zq&B<1_rRp3VYBj$TQ;{$ikF*Sy?xixrqP=!O}gPWKTr#a+x);Hq@g&&!`e9}fkj9h olfc3!8Z#b+3By(Oljbh{^18nsdhlqxt@FQhecNxo*naQ-0N2}GEdT%j literal 0 HcmV?d00001 diff --git a/apps/staking/src/api.ts b/apps/staking/src/api.ts index 8772f0e4f8..9759488b20 100644 --- a/apps/staking/src/api.ts +++ b/apps/staking/src/api.ts @@ -12,6 +12,8 @@ import { import { PublicKey } from "@solana/web3.js"; import { z } from "zod"; +import { KNOWN_PUBLISHERS } from "./known-publishers"; + const publishersRankingSchema = z .object({ publisher: z.string(), @@ -47,7 +49,12 @@ type Data = { m: bigint; z: bigint; integrityStakingPublishers: { - name: string | undefined; + identity: + | { + name: string; + icon: string; + } + | undefined; publicKey: PublicKey; stakeAccount: PublicKey | undefined; selfStake: bigint; @@ -263,7 +270,9 @@ const loadPublisherData = async ( return { apyHistory, - name: undefined, // TODO + identity: ( + KNOWN_PUBLISHERS as Record + )[publisher.pubkey.toBase58()], numFeeds: numberOfSymbols ?? 0, poolCapacity: getPublisherCap(publisherCaps, publisher.pubkey), poolUtilization: publisher.totalDelegation, diff --git a/apps/staking/src/components/CopyButton/index.tsx b/apps/staking/src/components/CopyButton/index.tsx index 7c27e02e70..5a7e5c4531 100644 --- a/apps/staking/src/components/CopyButton/index.tsx +++ b/apps/staking/src/components/CopyButton/index.tsx @@ -52,7 +52,7 @@ export const CopyButton = ({ onPress={copy} isDisabled={isCopied} className={clsx( - "group -mx-2 -mt-0.5 rounded-md px-2 py-0.5 align-middle transition hover:bg-white/10 focus:outline-none focus-visible:ring-1 focus-visible:ring-pythpurple-400", + "group mx-[-0.25em] -mt-0.5 inline-block rounded-md px-[0.25em] py-0.5 transition hover:bg-white/10 focus:outline-none focus-visible:ring-1 focus-visible:ring-pythpurple-400", className, )} {...(isCopied && { "data-is-copied": true })} @@ -60,13 +60,13 @@ export const CopyButton = ({ > {(...args) => ( <> - + {typeof children === "function" ? children(...args) : children} - + -
Copy code to clipboaord
+
Copy to clipboard
diff --git a/apps/staking/src/components/Header/current-stake-account.tsx b/apps/staking/src/components/Header/current-stake-account.tsx index a003ad0e71..1356124318 100644 --- a/apps/staking/src/components/Header/current-stake-account.tsx +++ b/apps/staking/src/components/Header/current-stake-account.tsx @@ -28,7 +28,7 @@ export const CurrentStakeAccount = ({
Stake account:
{api.account} diff --git a/apps/staking/src/components/OracleIntegrityStaking/index.tsx b/apps/staking/src/components/OracleIntegrityStaking/index.tsx index 66d8e82ac7..a4b8e68dbf 100644 --- a/apps/staking/src/components/OracleIntegrityStaking/index.tsx +++ b/apps/staking/src/components/OracleIntegrityStaking/index.tsx @@ -10,6 +10,7 @@ import { import { calculateApy } from "@pythnetwork/staking-sdk"; import { PublicKey } from "@solana/web3.js"; import clsx from "clsx"; +import Image from "next/image"; import { useMemo, useCallback, @@ -190,13 +191,13 @@ const SelfStaking = ({

Self Staking

- {self} - +
@@ -353,10 +354,12 @@ const ReassignStakeAccount = ({ closeDisabled={closeDisabled} description={ <> - + Designate a different stake account as the self-staking account for - {self} + + {self} + } {...props} @@ -613,8 +616,8 @@ const PublisherList = ({ .filter( (publisher) => filter.contains(publisher.publicKey.toBase58(), search) || - (publisher.name !== undefined && - filter.contains(publisher.name, search)), + (publisher.identity !== undefined && + filter.contains(publisher.identity.name, search)), ) .sort((a, b) => { if (yoursFirst) { @@ -1027,8 +1030,8 @@ const compareName = ( ) => (reverse ? -1 : 1) * collator.compare( - a.name ?? a.publicKey.toBase58(), - b.name ?? b.publicKey.toBase58(), + a.identity?.name ?? a.publicKey.toBase58(), + b.identity?.name ?? b.publicKey.toBase58(), ); const compareApy = ( @@ -1166,7 +1169,12 @@ type PublisherProps = { totalStaked: bigint; isSelf?: boolean | undefined; publisher: { - name: string | undefined; + identity: + | { + name: string; + icon: string; + } + | undefined; publicKey: PublicKey; stakeAccount: PublicKey | undefined; selfStake: bigint; @@ -1247,6 +1255,7 @@ const Publisher = ({ publisher.poolCapacity, publisher.poolUtilization, publisher.poolUtilizationDelta, + publisher.delegationFee, yieldRate, ], ); @@ -1255,13 +1264,14 @@ const Publisher = ({
{!isSelf && (
- {publisher} - + - {publisher} - + {publisher.selfStake + publisher.selfStakeDelta} @@ -1526,12 +1537,12 @@ const YourPositionsTable = ({ className="w-28" actionDescription={ <> - + Cancel tokens that are in warmup for staking to - + {publisher} - + } actionName="Cancel" @@ -1563,12 +1574,10 @@ const YourPositionsTable = ({ className="md:w-28" actionDescription={ <> - - Unstake tokens from - - + Unstake tokens from + {publisher} - + } actionName="Unstake" @@ -1615,8 +1624,10 @@ const StakeToPublisherButton = ({ size="small" actionDescription={ <> - Stake to - {publisher} + Stake to + + {publisher} + } actionName="Stake" @@ -1690,6 +1701,7 @@ const NewApy = ({ publisher.selfStakeDelta, publisher.poolUtilization, publisher.poolUtilizationDelta, + publisher.delegationFee, children, ], ); @@ -1697,34 +1709,58 @@ const NewApy = ({ return
{apy}%
; }; -type PublisherNameProps = { +type PublisherIdentityProps = PublisherKeyProps & { + withNameClassName?: string | undefined; +}; + +const PublisherIdentity = ({ + className, + withNameClassName, + ...props +}: PublisherIdentityProps) => + props.children.identity ? ( + + + {`${props.children.identity.name} + {props.children.identity.name} + + + + ) : ( + + ); + +type PublisherKeyProps = { className?: string | undefined; children: PublisherProps["publisher"]; fullClassName?: string; truncatedClassName?: string; }; -const PublisherName = ({ +const PublisherKey = ({ children, fullClassName, truncatedClassName, className, -}: PublisherNameProps) => - children.name ? ( - {children.name} - ) : ( - - {fullClassName && ( - {children.publicKey.toBase58()} - )} - - {children.publicKey} - - - ); +}: PublisherKeyProps) => ( + + {fullClassName && ( + {children.publicKey.toBase58()} + )} + + {children.publicKey} + + +); const useTransferActionForPublisher = ( action: ((publisher: PublicKey, amount: bigint) => Promise) | undefined, diff --git a/apps/staking/src/components/Tooltip/index.tsx b/apps/staking/src/components/Tooltip/index.tsx index fd095e9896..c28836452f 100644 --- a/apps/staking/src/components/Tooltip/index.tsx +++ b/apps/staking/src/components/Tooltip/index.tsx @@ -9,14 +9,19 @@ type Props = Omit, "children"> & { export const Tooltip = ({ children, className, offset, ...props }: Props) => ( - + diff --git a/apps/staking/src/known-publishers.ts b/apps/staking/src/known-publishers.ts new file mode 100644 index 0000000000..2aa096d8da --- /dev/null +++ b/apps/staking/src/known-publishers.ts @@ -0,0 +1,6 @@ +export const KNOWN_PUBLISHERS = { + CfVkYofcLC1iVBcYFzgdYPeiX25SVRmWvBQVHorP1A3y: { + name: "BLOCKSIZE", + icon: "/publisher-icons/blocksize.png", + }, +};