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

difftreelog

misc: Use PascalCase in OptionGeneric name

Trubnikov Sergey2023-01-11parent: #3006d97.patch.diff
in: master

17 files changed

modifiedcrates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity/impls.rs
+++ b/crates/evm-coder/src/solidity/impls.rs
@@ -141,12 +141,29 @@
 
 impl<T: SolidityTypeName> super::SolidityStructTy for Option<T> {
 	fn generate_solidity_interface(tc: &TypeCollector) -> String {
-		let mut solidity_name = "Option_".to_string();
+		const option_name: &str = "Option";
+		const option_name_len: usize = option_name.len();
+
+		let to_upper_case_generic_type_name = |s: &mut String| {
+			let c = s
+				.chars()
+				.skip(option_name_len)
+				.next()
+				.expect("Ethereum name must be presented");
+			if c.is_ascii_uppercase() {
+				return;
+			}
+			let uc = String::from(c.to_ascii_uppercase());
+			s.replace_range(option_name_len..option_name_len + 1, uc.as_str());
+		};
+
+		let mut solidity_name = option_name.to_string();
 		T::solidity_name(&mut solidity_name, tc);
-		let solidity_name_str = solidity_name.as_str();
+		to_upper_case_generic_type_name(&mut solidity_name);
+
 		let interface = super::SolidityStruct {
 			docs: &[" Optional value"],
-			name: solidity_name_str,
+			name: solidity_name.as_str(),
 			fields: (
 				super::SolidityStructField::<bool> {
 					docs: &[" Shows the status of accessibility of value"],
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
@@ -96,11 +96,11 @@
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
 	/// @dev EVM selector for this function is: 0x766c4f37,
 	///  or in textual repr: sponsor(address)
-	function sponsor(address contractAddress) public view returns (Option_CrossAddress memory) {
+	function sponsor(address contractAddress) public view returns (OptionCrossAddress memory) {
 		require(false, stub_error);
 		contractAddress;
 		dummy;
-		return Option_CrossAddress(false, CrossAddress(0x0000000000000000000000000000000000000000, 0));
+		return OptionCrossAddress(false, CrossAddress(0x0000000000000000000000000000000000000000, 0));
 	}
 
 	/// Check tat contract has confirmed sponsor.
@@ -282,7 +282,7 @@
 }
 
 /// Optional value
-struct Option_CrossAddress {
+struct OptionCrossAddress {
 	/// Shows the status of accessibility of value
 	bool status;
 	/// Actual value if `status` is true
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
@@ -466,11 +466,11 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	Option_uint256 value;
+	OptionUint256 value;
 }
 
 /// Optional value
-struct Option_uint256 {
+struct OptionUint256 {
 	/// Shows the status of accessibility of value
 	bool status;
 	/// Actual value if `status` is true
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
@@ -608,11 +608,11 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	Option_uint256 value;
+	OptionUint256 value;
 }
 
 /// Optional value
-struct Option_uint256 {
+struct OptionUint256 {
 	/// Shows the status of accessibility of value
 	bool status;
 	/// Actual value if `status` is true
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
@@ -608,11 +608,11 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	Option_uint256 value;
+	OptionUint256 value;
 }
 
 /// Optional value
-struct Option_uint256 {
+struct OptionUint256 {
 	/// Shows the status of accessibility of value
 	bool status;
 	/// Actual value if `status` is true
modifiedtests/src/eth/abi/contractHelpers.jsondiffbeforeafterboth
after · tests/src/eth/abi/contractHelpers.json
1[2  {3    "anonymous": false,4    "inputs": [5      {6        "indexed": true,7        "internalType": "address",8        "name": "contractAddress",9        "type": "address"10      }11    ],12    "name": "ContractSponsorRemoved",13    "type": "event"14  },15  {16    "anonymous": false,17    "inputs": [18      {19        "indexed": true,20        "internalType": "address",21        "name": "contractAddress",22        "type": "address"23      },24      {25        "indexed": false,26        "internalType": "address",27        "name": "sponsor",28        "type": "address"29      }30    ],31    "name": "ContractSponsorSet",32    "type": "event"33  },34  {35    "anonymous": false,36    "inputs": [37      {38        "indexed": true,39        "internalType": "address",40        "name": "contractAddress",41        "type": "address"42      },43      {44        "indexed": false,45        "internalType": "address",46        "name": "sponsor",47        "type": "address"48      }49    ],50    "name": "ContractSponsorshipConfirmed",51    "type": "event"52  },53  {54    "inputs": [55      {56        "internalType": "address",57        "name": "contractAddress",58        "type": "address"59      },60      { "internalType": "address", "name": "user", "type": "address" }61    ],62    "name": "allowed",63    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],64    "stateMutability": "view",65    "type": "function"66  },67  {68    "inputs": [69      {70        "internalType": "address",71        "name": "contractAddress",72        "type": "address"73      }74    ],75    "name": "allowlistEnabled",76    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],77    "stateMutability": "view",78    "type": "function"79  },80  {81    "inputs": [82      {83        "internalType": "address",84        "name": "contractAddress",85        "type": "address"86      }87    ],88    "name": "confirmSponsorship",89    "outputs": [],90    "stateMutability": "nonpayable",91    "type": "function"92  },93  {94    "inputs": [95      {96        "internalType": "address",97        "name": "contractAddress",98        "type": "address"99      }100    ],101    "name": "contractOwner",102    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],103    "stateMutability": "view",104    "type": "function"105  },106  {107    "inputs": [108      {109        "internalType": "address",110        "name": "contractAddress",111        "type": "address"112      }113    ],114    "name": "hasPendingSponsor",115    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],116    "stateMutability": "view",117    "type": "function"118  },119  {120    "inputs": [121      {122        "internalType": "address",123        "name": "contractAddress",124        "type": "address"125      }126    ],127    "name": "hasSponsor",128    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],129    "stateMutability": "view",130    "type": "function"131  },132  {133    "inputs": [134      {135        "internalType": "address",136        "name": "contractAddress",137        "type": "address"138      }139    ],140    "name": "removeSponsor",141    "outputs": [],142    "stateMutability": "nonpayable",143    "type": "function"144  },145  {146    "inputs": [147      {148        "internalType": "address",149        "name": "contractAddress",150        "type": "address"151      }152    ],153    "name": "selfSponsoredEnable",154    "outputs": [],155    "stateMutability": "nonpayable",156    "type": "function"157  },158  {159    "inputs": [160      {161        "internalType": "address",162        "name": "contractAddress",163        "type": "address"164      },165      { "internalType": "address", "name": "sponsor", "type": "address" }166    ],167    "name": "setSponsor",168    "outputs": [],169    "stateMutability": "nonpayable",170    "type": "function"171  },172  {173    "inputs": [174      {175        "internalType": "address",176        "name": "contractAddress",177        "type": "address"178      },179      { "internalType": "uint256", "name": "feeLimit", "type": "uint256" }180    ],181    "name": "setSponsoringFeeLimit",182    "outputs": [],183    "stateMutability": "nonpayable",184    "type": "function"185  },186  {187    "inputs": [188      {189        "internalType": "address",190        "name": "contractAddress",191        "type": "address"192      },193      {194        "internalType": "enum SponsoringModeT",195        "name": "mode",196        "type": "uint8"197      }198    ],199    "name": "setSponsoringMode",200    "outputs": [],201    "stateMutability": "nonpayable",202    "type": "function"203  },204  {205    "inputs": [206      {207        "internalType": "address",208        "name": "contractAddress",209        "type": "address"210      },211      { "internalType": "uint32", "name": "rateLimit", "type": "uint32" }212    ],213    "name": "setSponsoringRateLimit",214    "outputs": [],215    "stateMutability": "nonpayable",216    "type": "function"217  },218  {219    "inputs": [220      {221        "internalType": "address",222        "name": "contractAddress",223        "type": "address"224      }225    ],226    "name": "sponsor",227    "outputs": [228      {229        "components": [230          { "internalType": "bool", "name": "status", "type": "bool" },231          {232            "components": [233              { "internalType": "address", "name": "eth", "type": "address" },234              { "internalType": "uint256", "name": "sub", "type": "uint256" }235            ],236            "internalType": "struct CrossAddress",237            "name": "value",238            "type": "tuple"239          }240        ],241        "internalType": "struct OptionCrossAddress",242        "name": "",243        "type": "tuple"244      }245    ],246    "stateMutability": "view",247    "type": "function"248  },249  {250    "inputs": [251      {252        "internalType": "address",253        "name": "contractAddress",254        "type": "address"255      }256    ],257    "name": "sponsoringEnabled",258    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],259    "stateMutability": "view",260    "type": "function"261  },262  {263    "inputs": [264      {265        "internalType": "address",266        "name": "contractAddress",267        "type": "address"268      }269    ],270    "name": "sponsoringFeeLimit",271    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],272    "stateMutability": "view",273    "type": "function"274  },275  {276    "inputs": [277      {278        "internalType": "address",279        "name": "contractAddress",280        "type": "address"281      }282    ],283    "name": "sponsoringRateLimit",284    "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }],285    "stateMutability": "view",286    "type": "function"287  },288  {289    "inputs": [290      { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }291    ],292    "name": "supportsInterface",293    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],294    "stateMutability": "view",295    "type": "function"296  },297  {298    "inputs": [299      {300        "internalType": "address",301        "name": "contractAddress",302        "type": "address"303      },304      { "internalType": "address", "name": "user", "type": "address" },305      { "internalType": "bool", "name": "isAllowed", "type": "bool" }306    ],307    "name": "toggleAllowed",308    "outputs": [],309    "stateMutability": "nonpayable",310    "type": "function"311  },312  {313    "inputs": [314      {315        "internalType": "address",316        "name": "contractAddress",317        "type": "address"318      },319      { "internalType": "bool", "name": "enabled", "type": "bool" }320    ],321    "name": "toggleAllowlist",322    "outputs": [],323    "stateMutability": "nonpayable",324    "type": "function"325  }326]
modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -222,7 +222,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct Option_uint256",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
@@ -508,7 +508,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct Option_uint256",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -252,7 +252,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct Option_uint256",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
@@ -670,7 +670,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct Option_uint256",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -234,7 +234,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct Option_uint256",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
@@ -652,7 +652,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct Option_uint256",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -69,7 +69,7 @@
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
 	/// @dev EVM selector for this function is: 0x766c4f37,
 	///  or in textual repr: sponsor(address)
-	function sponsor(address contractAddress) external view returns (Option_CrossAddress memory);
+	function sponsor(address contractAddress) external view returns (OptionCrossAddress memory);
 
 	/// Check tat contract has confirmed sponsor.
 	///
@@ -182,7 +182,7 @@
 }
 
 /// Optional value
-struct Option_CrossAddress {
+struct OptionCrossAddress {
 	/// Shows the status of accessibility of value
 	bool status;
 	/// Actual value if `status` is true
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -308,11 +308,11 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	Option_uint256 value;
+	OptionUint256 value;
 }
 
 /// Optional value
-struct Option_uint256 {
+struct OptionUint256 {
 	/// Shows the status of accessibility of value
 	bool status;
 	/// Actual value if `status` is true
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -408,11 +408,11 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	Option_uint256 value;
+	OptionUint256 value;
 }
 
 /// Optional value
-struct Option_uint256 {
+struct OptionUint256 {
 	/// Shows the status of accessibility of value
 	bool status;
 	/// Actual value if `status` is true
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -408,11 +408,11 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	Option_uint256 value;
+	OptionUint256 value;
 }
 
 /// Optional value
-struct Option_uint256 {
+struct OptionUint256 {
 	/// Shows the status of accessibility of value
 	bool status;
 	/// Actual value if `status` is true