transactions.rs

Overview

This file defines types and structures used to query and paginate blockchain transactions within the system. It primarily focuses on GraphQL connection and edge types that facilitate efficient retrieval and navigation of transaction data, supporting filtering by specific criteria such as balance deltas and code hashes. The file integrates with the GraphQL schema and extends existing message and transaction definitions to represent blockchain-specific entities.

Types and Structures

Type Aliases

BlockchainTransactionsQueryArgs Struct

This struct encapsulates the arguments used to query blockchain transactions, including optional filters and pagination parameters.

#[derive(Clone)]
pub struct BlockchainTransactionsQueryArgs {
    pub min_balance_delta: Option<String>,
    pub max_balance_delta: Option<String>,
    pub code_hash: Option<String>,
    pub pagination: PaginationArgs,
}
let query_args = BlockchainTransactionsQueryArgs {
    min_balance_delta: Some("1000".to_string()),
    max_balance_delta: None,
    code_hash: Some("abc123...".to_string()),
    pagination: PaginationArgs { /* ... */ },
};

This struct is passed to query functions to retrieve filtered and paginated blockchain transactions.

BlockchainTransactionsEdge Struct

Represents an edge in the GraphQL connection pattern for blockchain transactions. Used to encapsulate a single transaction node with its cursor for pagination.

pub(crate) struct BlockchainTransactionsEdge;
impl EdgeNameType for BlockchainTransactionsEdge {
    fn type_name<T: OutputType>() -> String {
        "BlockchainTransactionsEdge".to_string()
    }
}

BlockchainTransactionsConnection Struct

Represents the connection type in the GraphQL pagination pattern for blockchain transactions. It provides the container for edges and pagination info.

pub(crate) struct BlockchainTransactionsConnection;
impl ConnectionNameType for BlockchainTransactionsConnection {
    fn type_name<T: OutputType>() -> String {
        "BlockchainTransactionsConnection".to_string()
    }
}

Implementation Details

Interactions with Other System Components

Visual Diagram: Structure of transactions.rs

classDiagram
class BlockchainTransactionsQueryArgs {
+min_balance_delta: Option<String>
+max_balance_delta: Option<String>
+code_hash: Option<String>
+pagination: PaginationArgs
}
class BlockchainTransactionsEdge {
<<EdgeNameType>>
+type_name()
}
class BlockchainTransactionsConnection {
<<ConnectionNameType>>
+type_name()
}
BlockchainTransactionsEdge ..|> EdgeNameType
BlockchainTransactionsConnection ..|> ConnectionNameType

This diagram illustrates the main structs defined in the file along with their roles and implemented traits. The QueryArgs struct holds query parameters, while Edge and Connection structs implement GraphQL pagination interfaces.