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(docsrs, feature(doc_cfg))]
9
10#[allow(unused_extern_crates)]
11extern crate self as alloy_sol_types;
12
13#[macro_use]
14extern crate alloc;
15
16#[macro_use]
17mod macros;
18
19pub mod abi;
20
21mod errors;
22pub use errors::{Error, Result};
23
24#[cfg(feature = "json")]
25mod ext;
26#[cfg(feature = "json")]
27pub use ext::JsonAbiExt;
28
29mod impl_core;
30
31mod types;
32pub use types::{
33 ContractError, EventTopic, GenericContractError, GenericRevertReason, Panic, PanicKind, Revert,
34 RevertReason, Selectors, SolCall, SolConstructor, SolEnum, SolError, SolEvent,
35 SolEventInterface, SolInterface, SolStruct, SolType, SolValue, TopicList,
36 data_type as sol_data, decode_revert_reason,
37};
38
39pub mod utils;
40
41mod eip712;
42pub use eip712::Eip712Domain;
43
44pub type Word = alloy_primitives::B256;
46
47#[doc(no_inline)]
48pub use alloy_sol_macro::sol;
49
50#[doc(hidden)]
52#[allow(missing_debug_implementations)]
53pub mod private {
54 #[allow(deprecated)]
55 pub use super::{
56 abi::RECURSION_LIMIT,
57 utils::{next_multiple_of_32, words_for, words_for_len},
58 };
59 pub use alloc::{
60 borrow::{Cow, ToOwned},
61 boxed::Box,
62 collections::BTreeMap,
63 string::{String, ToString},
64 vec,
65 vec::Vec,
66 };
67 pub use alloy_primitives::{
68 self as primitives, Address, B256, Bytes, FixedBytes, Function, I256, IntoLogData, LogData,
69 Signed, U256, Uint, bytes, keccak256,
70 };
71 pub use core::{
72 borrow::{Borrow, BorrowMut},
73 convert::From,
74 default::Default,
75 option::Option,
76 result::Result,
77 };
78
79 pub use Option::{None, Some};
80 pub use Result::{Err, Ok};
81
82 #[cfg(feature = "json")]
83 pub use alloy_json_abi;
84
85 pub trait SolTypeValue<T: super::SolType> {
96 #[inline(always)]
100 fn stv_abi_encoded_size(&self) -> usize {
101 T::ENCODED_SIZE.unwrap()
102 }
103 fn stv_to_tokens(&self) -> T::Token<'_>;
104
105 #[inline(always)]
106 fn stv_abi_packed_encoded_size(&self) -> usize {
107 T::PACKED_ENCODED_SIZE.unwrap()
108 }
109 fn stv_abi_encode_packed_to(&self, out: &mut Vec<u8>);
110
111 fn stv_eip712_data_word(&self) -> super::Word;
112 }
113
114 #[inline(always)]
115 pub const fn u256(n: u64) -> U256 {
116 U256::from_limbs([n, 0, 0, 0])
117 }
118
119 pub struct AssertTypeEq<T>(pub T);
120
121 #[inline(never)]
122 pub fn str_to_owned(s: &str) -> String {
123 s.to_owned()
124 }
125
126 #[inline(never)]
127 pub fn make_btree_map<K: Ord, V>(items: Vec<(K, V)>) -> BTreeMap<K, V> {
128 BTreeMap::from_iter(items)
129 }
130}