fuel_ethabi/
lib.rs

1// Copyright 2015-2020 Parity Technologies
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9//! Ethereum ABI encoding decoding library.
10
11#![cfg_attr(not(feature = "std"), no_std)]
12#![allow(clippy::module_inception)]
13#![warn(missing_docs)]
14
15#[cfg_attr(not(feature = "std"), macro_use)]
16extern crate alloc;
17#[cfg(not(feature = "std"))]
18mod no_std_prelude {
19	pub use alloc::{
20		borrow::{Cow, ToOwned},
21		boxed::Box,
22		string::{self, String, ToString},
23		vec::Vec,
24	};
25}
26#[cfg(feature = "std")]
27mod no_std_prelude {
28	pub use std::borrow::Cow;
29}
30#[cfg(not(feature = "std"))]
31use no_std_prelude::*;
32
33mod constructor;
34mod contract;
35mod decoder;
36mod encoder;
37mod error;
38mod errors;
39mod event;
40mod event_param;
41mod filter;
42mod function;
43mod log;
44#[cfg(feature = "serde")]
45pub mod operation;
46mod param;
47pub mod param_type;
48mod signature;
49mod state_mutability;
50pub mod token;
51#[cfg(feature = "serde")]
52mod tuple_param;
53mod util;
54
55#[cfg(test)]
56mod tests;
57
58pub use ethereum_types;
59
60#[cfg(feature = "serde")]
61pub use crate::tuple_param::TupleParam;
62pub use crate::{
63	constructor::Constructor,
64	contract::{Contract, Events, Functions},
65	decoder::{decode, decode_validate},
66	encoder::encode,
67	error::Error as AbiError,
68	errors::{Error, Result},
69	event::Event,
70	event_param::EventParam,
71	filter::{RawTopicFilter, Topic, TopicFilter},
72	function::Function,
73	log::{Log, LogFilter, LogParam, ParseLog, RawLog},
74	param::Param,
75	param_type::ParamType,
76	signature::{long_signature, short_signature},
77	state_mutability::StateMutability,
78	token::Token,
79};
80
81/// ABI word.
82pub type Word = [u8; 32];
83
84/// ABI address.
85pub type Address = ethereum_types::Address;
86
87/// ABI fixed bytes.
88pub type FixedBytes = Vec<u8>;
89
90/// ABI bytes.
91pub type Bytes = Vec<u8>;
92
93/// ABI signed integer.
94pub type Int = ethereum_types::U256;
95
96/// ABI unsigned integer.
97pub type Uint = ethereum_types::U256;
98
99/// Commonly used FixedBytes of size 32
100pub type Hash = ethereum_types::H256;
101
102/// Contract functions generated by ethabi-derive
103pub trait FunctionOutputDecoder {
104	/// Output types of the contract function
105	type Output;
106
107	/// Decodes the given bytes output for the contract function
108	fn decode(&self, _: &[u8]) -> Result<Self::Output>;
109}