use pyth::pyth::{GetPriceUnsafeError, DataSource, Price}; // Only used for tests. #[starknet::interface] pub trait IFakePyth { fn get_price_unsafe(self: @T, price_id: u256) -> Result; fn pyth_upgradable_magic(self: @T) -> u32; } #[starknet::contract] mod pyth_fake_upgrade1 { use pyth::pyth::{GetPriceUnsafeError, DataSource, Price}; use pyth::byte_buffer::ByteBuffer; #[storage] struct Storage {} #[constructor] fn constructor(ref self: ContractState) {} #[abi(embed_v0)] impl PythImpl of super::IFakePyth { fn get_price_unsafe( self: @ContractState, price_id: u256 ) -> Result { let price = Price { price: 42, conf: 2, expo: -5, publish_time: 101, }; Result::Ok(price) } fn pyth_upgradable_magic(self: @ContractState) -> u32 { 0x97a6f304 } } } #[starknet::contract] mod pyth_fake_upgrade_wrong_magic { use pyth::pyth::{GetPriceUnsafeError, DataSource, Price}; use pyth::byte_buffer::ByteBuffer; #[storage] struct Storage {} #[constructor] fn constructor(ref self: ContractState) {} #[abi(embed_v0)] impl PythImpl of super::IFakePyth { fn get_price_unsafe( self: @ContractState, price_id: u256 ) -> Result { panic!("unsupported") } fn pyth_upgradable_magic(self: @ContractState) -> u32 { 606 } } } #[starknet::interface] pub trait INotPyth { fn test1(ref self: T) -> u32; } #[starknet::contract] mod pyth_fake_upgrade_not_pyth { #[storage] struct Storage {} #[constructor] fn constructor(ref self: ContractState) {} #[abi(embed_v0)] impl NotPythImpl of super::INotPyth { fn test1(ref self: ContractState) -> u32 { 42 } } }