Skip to content

Commit f6eb99b

Browse files
SildDmitrii Korchagin
andauthored
use filename.rs instead of mod.rs everywhere (#98)
Co-authored-by: Dmitrii Korchagin <d.korchagin@ston.fi>
1 parent 4a783ed commit f6eb99b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+250
-247
lines changed

examples/ton_transfer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ mod example {
1010
use std::time::Duration;
1111
use ton_lib::block_tlb::{Coins, CommonMsgInfoInt, Msg};
1212
use ton_lib::block_tlb::{CommonMsgInfo, CurrencyCollection};
13-
use ton_lib::clients::tl_client::tl::client::TLClientTrait;
14-
use ton_lib::clients::tl_client::TLClient;
15-
use ton_lib::clients::tl_client::TLClientConfig;
16-
use ton_lib::contracts::contract_client::{ContractClient, ContractClientConfig};
1713
use ton_lib::contracts::tl_provider::TLProvider;
14+
use ton_lib::contracts::{ContractClient, ContractClientConfig};
1815
use ton_lib::contracts::{TonContract, TonWalletContract, TonWalletMethods};
1916
use ton_lib::sys_utils::sys_tonlib_set_verbosity_level;
17+
use ton_lib::tl_client::tl::client::TLClientTrait;
18+
use ton_lib::tl_client::TLClient;
19+
use ton_lib::tl_client::TLClientConfig;
2020
use ton_lib::wallet::WalletVersion;
2121
use ton_lib::wallet::{Mnemonic, TonWallet};
2222
use ton_lib_core::cell::TonCell;

ton/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ton_lib"
3-
version = "0.0.39"
3+
version = "0.0.1"
44
description.workspace = true
55
keywords.workspace = true
66
edition.workspace = true
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(test)]
22
mod _test_block_data;
33

4-
mod account;
4+
mod account_types;
55
mod block_types;
66
mod coins;
77
mod config_types;
@@ -13,7 +13,7 @@ mod state_init;
1313
mod tvm_types;
1414
mod tx_types;
1515

16-
pub use account::*;
16+
pub use account_types::*;
1717
pub use block_types::*;
1818
pub use coins::*;
1919
pub use config_types::*;

ton/src/block_tlb/account_types.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mod account_state;
2+
mod account_status;
3+
mod account_storage;
4+
mod shard_account;
5+
6+
pub use account_state::*;
7+
pub use account_status::*;
8+
pub use account_storage::*;
9+
pub use shard_account::*;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use crate::block_tlb::StateInit;
2+
use ton_lib_core::cell::TonHash;
3+
use ton_lib_core::TLB;
4+
5+
#[derive(Debug, Clone, PartialEq, TLB)]
6+
pub enum AccountState {
7+
Uninit(AccountStateUninit),
8+
Frozen(AccountStateFrozen),
9+
Active(AccountStateActive),
10+
}
11+
12+
#[derive(Debug, Clone, PartialEq, TLB)]
13+
#[tlb(prefix = 0b00, bits_len = 2)]
14+
pub struct AccountStateUninit;
15+
16+
#[derive(Debug, Clone, PartialEq, TLB)]
17+
#[tlb(prefix = 0b01, bits_len = 2)]
18+
pub struct AccountStateFrozen {
19+
pub state_hash: TonHash,
20+
}
21+
22+
#[derive(Debug, Clone, PartialEq, TLB)]
23+
#[tlb(prefix = 0b1, bits_len = 1)]
24+
pub struct AccountStateActive {
25+
pub state_init: StateInit,
26+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use ton_lib_core::TLB;
2+
3+
// https://github.com/ton-blockchain/ton/blob/ed4682066978f69ffa38dd98912ca77d4f660f66/crypto/block/block.tlb#L271
4+
#[derive(Debug, Clone, PartialEq, TLB)]
5+
pub enum AccountStatus {
6+
Uninit(AccountStatusUninit),
7+
Frozen(AccountStatusFrozen),
8+
Active(AccountStatusActive),
9+
NonExist(AccountStatusNotExist),
10+
}
11+
12+
#[derive(Debug, Clone, PartialEq, TLB)]
13+
#[tlb(prefix = 0b00, bits_len = 2)]
14+
pub struct AccountStatusUninit;
15+
16+
#[derive(Debug, Clone, PartialEq, TLB)]
17+
#[tlb(prefix = 0b01, bits_len = 2)]
18+
pub struct AccountStatusFrozen;
19+
20+
#[derive(Debug, Clone, PartialEq, TLB)]
21+
#[tlb(prefix = 0b10, bits_len = 2)]
22+
pub struct AccountStatusActive;
23+
24+
#[derive(Debug, Clone, PartialEq, TLB)]
25+
#[tlb(prefix = 0b11, bits_len = 2)]
26+
pub struct AccountStatusNotExist;
27+
28+
impl Default for AccountStatus {
29+
fn default() -> Self { AccountStatus::NonExist(AccountStatusNotExist) }
30+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
use crate::block_tlb::*;
2+
use ton_lib_core::cell::TonHash;
3+
use ton_lib_core::types::tlb_core::VarLenBytes;
4+
use ton_lib_core::TLB;
5+
6+
#[derive(Debug, Clone, PartialEq, TLB)]
7+
pub struct StorageUsed {
8+
pub cells: VarLenBytes<u64, 3>,
9+
pub bits: VarLenBytes<u64, 3>,
10+
}
11+
12+
#[derive(Debug, Clone, PartialEq, TLB)]
13+
pub struct StorageInfo {
14+
pub used: StorageUsed,
15+
pub storage_extra: MaybeStorageExtraInfo,
16+
pub last_paid: u32,
17+
pub due_payment: Option<Coins>,
18+
}
19+
20+
#[derive(Debug, Clone, PartialEq, TLB)]
21+
pub struct AccountStorage {
22+
pub last_tx_lt: u64,
23+
pub balance: CurrencyCollection,
24+
pub state: AccountState,
25+
}
26+
27+
#[derive(Debug, Clone, PartialEq, TLB)]
28+
pub enum MaybeStorageExtraInfo {
29+
None(StorageExtraInfoNone),
30+
Info(StorageExtraInfo),
31+
}
32+
33+
#[derive(Debug, Clone, PartialEq, TLB)]
34+
#[tlb(prefix = 0b000, bits_len = 3)]
35+
pub struct StorageExtraInfoNone;
36+
37+
#[derive(Debug, Clone, PartialEq, TLB)]
38+
#[tlb(prefix = 0b001, bits_len = 3)]
39+
pub struct StorageExtraInfo {
40+
pub dict_hash: TonHash,
41+
}

ton/src/block_tlb/account.rs renamed to ton/src/block_tlb/account_types/shard_account.rs

Lines changed: 6 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::block_tlb::{Coins, CurrencyCollection, StateInit};
1+
use crate::block_tlb::*;
22
use crate::tlb_adapters::TLBRef;
33
use ton_lib_core::cell::{TonCellRef, TonHash};
4-
use ton_lib_core::types::tlb_core::{MsgAddressInt, VarLenBytes};
4+
use ton_lib_core::types::tlb_core::MsgAddressInt;
55
use ton_lib_core::TLB;
66

77
#[derive(Default, Debug, Clone, PartialEq, TLB)]
@@ -33,91 +33,6 @@ pub struct Account {
3333
pub storage: AccountStorage,
3434
}
3535

36-
#[derive(Debug, Clone, PartialEq, TLB)]
37-
pub struct StorageUsed {
38-
pub cells: VarLenBytes<u64, 3>,
39-
pub bits: VarLenBytes<u64, 3>,
40-
}
41-
42-
#[derive(Debug, Clone, PartialEq, TLB)]
43-
pub struct StorageInfo {
44-
pub used: StorageUsed,
45-
pub storage_extra: MaybeStorageExtraInfo,
46-
pub last_paid: u32,
47-
pub due_payment: Option<Coins>,
48-
}
49-
50-
#[derive(Debug, Clone, PartialEq, TLB)]
51-
pub struct AccountStorage {
52-
pub last_tx_lt: u64,
53-
pub balance: CurrencyCollection,
54-
pub state: AccountState,
55-
}
56-
57-
#[derive(Debug, Clone, PartialEq, TLB)]
58-
pub enum MaybeStorageExtraInfo {
59-
None(StorageExtraInfoNone),
60-
Info(StorageExtraInfo),
61-
}
62-
63-
#[derive(Debug, Clone, PartialEq, TLB)]
64-
#[tlb(prefix = 0b000, bits_len = 3)]
65-
pub struct StorageExtraInfoNone;
66-
67-
#[derive(Debug, Clone, PartialEq, TLB)]
68-
#[tlb(prefix = 0b001, bits_len = 3)]
69-
pub struct StorageExtraInfo {
70-
pub dict_hash: TonHash,
71-
}
72-
73-
#[derive(Debug, Clone, PartialEq, TLB)]
74-
pub enum AccountState {
75-
Uninit(AccountStateUninit),
76-
Frozen(AccountStateFrozen),
77-
Active(AccountStateActive),
78-
}
79-
80-
#[derive(Debug, Clone, PartialEq, TLB)]
81-
#[tlb(prefix = 0b00, bits_len = 2)]
82-
pub struct AccountStateUninit;
83-
84-
#[derive(Debug, Clone, PartialEq, TLB)]
85-
#[tlb(prefix = 0b01, bits_len = 2)]
86-
pub struct AccountStateFrozen {
87-
pub state_hash: TonHash,
88-
}
89-
90-
#[derive(Debug, Clone, PartialEq, TLB)]
91-
#[tlb(prefix = 0b1, bits_len = 1)]
92-
pub struct AccountStateActive {
93-
pub state_init: StateInit,
94-
}
95-
96-
// https://github.com/ton-blockchain/ton/blob/ed4682066978f69ffa38dd98912ca77d4f660f66/crypto/block/block.tlb#L271
97-
#[derive(Debug, Clone, PartialEq, TLB)]
98-
pub enum AccountStatus {
99-
Uninit(AccountStatusUninit),
100-
Frozen(AccountStatusFrozen),
101-
Active(AccountStatusActive),
102-
NonExist(AccountStatusNotExist),
103-
}
104-
105-
#[derive(Debug, Clone, PartialEq, TLB)]
106-
#[tlb(prefix = 0b00, bits_len = 2)]
107-
pub struct AccountStatusUninit;
108-
109-
#[derive(Debug, Clone, PartialEq, TLB)]
110-
#[tlb(prefix = 0b01, bits_len = 2)]
111-
pub struct AccountStatusFrozen;
112-
113-
#[derive(Debug, Clone, PartialEq, TLB)]
114-
#[tlb(prefix = 0b10, bits_len = 2)]
115-
pub struct AccountStatusActive;
116-
117-
#[derive(Debug, Clone, PartialEq, TLB)]
118-
#[tlb(prefix = 0b11, bits_len = 2)]
119-
pub struct AccountStatusNotExist;
120-
12136
impl ShardAccount {
12237
pub const NON_EXIST: ShardAccount = ShardAccount {
12338
account: MaybeAccount::None(AccountNone),
@@ -126,10 +41,6 @@ impl ShardAccount {
12641
};
12742
}
12843

129-
impl Default for AccountStatus {
130-
fn default() -> Self { AccountStatus::NonExist(AccountStatusNotExist) }
131-
}
132-
13344
impl Default for MaybeAccount {
13445
fn default() -> Self { MaybeAccount::None(AccountNone) }
13546
}
@@ -152,14 +63,16 @@ impl MaybeAccount {
15263
#[cfg(test)]
15364
mod tests {
15465
use super::*;
155-
use crate::block_tlb::{SimpleLib, TickTock};
66+
use crate::block_tlb::{CurrencyCollection, SimpleLib, StateInit, TickTock};
15667
use std::collections::HashMap;
15768

69+
use crate::block_tlb::account_types::account_state::AccountState;
70+
use crate::block_tlb::account_types::account_storage::{StorageExtraInfoNone, StorageUsed};
15871
use std::str::FromStr;
15972
use tokio_test::assert_ok;
16073
use ton_lib_core::cell::TonCell;
16174
use ton_lib_core::traits::tlb::TLB;
162-
use ton_lib_core::types::tlb_core::{MsgAddressIntStd, VarLen};
75+
use ton_lib_core::types::tlb_core::{MsgAddressIntStd, VarLen, VarLenBytes};
16376

16477
#[test]
16578
fn test_block_tlb_account_some() -> anyhow::Result<()> {

0 commit comments

Comments
 (0)