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
22pub mod aliases;
23#[doc(no_inline)]
24pub use aliases::{
25    BlockHash, BlockNumber, BlockTimestamp, ChainId, Selector, StorageKey, StorageValue, TxHash,
26    TxIndex, TxNonce, TxNumber, B128, B256, B512, B64, I128, I16, I160, I256, I32, I64, I8, U128,
27    U16, U160, U256, U32, U512, U64, U8,
28};
29
30#[macro_use]
31mod bits;
32pub use bits::{
33    Address, AddressChecksumBuffer, AddressError, Bloom, BloomInput, FixedBytes, Function,
34    BLOOM_BITS_PER_ITEM, BLOOM_SIZE_BITS, BLOOM_SIZE_BYTES,
35};
36
37#[path = "bytes/mod.rs"]
38mod bytes_;
39pub use self::bytes_::Bytes;
40
41mod common;
42pub use common::TxKind;
43
44mod log;
45pub use log::{IntoLogData, Log, LogData};
46
47#[cfg(feature = "map")]
48pub mod map;
49
50mod sealed;
51pub use sealed::{Sealable, Sealed};
52
53mod signed;
54pub use signed::{BigIntConversionError, ParseSignedError, Sign, Signed};
55
56mod signature;
57pub use signature::{to_eip155_v, Parity, Signature, SignatureError};
58
59pub mod utils;
60pub use utils::{eip191_hash_message, keccak256, Keccak256};
61
62#[doc(no_inline)]
63pub use {
64    ::bytes,
65    ::hex,
66    hex_literal::{self, hex},
67    ruint::{self, uint, Uint},
68};
69
70#[cfg(feature = "serde")]
71#[doc(no_inline)]
72pub use ::hex::serde as serde_hex;
73
74/// 20-byte [fixed byte-array][FixedBytes] type.
75///
76/// You'll likely want to use [`Address`] instead, as it is a different type
77/// from `FixedBytes<20>`, and implements methods useful for working with
78/// Ethereum addresses.
79///
80/// If you are sure you want to use this type, and you don't want the
81/// deprecation warning, you can use `aliases::B160`.
82#[deprecated(
83    since = "0.3.2",
84    note = "you likely want to use `Address` instead. \
85            `B160` and `Address` are different types, \
86            see this type's documentation for more."
87)]
88pub type B160 = FixedBytes<20>;
89
90// Not public API.
91#[doc(hidden)]
92pub mod private {
93    pub use alloc::vec::Vec;
94    pub use core::{
95        self,
96        borrow::{Borrow, BorrowMut},
97        cmp::Ordering,
98        prelude::rust_2021::*,
99    };
100    pub use derive_more;
101
102    #[cfg(feature = "getrandom")]
103    pub use getrandom;
104
105    #[cfg(feature = "rand")]
106    pub use rand;
107
108    #[cfg(feature = "rlp")]
109    pub use alloy_rlp;
110
111    #[cfg(feature = "allocative")]
112    pub use allocative;
113
114    #[cfg(feature = "serde")]
115    pub use serde;
116
117    #[cfg(feature = "arbitrary")]
118    pub use {arbitrary, derive_arbitrary, proptest, proptest_derive};
119}