git.delta.rocks / unique-network / refs/commits / b11eb43d69dc

difftreelog

feat regenerate solidity stubs

Yaroslav Bolyukin2021-11-02parent: #44992fc.patch.diff
in: master

15 files changed

modified.maintain/scripts/compile_stub.shdiffbeforeafterboth
--- a/.maintain/scripts/compile_stub.sh
+++ b/.maintain/scripts/compile_stub.sh
@@ -6,9 +6,9 @@
 tmp=$(mktemp -d)
 cd $tmp
 cp $dir/$INPUT input.sol
-solcjs --optimize --bin input.sol
+solcjs --optimize --bin input.sol -o $PWD
 
 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
+mv out.raw $dir/$OUTPUT
modified.maintain/scripts/generate_api.shdiffbeforeafterboth
--- a/.maintain/scripts/generate_api.sh
+++ b/.maintain/scripts/generate_api.sh
@@ -9,4 +9,4 @@
 prettier --use-tabs $raw > $formatted
 solhint --fix $formatted
 
-mv $formatted $OUTPUT
\ No newline at end of file
+mv $formatted $OUTPUT
modifiedMakefilediffbeforeafterboth
--- a/Makefile
+++ b/Makefile
@@ -8,25 +8,26 @@
 
 .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-fungible NAME=erc::gen_iface OUTPUT=./tests/src/eth/api/UniqueFungible.sol ./.maintain/scripts/generate_api.sh
+	PACKAGE=pallet-nonfungible NAME=erc::gen_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-fungible NAME=erc::gen_impl OUTPUT=./pallets/fungible/src/stubs/UniqueFungible.sol ./.maintain/scripts/generate_api.sh
+	PACKAGE=pallet-nonfungible NAME=erc::gen_impl OUTPUT=./pallets/nonfungible/src/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
+FUNGIBLE_EVM_STUBS=./pallets/fungible/src/stubs
+NONFUNGIBLE_EVM_STUBS=./pallets/nonfungible/src/stubs
 CONTRACT_HELPERS_STUBS=./pallets/evm-contract-helpers/src/stubs/
 
-$(NFT_EVM_STUBS)/UniqueFungible.raw: $(NFT_EVM_STUBS)/UniqueFungible.sol
+$(FUNGIBLE_EVM_STUBS)/UniqueFungible.raw: $(FUNGIBLE_EVM_STUBS)/UniqueFungible.sol
 	INPUT=$< OUTPUT=$@ ./.maintain/scripts/compile_stub.sh
-$(NFT_EVM_STUBS)/UniqueNFT.raw: $(NFT_EVM_STUBS)/UniqueNFT.sol
+$(NONFUNGIBLE_EVM_STUBS)/UniqueNFT.raw: $(NONFUNGIBLE_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
+evm_stubs: $(FUNGIBLE_EVM_STUBS)/UniqueFungible.raw $(NONFUNGIBLE_EVM_STUBS)/UniqueNFT.raw $(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw
 
 .PHONY: _bench
 _bench:
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
@@ -714,9 +714,9 @@
 						)*),
 					};
 					if is_impl {
-						tc.collect("// Common stubs holder\ncontract Dummy {\n\tuint8 dummy;\n\tstring stub_error = \"this contract is implemented in native\";\n}\ninterface ERC165 {\n\tfunction supportsInterface(bytes4 interfaceID) external view returns (bool) {\n\t\trequire(false, stub_error);\n\t\tinterfaceID;\n\t\treturn true;\n\t}\n}\n".into());
+						tc.collect("// Common stubs holder\ncontract Dummy {\n\tuint8 dummy;\n\tstring stub_error = \"this contract is implemented in native\";\n}\ncontract ERC165 is Dummy {\n\tfunction supportsInterface(bytes4 interfaceID) external view returns (bool) {\n\t\trequire(false, stub_error);\n\t\tinterfaceID;\n\t\treturn true;\n\t}\n}\n".into());
 					} else {
-						tc.collect("// Common stubs holder\ninterface Dummy {\n}\ninterface ERC165 {\n\tfunction supportsInterface(bytes4 interfaceID) external view returns (bool);\n}\n".into());
+						tc.collect("// Common stubs holder\ninterface Dummy {\n}\ninterface ERC165 is Dummy {\n\tfunction supportsInterface(bytes4 interfaceID) external view returns (bool);\n}\n".into());
 					}
 					#(
 						#solidity_generators
modifiedpallets/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
@@ -9,7 +9,19 @@
 	string stub_error = "this contract is implemented in native";
 }
 
-contract ContractHelpers is Dummy {
+contract ERC165 is Dummy {
+	function supportsInterface(bytes4 interfaceID)
+		external
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		interfaceID;
+		return true;
+	}
+}
+
+contract ContractHelpers is Dummy, ERC165 {
 	// Selector: contractOwner(address) 5152b14c
 	function contractOwner(address contractAddress)
 		public
modifiedpallets/fungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/fungible/Cargo.toml
+++ b/pallets/fungible/Cargo.toml
@@ -18,8 +18,8 @@
 pallet-common = { default-features = false, path = '../common' }
 nft-data-structs = { default-features = false, path = '../../primitives/nft' }
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
+pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
 ethereum = { git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }
-pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
 frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
 scale-info = { version = "1.0.0", default-features = false, features = [
     "derive",
@@ -36,6 +36,7 @@
     "pallet-common/std",
     "evm-coder/std",
     "ethereum/std",
+    "pallet-evm-coder-substrate/std",
     'frame-benchmarking/std',
 ]
 runtime-benchmarks = ['frame-benchmarking', 'pallet-common/runtime-benchmarks']
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -111,7 +111,7 @@
 #[solidity_interface(name = "UniqueFungible", is(ERC20))]
 impl<T: Config> FungibleHandle<T> {}
 
-generate_stubgen!(get_impl, UniqueFungibleCall, true);
+generate_stubgen!(gen_impl, UniqueFungibleCall, true);
 generate_stubgen!(gen_iface, UniqueFungibleCall, false);
 
 impl<T: Config> CommonEvmHandler for FungibleHandle<T> {
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -9,6 +9,18 @@
 	string stub_error = "this contract is implemented in native";
 }
 
+contract ERC165 is Dummy {
+	function supportsInterface(bytes4 interfaceID)
+		external
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		interfaceID;
+		return true;
+	}
+}
+
 // Inline
 contract ERC20Events {
 	event Transfer(address indexed from, address indexed to, uint256 value);
@@ -19,8 +31,7 @@
 	);
 }
 
-// Inline
-contract InlineNameSymbol is Dummy {
+contract ERC20 is Dummy, ERC165, ERC20Events {
 	// Selector: name() 06fdde03
 	function name() public view returns (string memory) {
 		require(false, stub_error);
@@ -34,29 +45,14 @@
 		dummy;
 		return "";
 	}
-}
 
-// Inline
-contract InlineTotalSupply is Dummy {
 	// Selector: totalSupply() 18160ddd
 	function totalSupply() public view returns (uint256) {
 		require(false, stub_error);
 		dummy;
 		return 0;
 	}
-}
 
-contract ERC165 is Dummy {
-	// Selector: supportsInterface(bytes4) 01ffc9a7
-	function supportsInterface(uint32 interfaceId) public view returns (bool) {
-		require(false, stub_error);
-		interfaceId;
-		dummy;
-		return false;
-	}
-}
-
-contract ERC20 is Dummy, InlineNameSymbol, InlineTotalSupply, ERC20Events {
 	// Selector: decimals() 313ce567
 	function decimals() public view returns (uint8) {
 		require(false, stub_error);
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
before · pallets/nonfungible/src/stubs/UniqueNFT.sol
1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8	uint256 field_0;9	string field_1;10}1112// Common stubs holder13contract Dummy {14	uint8 dummy;15	string stub_error = "this contract is implemented in native";16}1718// Inline19contract ERC721Events {20	event Transfer(21		address indexed from,22		address indexed to,23		uint256 indexed tokenId24	);25	event Approval(26		address indexed owner,27		address indexed approved,28		uint256 indexed tokenId29	);30	event ApprovalForAll(31		address indexed owner,32		address indexed operator,33		bool approved34	);35}3637// Inline38contract ERC721MintableEvents {39	event MintingFinished();40}4142// Inline43contract InlineNameSymbol is Dummy {44	// Selector: name() 06fdde0345	function name() public view returns (string memory) {46		require(false, stub_error);47		dummy;48		return "";49	}5051	// Selector: symbol() 95d89b4152	function symbol() public view returns (string memory) {53		require(false, stub_error);54		dummy;55		return "";56	}57}5859// Inline60contract InlineTotalSupply is Dummy {61	// Selector: totalSupply() 18160ddd62	function totalSupply() public view returns (uint256) {63		require(false, stub_error);64		dummy;65		return 0;66	}67}6869contract ERC165 is Dummy {70	// Selector: supportsInterface(bytes4) 01ffc9a771	function supportsInterface(uint32 interfaceId) public view returns (bool) {72		require(false, stub_error);73		interfaceId;74		dummy;75		return false;76	}77}7879contract ERC721 is Dummy, ERC165, ERC721Events {80	// Selector: balanceOf(address) 70a0823181	function balanceOf(address owner) public view returns (uint256) {82		require(false, stub_error);83		owner;84		dummy;85		return 0;86	}8788	// Selector: ownerOf(uint256) 6352211e89	function ownerOf(uint256 tokenId) public view returns (address) {90		require(false, stub_error);91		tokenId;92		dummy;93		return 0x0000000000000000000000000000000000000000;94	}9596	// Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a1167297	function safeTransferFromWithData(98		address from,99		address to,100		uint256 tokenId,101		bytes memory data102	) public {103		require(false, stub_error);104		from;105		to;106		tokenId;107		data;108		dummy = 0;109	}110111	// Selector: safeTransferFrom(address,address,uint256) 42842e0e112	function safeTransferFrom(113		address from,114		address to,115		uint256 tokenId116	) public {117		require(false, stub_error);118		from;119		to;120		tokenId;121		dummy = 0;122	}123124	// Selector: transferFrom(address,address,uint256) 23b872dd125	function transferFrom(126		address from,127		address to,128		uint256 tokenId129	) public {130		require(false, stub_error);131		from;132		to;133		tokenId;134		dummy = 0;135	}136137	// Selector: approve(address,uint256) 095ea7b3138	function approve(address approved, uint256 tokenId) public {139		require(false, stub_error);140		approved;141		tokenId;142		dummy = 0;143	}144145	// Selector: setApprovalForAll(address,bool) a22cb465146	function setApprovalForAll(address operator, bool approved) public {147		require(false, stub_error);148		operator;149		approved;150		dummy = 0;151	}152153	// Selector: getApproved(uint256) 081812fc154	function getApproved(uint256 tokenId) public view returns (address) {155		require(false, stub_error);156		tokenId;157		dummy;158		return 0x0000000000000000000000000000000000000000;159	}160161	// Selector: isApprovedForAll(address,address) e985e9c5162	function isApprovedForAll(address owner, address operator)163		public164		view165		returns (address)166	{167		require(false, stub_error);168		owner;169		operator;170		dummy;171		return 0x0000000000000000000000000000000000000000;172	}173}174175contract ERC721Burnable is Dummy {176	// Selector: burn(uint256) 42966c68177	function burn(uint256 tokenId) public {178		require(false, stub_error);179		tokenId;180		dummy = 0;181	}182}183184contract ERC721Enumerable is Dummy, InlineTotalSupply {185	// Selector: tokenByIndex(uint256) 4f6ccce7186	function tokenByIndex(uint256 index) public view returns (uint256) {187		require(false, stub_error);188		index;189		dummy;190		return 0;191	}192193	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59194	function tokenOfOwnerByIndex(address owner, uint256 index)195		public196		view197		returns (uint256)198	{199		require(false, stub_error);200		owner;201		index;202		dummy;203		return 0;204	}205}206207contract ERC721Metadata is Dummy, InlineNameSymbol {208	// Selector: tokenURI(uint256) c87b56dd209	function tokenURI(uint256 tokenId) public view returns (string memory) {210		require(false, stub_error);211		tokenId;212		dummy;213		return "";214	}215}216217contract ERC721Mintable is Dummy, ERC721MintableEvents {218	// Selector: mintingFinished() 05d2035b219	function mintingFinished() public view returns (bool) {220		require(false, stub_error);221		dummy;222		return false;223	}224225	// Selector: mint(address,uint256) 40c10f19226	function mint(address to, uint256 tokenId) public returns (bool) {227		require(false, stub_error);228		to;229		tokenId;230		dummy = 0;231		return false;232	}233234	// Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f235	function mintWithTokenURI(236		address to,237		uint256 tokenId,238		string memory tokenUri239	) public returns (bool) {240		require(false, stub_error);241		to;242		tokenId;243		tokenUri;244		dummy = 0;245		return false;246	}247248	// Selector: finishMinting() 7d64bcb4249	function finishMinting() public returns (bool) {250		require(false, stub_error);251		dummy = 0;252		return false;253	}254}255256contract ERC721UniqueExtensions is Dummy {257	// Selector: transfer(address,uint256) a9059cbb258	function transfer(address to, uint256 tokenId) public {259		require(false, stub_error);260		to;261		tokenId;262		dummy = 0;263	}264265	// Selector: nextTokenId() 75794a3c266	function nextTokenId() public view returns (uint256) {267		require(false, stub_error);268		dummy;269		return 0;270	}271272	// Selector: setVariableMetadata(uint256,bytes) d4eac26d273	function setVariableMetadata(uint256 tokenId, bytes memory data) public {274		require(false, stub_error);275		tokenId;276		data;277		dummy = 0;278	}279280	// Selector: getVariableMetadata(uint256) e6c5ce6f281	function getVariableMetadata(uint256 tokenId)282		public283		view284		returns (bytes memory)285	{286		require(false, stub_error);287		tokenId;288		dummy;289		return hex"";290	}291292	// Selector: mintBulk(address,uint256[]) 44a9945e293	function mintBulk(address to, uint256[] memory tokenIds)294		public295		returns (bool)296	{297		require(false, stub_error);298		to;299		tokenIds;300		dummy = 0;301		return false;302	}303304	// Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006305	function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)306		public307		returns (bool)308	{309		require(false, stub_error);310		to;311		tokens;312		dummy = 0;313		return false;314	}315}316317contract UniqueNFT is318	Dummy,319	ERC165,320	ERC721,321	ERC721Metadata,322	ERC721Enumerable,323	ERC721UniqueExtensions,324	ERC721Mintable,325	ERC721Burnable326{}
modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -8,7 +8,11 @@
 
 }
 
-interface ContractHelpers is Dummy {
+interface ERC165 is Dummy {
+	function supportsInterface(bytes4 interfaceID) external view returns (bool);
+}
+
+interface ContractHelpers is Dummy, ERC165 {
 	// Selector: contractOwner(address) 5152b14c
 	function contractOwner(address contractAddress)
 		external
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -8,6 +8,10 @@
 
 }
 
+interface ERC165 is Dummy {
+	function supportsInterface(bytes4 interfaceID) external view returns (bool);
+}
+
 // Inline
 interface ERC20Events {
 	event Transfer(address indexed from, address indexed to, uint256 value);
@@ -18,27 +22,16 @@
 	);
 }
 
-// Inline
-interface InlineNameSymbol is Dummy {
+interface ERC20 is Dummy, ERC165, ERC20Events {
 	// Selector: name() 06fdde03
 	function name() external view returns (string memory);
 
 	// Selector: symbol() 95d89b41
 	function symbol() external view returns (string memory);
-}
 
-// Inline
-interface InlineTotalSupply is Dummy {
 	// Selector: totalSupply() 18160ddd
 	function totalSupply() external view returns (uint256);
-}
-
-interface ERC165 is Dummy {
-	// Selector: supportsInterface(bytes4) 01ffc9a7
-	function supportsInterface(uint32 interfaceId) external view returns (bool);
-}
 
-interface ERC20 is Dummy, InlineNameSymbol, InlineTotalSupply, ERC20Events {
 	// Selector: decimals() 313ce567
 	function decimals() external view returns (uint8);
 
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -14,6 +14,10 @@
 
 }
 
+interface ERC165 is Dummy {
+	function supportsInterface(bytes4 interfaceID) external view returns (bool);
+}
+
 // Inline
 interface ERC721Events {
 	event Transfer(
@@ -36,26 +40,6 @@
 // Inline
 interface ERC721MintableEvents {
 	event MintingFinished();
-}
-
-// Inline
-interface InlineNameSymbol is Dummy {
-	// Selector: name() 06fdde03
-	function name() external view returns (string memory);
-
-	// Selector: symbol() 95d89b41
-	function symbol() external view returns (string memory);
-}
-
-// Inline
-interface InlineTotalSupply is Dummy {
-	// Selector: totalSupply() 18160ddd
-	function totalSupply() external view returns (uint256);
-}
-
-interface ERC165 is Dummy {
-	// Selector: supportsInterface(bytes4) 01ffc9a7
-	function supportsInterface(uint32 interfaceId) external view returns (bool);
 }
 
 interface ERC721 is Dummy, ERC165, ERC721Events {
@@ -103,12 +87,12 @@
 		returns (address);
 }
 
-interface ERC721Burnable is Dummy {
+interface ERC721Burnable is Dummy, ERC165 {
 	// Selector: burn(uint256) 42966c68
 	function burn(uint256 tokenId) external;
 }
 
-interface ERC721Enumerable is Dummy, InlineTotalSupply {
+interface ERC721Enumerable is Dummy, ERC165 {
 	// Selector: tokenByIndex(uint256) 4f6ccce7
 	function tokenByIndex(uint256 index) external view returns (uint256);
 
@@ -117,14 +101,23 @@
 		external
 		view
 		returns (uint256);
+
+	// Selector: totalSupply() 18160ddd
+	function totalSupply() external view returns (uint256);
 }
 
-interface ERC721Metadata is Dummy, InlineNameSymbol {
+interface ERC721Metadata is Dummy, ERC165 {
+	// Selector: name() 06fdde03
+	function name() external view returns (string memory);
+
+	// Selector: symbol() 95d89b41
+	function symbol() external view returns (string memory);
+
 	// Selector: tokenURI(uint256) c87b56dd
 	function tokenURI(uint256 tokenId) external view returns (string memory);
 }
 
-interface ERC721Mintable is Dummy, ERC721MintableEvents {
+interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {
 	// Selector: mintingFinished() 05d2035b
 	function mintingFinished() external view returns (bool);
 
@@ -142,10 +135,13 @@
 	function finishMinting() external returns (bool);
 }
 
-interface ERC721UniqueExtensions is Dummy {
+interface ERC721UniqueExtensions is Dummy, ERC165 {
 	// Selector: transfer(address,uint256) a9059cbb
 	function transfer(address to, uint256 tokenId) external;
 
+	// Selector: burnFrom(address,uint256) 79cc6790
+	function burnFrom(address from, uint256 tokenId) external;
+
 	// Selector: nextTokenId() 75794a3c
 	function nextTokenId() external view returns (uint256);