git.delta.rocks / unique-network / refs/commits / 8900b85b9a67

difftreelog

misk: Change OptionCrossAddress to Option<CrossAddress>

Trubnikov Sergey2023-01-10parent: #72d7965.patch.diff
in: master

6 files changed

modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -66,15 +66,6 @@
 	T::CrossAccountId::from_sub(account_id)
 }
 
-/// Ethereum representation of Optional value with CrossAddress.
-#[derive(Debug, Default, AbiCoder)]
-pub struct OptionCrossAddress {
-	/// Whether or not this CrossAdress is valid and has meaning.
-	pub status: bool,
-	/// The underlying CrossAddress value. If the status is false, can be set to whatever.
-	pub value: CrossAddress,
-}
-
 /// Cross account struct
 #[derive(Debug, Default, AbiCoder)]
 pub struct CrossAddress {
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -175,16 +175,10 @@
 	///
 	/// @param contractAddress The contract for which a sponsor is requested.
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
-	fn sponsor(&self, contract_address: address) -> Result<eth::OptionCrossAddress> {
+	fn sponsor(&self, contract_address: address) -> Result<Option<eth::CrossAddress>> {
 		Ok(match Pallet::<T>::get_sponsor(contract_address) {
-			Some(ref value) => eth::OptionCrossAddress {
-				status: true,
-				value: eth::CrossAddress::from_sub_cross_account::<T>(value),
-			},
-			None => eth::OptionCrossAddress {
-				status: false,
-				value: Default::default(),
-			},
+			Some(ref value) => Some(eth::CrossAddress::from_sub_cross_account::<T>(value)),
+			None => None,
 		})
 	}
 
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth
96 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.96 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
97 /// @dev EVM selector for this function is: 0x766c4f37,97 /// @dev EVM selector for this function is: 0x766c4f37,
98 /// or in textual repr: sponsor(address)98 /// or in textual repr: sponsor(address)
99 function sponsor(address contractAddress) public view returns (OptionCrossAddress memory) {99 function sponsor(address contractAddress) public view returns (Option_CrossAddress memory) {
100 require(false, stub_error);100 require(false, stub_error);
101 contractAddress;101 contractAddress;
102 dummy;102 dummy;
103 return OptionCrossAddress(false, CrossAddress(0x0000000000000000000000000000000000000000, 0));103 return Option_CrossAddress(false, CrossAddress(0x0000000000000000000000000000000000000000, 0));
104 }104 }
105105
106 /// Check tat contract has confirmed sponsor.106 /// Check tat contract has confirmed sponsor.
281 uint256 sub;281 uint256 sub;
282}282}
283283
284/// Ethereum representation of Optional value with CrossAddress.284/// Optional value
285struct OptionCrossAddress {285struct Option_CrossAddress {
286 /// Whether or not this CrossAdress is valid and has meaning.286 /// Shows the status of accessibility of value
287 bool status;287 bool status;
288 /// The underlying CrossAddress value. If the status is false, can be set to whatever.288 /// Actual value if `status` is true
289 CrossAddress value;289 CrossAddress value;
290}290}
291291
modifiedtests/src/eth/abi/contractHelpers.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/contractHelpers.json
+++ b/tests/src/eth/abi/contractHelpers.json
@@ -238,7 +238,7 @@
             "type": "tuple"
           }
         ],
-        "internalType": "struct OptionCrossAddress",
+        "internalType": "struct Option_CrossAddress",
         "name": "",
         "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 (OptionCrossAddress memory);
+	function sponsor(address contractAddress) external view returns (Option_CrossAddress memory);
 
 	/// Check tat contract has confirmed sponsor.
 	///
@@ -181,11 +181,11 @@
 	Generous
 }
 
-/// Ethereum representation of Optional value with CrossAddress.
-struct OptionCrossAddress {
-	/// Whether or not this CrossAdress is valid and has meaning.
+/// Optional value
+struct Option_CrossAddress {
+	/// Shows the status of accessibility of value
 	bool status;
-	/// The underlying CrossAddress value. If the status is false, can be set to whatever.
+	/// Actual value if `status` is true
 	CrossAddress value;
 }