Skip to content

Commit

Permalink
Use ParsedVaa from wormhole contract
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos committed Jan 23, 2024
1 parent 4abbbd1 commit 3e62fdf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 57 deletions.
17 changes: 17 additions & 0 deletions target_chains/cosmwasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion target_chains/cosmwasm/contracts/pyth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["cdylib", "rlib"]
# IMPORTANT: if you want to build for injective or osmosis, enable injective default feature for injective
# and osmosis default feature for osmosis
# default=["injective"]
# default=["osmosis"]
default=["osmosis"]
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all init/handle/query exports
library = []
Expand Down Expand Up @@ -40,6 +40,7 @@ cosmwasm-schema = "1.1.9"
osmosis-std = "0.15.2"
pyth-sdk-cw = { path = "../../sdk/rust" }
pythnet-sdk = { path = "../../../../pythnet/pythnet_sdk" }
wormhole-cosmwasm = {git = "https://github.com/wormhole-foundation/wormhole"}

[dev-dependencies]
cosmwasm-vm = { version = "1.0.0", default-features = false }
Expand Down
18 changes: 9 additions & 9 deletions target_chains/cosmwasm/contracts/pyth/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ use {
ConfigInfo,
PythDataSource,
},
wormhole::{
ParsedVAA,
WormholeQueryMsg,
},
},
byteorder::BigEndian,
cosmwasm_std::{
Expand All @@ -60,6 +56,10 @@ use {
WasmMsg,
WasmQuery,
},
cw_wormhole::{
msg::QueryMsg as WormholeQueryMsg,
state::ParsedVAA,
},
pyth_sdk::{
Identifier,
UnixTimestamp,
Expand Down Expand Up @@ -1095,28 +1095,28 @@ mod test {
#[cfg(feature = "osmosis")]
fn check_sufficient_fee(deps: &Deps, data: &[Binary]) {
let mut info = mock_info("123", coins(100, "foo").as_slice());
let result = is_fee_sufficient(&deps, info.clone(), &data);
let result = is_fee_sufficient(deps, info.clone(), data);
assert_eq!(result, Ok(true));

// insufficient fee in base denom -> false
info.funds = coins(50, "foo");
let result = is_fee_sufficient(&deps, info.clone(), &data);
let result = is_fee_sufficient(deps, info.clone(), data);
assert_eq!(result, Ok(false));

// valid denoms are 'uion' or 'ibc/FF3065989E34457F342D4EFB8692406D49D4E2B5C70F725F127862E22CE6BDCD'
// a valid denom other than base denom with sufficient fee
info.funds = coins(100, "uion");
let result = is_fee_sufficient(&deps, info.clone(), &data);
let result = is_fee_sufficient(deps, info.clone(), data);
assert_eq!(result, Ok(true));

// insufficient fee in valid denom -> false
info.funds = coins(50, "uion");
let result = is_fee_sufficient(&deps, info.clone(), &data);
let result = is_fee_sufficient(deps, info.clone(), data);
assert_eq!(result, Ok(false));

// an invalid denom -> Err invalid fee denom
info.funds = coins(100, "invalid_denom");
let result = is_fee_sufficient(&deps, info, &data);
let result = is_fee_sufficient(deps, info, data);
assert_eq!(
result,
Err(PythContractError::InvalidFeeDenom {
Expand Down
1 change: 0 additions & 1 deletion target_chains/cosmwasm/contracts/pyth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub mod contract;
pub mod governance;
pub mod msg;
pub mod state;
pub mod wormhole;

#[cfg(feature = "injective")]
mod injective;
46 changes: 0 additions & 46 deletions target_chains/cosmwasm/contracts/pyth/src/wormhole.rs

This file was deleted.

0 comments on commit 3e62fdf

Please sign in to comment.