account.rs

Overview

The account.rs file defines GraphQL types and query resolvers related to user accounts within the application. It mainly handles querying account information and paginated account-related events (outgoing external messages). The file integrates with a SQLite database through the sqlx crate and uses async-graphql's connection-based pagination utilities for efficient event retrieval. It leverages external crates such as tvm_client for client context and tvm_types for base64 encoding.


Structs and Their Responsibilities

AccountEventEdge

AccountEventsConnection

Account

A GraphQL object representing an account.

Fields

Traits and Conversions

Usage Example

let db_account: db::Account = // obtain from DB
let gql_account: Account = db_account.into();

AccountQuery

Represents a GraphQL query root for fetching account data and related events.

Fields

Methods

info
pub async fn info(&self, ctx: &Context<'_>) -> Option<Account>

Retrieves the account information for the specified address.

Parameters
Returns
Usage Example
let query = AccountQuery { address: "0x123...".to_string(), preloaded: None };
let account_info = query.info(&context).await;

events
pub async fn events(
    &self,
    ctx: &Context<'_>,
    first: Option<i32>,
    after: Option<String>,
    last: Option<i32>,
    before: Option<String>,
) -> Option<Connection<String, Event, EmptyFields, EmptyFields, AccountEventsConnection, AccountEventEdge>>

Fetches a paginated list of account-related events based on cursor pagination arguments.

Parameters
Returns
Implementation Details
Usage Example
let events_connection = query.events(&ctx, Some(10), None, None, None).await;

Important Implementation Details and Algorithms


System Interaction


Mermaid Class Diagram

classDiagram
class Account {
+id: String
-boc: Option<String>
-dapp_id: Option<String>
}
class AccountQuery {
+address: String
-preloaded: Option<db::Account>
+info()
+events()
}
class AccountEventEdge {
<<EdgeNameType>>
+type_name()
}
class AccountEventsConnection {
<<ConnectionNameType>>
+type_name()
}
AccountQuery ..> Account : returns
AccountQuery ..> AccountEventsConnection : uses
AccountQuery ..> AccountEventEdge : uses