Skip to content

Commit

Permalink
Merge branch 'main' of github.com:neutron-org/neutron-dev-contracts i…
Browse files Browse the repository at this point in the history
…nto feat/improve-balances-query
  • Loading branch information
ratik committed Feb 25, 2024
2 parents abbba7f + a0ed4d8 commit 65bc3e9
Show file tree
Hide file tree
Showing 11 changed files with 2,646 additions and 34 deletions.
44 changes: 22 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ neutron-sdk = { git = "https://github.com/neutron-org/neutron-sdk", branch = "fe
prost = "0.12.1"
prost-types = "0.12.1"
cosmos-sdk-proto = { version = "0.20.0", default-features = false }
cosmwasm-std = "1.4.1"
cosmwasm-std = { version = "1.4.1", features = [
"stargate",
"staking",
"cosmwasm_1_1",
"cosmwasm_1_2"
] }
cw2 = "1.1.1"
cw-storage-plus = "1.1.0"
schemars = "0.8.15"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ compile:

check_contracts:
@cargo install cosmwasm-check
@cosmwasm-check --available-capabilities iterator,staking,stargate,neutron artifacts/*.wasm
@cosmwasm-check --available-capabilities iterator,staking,stargate,neutron,cosmwasm_1_1,cosmwasm_1_2 artifacts/*.wasm

build: schema clippy test fmt compile check_contracts
70 changes: 70 additions & 0 deletions contracts/neutron_interchain_queries/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,76 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"register_delegator_unbonding_delegations_query"
],
"properties": {
"register_delegator_unbonding_delegations_query": {
"type": "object",
"required": [
"connection_id",
"delegator",
"update_period",
"validators"
],
"properties": {
"connection_id": {
"type": "string"
},
"delegator": {
"type": "string"
},
"update_period": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"validators": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"register_validators_signing_info_query"
],
"properties": {
"register_validators_signing_info_query": {
"type": "object",
"required": [
"connection_id",
"update_period",
"validators"
],
"properties": {
"connection_id": {
"type": "string"
},
"update_period": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"validators": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down
44 changes: 44 additions & 0 deletions contracts/neutron_interchain_queries/schema/query_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,28 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"validators_signing_infos"
],
"properties": {
"validators_signing_infos": {
"type": "object",
"required": [
"query_id"
],
"properties": {
"query_id": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -134,6 +156,28 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"get_unbonding_delegations"
],
"properties": {
"get_unbonding_delegations": {
"type": "object",
"required": [
"query_id"
],
"properties": {
"query_id": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down
62 changes: 57 additions & 5 deletions contracts/neutron_interchain_queries/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ use neutron_sdk::interchain_queries::types::{
};
use neutron_sdk::interchain_queries::v045::queries::{
query_balance, query_bank_total, query_delegations, query_distribution_fee_pool,
query_government_proposals, query_staking_validators,
query_government_proposals, query_staking_validators, query_unbonding_delegations,
query_validators_signing_infos,
};
use neutron_sdk::interchain_queries::v045::register_queries::new_register_validators_signing_infos_query_msg;
use neutron_sdk::interchain_queries::v045::types::{COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD};
use neutron_sdk::interchain_queries::v045::{
new_register_balances_query_msg, new_register_bank_total_supply_query_msg,
new_register_delegator_delegations_query_msg, new_register_distribution_fee_pool_query_msg,
new_register_gov_proposal_query_msg, new_register_staking_validators_query_msg,
new_register_transfers_query_msg,
new_register_balance_query_msg, new_register_balances_query_msg,
new_register_bank_total_supply_query_msg, new_register_delegator_delegations_query_msg,
new_register_delegator_unbonding_delegations_query_msg,
new_register_distribution_fee_pool_query_msg, new_register_gov_proposal_query_msg,
new_register_staking_validators_query_msg, new_register_transfers_query_msg,
};
use neutron_sdk::sudo::msg::SudoMsg;
use neutron_sdk::{NeutronError, NeutronResult};
Expand Down Expand Up @@ -108,6 +111,22 @@ pub fn execute(
validators,
update_period,
} => register_delegations_query(connection_id, delegator, validators, update_period),
ExecuteMsg::RegisterDelegatorUnbondingDelegationsQuery {
connection_id,
delegator,
validators,
update_period,
} => register_unbonding_delegations_query(
connection_id,
delegator,
validators,
update_period,
),
ExecuteMsg::RegisterValidatorsSigningInfoQuery {
connection_id,
validators,
update_period,
} => register_validators_signing_infos_query(connection_id, validators, update_period),
ExecuteMsg::RegisterTransfersQuery {
connection_id,
recipient,
Expand Down Expand Up @@ -201,6 +220,33 @@ pub fn register_delegations_query(
Ok(Response::new().add_message(msg))
}

pub fn register_unbonding_delegations_query(
connection_id: String,
delegator: String,
validators: Vec<String>,
update_period: u64,
) -> NeutronResult<Response<NeutronMsg>> {
let msg = new_register_delegator_unbonding_delegations_query_msg(
connection_id,
delegator,
validators,
update_period,
)?;

Ok(Response::new().add_message(msg))
}

pub fn register_validators_signing_infos_query(
connection_id: String,
validators: Vec<String>,
update_period: u64,
) -> NeutronResult<Response<NeutronMsg>> {
let msg =
new_register_validators_signing_infos_query_msg(connection_id, validators, update_period)?;

Ok(Response::new().add_message(msg))
}

pub fn register_transfers_query(
connection_id: String,
recipient: String,
Expand Down Expand Up @@ -289,12 +335,18 @@ pub fn query(deps: Deps<NeutronQuery>, env: Env, msg: QueryMsg) -> NeutronResult
QueryMsg::StakingValidators { query_id } => Ok(to_json_binary(&query_staking_validators(
deps, env, query_id,
)?)?),
QueryMsg::ValidatorsSigningInfos { query_id } => Ok(to_json_binary(
&query_validators_signing_infos(deps, env, query_id)?,
)?),
QueryMsg::GovernmentProposals { query_id } => Ok(to_json_binary(
&query_government_proposals(deps, env, query_id)?,
)?),
QueryMsg::GetDelegations { query_id } => {
Ok(to_json_binary(&query_delegations(deps, env, query_id)?)?)
}
QueryMsg::GetUnbondingDelegations { query_id } => Ok(to_json_binary(
&query_unbonding_delegations(deps, env, query_id)?,
)?),
QueryMsg::GetRegisteredQuery { query_id } => {
Ok(to_json_binary(&get_registered_query(deps, query_id)?)?)
}
Expand Down
Loading

0 comments on commit 65bc3e9

Please sign in to comment.