1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "256"] // Enables certain tests of deep typed SBOR to function

#[cfg(not(any(feature = "std", feature = "alloc")))]
compile_error!("Either feature `std` or `alloc` must be enabled for this crate.");
#[cfg(all(feature = "std", feature = "alloc"))]
compile_error!("Feature `std` and `alloc` can't be enabled at the same time.");

pub mod api;
pub mod blueprints;
pub mod constants;
pub mod hooks;
pub mod traits;
pub mod types;

mod macros;
pub use macros::*;

// Re-export scrypto schema
pub mod schema {
    pub use scrypto_schema::*;
}

// Re-export radix engine common.
pub extern crate radix_engine_common;
pub use radix_engine_common::*;

// Re-export SBOR derive.
pub extern crate sbor;
pub use sbor::{Categorize, Decode, Encode, Sbor};

// extern crate self as X; in lib.rs allows ::X and X to resolve to this crate inside this crate.
// This enables procedural macros which output code involving paths to this crate, to work inside
// this crate. See this link for details:
// https://users.rust-lang.org/t/how-can-i-use-my-derive-macro-from-the-crate-that-declares-the-trait/60502
//
// IMPORTANT:
// This should never be pub, else `X::X::X::X::...` becomes a valid path in downstream crates,
// which we've discovered can cause really bad autocomplete times (when combined with other
// specific imports, generic traits, resolution paths which likely trigger edge cases in
// Rust Analyzer which get stuck on these infinite possible paths)
extern crate self as radix_engine_interface;

/// Each module should have its own prelude, which:
/// * Adds preludes of upstream crates
/// * Exports types with specific-enough names which mean they can safely be used downstream.
///
/// The idea is that we can just include the current crate's prelude and avoid messing around with tons of includes.
/// This makes refactors easier, and makes integration into the node less painful.
pub mod prelude {
    // Extern crates for the purposes of EG being visible from
    // scrypto macros
    pub extern crate radix_engine_common;

    // Exports from upstream crates
    pub use radix_engine_common::prelude::*;

    // Exports from this crate
    pub use crate::api::field_api::*;
    pub use crate::api::node_modules::metadata::*;
    pub use crate::api::*;
    pub use crate::blueprints::resource::*;
    pub use crate::schema::*;
    pub use crate::traits::*;
    pub use crate::types::*;
    pub use crate::{
        access_and_or, access_rule_node, burn_roles, dec, deposit_roles, freeze_roles,
        internal_roles, metadata, metadata_init, metadata_init_set_entry, metadata_roles,
        mint_roles, non_fungible_data_update_roles, pdec, recall_roles, role_entry, roles2, rule,
        withdraw_roles,
    };
}

pub(crate) mod internal_prelude {
    pub use crate::prelude::*;
}