Skip to content

Commit 4ffac28

Browse files
committed
Add cosmwasm_2_0 capability and feature
1 parent 4c673f4 commit 4ffac28

File tree

9 files changed

+34
-10
lines changed

9 files changed

+34
-10
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ jobs:
356356
- run:
357357
name: Build library for native target (all features)
358358
working_directory: ~/project/packages/std
359-
command: cargo build --locked --features abort,iterator,staking,stargate,cosmwasm_1_4
359+
command: cargo build --locked --features abort,iterator,staking,stargate,cosmwasm_2_0
360360
- run:
361361
name: Build library for wasm target (all features)
362362
working_directory: ~/project/packages/std
363-
command: cargo wasm --locked --features abort,iterator,staking,stargate,cosmwasm_1_4
363+
command: cargo wasm --locked --features abort,iterator,staking,stargate,cosmwasm_2_0
364364
- run:
365365
name: Run unit tests (all features)
366366
working_directory: ~/project/packages/std
367-
command: cargo test --locked --features abort,iterator,staking,stargate,cosmwasm_1_4
367+
command: cargo test --locked --features abort,iterator,staking,stargate,cosmwasm_2_0
368368
- save_cache:
369369
paths:
370370
- /usr/local/cargo/registry
@@ -903,7 +903,7 @@ jobs:
903903
- run:
904904
name: Clippy linting on std (all feature flags)
905905
working_directory: ~/project/packages/std
906-
command: cargo clippy --all-targets --features abort,iterator,staking,stargate,cosmwasm_1_4 -- -D warnings
906+
command: cargo clippy --all-targets --features abort,iterator,staking,stargate,cosmwasm_2_0 -- -D warnings
907907
- run:
908908
name: Clippy linting on vm (no feature flags)
909909
working_directory: ~/project/packages/vm

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"abort",
44
"stargate",
55
"staking",
6-
"cosmwasm_1_4"
6+
"cosmwasm_2_0"
77
]
88
}

MIGRATING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ major releases of `cosmwasm`. Note that you can also view the
3535
+cosmwasm-std = { version = "2.0.0", default-features = false, features = ["std", ...] }
3636
```
3737

38+
- If you want to use a feature that is only available on CosmWasm 2.0+ chains,
39+
use this feature:
40+
41+
```diff
42+
-cosmwasm-std = { version = "1.4.0", features = ["stargate"] }
43+
+cosmwasm-std = { version = "1.4.0", features = ["stargate", "cosmwasm_2_0"] }
44+
```
45+
46+
Please note that `cosmwasm_2_0` implies `cosmwasm_1_4`, `cosmwasm_1_3` and so
47+
on, so there is no need to set multiple.
48+
3849
- `ContractInfoResponse::new` now takes all fields of the response as
3950
parameters:
4051

docs/CAPABILITIES-BUILT-IN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ might define others.
2323
`DistributionQuery::DelegationTotalRewards` and
2424
`DistributionQuery::DelegatorValidators` queries. Only chains running CosmWasm
2525
`1.4.0` or higher support this.
26+
- `cosmwasm_2_0` enables `CosmosMsg::Any`. Only chains running CosmWasm `2.0.0`
27+
or higher support this.

packages/go-gen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ publish = false
99

1010
[dependencies]
1111
schemars = "0.8.3"
12-
cosmwasm-std = { path = "../std", version = "1.5.0", features = ["cosmwasm_1_4", "staking", "stargate"] }
12+
cosmwasm-std = { path = "../std", version = "1.5.0", features = ["cosmwasm_2_0", "staking", "stargate"] }
1313
cosmwasm-schema = { path = "../schema", version = "1.5.0" }
1414
anyhow = "1"
1515
Inflector = "0.11.4"

packages/std/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "Apache-2.0"
99
readme = "README.md"
1010

1111
[package.metadata.docs.rs]
12-
features = ["abort", "stargate", "staking", "cosmwasm_1_4"]
12+
features = ["abort", "stargate", "staking", "cosmwasm_2_0"]
1313

1414
[features]
1515
default = ["iterator", "abort", "std"]
@@ -46,6 +46,9 @@ cosmwasm_1_3 = ["cosmwasm_1_2"]
4646
# available for the contract to call.
4747
# It requires the host blockchain to run CosmWasm `1.4.0` or higher.
4848
cosmwasm_1_4 = ["cosmwasm_1_3"]
49+
# This enables functionality that is only available on 2.0 chains.
50+
# It adds `CosmosMsg::Any`, replacing `CosmosMsg::Stargate`.
51+
cosmwasm_2_0 = ["cosmwasm_1_4"]
4952

5053
[dependencies]
5154
base64 = "0.21.0"

packages/std/src/exports.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ extern "C" fn requires_cosmwasm_1_3() -> () {}
5757
#[no_mangle]
5858
extern "C" fn requires_cosmwasm_1_4() -> () {}
5959

60+
#[cfg(feature = "cosmwasm_2_0")]
61+
#[no_mangle]
62+
extern "C" fn requires_cosmwasm_2_0() -> () {}
63+
6064
/// interface_version_* exports mark which Wasm VM interface level this contract is compiled for.
6165
/// They can be checked by cosmwasm_vm.
6266
/// Update this whenever the Wasm VM interface breaks.

packages/std/src/results/cosmos_msg.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub enum CosmosMsg<T = Empty> {
3434
Staking(StakingMsg),
3535
#[cfg(feature = "staking")]
3636
Distribution(DistributionMsg),
37+
#[cfg(feature = "cosmwasm_2_0")]
3738
Any(AnyMsg),
3839
#[cfg(feature = "stargate")]
3940
Ibc(IbcMsg),
@@ -385,6 +386,7 @@ impl<T> From<DistributionMsg> for CosmosMsg<T> {
385386

386387
// By implementing `From<MyType> for cosmwasm_std::AnyMsg`,
387388
// you automatically get a MyType -> CosmosMsg conversion.
389+
#[cfg(feature = "cosmwasm_2_0")]
388390
impl<S: Into<AnyMsg>, T> From<S> for CosmosMsg<T> {
389391
fn from(source: S) -> Self {
390392
CosmosMsg::<T>::Any(source.into())
@@ -414,7 +416,7 @@ impl<T> From<GovMsg> for CosmosMsg<T> {
414416
#[cfg(test)]
415417
mod tests {
416418
use super::*;
417-
use crate::{coin, coins, to_json_string};
419+
use crate::{coin, coins};
418420

419421
#[test]
420422
fn from_bank_msg_works() {
@@ -429,6 +431,7 @@ mod tests {
429431
}
430432

431433
#[test]
434+
#[cfg(feature = "cosmwasm_2_0")]
432435
fn from_any_msg_works() {
433436
// should work with AnyMsg
434437
let any = AnyMsg {
@@ -519,13 +522,14 @@ mod tests {
519522
}
520523

521524
#[test]
525+
#[cfg(feature = "cosmwasm_2_0")]
522526
fn any_msg_serializes_to_correct_json() {
523527
// Same serialization as CosmosMsg::Stargate (see above), except the top level key
524528
let msg: CosmosMsg = CosmosMsg::Any(AnyMsg {
525529
type_url: "/cosmos.foo.v1beta.MsgBar".to_string(),
526530
value: Binary::from_base64("5yu/rQ+HrMcxH1zdga7P5hpGMLE=").unwrap(),
527531
});
528-
let json = to_json_string(&msg).unwrap();
532+
let json = crate::to_json_string(&msg).unwrap();
529533
assert_eq!(
530534
json,
531535
r#"{"any":{"type_url":"/cosmos.foo.v1beta.MsgBar","value":"5yu/rQ+HrMcxH1zdga7P5hpGMLE="}}"#,

packages/vm/src/testing/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl MockInstanceOptions<'_> {
9797
fn default_capabilities() -> HashSet<String> {
9898
#[allow(unused_mut)]
9999
let mut out = capabilities_from_csv(
100-
"iterator,staking,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,cosmwasm_1_4",
100+
"iterator,staking,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,cosmwasm_1_4,cosmwasm_2_0",
101101
);
102102
#[cfg(feature = "stargate")]
103103
out.insert("stargate".to_string());

0 commit comments

Comments
 (0)