1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
use crate::client::client_types::{terra_datetime_format, terra_i64_format, terra_u64_format};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize, Debug)]
pub struct BlockIdParts {
    #[serde(with = "terra_u64_format")]
    pub total: u64,
    pub hash: String,
}

#[derive(Deserialize, Serialize, Debug)]
pub struct BlockId {
    pub hash: String,
    pub parts: BlockIdParts,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct BlockHeaderVersion {
    #[serde(with = "terra_u64_format")]
    pub block: u64,
    #[serde(with = "terra_u64_format")]
    pub app: u64,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct BlockHeader {
    pub version: BlockHeaderVersion,
    pub chain_id: String,
    #[serde(with = "terra_u64_format")]
    pub height: u64,
    #[serde(with = "terra_datetime_format")]
    pub time: DateTime<Utc>,
    pub last_block_id: BlockId,
    pub last_commit_hash: String,
    pub data_hash: String,
    pub validators_hash: String,
    pub next_validators_hash: String,
    pub consensus_hash: String,
    pub app_hash: String,
    pub last_results_hash: String,
    pub evidence_hash: String,
    pub proposer_address: String,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct BlockEvidence {
    //pub evidence: Option<...>
}
#[derive(Deserialize, Serialize, Debug)]
pub struct BlockSignature {
    /// 1 -no signature .. 2 -- signature
    pub block_id_flag: usize,
    /// HEX/Bytes version of string
    pub validator_address: String,
    #[serde(with = "terra_datetime_format")]
    pub timestamp: DateTime<Utc>,
    pub signature: Option<String>,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct BlockCommit {
    #[serde(with = "terra_u64_format")]
    pub height: u64,
    #[serde(with = "terra_u64_format")]
    pub round: u64,
    pub block_id: BlockId,
    pub signatures: Vec<BlockSignature>,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct BlockData {
    pub txs: Vec<String>,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct Block {
    pub header: BlockHeader,
    pub data: BlockData,
    pub evidence: BlockEvidence,
    pub last_commit: BlockCommit,
}

#[derive(Deserialize, Serialize, Debug)]
pub struct BlockResult {
    pub block_id: BlockId,
    pub block: Block,
}

#[derive(Deserialize, Serialize, Debug)]
pub struct ValidatorSetResponse {
    #[serde(with = "terra_u64_format")]
    pub height: u64,
    pub result: ValidatorSetResult,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct ValidatorSetResult {
    #[serde(with = "terra_u64_format")]
    pub block_height: u64,
    pub validators: Vec<Validator>,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct Validator {
    pub address: String,
    pub pub_key: String,
    #[serde(with = "terra_i64_format")]
    pub proposer_priority: i64,
    #[serde(with = "terra_u64_format")]
    pub voting_power: u64,
}