nym_performance_contract_common/
msg.rs

1// Copyright 2025 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::{EpochId, NodeId, NodePerformance};
5use cosmwasm_schema::cw_serde;
6
7#[cfg(feature = "schema")]
8use crate::types::{
9    EpochMeasurementsPagedResponse, EpochPerformancePagedResponse,
10    FullHistoricalPerformancePagedResponse, LastSubmission, NetworkMonitorResponse,
11    NetworkMonitorsPagedResponse, NodeMeasurementsResponse, NodePerformancePagedResponse,
12    NodePerformanceResponse, RetiredNetworkMonitorsPagedResponse,
13};
14
15#[cw_serde]
16pub struct InstantiateMsg {
17    pub mixnet_contract_address: String,
18    pub authorised_network_monitors: Vec<String>,
19}
20
21#[cw_serde]
22pub enum ExecuteMsg {
23    /// Change the admin
24    UpdateAdmin { admin: String },
25
26    /// Attempt to submit performance data of a particular node for given epoch
27    Submit {
28        epoch: EpochId,
29        data: NodePerformance,
30    },
31
32    /// Attempt to submit performance data of a batch of nodes for given epoch
33    BatchSubmit {
34        epoch: EpochId,
35        data: Vec<NodePerformance>,
36    },
37
38    /// Attempt to authorise new network monitor for submitting performance data
39    AuthoriseNetworkMonitor { address: String },
40
41    /// Attempt to retire an existing network monitor and forbid it from submitting any future performance data
42    RetireNetworkMonitor { address: String },
43
44    /// An admin method to remove submitted node measurements. Used as an escape hatch should
45    /// the data stored get too unwieldy.
46    RemoveNodeMeasurements { epoch_id: EpochId, node_id: NodeId },
47
48    /// An admin method to remove submitted nodes measurements. Used as an escape hatch should
49    /// the data stored get too unwieldy. Note: it is expected to get called multiple times
50    /// until the response indicates all the epoch data has been removed.
51    RemoveEpochMeasurements { epoch_id: EpochId },
52}
53
54#[cw_serde]
55#[cfg_attr(feature = "schema", derive(cosmwasm_schema::QueryResponses))]
56pub enum QueryMsg {
57    #[cfg_attr(feature = "schema", returns(cw_controllers::AdminResponse))]
58    Admin {},
59
60    /// Returns performance of particular node for the provided epoch
61    #[cfg_attr(feature = "schema", returns(NodePerformanceResponse))]
62    NodePerformance { epoch_id: EpochId, node_id: NodeId },
63
64    /// Returns historical performance for particular node
65    #[cfg_attr(feature = "schema", returns(NodePerformancePagedResponse))]
66    NodePerformancePaged {
67        node_id: NodeId,
68        start_after: Option<EpochId>,
69        limit: Option<u32>,
70    },
71
72    /// Returns all submitted measurements for the particular node
73    #[cfg_attr(feature = "schema", returns(NodeMeasurementsResponse))]
74    NodeMeasurements { epoch_id: EpochId, node_id: NodeId },
75
76    /// Returns (paged) measurements for particular epoch
77    #[cfg_attr(feature = "schema", returns(EpochMeasurementsPagedResponse))]
78    EpochMeasurementsPaged {
79        epoch_id: EpochId,
80        start_after: Option<NodeId>,
81        limit: Option<u32>,
82    },
83
84    /// Returns (paged) performance for particular epoch
85    #[cfg_attr(feature = "schema", returns(EpochPerformancePagedResponse))]
86    EpochPerformancePaged {
87        epoch_id: EpochId,
88        start_after: Option<NodeId>,
89        limit: Option<u32>,
90    },
91
92    /// Returns full (paged) historical performance of the whole network
93    #[cfg_attr(feature = "schema", returns(FullHistoricalPerformancePagedResponse))]
94    FullHistoricalPerformancePaged {
95        start_after: Option<(EpochId, NodeId)>,
96        limit: Option<u32>,
97    },
98
99    /// Returns information about particular network monitor
100    #[cfg_attr(feature = "schema", returns(NetworkMonitorResponse))]
101    NetworkMonitor { address: String },
102
103    /// Returns information about all network monitors
104    #[cfg_attr(feature = "schema", returns(NetworkMonitorsPagedResponse))]
105    NetworkMonitorsPaged {
106        start_after: Option<String>,
107        limit: Option<u32>,
108    },
109
110    /// Returns information about all retired network monitors
111    #[cfg_attr(feature = "schema", returns(RetiredNetworkMonitorsPagedResponse))]
112    RetiredNetworkMonitorsPaged {
113        start_after: Option<String>,
114        limit: Option<u32>,
115    },
116
117    /// Returns information regarding the latest submitted performance data
118    #[cfg_attr(feature = "schema", returns(LastSubmission))]
119    LastSubmittedMeasurement {},
120}
121
122#[cw_serde]
123pub struct MigrateMsg {
124    //
125}