diff --git a/.circleci/config.yml b/.circleci/config.yml index 1a4701e4bb..f9bace4514 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -79,6 +79,7 @@ workflows: - contract_crypto_verify - contract_cyberpunk - contract_empty + - contract_replier # - contract_floaty # This contract needs nightly Rust to compile - contract_hackatom - contract_ibc_callbacks @@ -597,6 +598,34 @@ jobs: - target/wasm32-unknown-unknown/release/deps key: cargocache-v2-contract_burner-rust:1.74-{{ checksum "Cargo.lock" }} + contract_replier: + docker: + - image: rust:1.74 + environment: + RUST_BACKTRACE: 1 + working_directory: ~/cosmwasm/contracts/replier + steps: + - checkout: + path: ~/cosmwasm + - run: + name: Version information + command: rustc --version; cargo --version; rustup --version + - restore_cache: + keys: + - cargocache-v2-contract_replier-rust:1.74-{{ checksum "Cargo.lock" }} + - check_contract: + min_version: "1.4" + - save_cache: + paths: + - /usr/local/cargo/registry + - target/debug/.fingerprint + - target/debug/build + - target/debug/deps + - target/wasm32-unknown-unknown/release/.fingerprint + - target/wasm32-unknown-unknown/release/build + - target/wasm32-unknown-unknown/release/deps + key: cargocache-v2-contract_replier-rust:1.74-{{ checksum "Cargo.lock" }} + contract_crypto_verify: docker: - image: rust:1.74 diff --git a/contracts/replier/Cargo.toml b/contracts/replier/Cargo.toml index c7934cbbcd..3759758dc4 100644 --- a/contracts/replier/Cargo.toml +++ b/contracts/replier/Cargo.toml @@ -25,8 +25,8 @@ overflow-checks = true [dependencies] cosmwasm-schema = { path = "../../packages/schema" } cosmwasm-std = { path = "../../packages/std", default-features = false, features = [ - "abort", - "cosmwasm_2_2", + "cosmwasm_1_4", + "iterator", "std", ] } schemars = "0.8.12" diff --git a/contracts/replier/src/lib.rs b/contracts/replier/src/lib.rs index 2282b674b8..e830860261 100644 --- a/contracts/replier/src/lib.rs +++ b/contracts/replier/src/lib.rs @@ -6,6 +6,10 @@ use cosmwasm_std::{ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +const SET_DATA_IN_EXEC_AND_REPLY_FLAG: u64 = 0x100; +const RETURN_OERDER_IN_REPLY_FLAG: u64 = 0x200; +const REPLY_ERROR_FLAG: u64 = 0x400; + #[cw_serde] pub struct InstantiateMsg {} @@ -78,13 +82,13 @@ pub fn execute( }; let mut msg_id: u64 = msg.msg_id.into(); if msg.set_data_in_exec_and_reply { - msg_id = msg_id | 0x100; + msg_id |= SET_DATA_IN_EXEC_AND_REPLY_FLAG; } if msg.return_order_in_reply { - msg_id = msg_id | 0x200; + msg_id |= RETURN_OERDER_IN_REPLY_FLAG; } if msg.reply_error { - msg_id = msg_id | 0x400; + msg_id |= REPLY_ERROR_FLAG; } let submsg = SubMsg { @@ -111,9 +115,9 @@ pub fn query(_deps: Deps, _env: Env, _msg: QueryMsg) -> StdResult #[entry_point] pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> StdResult { let msg_id = msg.id & 0xFF; - let should_set_data = msg.id & 0x100 != 0; - let should_set_order = msg.id & 0x200 != 0; - let should_return_error = msg.id & 0x400 != 0; + let should_set_data = msg.id & SET_DATA_IN_EXEC_AND_REPLY_FLAG != 0; + let should_set_order = msg.id & RETURN_OERDER_IN_REPLY_FLAG != 0; + let should_return_error = msg.id & REPLY_ERROR_FLAG != 0; let data = deps.storage.get(CONFIG_KEY).unwrap(); let mut config: State = from_json(data)?; @@ -140,9 +144,8 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> StdResult { result .msg_responses .into_iter() - .map(|resp| resp.value.as_slice().to_vec()) - .flatten() - .chain([0xBB, msg_id as u8].into_iter()) + .flat_map(|resp| resp.value.as_slice().to_vec()) + .chain([0xBB, msg_id as u8]) .collect(), ))) } else { diff --git a/contracts/replier/tests/integration.rs b/contracts/replier/tests/integration.rs new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/contracts/replier/tests/integration.rs @@ -0,0 +1 @@ +