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
// Copyright (c) Subzero Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
use rialo_s_sdk::signature::Signature;
use serde::{Deserialize, Serialize};
use super::{
get_transaction::{Transaction, TransactionStatusMetadata},
rpc_response_context::RpcResponseContext,
};
/// Request parameters for the `getBlock` RPC method
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetBlockRequest {
/// Protocol version for forward compatibility.
#[serde(default)]
pub version: u16,
/// The block height to retrieve
pub block_height: u64,
/// Configuration options for the request
#[serde(default)]
pub config: Option<GetBlockConfig>,
}
/// Configuration options for getBlock requests
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetBlockConfig {
/// Level of transaction detail to return
#[serde(default)]
pub transaction_details: TransactionDetails,
}
/// Transaction detail levels
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub enum TransactionDetails {
/// Return full transaction details
#[default]
Full,
/// Return only transaction signatures
Signatures,
/// Return no transaction details
None,
}
/// Block information response
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BlockInfo {
/// Block height
pub block_height: u64,
/// Block timestamp in unix format (seconds since epoch)
pub block_time: i64,
/// Transactions in the block
pub transactions: Option<Vec<TransactionWithMeta>>,
/// Transaction signatures (when transaction_details is Signatures)
pub signatures: Option<Vec<Signature>>,
}
/// Transaction information in a block using existing types
#[derive(Debug, Serialize)]
pub struct TransactionWithMeta {
/// The transaction data (reusing from get_transaction.rs)
pub transaction: Transaction,
/// Transaction metadata (reusing from get_transaction.rs)
pub meta: Option<TransactionStatusMetadata>,
}
/// The response message for a GetBlock request
#[derive(Serialize, Debug)]
pub struct GetBlockResponse {
pub context: RpcResponseContext,
pub value: BlockInfo,
}