Skip to content

Commit 6a5f675

Browse files
committed
Replace pyth_sdk_solana::AccKey with solana_program::pubkey::Pubkey
1 parent 248b2f7 commit 6a5f675

File tree

1 file changed

+7
-37
lines changed

1 file changed

+7
-37
lines changed

pyth-sdk-solana/src/state.rs

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -115,27 +115,6 @@ impl Default for PriceType {
115115
}
116116
}
117117

118-
/// Public key of a Solana account
119-
#[derive(
120-
Copy,
121-
Clone,
122-
Debug,
123-
Default,
124-
PartialEq,
125-
Eq,
126-
Hash,
127-
Ord,
128-
PartialOrd,
129-
BorshSerialize,
130-
BorshDeserialize,
131-
serde::Serialize,
132-
serde::Deserialize,
133-
)]
134-
#[repr(C)]
135-
pub struct AccKey {
136-
pub val: [u8; 32],
137-
}
138-
139118
/// Mapping accounts form a linked-list containing the listing of all products on Pyth.
140119
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
141120
#[repr(C)]
@@ -152,8 +131,8 @@ pub struct MappingAccount {
152131
pub num: u32,
153132
pub unused: u32,
154133
/// next mapping account (if any)
155-
pub next: AccKey,
156-
pub products: [AccKey; MAP_TABLE_SIZE],
134+
pub next: Pubkey,
135+
pub products: [Pubkey; MAP_TABLE_SIZE],
157136
}
158137

159138
#[cfg(target_endian = "little")]
@@ -179,7 +158,7 @@ pub struct ProductAccount {
179158
/// price account size
180159
pub size: u32,
181160
/// first price account in list
182-
pub px_acc: AccKey,
161+
pub px_acc: Pubkey,
183162
/// key/value pairs of reference attr.
184163
pub attr: [u8; PROD_ATTR_SIZE],
185164
}
@@ -247,7 +226,7 @@ pub struct PriceInfo {
247226
#[repr(C)]
248227
pub struct PriceComp {
249228
/// key of contributing publisher
250-
pub publisher: AccKey,
229+
pub publisher: Pubkey,
251230
/// the price used to compute the current aggregate price
252231
pub agg: PriceInfo,
253232
/// The publisher's latest price. This price will be incorporated into the aggregate price
@@ -317,9 +296,9 @@ pub struct PriceAccount {
317296
/// space for future derived values
318297
pub drv4: u32,
319298
/// product account key
320-
pub prod: AccKey,
299+
pub prod: Pubkey,
321300
/// next Price account in linked list
322-
pub next: AccKey,
301+
pub next: Pubkey,
323302
/// valid slot of previous update
324303
pub prev_slot: u64,
325304
/// aggregate price of previous update with TRADING status
@@ -367,7 +346,7 @@ impl PriceAccount {
367346
self.expo,
368347
self.num,
369348
self.num_qt,
370-
ProductIdentifier::new(self.prod.val),
349+
ProductIdentifier::new(self.prod.to_bytes()),
371350
self.agg.price,
372351
self.agg.conf,
373352
self.ema_price.val,
@@ -392,15 +371,6 @@ unsafe impl Zeroable for AccKeyU64 {
392371
unsafe impl Pod for AccKeyU64 {
393372
}
394373

395-
impl AccKey {
396-
pub fn is_valid(&self) -> bool {
397-
match load::<AccKeyU64>(&self.val) {
398-
Ok(k8) => k8.val[0] != 0 || k8.val[1] != 0 || k8.val[2] != 0 || k8.val[3] != 0,
399-
Err(_) => false,
400-
}
401-
}
402-
}
403-
404374
fn load<T: Pod>(data: &[u8]) -> Result<&T, PodCastError> {
405375
let size = size_of::<T>();
406376
if data.len() >= size {

0 commit comments

Comments
 (0)