-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to query validator data in cosmwasm
contract.
#890
Comments
I think cosmwasm need add more infomation about validator data. https://github.com/CosmWasm/cosmwasm/blob/main/packages/std/src/query/staking.rs#L171-L186 |
In order to query more information about the data (tokens, delegate_shares), I modified validatorsResponse, but this doesn't get me the data I need, why is that? code: // msg.rs
/// Instances are created in the querier.
#[cw_serde]
pub struct Validator {
/// The operator address of the validator (e.g. cosmosvaloper1...).
/// See https://github.com/cosmos/cosmos-sdk/blob/v0.47.4/proto/cosmos/staking/v1beta1/staking.proto#L95-L96
/// for more information.
///
/// This uses `String` instead of `Addr` since the bech32 address prefix is different from
/// the ones that regular user accounts use.
pub address: String,
pub commission: Decimal,
pub max_commission: Decimal,
/// The maximum daily increase of the commission
pub max_change_rate: Decimal,
pub tokens: String,
pub delegator_shares: String,
}
/// The data format returned from StakingRequest::AllValidators query
#[cw_serde]
pub struct AllValidatorsResponseBak {
pub validators: Vec<Validator>,
}
// contracts.rs
pub fn execute_test(
deps: DepsMut,
_env: Env,
_info: MessageInfo,
// beneficiaries: Vec<BeneficiaryBody>,
) -> Result<Response, ContractError> {
let vals = deps.querier.query_all_validators()?;
let request = StakingQuery::AllValidators {}.into();
let data: AllValidatorsResponseBak = deps.querier.query(&request)?;
let res_data = data.validators;
Ok(Response::new()
.add_attribute("action", "add_whitelists")
.add_attribute("vals", format!("{:?}", vals))
.add_attribute("vals", format!("{:?}", res_data)))
} log:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to query validator data in cosmwasm contract, what should I do? (like: delegation,stake,voting_power...data(validator-set))
The text was updated successfully, but these errors were encountered: