rust_chain/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![cfg_attr(not(feature = "std"), feature(alloc_error_handler, panic_info_message, core_intrinsics))]
3
4#[cfg(not(feature = "std"))]
5mod allocator;
6
7#[cfg(not(feature = "std"))]
8#[cfg(not(feature = "wee-alloc"))]
9#[global_allocator]
10static mut ALLOC: allocator::bump::BumpAllocator = allocator::bump::BumpAllocator {};
11
12#[cfg(all(not(feature = "std"), target_arch = "wasm32"))]
13#[allow(unused_variables)]
14#[panic_handler]
15fn panic(info: &core::panic::PanicInfo) -> ! {
16    let msg = format!("{:?}", info.message().unwrap().as_str().unwrap());
17    self::vmapi::eosio::check(false, &msg);
18    core::arch::wasm32::unreachable();
19}
20
21#[cfg(not(feature = "std"))]
22extern crate alloc;
23
24use cfg_if::cfg_if;
25
26#[cfg(feature = "std")]
27pub use chaintester;
28
29#[cfg(feature = "std")]
30pub use chaintester::{
31    ChainTester,
32};
33
34cfg_if! {
35    if #[cfg(feature = "std")] {
36        pub use std::{
37            borrow,
38            boxed,
39            format,
40            string,
41            vec,
42            rc,
43        };
44
45        /// Collection types.
46        pub mod collections {
47            pub use self::{
48                binary_heap::BinaryHeap,
49                btree_map::BTreeMap,
50                btree_set::BTreeSet,
51                linked_list::LinkedList,
52                vec_deque::VecDeque,
53                Bound,
54            };
55            pub use std::collections::*;
56        }
57    } else {
58        pub use alloc::{
59            borrow,
60            boxed,
61            format,
62            string,
63            vec,
64            rc,
65        };
66
67        /// Collection types.
68        pub mod collections {
69            pub use self::{
70                BTreeMap,
71                BTreeSet,
72                BinaryHeap,
73                LinkedList,
74                VecDeque,
75            };
76            pub use alloc::collections::*;
77            pub use core::ops::Bound;
78        }
79    }
80}
81
82
83///
84pub mod vmapi;
85///
86pub mod structs;
87pub use self::structs::*;
88
89///
90pub mod transaction;
91pub use self::transaction::{
92    TransactionExtension,
93    Transaction,
94};
95
96///
97pub mod serializer;
98pub use serializer::{
99    Encoder,
100    Decoder,
101    Packer,
102};
103
104///
105pub mod db;
106pub use db::{
107    PrimaryValueInterface,
108    SecondaryValueInterface,
109    Secondary,
110    Iterator,
111    SecondaryIterator,
112    SecondaryValue,
113    TableI64,
114    Idx64Table,
115    Idx128Table,
116    Idx256Table,
117    IdxF64Table,
118    IdxF128Table,
119    IdxTable,
120    IdxTableProxy,
121};
122
123///
124#[macro_use]
125pub mod print;
126
127///
128pub mod mi;
129
130///
131pub mod mi_not_generic;
132
133///
134pub mod asset;
135pub use asset::{
136    Asset,
137    Symbol,
138};
139
140mod privileged;
141
142///
143pub mod crypto;
144pub use crypto::{
145    assert_sha256,
146    assert_sha1,
147    assert_sha512,
148    assert_ripemd160,
149
150    sha256,
151    sha1,
152    sha512,
153    ripemd160,
154
155    recover_key,
156    assert_recover_key,
157};
158
159pub use self::vmapi::eosio::{
160    get_active_producers,
161    check_transaction_authorization,
162    check_permission_authorization,
163    get_permission_last_used,
164    get_account_creation_time,
165
166    read_action_data,
167    action_data_size,
168    require_recipient,
169    require_auth,
170    has_auth,
171    require_auth2,
172    is_account,
173    send_inline,
174    send_context_free_inline,
175
176    publication_time,
177    current_receiver,
178    check,
179    eosio_assert_code,
180    eosio_exit,
181    current_time,
182    is_feature_activated,
183    get_sender,
184
185    get_resource_limits,
186    set_resource_limits,
187    set_proposed_producers,
188    set_proposed_producers_ex,
189    is_privileged,
190    set_privileged,
191    set_blockchain_parameters,
192    get_blockchain_parameters,
193    preactivate_feature,
194
195    send_deferred,
196    cancel_deferred,
197    read_transaction,
198    transaction_size,
199    tapos_block_num,
200    tapos_block_prefix,
201    expiration,
202    get_action,
203    get_context_free_data,
204};
205
206pub use self::vmapi::eosio_ex::{
207    set_action_return_value,
208    get_block_num,
209};
210
211///
212#[macro_use]
213pub mod name;
214
215pub use name::{
216    SAME_PAYER,
217    ACTIVE,
218    OWNER,
219    CODE,
220};
221
222///
223pub mod action;
224
225pub use action::{
226    PermissionLevel,
227    Action,
228};
229
230///
231pub mod utils;
232///
233pub mod varint;
234
235///
236pub mod binary_extension;
237pub use binary_extension::BinaryExtension;
238
239///
240pub mod intrinsic_abi_types;
241pub use intrinsic_abi_types::*;
242
243pub use eosio_macro::{
244    contract,
245    // chain,
246};
247
248#[cfg(feature = "std")]
249pub use eosio_scale_info;
250
251#[cfg(feature = "std")]
252pub mod abi;