@@ -43,11 +43,12 @@ mod pyth {
4343 use super :: governance;
4444 use super :: governance :: GovernancePayload ;
4545 use openzeppelin :: token :: erc20 :: interface :: {IERC20CamelDispatcherTrait , IERC20CamelDispatcher };
46- use pyth :: util :: ResultMapErrInto ;
46+ use pyth :: util :: { ResultMapErrInto , write_ i64 } ;
4747 use core :: nullable :: {NullableTrait , match_nullable, FromNullableResult };
48+ use core :: fmt :: {Debug , Formatter };
4849
4950 #[event]
50- #[derive(Drop , PartialEq , starknet:: Event )]
51+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
5152 pub enum Event {
5253 PriceFeedUpdated : PriceFeedUpdated ,
5354 FeeSet : FeeSet ,
@@ -57,41 +58,60 @@ mod pyth {
5758 ContractUpgraded : ContractUpgraded ,
5859 }
5960
60- #[derive(Drop , PartialEq , starknet:: Event )]
61+ #[derive(Drop , Clone , PartialEq , Serde , starknet:: Event )]
6162 pub struct PriceFeedUpdated {
6263 #[key]
6364 pub price_id : u256 ,
64- pub publish_time : u64 ,
6565 pub price : i64 ,
6666 pub conf : u64 ,
67+ pub publish_time : u64 ,
68+ }
69+
70+ // TODO: use derives after upgrading cairo
71+ impl DebugPriceFeedUpdated of Debug <PriceFeedUpdated > {
72+ fn fmt (self : @ PriceFeedUpdated , ref f : Formatter ) -> Result <(), core :: fmt :: Error > {
73+ write! (f , " PriceFeedUpdated {{ price_id: {}, price: " , self . price_id)? ;
74+ write_i64 (ref f , * self . price)? ;
75+ write! (f , " , conf: {}, publish_time: {} }}" , self . conf, self . publish_time)
76+ }
77+ }
78+
79+ #[cfg(test)]
80+ #[test]
81+ fn test_debug_price_feed_updated () {
82+ let value = PriceFeedUpdated { price_id : 1 , price : 2 , conf : 3 , publish_time : 5 , };
83+ let expected = " PriceFeedUpdated { price_id: 1, price: 2, conf: 3, publish_time: 5 }" ;
84+ let actual = format! (" {:?}" , value );
85+ assert! (actual == expected );
6786 }
6887
69- #[derive(Drop , PartialEq , starknet:: Event )]
88+
89+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
7090 pub struct FeeSet {
7191 pub old_fee : u256 ,
7292 pub new_fee : u256 ,
7393 }
7494
75- #[derive(Drop , PartialEq , starknet:: Event )]
95+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
7696 pub struct DataSourcesSet {
7797 pub old_data_sources : Array <DataSource >,
7898 pub new_data_sources : Array <DataSource >,
7999 }
80100
81- #[derive(Drop , PartialEq , starknet:: Event )]
101+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
82102 pub struct WormholeAddressSet {
83103 pub old_address : ContractAddress ,
84104 pub new_address : ContractAddress ,
85105 }
86106
87- #[derive(Drop , PartialEq , starknet:: Event )]
107+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
88108 pub struct GovernanceDataSourceSet {
89109 pub old_data_source : DataSource ,
90110 pub new_data_source : DataSource ,
91111 pub last_executed_governance_sequence : u64 ,
92112 }
93113
94- #[derive(Drop , PartialEq , starknet:: Event )]
114+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
95115 pub struct ContractUpgraded {
96116 pub new_class_hash : ClassHash ,
97117 }
0 commit comments