66 } ,
77 pyth_wormhole_attester_sdk:: PriceAttestation ,
88 pythnet_sdk:: messages:: PriceFeedMessage ,
9+ schemars:: { gen:: SchemaGenerator , schema:: Schema , JsonSchema } ,
910 wormhole_sdk:: Chain as WormholeChain ,
1011} ;
1112
@@ -68,6 +69,20 @@ impl near_sdk::serde::Serialize for PriceIdentifier {
6869 }
6970}
7071
72+ impl JsonSchema for PriceIdentifier {
73+ fn is_referenceable ( ) -> bool {
74+ false
75+ }
76+
77+ fn schema_name ( ) -> String {
78+ String :: schema_name ( )
79+ }
80+
81+ fn json_schema ( gen : & mut SchemaGenerator ) -> Schema {
82+ String :: json_schema ( gen)
83+ }
84+ }
85+
7186/// A price with a degree of uncertainty, represented as a price +- a confidence interval.
7287///
7388/// The confidence interval roughly corresponds to the standard error of a normal distribution.
@@ -79,6 +94,10 @@ impl near_sdk::serde::Serialize for PriceIdentifier {
7994#[ derive( BorshDeserialize , BorshSerialize , Debug , Deserialize , Serialize , PartialEq , Eq ) ]
8095#[ borsh( crate = "near_sdk::borsh" ) ]
8196#[ serde( crate = "near_sdk::serde" ) ]
97+ // I64 and U64 only implement JsonSchema when "abi" feature is enabled in near_sdk,
98+ // but unconditionally enabling this feature doesn't work, so we have to make this impl
99+ // conditional.
100+ #[ cfg_attr( abi, derive( JsonSchema ) ) ]
82101pub struct Price {
83102 pub price : I64 ,
84103 /// Confidence interval around the price
@@ -161,6 +180,7 @@ impl From<&PriceFeedMessage> for PriceFeed {
161180 PartialEq ,
162181 PartialOrd ,
163182 Serialize ,
183+ JsonSchema ,
164184) ]
165185#[ borsh( crate = "near_sdk::borsh" ) ]
166186#[ serde( crate = "near_sdk::serde" ) ]
@@ -197,6 +217,7 @@ impl From<Chain> for u16 {
197217 PartialEq ,
198218 PartialOrd ,
199219 Serialize ,
220+ JsonSchema ,
200221) ]
201222#[ borsh( crate = "near_sdk::borsh" ) ]
202223#[ serde( crate = "near_sdk::serde" ) ]
0 commit comments