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::{logs_bloom, 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::{normalize_v, to_eip155_v, PrimitiveSignature, SignatureError};
58#[allow(deprecated)]
59pub use signature::{Parity, Signature};
60
61pub mod utils;
62pub use utils::{eip191_hash_message, keccak256, Keccak256};
63
64#[doc(hidden)] // Use `hex` directly instead!
65pub mod hex_literal;
66
67#[doc(no_inline)]
68pub use {
69    ::bytes,
70    ::hex,
71    ruint::{self, uint, Uint},
72};
73
74#[cfg(feature = "serde")]
75#[doc(no_inline)]
76pub use ::hex::serde as serde_hex;
77
78/// 20-byte [fixed byte-array][FixedBytes] type.
79///
80/// You'll likely want to use [`Address`] instead, as it is a different type
81/// from `FixedBytes<20>`, and implements methods useful for working with
82/// Ethereum addresses.
83///
84/// If you are sure you want to use this type, and you don't want the
85/// deprecation warning, you can use `aliases::B160`.
86#[deprecated(
87    since = "0.3.2",
88    note = "you likely want to use `Address` instead. \
89            `B160` and `Address` are different types, \
90            see this type's documentation for more."
91)]
92pub type B160 = FixedBytes<20>;
93
94// Not public API.
95#[doc(hidden)]
96pub mod private {
97    pub use alloc::vec::Vec;
98    pub use core::{
99        self,
100        borrow::{Borrow, BorrowMut},
101        cmp::Ordering,
102        prelude::rust_2021::*,
103    };
104    pub use derive_more;
105
106    #[cfg(feature = "getrandom")]
107    pub use getrandom;
108
109    #[cfg(feature = "rand")]
110    pub use rand;
111
112    #[cfg(feature = "rlp")]
113    pub use alloy_rlp;
114
115    #[cfg(feature = "allocative")]
116    pub use allocative;
117
118    #[cfg(feature = "serde")]
119    pub use serde;
120
121    #[cfg(feature = "arbitrary")]
122    pub use {arbitrary, derive_arbitrary, proptest, proptest_derive};
123}