alloy_primitives/
lib.rs

1#![doc = include_str!("../README.md")]
2#![doc(
3    html_logo_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/alloy.jpg",
4    html_favicon_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/favicon.ico"
5)]
6#![cfg_attr(not(test), warn(unused_crate_dependencies))]
7#![cfg_attr(not(feature = "std"), no_std)]
8#![cfg_attr(feature = "nightly", feature(hasher_prefixfree_extras))]
9#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
10
11#[macro_use]
12extern crate alloc;
13
14use paste as _;
15#[cfg(feature = "sha3-keccak")]
16use sha3 as _;
17use tiny_keccak as _;
18
19#[cfg(feature = "postgres")]
20pub mod postgres;
21
22#[cfg(feature = "diesel")]
23pub mod diesel;
24
25pub mod aliases;
26#[doc(no_inline)]
27pub use aliases::{
28    BlockHash, BlockNumber, BlockTimestamp, ChainId, Selector, StorageKey, StorageValue, TxHash,
29    TxIndex, TxNonce, TxNumber, B128, B256, B512, B64, I128, I16, I160, I256, I32, I64, I8, U128,
30    U16, U160, U256, U32, U512, U64, U8,
31};
32
33#[macro_use]
34mod bits;
35pub use bits::{
36    Address, AddressChecksumBuffer, AddressError, Bloom, BloomInput, FixedBytes, Function,
37    BLOOM_BITS_PER_ITEM, BLOOM_SIZE_BITS, BLOOM_SIZE_BYTES,
38};
39
40#[path = "bytes/mod.rs"]
41mod bytes_;
42pub use self::bytes_::Bytes;
43
44mod common;
45pub use common::TxKind;
46
47mod log;
48pub use log::{logs_bloom, IntoLogData, Log, LogData};
49
50#[cfg(feature = "map")]
51pub mod map;
52
53mod sealed;
54pub use sealed::{Sealable, Sealed};
55
56mod signed;
57pub use signed::{BigIntConversionError, ParseSignedError, Sign, Signed};
58
59mod signature;
60#[allow(deprecated)]
61pub use signature::PrimitiveSignature;
62pub use signature::{normalize_v, to_eip155_v, Signature, SignatureError};
63
64pub mod utils;
65pub use utils::{eip191_hash_message, keccak256, Keccak256, KECCAK256_EMPTY};
66
67#[doc(hidden)] // Use `hex` directly instead!
68pub mod hex_literal;
69
70#[doc(no_inline)]
71pub use {
72    ::bytes,
73    ::hex,
74    ruint::{self, uint, Uint},
75};
76
77#[cfg(feature = "serde")]
78#[doc(no_inline)]
79pub use ::hex::serde as serde_hex;
80
81/// 20-byte [fixed byte-array][FixedBytes] type.
82///
83/// You'll likely want to use [`Address`] instead, as it is a different type
84/// from `FixedBytes<20>`, and implements methods useful for working with
85/// Ethereum addresses.
86///
87/// If you are sure you want to use this type, and you don't want the
88/// deprecation warning, you can use `aliases::B160`.
89#[deprecated(
90    since = "0.3.2",
91    note = "you likely want to use `Address` instead. \
92            `B160` and `Address` are different types, \
93            see this type's documentation for more."
94)]
95pub type B160 = FixedBytes<20>;
96
97// Not public API.
98#[doc(hidden)]
99pub mod private {
100    pub use alloc::vec::Vec;
101    pub use core::{
102        self,
103        borrow::{Borrow, BorrowMut},
104        cmp::Ordering,
105        prelude::rust_2021::*,
106    };
107    pub use derive_more;
108
109    #[cfg(feature = "getrandom")]
110    pub use getrandom;
111
112    #[cfg(feature = "rand")]
113    pub use rand;
114
115    #[cfg(feature = "rlp")]
116    pub use alloy_rlp;
117
118    #[cfg(feature = "allocative")]
119    pub use allocative;
120
121    #[cfg(feature = "serde")]
122    pub use serde;
123
124    #[cfg(feature = "arbitrary")]
125    pub use {arbitrary, derive_arbitrary, proptest, proptest_derive};
126
127    #[cfg(feature = "diesel")]
128    pub use diesel;
129}