tonlib_core/wallet/versioned/
highload_v2.rs

1use crate::cell::{ArcCell, CellBuilder, CellParser, TonCellError};
2use crate::tlb_types::primitives::reference::Ref;
3use crate::tlb_types::tlb::TLB;
4use crate::types::TonHash;
5
6/// WalletVersion::HighloadV2R2
7#[derive(Clone, Debug)]
8pub struct WalletDataHighloadV2R2 {
9    pub wallet_id: i32,
10    pub last_cleaned_time: u64,
11    pub public_key: TonHash,
12    pub queries: Option<Ref<ArcCell>>,
13}
14
15impl WalletDataHighloadV2R2 {
16    pub fn new(wallet_id: i32, public_key: TonHash) -> Self {
17        Self {
18            wallet_id,
19            last_cleaned_time: 0,
20            public_key,
21            queries: None,
22        }
23    }
24}
25
26impl TLB for WalletDataHighloadV2R2 {
27    fn read_definition(parser: &mut CellParser) -> Result<Self, TonCellError> {
28        Ok(Self {
29            wallet_id: parser.load_i32(32)?,
30            last_cleaned_time: parser.load_u64(64)?,
31            public_key: parser.load_tonhash()?,
32            queries: TLB::read(parser)?,
33        })
34    }
35
36    fn write_definition(&self, dst: &mut CellBuilder) -> Result<(), TonCellError> {
37        dst.store_i32(32, self.wallet_id)?;
38        dst.store_u64(64, self.last_cleaned_time)?;
39        dst.store_tonhash(&self.public_key)?;
40        self.queries.write(dst)?;
41        Ok(())
42    }
43}