From 8900b85b9a6718181903235121a69b77cf570a47 Mon Sep 17 00:00:00 2001 From: Trubnikov Sergey Date: Tue, 10 Jan 2023 12:24:16 +0000 Subject: [PATCH] misk: Change OptionCrossAddress to Option --- --- 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 { --- 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 { + fn sponsor(&self, contract_address: address) -> Result> { Ok(match Pallet::::get_sponsor(contract_address) { - Some(ref value) => eth::OptionCrossAddress { - status: true, - value: eth::CrossAddress::from_sub_cross_account::(value), - }, - None => eth::OptionCrossAddress { - status: false, - value: Default::default(), - }, + Some(ref value) => Some(eth::CrossAddress::from_sub_cross_account::(value)), + None => None, }) } --- 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; } --- 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" } --- 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; } -- gitstuff