feat: introduce node families contract query for Config retrieval (#6870)
This commit is contained in:
committed by
GitHub
parent
fa842ceb4f
commit
2705330595
+8
-2
@@ -7,12 +7,12 @@ use crate::nyxd::error::NyxdError;
|
|||||||
use crate::nyxd::CosmWasmClient;
|
use crate::nyxd::CosmWasmClient;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use cosmrs::AccountId;
|
use cosmrs::AccountId;
|
||||||
|
use nym_mixnet_contract_common::NodeId;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use nym_mixnet_contract_common::NodeId;
|
|
||||||
pub use nym_node_families_contract_common::{
|
pub use nym_node_families_contract_common::{
|
||||||
msg::QueryMsg as NodeFamiliesQueryMsg, AllFamilyMembersPagedResponse,
|
msg::QueryMsg as NodeFamiliesQueryMsg, AllFamilyMembersPagedResponse,
|
||||||
AllPastFamilyInvitationsPagedResponse, FamiliesPagedResponse, FamilyMemberRecord,
|
AllPastFamilyInvitationsPagedResponse, Config, FamiliesPagedResponse, FamilyMemberRecord,
|
||||||
FamilyMembersPagedResponse, GlobalPastFamilyInvitationCursor, NodeFamily,
|
FamilyMembersPagedResponse, GlobalPastFamilyInvitationCursor, NodeFamily,
|
||||||
NodeFamilyByNameResponse, NodeFamilyByOwnerResponse, NodeFamilyId,
|
NodeFamilyByNameResponse, NodeFamilyByOwnerResponse, NodeFamilyId,
|
||||||
NodeFamilyMembershipResponse, NodeFamilyResponse, PastFamilyInvitation,
|
NodeFamilyMembershipResponse, NodeFamilyResponse, PastFamilyInvitation,
|
||||||
@@ -35,6 +35,11 @@ pub trait NodeFamiliesQueryClient {
|
|||||||
where
|
where
|
||||||
for<'a> T: Deserialize<'a>;
|
for<'a> T: Deserialize<'a>;
|
||||||
|
|
||||||
|
async fn get_config(&self) -> Result<Config, NyxdError> {
|
||||||
|
self.query_node_families_contract(NodeFamiliesQueryMsg::GetConfig {})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_family_by_id(
|
async fn get_family_by_id(
|
||||||
&self,
|
&self,
|
||||||
family_id: NodeFamilyId,
|
family_id: NodeFamilyId,
|
||||||
@@ -360,6 +365,7 @@ mod tests {
|
|||||||
msg: NodeFamiliesQueryMsg,
|
msg: NodeFamiliesQueryMsg,
|
||||||
) {
|
) {
|
||||||
match msg {
|
match msg {
|
||||||
|
NodeFamiliesQueryMsg::GetConfig {} => client.get_config().ignore(),
|
||||||
NodeFamiliesQueryMsg::GetFamilyById { family_id } => {
|
NodeFamiliesQueryMsg::GetFamilyById { family_id } => {
|
||||||
client.get_family_by_id(family_id).ignore()
|
client.get_family_by_id(family_id).ignore()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,10 @@ pub enum ExecuteMsg {
|
|||||||
#[cw_serde]
|
#[cw_serde]
|
||||||
#[cfg_attr(feature = "schema", derive(cosmwasm_schema::QueryResponses))]
|
#[cfg_attr(feature = "schema", derive(cosmwasm_schema::QueryResponses))]
|
||||||
pub enum QueryMsg {
|
pub enum QueryMsg {
|
||||||
|
/// Retrieve current contract configuration values
|
||||||
|
#[cfg_attr(feature = "schema", returns(Config))]
|
||||||
|
GetConfig {},
|
||||||
|
|
||||||
/// Look up a single family by its id.
|
/// Look up a single family by its id.
|
||||||
#[cfg_attr(feature = "schema", returns(NodeFamilyResponse))]
|
#[cfg_attr(feature = "schema", returns(NodeFamilyResponse))]
|
||||||
GetFamilyById { family_id: NodeFamilyId },
|
GetFamilyById { family_id: NodeFamilyId },
|
||||||
|
|||||||
Generated
+1
-2
@@ -1037,7 +1037,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "node-families"
|
name = "node-families"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cosmwasm-schema",
|
"cosmwasm-schema",
|
||||||
@@ -1052,7 +1052,6 @@ dependencies = [
|
|||||||
"nym-mixnet-contract",
|
"nym-mixnet-contract",
|
||||||
"nym-mixnet-contract-common",
|
"nym-mixnet-contract-common",
|
||||||
"nym-node-families-contract-common",
|
"nym-node-families-contract-common",
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ cw3-flex-multisig = { version = "2.0.0", path = "multisig/cw3-flex-multisig" }
|
|||||||
cw4-group = { version = "2.0.0", path = "multisig/cw4-group" }
|
cw4-group = { version = "2.0.0", path = "multisig/cw4-group" }
|
||||||
nym-mixnet-contract = { version = "1.5.1", path = "mixnet" }
|
nym-mixnet-contract = { version = "1.5.1", path = "mixnet" }
|
||||||
nym-vesting-contract = { version = "1.4.1", path = "vesting" }
|
nym-vesting-contract = { version = "1.4.1", path = "vesting" }
|
||||||
node-families = { version = "0.1.0", path = "node-families" }
|
node-families = { version = "0.1.1", path = "node-families" }
|
||||||
|
|
||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
unwrap_used = "deny"
|
unwrap_used = "deny"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "node-families"
|
name = "node-families"
|
||||||
description = "Nym Node Families contract"
|
description = "Nym Node Families contract"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
@@ -25,7 +25,6 @@ cosmwasm-std = { workspace = true }
|
|||||||
cw2 = { workspace = true }
|
cw2 = { workspace = true }
|
||||||
cw-storage-plus = { workspace = true }
|
cw-storage-plus = { workspace = true }
|
||||||
cw-controllers = { workspace = true }
|
cw-controllers = { workspace = true }
|
||||||
serde = { workspace = true }
|
|
||||||
cosmwasm-schema = { workspace = true, optional = true }
|
cosmwasm-schema = { workspace = true, optional = true }
|
||||||
cw-utils = { workspace = true }
|
cw-utils = { workspace = true }
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
use crate::queries::{
|
use crate::queries::{
|
||||||
query_all_family_members_paged, query_all_past_invitations_paged,
|
query_all_family_members_paged, query_all_past_invitations_paged,
|
||||||
query_all_pending_invitations_paged, query_families_paged, query_family_by_id,
|
query_all_pending_invitations_paged, query_config, query_families_paged, query_family_by_id,
|
||||||
query_family_by_name, query_family_by_owner, query_family_members_paged,
|
query_family_by_name, query_family_by_owner, query_family_members_paged,
|
||||||
query_family_membership, query_past_invitations_for_family_paged,
|
query_family_membership, query_past_invitations_for_family_paged,
|
||||||
query_past_invitations_for_node_paged, query_past_members_for_family_paged,
|
query_past_invitations_for_node_paged, query_past_members_for_family_paged,
|
||||||
@@ -100,6 +100,7 @@ pub fn execute(
|
|||||||
#[entry_point]
|
#[entry_point]
|
||||||
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<Binary, NodeFamiliesContractError> {
|
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<Binary, NodeFamiliesContractError> {
|
||||||
match msg {
|
match msg {
|
||||||
|
QueryMsg::GetConfig {} => Ok(to_json_binary(&query_config(deps)?)?),
|
||||||
QueryMsg::GetFamilyById { family_id } => {
|
QueryMsg::GetFamilyById { family_id } => {
|
||||||
Ok(to_json_binary(&query_family_by_id(deps, family_id)?)?)
|
Ok(to_json_binary(&query_family_by_id(deps, family_id)?)?)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,18 +7,23 @@ use cosmwasm_std::{Deps, Env, Order, StdResult};
|
|||||||
use cw_storage_plus::Bound;
|
use cw_storage_plus::Bound;
|
||||||
use nym_mixnet_contract_common::NodeId;
|
use nym_mixnet_contract_common::NodeId;
|
||||||
use nym_node_families_contract_common::{
|
use nym_node_families_contract_common::{
|
||||||
AllFamilyMembersPagedResponse, AllPastFamilyInvitationsPagedResponse, FamiliesPagedResponse,
|
AllFamilyMembersPagedResponse, AllPastFamilyInvitationsPagedResponse, Config,
|
||||||
FamilyMemberRecord, FamilyMembersPagedResponse, GlobalPastFamilyInvitationCursor,
|
FamiliesPagedResponse, FamilyMemberRecord, FamilyMembersPagedResponse,
|
||||||
NodeFamiliesContractError, NodeFamilyByNameResponse, NodeFamilyByOwnerResponse, NodeFamilyId,
|
GlobalPastFamilyInvitationCursor, NodeFamiliesContractError, NodeFamilyByNameResponse,
|
||||||
NodeFamilyMembershipResponse, NodeFamilyResponse, PastFamilyInvitationCursor,
|
NodeFamilyByOwnerResponse, NodeFamilyId, NodeFamilyMembershipResponse, NodeFamilyResponse,
|
||||||
PastFamilyInvitationForNodeCursor, PastFamilyInvitationsForNodePagedResponse,
|
PastFamilyInvitationCursor, PastFamilyInvitationForNodeCursor,
|
||||||
PastFamilyInvitationsPagedResponse, PastFamilyMemberCursor, PastFamilyMemberForNodeCursor,
|
PastFamilyInvitationsForNodePagedResponse, PastFamilyInvitationsPagedResponse,
|
||||||
PastFamilyMembersForNodePagedResponse, PastFamilyMembersPagedResponse,
|
PastFamilyMemberCursor, PastFamilyMemberForNodeCursor, PastFamilyMembersForNodePagedResponse,
|
||||||
PendingFamilyInvitationDetails, PendingFamilyInvitationResponse,
|
PastFamilyMembersPagedResponse, PendingFamilyInvitationDetails,
|
||||||
PendingFamilyInvitationsPagedResponse, PendingInvitationsForNodePagedResponse,
|
PendingFamilyInvitationResponse, PendingFamilyInvitationsPagedResponse,
|
||||||
PendingInvitationsPagedResponse,
|
PendingInvitationsForNodePagedResponse, PendingInvitationsPagedResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Retrieve current contract configuration values
|
||||||
|
pub fn query_config(deps: Deps) -> Result<Config, NodeFamiliesContractError> {
|
||||||
|
Ok(NodeFamiliesStorage::new().config.load(deps.storage)?)
|
||||||
|
}
|
||||||
|
|
||||||
/// Resolve a single family by its id. Returns `family: None` if no family
|
/// Resolve a single family by its id. Returns `family: None` if no family
|
||||||
/// with that id exists.
|
/// with that id exists.
|
||||||
pub fn query_family_by_id(
|
pub fn query_family_by_id(
|
||||||
|
|||||||
Reference in New Issue
Block a user