git.delta.rocks / unique-network / refs/commits / 3d14ec560294

difftreelog

feat generate solidity documentation

Yaroslav Bolyukin2021-11-05parent: #a5e777f.patch.diff
in: master

9 files changed

modifiedcrates/evm-coder-macros/src/solidity_interface.rsdiffbeforeafterboth
--- a/crates/evm-coder-macros/src/solidity_interface.rs
+++ b/crates/evm-coder-macros/src/solidity_interface.rs
@@ -6,7 +6,7 @@
 use std::fmt::Write;
 use syn::{
 	Expr, FnArg, GenericArgument, Generics, Ident, ImplItem, ImplItemMethod, ItemImpl, Lit, Meta,
-	NestedMeta, PatType, Path, PathArguments, ReturnType, Type, spanned::Spanned,
+	MetaNameValue, NestedMeta, PatType, Path, PathArguments, ReturnType, Type, spanned::Spanned,
 };
 
 use crate::{
@@ -362,19 +362,28 @@
 	has_normal_args: bool,
 	mutability: Mutability,
 	result: Type,
+	docs: Vec<String>,
 }
 impl Method {
 	fn try_from(value: &ImplItemMethod) -> syn::Result<Self> {
 		let mut info = MethodInfo {
 			rename_selector: None,
 		};
+		let mut docs = Vec::new();
 		for attr in &value.attrs {
 			let ident = parse_ident_from_path(&attr.path, false)?;
 			if ident == "solidity" {
 				let args = attr.parse_meta().unwrap();
 				info = MethodInfo::from_meta(&args).unwrap();
 			} else if ident == "doc" {
-				// TODO: Add docs to evm interfaces
+				let args = attr.parse_meta().unwrap();
+				let value = match args {
+					Meta::NameValue(MetaNameValue {
+						lit: Lit::Str(str), ..
+					}) => str.value(),
+					_ => unreachable!(),
+				};
+				docs.push(value);
 			}
 		}
 		let ident = &value.sig.ident;
@@ -457,6 +466,7 @@
 			has_normal_args,
 			mutability,
 			result: result.clone(),
+			docs,
 		})
 	}
 	fn expand_call_def(&self) -> proc_macro2::TokenStream {
@@ -570,10 +580,12 @@
 			.iter()
 			.filter(|a| !a.is_special())
 			.map(MethodArg::expand_solidity_argument);
+		let docs = self.docs.iter();
 		let selector = format!("{} {:0>8x}", self.selector_str, self.selector);
 
 		quote! {
 			SolidityFunction {
+				docs: &[#(#docs),*],
 				selector: #selector,
 				name: #camel_name,
 				mutability: #mutability,
@@ -704,6 +716,7 @@
 					use core::fmt::Write;
 					let interface = SolidityInterface {
 						name: #solidity_name,
+						selector: Self::interface_id(),
 						is: &["Dummy", "ERC165", #(
 							#solidity_is,
 						)* #(
modifiedcrates/evm-coder-macros/src/to_log.rsdiffbeforeafterboth
--- a/crates/evm-coder-macros/src/to_log.rs
+++ b/crates/evm-coder-macros/src/to_log.rs
@@ -183,6 +183,7 @@
 					use evm_coder::solidity::*;
 					use core::fmt::Write;
 					let interface = SolidityInterface {
+						selector: 0,
 						name: #solidity_name,
 						is: &[],
 						functions: (#(
modifiedcrates/evm-coder/src/solidity.rsdiffbeforeafterboth
after · crates/evm-coder/src/solidity.rs
1#[cfg(not(feature = "std"))]2use alloc::{3	string::String,4	vec::Vec,5	collections::{BTreeSet, BTreeMap},6	format,7};8#[cfg(feature = "std")]9use std::collections::{BTreeSet, BTreeMap};10use core::{11	fmt::{self, Write},12	marker::PhantomData,13	cell::{Cell, RefCell},14};15use impl_trait_for_tuples::impl_for_tuples;16use crate::types::*;1718#[derive(Default)]19pub struct TypeCollector {20	structs: RefCell<BTreeSet<string>>,21	anonymous: RefCell<BTreeMap<Vec<string>, usize>>,22	id: Cell<usize>,23}24impl TypeCollector {25	pub fn new() -> Self {26		Self::default()27	}28	pub fn collect(&self, item: string) {29		self.structs.borrow_mut().insert(item);30	}31	pub fn next_id(&self) -> usize {32		let v = self.id.get();33		self.id.set(v + 1);34		v35	}36	pub fn collect_tuple<T: SolidityTupleType>(&self) -> String {37		let names = T::names(self);38		if let Some(id) = self.anonymous.borrow().get(&names).cloned() {39			return format!("Tuple{}", id);40		}41		let id = self.next_id();42		let mut str = String::new();43		writeln!(str, "// Anonymous struct").unwrap();44		writeln!(str, "struct Tuple{} {{", id).unwrap();45		for (i, name) in names.iter().enumerate() {46			writeln!(str, "\t{} field_{};", name, i).unwrap();47		}48		writeln!(str, "}}").unwrap();49		self.collect(str);50		self.anonymous.borrow_mut().insert(names, id);51		format!("Tuple{}", id)52	}53	pub fn finish(self) -> BTreeSet<string> {54		self.structs.into_inner()55	}56}5758pub trait SolidityTypeName: 'static {59	fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;60	fn is_simple() -> bool;61	fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;62	fn is_void() -> bool {63		false64	}65}66macro_rules! solidity_type_name {67    ($($ty:ty => $name:literal $simple:literal = $default:literal),* $(,)?) => {68        $(69            impl SolidityTypeName for $ty {70                fn solidity_name(writer: &mut impl core::fmt::Write, _tc: &TypeCollector) -> core::fmt::Result {71                    write!(writer, $name)72                }73				fn is_simple() -> bool {74					$simple75				}76				fn solidity_default(writer: &mut impl core::fmt::Write, _tc: &TypeCollector) -> core::fmt::Result {77					write!(writer, $default)78				}79            }80        )*81    };82}8384solidity_type_name! {85	uint8 => "uint8" true = "0",86	uint32 => "uint32" true = "0",87	uint64 => "uint64" true = "0",88	uint128 => "uint128" true = "0",89	uint256 => "uint256" true = "0",90	address => "address" true = "0x0000000000000000000000000000000000000000",91	string => "string" false = "\"\"",92	bytes => "bytes" false = "hex\"\"",93	bool => "bool" true = "false",94}95impl SolidityTypeName for void {96	fn solidity_name(_writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {97		Ok(())98	}99	fn is_simple() -> bool {100		true101	}102	fn solidity_default(_writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {103		Ok(())104	}105	fn is_void() -> bool {106		true107	}108}109110mod sealed {111	pub trait CanBePlacedInVec {}112}113114impl sealed::CanBePlacedInVec for uint256 {}115impl sealed::CanBePlacedInVec for string {}116impl sealed::CanBePlacedInVec for address {}117118impl<T: SolidityTypeName + sealed::CanBePlacedInVec> SolidityTypeName for Vec<T> {119	fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {120		T::solidity_name(writer, tc)?;121		write!(writer, "[]")122	}123	fn is_simple() -> bool {124		false125	}126	fn solidity_default(writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {127		write!(writer, "[]")128	}129}130131pub trait SolidityTupleType {132	fn names(tc: &TypeCollector) -> Vec<String>;133	fn len() -> usize;134}135136macro_rules! count {137    () => (0usize);138    ( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*));139}140141macro_rules! impl_tuples {142	($($ident:ident)+) => {143		impl<$($ident),+> sealed::CanBePlacedInVec for ($($ident,)+) {}144		impl<$($ident: SolidityTypeName + 'static),+> SolidityTupleType for ($($ident,)+) {145			fn names(tc: &TypeCollector) -> Vec<string> {146				let mut collected = Vec::with_capacity(Self::len());147				$({148					let mut out = string::new();149					$ident::solidity_name(&mut out, tc).expect("no fmt error");150					collected.push(out);151				})*;152				collected153			}154155			fn len() -> usize {156				count!($($ident)*)157			}158		}159		impl<$($ident: SolidityTypeName + 'static),+> SolidityTypeName for ($($ident,)+) {160			fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {161				write!(writer, "{}", tc.collect_tuple::<Self>())162			}163			fn is_simple() -> bool {164				false165			}166			fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {167				write!(writer, "{}(", tc.collect_tuple::<Self>())?;168				$(169					<$ident>::solidity_default(writer, tc)?;170				)*171				write!(writer, ")")172			}173		}174	};175}176177impl_tuples! {A}178impl_tuples! {A B}179impl_tuples! {A B C}180impl_tuples! {A B C D}181impl_tuples! {A B C D E}182impl_tuples! {A B C D E F}183impl_tuples! {A B C D E F G}184impl_tuples! {A B C D E F G H}185impl_tuples! {A B C D E F G H I}186impl_tuples! {A B C D E F G H I J}187188pub trait SolidityArguments {189	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;190	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result;191	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;192	fn is_empty(&self) -> bool {193		self.len() == 0194	}195	fn len(&self) -> usize;196}197198#[derive(Default)]199pub struct UnnamedArgument<T>(PhantomData<*const T>);200201impl<T: SolidityTypeName> SolidityArguments for UnnamedArgument<T> {202	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {203		if !T::is_void() {204			T::solidity_name(writer, tc)?;205			if !T::is_simple() {206				write!(writer, " memory")?;207			}208			Ok(())209		} else {210			Ok(())211		}212	}213	fn solidity_get(&self, _writer: &mut impl fmt::Write) -> fmt::Result {214		Ok(())215	}216	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {217		T::solidity_default(writer, tc)218	}219	fn len(&self) -> usize {220		if T::is_void() {221			0222		} else {223			1224		}225	}226}227228pub struct NamedArgument<T>(&'static str, PhantomData<*const T>);229230impl<T> NamedArgument<T> {231	pub fn new(name: &'static str) -> Self {232		Self(name, Default::default())233	}234}235236impl<T: SolidityTypeName> SolidityArguments for NamedArgument<T> {237	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {238		if !T::is_void() {239			T::solidity_name(writer, tc)?;240			if !T::is_simple() {241				write!(writer, " memory")?;242			}243			write!(writer, " {}", self.0)244		} else {245			Ok(())246		}247	}248	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result {249		writeln!(writer, "\t\t{};", self.0)250	}251	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {252		T::solidity_default(writer, tc)253	}254	fn len(&self) -> usize {255		if T::is_void() {256			0257		} else {258			1259		}260	}261}262263pub struct SolidityEventArgument<T>(pub bool, &'static str, PhantomData<*const T>);264265impl<T> SolidityEventArgument<T> {266	pub fn new(indexed: bool, name: &'static str) -> Self {267		Self(indexed, name, Default::default())268	}269}270271impl<T: SolidityTypeName> SolidityArguments for SolidityEventArgument<T> {272	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {273		if !T::is_void() {274			T::solidity_name(writer, tc)?;275			if self.0 {276				write!(writer, " indexed")?;277			}278			write!(writer, " {}", self.1)279		} else {280			Ok(())281		}282	}283	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result {284		writeln!(writer, "\t\t{};", self.1)285	}286	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {287		T::solidity_default(writer, tc)288	}289	fn len(&self) -> usize {290		if T::is_void() {291			0292		} else {293			1294		}295	}296}297298impl SolidityArguments for () {299	fn solidity_name(&self, _writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {300		Ok(())301	}302	fn solidity_get(&self, _writer: &mut impl fmt::Write) -> fmt::Result {303		Ok(())304	}305	fn solidity_default(&self, _writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {306		Ok(())307	}308	fn len(&self) -> usize {309		0310	}311}312313#[impl_for_tuples(1, 5)]314impl SolidityArguments for Tuple {315	for_tuples!( where #( Tuple: SolidityArguments ),* );316317	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {318		let mut first = true;319		for_tuples!( #(320            if !Tuple.is_empty() {321                if !first {322                    write!(writer, ", ")?;323                }324                first = false;325                Tuple.solidity_name(writer, tc)?;326            }327        )* );328		Ok(())329	}330	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result {331		for_tuples!( #(332            Tuple.solidity_get(writer)?;333        )* );334		Ok(())335	}336	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {337		if self.is_empty() {338			Ok(())339		} else if self.len() == 1 {340			for_tuples!( #(341				Tuple.solidity_default(writer, tc)?;342			)* );343			Ok(())344		} else {345			write!(writer, "(")?;346			let mut first = true;347			for_tuples!( #(348				if !Tuple.is_empty() {349					if !first {350						write!(writer, ", ")?;351					}352					first = false;353					Tuple.solidity_default(writer, tc)?;354				}355			)* );356			write!(writer, ")")?;357			Ok(())358		}359	}360	fn len(&self) -> usize {361		for_tuples!( #( Tuple.len() )+* )362	}363}364365pub trait SolidityFunctions {366	fn solidity_name(367		&self,368		is_impl: bool,369		writer: &mut impl fmt::Write,370		tc: &TypeCollector,371	) -> fmt::Result;372}373374pub enum SolidityMutability {375	Pure,376	View,377	Mutable,378}379pub struct SolidityFunction<A, R> {380	pub docs: &'static [&'static str],381	pub selector: &'static str,382	pub name: &'static str,383	pub args: A,384	pub result: R,385	pub mutability: SolidityMutability,386}387impl<A: SolidityArguments, R: SolidityArguments> SolidityFunctions for SolidityFunction<A, R> {388	fn solidity_name(389		&self,390		is_impl: bool,391		writer: &mut impl fmt::Write,392		tc: &TypeCollector,393	) -> fmt::Result {394		for doc in self.docs {395			writeln!(writer, "\t//{}", doc)?;396		}397		if !self.docs.is_empty() {398			writeln!(writer, "\t//")?;399		}400		writeln!(writer, "\t// Selector: {}", self.selector)?;401		write!(writer, "\tfunction {}(", self.name)?;402		self.args.solidity_name(writer, tc)?;403		write!(writer, ")")?;404		if is_impl {405			write!(writer, " public")?;406		} else {407			write!(writer, " external")?;408		}409		match &self.mutability {410			SolidityMutability::Pure => write!(writer, " pure")?,411			SolidityMutability::View => write!(writer, " view")?,412			SolidityMutability::Mutable => {}413		}414		if !self.result.is_empty() {415			write!(writer, " returns (")?;416			self.result.solidity_name(writer, tc)?;417			write!(writer, ")")?;418		}419		if is_impl {420			writeln!(writer, " {{")?;421			writeln!(writer, "\t\trequire(false, stub_error);")?;422			self.args.solidity_get(writer)?;423			match &self.mutability {424				SolidityMutability::Pure => {}425				SolidityMutability::View => writeln!(writer, "\t\tdummy;")?,426				SolidityMutability::Mutable => writeln!(writer, "\t\tdummy = 0;")?,427			}428			if !self.result.is_empty() {429				write!(writer, "\t\treturn ")?;430				self.result.solidity_default(writer, tc)?;431				writeln!(writer, ";")?;432			}433			writeln!(writer, "\t}}")?;434		} else {435			writeln!(writer, ";")?;436		}437		Ok(())438	}439}440441#[impl_for_tuples(0, 12)]442impl SolidityFunctions for Tuple {443	for_tuples!( where #( Tuple: SolidityFunctions ),* );444445	fn solidity_name(446		&self,447		is_impl: bool,448		writer: &mut impl fmt::Write,449		tc: &TypeCollector,450	) -> fmt::Result {451		let mut first = false;452		for_tuples!( #(453            Tuple.solidity_name(is_impl, writer, tc)?;454        )* );455		Ok(())456	}457}458459pub struct SolidityInterface<F: SolidityFunctions> {460	pub selector: u32,461	pub name: &'static str,462	pub is: &'static [&'static str],463	pub functions: F,464}465466impl<F: SolidityFunctions> SolidityInterface<F> {467	pub fn format(468		&self,469		is_impl: bool,470		out: &mut impl fmt::Write,471		tc: &TypeCollector,472	) -> fmt::Result {473		if self.selector != 0 {474			writeln!(out, "// Selector: {:0>8x}", self.selector)?;475		}476		if is_impl {477			write!(out, "contract ")?;478		} else {479			write!(out, "interface ")?;480		}481		write!(out, "{}", self.name)?;482		if !self.is.is_empty() {483			write!(out, " is")?;484			for (i, n) in self.is.iter().enumerate() {485				if i != 0 {486					write!(out, ",")?;487				}488				write!(out, " {}", n)?;489			}490		}491		writeln!(out, " {{")?;492		self.functions.solidity_name(is_impl, out, tc)?;493		writeln!(out, "}}")?;494		Ok(())495	}496}497498pub struct SolidityEvent<A> {499	pub name: &'static str,500	pub args: A,501}502503impl<A: SolidityArguments> SolidityFunctions for SolidityEvent<A> {504	fn solidity_name(505		&self,506		_is_impl: bool,507		writer: &mut impl fmt::Write,508		tc: &TypeCollector,509	) -> fmt::Result {510		write!(writer, "\tevent {}(", self.name)?;511		self.args.solidity_name(writer, tc)?;512		writeln!(writer, ");")513	}514}
modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -31,6 +31,7 @@
 	);
 }
 
+// Selector: 942e8b22
 contract ERC20 is Dummy, ERC165, ERC20Events {
 	// Selector: name() 06fdde03
 	function name() public view returns (string memory) {
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -61,6 +61,7 @@
 		Ok(string::from_utf8_lossy(&self.token_prefix).into())
 	}
 
+	/// Returns token's const_metadata
 	#[solidity(rename_selector = "tokenURI")]
 	fn token_uri(&self, token_id: uint256) -> Result<string> {
 		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
@@ -79,6 +80,7 @@
 		Ok(index)
 	}
 
+	/// Not implemented
 	fn token_of_owner_by_index(&self, _owner: address, _index: uint256) -> Result<uint256> {
 		// TODO: Not implemetable
 		Err("not implemented".into())
@@ -103,6 +105,7 @@
 			.owner
 			.as_eth())
 	}
+	/// Not implemented
 	fn safe_transfer_from_with_data(
 		&mut self,
 		_from: address,
@@ -114,6 +117,7 @@
 		// TODO: Not implemetable
 		Err("not implemented".into())
 	}
+	/// Not implemented
 	fn safe_transfer_from(
 		&mut self,
 		_from: address,
@@ -159,6 +163,7 @@
 		Ok(())
 	}
 
+	/// Not implemented
 	fn set_approval_for_all(
 		&mut self,
 		_caller: caller,
@@ -169,11 +174,13 @@
 		Err("not implemented".into())
 	}
 
+	/// Not implemented
 	fn get_approved(&self, _token_id: uint256) -> Result<address> {
 		// TODO: Not implemetable
 		Err("not implemented".into())
 	}
 
+	/// Not implemented
 	fn is_approved_for_all(&self, _owner: address, _operator: address) -> Result<address> {
 		// TODO: Not implemetable
 		Err("not implemented".into())
@@ -197,6 +204,8 @@
 		Ok(false)
 	}
 
+	/// `token_id` should be obtained with `next_token_id` method,
+	/// unlike standard, you can't specify it manually
 	fn mint(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let to = T::CrossAccountId::from_eth(to);
@@ -223,6 +232,8 @@
 		Ok(true)
 	}
 
+	/// `token_id` should be obtained with `next_token_id` method,
+	/// unlike standard, you can't specify it manually
 	#[solidity(rename_selector = "mintWithTokenURI")]
 	fn mint_with_token_uri(
 		&mut self,
@@ -257,6 +268,7 @@
 		Ok(true)
 	}
 
+	/// Not implemented
 	fn finish_minting(&mut self, _caller: caller) -> Result<bool> {
 		Err("not implementable".into())
 	}
modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -51,6 +51,17 @@
 	event MintingFinished();
 }
 
+// Selector: 42966c68
+contract ERC721Burnable is Dummy, ERC165 {
+	// Selector: burn(uint256) 42966c68
+	function burn(uint256 tokenId) public {
+		require(false, stub_error);
+		tokenId;
+		dummy = 0;
+	}
+}
+
+// Selector: 58800161
 contract ERC721 is Dummy, ERC165, ERC721Events {
 	// Selector: balanceOf(address) 70a08231
 	function balanceOf(address owner) public view returns (uint256) {
@@ -68,6 +79,8 @@
 		return 0x0000000000000000000000000000000000000000;
 	}
 
+	// Not implemented
+	//
 	// Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672
 	function safeTransferFromWithData(
 		address from,
@@ -83,6 +96,8 @@
 		dummy = 0;
 	}
 
+	// Not implemented
+	//
 	// Selector: safeTransferFrom(address,address,uint256) 42842e0e
 	function safeTransferFrom(
 		address from,
@@ -117,6 +132,8 @@
 		dummy = 0;
 	}
 
+	// Not implemented
+	//
 	// Selector: setApprovalForAll(address,bool) a22cb465
 	function setApprovalForAll(address operator, bool approved) public {
 		require(false, stub_error);
@@ -125,6 +142,8 @@
 		dummy = 0;
 	}
 
+	// Not implemented
+	//
 	// Selector: getApproved(uint256) 081812fc
 	function getApproved(uint256 tokenId) public view returns (address) {
 		require(false, stub_error);
@@ -133,6 +152,8 @@
 		return 0x0000000000000000000000000000000000000000;
 	}
 
+	// Not implemented
+	//
 	// Selector: isApprovedForAll(address,address) e985e9c5
 	function isApprovedForAll(address owner, address operator)
 		public
@@ -147,45 +168,7 @@
 	}
 }
 
-contract ERC721Burnable is Dummy, ERC165 {
-	// Selector: burn(uint256) 42966c68
-	function burn(uint256 tokenId) public {
-		require(false, stub_error);
-		tokenId;
-		dummy = 0;
-	}
-}
-
-contract ERC721Enumerable is Dummy, ERC165 {
-	// Selector: tokenByIndex(uint256) 4f6ccce7
-	function tokenByIndex(uint256 index) public view returns (uint256) {
-		require(false, stub_error);
-		index;
-		dummy;
-		return 0;
-	}
-
-	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
-	function tokenOfOwnerByIndex(address owner, uint256 index)
-		public
-		view
-		returns (uint256)
-	{
-		require(false, stub_error);
-		owner;
-		index;
-		dummy;
-		return 0;
-	}
-
-	// Selector: totalSupply() 18160ddd
-	function totalSupply() public view returns (uint256) {
-		require(false, stub_error);
-		dummy;
-		return 0;
-	}
-}
-
+// Selector: 5b5e139f
 contract ERC721Metadata is Dummy, ERC165 {
 	// Selector: name() 06fdde03
 	function name() public view returns (string memory) {
@@ -201,6 +184,8 @@
 		return "";
 	}
 
+	// Returns token's const_metadata
+	//
 	// Selector: tokenURI(uint256) c87b56dd
 	function tokenURI(uint256 tokenId) public view returns (string memory) {
 		require(false, stub_error);
@@ -210,6 +195,7 @@
 	}
 }
 
+// Selector: 68ccfe89
 contract ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {
 	// Selector: mintingFinished() 05d2035b
 	function mintingFinished() public view returns (bool) {
@@ -218,6 +204,9 @@
 		return false;
 	}
 
+	// `token_id` should be obtained with `next_token_id` method,
+	// unlike standard, you can't specify it manually
+	//
 	// Selector: mint(address,uint256) 40c10f19
 	function mint(address to, uint256 tokenId) public returns (bool) {
 		require(false, stub_error);
@@ -227,6 +216,9 @@
 		return false;
 	}
 
+	// `token_id` should be obtained with `next_token_id` method,
+	// unlike standard, you can't specify it manually
+	//
 	// Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f
 	function mintWithTokenURI(
 		address to,
@@ -241,6 +233,8 @@
 		return false;
 	}
 
+	// Not implemented
+	//
 	// Selector: finishMinting() 7d64bcb4
 	function finishMinting() public returns (bool) {
 		require(false, stub_error);
@@ -249,6 +243,40 @@
 	}
 }
 
+// Selector: 780e9d63
+contract ERC721Enumerable is Dummy, ERC165 {
+	// Selector: tokenByIndex(uint256) 4f6ccce7
+	function tokenByIndex(uint256 index) public view returns (uint256) {
+		require(false, stub_error);
+		index;
+		dummy;
+		return 0;
+	}
+
+	// Not implemented
+	//
+	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
+	function tokenOfOwnerByIndex(address owner, uint256 index)
+		public
+		view
+		returns (uint256)
+	{
+		require(false, stub_error);
+		owner;
+		index;
+		dummy;
+		return 0;
+	}
+
+	// Selector: totalSupply() 18160ddd
+	function totalSupply() public view returns (uint256) {
+		require(false, stub_error);
+		dummy;
+		return 0;
+	}
+}
+
+// Selector: e562194d
 contract ERC721UniqueExtensions is Dummy, ERC165 {
 	// Selector: transfer(address,uint256) a9059cbb
 	function transfer(address to, uint256 tokenId) public {
modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -12,6 +12,7 @@
 	function supportsInterface(bytes4 interfaceID) external view returns (bool);
 }
 
+// Selector: 31acb1fe
 interface ContractHelpers is Dummy, ERC165 {
 	// Selector: contractOwner(address) 5152b14c
 	function contractOwner(address contractAddress)
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -22,6 +22,7 @@
 	);
 }
 
+// Selector: 942e8b22
 interface ERC20 is Dummy, ERC165, ERC20Events {
 	// Selector: name() 06fdde03
 	function name() external view returns (string memory);
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -42,6 +42,13 @@
 	event MintingFinished();
 }
 
+// Selector: 42966c68
+interface ERC721Burnable is Dummy, ERC165 {
+	// Selector: burn(uint256) 42966c68
+	function burn(uint256 tokenId) external;
+}
+
+// Selector: 58800161
 interface ERC721 is Dummy, ERC165, ERC721Events {
 	// Selector: balanceOf(address) 70a08231
 	function balanceOf(address owner) external view returns (uint256);
@@ -49,6 +56,8 @@
 	// Selector: ownerOf(uint256) 6352211e
 	function ownerOf(uint256 tokenId) external view returns (address);
 
+	// Not implemented
+	//
 	// Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672
 	function safeTransferFromWithData(
 		address from,
@@ -57,6 +66,8 @@
 		bytes memory data
 	) external;
 
+	// Not implemented
+	//
 	// Selector: safeTransferFrom(address,address,uint256) 42842e0e
 	function safeTransferFrom(
 		address from,
@@ -74,12 +85,18 @@
 	// Selector: approve(address,uint256) 095ea7b3
 	function approve(address approved, uint256 tokenId) external;
 
+	// Not implemented
+	//
 	// Selector: setApprovalForAll(address,bool) a22cb465
 	function setApprovalForAll(address operator, bool approved) external;
 
+	// Not implemented
+	//
 	// Selector: getApproved(uint256) 081812fc
 	function getApproved(uint256 tokenId) external view returns (address);
 
+	// Not implemented
+	//
 	// Selector: isApprovedForAll(address,address) e985e9c5
 	function isApprovedForAll(address owner, address operator)
 		external
@@ -87,25 +104,7 @@
 		returns (address);
 }
 
-interface ERC721Burnable is Dummy, ERC165 {
-	// Selector: burn(uint256) 42966c68
-	function burn(uint256 tokenId) external;
-}
-
-interface ERC721Enumerable is Dummy, ERC165 {
-	// Selector: tokenByIndex(uint256) 4f6ccce7
-	function tokenByIndex(uint256 index) external view returns (uint256);
-
-	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
-	function tokenOfOwnerByIndex(address owner, uint256 index)
-		external
-		view
-		returns (uint256);
-
-	// Selector: totalSupply() 18160ddd
-	function totalSupply() external view returns (uint256);
-}
-
+// Selector: 5b5e139f
 interface ERC721Metadata is Dummy, ERC165 {
 	// Selector: name() 06fdde03
 	function name() external view returns (string memory);
@@ -113,17 +112,26 @@
 	// Selector: symbol() 95d89b41
 	function symbol() external view returns (string memory);
 
+	// Returns token's const_metadata
+	//
 	// Selector: tokenURI(uint256) c87b56dd
 	function tokenURI(uint256 tokenId) external view returns (string memory);
 }
 
+// Selector: 68ccfe89
 interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {
 	// Selector: mintingFinished() 05d2035b
 	function mintingFinished() external view returns (bool);
 
+	// `token_id` should be obtained with `next_token_id` method,
+	// unlike standard, you can't specify it manually
+	//
 	// Selector: mint(address,uint256) 40c10f19
 	function mint(address to, uint256 tokenId) external returns (bool);
 
+	// `token_id` should be obtained with `next_token_id` method,
+	// unlike standard, you can't specify it manually
+	//
 	// Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f
 	function mintWithTokenURI(
 		address to,
@@ -131,10 +139,30 @@
 		string memory tokenUri
 	) external returns (bool);
 
+	// Not implemented
+	//
 	// Selector: finishMinting() 7d64bcb4
 	function finishMinting() external returns (bool);
 }
 
+// Selector: 780e9d63
+interface ERC721Enumerable is Dummy, ERC165 {
+	// Selector: tokenByIndex(uint256) 4f6ccce7
+	function tokenByIndex(uint256 index) external view returns (uint256);
+
+	// Not implemented
+	//
+	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
+	function tokenOfOwnerByIndex(address owner, uint256 index)
+		external
+		view
+		returns (uint256);
+
+	// Selector: totalSupply() 18160ddd
+	function totalSupply() external view returns (uint256);
+}
+
+// Selector: e562194d
 interface ERC721UniqueExtensions is Dummy, ERC165 {
 	// Selector: transfer(address,uint256) a9059cbb
 	function transfer(address to, uint256 tokenId) external;