@@ -9,7 +9,10 @@ pub use pyth::{Event, PriceFeedUpdateEvent};
9
9
pub trait IPyth <T > {
10
10
fn get_price_unsafe (self : @ T , price_id : u256 ) -> Result <Price , GetPriceUnsafeError >;
11
11
fn get_ema_price_unsafe (self : @ T , price_id : u256 ) -> Result <Price , GetPriceUnsafeError >;
12
- fn set_data_sources (ref self : T , sources : Array <DataSource >) -> Result <(), SetDataSourcesError >;
12
+ fn set_data_sources (
13
+ ref self : T , sources : Array <DataSource >
14
+ ) -> Result <(), GovernanceActionError >;
15
+ fn set_fee (ref self : T , single_update_fee : u256 ) -> Result <(), GovernanceActionError >;
13
16
fn update_price_feeds (ref self : T , data : ByteArray ) -> Result <(), UpdatePriceFeedsError >;
14
17
}
15
18
@@ -35,25 +38,24 @@ impl GetPriceUnsafeErrorIntoFelt252 of Into<GetPriceUnsafeError, felt252> {
35
38
}
36
39
}
37
40
38
-
39
41
#[derive(Copy , Drop , Debug , Serde , PartialEq )]
40
- pub enum SetDataSourcesError {
42
+ pub enum GovernanceActionError {
41
43
AccessDenied ,
42
44
}
43
45
44
- pub impl SetDataSourcesErrorUnwrapWithFelt252 <T > of UnwrapWithFelt252 <T , SetDataSourcesError > {
45
- fn unwrap_with_felt252 (self : Result <T , SetDataSourcesError >) -> T {
46
+ pub impl GovernanceActionErrorUnwrapWithFelt252 <T > of UnwrapWithFelt252 <T , GovernanceActionError > {
47
+ fn unwrap_with_felt252 (self : Result <T , GovernanceActionError >) -> T {
46
48
match self {
47
49
Result :: Ok (v ) => v ,
48
50
Result :: Err (err ) => core :: panic_with_felt252 (err . into ()),
49
51
}
50
52
}
51
53
}
52
54
53
- impl SetDataSourcesErrorIntoFelt252 of Into <SetDataSourcesError , felt252 > {
54
- fn into (self : SetDataSourcesError ) -> felt252 {
55
+ impl GovernanceActionErrorIntoFelt252 of Into <GovernanceActionError , felt252 > {
56
+ fn into (self : GovernanceActionError ) -> felt252 {
55
57
match self {
56
- SetDataSourcesError :: AccessDenied => ' access denied' ,
58
+ GovernanceActionError :: AccessDenied => ' access denied' ,
57
59
}
58
60
}
59
61
}
@@ -116,10 +118,10 @@ mod pyth {
116
118
use pyth :: reader :: {Reader , ReaderImpl };
117
119
use pyth :: byte_array :: {ByteArray , ByteArrayImpl };
118
120
use core :: panic_with_felt252 ;
119
- use core :: starknet :: {ContractAddress , get_caller_address};
121
+ use core :: starknet :: {ContractAddress , get_caller_address, get_execution_info };
120
122
use pyth :: wormhole :: {IWormholeDispatcher , IWormholeDispatcherTrait };
121
123
use super :: {
122
- DataSource , UpdatePriceFeedsError , PriceInfo , SetDataSourcesError , Price ,
124
+ DataSource , UpdatePriceFeedsError , PriceInfo , GovernanceActionError , Price ,
123
125
GetPriceUnsafeError
124
126
};
125
127
use pyth :: merkle_tree :: {read_and_verify_proof, MerkleVerificationError };
@@ -220,6 +222,8 @@ mod pyth {
220
222
#[storage]
221
223
struct Storage {
222
224
wormhole_address : ContractAddress ,
225
+ fee_contract_address : ContractAddress ,
226
+ single_update_fee : u256 ,
223
227
owner : ContractAddress ,
224
228
data_sources : LegacyMap <usize , DataSource >,
225
229
num_data_sources : usize ,
@@ -233,10 +237,14 @@ mod pyth {
233
237
ref self : ContractState ,
234
238
owner : ContractAddress ,
235
239
wormhole_address : ContractAddress ,
240
+ fee_contract_address : ContractAddress ,
241
+ single_update_fee : u256 ,
236
242
data_sources : Array <DataSource >
237
243
) {
238
244
self . owner. write (wormhole_address );
239
245
self . wormhole_address. write (wormhole_address );
246
+ self . fee_contract_address. write (fee_contract_address );
247
+ self . single_update_fee. write (single_update_fee );
240
248
write_data_sources (ref self , data_sources );
241
249
}
242
250
@@ -308,14 +316,24 @@ mod pyth {
308
316
309
317
fn set_data_sources (
310
318
ref self : ContractState , sources : Array <DataSource >
311
- ) -> Result <(), SetDataSourcesError > {
319
+ ) -> Result <(), GovernanceActionError > {
312
320
if self . owner. read () != get_caller_address () {
313
- return Result :: Err (SetDataSourcesError :: AccessDenied );
321
+ return Result :: Err (GovernanceActionError :: AccessDenied );
314
322
}
315
323
write_data_sources (ref self , sources );
316
324
Result :: Ok (())
317
325
}
318
326
327
+ fn set_fee (
328
+ ref self : ContractState , single_update_fee : u256
329
+ ) -> Result <(), GovernanceActionError > {
330
+ if self . owner. read () != get_caller_address () {
331
+ return Result :: Err (GovernanceActionError :: AccessDenied );
332
+ }
333
+ self . single_update_fee. write (single_update_fee );
334
+ Result :: Ok (())
335
+ }
336
+
319
337
fn update_price_feeds (
320
338
ref self : ContractState , data : ByteArray
321
339
) -> Result <(), UpdatePriceFeedsError > {
0 commit comments