Skip to content

Commit 25faa8c

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

File tree

10 files changed

+34
-27
lines changed

10 files changed

+34
-27
lines changed

.circleci/config.yml

Lines changed: 11 additions & 3 deletions
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

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ and this project adheres to
1414
`CanonicalAddr` ([#1463]).
1515
- cosmwasm-std: Implement `PartialEq` between `CanonicalAddr` and
1616
`HexBinary`/`Binary` ([#1463]).
17+
- cosmwasm-std: Add `std` feature to support `no_std` if this feature
18+
is not enabled.
19+
- cosmwasm-std: Add `std` feature to default features.
1720

1821
[#1463]: https://github.com/CosmWasm/cosmwasm/pull/1463
22+
[#1483]: https://github.com/CosmWasm/cosmwasm/pull/1483
1923

2024
### Changed
2125

Cargo.toml

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ pub use crate::types::{BlockInfo, ContractInfo, Env, MessageInfo, TransactionInf
9393
mod exports;
9494
#[cfg(all(target_arch = "wasm32", feature = "std"))]
9595
mod imports;
96+
#[cfg(all(target_arch = "wasm32", feature = "std"))]
9697
mod memory; // Used by exports and imports only. This assumes pointers are 32 bit long, which makes it untestable on dev machines.
9798

9899
#[cfg(all(target_arch = "wasm32", feature = "std"))]
@@ -105,11 +106,9 @@ pub use crate::exports::{
105106
#[cfg(all(target_arch = "wasm32", feature = "std"))]
106107
pub use crate::imports::{ExternalApi, ExternalQuerier, ExternalStorage};
107108

108-
pub use memory::Region;
109-
110109
// Exposed for testing only
111110
// Both unit tests and integration tests are compiled to native code, so everything in here does not need to compile to Wasm.
112-
#[cfg(not(target_arch = "wasm32"))]
111+
#[cfg(all(not(target_arch = "wasm32"), feature = "std"))]
113112
pub mod testing;
114113

115114
// Re-exports

packages/std/src/memory.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unused)]
2-
31
use alloc::boxed::Box;
42
use alloc::vec::Vec;
53
use core::mem;

packages/std/src/results/cosmos_msg.rs

Lines changed: 10 additions & 9 deletions
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

Lines changed: 2 additions & 6 deletions
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
}

packages/storage/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ iterator = ["cosmwasm-std/iterator"]
1616

1717
[dependencies]
1818
# Uses the path when built locally; uses the given version from crates.io when published
19-
cosmwasm-std = { path = "../std", version = "1.1.5", default-features = false }
19+
cosmwasm-std = { path = "../std", version = "1.1.5", default-features = false, features = ["std"] }
2020
serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] }

packages/vm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ required-features = ["iterator"]
4141
[dependencies]
4242
clru = "0.4.0"
4343
# Uses the path when built locally; uses the given version from crates.io when published
44-
cosmwasm-std = { path = "../std", version = "1.1.5", default-features = false }
44+
cosmwasm-std = { path = "../std", version = "1.1.5", default-features = false, features = ["std"] }
4545
cosmwasm-crypto = { path = "../crypto", version = "1.1.5" }
4646
hex = "0.4"
4747
parity-wasm = "0.42"

0 commit comments

Comments
 (0)