gmsol/pyth/
push_oracle.rs1use anchor_client::anchor_lang::solana_program::pubkey::Pubkey;
2use gmsol_store::states::Pyth;
3
4pub fn find_pyth_feed_account(shard_id: u16, feed_id: [u8; 32]) -> (Pubkey, u8) {
6 Pubkey::find_program_address(
7 &[shard_id.to_le_bytes().as_slice(), feed_id.as_slice()],
8 &Pyth::PUSH_ORACLE_ID,
9 )
10}
11
12#[cfg(test)]
13mod tests {
14 #[cfg(feature = "pyth-solana-receiver-sdk")]
15 #[test]
16 fn test_sol_feed_account() {
17 use super::{find_pyth_feed_account, Pubkey};
18 use pyth_solana_receiver_sdk::price_update::get_feed_id_from_hex;
19 use std::str::FromStr;
20
21 let feed_id = get_feed_id_from_hex(
22 "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
23 )
24 .unwrap();
25 let expected_address =
26 Pubkey::from_str("7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE").unwrap();
27 assert_eq!(find_pyth_feed_account(0, feed_id).0, expected_address);
28 }
29}