git.delta.rocks / unique-network / refs/commits / 691516e64f00

difftreelog

build update evm stubs

Yaroslav Bolyukin2021-08-30parent: #c2fde9c.patch.diff
in: master

25 files changed

added.maintain/scripts/compile_stub.shdiffbeforeafterboth
--- /dev/null
+++ b/.maintain/scripts/compile_stub.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -eu
+
+dir=$PWD
+
+tmp=$(mktemp -d)
+cd $tmp
+cp $dir/$INPUT input.sol
+solcjs --optimize --bin input.sol
+
+mv input_sol_$(basename $OUTPUT .raw).bin out.bin
+xxd -r -p out.bin out.raw
+
+mv out.raw $dir/$OUTPUT
\ No newline at end of file
added.maintain/scripts/generate_api.shdiffbeforeafterboth
--- /dev/null
+++ b/.maintain/scripts/generate_api.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+set -eu
+
+tmp=$(mktemp)
+cargo test --package $PACKAGE -- $NAME --exact --nocapture --ignored | tee $tmp
+raw=$(mktemp --suffix .sol)
+sed -n '/=== SNIP START ===/, /=== SNIP END ===/{ /=== SNIP START ===/! { /=== SNIP END ===/! p } }' $tmp > $raw
+formatted=$(mktemp)
+prettier --use-tabs $raw > $formatted
+solhint --fix $formatted
+
+mv $formatted $OUTPUT
\ No newline at end of file
addedMakefilediffbeforeafterboth
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+.PHONY: _eth_codegen
+_eth_codegen:
+
+.PHONY: regenerate_solidity
+regenerate_solidity:
+	PACKAGE=pallet-nft NAME=eth::erc::fungible_iface OUTPUT=./tests/src/eth/api/UniqueFungible.sol ./.maintain/scripts/generate_api.sh
+	PACKAGE=pallet-nft NAME=eth::erc::nft_iface OUTPUT=./tests/src/eth/api/UniqueNFT.sol ./.maintain/scripts/generate_api.sh
+	PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_iface OUTPUT=./tests/src/eth/api/ContractHelpers.sol ./.maintain/scripts/generate_api.sh
+
+	PACKAGE=pallet-nft NAME=eth::erc::fungible_impl OUTPUT=./pallets/nft/src/eth/stubs/UniqueFungible.sol ./.maintain/scripts/generate_api.sh
+	PACKAGE=pallet-nft NAME=eth::erc::nft_impl OUTPUT=./pallets/nft/src/eth/stubs/UniqueNFT.sol ./.maintain/scripts/generate_api.sh
+	PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_impl OUTPUT=./pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol ./.maintain/scripts/generate_api.sh
+
+NFT_EVM_STUBS=./pallets/nft/src/eth/stubs
+CONTRACT_HELPERS_STUBS=./pallets/evm-contract-helpers/src/stubs/
+
+$(NFT_EVM_STUBS)/UniqueFungible.raw: $(NFT_EVM_STUBS)/UniqueFungible.sol
+	INPUT=$< OUTPUT=$@ ./.maintain/scripts/compile_stub.sh
+$(NFT_EVM_STUBS)/UniqueNFT.raw: $(NFT_EVM_STUBS)/UniqueNFT.sol
+	INPUT=$< OUTPUT=$@ ./.maintain/scripts/compile_stub.sh
+$(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw: $(CONTRACT_HELPERS_STUBS)/ContractHelpers.sol
+	INPUT=$< OUTPUT=$@ ./.maintain/scripts/compile_stub.sh
+
+evm_stubs: $(NFT_EVM_STUBS)/UniqueFungible.raw $(NFT_EVM_STUBS)/UniqueNFT.raw $(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw
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
@@ -34,8 +34,9 @@
 	fn expand_solidity_argument(&self) -> proc_macro2::TokenStream {
 		let camel_name = &self.camel_name;
 		let ty = &self.ty;
+		let indexed = self.indexed;
 		quote! {
-			<NamedArgument<#ty>>::new(#camel_name)
+			<SolidityEventArgument<#ty>>::new(#indexed, #camel_name)
 		}
 	}
 }
modifiedcrates/evm-coder/src/lib.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/lib.rs
+++ b/crates/evm-coder/src/lib.rs
@@ -61,6 +61,29 @@
 	fn call(&mut self, call: types::Msg<C>) -> execution::Result<AbiWriter>;
 }
 
+#[macro_export]
+macro_rules! generate_stubgen {
+	($name:ident, $decl:ident, $is_impl:literal) => {
+		#[test]
+		#[ignore]
+		fn $name() {
+			use sp_std::collections::btree_set::BTreeSet;
+			let mut out = BTreeSet::new();
+			$decl::generate_solidity_interface(&mut out, $is_impl);
+			println!("=== SNIP START ===");
+			println!("// SPDX-License-Identifier: OTHER");
+			println!("// This code is automatically generated");
+			println!();
+			println!("pragma solidity >=0.8.0 <0.9.0;");
+			println!();
+			for b in out {
+				println!("{}", b);
+			}
+			println!("=== SNIP END ===");
+		}
+	};
+}
+
 #[cfg(test)]
 mod tests {
 	use super::*;
modifiedcrates/evm-coder/src/solidity.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity.rs
+++ b/crates/evm-coder/src/solidity.rs
@@ -117,6 +117,41 @@
 	}
 }
 
+pub struct SolidityEventArgument<T>(pub bool, &'static str, PhantomData<*const T>);
+
+impl<T> SolidityEventArgument<T> {
+	pub fn new(indexed: bool, name: &'static str) -> Self {
+		Self(indexed, name, Default::default())
+	}
+}
+
+impl<T: SolidityTypeName> SolidityArguments for SolidityEventArgument<T> {
+	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {
+		if !T::is_void() {
+			T::solidity_name(writer)?;
+			if self.0 {
+				write!(writer, " indexed")?;
+			}
+			write!(writer, " {}", self.1)
+		} else {
+			Ok(())
+		}
+	}
+	fn solidity_get(&self, writer: &mut impl fmt::Write) -> fmt::Result {
+		writeln!(writer, "\t\t{};", self.1)
+	}
+	fn solidity_default(&self, writer: &mut impl fmt::Write) -> fmt::Result {
+		T::solidity_default(writer)
+	}
+	fn len(&self) -> usize {
+		if T::is_void() {
+			0
+		} else {
+			1
+		}
+	}
+}
+
 impl SolidityArguments for () {
 	fn solidity_name(&self, _writer: &mut impl fmt::Write) -> fmt::Result {
 		Ok(())
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -1,5 +1,5 @@
 use core::marker::PhantomData;
-use evm_coder::{abi::AbiWriter, execution::Result, solidity_interface, types::*};
+use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};
 use pallet_evm_coder_substrate::SubstrateRecorder;
 use pallet_evm::{ExitReason, ExitRevert, OnCreate, OnMethodCall, PrecompileOutput};
 use sp_core::H160;
@@ -14,76 +14,76 @@
 
 #[solidity_interface(name = "ContractHelpers")]
 impl<T: Config> ContractHelpers<T> {
-	fn contract_owner(&self, contract: address) -> Result<address> {
+	fn contract_owner(&self, contract_address: address) -> Result<address> {
 		self.0.consume_sload()?;
-		Ok(<Owner<T>>::get(contract))
+		Ok(<Owner<T>>::get(contract_address))
 	}
 
-	fn sponsoring_enabled(&self, contract: address) -> Result<bool> {
+	fn sponsoring_enabled(&self, contract_address: address) -> Result<bool> {
 		self.0.consume_sload()?;
-		Ok(<SelfSponsoring<T>>::get(contract))
+		Ok(<SelfSponsoring<T>>::get(contract_address))
 	}
 
 	fn toggle_sponsoring(
 		&mut self,
 		caller: caller,
-		contract: address,
+		contract_address: address,
 		enabled: bool,
 	) -> Result<void> {
 		self.0.consume_sload()?;
-		<Pallet<T>>::ensure_owner(contract, caller)?;
+		<Pallet<T>>::ensure_owner(contract_address, caller)?;
 		self.0.consume_sstore()?;
-		<Pallet<T>>::toggle_sponsoring(contract, enabled);
+		<Pallet<T>>::toggle_sponsoring(contract_address, enabled);
 		Ok(())
 	}
 
 	fn set_sponsoring_rate_limit(
 		&mut self,
 		caller: caller,
-		contract: address,
+		contract_address: address,
 		rate_limit: uint32,
 	) -> Result<void> {
 		self.0.consume_sload()?;
-		<Pallet<T>>::ensure_owner(contract, caller)?;
+		<Pallet<T>>::ensure_owner(contract_address, caller)?;
 		self.0.consume_sstore()?;
-		<Pallet<T>>::set_sponsoring_rate_limit(contract, rate_limit.into());
+		<Pallet<T>>::set_sponsoring_rate_limit(contract_address, rate_limit.into());
 		Ok(())
 	}
 
-	fn allowed(&self, contract: address, user: address) -> Result<bool> {
+	fn allowed(&self, contract_address: address, user: address) -> Result<bool> {
 		self.0.consume_sload()?;
-		Ok(<Pallet<T>>::allowed(contract, user, true))
+		Ok(<Pallet<T>>::allowed(contract_address, user, true))
 	}
 
-	fn allowlist_enabled(&self, contract: address) -> Result<bool> {
+	fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {
 		self.0.consume_sload()?;
-		Ok(<AllowlistEnabled<T>>::get(contract))
+		Ok(<AllowlistEnabled<T>>::get(contract_address))
 	}
 
 	fn toggle_allowlist(
 		&mut self,
 		caller: caller,
-		contract: address,
+		contract_address: address,
 		enabled: bool,
 	) -> Result<void> {
 		self.0.consume_sload()?;
-		<Pallet<T>>::ensure_owner(contract, caller)?;
+		<Pallet<T>>::ensure_owner(contract_address, caller)?;
 		self.0.consume_sstore()?;
-		<Pallet<T>>::toggle_allowlist(contract, enabled);
+		<Pallet<T>>::toggle_allowlist(contract_address, enabled);
 		Ok(())
 	}
 
 	fn toggle_allowed(
 		&mut self,
 		caller: caller,
-		contract: address,
+		contract_address: address,
 		user: address,
 		allowed: bool,
 	) -> Result<void> {
 		self.0.consume_sload()?;
-		<Pallet<T>>::ensure_owner(contract, caller)?;
+		<Pallet<T>>::ensure_owner(contract_address, caller)?;
 		self.0.consume_sstore()?;
-		<Pallet<T>>::toggle_allowed(contract, user, allowed);
+		<Pallet<T>>::toggle_allowed(contract_address, user, allowed);
 		Ok(())
 	}
 }
@@ -130,7 +130,7 @@
 
 	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {
 		(contract == &T::ContractAddress::get())
-			.then(|| include_bytes!("./stubs/ContractHelpers.bin").to_vec())
+			.then(|| include_bytes!("./stubs/ContractHelpers.raw").to_vec())
 	}
 }
 
@@ -162,3 +162,6 @@
 		None
 	}
 }
+
+generate_stubgen!(contract_helpers_impl, ContractHelpersCall, true);
+generate_stubgen!(contract_helpers_iface, ContractHelpersCall, false);
deletedpallets/evm-contract-helpers/src/stubs/ContractHelpers.bindiffbeforeafterboth

binary blob — no preview

addedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
+++ b/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
@@ -1,40 +1,92 @@
-contract ContractHelpers {
-    uint8 _dummmy = 0;
-    address _dummy_addr = 0x0000000000000000000000000000000000000000;
-	string stub_error = "this contract does not exists, contract helpers are implemented on substrate chain side";
+// SPDX-License-Identifier: OTHER
+// This code is automatically generated
+
+pragma solidity >=0.8.0 <0.9.0;
+
+// Common stubs holder
+contract Dummy {
+	uint8 dummy;
+	string stub_error = "this contract is implemented in native";
+}
+
+contract ContractHelpers is Dummy {
+	function contractOwner(address contractAddress)
+		public
+		view
+		returns (address)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return 0x0000000000000000000000000000000000000000;
+	}
+
+	function sponsoringEnabled(address contractAddress)
+		public
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return false;
+	}
+
+	function toggleSponsoring(address contractAddress, bool enabled) public {
+		require(false, stub_error);
+		contractAddress;
+		enabled;
+		dummy = 0;
+	}
+
+	function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
+		public
+	{
+		require(false, stub_error);
+		contractAddress;
+		rateLimit;
+		dummy = 0;
+	}
+
+	function allowed(address contractAddress, address user)
+		public
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		contractAddress;
+		user;
+		dummy;
+		return false;
+	}
+
+	function allowlistEnabled(address contractAddress)
+		public
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return false;
+	}
 
-    function contractOwner(address contract_address) public view returns (address) {
-        require(false, stub_error);
-        contract_address;
-        return _dummy_addr;
-    }
-    
-    function sponsoringEnabled(address contract_address) public view returns (bool) {
-        require(false, stub_error);
-        contract_address;
-        _dummmy;
-        return false;
-    }
-    
-    function toggleSponsoring(address contract_address, bool enabled) public {
-        require(false, stub_error);
-        contract_address;
-        enabled;
-        _dummmy = 0;
-    }
-    
-    function toggleAllowlist(address contract_address, bool enabled) public {
-        require(false, stub_error);
-        contract_address;
-        enabled;
-        _dummmy = 0;
-    }
-    
-    function toggleAllowed(address contract_address, address user, bool allowed) public {
-        require(false, stub_error);
-        contract_address;
-        user;
-        allowed;
-        _dummmy = 0;
-    }
-}
\ No newline at end of file
+	function toggleAllowlist(address contractAddress, bool enabled) public {
+		require(false, stub_error);
+		contractAddress;
+		enabled;
+		dummy = 0;
+	}
+
+	function toggleAllowed(
+		address contractAddress,
+		address user,
+		bool allowed
+	) public {
+		require(false, stub_error);
+		contractAddress;
+		user;
+		allowed;
+		dummy = 0;
+	}
+}
modifiedpallets/nft/src/eth/erc.rsdiffbeforeafterboth
--- a/pallets/nft/src/eth/erc.rs
+++ b/pallets/nft/src/eth/erc.rs
@@ -1,5 +1,5 @@
 use core::char::{decode_utf16, REPLACEMENT_CHARACTER};
-use evm_coder::{ToLog, execution::Result, solidity, solidity_interface, types::*};
+use evm_coder::{ToLog, execution::Result, generate_stubgen, solidity, solidity_interface, types::*};
 use nft_data_structs::{CreateItemData, CreateNftData};
 use core::convert::TryInto;
 use crate::{
@@ -402,32 +402,10 @@
 
 #[solidity_interface(name = "UniqueFungible", is(ERC165, ERC20))]
 impl<T: Config> CollectionHandle<T> {}
-
-macro_rules! generate_code {
-	($name:ident, $decl:ident, $is_impl:literal) => {
-		#[test]
-		#[ignore]
-		fn $name() {
-			use sp_std::collections::btree_set::BTreeSet;
-			let mut out = BTreeSet::new();
-			$decl::generate_solidity_interface(&mut out, $is_impl);
-			println!("=== SNIP START ===");
-			println!("// SPDX-License-Identifier: OTHER");
-			println!("// This code is automatically generated with `cargo test --package pallet-nft -- eth::erc::{} --exact --nocapture --ignored`", stringify!(name));
-			println!();
-			println!("pragma solidity >=0.8.0 <0.9.0;");
-			println!();
-			for b in out {
-				println!("{}", b);
-			}
-			println!("=== SNIP END ===");
-		}
-	};
-}
 
 // Not a tests, but code generators
-generate_code!(nft_impl, UniqueNFTCall, true);
-generate_code!(nft_iface, UniqueNFTCall, false);
+generate_stubgen!(nft_impl, UniqueNFTCall, true);
+generate_stubgen!(nft_iface, UniqueNFTCall, false);
 
-generate_code!(fungible_impl, UniqueFungibleCall, true);
-generate_code!(fungible_iface, UniqueFungibleCall, false);
+generate_stubgen!(fungible_impl, UniqueFungibleCall, true);
+generate_stubgen!(fungible_iface, UniqueFungibleCall, false);
modifiedpallets/nft/src/eth/mod.rsdiffbeforeafterboth
before · pallets/nft/src/eth/mod.rs
1pub mod account;2pub mod erc;3pub mod sponsoring;45use pallet_evm_coder_substrate::call_internal;6use sp_std::borrow::ToOwned;7use sp_std::vec::Vec;8use pallet_evm::{PrecompileOutput};9use sp_core::{H160, U256};10use frame_support::storage::StorageMap;11use crate::{Config, CollectionById, CollectionHandle, CollectionId, CollectionMode};12use erc::{UniqueFungibleCall, UniqueNFTCall};1314pub struct NftErcSupport<T: Config>(core::marker::PhantomData<T>);1516// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection17// TODO: Unhardcode prefix18const ETH_ACCOUNT_PREFIX: [u8; 16] = [19	0x17, 0xc4, 0xe6, 0x45, 0x3c, 0xc4, 0x9a, 0xaa, 0xae, 0xac, 0xa8, 0x94, 0xe6, 0xd9, 0x68, 0x3e,20];2122fn map_eth_to_id(eth: &H160) -> Option<CollectionId> {23	if eth[0..16] != ETH_ACCOUNT_PREFIX {24		return None;25	}26	let mut id_bytes = [0; 4];27	id_bytes.copy_from_slice(&eth[16..20]);28	Some(u32::from_be_bytes(id_bytes))29}30pub fn collection_id_to_address(id: u32) -> H160 {31	let mut out = [0; 20];32	out[0..16].copy_from_slice(&ETH_ACCOUNT_PREFIX);33	out[16..20].copy_from_slice(&u32::to_be_bytes(id));34	H160(out)35}3637/*38fn call_internal<T: Config>(39	collection: &mut CollectionHandle<T>,40	caller: caller,41	method_id: u32,42	mut input: AbiReader,43	value: U256,44) -> Result<Option<AbiWriter>> {45	match collection.mode.clone() {46		CollectionMode::Fungible(_) => {47			call_internal();48			let call = match UniqueFungibleCall::parse(method_id, &mut input)? {49				Some(v) => v,50				None => {51					#[cfg(feature = "std")]52					{53						println!("Method not found");54					}55					return Ok(None);56				}57			};58			Ok(Some(<CollectionHandle<T> as UniqueFungible>::call(59				collection,60				Msg {61					call,62					caller,63					value,64				},65			)?))66		}67		CollectionMode::NFT => {68			let call = match UniqueNFTCall::parse(method_id, &mut input)? {69				Some(v) => v,70				None => return Ok(None),71			};72			Ok(Some(<CollectionHandle<T> as UniqueNFT>::call(73				collection,74				Msg {75					call,76					caller,77					value,78				},79			)?))80		}81		_ => Err("erc calls only supported to fungible and nft collections for now".into()),82	}83}*/8485impl<T: Config> pallet_evm::OnMethodCall<T> for NftErcSupport<T> {86	fn is_reserved(target: &H160) -> bool {87		map_eth_to_id(target).is_some()88	}89	fn is_used(target: &H160) -> bool {90		map_eth_to_id(target)91			.map(<CollectionById<T>>::contains_key)92			.unwrap_or(false)93	}94	fn get_code(target: &H160) -> Option<Vec<u8>> {95		map_eth_to_id(target)96			.and_then(<CollectionById<T>>::get)97			.map(|collection| {98				match collection.mode {99					CollectionMode::NFT => include_bytes!("stubs/ERC721.bin") as &[u8],100					CollectionMode::Fungible(_) => include_bytes!("stubs/ERC20.bin") as &[u8],101					CollectionMode::ReFungible => include_bytes!("stubs/ERC1633.bin") as &[u8],102					CollectionMode::Invalid => include_bytes!("stubs/Invalid.bin") as &[u8],103				}104				.to_owned()105			})106	}107	fn call(108		source: &H160,109		target: &H160,110		gas_limit: u64,111		input: &[u8],112		value: U256,113	) -> Option<PrecompileOutput> {114		let mut collection = map_eth_to_id(target)115			.and_then(|id| <CollectionHandle<T>>::get_with_gas_limit(id, gas_limit))?;116		let result = match collection.mode {117			CollectionMode::NFT => {118				call_internal::<UniqueNFTCall, _>(*source, &mut collection, value, input)119			}120			CollectionMode::Fungible(_) => {121				call_internal::<UniqueFungibleCall, _>(*source, &mut collection, value, input)122			}123			_ => return None,124		};125		collection.recorder.evm_to_precompile_output(result)126	}127}
deletedpallets/nft/src/eth/stubs/ERC1633.bindiffbeforeafterboth
--- a/pallets/nft/src/eth/stubs/ERC1633.bin
+++ /dev/null
@@ -1 +0,0 @@
-TODO
\ No newline at end of file
deletedpallets/nft/src/eth/stubs/ERC20.bindiffbeforeafterboth

binary blob — no preview

deletedpallets/nft/src/eth/stubs/ERC20.soldiffbeforeafterboth
--- a/pallets/nft/src/eth/stubs/ERC20.sol
+++ /dev/null
@@ -1,94 +0,0 @@
-// SPDX-License-Identifier: OTHER
-// This code is automatically generated with `cargo test --package pallet-nft -- eth::erc::name --exact --nocapture --ignored`
-
-pragma solidity >=0.8.0 <0.9.0;
-
-// Common stubs holder
-contract Dummy {
-	uint8 dummy;
-	string stub_error = "this contract is implemented in native";
-}
-
-// Inline
-contract ERC20Events {
-	event Transfer(address from, address to, uint256 value);
-	event Approval(address owner, address spender, uint256 value);
-}
-
-// Inline
-contract InlineNameSymbol is Dummy {
-	function name() public view returns (string memory) {
-		require(false, stub_error);
-		dummy;
-		return "";
-	}
-	function symbol() public view returns (string memory) {
-		require(false, stub_error);
-		dummy;
-		return "";
-	}
-}
-
-// Inline
-contract InlineTotalSupply is Dummy {
-	function totalSupply() public view returns (uint256) {
-		require(false, stub_error);
-		dummy;
-		return 0;
-	}
-}
-
-contract ERC165 is Dummy {
-	function supportsInterface(uint32 interfaceId) public view returns (bool) {
-		require(false, stub_error);
-		interfaceId;
-		dummy;
-		return false;
-	}
-}
-
-contract ERC20 is Dummy, InlineNameSymbol, InlineTotalSupply, ERC20Events {
-	function decimals() public view returns (uint8) {
-		require(false, stub_error);
-		dummy;
-		return 0;
-	}
-	function balanceOf(address owner) public view returns (uint256) {
-		require(false, stub_error);
-		owner;
-		dummy;
-		return 0;
-	}
-	function transfer(address to, uint256 amount) public returns (bool) {
-		require(false, stub_error);
-		to;
-		amount;
-		dummy = 0;
-		return false;
-	}
-	function transferFrom(address from, address to, uint256 amount) public returns (bool) {
-		require(false, stub_error);
-		from;
-		to;
-		amount;
-		dummy = 0;
-		return false;
-	}
-	function approve(address spender, uint256 amount) public returns (bool) {
-		require(false, stub_error);
-		spender;
-		amount;
-		dummy = 0;
-		return false;
-	}
-	function allowance(address owner, address spender) public view returns (uint256) {
-		require(false, stub_error);
-		owner;
-		spender;
-		dummy;
-		return 0;
-	}
-}
-
-contract UniqueFungible is Dummy, ERC165, ERC20 {
-}
\ No newline at end of file
deletedpallets/nft/src/eth/stubs/ERC721.bindiffbeforeafterboth

binary blob — no preview

deletedpallets/nft/src/eth/stubs/ERC721.soldiffbeforeafterboth
--- a/pallets/nft/src/eth/stubs/ERC721.sol
+++ /dev/null
@@ -1,194 +0,0 @@
-// SPDX-License-Identifier: OTHER
-// This code is automatically generated with `cargo test --package pallet-nft -- eth::erc::name --exact --nocapture --ignored`
-
-pragma solidity >=0.8.0 <0.9.0;
-
-// Common stubs holder
-contract Dummy {
-	uint8 dummy;
-	string stub_error = "this contract is implemented in native";
-}
-
-// Inline
-contract ERC721Events {
-	event Transfer(address from, address to, uint256 tokenId);
-	event Approval(address owner, address approved, uint256 tokenId);
-	event ApprovalForAll(address owner, address operator, bool approved);
-}
-
-// Inline
-contract ERC721MintableEvents {
-	event MintingFinished();
-}
-
-// Inline
-contract InlineNameSymbol is Dummy {
-	function name() public view returns (string memory) {
-		require(false, stub_error);
-		dummy;
-		return "";
-	}
-	function symbol() public view returns (string memory) {
-		require(false, stub_error);
-		dummy;
-		return "";
-	}
-}
-
-// Inline
-contract InlineTotalSupply is Dummy {
-	function totalSupply() public view returns (uint256) {
-		require(false, stub_error);
-		dummy;
-		return 0;
-	}
-}
-
-contract ERC165 is Dummy {
-	function supportsInterface(uint32 interfaceId) public view returns (bool) {
-		require(false, stub_error);
-		interfaceId;
-		dummy;
-		return false;
-	}
-}
-
-contract ERC721 is Dummy, ERC165, ERC721Events {
-	function balanceOf(address owner) public view returns (uint256) {
-		require(false, stub_error);
-		owner;
-		dummy;
-		return 0;
-	}
-	function ownerOf(uint256 tokenId) public view returns (address) {
-		require(false, stub_error);
-		tokenId;
-		dummy;
-		return 0x0000000000000000000000000000000000000000;
-	}
-	function safeTransferFromWithData(address from, address to, uint256 tokenId, bytes memory data) public {
-		require(false, stub_error);
-		from;
-		to;
-		tokenId;
-		data;
-		dummy = 0;
-	}
-	function safeTransferFrom(address from, address to, uint256 tokenId) public {
-		require(false, stub_error);
-		from;
-		to;
-		tokenId;
-		dummy = 0;
-	}
-	function transferFrom(address from, address to, uint256 tokenId) public {
-		require(false, stub_error);
-		from;
-		to;
-		tokenId;
-		dummy = 0;
-	}
-	function approve(address approved, uint256 tokenId) public {
-		require(false, stub_error);
-		approved;
-		tokenId;
-		dummy = 0;
-	}
-	function setApprovalForAll(address operator, bool approved) public {
-		require(false, stub_error);
-		operator;
-		approved;
-		dummy = 0;
-	}
-	function getApproved(uint256 tokenId) public view returns (address) {
-		require(false, stub_error);
-		tokenId;
-		dummy;
-		return 0x0000000000000000000000000000000000000000;
-	}
-	function isApprovedForAll(address owner, address operator) public view returns (address) {
-		require(false, stub_error);
-		owner;
-		operator;
-		dummy;
-		return 0x0000000000000000000000000000000000000000;
-	}
-}
-
-contract ERC721Burnable is Dummy {
-	function burn(uint256 tokenId) public {
-		require(false, stub_error);
-		tokenId;
-		dummy = 0;
-	}
-}
-
-contract ERC721Enumerable is Dummy, InlineTotalSupply {
-	function tokenByIndex(uint256 index) public view returns (uint256) {
-		require(false, stub_error);
-		index;
-		dummy;
-		return 0;
-	}
-	function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) {
-		require(false, stub_error);
-		owner;
-		index;
-		dummy;
-		return 0;
-	}
-}
-
-contract ERC721Metadata is Dummy, InlineNameSymbol {
-	function tokenURI(uint256 tokenId) public view returns (string memory) {
-		require(false, stub_error);
-		tokenId;
-		dummy;
-		return "";
-	}
-}
-
-contract ERC721Mintable is Dummy, ERC721MintableEvents {
-	function mintingFinished() public view returns (bool) {
-		require(false, stub_error);
-		dummy;
-		return false;
-	}
-	function mint(address to, uint256 tokenId) public returns (bool) {
-		require(false, stub_error);
-		to;
-		tokenId;
-		dummy = 0;
-		return false;
-	}
-	function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) public returns (bool) {
-		require(false, stub_error);
-		to;
-		tokenId;
-		tokenUri;
-		dummy = 0;
-		return false;
-	}
-	function finishMinting() public returns (bool) {
-		require(false, stub_error);
-		dummy = 0;
-		return false;
-	}
-}
-
-contract ERC721UniqueExtensions is Dummy {
-	function transfer(address to, uint256 tokenId) public {
-		require(false, stub_error);
-		to;
-		tokenId;
-		dummy = 0;
-	}
-	function nextTokenId() public view returns (uint256) {
-		require(false, stub_error);
-		dummy;
-		return 0;
-	}
-}
-
-contract UniqueNFT is Dummy, ERC165, ERC721, ERC721Metadata, ERC721Enumerable, ERC721UniqueExtensions, ERC721Mintable, ERC721Burnable {
-}
\ No newline at end of file
deletedpallets/nft/src/eth/stubs/Invalid.bindiffbeforeafterboth
--- a/pallets/nft/src/eth/stubs/Invalid.bin
+++ /dev/null
@@ -1 +0,0 @@
-TODO
\ No newline at end of file
addedpallets/nft/src/eth/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

addedpallets/nft/src/eth/stubs/UniqueFungible.soldiffbeforeafterboth
--- /dev/null
+++ b/pallets/nft/src/eth/stubs/UniqueFungible.sol
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: OTHER
+// This code is automatically generated
+
+pragma solidity >=0.8.0 <0.9.0;
+
+// Common stubs holder
+contract Dummy {
+	uint8 dummy;
+	string stub_error = "this contract is implemented in native";
+}
+
+// Inline
+contract ERC20Events {
+	event Transfer(address indexed from, address indexed to, uint256 value);
+	event Approval(
+		address indexed owner,
+		address indexed spender,
+		uint256 value
+	);
+}
+
+// Inline
+contract InlineNameSymbol is Dummy {
+	function name() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
+	function symbol() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+}
+
+// Inline
+contract InlineTotalSupply is Dummy {
+	function totalSupply() public view returns (uint256) {
+		require(false, stub_error);
+		dummy;
+		return 0;
+	}
+}
+
+contract ERC165 is Dummy {
+	function supportsInterface(uint32 interfaceId) public view returns (bool) {
+		require(false, stub_error);
+		interfaceId;
+		dummy;
+		return false;
+	}
+}
+
+contract ERC20 is Dummy, InlineNameSymbol, InlineTotalSupply, ERC20Events {
+	function decimals() public view returns (uint8) {
+		require(false, stub_error);
+		dummy;
+		return 0;
+	}
+
+	function balanceOf(address owner) public view returns (uint256) {
+		require(false, stub_error);
+		owner;
+		dummy;
+		return 0;
+	}
+
+	function transfer(address to, uint256 amount) public returns (bool) {
+		require(false, stub_error);
+		to;
+		amount;
+		dummy = 0;
+		return false;
+	}
+
+	function transferFrom(
+		address from,
+		address to,
+		uint256 amount
+	) public returns (bool) {
+		require(false, stub_error);
+		from;
+		to;
+		amount;
+		dummy = 0;
+		return false;
+	}
+
+	function approve(address spender, uint256 amount) public returns (bool) {
+		require(false, stub_error);
+		spender;
+		amount;
+		dummy = 0;
+		return false;
+	}
+
+	function allowance(address owner, address spender)
+		public
+		view
+		returns (uint256)
+	{
+		require(false, stub_error);
+		owner;
+		spender;
+		dummy;
+		return 0;
+	}
+}
+
+contract UniqueFungible is Dummy, ERC165, ERC20 {}
addedpallets/nft/src/eth/stubs/UniqueInvalid.rawdiffbeforeafterboth
--- /dev/null
+++ b/pallets/nft/src/eth/stubs/UniqueInvalid.raw
@@ -0,0 +1 @@
+TODO
\ No newline at end of file
addedpallets/nft/src/eth/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

addedpallets/nft/src/eth/stubs/UniqueNFT.soldiffbeforeafterboth
--- /dev/null
+++ b/pallets/nft/src/eth/stubs/UniqueNFT.sol
@@ -0,0 +1,253 @@
+// SPDX-License-Identifier: OTHER
+// This code is automatically generated
+
+pragma solidity >=0.8.0 <0.9.0;
+
+// Common stubs holder
+contract Dummy {
+	uint8 dummy;
+	string stub_error = "this contract is implemented in native";
+}
+
+// Inline
+contract ERC721Events {
+	event Transfer(
+		address indexed from,
+		address indexed to,
+		uint256 indexed tokenId
+	);
+	event Approval(
+		address indexed owner,
+		address indexed approved,
+		uint256 indexed tokenId
+	);
+	event ApprovalForAll(
+		address indexed owner,
+		address indexed operator,
+		bool approved
+	);
+}
+
+// Inline
+contract ERC721MintableEvents {
+	event MintingFinished();
+}
+
+// Inline
+contract InlineNameSymbol is Dummy {
+	function name() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
+	function symbol() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+}
+
+// Inline
+contract InlineTotalSupply is Dummy {
+	function totalSupply() public view returns (uint256) {
+		require(false, stub_error);
+		dummy;
+		return 0;
+	}
+}
+
+contract ERC165 is Dummy {
+	function supportsInterface(uint32 interfaceId) public view returns (bool) {
+		require(false, stub_error);
+		interfaceId;
+		dummy;
+		return false;
+	}
+}
+
+contract ERC721 is Dummy, ERC165, ERC721Events {
+	function balanceOf(address owner) public view returns (uint256) {
+		require(false, stub_error);
+		owner;
+		dummy;
+		return 0;
+	}
+
+	function ownerOf(uint256 tokenId) public view returns (address) {
+		require(false, stub_error);
+		tokenId;
+		dummy;
+		return 0x0000000000000000000000000000000000000000;
+	}
+
+	function safeTransferFromWithData(
+		address from,
+		address to,
+		uint256 tokenId,
+		bytes memory data
+	) public {
+		require(false, stub_error);
+		from;
+		to;
+		tokenId;
+		data;
+		dummy = 0;
+	}
+
+	function safeTransferFrom(
+		address from,
+		address to,
+		uint256 tokenId
+	) public {
+		require(false, stub_error);
+		from;
+		to;
+		tokenId;
+		dummy = 0;
+	}
+
+	function transferFrom(
+		address from,
+		address to,
+		uint256 tokenId
+	) public {
+		require(false, stub_error);
+		from;
+		to;
+		tokenId;
+		dummy = 0;
+	}
+
+	function approve(address approved, uint256 tokenId) public {
+		require(false, stub_error);
+		approved;
+		tokenId;
+		dummy = 0;
+	}
+
+	function setApprovalForAll(address operator, bool approved) public {
+		require(false, stub_error);
+		operator;
+		approved;
+		dummy = 0;
+	}
+
+	function getApproved(uint256 tokenId) public view returns (address) {
+		require(false, stub_error);
+		tokenId;
+		dummy;
+		return 0x0000000000000000000000000000000000000000;
+	}
+
+	function isApprovedForAll(address owner, address operator)
+		public
+		view
+		returns (address)
+	{
+		require(false, stub_error);
+		owner;
+		operator;
+		dummy;
+		return 0x0000000000000000000000000000000000000000;
+	}
+}
+
+contract ERC721Burnable is Dummy {
+	function burn(uint256 tokenId) public {
+		require(false, stub_error);
+		tokenId;
+		dummy = 0;
+	}
+}
+
+contract ERC721Enumerable is Dummy, InlineTotalSupply {
+	function tokenByIndex(uint256 index) public view returns (uint256) {
+		require(false, stub_error);
+		index;
+		dummy;
+		return 0;
+	}
+
+	function tokenOfOwnerByIndex(address owner, uint256 index)
+		public
+		view
+		returns (uint256)
+	{
+		require(false, stub_error);
+		owner;
+		index;
+		dummy;
+		return 0;
+	}
+}
+
+contract ERC721Metadata is Dummy, InlineNameSymbol {
+	function tokenURI(uint256 tokenId) public view returns (string memory) {
+		require(false, stub_error);
+		tokenId;
+		dummy;
+		return "";
+	}
+}
+
+contract ERC721Mintable is Dummy, ERC721MintableEvents {
+	function mintingFinished() public view returns (bool) {
+		require(false, stub_error);
+		dummy;
+		return false;
+	}
+
+	function mint(address to, uint256 tokenId) public returns (bool) {
+		require(false, stub_error);
+		to;
+		tokenId;
+		dummy = 0;
+		return false;
+	}
+
+	function mintWithTokenURI(
+		address to,
+		uint256 tokenId,
+		string memory tokenUri
+	) public returns (bool) {
+		require(false, stub_error);
+		to;
+		tokenId;
+		tokenUri;
+		dummy = 0;
+		return false;
+	}
+
+	function finishMinting() public returns (bool) {
+		require(false, stub_error);
+		dummy = 0;
+		return false;
+	}
+}
+
+contract ERC721UniqueExtensions is Dummy {
+	function transfer(address to, uint256 tokenId) public {
+		require(false, stub_error);
+		to;
+		tokenId;
+		dummy = 0;
+	}
+
+	function nextTokenId() public view returns (uint256) {
+		require(false, stub_error);
+		dummy;
+		return 0;
+	}
+}
+
+contract UniqueNFT is
+	Dummy,
+	ERC165,
+	ERC721,
+	ERC721Metadata,
+	ERC721Enumerable,
+	ERC721UniqueExtensions,
+	ERC721Mintable,
+	ERC721Burnable
+{}
addedpallets/nft/src/eth/stubs/UniqueRefungible.rawdiffbeforeafterboth
--- /dev/null
+++ b/pallets/nft/src/eth/stubs/UniqueRefungible.raw
@@ -0,0 +1 @@
+TODO
\ No newline at end of file
modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -9,22 +9,35 @@
 }
 
 interface ContractHelpers is Dummy {
-	function contractOwner(address contr) external view returns (address);
+	function contractOwner(address contractAddress)
+		external
+		view
+		returns (address);
 
-	function sponsoringEnabled(address contr) external view returns (bool);
+	function sponsoringEnabled(address contractAddress)
+		external
+		view
+		returns (bool);
 
-	function toggleSponsoring(address contr, bool enabled) external;
+	function toggleSponsoring(address contractAddress, bool enabled) external;
 
-	function setSponsoringRateLimit(address contr, uint32 rateLimit) external;
+	function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
+		external;
 
-	function allowed(address contr, address user) external view returns (bool);
+	function allowed(address contractAddress, address user)
+		external
+		view
+		returns (bool);
 
-	function allowlistEnabled(address contr) external view returns (bool);
+	function allowlistEnabled(address contractAddress)
+		external
+		view
+		returns (bool);
 
-	function toggleAllowlist(address contr, bool enabled) external;
+	function toggleAllowlist(address contractAddress, bool enabled) external;
 
 	function toggleAllowed(
-		address contr,
+		address contractAddress,
 		address user,
 		bool allowed
 	) external;