Skip to content

Commit e27ef1d

Browse files
committed
Add exports feature to enable exports
1 parent 7f63657 commit e27ef1d

File tree

9 files changed

+34
-20
lines changed

9 files changed

+34
-20
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ and this project adheres to
7878
- cosmwasm-std: Remove export of `ExternalApi`, `ExternalQuerier` and
7979
`ExternalStorage` as those are only needed by export implementations in
8080
cosmwasm-std. ([#2467])
81+
- cosmwasm-std: Add a new `exports` feature which needs to be enabled for the
82+
primary cosmwasm_std dependency of a contract.
8183

8284
## Fixed
8385

contracts/cyberpunk/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ overflow-checks = true
2424
cosmwasm-schema = { path = "../../packages/schema" }
2525
cosmwasm-std = { path = "../../packages/std", default-features = false, features = [
2626
"cosmwasm_1_3",
27+
"exports",
2728
"std",
2829
] }
2930
rust-argon2 = "2.1"

contracts/hackatom/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ overflow-checks = true
2626
cosmwasm-schema = { path = "../../packages/schema" }
2727
cosmwasm-std = { path = "../../packages/std", default-features = false, features = [
2828
"cosmwasm_2_2",
29+
"exports",
2930
"std",
3031
] }
3132
schemars = "0.8.12"

contracts/reflect/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ overflow-checks = true
2727
cosmwasm-schema = { path = "../../packages/schema" }
2828
cosmwasm-std = { path = "../../packages/std", default-features = false, features = [
2929
"cosmwasm_2_2",
30+
"exports",
3031
"staking",
3132
"stargate",
3233
"std",

contracts/replier/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ overflow-checks = true
2626
cosmwasm-schema = { path = "../../packages/schema" }
2727
cosmwasm-std = { path = "../../packages/std", default-features = false, features = [
2828
"cosmwasm_1_4",
29+
"exports",
2930
"iterator",
3031
"std",
3132
] }

contracts/staking/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ overflow-checks = true
2525
[dependencies]
2626
cosmwasm-schema = { path = "../../packages/schema" }
2727
cosmwasm-std = { path = "../../packages/std", default-features = false, features = [
28+
"exports",
2829
"staking",
2930
"std",
3031
] }

docs/USING_COSMWASM_STD.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ in the dependency tree. Otherwise conflicting C exports are created.
3333

3434
The library comes with the following features:
3535

36-
| Feature | Enabled by default | Description |
37-
| ------------ | ------------------ | ------------------------------------------------------------------------------------ |
38-
| iterator | x | Storage iterators |
39-
| abort | x | DEPRECATED A panic handler that aborts the contract execution with a helpful message |
40-
| stargate | | Cosmos SDK 0.40+ features and IBC |
41-
| staking | | Access to the staking module |
42-
| cosmwasm_1_1 | | Features that require CosmWasm 1.1+ on the chain |
43-
| cosmwasm_1_2 | | Features that require CosmWasm 1.2+ on the chain |
44-
| cosmwasm_1_3 | | Features that require CosmWasm 1.3+ on the chain |
45-
| cosmwasm_1_4 | | Features that require CosmWasm 1.4+ on the chain |
36+
| Feature | Enabled by default | Description |
37+
| ------------ | ------------------ | -------------------------------------------------------------------------------- |
38+
| exports | x | Adds exports and imports needed for basic communication between contract and VM. |
39+
| iterator | x | Storage iterators |
40+
| stargate | | Cosmos SDK 0.40+ features and IBC |
41+
| staking | | Access to the staking module |
42+
| cosmwasm_1_1 | | Features that require CosmWasm 1.1+ on the chain |
43+
| cosmwasm_1_2 | | Features that require CosmWasm 1.2+ on the chain |
44+
| cosmwasm_1_3 | | Features that require CosmWasm 1.3+ on the chain |
45+
| cosmwasm_1_4 | | Features that require CosmWasm 1.4+ on the chain |
4646

4747
## The cosmwasm-std dependency for contract developers
4848

@@ -78,13 +78,13 @@ might move certain existing functionality to that feature in the future.
7878

7979
Also libraries should define a loose version range that allows the contract
8080
developer to control which cosmwasm-std version they want to use in the final
81-
project. E.g. if your library does not work with 1.0.0 due to a bug fixed in
82-
1.0.1, your min version is 1.0.1 and not the latest stable.
81+
project. E.g. if your library does not work with 3.0.0 due to a bug fixed in
82+
3.0.1, your min version is 3.0.1 and not the latest stable.
8383

8484
A typical dependency then looks like this:
8585

8686
```toml
87-
# We really need `stargate` here as this is an IBC related library. `abort` and `iterator` are not needed.
87+
# We really need `stargate` here as this is an IBC related library. `exports` and `iterator` are not needed.
8888
# `std` should always stay enabled.
89-
cosmwasm-std = { version = "1.0.1", default-features = false, features = ["std", "stargate"] }
89+
cosmwasm-std = { version = "3.0.1", default-features = false, features = ["std", "stargate"] }
9090
```

packages/std/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ readme = "README.md"
1212
features = ["cosmwasm_2_2", "staking", "stargate", "ibc2"]
1313

1414
[features]
15-
default = ["iterator", "std"]
15+
default = ["exports", "iterator", "std"]
16+
# Enable if this cosmwasm-std is the primary version of cosmwas-std used in the contract. This
17+
# adds exports and imports needed for basic communication between contract and VM.
18+
exports = []
1619
std = []
1720
# iterator allows us to iterate over all DB items in a given range
1821
# optional as some merkle stores (like tries) don't support this

packages/std/src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,23 @@ pub use crate::timestamp::Timestamp;
114114
pub use crate::traits::{Api, HashFunction, Querier, QuerierResult, QuerierWrapper, Storage};
115115
pub use crate::types::{BlockInfo, ContractInfo, Env, MessageInfo, MigrateInfo, TransactionInfo};
116116

117-
#[cfg(target_arch = "wasm32")]
117+
//
118+
// Exports
119+
//
120+
121+
#[cfg(all(feature = "exports", target_arch = "wasm32"))]
118122
mod exports;
119123

120-
#[cfg(all(feature = "cosmwasm_2_2", target_arch = "wasm32"))]
124+
#[cfg(all(feature = "exports", target_arch = "wasm32", feature = "cosmwasm_2_2"))]
121125
pub use crate::exports::do_migrate_with_info;
122-
#[cfg(target_arch = "wasm32")]
126+
#[cfg(all(feature = "exports", target_arch = "wasm32"))]
123127
pub use crate::exports::{
124128
do_execute, do_ibc_destination_callback, do_ibc_source_callback, do_instantiate, do_migrate,
125129
do_query, do_reply, do_sudo,
126130
};
127-
#[cfg(all(feature = "ibc2", target_arch = "wasm32"))]
131+
#[cfg(all(feature = "exports", target_arch = "wasm32", feature = "ibc2"))]
128132
pub use crate::exports::{do_ibc2_packet_receive, do_ibc2_packet_timeout};
129-
#[cfg(all(feature = "stargate", target_arch = "wasm32"))]
133+
#[cfg(all(feature = "exports", target_arch = "wasm32", feature = "stargate"))]
130134
pub use crate::exports::{
131135
do_ibc_channel_close, do_ibc_channel_connect, do_ibc_channel_open, do_ibc_packet_ack,
132136
do_ibc_packet_receive, do_ibc_packet_timeout,

0 commit comments

Comments
 (0)