Skip to content

Commit 8d8901f

Browse files
authored
Merge pull request #1788 from CosmWasm/1154-delegation-queries
Implement more delegation queries
2 parents 1dc5552 + ea4a20b commit 8d8901f

20 files changed

+423
-20
lines changed

.circleci/config.yml

Lines changed: 5 additions & 5 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_3
359+
command: cargo build --locked --features abort,iterator,staking,stargate,cosmwasm_1_4
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_3
363+
command: cargo wasm --locked --features abort,iterator,staking,stargate,cosmwasm_1_4
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_3
367+
command: cargo test --locked --features abort,iterator,staking,stargate,cosmwasm_1_4
368368
- save_cache:
369369
paths:
370370
- /usr/local/cargo/registry
@@ -907,7 +907,7 @@ jobs:
907907
- run:
908908
name: Clippy linting on std (all feature flags)
909909
working_directory: ~/project/packages/std
910-
command: cargo clippy --all-targets --features abort,iterator,staking,stargate,cosmwasm_1_3 -- -D warnings
910+
command: cargo clippy --all-targets --features abort,iterator,staking,stargate,cosmwasm_1_4 -- -D warnings
911911
- run:
912912
name: Clippy linting on storage (no feature flags)
913913
working_directory: ~/project/packages/storage
@@ -984,7 +984,7 @@ jobs:
984984
CRYPTO=" cargo tarpaulin --skip-clean --out Xml --output-dir reports/crypto --packages cosmwasm-crypto"
985985
DERIVE=" cargo tarpaulin --skip-clean --out Xml --output-dir reports/derive --packages cosmwasm-derive"
986986
SCHEMA=" cargo tarpaulin --skip-clean --out Xml --output-dir reports/schema --packages cosmwasm-schema"
987-
STD=" cargo tarpaulin --skip-clean --out Xml --output-dir reports/std --packages cosmwasm-std --features abort,iterator,staking,stargate,cosmwasm_1_3"
987+
STD=" cargo tarpaulin --skip-clean --out Xml --output-dir reports/std --packages cosmwasm-std --features abort,iterator,staking,stargate,cosmwasm_1_4"
988988
STORAGE="cargo tarpaulin --skip-clean --out Xml --output-dir reports/storage --packages cosmwasm-storage"
989989
docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin:0.21.0 \
990990
sh -c "$CRYPTO && $DERIVE && $SCHEMA && $STD && $STORAGE"

.vscode/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"rust-analyzer.cargo.features": ["abort", "stargate", "staking", "cosmwasm_1_3"]
2+
"rust-analyzer.cargo.features": [
3+
"abort",
4+
"stargate",
5+
"staking",
6+
"cosmwasm_1_4"
7+
]
38
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ and this project adheres to
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- cosmwasm-std: Add
12+
`DistributionQuery::{DelegationRewards, DelegationTotalRewards, DelegatorValidators}`.
13+
This requires the `cosmwasm_1_4` feature to be enabled. ([#1788])
14+
15+
[#1788]: https://github.com/CosmWasm/cosmwasm/pull/1788
16+
917
## [1.4.0-beta.1] - 2023-08-29
1018

1119
### Added

docs/CAPABILITIES-BUILT-IN.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ might define others.
1919
`BankQuery::DenomMetadata` and `DistributionQuery::DelegatorWithdrawAddress`
2020
queries, as well as `DistributionMsg::FundCommunityPool`. Only chains running
2121
CosmWasm `1.3.0` or higher support this.
22+
- `cosmwasm_1_4` enables the `DistributionQuery::DelegationRewards`,
23+
`DistributionQuery::DelegationTotalRewards` and
24+
`DistributionQuery::DelegatorValidators` queries. Only chains running CosmWasm
25+
`1.4.0` or higher support this.

docs/USING_COSMWASM_STD.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The libarary comes with the following features:
4545
| cosmwasm_1_1 | | Features that require CosmWasm 1.1+ on the chain |
4646
| cosmwasm_1_2 | | Features that require CosmWasm 1.2+ on the chain |
4747
| cosmwasm_1_3 | | Features that require CosmWasm 1.3+ on the chain |
48+
| cosmwasm_1_4 | | Features that require CosmWasm 1.4+ on the chain |
4849

4950
## The cosmwasm-std dependency for contract developers
5051

packages/check/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use cosmwasm_vm::capabilities_from_csv;
1111
use cosmwasm_vm::internals::{check_wasm, compile, make_compiling_engine};
1212

1313
const DEFAULT_AVAILABLE_CAPABILITIES: &str =
14-
"iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3";
14+
"iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,cosmwasm_1_4";
1515

1616
pub fn main() {
1717
let matches = Command::new("Contract checking")

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.4.0-beta.1", features = ["cosmwasm_1_3", "staking", "stargate", "ibc3"] }
12+
cosmwasm-std = { path = "../std", version = "1.4.0-beta.1", features = ["cosmwasm_1_4", "staking", "stargate", "ibc3"] }
1313
cosmwasm-schema = { path = "../schema", version = "1.4.0-beta.1" }
1414
anyhow = "1"
1515
Inflector = "0.11.4"

packages/go-gen/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ mod tests {
352352
// compare_codes!(cosmwasm_std::ValidatorResponse); // does not use "omitempty" for `Validator` field
353353
// distribution
354354
compare_codes!(cosmwasm_std::DelegatorWithdrawAddressResponse);
355+
compare_codes!(cosmwasm_std::DelegationRewardsResponse);
356+
compare_codes!(cosmwasm_std::DelegationTotalRewardsResponse);
357+
compare_codes!(cosmwasm_std::DelegatorValidatorsResponse);
355358
// wasm
356359
compare_codes!(cosmwasm_std::ContractInfoResponse);
357360
// compare_codes!(cosmwasm_std::CodeInfoResponse); // TODO: Checksum type and "omitempty"

packages/go-gen/src/schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ pub fn custom_type_of(ty: &str) -> Option<&str> {
264264
"HexBinary" => Some("Checksum"),
265265
"Addr" => Some("string"),
266266
"Decimal" => Some("string"),
267+
"Decimal256" => Some("string"),
267268
_ => None,
268269
}
269270
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// See <https://github.com/cosmos/cosmos-sdk/blob/c74e2887b0b73e81d48c2f33e6b1020090089ee0/proto/cosmos/distribution/v1beta1/query.proto#L169-L178>
2+
type DelegationRewardsResponse struct {
3+
Rewards []DecCoin `json:"rewards"`
4+
}
5+
6+
// A coin type with decimal amount. Modeled after the Cosmos SDK's [DecCoin](https://github.com/cosmos/cosmos-sdk/blob/c74e2887b0b73e81d48c2f33e6b1020090089ee0/proto/cosmos/base/v1beta1/coin.proto#L32-L41) type
7+
type DecCoin struct {
8+
Amount string `json:"amount"`
9+
Denom string `json:"denom"`
10+
}

0 commit comments

Comments
 (0)