Skip to content

Commit 9fe481a

Browse files
feat: add price_id field to PriceFeedStorage and rename from PriceInfoStorage
- Add price_id field as StorageFixedBytes<32> to PriceInfoStorage struct - Rename PriceInfoStorage to PriceFeedStorage for consistency - Update import statement and storage map declaration in lib.rs - Update update_price_feeds_internal to populate price_id field when storing price data - All tests pass with structural changes Co-Authored-By: [email protected] <[email protected]>
1 parent 7f154ba commit 9fe481a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

target_chains/stylus/contracts/pyth-receiver/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use pythnet_sdk::{
3939
},
4040
},
4141
};
42-
use structs::{DataSource, DataSourceStorage, PriceFeedReturn, PriceInfoStorage};
42+
use structs::{DataSource, DataSourceStorage, PriceFeedReturn, PriceFeedStorage};
4343
use wormhole_vaas::{Readable, Vaa, Writeable};
4444

4545
sol_interface! {
@@ -63,7 +63,7 @@ pub struct PythReceiver {
6363
pub governance_data_source_emitter_address: StorageFixedBytes<32>,
6464
pub last_executed_governance_sequence: StorageUint<64, 1>,
6565
pub governance_data_source_index: StorageUint<32, 1>,
66-
pub latest_price_info: StorageMap<FixedBytes<32>, PriceInfoStorage>,
66+
pub latest_price_info: StorageMap<FixedBytes<32>, PriceFeedStorage>,
6767
pub transaction_fee_in_wei: StorageU256,
6868
}
6969

@@ -243,6 +243,7 @@ impl PythReceiver {
243243
if recent_price_info.publish_time.get() < price_return.1
244244
|| recent_price_info.price.get() == I64::ZERO
245245
{
246+
recent_price_info.price_id.set(FixedBytes::from(price_return.0));
246247
recent_price_info.publish_time.set(price_return.1);
247248
recent_price_info.expo.set(price_return.2);
248249
recent_price_info.price.set(price_return.3);

target_chains/stylus/contracts/pyth-receiver/src/structs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ impl StorageKey for DataSource {
3636
}
3737
}
3838
#[storage]
39-
pub struct PriceInfoStorage {
39+
pub struct PriceFeedStorage {
40+
pub price_id: StorageFixedBytes<32>,
4041
pub publish_time: StorageU64,
4142
pub expo: StorageI32,
4243
pub price: StorageI64,

0 commit comments

Comments
 (0)