Expand description
§Rialo API Types
This crate provides strongly-typed, validated data structures for all Rialo RPC endpoints. It implements the JSON-RPC 2.0 specification with full Solana compatibility.
§Features
- Type Safety: Strongly typed request and response structures for all RPC endpoints
- Input Validation: Built-in validation using the
validatorcrate with custom rules - JSON-RPC 2.0: Full compliance with JSON-RPC 2.0 specification
- Solana Compatibility: Compatible with Solana RPC client libraries and tools
- Comprehensive Documentation: Each endpoint includes examples and usage patterns
§Quick Start
use rialo_api_types::{
messages::get_account_info::{GetAccountInfoRequest, GetAccountInfoConfig},
validation::validate_request
};
// Create a request
let request = GetAccountInfoRequest {
version: 0,
address: "7xB9i2AcjLNJ6M8iZ3LZJvLm7xpSmH7T5uZzR3DeVXWi".to_string(),
config: Some(GetAccountInfoConfig {
data_slice: None,
min_context_slot: None,
})
};
// Serialize to JSON
let json = serde_json::to_string(&request).unwrap();§Validation
All request types support comprehensive input validation:
use rialo_api_types::{
messages::request_airdrop::RequestAirdropRequest,
validation::validate_request
};
let request = RequestAirdropRequest::new(
"7xB9i2AcjLNJ6M8iZ3LZJvLm7xpSmH7T5uZzR3DeVXWi".to_string(),
1_000_000_000 // 1 RLO in kelvins
);
// This validates the pubkey format and amount constraints
let validated = validate_request(request).unwrap();§Supported RPC Methods
§Account Operations
getAccountInfo- Get account information and datagetBalance- Get account balance in kelvinsgetMultipleAccounts- Get information for multiple accounts
§Transaction Operations
sendTransaction- Submit a signed transaction to the networkgetTransaction- Get transaction details and metadatagetSignatureStatuses- Get confirmation status of transactionsgetSignaturesForAddress- Get transaction signatures for an address
§Block Operations
getBlock- Get confirmed block information
§Health & Status
getHealth- Node health check endpointgetValidatorHealth- Validator-specific health checkgetConnectedFullNodes- Get full nodes connected to validatorgetEpochInfo- Get current epoch information
§Utility Operations
requestAirdrop- Request test tokens (devnet/testnet only)getMinimumBalanceForRentExemption- Get minimum balance for rent exemptiongetFeeForMessage- Calculate transaction feesisBlockhashValid- Check if a blockhash is still valid
§Rialo-Specific Operations
getWorkflowLineage- Get workflow transaction lineage and relationshipsgetTriggeredTransactions- Get transactions triggered by eventsgetSubscription- Get subscription by subscriber and noncegetTransactionCount- Get total transaction count
§Error Handling
use rialo_api_types::validation::{ValidationError, ValidationResult};
use rialo_api_types::messages::request_airdrop::RequestAirdropRequest;
fn handle_validation_error(result: ValidationResult<RequestAirdropRequest>) {
match result {
Ok(data) => { /* Use validated data */ }
Err(ValidationError::InvalidPublicKey(msg)) => {
println!("Invalid public key: {}", msg);
}
Err(ValidationError::Multiple(msg)) => {
println!("Multiple validation errors: {}", msg);
}
Err(err) => {
println!("Validation failed: {}", err);
}
}
}§JSON-RPC 2.0 Format
All requests follow the JSON-RPC 2.0 specification:
{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"7xB9i2AcjLNJ6M8iZ3LZJvLm7xpSmH7T5uZzR3DeVXWi"
]
}Responses include context information and follow the same format:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"context": {
"slot": 1234567
},
"value": {
"kelvins": 1000000000,
"data": ["SGVsbG8gV29ybGQ=", "base64"],
"owner": "11111111111111111111111111111111",
"executable": false,
"rentEpoch": 200
}
}
}Re-exports§
pub use messages::get_block::GetBlockRequest;pub use messages::get_block::GetBlockResponse;pub use messages::get_connected_full_nodes::GetConnectedFullNodesResponse;pub use messages::get_health::GetHealthResponse;pub use messages::get_signature_statuses::GetSignatureStatusesRequest;pub use messages::get_transaction_count::GetTransactionCountResponse;pub use messages::get_validator_health::GetValidatorHealthResponse;pub use messages::get_validator_health::ValidatorHealthStatus;pub use messages::get_workflow_lineage::GetWorkflowLineageRequest;pub use messages::get_workflow_lineage::GetWorkflowLineageResponse;pub use messages::request_airdrop::RequestAirdropRequest;pub use messages::request_airdrop::RequestAirdropResponse;pub use messages::rpc_response_context::RpcResponseContext;
Modules§
- constants
- Constants used throughout the API validation
- messages
- parameters
- Structured parameter types for RPC calls
- requests
- Request types for node RPC handlers
- validation
- Validation for API request types