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
--- a/pallets/nft/src/eth/mod.rs
+++ b/pallets/nft/src/eth/mod.rs
@@ -96,10 +96,14 @@
 			.and_then(<CollectionById<T>>::get)
 			.map(|collection| {
 				match collection.mode {
-					CollectionMode::NFT => include_bytes!("stubs/ERC721.bin") as &[u8],
-					CollectionMode::Fungible(_) => include_bytes!("stubs/ERC20.bin") as &[u8],
-					CollectionMode::ReFungible => include_bytes!("stubs/ERC1633.bin") as &[u8],
-					CollectionMode::Invalid => include_bytes!("stubs/Invalid.bin") as &[u8],
+					CollectionMode::NFT => include_bytes!("stubs/UniqueNFT.raw") as &[u8],
+					CollectionMode::Fungible(_) => {
+						include_bytes!("stubs/UniqueFungible.raw") as &[u8]
+					}
+					CollectionMode::ReFungible => {
+						include_bytes!("stubs/UniqueRefungible.raw") as &[u8]
+					}
+					CollectionMode::Invalid => include_bytes!("stubs/UniqueInvalid.raw") as &[u8],
 				}
 				.to_owned()
 			})
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
after · pallets/nft/src/eth/stubs/UniqueNFT.sol
1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56// Common stubs holder7contract Dummy {8	uint8 dummy;9	string stub_error = "this contract is implemented in native";10}1112// Inline13contract ERC721Events {14	event Transfer(15		address indexed from,16		address indexed to,17		uint256 indexed tokenId18	);19	event Approval(20		address indexed owner,21		address indexed approved,22		uint256 indexed tokenId23	);24	event ApprovalForAll(25		address indexed owner,26		address indexed operator,27		bool approved28	);29}3031// Inline32contract ERC721MintableEvents {33	event MintingFinished();34}3536// Inline37contract InlineNameSymbol is Dummy {38	function name() public view returns (string memory) {39		require(false, stub_error);40		dummy;41		return "";42	}4344	function symbol() public view returns (string memory) {45		require(false, stub_error);46		dummy;47		return "";48	}49}5051// Inline52contract InlineTotalSupply is Dummy {53	function totalSupply() public view returns (uint256) {54		require(false, stub_error);55		dummy;56		return 0;57	}58}5960contract ERC165 is Dummy {61	function supportsInterface(uint32 interfaceId) public view returns (bool) {62		require(false, stub_error);63		interfaceId;64		dummy;65		return false;66	}67}6869contract ERC721 is Dummy, ERC165, ERC721Events {70	function balanceOf(address owner) public view returns (uint256) {71		require(false, stub_error);72		owner;73		dummy;74		return 0;75	}7677	function ownerOf(uint256 tokenId) public view returns (address) {78		require(false, stub_error);79		tokenId;80		dummy;81		return 0x0000000000000000000000000000000000000000;82	}8384	function safeTransferFromWithData(85		address from,86		address to,87		uint256 tokenId,88		bytes memory data89	) public {90		require(false, stub_error);91		from;92		to;93		tokenId;94		data;95		dummy = 0;96	}9798	function safeTransferFrom(99		address from,100		address to,101		uint256 tokenId102	) public {103		require(false, stub_error);104		from;105		to;106		tokenId;107		dummy = 0;108	}109110	function transferFrom(111		address from,112		address to,113		uint256 tokenId114	) public {115		require(false, stub_error);116		from;117		to;118		tokenId;119		dummy = 0;120	}121122	function approve(address approved, uint256 tokenId) public {123		require(false, stub_error);124		approved;125		tokenId;126		dummy = 0;127	}128129	function setApprovalForAll(address operator, bool approved) public {130		require(false, stub_error);131		operator;132		approved;133		dummy = 0;134	}135136	function getApproved(uint256 tokenId) public view returns (address) {137		require(false, stub_error);138		tokenId;139		dummy;140		return 0x0000000000000000000000000000000000000000;141	}142143	function isApprovedForAll(address owner, address operator)144		public145		view146		returns (address)147	{148		require(false, stub_error);149		owner;150		operator;151		dummy;152		return 0x0000000000000000000000000000000000000000;153	}154}155156contract ERC721Burnable is Dummy {157	function burn(uint256 tokenId) public {158		require(false, stub_error);159		tokenId;160		dummy = 0;161	}162}163164contract ERC721Enumerable is Dummy, InlineTotalSupply {165	function tokenByIndex(uint256 index) public view returns (uint256) {166		require(false, stub_error);167		index;168		dummy;169		return 0;170	}171172	function tokenOfOwnerByIndex(address owner, uint256 index)173		public174		view175		returns (uint256)176	{177		require(false, stub_error);178		owner;179		index;180		dummy;181		return 0;182	}183}184185contract ERC721Metadata is Dummy, InlineNameSymbol {186	function tokenURI(uint256 tokenId) public view returns (string memory) {187		require(false, stub_error);188		tokenId;189		dummy;190		return "";191	}192}193194contract ERC721Mintable is Dummy, ERC721MintableEvents {195	function mintingFinished() public view returns (bool) {196		require(false, stub_error);197		dummy;198		return false;199	}200201	function mint(address to, uint256 tokenId) public returns (bool) {202		require(false, stub_error);203		to;204		tokenId;205		dummy = 0;206		return false;207	}208209	function mintWithTokenURI(210		address to,211		uint256 tokenId,212		string memory tokenUri213	) public returns (bool) {214		require(false, stub_error);215		to;216		tokenId;217		tokenUri;218		dummy = 0;219		return false;220	}221222	function finishMinting() public returns (bool) {223		require(false, stub_error);224		dummy = 0;225		return false;226	}227}228229contract ERC721UniqueExtensions is Dummy {230	function transfer(address to, uint256 tokenId) public {231		require(false, stub_error);232		to;233		tokenId;234		dummy = 0;235	}236237	function nextTokenId() public view returns (uint256) {238		require(false, stub_error);239		dummy;240		return 0;241	}242}243244contract UniqueNFT is245	Dummy,246	ERC165,247	ERC721,248	ERC721Metadata,249	ERC721Enumerable,250	ERC721UniqueExtensions,251	ERC721Mintable,252	ERC721Burnable253{}
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;