Skip to content

Commit

Permalink
Add new lite_api.tl types
Browse files Browse the repository at this point in the history
  • Loading branch information
hacker-volodya committed Nov 29, 2024
1 parent d54260b commit aee9c1b
Show file tree
Hide file tree
Showing 2 changed files with 257 additions and 1 deletion.
114 changes: 113 additions & 1 deletion liteapi/src/tl/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,31 @@ pub struct LookupBlock {
pub with_prev_blk_signatures: Option<()>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct LookupBlockWithProof {
#[tl(flags)]
pub mode: (),
pub id: BlockId,
pub mc_block_id: BlockIdExt,
#[tl(flags_bit = "mode.0")]
pub seqno: Option<()>,
#[tl(flags_bit = "mode.1")]
pub lt: Option<u64>,
#[tl(flags_bit = "mode.2")]
pub utime: Option<u32>,
#[tl(flags_bit = "mode.4")]
pub with_state_update: Option<()>,
#[tl(flags_bit = "mode.5")]
pub with_value_flow: Option<()>,
#[tl(flags_bit = "mode.8")]
pub with_extra: Option<()>,
#[tl(flags_bit = "mode.9")]
pub with_shard_hashes: Option<()>,
#[tl(flags_bit = "mode.10")]
pub with_prev_blk_signatures: Option<()>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct ListBlockTransactions {
Expand Down Expand Up @@ -271,6 +296,61 @@ pub struct GetLibrariesWithProof {
pub library_list: Vec<Int256>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct GetShardBlockProof {
pub id: BlockIdExt,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct GetOutMsgQueueSizes {
#[tl(flags)]
pub mode: (),
#[tl(flags_bit = "mode.0")]
pub shard_id: Option<(u32, u64)>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct GetBlockOutMsgQueueSize {
#[tl(flags)]
pub mode: (),
pub id: BlockIdExt,
#[tl(flags_bit = "mode.0")]
pub want_proof: Option<()>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct GetDispatchQueueInfo {
#[tl(flags)]
pub mode: (),
pub id: BlockIdExt,
#[tl(flags_bit = "mode.0")]
pub want_proof: Option<()>,
#[tl(flags_bit = "mode.1")]
pub after_addr: Option<Int256>,
pub max_accounts: u32,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct GetDispatchQueueMessages {
#[tl(flags)]
pub mode: (),
pub id: BlockIdExt,
pub addr: Int256,
pub after_lt: u64,
pub max_messages: u32,
#[tl(flags_bit = "mode.0")]
pub want_proof: Option<()>,
#[tl(flags_bit = "mode.1")]
pub one_account: Option<()>,
#[tl(flags_bit = "mode.2")]
pub message_boc: Option<()>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
#[tl(boxed)]
Expand Down Expand Up @@ -311,6 +391,10 @@ pub enum Request {
#[tl(id = 0x6b890e25)]
GetAccountState(GetAccountState),

/// liteServer.getAccountStatePrunned id:tonNode.blockIdExt account:liteServer.accountId = liteServer.AccountState;
#[tl(id = 0x5a698507)]
GetAccountStatePrunned(GetAccountState),

/// liteServer.runSmcMethod mode:# id:tonNode.blockIdExt account:liteServer.accountId method_id:long params:bytes = liteServer.RunMethodResult;
#[tl(id = 0x5cc65dd2)]
RunSmcMethod(RunSmcMethod),
Expand All @@ -335,10 +419,18 @@ pub enum Request {
#[tl(id = 0xfac8f71e)]
LookupBlock(LookupBlock),

/// liteServer.lookupBlockWithProof mode:# id:tonNode.blockId mc_block_id:tonNode.blockIdExt lt:mode.1?long utime:mode.2?int = liteServer.LookupBlockResult;
#[tl(id = 0x9c045ff8)]
LookupBlockWithProof(LookupBlockWithProof),

/// liteServer.listBlockTransactions id:tonNode.blockIdExt mode:# count:# after:mode.7?liteServer.transactionId3 reverse_order:mode.6?true want_proof:mode.5?true = liteServer.BlockTransactions;
#[tl(id = 0xadfcc7da)]
ListBlockTransactions(ListBlockTransactions),

/// liteServer.listBlockTransactionsExt id:tonNode.blockIdExt mode:# count:# after:mode.7?liteServer.transactionId3 reverse_order:mode.6?true want_proof:mode.5?true = liteServer.BlockTransactionsExt;
#[tl(id = 0x0079dd5c)]
ListBlockTransactionsExt(ListBlockTransactions),

/// liteServer.getBlockProof mode:# known_block:tonNode.blockIdExt target_block:mode.0?tonNode.blockIdExt = liteServer.PartialBlockProof;
#[tl(id = 0x8aea9c44)]
GetBlockProof(GetBlockProof),
Expand All @@ -352,7 +444,7 @@ pub enum Request {
GetConfigParams(GetConfigParams),

/// liteServer.getValidatorStats#091a58bc mode:# id:tonNode.blockIdExt limit:int start_after:mode.0?int256 modified_after:mode.2?int = liteServer.ValidatorStats;
#[tl(id = 0xe7253699)]
#[tl(id = 0x091a58bc)]
GetValidatorStats(GetValidatorStats),

/// liteServer.getLibraries library_list:(vector int256) = liteServer.LibraryResult;
Expand All @@ -362,4 +454,24 @@ pub enum Request {
/// liteServer.getLibrariesWithProof id:tonNode.blockIdExt mode:# library_list:(vector int256) = liteServer.LibraryResultWithProof;
#[tl(id = 0xd97693bd)]
GetLibrariesWithProof(GetLibrariesWithProof),

/// liteServer.getShardBlockProof id:tonNode.blockIdExt = liteServer.ShardBlockProof;
#[tl(id = 0x4ca60350)]
GetShardBlockProof(GetShardBlockProof),

/// liteServer.getOutMsgQueueSizes mode:# wc:mode.0?int shard:mode.0?long = liteServer.OutMsgQueueSizes;
#[tl(id = 0x7bc19c36)]
GetOutMsgQueueSizes(GetOutMsgQueueSizes),

/// liteServer.getBlockOutMsgQueueSize mode:# id:tonNode.blockIdExt want_proof:mode.0?true = liteServer.BlockOutMsgQueueSize;
#[tl(id = 0x8f6c7779)]
GetBlockOutMsgQueueSize(GetBlockOutMsgQueueSize),

/// liteServer.getDispatchQueueInfo mode:# id:tonNode.blockIdExt after_addr:mode.1?int256 max_accounts:int want_proof:mode.0?true = liteServer.DispatchQueueInfo;
#[tl(id = 0x01e66bf3)]
GetDispatchQueueInfo(GetDispatchQueueInfo),

/// liteServer.getDispatchQueueMessages mode:# id:tonNode.blockIdExt addr:int256 after_lt:long max_messages:int want_proof:mode.0?true one_account:mode.1?true messages_boc:mode.2?true = liteServer.DispatchQueueMessages;
#[tl(id = 0xbbfd6439)]
GetDispatchQueueMessages(GetDispatchQueueMessages),
}
144 changes: 144 additions & 0 deletions liteapi/src/tl/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ pub struct BlockTransactions {
pub proof: Vec<u8>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct BlockTransactionsExt {
pub id: BlockIdExt,
pub req_count: u32,
pub incomplete: bool,
#[derivative(Debug(format_with = "fmt_bytes"))]
pub transactions: Vec<u8>,
#[derivative(Debug(format_with = "fmt_bytes"))]
pub proof: Vec<u8>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct PartialBlockProof {
Expand Down Expand Up @@ -271,10 +283,118 @@ pub struct LibraryResultWithProof {
#[tl(flags)]
pub mode: (),
pub result: Vec<LibraryEntry>,
#[derivative(Debug(format_with = "fmt_bytes"))]
pub state_proof: Vec<u8>,
#[derivative(Debug(format_with = "fmt_bytes"))]
pub data_proof: Vec<u8>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct ShardBlockLink {
pub id: BlockIdExt,
#[derivative(Debug(format_with = "fmt_bytes"))]
pub proof: Vec<u8>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct ShardBlockProof {
pub masterchain_id: BlockIdExt,
pub links: Vec<ShardBlockLink>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct LookupBlockResult {
pub id: BlockIdExt,
#[tl(flags)]
pub mode: (),
pub mc_block_id: BlockIdExt,
#[derivative(Debug(format_with = "fmt_bytes"))]
pub client_mc_state_proof: Vec<u8>,
#[derivative(Debug(format_with = "fmt_bytes"))]
pub mc_block_proof: Vec<u8>,
pub shard_links: Vec<ShardBlockLink>,
#[derivative(Debug(format_with = "fmt_bytes"))]
pub header: Vec<u8>,
#[derivative(Debug(format_with = "fmt_bytes"))]
pub prev_header: Vec<u8>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct OutMsgQueueSize {
pub id: BlockIdExt,
pub size: u32,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct OutMsgQueueSizes {
pub shards: Vec<OutMsgQueueSize>,
pub ext_msg_queue_size_limit: u32,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct BlockOutMsgQueueSize {
#[tl(flags)]
pub mode: (),
pub id: BlockIdExt,
pub size: u64,
#[tl(flags_bit = "mode.0")]
#[derivative(Debug(format_with = "fmt_opt_bytes"))]
pub proof: Option<Vec<u8>>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct AccountDispatchQueueInfo {
pub addr: Int256,
pub size: u64,
pub min_lt: u64,
pub max_lt: u64,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct DispatchQueueInfo {
#[tl(flags)]
pub mode: (),
pub id: BlockIdExt,
pub account_dispatch_queues: Vec<AccountDispatchQueueInfo>,
pub complete: bool,
#[tl(flags_bit = "mode.0")]
#[derivative(Debug(format_with = "fmt_opt_bytes"))]
pub proof: Option<Vec<u8>>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct DispatchQueueMessage {
pub addr: Int256,
pub lt: u64,
pub hash: Int256,
pub metadata: TransactionMetadata,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct DispatchQueueMessages {
#[tl(flags)]
pub mode: (),
pub id: BlockIdExt,
pub messages: Vec<DispatchQueueMessage>,
pub complete: bool,
#[tl(flags_bit = "mode.0")]
#[derivative(Debug(format_with = "fmt_opt_bytes"))]
pub proof: Option<Vec<u8>>,
#[tl(flags_bit = "mode.2")]
#[derivative(Debug(format_with = "fmt_opt_bytes"))]
pub messages_boc: Option<Vec<u8>>,
}

#[derive(TlRead, TlWrite, Derivative)]
#[derivative(Debug, Clone, PartialEq)]
pub struct Error {
Expand Down Expand Up @@ -371,6 +491,30 @@ pub enum Response {
#[tl(id = 0x10a927bf)]
LibraryResultWithProof(LibraryResultWithProof),

/// liteServer.shardBlockProof masterchain_id:tonNode.blockIdExt links:(vector liteServer.shardBlockLink) = liteServer.ShardBlockProof;
#[tl(id = 0x1d62a07a)]
ShardBlockProof(ShardBlockProof),

/// liteServer.lookupBlockResult id:tonNode.blockIdExt mode:# mc_block_id:tonNode.blockIdExt client_mc_state_proof:bytes mc_block_proof:bytes shard_links:(vector liteServer.shardBlockLink) header:bytes prev_header:bytes = liteServer.LookupBlockResult;
#[tl(id = 0x99786be7)]
LookupBlockResult(LookupBlockResult),

/// liteServer.outMsgQueueSizes shards:(vector liteServer.outMsgQueueSize) ext_msg_queue_size_limit:int = liteServer.OutMsgQueueSizes;
#[tl(id = 0xf8504a03)]
OutMsgQueueSizes(OutMsgQueueSizes),

/// liteServer.blockOutMsgQueueSize mode:# id:tonNode.blockIdExt size:long proof:mode.0?bytes = liteServer.BlockOutMsgQueueSize;
#[tl(id = 0x8acdbe1b)]
BlockOutMsgQueueSize(BlockOutMsgQueueSize),

/// liteServer.dispatchQueueInfo mode:# id:tonNode.blockIdExt account_dispatch_queues:(vector liteServer.accountDispatchQueueInfo) complete:Bool proof:mode.0?bytes = liteServer.DispatchQueueInfo;
#[tl(id = 0x5d1132d0)]
DispatchQueueInfo(DispatchQueueInfo),

/// liteServer.dispatchQueueMessages mode:# id:tonNode.blockIdExt messages:(vector liteServer.dispatchQueueMessage) complete:Bool proof:mode.0?bytes messages_boc:mode.2?bytes = liteServer.DispatchQueueMessages;
#[tl(id = 0x4b407931)]
DispatchQueueMessages(DispatchQueueMessages),

/// liteServer.error code:int message:string = liteServer.Error;
#[tl(id = 0xbba9e148)]
Error(Error),
Expand Down

0 comments on commit aee9c1b

Please sign in to comment.