Expand description
§Circles Types
Complete type definitions for the Circles protocol ecosystem in Rust.
This crate provides comprehensive data structures for all aspects of the Circles
protocol, including avatar management, trust relations, token operations, pathfinding,
event handling, RPC communication, and contract interactions. All types support
full serde serialization and are compatible with the TypeScript Circles SDK.
§Features
- Complete Protocol Coverage: Types for avatars, trust, tokens, groups, events
- Alloy Integration: Built on
alloy-primitivesfor Ethereum compatibility - API Compatible: Matches TypeScript SDK structure exactly
- Type Safety: Leverages Rust’s type system while maintaining flexibility
- Async Ready: Traits for contract runners and batch operations
- Query DSL: Complete query builder for
circles_queryRPC method
§Usage Examples
ⓘ
use circles_types::{
// Core types
Address, U256, TxHash,
// Avatar and profile types
AvatarInfo, Profile, AvatarType,
// Pathfinding
FindPathParams, PathfindingResult,
// Trust relations
TrustRelation, TrustRelationType,
// Configuration
CirclesConfig,
};
// Create avatar information
let avatar = AvatarInfo {
block_number: 12345,
timestamp: Some(1234567890),
transaction_index: 1,
log_index: 0,
transaction_hash: "0xabc123...".parse()?,
version: 2,
avatar_type: AvatarType::CrcV2RegisterHuman,
avatar: "0x123...".parse()?,
token_id: Some(U256::from(1)),
has_v1: false,
v1_token: None,
cid_v0_digest: None,
cid_v0: None,
v1_stopped: None,
is_human: true,
name: None,
symbol: None,
};
// Create pathfinding parameters
let params = FindPathParams {
from: "0xabc...".parse()?,
to: "0xdef...".parse()?,
target_flow: U256::from(1000u64),
use_wrapped_balances: Some(true),
from_tokens: None,
to_tokens: None,
exclude_from_tokens: None,
exclude_to_tokens: None,
simulated_balances: None,
max_transfers: Some(10),
};
// Serialize to JSON
let json = serde_json::to_string(&avatar)?;§Type Categories
§Core Blockchain Types
Address- Ethereum address (re-exported from alloy-primitives)TxHash,BlockHash- Transaction and block hashesU256,U192- Large unsigned integersTransactionRequest- Transaction request data
§Avatar & Profile Management
AvatarInfo- Complete avatar information and metadataProfile- User profile with name, description, imagesGroupProfile- Group profile extending Profile with symbolAvatarType- Registration event types (Human, Group, Organization)
§Trust & Social Graph
TrustRelation- Individual trust relationshipAggregatedTrustRelation- Processed trust relationshipsTrustRelationType- Trust relationship types
§Token Operations
TokenBalance- Token balance with metadataTokenInfo- Token creation and type informationTokenHolder- Account token holdingsBalance- Flexible balance type (raw or formatted)
§Group Management
GroupRow- Group registration and metadataGroupMembershipRow- Group membership recordsGroupQueryParams- Parameters for group queries
§Pathfinding & Transfers
FindPathParams- Parameters for path computationPathfindingResult- Computed transfer pathTransferStep- Individual transfer in a pathFlowMatrix- Complete flow representation for contractsSimulatedBalance- Balance simulation for pathfinding
§Event System
CirclesEvent- Universal event structureCirclesEventType- All supported event types (25+ variants)CirclesBaseEvent- Common event metadata
§RPC & Communication
JsonRpcRequest,JsonRpcResponse- Standard JSON-RPC typesCirclesQueryResponse- Response format for queriesTokenBalanceResponse- Token balance from RPC calls
§Query System
QueryParams- Parameters forcircles_queryRPC methodFilterPredicate,Conjunction- Query filtering DSLPagedResult- Paginated query resultsSortOrder,OrderBy- Result sorting
§Contract Execution
ContractRunner- Async trait for contract interactionsBatchRun- Trait for batched transaction executionRunnerConfig- Configuration for contract runners
§Protocol Configuration
CirclesConfig- Complete protocol configurationEscrowedAmountAndDays- Contract-specific response typesDecodedContractError- Contract error information
§Network State
NetworkSnapshot- Complete network state at a blockEventRow- Base structure for event paginationCursor- Pagination cursor for efficient queries
Structs§
- Address
- An Ethereum address, 20 bytes in length.
- Advanced
Transfer Options - Advanced transfer options.
Extends
FindPathParamsto add transfer-specific options. - Aggregated
Trust Relation - Aggregated trust relation
- Avatar
Info - Avatar information Contains basic information about a Circles avatar.
- Avatar
Row - Avatar row data from RPC
- Bytes
- Wrapper type around
bytes::Bytesto support “0x” prefixed hex strings. - Circles
Base Event - Base event information shared by all Circles events.
- Circles
Config - Circles protocol configuration for a specific chain.
- Circles
Event - Generic Circles event with dynamic data parsed from HTTP/WS.
- Circles
Query - Circles query result with pagination Note: This is a trait-like interface in TypeScript, but we’ll use a struct with a callback
- Circles
Query Response - Circles query response format Used for circles_query RPC method results
- Column
Info - Column information for table metadata.
- Conjunction
- Conjunction for combining multiple predicates.
- Decoded
Contract Error - Decoded contract error information Contains parsed error data from failed contract transactions
- Escrowed
Amount AndDays - Escrowed Amount and Days Result Returned by InvitationEscrow.getEscrowedAmountAndDays()
- Event
Row - Defines the minimum columns any event row must have for cursor-based pagination. These values are important for determining cursor position in result sets.
- Filter
Predicate - Filter predicate for querying.
- Find
Path Params - Path finding parameters for
circlesV2_findPath. - Flow
Edge - Edge in the flow graph (sinkId 1 == final hop). This is the original version from lib.rs.
- Flow
Edge Struct - Flow edge structure for
operateFlowMatrix. Corresponds toTypeDefinitions.FlowEdgein Hub V2. - Flow
Matrix - ABI-ready matrix returned by
create_flow_matrix. This is the original version from lib.rs—different fromPathfindingFlowMatrix. - GeoLocation
- Geographic location coordinates
- Group
Membership Row - Group membership row
- Group
Profile - Group profile with additional symbol field
- Group
Query Params - Group query parameters
- Group
Row - Group row information
- Json
RpcError - JSON-RPC error object
- Json
RpcRequest - JSON-RPC request structure
- Json
RpcResponse - JSON-RPC response structure
- Network
Snapshot - Network snapshot structure
- OrderBy
- Order by clause.
- Paged
Query Params - Parameters for a paginated query
- Paged
Result - Result of a paginated query
- Pathfinding
Flow Matrix - Flow matrix for ABI encoding, used with Hub V2
operateFlowMatrix. This is the pathfinding version; different from the contract-facingFlowMatrix. - Pathfinding
Result - Result of pathfinding computation.
- Pathfinding
Transfer Step - A single transfer step in a pathfinding result.
This is the pathfinding version; different from the contract-facing
TransferStep. - Profile
- Profile information
- Query
Params - Query parameters for
circles_query. - Query
Response - Generic query response wrapper Used for internal query transformations and type-safe responses
- RpcSubscription
Event - Raw RPC subscription event (
eth_subscribe("circles")) before parsing. - Runner
Config - Configuration for contract runners
- Safe
Query Response - Better version of QueryResponse that’s more idiomatic
- Simulated
Balance - Simulated balance for path finding.
- Stream
- Stream with byte data. This is the original version from lib.rs.
- Stream
Struct - Stream structure for
operateFlowMatrix. Corresponds toTypeDefinitions.Streamin Hub V2. - Table
Info - Table information from circles_tables
- Token
Balance - Token balance information
- Token
Balance Response - Token balance response from circles_getTokenBalances
- Token
Balance Row - Token balance row from RPC
- Token
Holder - Token holder information from V_CrcV2_BalancesByAccountAndToken
- Token
Info - Token information
- Transaction
Request - Represents all transaction requests to/from RPC.
- Transfer
Step - Transfer step for internal flow calculations.
This is the original version from lib.rs—different from
PathfindingTransferStep. - Trust
Relation - Trust relation information
- Trust
Relation Row - Trust relation row from RPC
- Wrapped
Token Info - Information about a wrapped token found in a transfer path Maps wrapper address to [amount used in path, wrapper type]
Enums§
- Avatar
Type - Avatar type variants
- Balance
- Balance type that can be either raw U256 or formatted as TimeCircles floating point
- Circles
Event Type - All possible Circles event types (unknowns map to
CrcUnknownEvent). - Circles
Type - CirclesType enum Represents the type of Circles ERC20 wrapper
- Conjunction
Type - Conjunction types for combining predicates.
- Event
Type - Event types for network events
- Filter
- Filter type (either a predicate or conjunction).
- Filter
Type - Filter types for query predicates.
- Group
Type - Group type enumeration
- Sort
Order - Order direction for query results.
- Trust
Relation Type - Trust relation type enumeration
Traits§
- Batch
Run - Batch transaction runner trait Allows multiple transactions to be batched and executed atomically
- Contract
Runner - Contract runner trait for executing blockchain operations This is the base trait that all contract runners must implement
Type Aliases§
- Block
Hash - A block hash.
- Cursor
- A cursor is a sortable unique identifier for a specific log entry. Used to paginate through query results efficiently.
- Transport
Result - A transport result is a
Resultcontaining aTransportError. - TxHash
- A transaction hash is a keccak hash of an RLP encoded signed transaction.
- U192
- 192-bit unsigned integer type, consisting of 3, 64-bit limbs.
- U256
- 256-bit unsigned integer type, consisting of 4, 64-bit limbs.
- Wrapped
Tokens Record - Record of wrapped tokens found in a transfer path Maps wrapper address to wrapped token information