Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,29 @@ jobs:
name: Add wasm32 target
command: rustup target add wasm32-unknown-unknown && rustup target list --installed
- run:
name: Build library for native target
name: Build library for native target (no features)
working_directory: ~/project/packages/std
command: cargo build --locked
command: cargo build --locked --no-default-features
- run:
name: Build library for wasm target
name: Build library for wasm target (no features)
working_directory: ~/project/packages/std
command: cargo wasm --locked
command: cargo wasm --locked --no-default-features
- run:
name: Run unit tests
name: Run unit tests (no features)
working_directory: ~/project/packages/std
command: cargo test --locked
command: cargo test --locked --no-default-features
- run:
name: Build library for native target (with iterator support)
name: Build library for native target (all features)
working_directory: ~/project/packages/std
command: cargo build --locked --features iterator
command: cargo build --locked --all-features
- run:
name: Build library for wasm target (with iterator support)
name: Build library for wasm target (all features)
working_directory: ~/project/packages/std
command: cargo wasm --locked --features iterator
command: cargo wasm --locked --all-features
- run:
name: Run unit tests (with iterator support)
name: Run unit tests (all features)
working_directory: ~/project/packages/std
command: cargo test --locked --features iterator
command: cargo test --locked --all-features
- run:
name: Build and run schema generator
working_directory: ~/project/packages/std
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@
- `ExternalStorage.get` now returns an empty vector if a storage entry exists
but has an empty value. Before, this was normalized to `None`.
- Reorganize `CosmosMsg` enum types. They are now split by modules:
`CosmosMsg::Bank(BankMsg)`, `CosmosMsg::Custom(T)`,
`CosmosMsg::Wasm(WasmMsg)`
`CosmosMsg::Bank(BankMsg)`, `CosmosMsg::Custom(T)`, `CosmosMsg::Wasm(WasmMsg)`
- CosmosMsg is now generic over the content of `Custom` variant. This allows
blockchains to support custom native calls in their Cosmos-SDK apps and
developers to make use of them in CosmWasm apps without forking the
`cosmwasm-vm` and `go-cosmwasm` runtime.
- Add `staking` feature flag to expose new `StakingMsg` types under `CosmosMsg`
and new `StakingRequest` types under `QueryRequest`.

**cosmwasm-vm**

Expand Down
117 changes: 117 additions & 0 deletions contracts/reflect/schema/handle_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@
}
}
},
{
"type": "object",
"required": [
"staking"
],
"properties": {
"staking": {
"$ref": "#/definitions/StakingMsg"
}
}
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -165,6 +176,112 @@
"HumanAddr": {
"type": "string"
},
"StakingMsg": {
"anyOf": [
{
"type": "object",
"required": [
"delegate"
],
"properties": {
"delegate": {
"type": "object",
"required": [
"amount",
"validator"
],
"properties": {
"amount": {
"$ref": "#/definitions/Coin"
},
"validator": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"undelegate"
],
"properties": {
"undelegate": {
"type": "object",
"required": [
"amount",
"validator"
],
"properties": {
"amount": {
"$ref": "#/definitions/Coin"
},
"validator": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"withdraw"
],
"properties": {
"withdraw": {
"type": "object",
"required": [
"validator"
],
"properties": {
"recipient": {
"anyOf": [
{
"$ref": "#/definitions/HumanAddr"
},
{
"type": "null"
}
]
},
"validator": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"redelegate"
],
"properties": {
"redelegate": {
"type": "object",
"required": [
"amount",
"dst_validator",
"src_validator"
],
"properties": {
"amount": {
"$ref": "#/definitions/Coin"
},
"dst_validator": {
"$ref": "#/definitions/HumanAddr"
},
"src_validator": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
}
]
},
"Uint128": {
"type": "string"
},
Expand Down
117 changes: 117 additions & 0 deletions contracts/reflect/schema/handle_response_for__custom_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@
}
}
},
{
"type": "object",
"required": [
"staking"
],
"properties": {
"staking": {
"$ref": "#/definitions/StakingMsg"
}
}
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -166,6 +177,112 @@
}
}
},
"StakingMsg": {
"anyOf": [
{
"type": "object",
"required": [
"delegate"
],
"properties": {
"delegate": {
"type": "object",
"required": [
"amount",
"validator"
],
"properties": {
"amount": {
"$ref": "#/definitions/Coin"
},
"validator": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"undelegate"
],
"properties": {
"undelegate": {
"type": "object",
"required": [
"amount",
"validator"
],
"properties": {
"amount": {
"$ref": "#/definitions/Coin"
},
"validator": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"withdraw"
],
"properties": {
"withdraw": {
"type": "object",
"required": [
"validator"
],
"properties": {
"recipient": {
"anyOf": [
{
"$ref": "#/definitions/HumanAddr"
},
{
"type": "null"
}
]
},
"validator": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"redelegate"
],
"properties": {
"redelegate": {
"type": "object",
"required": [
"amount",
"dst_validator",
"src_validator"
],
"properties": {
"amount": {
"$ref": "#/definitions/Coin"
},
"dst_validator": {
"$ref": "#/definitions/HumanAddr"
},
"src_validator": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
}
]
},
"Uint128": {
"type": "string"
},
Expand Down
7 changes: 6 additions & 1 deletion contracts/reflect/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn query_owner<S: Storage, A: Api, Q: Querier>(deps: &Extern<S, A, Q>) -> StdRes
mod tests {
use super::*;
use cosmwasm_std::testing::{mock_dependencies, mock_env};
use cosmwasm_std::{coins, from_binary, BankMsg, Binary, StdError};
use cosmwasm_std::{coin, coins, from_binary, BankMsg, Binary, StakingMsg, StdError};

#[test]
fn proper_initialization() {
Expand Down Expand Up @@ -203,6 +203,11 @@ mod tests {
// make sure we can pass through custom native messages
CustomMsg::Raw(Binary(b"{\"foo\":123}".to_vec())).into(),
CustomMsg::Debug("Hi, Dad!".to_string()).into(),
StakingMsg::Delegate {
validator: HumanAddr::from("validator"),
amount: coin(100, "stake"),
}
.into(),
];

let msg = HandleMsg::ReflectMsg {
Expand Down
9 changes: 7 additions & 2 deletions contracts/reflect/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cosmwasm_std::testing::mock_env;
use cosmwasm_std::{
coins, from_binary, Api, ApiError, BankMsg, Binary, HandleResponse, HandleResult, HumanAddr,
InitResponse,
coin, coins, from_binary, Api, ApiError, BankMsg, Binary, HandleResponse, HandleResult,
HumanAddr, InitResponse, StakingMsg,
};

use cosmwasm_vm::testing::{handle, init, mock_instance, query};
Expand Down Expand Up @@ -86,6 +86,11 @@ fn reflect() {
// make sure we can pass through custom native messages
CustomMsg::Raw(Binary(b"{\"foo\":123}".to_vec())).into(),
CustomMsg::Debug("Hi, Dad!".to_string()).into(),
StakingMsg::Delegate {
validator: HumanAddr::from("validator"),
amount: coin(100, "stake"),
}
.into(),
];
let msg = HandleMsg::ReflectMsg {
msgs: payload.clone(),
Expand Down
5 changes: 5 additions & 0 deletions packages/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ circle-ci = { repository = "CosmWasm/cosmwasm", branch = "master" }
maintenance = { status = "actively-developed" }

[features]
default = ["staking"]
# iterator allows us to iterate over all DB items in a given range
# optional as some merkle stores (like tries) don't support this
# given Ethereum 1.0, 2.0, Substrate, and other major projects use Tries
# we keep this optional, to allow possible future integration (or different Cosmos Backends)
iterator = []
# staking exposes bindings to a required staking moudle in the runtime, via new
# CosmosMsg types, and new QueryRequest types. This should only be enabled on contracts
# that require these types, so other contracts can be used on systems with eg. PoA consensus
staking = []
# backtraces provides much better context at runtime errors (in non-wasm code)
# at the cost of a bit of code size and performance.
backtraces = ["snafu/backtraces"]
Expand Down
Loading