1mod abi_type;
6mod artifact;
7pub use artifact::SolidityArtifact;
8mod typed_value;
9pub use typed_value::AbiValue;
10mod codec;
11mod packed;
12pub use packed::{solidity_packed, solidity_packed_keccak256, solidity_packed_sha256};
13mod document;
14mod human;
15mod interface;
16mod parameter;
17pub use parameter::{AbiFormat, AbiParameter};
18mod result;
19pub use result::AbiResult;
20mod workflows;
21pub use workflows::{
22 AbiFilterTopic, AbiFilterValue, MAX_FILTER_ALTERNATIVES, ParsedCall, ParsedLog, ParsedRevert,
23};
24mod schema;
25mod typed_visit;
26pub use typed_visit::TypedValueEncoder;
27mod value;
28
29pub use document::TypedData;
30pub use schema::{TypedDataEncoder, TypedDataField, TypedDataTypes};
31pub use value::{hash_domain, hash_typed_data};
32
33pub const MAX_DATA_BYTES: usize = 1 << 20;
35pub const MAX_VALUE_NODES: usize = 32_768;
37pub const MAX_DEPTH: usize = 64;
39pub const MAX_TYPES: usize = 128;
41pub const MAX_FIELDS: usize = 1024;
43pub const MAX_SCHEMA_BYTES: usize = 65_536;
45
46#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
48#[non_exhaustive]
49pub enum TypedDataError {
50 #[error("typed data exceeds resource limits")]
52 Limit,
53 #[error("invalid typed-data document")]
55 Document,
56 #[error("invalid typed-data schema")]
58 Schema,
59 #[error("unknown typed-data type")]
61 UnknownType,
62 #[error("typed-data schema requires one primary type")]
64 PrimaryType,
65 #[error("cyclic typed-data schema")]
67 Cycle,
68 #[error("typed-data value does not match schema")]
70 Value,
71 #[error("invalid typed-data integer")]
73 Integer,
74 #[error("invalid typed-data bytes or address")]
76 Bytes,
77 #[error("typed-data array length mismatch")]
79 ArrayLength,
80 #[error("invalid typed-data domain")]
82 Domain,
83}
84
85pub(crate) fn keccak(bytes: &[u8]) -> [u8; 32] {
86 use tiny_keccak::{Hasher, Keccak};
87 let mut hasher = Keccak::v256();
88 hasher.update(bytes);
89 let mut result = [0; 32];
90 hasher.finalize(&mut result);
91 result
92}
93
94pub use abi_type::{AbiError, AbiType};
95pub use codec::{AbiCoder, indexed_event_topic};
96pub use interface::{
97 AbiConstructor, AbiCustomError, AbiEvent, AbiEventValue, AbiFunction, AbiInterface,
98 StateMutability, function_selector, signature_hash,
99};