Expand description
Utility functions for the Miracle API/SDK
This module provides common utilities for data conversion, validation, and other helper functions used across the Miracle ecosystem.
§Key Features
§Hex String Conversion
- Convert hex strings to byte arrays for on-chain consumption
- Support for common hex prefixes (0x, \x)
- Type-safe conversions with compile-time size checking
§Claim Instruction Utilities
- Convert database hex strings to
EpochClaimData
structs - Bridge between off-chain database queries and on-chain instruction data
- Support for both hex string and native u64 inputs
§Usage Examples
use miracle_api::utils::{hex, claim};
// Convert hex string to byte array
let bytes: [u8; 8] = hex::hex_string_to_u64_bytes("0x1234567890abcdef")?;
// Create EpochClaimData from hex strings (from database)
let epoch_data = claim::epoch_claim_data_from_hex(
"0x1234567890abcdef",
"0xfedcba0987654321",
"0x0000000000000064",
"0x00000000000000c8"
)?;
// Create EpochClaimData from native u64 values
let epoch_data = claim::epoch_claim_data_from_u64(1234567890, 9876543210, 100, 200);
§Key Features
§Hex String Conversion
- Convert hex strings to byte arrays for on-chain consumption
- Support for common hex prefixes (0x, \x)
- Type-safe conversions with compile-time size checking
§Claim Instruction Utilities
- Convert database hex strings to
EpochClaimData
structs - Bridge between off-chain database queries and on-chain instruction data
- Support for both hex string and native u64 inputs
§Usage Examples
use miracle_api::utils::{hex, claim};
// Convert hex string to byte array
let bytes: [u8; 8] = hex::hex_string_to_u64_bytes("0x1234567890abcdef")?;
// Create EpochClaimData from hex strings (from database)
let epoch_data = claim::epoch_claim_data_from_hex(
"0x1234567890abcdef",
"0xfedcba0987654321",
"0x0000000000000064",
"0x00000000000000c8"
)?;
// Create EpochClaimData from native u64 values
let epoch_data = claim::epoch_claim_data_from_u64(1234567890, 9876543210, 100, 200);