Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import solanaMainnet from "./data/svm/solana-mainnet.json";
<SponsoredFeedsTable
feeds={solanaMainnet.feeds}
networkName="Solana mainnet and devnet"
showUpgradedAccountAddress
/>

Note: The addresses represent the price feed account for shard 0 of the relevant price feed id.
Note: The addresses represent the price feed account for shard 0 of the relevant price feed id. The "Upgraded Account Address" is derived from the upcoming `PRO_COMPATIBLE_PUSH_ORACLE_PROGRAM_ID` (`pyt2F414BA6dPttK6RddPZUdHfapoBN24GL5wbrPCou`).
34 changes: 32 additions & 2 deletions apps/developer-hub/src/components/SponsoredFeedsTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { CopyButton } from "@pythnetwork/component-library/CopyButton";
import { Table } from "@pythnetwork/component-library/Table";
import {
getPriceFeedAccountForProgram,
PRO_COMPATIBLE_PUSH_ORACLE_PROGRAM_ID,
} from "@pythnetwork/pyth-solana-receiver";
import clsx from "clsx";
import type { ReactNode } from "react";
import { useMemo } from "react";
Expand All @@ -18,6 +22,7 @@ type SponsoredFeed = {
type SponsoredFeedsTableProps = {
feeds: SponsoredFeed[];
networkName: string;
showUpgradedAccountAddress?: boolean;
};

type UpdateParamsProps = {
Expand Down Expand Up @@ -82,6 +87,7 @@ const UpdateParams = ({ feed, isDefault }: UpdateParamsProps) => {
export const SponsoredFeedsTable = ({
feeds,
networkName,
showUpgradedAccountAddress = false,
}: SponsoredFeedsTableProps) => {
const paramCounts: Record<string, number> = {};
for (const feed of feeds) {
Expand Down Expand Up @@ -116,6 +122,15 @@ export const SponsoredFeedsTable = ({
},
]
: []),
...(showUpgradedAccountAddress
? [
{
id: "upgradedAccountAddress",
name: "Upgraded Account Address",
alignment: "left" as const,
},
]
: []),
{
id: "priceFeedId",
name: "Price Feed Id",
Expand All @@ -127,7 +142,7 @@ export const SponsoredFeedsTable = ({
alignment: "left" as const,
},
],
[hasAccountAddress],
[hasAccountAddress, showUpgradedAccountAddress],
);

const rows = useMemo(
Expand All @@ -141,13 +156,15 @@ export const SponsoredFeedsTable = ({
priceFeedId: ReactNode;
updateParameters: ReactNode;
accountAddress: ReactNode | undefined;
upgradedAccountAddress: ReactNode | undefined;
} = {
name: <span className={styles.nameLabel}>{feed.alias}</span>,
priceFeedId: (
<CopyButton text={feed.id}>{truncateHex(feed.id)}</CopyButton>
),
updateParameters: <UpdateParams feed={feed} isDefault={isDefault} />,
accountAddress: undefined,
upgradedAccountAddress: undefined,
};

if (hasAccountAddress) {
Expand All @@ -158,12 +175,25 @@ export const SponsoredFeedsTable = ({
) : undefined;
}

if (showUpgradedAccountAddress) {
const upgradedAddress = getPriceFeedAccountForProgram(
0,
feed.id,
PRO_COMPATIBLE_PUSH_ORACLE_PROGRAM_ID,
).toBase58();
rowData.upgradedAccountAddress = (
<CopyButton text={upgradedAddress}>
{truncateHex(upgradedAddress)}
</CopyButton>
);
}

return {
id: feed.id,
data: rowData,
};
}),
[feeds, defaultParams, hasAccountAddress],
[feeds, defaultParams, hasAccountAddress, showUpgradedAccountAddress],
);

if (feeds.length === 0) {
Expand Down
Loading