mod.rs

Overview

This file defines the data structures, enums, and GraphQL schema objects related to blockchain transactions within the system. It provides comprehensive representations of transaction details, status, types, and associated actions, bounces, computation, storage, credit, and split information. The file implements conversions from database transaction records to GraphQL-friendly transaction models and includes format helpers for large integer fields.

The core purpose of the file is to bridge the raw blockchain transaction data (from the database layer) to a structured, strongly typed, and GraphQL-exposable format. It supports querying, filtering, and loading transaction data with rich metadata and status information.


Enums

TransactionProcessingStatusEnum

Represents the processing status of a blockchain transaction.

Variant

Description

Unknown

Status is unknown

Preliminary

Transaction is preliminary

Proposed

Transaction is proposed

Finalized

Transaction is finalized

Refused

Transaction has been refused

Usage: Used to indicate the current state of a transaction during processing.


TransactionTypeEnum

Enumerates the type of transaction according to the blockchain specification clause 4.2.4.

Variant

Description

Ordinary

Standard transaction

Storage

Storage related transaction

Tick

Tick transaction

Tock

Tock transaction

SplitPrepare

Split preparation

SplitInstall

Split installation

MergePrepare

Merge preparation

MergeInstall

Merge installation


BounceTypeEnum

Describes the type of bounce for a transaction message.

Variant

Description

NegFunds

Negative funds

NoFunds

No funds available

Ok

Bounce status OK or no bounce


ComputeTypeEnum

Type of computation performed during transaction execution.

Variant

Description

Skipped

Compute phase skipped

Vm

Virtual Machine execution


SkipReasonEnum

Reasons for skipping the compute phase.

Variant

Reason Description

NoState

No state available

BadState

Invalid or corrupted state

NoGas

Insufficient gas


Structs and GraphQL Objects

TransactionAction

Represents detailed information about the actions performed in a transaction.

Field

Type

Description

action_list_hash

String

Hash of the action list

msgs_created

Option

Number of messages created

no_funds

bool

Indicates if there were insufficient funds for outbound message creation

result_arg

Option

Result argument code

result_code

i32

Result code of the action

skipped_actions

i16

Number of skipped actions

spec_actions

i16

Number of specialized actions

status_change

u8

Status change code

status_change_name

AccountStatusChangeEnum

Enum variant representing the status change

success

bool

Indicates if the action succeeded

tot_actions

i16

Total number of actions

tot_msg_size_bits

Option

Total message size in bits

tot_msg_size_cells

Option

Total message size in cells

total_fwd_fees

Option

Total forwarding fees (hidden from GraphQL)

total_action_fees

Option

Total fees for actions (hidden from GraphQL)

valid

bool

Validity flag

ComplexObject Methods:


TransactionBounce

Details about message bounce behavior and fees.

Field

Type

Description

bounce_type

Option

Bounce type code

bounce_type_name

Option

Bounce type enum variant

fwd_fees

Option

Forwarding fees (hidden from GraphQL)

msg_fees

Option

Message fees (hidden from GraphQL)

msg_size_bits

Option

Message size in bits

msg_size_cells

Option

Message size in cells

req_fwd_fees

Option

Required forwarding fees (hidden from GraphQL)

ComplexObject Methods:


TransactionCompute

Information about the compute phase of transaction execution.

Field

Type

Description

account_activated

bool

Indicates if the account was activated during compute phase

compute_type

u8

Compute type code

compute_type_name

ComputeTypeEnum

Enum representing compute type

exit_arg

Option

Exit argument from compute

exit_code

Option

Exit code (0 or 1 indicates success)

gas_credit

Option

Gas credit available

gas_fees

Option

Gas fees collected (hidden from GraphQL)

gas_limit

Option

Gas limit for the TVM instance (hidden from GraphQL)

gas_used

Option

Gas used (hidden from GraphQL)

mode

i8

Mode of computation

msg_state_used

bool

Whether state from message was used

skipped_reason

Option

Reason for skipping compute phase

success

bool

Whether computation succeeded

vm_final_state_hash

String

Final VM state hash

vm_init_state_hash

String

Initial VM state hash

vm_steps

u64

Number of VM steps executed

ComplexObject Methods:


TransactionCredit

Represents credit information related to a transaction.

Field

Type

Description

credit

Option

Credit amount (hidden from GraphQL)

dummy

Option

Dummy field, hidden from GraphQL

ComplexObject Methods:


TransactionSplitInfo

Information related to split transactions.

Field

Type

Description

acc_split_depth

Option

Account split depth

cur_shard_pfx_len

Option

Current shard prefix length

sibling_addr

Option

Sibling address in split

this_addr

Option

Current address


TransactionStorage

Storage-related transaction fee details.

Field

Type

Description

status_change

Option

Status change code

status_change_name

Option

Enum for status change

storage_fees_collected

Option

Storage fees collected (hidden from GraphQL)

storage_fees_due

Option

Storage fees due (hidden from GraphQL)

ComplexObject Methods:


Transaction

The main struct representing a blockchain transaction with all associated metadata, actions, messages, and status.

Field

Type

Description

id

String

Unique transaction identifier

aborted

bool

Whether the transaction was aborted

account_addr

Option

Address of the account related to the transaction

action

TransactionAction

Detailed transaction action data

balance_delta

Option

Account balance change after transaction

block_id

String

Identifier of the block containing the transaction

boc

String

Binary object code of the transaction

bounce

Option

Bounce information

chain_order

String

Chain order for pagination and sorting

code_hash

Option

Code hash of the account before execution

compute

TransactionCompute

Compute phase information

credit

Option

Credit information

credit_first

bool

Flag indicating credit priority

destroyed

bool

Whether the account was destroyed

end_status

u8

End status code

end_status_name

AccountStatusEnum

Enum variant of end status

ext_in_msg_fee

Option

Fee for inbound external message import

in_message

Option

Inbound message object

in_msg

String

Inbound message hash

installed

Option

Whether the contract is installed

lt

Option

Logical time of the transaction

master_seq_no

Option

Masterchain sequence number

new_hash

Option

New state hash after transaction

now

u64

Timestamp of the transaction

now_string

String

Timestamp as string

old_hash

Option

Previous state hash before transaction

orig_status

u8

Original status code

orig_status_name

AccountStatusEnum

Enum variant of original status

out_messages

Option<Vec<Option>>

Outbound messages

out_msgs

Vec

Outbound message hashes

outmsg_cnt

u16

Number of outbound messages

prepare_transaction

Option

Optional prepared transaction data

prev_trans_hash

Option

Previous transaction hash

prev_trans_lt

Option

Previous transaction logical time

proof

Option

Proof related to transaction

split_info

Option

Split transaction information

status

u8

Processing status code

status_name

TransactionProcessingStatusEnum

Enum variant of status

storage

TransactionStorage

Storage phase details

total_fees

Option

Total fees collected

tr_type

u8

Transaction type code

tr_type_name

TransactionTypeEnum

Enum variant of transaction type

tt

Option

Virtual machine debug trace

workchain_id

i32

Workchain ID of the account address

ComplexObject Methods:


Implementations and Conversions

From primitive types to enums

The file implements From trait conversions to map primitive integer values into their corresponding enum variants for:

This allows easy casting from stored integer codes (e.g., from database) to meaningful enum types used in code and GraphQL interface.


From Database Transaction to GraphQL Transaction

The Fromdb::Transaction trait implementation converts a database transaction record into the GraphQL Transaction model. During this conversion:


Interaction with Other Parts of the System


Important Implementation Details


Usage Examples

Creating a Transaction from a database transaction record

let db_trx: db::Transaction = get_transaction_from_db(id);
let trx: Transaction = db_trx.into();

Querying formatted total fees in a GraphQL resolver

async fn total_fees(&self, format: Option<BigIntFormat>) -> Option<String> {
    self.total_fees(format).await
}

Mermaid Class Diagram

classDiagram
    class Transaction {
        +id: String
        +aborted: bool
        +account_addr: Option<String>
        +action: TransactionAction
        +balance_delta: Option<String>
        +block_id: String
        +boc: String
        +bounce: Option<TransactionBounce>
        +chain_order: String
        +code_hash: Option<String>
        +compute: TransactionCompute
        +credit: Option<TransactionCredit>
        +credit_first: bool
        +destroyed: bool
        +end_status: u8
        +end_status_name: AccountStatusEnum
        +ext_in_msg_fee: Option<String>
        +in_message: Option<Message>
        +in_msg: String
        +installed: Option<bool>
        +lt: Option<String>
        +master_seq_no: Option<f64>
        +new_hash: Option<String>
        +now: u64
        +now_string: String
        +old_hash: Option<String>
        +orig_status: u8
        +orig_status_name: AccountStatusEnum
        +out_messages: Option<Vec<Option<Message>>>
        +out_msgs: Vec<String>
        +outmsg_cnt: u16
        +prepare_transaction: Option<String>
        +prev_trans_hash: Option<String>
        +prev_trans_lt: Option<String>
        +proof: Option<String>
        +split_info: Option<TransactionSplitInfo>
        +status: u8
        +status_name: TransactionProcessingStatusEnum
        +storage: TransactionStorage
        +total_fees: Option<String>
        +tr_type: u8
        +tr_type_name: TransactionTypeEnum
        +tt: Option<String>
        +workchain_id: i32
    }

    class TransactionAction {
        +action_list_hash: String
        +msgs_created: Option<i16>
        +no_funds: bool
        +result_arg: Option<i32>
        +result_code: i32
        +skipped_actions: i16
        +spec_actions: i16
        +status_change: u8
        +status_change_name: AccountStatusChangeEnum
        +success: bool
        +tot_actions: i16
        +tot_msg_size_bits: Option<f64>
        +tot_msg_size_cells: Option<f64>
        +valid: bool
    }

    class TransactionBounce {
        +bounce_type: Option<i32>
        +bounce_type_name: Option<BounceTypeEnum>
        +msg_size_bits: Option<f64>
        +msg_size_cells: Option<f64>
    }

    class TransactionCompute {
        +account_activated: bool
        +compute_type: u8
        +compute