| Crates.io | rialo-api-types |
| lib.rs | rialo-api-types |
| version | 0.1.10 |
| created_at | 2025-11-14 16:40:40.670667+00 |
| updated_at | 2025-12-09 20:54:24.866384+00 |
| description | API types for Rialo RPC endpoints |
| homepage | |
| repository | https://github.com/SubzeroLabs/rialo |
| max_upload_size | |
| id | 1933134 |
| size | 276,231 |
This crate contains all the request and response types used by the Rialo RPC API. It provides strongly-typed, validated data structures for all supported RPC endpoints, following the JSON-RPC 2.0 specification with Solana compatibility.
validator crategetAccountInfo - Get account informationgetBalance - Get account balancegetMultipleAccounts - Get multiple account infosendTransaction - Submit a transactiongetTransaction - Get transaction detailsgetSignatureStatuses - Get transaction statusesgetSignaturesForAddress - Get signatures for addressgetBlock - Get block informationgetHealth - Node health checkgetValidatorHealth - Validator health checkgetConnectedFullNodes - Get full nodes connected to validatorgetEpochInfo - Get epoch informationrequestAirdrop - Request test tokensgetMinimumBalanceForRentExemption - Get rent exemptiongetFeeForMessage - Calculate transaction feesisBlockhashValid - Validate blockhashgetWorkflowLineage - Get workflow transaction lineagegetTriggeredTransactions - Get triggered transactionsgetSubscriptions - Get active subscriptionsgetTransactionCount - Get transaction countgetClusterNodes - Get information about all nodes in the current cluster (committee)use rialo_api_types::messages::get_account_info::{
GetAccountInfoRequest, GetAccountInfoResponse, GetAccountInfoConfig
};
// Create a request
let request = GetAccountInfoRequest {
address: "7xB9i2AcjLNJ6M8iZ3LZJvLm7xpSmH7T5uZzR3DeVXWi".to_string(),
config: Some(GetAccountInfoConfig {
encoding: Some("base64".to_string()),
..Default::default()
})
};
// Serialize to JSON
let json = serde_json::to_string(&request)?;
println!("Request: {}", json);
All request types implement validation using the validator crate:
use rialo_api_types::{
messages::request_airdrop::RequestAirdropRequest,
validation::validate_request
};
// Create and validate a request
let request = RequestAirdropRequest::new(
"7xB9i2AcjLNJ6M8iZ3LZJvLm7xpSmH7T5uZzR3DeVXWi".to_string(),
1_000_000_000 // 1 SOL
);
// This will validate pubkey format and airdrop amount constraints
let validated = validate_request(request)?;
Some endpoints support both object and array parameter formats for Solana compatibility:
use rialo_api_types::requests::{SendTransactionRequest, FromArrayParams};
use serde_json::Value;
// Parse from array format: ["transaction", {"encoding": "base64"}]
let params = vec![
Value::String("base64_transaction_data".to_string()),
serde_json::json!({"encoding": "base64"})
];
let request = SendTransactionRequest::from_array_params(¶ms)?;
The crate provides comprehensive input validation:
use rialo_api_types::validation::{
validate_pubkey, validate_signature, validate_airdrop_amount
};
// Validate individual values
validate_pubkey("7xB9i2AcjLNJ6M8iZ3LZJvLm7xpSmH7T5uZzR3DeVXWi")?;
validate_signature("signature_base58")?;
validate_airdrop_amount(1_000_000_000)?; // 1 SOL
All validation errors implement the ValidationError type:
use rialo_api_types::validation::{ValidationError, ValidationResult};
fn handle_validation(result: ValidationResult<T>) {
match result {
Ok(validated_data) => {
// Process validated data
}
Err(ValidationError::InvalidPublicKey(msg)) => {
println!("Invalid public key: {}", msg);
}
Err(ValidationError::InvalidSignature(msg)) => {
println!("Invalid signature: {}", msg);
}
Err(ValidationError::Multiple(msg)) => {
println!("Multiple validation errors: {}", msg);
}
Err(err) => {
println!("Validation error: {}", err);
}
}
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"7xB9i2AcjLNJ6M8iZ3LZJvLm7xpSmH7T5uZzR3DeVXWi",
{
"encoding": "base64"
}
]
}
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"context": {
"slot": 1234567
},
"value": {
"data": ["base64_encoded_data", "base64"],
"executable": false,
"lamports": 1000000000,
"owner": "11111111111111111111111111111111",
"rentEpoch": 200
}
}
}
src/
├── lib.rs # Main crate interface
├── messages/ # RPC method types
│ ├── get_*.rs # Get method types
│ ├── send_*.rs # Send method types
│ └── request_*.rs # Request method types
├── parameters.rs # Parameter re-exports
├── requests.rs # Array parameter parsing
├── validation.rs # Validation logic
└── validation_test.rs # Validation tests
src/messages/#[validate(...)]lib.rs re-exports// src/messages/my_new_method.rs
use serde::{Deserialize, Serialize};
use validator::Validate;
use crate::validation::validate_pubkey;
/// Request for myNewMethod RPC call
///
/// This method does something specific...
///
/// ## Example
///
/// ```json
/// {
/// "jsonrpc": "2.0",
/// "id": 1,
/// "method": "myNewMethod",
/// "params": ["pubkey_here"]
/// }
/// ```
#[derive(Debug, Clone, Serialize, Deserialize, Validate)]
pub struct MyNewMethodRequest {
/// The account public key (base58 encoded)
#[validate(length(min = 1, message = "Public key cannot be empty"))]
#[validate(custom(function = validate_pubkey))]
pub pubkey: String,
}
/// Response for myNewMethod RPC call
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MyNewMethodResponse {
/// The result data
pub result: String,
}
Run the test suite:
cargo test --package rialo-api-types
Run validation-specific tests:
cargo test --package rialo-api-types validation
When contributing new API types:
serde - Serialization/deserializationvalidator - Input validationrialo-s-sdk - Solana types and utilitiesthiserror - Error handlingrialo-types - Shared Rialo typesLicensed under the Apache License, Version 2.0.