git.delta.rocks / unique-network / refs/commits / 45d19b2ecee4

difftreelog

refactor remove last anonimous structs

Trubnikov Sergey2022-12-21parent: #8ca834e.patch.diff
in: master

14 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -34,9 +34,7 @@
 
 use crate::{
 	Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,
-	eth::{
-		CollectionPermissions as EvmPermissions, CollectionLimitField as EvmCollectionLimits, self,
-	},
+	eth::{CollectionLimitField as EvmCollectionLimits, self},
 	weights::WeightInfo,
 };
 
@@ -490,10 +488,10 @@
 
 	/// Returns nesting for a collection
 	#[solidity(rename_selector = "collectionNestingRestrictedCollectionIds")]
-	fn collection_nesting_restricted_ids(&self) -> Result<(bool, Vec<uint256>)> {
+	fn collection_nesting_restricted_ids(&self) -> Result<eth::CollectionNesting> {
 		let nesting = self.collection.permissions.nesting();
 
-		Ok((
+		Ok(eth::CollectionNesting::new(
 			nesting.token_owner,
 			nesting
 				.restricted
@@ -504,11 +502,17 @@
 	}
 
 	/// Returns permissions for a collection
-	fn collection_nesting_permissions(&self) -> Result<Vec<(EvmPermissions, bool)>> {
+	fn collection_nesting_permissions(&self) -> Result<Vec<eth::CollectionNestingPermission>> {
 		let nesting = self.collection.permissions.nesting();
 		Ok(vec![
-			(EvmPermissions::CollectionAdmin, nesting.collection_admin),
-			(EvmPermissions::TokenOwner, nesting.token_owner),
+			eth::CollectionNestingPermission::new(
+				eth::CollectionPermissionField::CollectionAdmin,
+				nesting.collection_admin,
+			),
+			eth::CollectionNestingPermission::new(
+				eth::CollectionPermissionField::TokenOwner,
+				nesting.token_owner,
+			),
 		])
 	}
 	/// Set the collection access method.
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -306,7 +306,7 @@
 /// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
 #[derive(Default, Debug, Clone, Copy, AbiCoder)]
 #[repr(u8)]
-pub enum CollectionPermissions {
+pub enum CollectionPermissionField {
 	/// Owner of token can nest tokens under it.
 	#[default]
 	TokenOwner,
@@ -431,3 +431,31 @@
 		Ok(perms)
 	}
 }
+
+/// Nested collections.
+#[derive(Debug, Default, AbiCoder)]
+pub struct CollectionNesting {
+	token_owner: bool,
+	ids: Vec<uint256>,
+}
+
+impl CollectionNesting {
+	/// Create [`CollectionNesting`].
+	pub fn new(token_owner: bool, ids: Vec<uint256>) -> Self {
+		Self { token_owner, ids }
+	}
+}
+
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+#[derive(Debug, Default, AbiCoder)]
+pub struct CollectionNestingPermission {
+	field: CollectionPermissionField,
+	value: bool,
+}
+
+impl CollectionNestingPermission {
+	/// Create [`CollectionNestingPermission`].
+	pub fn new(field: CollectionPermissionField, value: bool) -> Self {
+		Self { field, value }
+	}
+}
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
@@ -257,19 +257,19 @@
 	/// Returns nesting for a collection
 	/// @dev EVM selector for this function is: 0x22d25bfe,
 	///  or in textual repr: collectionNestingRestrictedCollectionIds()
-	function collectionNestingRestrictedCollectionIds() public view returns (Tuple33 memory) {
+	function collectionNestingRestrictedCollectionIds() public view returns (CollectionNesting memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple33(false, new uint256[](0));
+		return CollectionNesting(false, new uint256[](0));
 	}
 
 	/// Returns permissions for a collection
 	/// @dev EVM selector for this function is: 0x5b2eaf4b,
 	///  or in textual repr: collectionNestingPermissions()
-	function collectionNestingPermissions() public view returns (Tuple36[] memory) {
+	function collectionNestingPermissions() public view returns (CollectionNestingPermission[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple36[](0);
+		return new CollectionNestingPermission[](0);
 	}
 
 	/// Set the collection access method.
@@ -443,24 +443,24 @@
 	uint256 sub;
 }
 
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+struct CollectionNestingPermission {
+	CollectionPermissionField field;
+	bool value;
+}
+
 /// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
-enum CollectionPermissions {
+enum CollectionPermissionField {
 	/// @dev Owner of token can nest tokens under it.
 	TokenOwner,
 	/// @dev Admin of token collection can nest tokens under token.
 	CollectionAdmin
 }
 
-/// @dev anonymous struct
-struct Tuple36 {
-	CollectionPermissions field_0;
-	bool field_1;
-}
-
-/// @dev anonymous struct
-struct Tuple33 {
-	bool field_0;
-	uint256[] field_1;
+/// @dev Nested collections.
+struct CollectionNesting {
+	bool token_owner;
+	uint256[] ids;
 }
 
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
@@ -469,6 +469,7 @@
 	OptionUint value;
 }
 
+/// @dev Ethereum representation of Optional value with uint256.
 struct OptionUint {
 	bool status;
 	uint256 value;
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -401,19 +401,19 @@
 	/// Returns nesting for a collection
 	/// @dev EVM selector for this function is: 0x22d25bfe,
 	///  or in textual repr: collectionNestingRestrictedCollectionIds()
-	function collectionNestingRestrictedCollectionIds() public view returns (Tuple45 memory) {
+	function collectionNestingRestrictedCollectionIds() public view returns (CollectionNesting memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple45(false, new uint256[](0));
+		return CollectionNesting(false, new uint256[](0));
 	}
 
 	/// Returns permissions for a collection
 	/// @dev EVM selector for this function is: 0x5b2eaf4b,
 	///  or in textual repr: collectionNestingPermissions()
-	function collectionNestingPermissions() public view returns (Tuple48[] memory) {
+	function collectionNestingPermissions() public view returns (CollectionNestingPermission[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple48[](0);
+		return new CollectionNestingPermission[](0);
 	}
 
 	/// Set the collection access method.
@@ -587,24 +587,24 @@
 	uint256 sub;
 }
 
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+struct CollectionNestingPermission {
+	CollectionPermissionField field;
+	bool value;
+}
+
 /// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
-enum CollectionPermissions {
+enum CollectionPermissionField {
 	/// @dev Owner of token can nest tokens under it.
 	TokenOwner,
 	/// @dev Admin of token collection can nest tokens under token.
 	CollectionAdmin
 }
 
-/// @dev anonymous struct
-struct Tuple48 {
-	CollectionPermissions field_0;
-	bool field_1;
-}
-
-/// @dev anonymous struct
-struct Tuple45 {
-	bool field_0;
-	uint256[] field_1;
+/// @dev Nested collections.
+struct CollectionNesting {
+	bool token_owner;
+	uint256[] ids;
 }
 
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
@@ -613,6 +613,7 @@
 	OptionUint value;
 }
 
+/// @dev Ethereum representation of Optional value with uint256.
 struct OptionUint {
 	bool status;
 	uint256 value;
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -401,19 +401,19 @@
 	/// Returns nesting for a collection
 	/// @dev EVM selector for this function is: 0x22d25bfe,
 	///  or in textual repr: collectionNestingRestrictedCollectionIds()
-	function collectionNestingRestrictedCollectionIds() public view returns (Tuple44 memory) {
+	function collectionNestingRestrictedCollectionIds() public view returns (CollectionNesting memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple44(false, new uint256[](0));
+		return CollectionNesting(false, new uint256[](0));
 	}
 
 	/// Returns permissions for a collection
 	/// @dev EVM selector for this function is: 0x5b2eaf4b,
 	///  or in textual repr: collectionNestingPermissions()
-	function collectionNestingPermissions() public view returns (Tuple47[] memory) {
+	function collectionNestingPermissions() public view returns (CollectionNestingPermission[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple47[](0);
+		return new CollectionNestingPermission[](0);
 	}
 
 	/// Set the collection access method.
@@ -587,24 +587,24 @@
 	uint256 sub;
 }
 
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+struct CollectionNestingPermission {
+	CollectionPermissionField field;
+	bool value;
+}
+
 /// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
-enum CollectionPermissions {
+enum CollectionPermissionField {
 	/// @dev Owner of token can nest tokens under it.
 	TokenOwner,
 	/// @dev Admin of token collection can nest tokens under token.
 	CollectionAdmin
 }
 
-/// @dev anonymous struct
-struct Tuple47 {
-	CollectionPermissions field_0;
-	bool field_1;
-}
-
-/// @dev anonymous struct
-struct Tuple44 {
-	bool field_0;
-	uint256[] field_1;
+/// @dev Nested collections.
+struct CollectionNesting {
+	bool token_owner;
+	uint256[] ids;
 }
 
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
@@ -613,6 +613,7 @@
 	OptionUint value;
 }
 
+/// @dev Ethereum representation of Optional value with uint256.
 struct OptionUint {
 	bool status;
 	uint256 value;
modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -242,13 +242,13 @@
       {
         "components": [
           {
-            "internalType": "enum CollectionPermissions",
-            "name": "field_0",
+            "internalType": "enum CollectionPermissionField",
+            "name": "field",
             "type": "uint8"
           },
-          { "internalType": "bool", "name": "field_1", "type": "bool" }
+          { "internalType": "bool", "name": "value", "type": "bool" }
         ],
-        "internalType": "struct Tuple36[]",
+        "internalType": "struct CollectionNestingPermission[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -262,14 +262,10 @@
     "outputs": [
       {
         "components": [
-          { "internalType": "bool", "name": "field_0", "type": "bool" },
-          {
-            "internalType": "uint256[]",
-            "name": "field_1",
-            "type": "uint256[]"
-          }
+          { "internalType": "bool", "name": "token_owner", "type": "bool" },
+          { "internalType": "uint256[]", "name": "ids", "type": "uint256[]" }
         ],
-        "internalType": "struct Tuple33",
+        "internalType": "struct CollectionNesting",
         "name": "",
         "type": "tuple"
       }
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -272,13 +272,13 @@
       {
         "components": [
           {
-            "internalType": "enum CollectionPermissions",
-            "name": "field_0",
+            "internalType": "enum CollectionPermissionField",
+            "name": "field",
             "type": "uint8"
           },
-          { "internalType": "bool", "name": "field_1", "type": "bool" }
+          { "internalType": "bool", "name": "value", "type": "bool" }
         ],
-        "internalType": "struct Tuple48[]",
+        "internalType": "struct CollectionNestingPermission[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -292,14 +292,10 @@
     "outputs": [
       {
         "components": [
-          { "internalType": "bool", "name": "field_0", "type": "bool" },
-          {
-            "internalType": "uint256[]",
-            "name": "field_1",
-            "type": "uint256[]"
-          }
+          { "internalType": "bool", "name": "token_owner", "type": "bool" },
+          { "internalType": "uint256[]", "name": "ids", "type": "uint256[]" }
         ],
-        "internalType": "struct Tuple45",
+        "internalType": "struct CollectionNesting",
         "name": "",
         "type": "tuple"
       }
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -254,13 +254,13 @@
       {
         "components": [
           {
-            "internalType": "enum CollectionPermissions",
-            "name": "field_0",
+            "internalType": "enum CollectionPermissionField",
+            "name": "field",
             "type": "uint8"
           },
-          { "internalType": "bool", "name": "field_1", "type": "bool" }
+          { "internalType": "bool", "name": "value", "type": "bool" }
         ],
-        "internalType": "struct Tuple47[]",
+        "internalType": "struct CollectionNestingPermission[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -274,14 +274,10 @@
     "outputs": [
       {
         "components": [
-          { "internalType": "bool", "name": "field_0", "type": "bool" },
-          {
-            "internalType": "uint256[]",
-            "name": "field_1",
-            "type": "uint256[]"
-          }
+          { "internalType": "bool", "name": "token_owner", "type": "bool" },
+          { "internalType": "uint256[]", "name": "ids", "type": "uint256[]" }
         ],
-        "internalType": "struct Tuple44",
+        "internalType": "struct CollectionNesting",
         "name": "",
         "type": "tuple"
       }
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
166 /// Returns nesting for a collection166 /// Returns nesting for a collection
167 /// @dev EVM selector for this function is: 0x22d25bfe,167 /// @dev EVM selector for this function is: 0x22d25bfe,
168 /// or in textual repr: collectionNestingRestrictedCollectionIds()168 /// or in textual repr: collectionNestingRestrictedCollectionIds()
169 function collectionNestingRestrictedCollectionIds() external view returns (Tuple28 memory);169 function collectionNestingRestrictedCollectionIds() external view returns (CollectionNesting memory);
170170
171 /// Returns permissions for a collection171 /// Returns permissions for a collection
172 /// @dev EVM selector for this function is: 0x5b2eaf4b,172 /// @dev EVM selector for this function is: 0x5b2eaf4b,
173 /// or in textual repr: collectionNestingPermissions()173 /// or in textual repr: collectionNestingPermissions()
174 function collectionNestingPermissions() external view returns (Tuple31[] memory);174 function collectionNestingPermissions() external view returns (CollectionNestingPermission[] memory);
175175
176 /// Set the collection access method.176 /// Set the collection access method.
177 /// @param mode Access mode177 /// @param mode Access mode
285 uint256 sub;285 uint256 sub;
286}286}
287287
288/// @dev anonymous struct288/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
289struct Tuple31 {289struct CollectionNestingPermission {
290 CollectionPermissions field_0;290 CollectionPermissionField field;
291 bool field_1;291 bool value;
292}292}
293293
294/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.294/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
295enum CollectionPermissions {295enum CollectionPermissionField {
296 /// @dev Owner of token can nest tokens under it.296 /// @dev Owner of token can nest tokens under it.
297 TokenOwner,297 TokenOwner,
298 /// @dev Admin of token collection can nest tokens under token.298 /// @dev Admin of token collection can nest tokens under token.
299 CollectionAdmin299 CollectionAdmin
300}300}
301301
302/// @dev anonymous struct302/// @dev Nested collections.
303struct Tuple28 {303struct CollectionNesting {
304 bool field_0;304 bool token_owner;
305 uint256[] field_1;305 uint256[] ids;
306}306}
307307
308/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.308/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
311 OptionUint value;311 OptionUint value;
312}312}
313313
314/// @dev Ethereum representation of Optional value with uint256.
314struct OptionUint {315struct OptionUint {
315 bool status;316 bool status;
316 uint256 value;317 uint256 value;
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -268,12 +268,12 @@
 	/// Returns nesting for a collection
 	/// @dev EVM selector for this function is: 0x22d25bfe,
 	///  or in textual repr: collectionNestingRestrictedCollectionIds()
-	function collectionNestingRestrictedCollectionIds() external view returns (Tuple38 memory);
+	function collectionNestingRestrictedCollectionIds() external view returns (CollectionNesting memory);
 
 	/// Returns permissions for a collection
 	/// @dev EVM selector for this function is: 0x5b2eaf4b,
 	///  or in textual repr: collectionNestingPermissions()
-	function collectionNestingPermissions() external view returns (Tuple41[] memory);
+	function collectionNestingPermissions() external view returns (CollectionNestingPermission[] memory);
 
 	/// Set the collection access method.
 	/// @param mode Access mode
@@ -387,24 +387,24 @@
 	uint256 sub;
 }
 
-/// @dev anonymous struct
-struct Tuple41 {
-	CollectionPermissions field_0;
-	bool field_1;
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+struct CollectionNestingPermission {
+	CollectionPermissionField field;
+	bool value;
 }
 
 /// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
-enum CollectionPermissions {
+enum CollectionPermissionField {
 	/// @dev Owner of token can nest tokens under it.
 	TokenOwner,
 	/// @dev Admin of token collection can nest tokens under token.
 	CollectionAdmin
 }
 
-/// @dev anonymous struct
-struct Tuple38 {
-	bool field_0;
-	uint256[] field_1;
+/// @dev Nested collections.
+struct CollectionNesting {
+	bool token_owner;
+	uint256[] ids;
 }
 
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
@@ -413,6 +413,7 @@
 	OptionUint value;
 }
 
+/// @dev Ethereum representation of Optional value with uint256.
 struct OptionUint {
 	bool status;
 	uint256 value;
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -268,12 +268,12 @@
 	/// Returns nesting for a collection
 	/// @dev EVM selector for this function is: 0x22d25bfe,
 	///  or in textual repr: collectionNestingRestrictedCollectionIds()
-	function collectionNestingRestrictedCollectionIds() external view returns (Tuple37 memory);
+	function collectionNestingRestrictedCollectionIds() external view returns (CollectionNesting memory);
 
 	/// Returns permissions for a collection
 	/// @dev EVM selector for this function is: 0x5b2eaf4b,
 	///  or in textual repr: collectionNestingPermissions()
-	function collectionNestingPermissions() external view returns (Tuple40[] memory);
+	function collectionNestingPermissions() external view returns (CollectionNestingPermission[] memory);
 
 	/// Set the collection access method.
 	/// @param mode Access mode
@@ -387,24 +387,24 @@
 	uint256 sub;
 }
 
-/// @dev anonymous struct
-struct Tuple40 {
-	CollectionPermissions field_0;
-	bool field_1;
+/// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
+struct CollectionNestingPermission {
+	CollectionPermissionField field;
+	bool value;
 }
 
 /// @dev Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
-enum CollectionPermissions {
+enum CollectionPermissionField {
 	/// @dev Owner of token can nest tokens under it.
 	TokenOwner,
 	/// @dev Admin of token collection can nest tokens under token.
 	CollectionAdmin
 }
 
-/// @dev anonymous struct
-struct Tuple37 {
-	bool field_0;
-	uint256[] field_1;
+/// @dev Nested collections.
+struct CollectionNesting {
+	bool token_owner;
+	uint256[] ids;
 }
 
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
@@ -413,6 +413,7 @@
 	OptionUint value;
 }
 
+/// @dev Ethereum representation of Optional value with uint256.
 struct OptionUint {
 	bool status;
 	uint256 value;