@@ -43,11 +43,12 @@ mod pyth {
43
43
use super :: governance;
44
44
use super :: governance :: GovernancePayload ;
45
45
use openzeppelin :: token :: erc20 :: interface :: {IERC20CamelDispatcherTrait , IERC20CamelDispatcher };
46
- use pyth :: util :: ResultMapErrInto ;
46
+ use pyth :: util :: { ResultMapErrInto , write_ i64 } ;
47
47
use core :: nullable :: {NullableTrait , match_nullable, FromNullableResult };
48
+ use core :: fmt :: {Debug , Formatter };
48
49
49
50
#[event]
50
- #[derive(Drop , PartialEq , starknet:: Event )]
51
+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
51
52
pub enum Event {
52
53
PriceFeedUpdated : PriceFeedUpdated ,
53
54
FeeSet : FeeSet ,
@@ -57,41 +58,60 @@ mod pyth {
57
58
ContractUpgraded : ContractUpgraded ,
58
59
}
59
60
60
- #[derive(Drop , PartialEq , starknet:: Event )]
61
+ #[derive(Drop , Clone , PartialEq , Serde , starknet:: Event )]
61
62
pub struct PriceFeedUpdated {
62
63
#[key]
63
64
pub price_id : u256 ,
64
- pub publish_time : u64 ,
65
65
pub price : i64 ,
66
66
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 );
67
86
}
68
87
69
- #[derive(Drop , PartialEq , starknet:: Event )]
88
+
89
+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
70
90
pub struct FeeSet {
71
91
pub old_fee : u256 ,
72
92
pub new_fee : u256 ,
73
93
}
74
94
75
- #[derive(Drop , PartialEq , starknet:: Event )]
95
+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
76
96
pub struct DataSourcesSet {
77
97
pub old_data_sources : Array <DataSource >,
78
98
pub new_data_sources : Array <DataSource >,
79
99
}
80
100
81
- #[derive(Drop , PartialEq , starknet:: Event )]
101
+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
82
102
pub struct WormholeAddressSet {
83
103
pub old_address : ContractAddress ,
84
104
pub new_address : ContractAddress ,
85
105
}
86
106
87
- #[derive(Drop , PartialEq , starknet:: Event )]
107
+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
88
108
pub struct GovernanceDataSourceSet {
89
109
pub old_data_source : DataSource ,
90
110
pub new_data_source : DataSource ,
91
111
pub last_executed_governance_sequence : u64 ,
92
112
}
93
113
94
- #[derive(Drop , PartialEq , starknet:: Event )]
114
+ #[derive(Drop , Clone , Debug , PartialEq , Serde , starknet:: Event )]
95
115
pub struct ContractUpgraded {
96
116
pub new_class_hash : ClassHash ,
97
117
}
0 commit comments