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