Skip to content

Commit 3e104b4

Browse files
author
Dev Kalra
authored
[cosmwasm] address audit (#685)
* remove todos * add governance source index check * bumb pyth-sdk-cw version
1 parent b6fcb03 commit 3e104b4

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

target_chains/cosmwasm/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

target_chains/cosmwasm/contracts/pyth/src/contract.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ fn transfer_governance(
334334
RequestGovernanceDataSourceTransfer {
335335
governance_data_source_index,
336336
} => {
337-
if current_config.governance_source_index >= governance_data_source_index {
338-
Err(PythContractError::OldGovernanceMessage)?
337+
if current_config.governance_source_index != governance_data_source_index - 1 {
338+
Err(PythContractError::InvalidGovernanceSourceIndex)?
339339
}
340340

341341
next_config.governance_source_index = governance_data_source_index;
@@ -657,8 +657,7 @@ mod test {
657657

658658
fn create_price_update_msg(emitter_address: &[u8], emitter_chain: u16) -> Binary {
659659
let batch_attestation = BatchPriceAttestation {
660-
// TODO: pass these in
661-
price_attestations: vec![],
660+
price_attestations: vec![PriceAttestation::default()],
662661
};
663662

664663
let mut vaa = create_zero_vaa();
@@ -1292,7 +1291,7 @@ mod test {
12921291
module: Target,
12931292
target_chain_id: test_config.chain_id,
12941293
action: RequestGovernanceDataSourceTransfer {
1295-
governance_data_source_index: 11,
1294+
governance_data_source_index: 1,
12961295
},
12971296
}
12981297
.serialize()
@@ -1306,7 +1305,7 @@ mod test {
13061305
let test_vaa = governance_vaa(&test_instruction);
13071306
let (_response, result_config) = apply_governance_vaa(&test_config, &test_vaa).unwrap();
13081307
assert_eq!(result_config.governance_source, source_2);
1309-
assert_eq!(result_config.governance_source_index, 11);
1308+
assert_eq!(result_config.governance_source_index, 1);
13101309
assert_eq!(result_config.governance_sequence_number, 12);
13111310
}
13121311

@@ -1345,7 +1344,7 @@ mod test {
13451344
let test_vaa = governance_vaa(&test_instruction);
13461345
assert_eq!(
13471346
apply_governance_vaa(&test_config, &test_vaa),
1348-
Err(PythContractError::OldGovernanceMessage.into())
1347+
Err(PythContractError::InvalidGovernanceSourceIndex.into())
13491348
);
13501349
}
13511350

target_chains/cosmwasm/pyth-sdk-cw/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-sdk-cw"
3-
version = "1.0.0"
3+
version = "1.1.0"
44
authors = ["Pyth Data Foundation"]
55
edition = "2018"
66
license = "Apache-2.0"

target_chains/cosmwasm/pyth-sdk-cw/src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ pub enum PythContractError {
4141
#[error("OldGovernanceMessage")]
4242
OldGovernanceMessage,
4343

44+
/// The governance source index it not valid.
45+
#[error("OldGovernanceMessage")]
46+
InvalidGovernanceSourceIndex,
47+
4448
/// The message did not include a sufficient fee.
4549
#[error("InsufficientFee")]
4650
InsufficientFee,

0 commit comments

Comments
 (0)