|
|
@@ -1,8 +1,16 @@
|
|
|
+use pyth::pyth::{GetPriceUnsafeError, DataSource, Price};
|
|
|
+
|
|
|
// Only used for tests.
|
|
|
|
|
|
+#[starknet::interface]
|
|
|
+pub trait IFakePyth<T> {
|
|
|
+ fn get_price_unsafe(self: @T, price_id: u256) -> Result<Price, GetPriceUnsafeError>;
|
|
|
+ fn pyth_upgradable_magic(self: @T) -> u32;
|
|
|
+}
|
|
|
+
|
|
|
#[starknet::contract]
|
|
|
mod pyth_fake_upgrade1 {
|
|
|
- use pyth::pyth::{IPyth, GetPriceUnsafeError, DataSource, Price};
|
|
|
+ use pyth::pyth::{GetPriceUnsafeError, DataSource, Price};
|
|
|
use pyth::byte_array::ByteArray;
|
|
|
|
|
|
#[storage]
|
|
|
@@ -12,24 +20,13 @@ mod pyth_fake_upgrade1 {
|
|
|
fn constructor(ref self: ContractState) {}
|
|
|
|
|
|
#[abi(embed_v0)]
|
|
|
- impl PythImpl of IPyth<ContractState> {
|
|
|
+ impl PythImpl of super::IFakePyth<ContractState> {
|
|
|
fn get_price_unsafe(
|
|
|
self: @ContractState, price_id: u256
|
|
|
) -> Result<Price, GetPriceUnsafeError> {
|
|
|
let price = Price { price: 42, conf: 2, expo: -5, publish_time: 101, };
|
|
|
Result::Ok(price)
|
|
|
}
|
|
|
- fn get_ema_price_unsafe(
|
|
|
- self: @ContractState, price_id: u256
|
|
|
- ) -> Result<Price, GetPriceUnsafeError> {
|
|
|
- panic!("unsupported")
|
|
|
- }
|
|
|
- fn update_price_feeds(ref self: ContractState, data: ByteArray) {
|
|
|
- panic!("unsupported")
|
|
|
- }
|
|
|
- fn execute_governance_instruction(ref self: ContractState, data: ByteArray) {
|
|
|
- panic!("unsupported")
|
|
|
- }
|
|
|
fn pyth_upgradable_magic(self: @ContractState) -> u32 {
|
|
|
0x97a6f304
|
|
|
}
|
|
|
@@ -38,7 +35,7 @@ mod pyth_fake_upgrade1 {
|
|
|
|
|
|
#[starknet::contract]
|
|
|
mod pyth_fake_upgrade_wrong_magic {
|
|
|
- use pyth::pyth::{IPyth, GetPriceUnsafeError, DataSource, Price};
|
|
|
+ use pyth::pyth::{GetPriceUnsafeError, DataSource, Price};
|
|
|
use pyth::byte_array::ByteArray;
|
|
|
|
|
|
#[storage]
|
|
|
@@ -48,23 +45,12 @@ mod pyth_fake_upgrade_wrong_magic {
|
|
|
fn constructor(ref self: ContractState) {}
|
|
|
|
|
|
#[abi(embed_v0)]
|
|
|
- impl PythImpl of IPyth<ContractState> {
|
|
|
+ impl PythImpl of super::IFakePyth<ContractState> {
|
|
|
fn get_price_unsafe(
|
|
|
self: @ContractState, price_id: u256
|
|
|
) -> Result<Price, GetPriceUnsafeError> {
|
|
|
panic!("unsupported")
|
|
|
}
|
|
|
- fn get_ema_price_unsafe(
|
|
|
- self: @ContractState, price_id: u256
|
|
|
- ) -> Result<Price, GetPriceUnsafeError> {
|
|
|
- panic!("unsupported")
|
|
|
- }
|
|
|
- fn update_price_feeds(ref self: ContractState, data: ByteArray) {
|
|
|
- panic!("unsupported")
|
|
|
- }
|
|
|
- fn execute_governance_instruction(ref self: ContractState, data: ByteArray) {
|
|
|
- panic!("unsupported")
|
|
|
- }
|
|
|
fn pyth_upgradable_magic(self: @ContractState) -> u32 {
|
|
|
606
|
|
|
}
|