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
before · 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	uint128 => "uint128" true = "0",88	uint256 => "uint256" true = "0",89	address => "address" true = "0x0000000000000000000000000000000000000000",90	string => "string" false = "\"\"",91	bytes => "bytes" false = "hex\"\"",92	bool => "bool" true = "false",93}94impl SolidityTypeName for void {95	fn solidity_name(_writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {96		Ok(())97	}98	fn is_simple() -> bool {99		true100	}101	fn solidity_default(_writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {102		Ok(())103	}104	fn is_void() -> bool {105		true106	}107}108109mod sealed {110	pub trait CanBePlacedInVec {}111}112113impl sealed::CanBePlacedInVec for uint256 {}114impl sealed::CanBePlacedInVec for string {}115impl sealed::CanBePlacedInVec for address {}116117impl<T: SolidityTypeName + sealed::CanBePlacedInVec> SolidityTypeName for Vec<T> {118	fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {119		T::solidity_name(writer, tc)?;120		write!(writer, "[]")121	}122	fn is_simple() -> bool {123		false124	}125	fn solidity_default(writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {126		write!(writer, "[]")127	}128}129130pub trait SolidityTupleType {131	fn names(tc: &TypeCollector) -> Vec<String>;132	fn len() -> usize;133}134135macro_rules! count {136    () => (0usize);137    ( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*));138}139140macro_rules! impl_tuples {141	($($ident:ident)+) => {142		impl<$($ident),+> sealed::CanBePlacedInVec for ($($ident,)+) {}143		impl<$($ident: SolidityTypeName + 'static),+> SolidityTupleType for ($($ident,)+) {144			fn names(tc: &TypeCollector) -> Vec<string> {145				let mut collected = Vec::with_capacity(Self::len());146				$({147					let mut out = string::new();148					$ident::solidity_name(&mut out, tc).expect("no fmt error");149					collected.push(out);150				})*;151				collected152			}153154			fn len() -> usize {155				count!($($ident)*)156			}157		}158		impl<$($ident: SolidityTypeName + 'static),+> SolidityTypeName for ($($ident,)+) {159			fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {160				write!(writer, "{}", tc.collect_tuple::<Self>())161			}162			fn is_simple() -> bool {163				false164			}165			fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {166				write!(writer, "{}(", tc.collect_tuple::<Self>())?;167				$(168					<$ident>::solidity_default(writer, tc)?;169				)*170				write!(writer, ")")171			}172		}173	};174}175176impl_tuples! {A}177impl_tuples! {A B}178impl_tuples! {A B C}179impl_tuples! {A B C D}180impl_tuples! {A B C D E}181impl_tuples! {A B C D E F}182impl_tuples! {A B C D E F G}183impl_tuples! {A B C D E F G H}184impl_tuples! {A B C D E F G H I}185impl_tuples! {A B C D E F G H I J}186187pub trait SolidityArguments {188	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;189	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result;190	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;191	fn is_empty(&self) -> bool {192		self.len() == 0193	}194	fn len(&self) -> usize;195}196197#[derive(Default)]198pub struct UnnamedArgument<T>(PhantomData<*const T>);199200impl<T: SolidityTypeName> SolidityArguments for UnnamedArgument<T> {201	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {202		if !T::is_void() {203			T::solidity_name(writer, tc)?;204			if !T::is_simple() {205				write!(writer, " memory")?;206			}207			Ok(())208		} else {209			Ok(())210		}211	}212	fn solidity_get(&self, _writer: &mut impl fmt::Write) -> fmt::Result {213		Ok(())214	}215	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {216		T::solidity_default(writer, tc)217	}218	fn len(&self) -> usize {219		if T::is_void() {220			0221		} else {222			1223		}224	}225}226227pub struct NamedArgument<T>(&'static str, PhantomData<*const T>);228229impl<T> NamedArgument<T> {230	pub fn new(name: &'static str) -> Self {231		Self(name, Default::default())232	}233}234235impl<T: SolidityTypeName> SolidityArguments for NamedArgument<T> {236	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {237		if !T::is_void() {238			T::solidity_name(writer, tc)?;239			if !T::is_simple() {240				write!(writer, " memory")?;241			}242			write!(writer, " {}", self.0)243		} else {244			Ok(())245		}246	}247	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result {248		writeln!(writer, "\t\t{};", self.0)249	}250	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {251		T::solidity_default(writer, tc)252	}253	fn len(&self) -> usize {254		if T::is_void() {255			0256		} else {257			1258		}259	}260}261262pub struct SolidityEventArgument<T>(pub bool, &'static str, PhantomData<*const T>);263264impl<T> SolidityEventArgument<T> {265	pub fn new(indexed: bool, name: &'static str) -> Self {266		Self(indexed, name, Default::default())267	}268}269270impl<T: SolidityTypeName> SolidityArguments for SolidityEventArgument<T> {271	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {272		if !T::is_void() {273			T::solidity_name(writer, tc)?;274			if self.0 {275				write!(writer, " indexed")?;276			}277			write!(writer, " {}", self.1)278		} else {279			Ok(())280		}281	}282	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result {283		writeln!(writer, "\t\t{};", self.1)284	}285	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {286		T::solidity_default(writer, tc)287	}288	fn len(&self) -> usize {289		if T::is_void() {290			0291		} else {292			1293		}294	}295}296297impl SolidityArguments for () {298	fn solidity_name(&self, _writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {299		Ok(())300	}301	fn solidity_get(&self, _writer: &mut impl fmt::Write) -> fmt::Result {302		Ok(())303	}304	fn solidity_default(&self, _writer: &mut impl fmt::Write, _tc: &TypeCollector) -> fmt::Result {305		Ok(())306	}307	fn len(&self) -> usize {308		0309	}310}311312#[impl_for_tuples(1, 5)]313impl SolidityArguments for Tuple {314	for_tuples!( where #( Tuple: SolidityArguments ),* );315316	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {317		let mut first = true;318		for_tuples!( #(319            if !Tuple.is_empty() {320                if !first {321                    write!(writer, ", ")?;322                }323                first = false;324                Tuple.solidity_name(writer, tc)?;325            }326        )* );327		Ok(())328	}329	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result {330		for_tuples!( #(331            Tuple.solidity_get(writer)?;332        )* );333		Ok(())334	}335	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {336		if self.is_empty() {337			Ok(())338		} else if self.len() == 1 {339			for_tuples!( #(340				Tuple.solidity_default(writer, tc)?;341			)* );342			Ok(())343		} else {344			write!(writer, "(")?;345			let mut first = true;346			for_tuples!( #(347				if !Tuple.is_empty() {348					if !first {349						write!(writer, ", ")?;350					}351					first = false;352					Tuple.solidity_default(writer, tc)?;353				}354			)* );355			write!(writer, ")")?;356			Ok(())357		}358	}359	fn len(&self) -> usize {360		for_tuples!( #( Tuple.len() )+* )361	}362}363364pub trait SolidityFunctions {365	fn solidity_name(366		&self,367		is_impl: bool,368		writer: &mut impl fmt::Write,369		tc: &TypeCollector,370	) -> fmt::Result;371}372373pub enum SolidityMutability {374	Pure,375	View,376	Mutable,377}378pub struct SolidityFunction<A, R> {379	pub selector: &'static str,380	pub name: &'static str,381	pub args: A,382	pub result: R,383	pub mutability: SolidityMutability,384}385impl<A: SolidityArguments, R: SolidityArguments> SolidityFunctions for SolidityFunction<A, R> {386	fn solidity_name(387		&self,388		is_impl: bool,389		writer: &mut impl fmt::Write,390		tc: &TypeCollector,391	) -> fmt::Result {392		writeln!(writer, "\t// Selector: {}", self.selector)?;393		write!(writer, "\tfunction {}(", self.name)?;394		self.args.solidity_name(writer, tc)?;395		write!(writer, ")")?;396		if is_impl {397			write!(writer, " public")?;398		} else {399			write!(writer, " external")?;400		}401		match &self.mutability {402			SolidityMutability::Pure => write!(writer, " pure")?,403			SolidityMutability::View => write!(writer, " view")?,404			SolidityMutability::Mutable => {}405		}406		if !self.result.is_empty() {407			write!(writer, " returns (")?;408			self.result.solidity_name(writer, tc)?;409			write!(writer, ")")?;410		}411		if is_impl {412			writeln!(writer, " {{")?;413			writeln!(writer, "\t\trequire(false, stub_error);")?;414			self.args.solidity_get(writer)?;415			match &self.mutability {416				SolidityMutability::Pure => {}417				SolidityMutability::View => writeln!(writer, "\t\tdummy;")?,418				SolidityMutability::Mutable => writeln!(writer, "\t\tdummy = 0;")?,419			}420			if !self.result.is_empty() {421				write!(writer, "\t\treturn ")?;422				self.result.solidity_default(writer, tc)?;423				writeln!(writer, ";")?;424			}425			writeln!(writer, "\t}}")?;426		} else {427			writeln!(writer, ";")?;428		}429		Ok(())430	}431}432433#[impl_for_tuples(0, 12)]434impl SolidityFunctions for Tuple {435	for_tuples!( where #( Tuple: SolidityFunctions ),* );436437	fn solidity_name(438		&self,439		is_impl: bool,440		writer: &mut impl fmt::Write,441		tc: &TypeCollector,442	) -> fmt::Result {443		let mut first = false;444		for_tuples!( #(445            Tuple.solidity_name(is_impl, writer, tc)?;446        )* );447		Ok(())448	}449}450451pub struct SolidityInterface<F: SolidityFunctions> {452	pub name: &'static str,453	pub is: &'static [&'static str],454	pub functions: F,455}456457impl<F: SolidityFunctions> SolidityInterface<F> {458	pub fn format(459		&self,460		is_impl: bool,461		out: &mut impl fmt::Write,462		tc: &TypeCollector,463	) -> fmt::Result {464		if is_impl {465			write!(out, "contract ")?;466		} else {467			write!(out, "interface ")?;468		}469		write!(out, "{}", self.name)?;470		if !self.is.is_empty() {471			write!(out, " is")?;472			for (i, n) in self.is.iter().enumerate() {473				if i != 0 {474					write!(out, ",")?;475				}476				write!(out, " {}", n)?;477			}478		}479		writeln!(out, " {{")?;480		self.functions.solidity_name(is_impl, out, tc)?;481		writeln!(out, "}}")?;482		Ok(())483	}484}485486pub struct SolidityEvent<A> {487	pub name: &'static str,488	pub args: A,489}490491impl<A: SolidityArguments> SolidityFunctions for SolidityEvent<A> {492	fn solidity_name(493		&self,494		_is_impl: bool,495		writer: &mut impl fmt::Write,496		tc: &TypeCollector,497	) -> fmt::Result {498		write!(writer, "\tevent {}(", self.name)?;499		self.args.solidity_name(writer, tc)?;500		writeln!(writer, ");")501	}502}
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;