diff --git a/target_chains/cosmwasm/Cargo.lock b/target_chains/cosmwasm/Cargo.lock index 975f236742..716fc00067 100644 --- a/target_chains/cosmwasm/Cargo.lock +++ b/target_chains/cosmwasm/Cargo.lock @@ -1486,6 +1486,7 @@ dependencies = [ "sha3 0.9.1", "terraswap", "thiserror", + "wormhole-cosmwasm", ] [[package]] @@ -2644,13 +2645,24 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "wormhole-cosmwasm" +version = "0.1.0" +source = "git+https://github.com/wormhole-foundation/wormhole?tag=v2.23.37#846c2e9c9dce18a48745e79ba2ee7eaa5acaf1f4" +dependencies = [ + "cosmwasm-std", + "cosmwasm-storage", + "generic-array", + "hex", + "k256", + "schemars", + "serde", + "sha3 0.9.1", + "thiserror", +] + [[package]] name = "zeroize" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" - -[[patch.unused]] -name = "cw20-wrapped-2" -version = "0.1.0" -source = "git+https://github.com/wormhole-foundation/wormhole?tag=v2.14.8#7e982cb03264cf1cccfbb5d947c00d6ad3e2f8f1" diff --git a/target_chains/cosmwasm/Cargo.toml b/target_chains/cosmwasm/Cargo.toml index c2b1345f50..969a48011f 100644 --- a/target_chains/cosmwasm/Cargo.toml +++ b/target_chains/cosmwasm/Cargo.toml @@ -2,6 +2,8 @@ members = ["contracts/pyth", "sdk/rust"] exclude = ["examples/cw-contract"] +resolver = "2" + [profile.release] opt-level = 3 debug = false @@ -12,6 +14,3 @@ codegen-units = 1 panic = 'abort' incremental = false overflow-checks = true - -[patch.crates-io] -cw20-wrapped-2 = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.14.8"} diff --git a/target_chains/cosmwasm/contracts/pyth/Cargo.toml b/target_chains/cosmwasm/contracts/pyth/Cargo.toml index 7d716d5e4e..0ea3b0418e 100644 --- a/target_chains/cosmwasm/contracts/pyth/Cargo.toml +++ b/target_chains/cosmwasm/contracts/pyth/Cargo.toml @@ -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", tag="v2.23.37"} [dev-dependencies] cosmwasm-vm = { version = "1.0.0", default-features = false } diff --git a/target_chains/cosmwasm/contracts/pyth/src/contract.rs b/target_chains/cosmwasm/contracts/pyth/src/contract.rs index 218ac4b47a..055afa004d 100644 --- a/target_chains/cosmwasm/contracts/pyth/src/contract.rs +++ b/target_chains/cosmwasm/contracts/pyth/src/contract.rs @@ -34,10 +34,6 @@ use { ConfigInfo, PythDataSource, }, - wormhole::{ - ParsedVAA, - WormholeQueryMsg, - }, }, byteorder::BigEndian, cosmwasm_std::{ @@ -60,6 +56,10 @@ use { WasmMsg, WasmQuery, }, + cw_wormhole::{ + msg::QueryMsg as WormholeQueryMsg, + state::ParsedVAA, + }, pyth_sdk::{ Identifier, UnixTimestamp, @@ -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 { diff --git a/target_chains/cosmwasm/contracts/pyth/src/lib.rs b/target_chains/cosmwasm/contracts/pyth/src/lib.rs index 98c98d3937..9d485196b4 100644 --- a/target_chains/cosmwasm/contracts/pyth/src/lib.rs +++ b/target_chains/cosmwasm/contracts/pyth/src/lib.rs @@ -5,7 +5,6 @@ pub mod contract; pub mod governance; pub mod msg; pub mod state; -pub mod wormhole; #[cfg(feature = "injective")] mod injective; diff --git a/target_chains/cosmwasm/contracts/pyth/src/wormhole.rs b/target_chains/cosmwasm/contracts/pyth/src/wormhole.rs deleted file mode 100644 index 41fcfac377..0000000000 --- a/target_chains/cosmwasm/contracts/pyth/src/wormhole.rs +++ /dev/null @@ -1,46 +0,0 @@ -// These types are copied from the Wormhole contract. See the links with each type to see the original code -// The reason to do so was dependency conflict. Wormhole contracts were using a very old version of a dependency -// which is not compatible with the one used by osmosis-sdk. And since we weren't using anything else from -// the Wormhole contract the types are moved here. - -use { - cosmwasm_std::Binary, - schemars::JsonSchema, - serde::{ - Deserialize, - Serialize, - }, -}; - -type HumanAddr = String; - -// This type is copied from -// https://github.com/wormhole-foundation/wormhole/blob/main/cosmwasm/contracts/wormhole/src/state.rs#L75 -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct ParsedVAA { - pub version: u8, - pub guardian_set_index: u32, - pub timestamp: u32, - pub nonce: u32, - pub len_signers: u8, - - pub emitter_chain: u16, - pub emitter_address: Vec, - pub sequence: u64, - pub consistency_level: u8, - pub payload: Vec, - - pub hash: Vec, -} - - -// The type is copied from -// https://github.com/wormhole-foundation/wormhole/blob/main/cosmwasm/contracts/wormhole/src/msg.rs#L37 -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum WormholeQueryMsg { - GuardianSetInfo {}, - VerifyVAA { vaa: Binary, block_time: u64 }, - GetState {}, - QueryAddressHex { address: HumanAddr }, -}