Rialo API Types
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.
Features
- Type Safety: Strongly typed request and response structures for all RPC endpoints
- Validation: Built-in input validation using the
validatorcrate - JSON-RPC 2.0: Full compliance with JSON-RPC 2.0 specification
- Solana Compatibility: Compatible with Solana RPC client libraries
- Serde Support: Full serialization/deserialization support
- Documentation: Comprehensive documentation with examples
Supported RPC Methods
Account Operations
getAccountInfo- Get account informationgetBalance- Get account balancegetMultipleAccounts- Get multiple account info
Transaction Operations
sendTransaction- Submit a transactiongetTransaction- Get transaction detailsgetSignatureStatuses- Get transaction statusesgetSignaturesForAddress- Get signatures for address
Block Operations
getBlock- Get block informationgetLatestBlockhash- Get latest blockhash
Health & Status
getHealth- Node health checkgetValidatorHealth- Validator health checkgetConnectedFullNodes- Get full nodes connected to validatorgetEpochInfo- Get epoch information
Utility Operations
requestAirdrop- Request test tokensgetMinimumBalanceForRentExemption- Get rent exemptiongetFeeForMessage- Calculate transaction feesisBlockhashValid- Validate blockhash
Rialo-Specific Operations
getWorkflowLineage- Get workflow transaction lineagegetTriggeredTransactions- Get triggered transactionsgetSubscriptions- Get active subscriptionsgetTransactionCount- Get transaction count
Network Operations
getClusterNodes- Get information about all nodes in the current cluster (committee)
Usage
Basic Request/Response Types
use ;
// Create a request
let request = GetAccountInfoRequest ;
// Serialize to JSON
let json = to_string?;
println!;
Validation
All request types implement validation using the validator crate:
use ;
// Create and validate a request
let request = new;
// This will validate pubkey format and airdrop amount constraints
let validated = validate_request?;
Array Parameter Support
Some endpoints support both object and array parameter formats for Solana compatibility:
use ;
use Value;
// Parse from array format: ["transaction", {"encoding": "base64"}]
let params = vec!;
let request = from_array_params?;
Validation Features
The crate provides comprehensive input validation:
Built-in Validators
- Public Key Validation: Ensures valid Solana public key format
- Signature Validation: Validates base58-encoded signatures (87-88 chars)
- Encoding Validation: Ensures supported encoding formats (base64, base58)
- Amount Validation: Range checking for lamport amounts and limits
- Base64/Base58 Validation: Format validation for encoded data
Custom Validation
use ;
// Validate individual values
validate_pubkey?;
validate_signature?;
validate_airdrop_amount?; // 1 SOL
Error Handling
All validation errors implement the ValidationError type:
use ;
JSON-RPC 2.0 Examples
Request Format
Response Format
Type Organization
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
Development
Adding New RPC Methods
- Create a new file in
src/messages/ - Define request, response, and config types
- Add validation annotations using
#[validate(...)] - Include comprehensive documentation with examples
- Add the types to
lib.rsre-exports - Write tests for the new types
Example New Method
// src/messages/my_new_method.rs
use ;
use Validate;
use cratevalidate_pubkey;
/// Request for myNewMethod RPC call
///
/// This method does something specific...
///
/// ## Example
///
/// ```json
/// {
/// "jsonrpc": "2.0",
/// "id": 1,
/// "method": "myNewMethod",
/// "params": ["pubkey_here"]
/// }
/// ```
/// Response for myNewMethod RPC call
Testing
Run the test suite:
Run validation-specific tests:
Contributing
When contributing new API types:
- Follow existing naming conventions
- Add comprehensive documentation with JSON examples
- Include proper validation constraints
- Write unit tests for all new types
- Update this README if adding new categories
Dependencies
serde- Serialization/deserializationvalidator- Input validationrialo-s-sdk- Solana types and utilitiesthiserror- Error handlingrialo-types- Shared Rialo types
License
Licensed under the Apache License, Version 2.0.