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
--- 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 (OptionCrossAddress memory) {
+	function sponsor(address contractAddress) public view returns (Option_CrossAddress memory) {
 		require(false, stub_error);
 		contractAddress;
 		dummy;
-		return OptionCrossAddress(false, CrossAddress(0x0000000000000000000000000000000000000000, 0));
+		return Option_CrossAddress(false, CrossAddress(0x0000000000000000000000000000000000000000, 0));
 	}
 
 	/// Check tat contract has confirmed sponsor.
@@ -281,10 +281,10 @@
 	uint256 sub;
 }
 
-/// 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;
 }
modifiedtests/src/eth/abi/contractHelpers.jsondiffbeforeafterboth
before · 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/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;
 }