5
5
BorshDeserialize ,
6
6
BorshSerialize ,
7
7
} ,
8
+ json_types:: {
9
+ I64 ,
10
+ U64 ,
11
+ } ,
8
12
serde:: {
9
13
Deserialize ,
10
14
Serialize ,
@@ -84,13 +88,13 @@ impl near_sdk::serde::Serialize for PriceIdentifier {
84
88
#[ derive( BorshDeserialize , BorshSerialize , Debug , Deserialize , Serialize , PartialEq , Eq ) ]
85
89
#[ serde( crate = "near_sdk::serde" ) ]
86
90
pub struct Price {
87
- pub price : i64 ,
91
+ pub price : I64 ,
88
92
/// Confidence interval around the price
89
- pub conf : u64 ,
93
+ pub conf : U64 ,
90
94
/// The exponent
91
95
pub expo : i32 ,
92
96
/// Unix timestamp of when this price was computed
93
- pub timestamp : u64 ,
97
+ pub timestamp : U64 ,
94
98
}
95
99
96
100
/// The PriceFeed structure is stored in the contract under a Price Feed Identifier.
@@ -113,16 +117,20 @@ impl From<&PriceAttestation> for PriceFeed {
113
117
Self {
114
118
id : PriceIdentifier ( price_attestation. price_id . to_bytes ( ) ) ,
115
119
price : Price {
116
- price : price_attestation. price ,
117
- conf : price_attestation. conf ,
120
+ price : price_attestation. price . into ( ) ,
121
+ conf : price_attestation. conf . into ( ) ,
118
122
expo : price_attestation. expo ,
119
- timestamp : price_attestation. publish_time . try_into ( ) . unwrap ( ) ,
123
+ timestamp : TryInto :: < u64 > :: try_into ( price_attestation. publish_time )
124
+ . unwrap ( )
125
+ . into ( ) ,
120
126
} ,
121
127
ema_price : Price {
122
- price : price_attestation. ema_price ,
123
- conf : price_attestation. ema_conf ,
128
+ price : price_attestation. ema_price . into ( ) ,
129
+ conf : price_attestation. ema_conf . into ( ) ,
124
130
expo : price_attestation. expo ,
125
- timestamp : price_attestation. publish_time . try_into ( ) . unwrap ( ) ,
131
+ timestamp : TryInto :: < u64 > :: try_into ( price_attestation. publish_time )
132
+ . unwrap ( )
133
+ . into ( ) ,
126
134
} ,
127
135
}
128
136
}
@@ -133,16 +141,20 @@ impl From<&PriceFeedMessage> for PriceFeed {
133
141
Self {
134
142
id : PriceIdentifier ( price_feed_message. feed_id ) ,
135
143
price : Price {
136
- price : price_feed_message. price ,
137
- conf : price_feed_message. conf ,
144
+ price : price_feed_message. price . into ( ) ,
145
+ conf : price_feed_message. conf . into ( ) ,
138
146
expo : price_feed_message. exponent ,
139
- timestamp : price_feed_message. publish_time . try_into ( ) . unwrap ( ) ,
147
+ timestamp : TryInto :: < u64 > :: try_into ( price_feed_message. publish_time )
148
+ . unwrap ( )
149
+ . into ( ) ,
140
150
} ,
141
151
ema_price : Price {
142
- price : price_feed_message. ema_price ,
143
- conf : price_feed_message. ema_conf ,
152
+ price : price_feed_message. ema_price . into ( ) ,
153
+ conf : price_feed_message. ema_conf . into ( ) ,
144
154
expo : price_feed_message. exponent ,
145
- timestamp : price_feed_message. publish_time . try_into ( ) . unwrap ( ) ,
155
+ timestamp : TryInto :: < u64 > :: try_into ( price_feed_message. publish_time )
156
+ . unwrap ( )
157
+ . into ( ) ,
146
158
} ,
147
159
}
148
160
}
0 commit comments