소스 검색

p2w-sdk/rust: Remove utils.rs and the helper type

commit-id:e72c6345
Stan Drozd 3 년 전
부모
커밋
58b17c79f5
2개의 변경된 파일2개의 추가작업 그리고 46개의 파일을 삭제
  1. 2 6
      third_party/pyth/p2w-sdk/rust/src/lib.rs
  2. 0 40
      third_party/pyth/p2w-sdk/rust/src/utils.rs

+ 2 - 6
third_party/pyth/p2w-sdk/rust/src/lib.rs

@@ -7,6 +7,7 @@
 //! the probable adversarial scenarios.
 
 use serde::{
+    Deserialize,
     Serialize,
     Serializer,
 };
@@ -36,10 +37,6 @@ pub mod wasm;
 #[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
 use wasm_bindgen::prelude::*;
 
-pub mod utils;
-
-use utils::P2WPriceStatus;
-
 pub type ErrBox = Box<dyn std::error::Error>;
 
 /// Precedes every message implementing the p2w serialization format
@@ -79,7 +76,7 @@ pub enum PayloadId {
 ///
 /// NOTE(2022-04-25): the serde attributes help prevent math errors,
 /// and no less annoying low-effort serialization override method is known.
-#[derive(Clone, Default, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
+#[derive(Clone, Default, Debug, Eq, PartialEq, Serialize, Deserialize)]
 #[serde(rename_all = "camelCase")]
 pub struct PriceAttestation {
     pub product_id:         Pubkey,
@@ -93,7 +90,6 @@ pub struct PriceAttestation {
     pub ema_price:          i64,
     #[serde(serialize_with = "use_to_string")]
     pub ema_conf:           u64,
-    #[serde(with = "P2WPriceStatus")]
     pub status:             PriceStatus,
     pub num_publishers:     u32,
     pub max_num_publishers: u32,

+ 0 - 40
third_party/pyth/p2w-sdk/rust/src/utils.rs

@@ -1,40 +0,0 @@
-//! Utility types and functions
-use pyth_sdk_solana::state::PriceStatus;
-
-/// Helps add wasm serialization functionality to upstream PriceStatus
-#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq,)]
-#[repr(u8)]
-#[serde(remote = "PriceStatus")]
-pub enum P2WPriceStatus {
-    Unknown,
-    Trading,
-    Halted,
-    Auction
-}
-impl From<PriceStatus> for P2WPriceStatus {
-    fn from(ps: PriceStatus) -> Self {
-        match ps {
-            PriceStatus::Unknown => Self::Unknown,
-            PriceStatus::Trading => Self::Trading,
-            PriceStatus::Halted => Self::Halted,
-            PriceStatus::Auction => Self::Auction,
-        }
-    }
-}
-
-impl Into<PriceStatus> for P2WPriceStatus {
-    fn into(self) -> PriceStatus {
-        match self {
-            Self::Unknown => PriceStatus::Unknown,
-            Self::Trading => PriceStatus::Trading,
-            Self::Halted => PriceStatus::Halted,
-            Self::Auction => PriceStatus::Auction,
-        }
-    }
-}
-
-impl Default for P2WPriceStatus {
-    fn default() -> Self {
-        PriceStatus::default().into()
-    }
-}