55 BorshDeserialize ,
66 BorshSerialize ,
77 } ,
8+ json_types:: {
9+ I64 ,
10+ U64 ,
11+ } ,
812 serde:: {
913 Deserialize ,
1014 Serialize ,
@@ -84,13 +88,13 @@ impl near_sdk::serde::Serialize for PriceIdentifier {
8488#[ derive( BorshDeserialize , BorshSerialize , Debug , Deserialize , Serialize , PartialEq , Eq ) ]
8589#[ serde( crate = "near_sdk::serde" ) ]
8690pub struct Price {
87- pub price : i64 ,
91+ pub price : I64 ,
8892 /// Confidence interval around the price
89- pub conf : u64 ,
93+ pub conf : U64 ,
9094 /// The exponent
9195 pub expo : i32 ,
9296 /// Unix timestamp of when this price was computed
93- pub timestamp : u64 ,
97+ pub timestamp : U64 ,
9498}
9599
96100/// The PriceFeed structure is stored in the contract under a Price Feed Identifier.
@@ -113,16 +117,20 @@ impl From<&PriceAttestation> for PriceFeed {
113117 Self {
114118 id : PriceIdentifier ( price_attestation. price_id . to_bytes ( ) ) ,
115119 price : Price {
116- price : price_attestation. price ,
117- conf : price_attestation. conf ,
120+ price : price_attestation. price . into ( ) ,
121+ conf : price_attestation. conf . into ( ) ,
118122 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 ( ) ,
120126 } ,
121127 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 ( ) ,
124130 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 ( ) ,
126134 } ,
127135 }
128136 }
@@ -133,16 +141,20 @@ impl From<&PriceFeedMessage> for PriceFeed {
133141 Self {
134142 id : PriceIdentifier ( price_feed_message. feed_id ) ,
135143 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 ( ) ,
138146 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 ( ) ,
140150 } ,
141151 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 ( ) ,
144154 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 ( ) ,
146158 } ,
147159 }
148160 }
0 commit comments