abi.rs
Overview
The abi.rs file serves as a centralized repository for Ethereum-style contract interface definitions (ABIs) and associated binary contract data used within the system. It statically includes JSON ABI files and a TVC (TON Virtual Cell) binary for smart contracts related to the BlockKeeper system. These constants enable other components of the system to interact with deployed smart contracts by providing the necessary contract interface descriptions and compiled bytecode.
This file does not contain executable logic or functions but provides essential static data that represent the contract interfaces for use in contract calls, encoding/decoding contract messages, and deployment operations.
Constants
The file defines the following public static constants:
1. EPOCH_ABI: &str
Description: Contains the JSON ABI of the
BlockKeeperEpochContract.Source: Loaded from ../../../contracts/bksystem/BlockKeeperEpochContract.abi.json.
Usage: Used for encoding and decoding interactions with the BlockKeeper Epoch smart contract, which manages epoch-related operations in the blockchain system.
Type:
&str(string slice representing the JSON ABI).
2. PREEPOCH_ABI: &str
Description: Contains the JSON ABI of the
BlockKeeperPreEpochContract.Source: Loaded from ../../../contracts/bksystem/BlockKeeperPreEpochContract.abi.json.
Usage: Used for interacting with the Pre-Epoch contract, which likely handles preliminary or preparatory epoch state management.
Type:
&str.
3. BLOCK_KEEPER_WALLET_ABI: &str
Description: Contains the JSON ABI of the
AckiNackiBlockKeeperNodeWallet.Source: Loaded from ../../../contracts/bksystem/AckiNackiBlockKeeperNodeWallet.abi.json.
Usage: Facilitates interactions with the wallet contract used by BlockKeeper nodes, enabling wallet-related operations such as transfers, balance queries, and signing.
Type:
&str.
4. BLOCK_KEEPER_WALLET_TVC: &[u8]
Description: Contains the compiled TVC (TON Virtual Cell) bytecode of the
AckiNackiBlockKeeperNodeWalletcontract.Source: Loaded from ../../../contracts/bksystem/AckiNackiBlockKeeperNodeWallet.tvc.
Usage: Used for deploying or verifying the wallet contract on the blockchain.
Type: Byte slice (
&[u8]).
5. BLOCK_MANAGER_LICENSE_ABI: &str
Description: Contains the JSON ABI of the
LicenseBMcontract.Source: Loaded from ../../../contracts/bksystem/LicenseBM.abi.json.
Usage: Used for interacting with the license management contract within the BlockKeeper system, possibly to manage permissions and licenses.
Type:
&str.
Implementation Details
The file uses Rust's
include_str!andinclude_bytes!macros to embed external contract files directly into the compiled binary. This approach ensures that the ABI and bytecode data are bundled with the application, eliminating the need to load these files at runtime from the filesystem.The paths to the contract files are relative, pointing to a contracts/bksystem directory located three levels above the source file location. This indicates an organized project structure separating contract artifacts from source code.
The use of static constants makes these ABIs and bytecode immutable and accessible globally across the application.
Interaction with Other System Components
Components responsible for blockchain interaction, such as transaction builders, contract callers, and deployment modules, utilize these constants to access contract ABIs and bytecode.
The ABIs are critical for serializing method calls and decoding contract events, facilitating the communication between off-chain logic and on-chain smart contracts.
The wallet contract ABI and TVC are specifically used by node wallet management modules to handle accounts and keys within the BlockKeeper ecosystem.
The license contract ABI supports modules enforcing licensing rules and access control.
This file acts as a shared dependency for any module that performs smart contract interactions related to the BlockKeeper system.
Diagram: Structure of abi.rs
flowchart TD
A[abi.rs] --> B[EPOCH_ABI]
A --> C[PREEPOCH_ABI]
A --> D[BLOCK_KEEPER_WALLET_ABI]
A --> E[BLOCK_KEEPER_WALLET_TVC]
A --> F[BLOCK_MANAGER_LICENSE_ABI]
B["BlockKeeperEpochContract ABI\n(string)"]
C["BlockKeeperPreEpochContract ABI\n(string)"]
D["AckiNackiBlockKeeperNodeWallet ABI\n(string)"]
E["AckiNackiBlockKeeperNodeWallet TVC\n(bytecode)"]
F["LicenseBM ABI\n(string)"]
This diagram illustrates the file's role as a container of static contract data, each representing a distinct smart contract interface or bytecode binary.