Skip to content

Commit 9d4a6b8

Browse files
authored
Ensure initialization data source emitter address and chain ids are the same length (#337)
1 parent 4455910 commit 9d4a6b8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

aptos/contracts/sources/error.move

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,8 @@ module pyth::error {
9898
public fun invalid_attestation_magic_value(): u64 {
9999
error::invalid_argument(24)
100100
}
101+
102+
public fun data_source_emitter_address_and_chain_ids_different_lengths(): u64 {
103+
error::invalid_argument(25)
104+
}
101105
}

aptos/contracts/sources/pyth.move

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ module pyth::pyth {
7474
fun parse_data_sources(
7575
emitter_chain_ids: vector<u64>,
7676
emitter_addresses: vector<vector<u8>>): vector<DataSource> {
77+
78+
assert!(vector::length(&emitter_chain_ids) == vector::length(&emitter_addresses),
79+
error::data_source_emitter_address_and_chain_ids_different_lengths());
80+
7781
let sources = vector::empty();
7882
let i = 0;
7983
while (i < vector::length(&emitter_chain_ids)) {

0 commit comments

Comments
 (0)