tg_bindings/sudo.rs
1use cosmwasm_std::Empty;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5use crate::validator::{Validator, ValidatorUpdate};
6
7#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
8#[serde(rename_all = "snake_case")]
9pub enum TgradeSudoMsg<S = Empty> {
10 /// This will be delivered every block if the contract is currently registered for Begin Block
11 /// types based on subset of https://github.com/tendermint/tendermint/blob/v0.34.8/proto/tendermint/abci/types.proto#L81
12 BeginBlock {
13 /// This is proven evidence of malice and the basis for slashing validators
14 evidence: Vec<Evidence>,
15 },
16 /// This will be delivered every block if the contract is currently registered for End Block
17 /// Block height and time is already in Env.
18 EndBlock {},
19 /// This will be delivered after all end blockers if this is registered for ValidatorUpdates.
20 /// If it sets Response.data, it must be a JSON-encoded ValidatorDiff,
21 /// which will be used to change the validator set.
22 EndWithValidatorUpdate {},
23 PrivilegeChange(PrivilegeChangeMsg),
24 /// This will export contract state. Requires `StateExporterImporter` privilege.
25 Export {},
26 /// This will import contract state. Requires `StateExporterImporter` privilege.
27 Import(S),
28}
29
30#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
31#[serde(rename_all = "snake_case")]
32/// These are called on a contract when it is made privileged or demoted
33pub enum PrivilegeChangeMsg {
34 /// This is called when a contract gets "privileged status".
35 /// It is a proper place to call `RegisterXXX` methods that require this status.
36 /// Contracts that require this should be in a "frozen" state until they get this callback.
37 Promoted {},
38 /// This is called when a contract loses "privileged status"
39 Demoted {},
40}
41
42/// See https://github.com/tendermint/tendermint/blob/v0.34.8/proto/tendermint/abci/types.proto#L229-L235
43/// A `EndWithValidatorUpdate{}` call may return a JSON-encoded ValidatorDiff in Response.data
44/// if it wishes to change the validator set.
45#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)]
46pub struct ValidatorDiff {
47 // If a validator is present in this list, change its points to the provided points.
48 // Return a `points` of 0 to remove the named validator from the validator set.
49 pub diffs: Vec<ValidatorUpdate>,
50}
51
52/// See https://github.com/tendermint/tendermint/blob/v0.34.8/proto/tendermint/abci/types.proto#L354-L375
53#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
54pub struct Evidence {
55 pub evidence_type: EvidenceType,
56 pub validator: Validator,
57 /// the block height the offense occurred
58 pub height: u64,
59 /// the time when the offense occurred (in seconds UNIX time, like env.block.time)
60 pub time: u64,
61 /// the total voting power of the validator set at the time the offense occurred
62 pub total_voting_power: u64,
63}
64
65#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
66#[serde(rename_all = "snake_case")]
67pub enum EvidenceType {
68 DuplicateVote,
69 LightClientAttack,
70}