1#![cfg_attr(not(feature = "std"), no_std)]2#[cfg(not(feature = "std"))]3extern crate alloc;45use abi::{AbiReader, AbiWriter};6pub use evm_coder_macros::{event_topic, fn_selector, solidity_interface, solidity, ToLog};7pub mod abi;8pub mod events;9pub use events::ToLog;10pub mod execution;11pub mod solidity;121314pub mod types {15 #![allow(non_camel_case_types)]1617 #[cfg(not(feature = "std"))]18 use alloc::{vec::Vec};19 use primitive_types::{U256, H160, H256};2021 pub type address = H160;2223 pub type uint8 = u8;24 pub type uint16 = u16;25 pub type uint32 = u32;26 pub type uint64 = u64;27 pub type uint128 = u128;28 pub type uint256 = U256;2930 pub type bytes4 = u32;3132 pub type topic = H256;3334 #[cfg(not(feature = "std"))]35 pub type string = ::alloc::string::String;36 #[cfg(feature = "std")]37 pub type string = ::std::string::String;38 pub type bytes = Vec<u8>;3940 pub type void = ();4142 43 44 pub type value = U256;45 46 pub type caller = address;47 4849 pub struct Msg<C> {50 pub call: C,51 pub caller: H160,52 pub value: U256,53 }54}5556pub trait Call: Sized {57 fn parse(selector: u32, input: &mut AbiReader) -> execution::Result<Option<Self>>;58}5960pub trait Callable {61 type Call: Call;62 fn call(&mut self, call: types::Msg<Self::Call>) -> execution::Result<AbiWriter>;63}6465#[cfg(test)]66mod tests {67 use super::*;6869 #[test]70 fn function_selector_generation() {71 assert_eq!(fn_selector!(transfer(address, uint256)), 0xa9059cbb);72 }7374 #[test]75 fn event_topic_generation() {76 assert_eq!(77 hex::encode(&event_topic!(Transfer(address, address, uint256))[..]),78 "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",79 );80 }81}