@@ -2,10 +2,12 @@ import { useState, useEffect } from "react";
22import { TextField , Select , MenuItem } from "@mui/material" ;
33import { HermesClient , PriceFeedMetadata } from "@pythnetwork/hermes-client" ;
44import { Table , Td , Th , Tr , CopyToClipboard } from "nextra/components" ;
5+ import base58 from "bs58" ;
6+ import { getPriceFeedAccountForProgram } from "@pythnetwork/pyth-solana-receiver" ;
57
6- const fetchStablePriceFeeds = async ( ) => {
8+ const fetchPriceFeeds = async ( stable : boolean ) => {
79 const priceFeeds = await new HermesClient (
8- "https://hermes.pyth.network"
10+ stable ? "https://hermes.pyth.network" : "https://hermes-beta .pyth.network"
911 ) . getPriceFeeds ( ) ;
1012 const assetTypes = Array . from (
1113 new Set ( priceFeeds . map ( ( feed ) => feed . attributes . asset_type ?? "" ) )
@@ -14,15 +16,12 @@ const fetchStablePriceFeeds = async () => {
1416 return { priceFeeds, assetTypes } ;
1517} ;
1618
17- const fetchBetaPriceFeeds = async ( ) => {
18- const priceFeeds = await new HermesClient (
19- "https://hermes-beta.pyth.network"
20- ) . getPriceFeeds ( ) ;
21- const assetTypes = Array . from (
22- new Set ( priceFeeds . map ( ( feed ) => feed . attributes . asset_type ?? "" ) )
19+ const fetchSolanaPriceFeedAccounts = async ( ) => {
20+ const priceFeeds = await fetchPriceFeeds ( true ) ;
21+ const priceFeedIds = priceFeeds . priceFeeds . map ( ( feed ) =>
22+ getPriceFeedAccountForProgram ( 0 , base58 . decode ( feed . id ) ) . toBase58 ( )
2323 ) ;
24- console . log ( priceFeeds ) ;
25- return { priceFeeds, assetTypes } ;
24+ return priceFeedIds ;
2625} ;
2726
2827type AssetTypesSelectorProps = {
@@ -63,7 +62,8 @@ const usePriceFeeds = (): PriceFeedsState => {
6362
6463 useEffect ( ( ) => {
6564 setPriceFeeds ( PriceFeedsState . Loading ( ) ) ;
66- fetchStablePriceFeeds ( )
65+ // console.log(fetchSolanaPriceFeedAccounts())
66+ fetchPriceFeeds ( true )
6767 . then ( ( { priceFeeds, assetTypes } ) => {
6868 setPriceFeeds ( PriceFeedsState . Loaded ( priceFeeds , assetTypes ) ) ;
6969 } )
0 commit comments