Git Product home page Git Product logo

Comments (2)

99Kies avatar 99Kies commented on July 17, 2024

I think cosmwasm need add more infomation about validator data.

https://github.com/cosmos/cosmos-sdk/blob/v0.47.4/proto/cosmos/staking/v1beta1/staking.proto#L96-L137

https://github.com/CosmWasm/cosmwasm/blob/main/packages/std/src/query/staking.rs#L171-L186

from cw-plus.

99Kies avatar 99Kies commented on July 17, 2024

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:

Error: rpc error: code = Unknown desc = rpc error: code = Unknown desc = failed to execute message; message index: 0: Error parsing into type cw_vesting::msg::AllValidatorsResponseBak: missing field `tokens`: execute wasm contract failed [!cosm!wasm/[email protected]/x/wasm/keeper/keeper.go:395] With gas wanted: '18446744073709551615' and gas used: '102538' : unknown request

from cw-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.