Skip to content

Commit 022a858

Browse files
committed
chore: Add replier contract to CI and apply review comments
1 parent 618215c commit 022a858

File tree

4 files changed

+44
-11
lines changed

4 files changed

+44
-11
lines changed

.circleci/config.yml

+29
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ workflows:
7979
- contract_crypto_verify
8080
- contract_cyberpunk
8181
- contract_empty
82+
- contract_replier
8283
# - contract_floaty # This contract needs nightly Rust to compile
8384
- contract_hackatom
8485
- contract_ibc_callbacks
@@ -597,6 +598,34 @@ jobs:
597598
- target/wasm32-unknown-unknown/release/deps
598599
key: cargocache-v2-contract_burner-rust:1.74-{{ checksum "Cargo.lock" }}
599600

601+
contract_replier:
602+
docker:
603+
- image: rust:1.74
604+
environment:
605+
RUST_BACKTRACE: 1
606+
working_directory: ~/cosmwasm/contracts/replier
607+
steps:
608+
- checkout:
609+
path: ~/cosmwasm
610+
- run:
611+
name: Version information
612+
command: rustc --version; cargo --version; rustup --version
613+
- restore_cache:
614+
keys:
615+
- cargocache-v2-contract_replier-rust:1.74-{{ checksum "Cargo.lock" }}
616+
- check_contract:
617+
min_version: "1.4"
618+
- save_cache:
619+
paths:
620+
- /usr/local/cargo/registry
621+
- target/debug/.fingerprint
622+
- target/debug/build
623+
- target/debug/deps
624+
- target/wasm32-unknown-unknown/release/.fingerprint
625+
- target/wasm32-unknown-unknown/release/build
626+
- target/wasm32-unknown-unknown/release/deps
627+
key: cargocache-v2-contract_replier-rust:1.74-{{ checksum "Cargo.lock" }}
628+
600629
contract_crypto_verify:
601630
docker:
602631
- image: rust:1.74

contracts/replier/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ overflow-checks = true
2525
[dependencies]
2626
cosmwasm-schema = { path = "../../packages/schema" }
2727
cosmwasm-std = { path = "../../packages/std", default-features = false, features = [
28-
"abort",
29-
"cosmwasm_2_2",
28+
"cosmwasm_1_4",
29+
"iterator",
3030
"std",
3131
] }
3232
schemars = "0.8.12"

contracts/replier/src/lib.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ use cosmwasm_std::{
66
use schemars::JsonSchema;
77
use serde::{Deserialize, Serialize};
88

9+
const SET_DATA_IN_EXEC_AND_REPLY_FLAG: u64 = 0x100;
10+
const RETURN_OERDER_IN_REPLY_FLAG: u64 = 0x200;
11+
const REPLY_ERROR_FLAG: u64 = 0x400;
12+
913
#[cw_serde]
1014
pub struct InstantiateMsg {}
1115

@@ -78,13 +82,13 @@ pub fn execute(
7882
};
7983
let mut msg_id: u64 = msg.msg_id.into();
8084
if msg.set_data_in_exec_and_reply {
81-
msg_id = msg_id | 0x100;
85+
msg_id |= SET_DATA_IN_EXEC_AND_REPLY_FLAG;
8286
}
8387
if msg.return_order_in_reply {
84-
msg_id = msg_id | 0x200;
88+
msg_id |= RETURN_OERDER_IN_REPLY_FLAG;
8589
}
8690
if msg.reply_error {
87-
msg_id = msg_id | 0x400;
91+
msg_id |= REPLY_ERROR_FLAG;
8892
}
8993

9094
let submsg = SubMsg {
@@ -111,9 +115,9 @@ pub fn query(_deps: Deps, _env: Env, _msg: QueryMsg) -> StdResult<QueryResponse>
111115
#[entry_point]
112116
pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> StdResult<Response> {
113117
let msg_id = msg.id & 0xFF;
114-
let should_set_data = msg.id & 0x100 != 0;
115-
let should_set_order = msg.id & 0x200 != 0;
116-
let should_return_error = msg.id & 0x400 != 0;
118+
let should_set_data = msg.id & SET_DATA_IN_EXEC_AND_REPLY_FLAG != 0;
119+
let should_set_order = msg.id & RETURN_OERDER_IN_REPLY_FLAG != 0;
120+
let should_return_error = msg.id & REPLY_ERROR_FLAG != 0;
117121

118122
let data = deps.storage.get(CONFIG_KEY).unwrap();
119123
let mut config: State = from_json(data)?;
@@ -140,9 +144,8 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> StdResult<Response> {
140144
result
141145
.msg_responses
142146
.into_iter()
143-
.map(|resp| resp.value.as_slice().to_vec())
144-
.flatten()
145-
.chain([0xBB, msg_id as u8].into_iter())
147+
.flat_map(|resp| resp.value.as_slice().to_vec())
148+
.chain([0xBB, msg_id as u8])
146149
.collect(),
147150
)))
148151
} else {
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)