Skip to content

Commit a6f300e

Browse files
committed
verified vaa from valid source
1 parent 5c9453c commit a6f300e

File tree

1 file changed

+11
-0
lines changed
  • target_chains/stylus/contracts/pyth-receiver/src

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ impl PythReceiver {
165165

166166
// TODO: CHECK IF THE VAA IS FROM A VALID DATA SOURCE
167167

168+
let cur_emitter_address: &[u8; 32] = vaa.body.emitter_address.as_slice().try_into().expect("emitter address must be 32 bytes");
169+
170+
let cur_data_source = DataSource {
171+
chain_id: U16::from(vaa.body.emitter_chain),
172+
emitter_address: FixedBytes::from(cur_emitter_address),
173+
};
174+
175+
if !self.is_valid_data_source.get(cur_data_source) {
176+
return Err(PythReceiverError::InvalidWormholeMessage);
177+
}
178+
168179
let root_digest: MerkleRoot<Keccak160> = parse_wormhole_proof(vaa).unwrap();
169180

170181
for update in updates {

0 commit comments

Comments
 (0)