Skip to content

Commit b87282b

Browse files
committed
Fix CI and dependency resolver
Signed-off-by: aeryz <[email protected]>
1 parent 96c7944 commit b87282b

File tree

5 files changed

+26
-20
lines changed

5 files changed

+26
-20
lines changed

.circleci/config.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,25 @@ jobs:
260260
name: Add wasm32 target
261261
command: rustup target add wasm32-unknown-unknown && rustup target list --installed
262262
- run:
263-
name: Build library for native target (no features)
263+
name: Build library for native target (no_std)
264264
working_directory: ~/project/packages/std
265265
command: cargo build --locked --no-default-features
266266
- run:
267-
name: Build library for wasm target (no features)
267+
name: Build library for native target (only "std" feature)
268268
working_directory: ~/project/packages/std
269-
command: cargo wasm --locked --no-default-features
269+
command: cargo build --locked --no-default-features --features std
270+
- run:
271+
name: Build library for wasm target (only "std" feature)
272+
working_directory: ~/project/packages/std
273+
command: cargo wasm --locked --no-default-features --features std
270274
- run:
271275
name: Run unit tests (only "std" feature)
272276
working_directory: ~/project/packages/std
273277
command: cargo test --locked --no-default-features --features std
278+
- run:
279+
name: Build library for native target (all features "no_std")
280+
working_directory: ~/project/packages/std
281+
command: cargo build --locked --no-default-features --features abort,iterator,staking,stargate,std,cosmwasm_1_1
274282
- run:
275283
name: Build library for native target (all features)
276284
working_directory: ~/project/packages/std

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[workspace]
22
members = ["packages/*"]
33
exclude = ["contracts"]
4+
resolver = "2"

packages/std/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ ibc3 = ["stargate"]
3737
# the host blockchain to run CosmWasm `1.1.0` or higher.
3838
cosmwasm_1_1 = []
3939
# enable std support
40-
std = ["forward_ref", "schemars", "serde-json-wasm", "thiserror", "cosmwasm-crypto", "derivative"]
40+
std = ["forward_ref", "schemars", "serde-json-wasm", "thiserror", "cosmwasm-crypto"]
4141

4242
[dependencies]
4343
base64 = { version = "0.13.0", default-features = false, features = ["alloc"] }
4444
cosmwasm-derive = { path = "../derive", version = "1.1.5" }
45-
derivative = { version = "2", features = ["use_core"], optional = true }
45+
derivative = { version = "2", features = ["use_core"] }
4646
forward_ref = { version = "1", optional = true }
4747
hex = { version = "0.4", default-features = false, features = ["alloc"] }
4848
schemars = { version = "0.8.3", optional = true }

packages/std/src/results/cosmos_msg.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use alloc::fmt;
22
use alloc::string::String;
33
use alloc::vec::Vec;
4+
use derivative::Derivative;
45
use serde::{Deserialize, Serialize};
56

67
use crate::binary::Binary;
@@ -120,8 +121,10 @@ pub enum DistributionMsg {
120121
},
121122
}
122123

123-
#[cfg(feature = "std")]
124-
fn binary_to_string(data: &Binary, fmt: &mut alloc::fmt::Formatter) -> Result<(), std::fmt::Error> {
124+
fn binary_to_string(
125+
data: &Binary,
126+
fmt: &mut alloc::fmt::Formatter,
127+
) -> Result<(), core::fmt::Error> {
125128
match core::str::from_utf8(data.as_slice()) {
126129
Ok(s) => fmt.write_str(s),
127130
Err(_) => write!(fmt, "{:?}", data),
@@ -133,10 +136,8 @@ fn binary_to_string(data: &Binary, fmt: &mut alloc::fmt::Formatter) -> Result<()
133136
/// See https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto
134137
#[non_exhaustive]
135138
#[cfg_attr(feature = "std", derive(schemars::JsonSchema))]
136-
#[cfg_attr(feature = "std", derive(derivative::Derivative))]
137-
#[cfg_attr(not(feature = "std"), derive(Debug))]
138-
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)]
139-
#[cfg_attr(feature = "std", derivative(Debug))]
139+
#[derive(Serialize, Deserialize, Clone, Derivative, PartialEq, Eq)]
140+
#[derivative(Debug)]
140141
#[serde(rename_all = "snake_case")]
141142
pub enum WasmMsg {
142143
/// Dispatches a call to another contract at a known address (with known ABI).
@@ -146,7 +147,7 @@ pub enum WasmMsg {
146147
Execute {
147148
contract_addr: String,
148149
/// msg is the json-encoded ExecuteMsg struct (as raw Binary)
149-
#[cfg_attr(feature = "std", derivative(Debug(format_with = "binary_to_string")))]
150+
#[derivative(Debug(format_with = "binary_to_string"))]
150151
msg: Binary,
151152
funds: Vec<Coin>,
152153
},
@@ -158,7 +159,7 @@ pub enum WasmMsg {
158159
admin: Option<String>,
159160
code_id: u64,
160161
/// msg is the JSON-encoded InstantiateMsg struct (as raw Binary)
161-
#[cfg_attr(feature = "std", derivative(Debug(format_with = "binary_to_string")))]
162+
#[derivative(Debug(format_with = "binary_to_string"))]
162163
msg: Binary,
163164
funds: Vec<Coin>,
164165
/// A human-readbale label for the contract
@@ -176,7 +177,7 @@ pub enum WasmMsg {
176177
/// the code_id of the new logic to place in the given contract
177178
new_code_id: u64,
178179
/// msg is the json-encoded MigrateMsg struct that will be passed to the new code
179-
#[cfg_attr(feature = "std", derivative(Debug(format_with = "binary_to_string")))]
180+
#[derivative(Debug(format_with = "binary_to_string"))]
180181
msg: Binary,
181182
},
182183
/// Sets a new admin (for migrate) on the given contract.

packages/std/src/testing/mock.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,8 @@ impl Api for MockApi {
218218
)?)
219219
}
220220

221-
fn debug(&self, _message: &str) {
222-
#[cfg(feature = "std")]
223-
println!("{}", _message);
221+
fn debug(&self, message: &str) {
222+
println!("{}", message);
224223
}
225224
}
226225

@@ -1555,10 +1554,7 @@ mod tests {
15551554
});
15561555
match result {
15571556
SystemResult::Ok(ContractResult::Err(err)) => {
1558-
#[cfg(feature = "std")]
15591557
assert_eq!(err, "Error parsing into type cosmwasm_std::testing::mock::tests::wasm_querier_works::{{closure}}::MyMsg: Invalid type");
1560-
#[cfg(not(feature = "std"))]
1561-
assert_eq!(err, "ParseErr { target_type: \"cosmwasm_std::testing::mock::tests::wasm_querier_works::{{closure}}::MyMsg\", msg: \"Invalid type\" }");
15621558
}
15631559
res => panic!("Unexpected result: {:?}", res),
15641560
}

0 commit comments

Comments
 (0)