git.delta.rocks / unique-network / refs/commits / 4efa9ce62081

difftreelog

doc(pallet-evm-contract-helpers): document public api

Yaroslav Bolyukin2022-07-12parent: #c098935.patch.diff
in: master

7 files changed

addedpallets/evm-contract-helpers/README.mddiffbeforeafterboth
--- /dev/null
+++ b/pallets/evm-contract-helpers/README.md
@@ -0,0 +1,13 @@
+# EVM Contract Helpers
+
+This pallet extends pallet-evm contracts with several new functions.
+
+## Overview
+
+Evm contract helpers pallet provides ability to
+
+- Tracking and getting of user, which deployed contract
+- Sponsoring EVM contract calls (Make transaction calls to be free for users, instead making them being paid from contract address)
+- Allowlist access mode
+
+As most of those functions are intented to be consumed by ethereum users, only API provided by this pallet is [ContractHelpers magic contract](./src/stubs/ContractHelpers.sol)
\ No newline at end of file
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -14,6 +14,8 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+//! Implementation of magic contract
+
 use core::marker::PhantomData;
 use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};
@@ -31,7 +33,8 @@
 use up_sponsorship::SponsorshipHandler;
 use sp_std::vec::Vec;
 
-struct ContractHelpers<T: Config>(SubstrateRecorder<T>);
+/// See [`ContractHelpersCall`]
+pub struct ContractHelpers<T: Config>(SubstrateRecorder<T>);
 impl<T: Config> WithRecorder<T> for ContractHelpers<T> {
 	fn recorder(&self) -> &SubstrateRecorder<T> {
 		&self.0
@@ -42,21 +45,24 @@
 	}
 }
 
+/// @title Magic contract, which allows users to reconfigure other contracts
 #[solidity_interface(name = ContractHelpers)]
 impl<T: Config> ContractHelpers<T>
 where
 	T::AccountId: AsRef<[u8; 32]>,
 {
-	/// Get contract ovner
-	///
-	/// @param contractAddress contract for which the owner is being determined.
-	/// @return Contract owner.
+	/// Get user, which deployed specified contract
+	/// @dev May return zero address in case if contract is deployed
+	///  using uniquenetwork evm-migration pallet, or using other terms not
+	///  intended by pallet-evm
+	/// @dev Returns zero address if contract does not exists
+	/// @param contractAddress Contract to get owner of
+	/// @return address Owner of contract
 	fn contract_owner(&self, contract_address: address) -> Result<address> {
 		Ok(<Owner<T>>::get(contract_address))
 	}
 
 	/// Set sponsor.
-	///
 	/// @param contractAddress Contract for which a sponsor is being established.
 	/// @param sponsor User address who set as pending sponsor.
 	fn set_sponsor(
@@ -163,6 +169,7 @@
 		&mut self,
 		caller: caller,
 		contract_address: address,
+		// TODO: implement support for enums in evm-coder
 		mode: uint8,
 	) -> Result<void> {
 		self.recorder().consume_sload()?;
@@ -175,10 +182,21 @@
 		Ok(())
 	}
 
-	fn sponsoring_mode(&self, contract_address: address) -> Result<uint8> {
-		Ok(<Pallet<T>>::sponsoring_mode(contract_address).to_eth())
+	/// Get current contract sponsoring rate limit
+	/// @param contractAddress Contract to get sponsoring mode of
+	/// @return uint32 Amount of blocks between two sponsored transactions
+	fn get_sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {
+		Ok(<SponsoringRateLimit<T>>::get(contract_address)
+			.try_into()
+			.map_err(|_| "rate limit > u32::MAX")?)
 	}
 
+	/// Set contract sponsoring rate limit
+	/// @dev Sponsoring rate limit - is a minimum amount of blocks that should
+	///  pass between two sponsored transactions
+	/// @param contractAddress Contract to change sponsoring rate limit of
+	/// @param rateLimit Target rate limit
+	/// @dev Only contract owner can change this setting
 	fn set_sponsoring_rate_limit(
 		&mut self,
 		caller: caller,
@@ -190,57 +208,70 @@
 
 		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;
 		<Pallet<T>>::set_sponsoring_rate_limit(contract_address, rate_limit.into());
-
 		Ok(())
 	}
 
-	fn get_sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {
-		Ok(<SponsoringRateLimit<T>>::get(contract_address)
-			.try_into()
-			.map_err(|_| "rate limit > u32::MAX")?)
-	}
-
+	/// Is specified user present in contract allow list
+	/// @dev Contract owner always implicitly included
+	/// @param contractAddress Contract to check allowlist of
+	/// @param user User to check
+	/// @return bool Is specified users exists in contract allowlist
 	fn allowed(&self, contract_address: address, user: address) -> Result<bool> {
 		self.0.consume_sload()?;
 		Ok(<Pallet<T>>::allowed(contract_address, user))
 	}
 
-	fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {
-		Ok(<AllowlistEnabled<T>>::get(contract_address))
-	}
-
-	fn toggle_allowlist(
+	/// Toggle user presence in contract allowlist
+	/// @param contractAddress Contract to change allowlist of
+	/// @param user Which user presence should be toggled
+	/// @param isAllowed `true` if user should be allowed to be sponsored
+	///  or call this contract, `false` otherwise
+	/// @dev Only contract owner can change this setting
+	fn toggle_allowed(
 		&mut self,
 		caller: caller,
 		contract_address: address,
-		enabled: bool,
+		user: address,
+		is_allowed: bool,
 	) -> Result<void> {
 		self.recorder().consume_sload()?;
 		self.recorder().consume_sstore()?;
 
 		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;
-		<Pallet<T>>::toggle_allowlist(contract_address, enabled);
+		<Pallet<T>>::toggle_allowed(contract_address, user, is_allowed);
 
 		Ok(())
 	}
 
-	fn toggle_allowed(
+	/// Is this contract has allowlist access enabled
+	/// @dev Allowlist always can have users, and it is used for two purposes:
+	///  in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist
+	///  in case of allowlist access enabled, only users from allowlist may call this contract
+	/// @param contractAddress Contract to get allowlist access of
+	/// @return bool Is specified contract has allowlist access enabled
+	fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {
+		Ok(<AllowlistEnabled<T>>::get(contract_address))
+	}
+
+	/// Toggle contract allowlist access
+	/// @param contractAddress Contract to change allowlist access of
+	/// @param enabled Should allowlist access to be enabled?
+	fn toggle_allowlist(
 		&mut self,
 		caller: caller,
 		contract_address: address,
-		user: address,
-		is_allowed: bool,
+		enabled: bool,
 	) -> Result<void> {
 		self.recorder().consume_sload()?;
 		self.recorder().consume_sstore()?;
 
 		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;
-		<Pallet<T>>::toggle_allowed(contract_address, user, is_allowed);
-
+		<Pallet<T>>::toggle_allowlist(contract_address, enabled);
 		Ok(())
 	}
 }
 
+/// Implements [`OnMethodCall`], which delegates call to [`ContractHelpers`]
 pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);
 impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T>
 where
@@ -283,6 +314,7 @@
 	}
 }
 
+/// Hooks into contract creation, storing owner of newly deployed contract
 pub struct HelpersOnCreate<T: Config>(PhantomData<*const T>);
 impl<T: Config> OnCreate<T> for HelpersOnCreate<T> {
 	fn on_create(owner: H160, contract: H160) {
@@ -290,6 +322,7 @@
 	}
 }
 
+/// Bridge to pallet-sponsoring
 pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);
 impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>)>
 	for HelpersContractSponsoring<T>
modifiedpallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/lib.rs
+++ b/pallets/evm-contract-helpers/src/lib.rs
@@ -14,7 +14,9 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+#![doc = include_str!("../README.md")]
 #![cfg_attr(not(feature = "std"), no_std)]
+#![deny(missing_docs)]
 
 use codec::{Decode, Encode, MaxEncodedLen};
 pub use pallet::*;
@@ -35,13 +37,16 @@
 	pub trait Config:
 		frame_system::Config + pallet_evm_coder_substrate::Config + pallet_evm::account::Config
 	{
+		/// Address, under which magic contract will be available
 		type ContractAddress: Get<H160>;
+		/// In case of enabled sponsoring, but no sponsoring rate limit set,
+		/// this value will be used implicitly
 		type DefaultSponsoringRateLimit: Get<Self::BlockNumber>;
 	}
 
 	#[pallet::error]
 	pub enum Error<T> {
-		/// This method is only executable by owner.
+		/// This method is only executable by contract owner
 		NoPermission,
 
 		/// No pending sponsor for contract.
@@ -217,6 +222,7 @@
 			}
 		}
 
+		/// Get current sponsoring mode, performing lazy migration from legacy storage
 		pub fn sponsoring_mode(contract: H160) -> SponsoringModeT {
 			<SponsoringMode<T>>::get(contract)
 				.or_else(|| {
@@ -225,6 +231,7 @@
 				.unwrap_or_default()
 		}
 
+		/// Reconfigure contract sponsoring mode
 		pub fn set_sponsoring_mode(contract: H160, mode: SponsoringModeT) {
 			if mode == SponsoringModeT::Disabled {
 				<SponsoringMode<T>>::remove(contract);
@@ -234,22 +241,27 @@
 			<SelfSponsoring<T>>::remove(contract)
 		}
 
+		/// Set duration between two sponsored contract calls
 		pub fn set_sponsoring_rate_limit(contract: H160, rate_limit: T::BlockNumber) {
 			<SponsoringRateLimit<T>>::insert(contract, rate_limit);
 		}
 
+		/// Is user added to allowlist, or he is owner of specified contract
 		pub fn allowed(contract: H160, user: H160) -> bool {
 			<Allowlist<T>>::get(&contract, &user) || <Owner<T>>::get(&contract) == user
 		}
 
+		/// Toggle contract allowlist access
 		pub fn toggle_allowlist(contract: H160, enabled: bool) {
 			<AllowlistEnabled<T>>::insert(contract, enabled)
 		}
 
+		/// Toggle user presence in contract's allowlist
 		pub fn toggle_allowed(contract: H160, user: H160, allowed: bool) {
 			<Allowlist<T>>::insert(contract, user, allowed);
 		}
 
+		/// Throw error if user is not allowed to reconfigure target contract
 		pub fn ensure_owner(contract: H160, user: H160) -> DispatchResult {
 			ensure!(<Owner<T>>::get(&contract) == user, Error::<T>::NoPermission);
 			Ok(())
@@ -257,10 +269,15 @@
 	}
 }
 
-#[derive(Encode, Decode, PartialEq, TypeInfo, MaxEncodedLen)]
+/// Available contract sponsoring modes
+#[derive(Encode, Decode, PartialEq, TypeInfo, MaxEncodedLen, Default)]
 pub enum SponsoringModeT {
+	/// Sponsoring is disabled
+	#[default]
 	Disabled,
+	/// Only users from allowlist will be sponsored
 	Allowlisted,
+	/// All users will be sponsored
 	Generous,
 }
 
@@ -279,11 +296,5 @@
 			SponsoringModeT::Allowlisted => 1,
 			SponsoringModeT::Generous => 2,
 		}
-	}
-}
-
-impl Default for SponsoringModeT {
-	fn default() -> Self {
-		Self::Disabled
 	}
 }
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
@@ -3,12 +3,6 @@
 
 pragma solidity >=0.8.0 <0.9.0;
 
-/// @dev anonymous struct
-struct Tuple0 {
-	address field_0;
-	uint256 field_1;
-}
-
 /// @dev common stubs holder
 contract Dummy {
 	uint8 dummy;
@@ -27,14 +21,18 @@
 	}
 }
 
-/// @dev the ERC-165 identifier for this interface is 0x6073d917
+/// @title Magic contract, which allows users to reconfigure other contracts
+/// @dev the ERC-165 identifier for this interface is 0xd77fab70
 contract ContractHelpers is Dummy, ERC165 {
-	/// Get contract ovner
-	///
-	/// @param contractAddress contract for which the owner is being determined.
-	/// @return Contract owner.
-	///
-	/// Selector: contractOwner(address) 5152b14c
+	/// Get user, which deployed specified contract
+	/// @dev May return zero address in case if contract is deployed
+	///  using uniquenetwork evm-migration pallet, or using other terms not
+	///  intended by pallet-evm
+	/// @dev Returns zero address if contract does not exists
+	/// @param contractAddress Contract to get owner of
+	/// @return address Owner of contract
+	/// @dev EVM selector for this function is: 0x5152b14c,
+	///  or in textual repr: contractOwner(address)
 	function contractOwner(address contractAddress)
 		public
 		view
@@ -47,11 +45,10 @@
 	}
 
 	/// Set sponsor.
-	///
 	/// @param contractAddress Contract for which a sponsor is being established.
 	/// @param sponsor User address who set as pending sponsor.
-	///
-	/// Selector: setSponsor(address,address) f01fba93
+	/// @dev EVM selector for this function is: 0xf01fba93,
+	///  or in textual repr: setSponsor(address,address)
 	function setSponsor(address contractAddress, address sponsor) public {
 		require(false, stub_error);
 		contractAddress;
@@ -62,8 +59,8 @@
 	/// Set contract as self sponsored.
 	///
 	/// @param contractAddress Contract for which a self sponsoring is being enabled.
-	///
-	/// Selector: selfSponsoredEnable(address) 89f7d9ae
+	/// @dev EVM selector for this function is: 0x89f7d9ae,
+	///  or in textual repr: selfSponsoredEnable(address)
 	function selfSponsoredEnable(address contractAddress) public {
 		require(false, stub_error);
 		contractAddress;
@@ -73,8 +70,8 @@
 	/// Remove sponsor.
 	///
 	/// @param contractAddress Contract for which a sponsorship is being removed.
-	///
-	/// Selector: removeSponsor(address) ef784250
+	/// @dev EVM selector for this function is: 0xef784250,
+	///  or in textual repr: removeSponsor(address)
 	function removeSponsor(address contractAddress) public {
 		require(false, stub_error);
 		contractAddress;
@@ -86,8 +83,8 @@
 	/// @dev Caller must be same that set via [`setSponsor`].
 	///
 	/// @param contractAddress Сontract for which need to confirm sponsorship.
-	///
-	/// Selector: confirmSponsorship(address) abc00001
+	/// @dev EVM selector for this function is: 0xabc00001,
+	///  or in textual repr: confirmSponsorship(address)
 	function confirmSponsorship(address contractAddress) public {
 		require(false, stub_error);
 		contractAddress;
@@ -98,8 +95,8 @@
 	///
 	/// @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.
-	///
-	/// Selector: getSponsor(address) 743fc745
+	/// @dev EVM selector for this function is: 0x743fc745,
+	///  or in textual repr: getSponsor(address)
 	function getSponsor(address contractAddress)
 		public
 		view
@@ -115,8 +112,8 @@
 	///
 	/// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.
 	/// @return **true** if contract has confirmed sponsor.
-	///
-	/// Selector: hasSponsor(address) 97418603
+	/// @dev EVM selector for this function is: 0x97418603,
+	///  or in textual repr: hasSponsor(address)
 	function hasSponsor(address contractAddress) public view returns (bool) {
 		require(false, stub_error);
 		contractAddress;
@@ -128,8 +125,8 @@
 	///
 	/// @param contractAddress The contract for which the presence of a pending sponsor is checked.
 	/// @return **true** if contract has pending sponsor.
-	///
-	/// Selector: hasPendingSponsor(address) 39b9b242
+	/// @dev EVM selector for this function is: 0x39b9b242,
+	///  or in textual repr: hasPendingSponsor(address)
 	function hasPendingSponsor(address contractAddress)
 		public
 		view
@@ -141,7 +138,8 @@
 		return false;
 	}
 
-	/// Selector: sponsoringEnabled(address) 6027dc61
+	/// @dev EVM selector for this function is: 0x6027dc61,
+	///  or in textual repr: sponsoringEnabled(address)
 	function sponsoringEnabled(address contractAddress)
 		public
 		view
@@ -153,7 +151,8 @@
 		return false;
 	}
 
-	/// Selector: setSponsoringMode(address,uint8) fde8a560
+	/// @dev EVM selector for this function is: 0xfde8a560,
+	///  or in textual repr: setSponsoringMode(address,uint8)
 	function setSponsoringMode(address contractAddress, uint8 mode) public {
 		require(false, stub_error);
 		contractAddress;
@@ -161,11 +160,15 @@
 		dummy = 0;
 	}
 
-	/// Selector: sponsoringMode(address) b70c7267
-	function sponsoringMode(address contractAddress)
+	/// Get current contract sponsoring rate limit
+	/// @param contractAddress Contract to get sponsoring mode of
+	/// @return uint32 Amount of blocks between two sponsored transactions
+	/// @dev EVM selector for this function is: 0x610cfabd,
+	///  or in textual repr: getSponsoringRateLimit(address)
+	function getSponsoringRateLimit(address contractAddress)
 		public
 		view
-		returns (uint8)
+		returns (uint32)
 	{
 		require(false, stub_error);
 		contractAddress;
@@ -173,7 +176,14 @@
 		return 0;
 	}
 
-	/// Selector: setSponsoringRateLimit(address,uint32) 77b6c908
+	/// Set contract sponsoring rate limit
+	/// @dev Sponsoring rate limit - is a minimum amount of blocks that should
+	///  pass between two sponsored transactions
+	/// @param contractAddress Contract to change sponsoring rate limit of
+	/// @param rateLimit Target rate limit
+	/// @dev Only contract owner can change this setting
+	/// @dev EVM selector for this function is: 0x77b6c908,
+	///  or in textual repr: setSponsoringRateLimit(address,uint32)
 	function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
 		public
 	{
@@ -183,32 +193,53 @@
 		dummy = 0;
 	}
 
-	/// Selector: getSponsoringRateLimit(address) 610cfabd
-	function getSponsoringRateLimit(address contractAddress)
+	/// Is specified user present in contract allow list
+	/// @dev Contract owner always implicitly included
+	/// @param contractAddress Contract to check allowlist of
+	/// @param user User to check
+	/// @return bool Is specified users exists in contract allowlist
+	/// @dev EVM selector for this function is: 0x5c658165,
+	///  or in textual repr: allowed(address,address)
+	function allowed(address contractAddress, address user)
 		public
 		view
-		returns (uint32)
+		returns (bool)
 	{
 		require(false, stub_error);
 		contractAddress;
+		user;
 		dummy;
-		return 0;
+		return false;
 	}
 
-	/// Selector: allowed(address,address) 5c658165
-	function allowed(address contractAddress, address user)
-		public
-		view
-		returns (bool)
-	{
+	/// Toggle user presence in contract allowlist
+	/// @param contractAddress Contract to change allowlist of
+	/// @param user Which user presence should be toggled
+	/// @param isAllowed `true` if user should be allowed to be sponsored
+	///  or call this contract, `false` otherwise
+	/// @dev Only contract owner can change this setting
+	/// @dev EVM selector for this function is: 0x4706cc1c,
+	///  or in textual repr: toggleAllowed(address,address,bool)
+	function toggleAllowed(
+		address contractAddress,
+		address user,
+		bool isAllowed
+	) public {
 		require(false, stub_error);
 		contractAddress;
 		user;
-		dummy;
-		return false;
+		isAllowed;
+		dummy = 0;
 	}
 
-	/// Selector: allowlistEnabled(address) c772ef6c
+	/// Is this contract has allowlist access enabled
+	/// @dev Allowlist always can have users, and it is used for two purposes:
+	///  in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist
+	///  in case of allowlist access enabled, only users from allowlist may call this contract
+	/// @param contractAddress Contract to get allowlist access of
+	/// @return bool Is specified contract has allowlist access enabled
+	/// @dev EVM selector for this function is: 0xc772ef6c,
+	///  or in textual repr: allowlistEnabled(address)
 	function allowlistEnabled(address contractAddress)
 		public
 		view
@@ -220,24 +251,21 @@
 		return false;
 	}
 
-	/// Selector: toggleAllowlist(address,bool) 36de20f5
+	/// Toggle contract allowlist access
+	/// @param contractAddress Contract to change allowlist access of
+	/// @param enabled Should allowlist access to be enabled?
+	/// @dev EVM selector for this function is: 0x36de20f5,
+	///  or in textual repr: toggleAllowlist(address,bool)
 	function toggleAllowlist(address contractAddress, bool enabled) public {
 		require(false, stub_error);
 		contractAddress;
 		enabled;
 		dummy = 0;
 	}
+}
 
-	/// Selector: toggleAllowed(address,address,bool) 4706cc1c
-	function toggleAllowed(
-		address contractAddress,
-		address user,
-		bool isAllowed
-	) public {
-		require(false, stub_error);
-		contractAddress;
-		user;
-		isAllowed;
-		dummy = 0;
-	}
+/// @dev anonymous struct
+struct Tuple0 {
+	address field_0;
+	uint256 field_1;
 }
modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
33
4pragma solidity >=0.8.0 <0.9.0;4pragma solidity >=0.8.0 <0.9.0;
5
6/// @dev anonymous struct
7struct Tuple0 {
8 address field_0;
9 uint256 field_1;
10}
115
12/// @dev common stubs holder6/// @dev common stubs holder
13interface Dummy {7interface Dummy {
18 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);
19}13}
2014
15/// @title Magic contract, which allows users to reconfigure other contracts
21/// @dev the ERC-165 identifier for this interface is 0x6073d91716/// @dev the ERC-165 identifier for this interface is 0xd77fab70
22interface ContractHelpers is Dummy, ERC165 {17interface ContractHelpers is Dummy, ERC165 {
23 /// Get contract ovner18 /// Get user, which deployed specified contract
24 ///19 /// @dev May return zero address in case if contract is deployed
25 /// @param contractAddress contract for which the owner is being determined.20 /// using uniquenetwork evm-migration pallet, or using other terms not
21 /// intended by pallet-evm
22 /// @dev Returns zero address if contract does not exists
23 /// @param contractAddress Contract to get owner of
26 /// @return Contract owner.24 /// @return address Owner of contract
27 ///25 /// @dev EVM selector for this function is: 0x5152b14c,
28 /// Selector: contractOwner(address) 5152b14c26 /// or in textual repr: contractOwner(address)
29 function contractOwner(address contractAddress)27 function contractOwner(address contractAddress)
30 external28 external
31 view29 view
32 returns (address);30 returns (address);
3331
34 /// Set sponsor.32 /// Set sponsor.
35 ///
36 /// @param contractAddress Contract for which a sponsor is being established.33 /// @param contractAddress Contract for which a sponsor is being established.
37 /// @param sponsor User address who set as pending sponsor.34 /// @param sponsor User address who set as pending sponsor.
38 ///35 /// @dev EVM selector for this function is: 0xf01fba93,
39 /// Selector: setSponsor(address,address) f01fba9336 /// or in textual repr: setSponsor(address,address)
40 function setSponsor(address contractAddress, address sponsor) external;37 function setSponsor(address contractAddress, address sponsor) external;
4138
42 /// Set contract as self sponsored.39 /// Set contract as self sponsored.
43 ///40 ///
44 /// @param contractAddress Contract for which a self sponsoring is being enabled.41 /// @param contractAddress Contract for which a self sponsoring is being enabled.
45 ///42 /// @dev EVM selector for this function is: 0x89f7d9ae,
46 /// Selector: selfSponsoredEnable(address) 89f7d9ae43 /// or in textual repr: selfSponsoredEnable(address)
47 function selfSponsoredEnable(address contractAddress) external;44 function selfSponsoredEnable(address contractAddress) external;
4845
49 /// Remove sponsor.46 /// Remove sponsor.
50 ///47 ///
51 /// @param contractAddress Contract for which a sponsorship is being removed.48 /// @param contractAddress Contract for which a sponsorship is being removed.
52 ///49 /// @dev EVM selector for this function is: 0xef784250,
53 /// Selector: removeSponsor(address) ef78425050 /// or in textual repr: removeSponsor(address)
54 function removeSponsor(address contractAddress) external;51 function removeSponsor(address contractAddress) external;
5552
56 /// Confirm sponsorship.53 /// Confirm sponsorship.
57 ///54 ///
58 /// @dev Caller must be same that set via [`setSponsor`].55 /// @dev Caller must be same that set via [`setSponsor`].
59 ///56 ///
60 /// @param contractAddress Сontract for which need to confirm sponsorship.57 /// @param contractAddress Сontract for which need to confirm sponsorship.
61 ///58 /// @dev EVM selector for this function is: 0xabc00001,
62 /// Selector: confirmSponsorship(address) abc0000159 /// or in textual repr: confirmSponsorship(address)
63 function confirmSponsorship(address contractAddress) external;60 function confirmSponsorship(address contractAddress) external;
6461
65 /// Get current sponsor.62 /// Get current sponsor.
66 ///63 ///
67 /// @param contractAddress The contract for which a sponsor is requested.64 /// @param contractAddress The contract for which a sponsor is requested.
68 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.65 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
69 ///66 /// @dev EVM selector for this function is: 0x743fc745,
70 /// Selector: getSponsor(address) 743fc74567 /// or in textual repr: getSponsor(address)
71 function getSponsor(address contractAddress)68 function getSponsor(address contractAddress)
72 external69 external
73 view70 view
77 ///74 ///
78 /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.75 /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.
79 /// @return **true** if contract has confirmed sponsor.76 /// @return **true** if contract has confirmed sponsor.
80 ///77 /// @dev EVM selector for this function is: 0x97418603,
81 /// Selector: hasSponsor(address) 9741860378 /// or in textual repr: hasSponsor(address)
82 function hasSponsor(address contractAddress) external view returns (bool);79 function hasSponsor(address contractAddress) external view returns (bool);
8380
84 /// Check tat contract has pending sponsor.81 /// Check tat contract has pending sponsor.
85 ///82 ///
86 /// @param contractAddress The contract for which the presence of a pending sponsor is checked.83 /// @param contractAddress The contract for which the presence of a pending sponsor is checked.
87 /// @return **true** if contract has pending sponsor.84 /// @return **true** if contract has pending sponsor.
88 ///85 /// @dev EVM selector for this function is: 0x39b9b242,
89 /// Selector: hasPendingSponsor(address) 39b9b24286 /// or in textual repr: hasPendingSponsor(address)
90 function hasPendingSponsor(address contractAddress)87 function hasPendingSponsor(address contractAddress)
91 external88 external
92 view89 view
93 returns (bool);90 returns (bool);
9491
92 /// @dev EVM selector for this function is: 0x6027dc61,
95 /// Selector: sponsoringEnabled(address) 6027dc6193 /// or in textual repr: sponsoringEnabled(address)
96 function sponsoringEnabled(address contractAddress)94 function sponsoringEnabled(address contractAddress)
97 external95 external
98 view96 view
99 returns (bool);97 returns (bool);
10098
99 /// @dev EVM selector for this function is: 0xfde8a560,
101 /// Selector: setSponsoringMode(address,uint8) fde8a560100 /// or in textual repr: setSponsoringMode(address,uint8)
102 function setSponsoringMode(address contractAddress, uint8 mode) external;101 function setSponsoringMode(address contractAddress, uint8 mode) external;
103102
104 /// Selector: sponsoringMode(address) b70c7267103 /// Get current contract sponsoring rate limit
104 /// @param contractAddress Contract to get sponsoring mode of
105 /// @return uint32 Amount of blocks between two sponsored transactions
106 /// @dev EVM selector for this function is: 0x610cfabd,
107 /// or in textual repr: getSponsoringRateLimit(address)
105 function sponsoringMode(address contractAddress)108 function getSponsoringRateLimit(address contractAddress)
106 external109 external
107 view110 view
108 returns (uint8);111 returns (uint32);
109112
113 /// Set contract sponsoring rate limit
114 /// @dev Sponsoring rate limit - is a minimum amount of blocks that should
115 /// pass between two sponsored transactions
116 /// @param contractAddress Contract to change sponsoring rate limit of
117 /// @param rateLimit Target rate limit
118 /// @dev Only contract owner can change this setting
119 /// @dev EVM selector for this function is: 0x77b6c908,
110 /// Selector: setSponsoringRateLimit(address,uint32) 77b6c908120 /// or in textual repr: setSponsoringRateLimit(address,uint32)
111 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)121 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
112 external;122 external;
113123
114 /// Selector: getSponsoringRateLimit(address) 610cfabd124 /// Is specified user present in contract allow list
125 /// @dev Contract owner always implicitly included
126 /// @param contractAddress Contract to check allowlist of
127 /// @param user User to check
128 /// @return bool Is specified users exists in contract allowlist
129 /// @dev EVM selector for this function is: 0x5c658165,
130 /// or in textual repr: allowed(address,address)
115 function getSponsoringRateLimit(address contractAddress)131 function allowed(address contractAddress, address user)
116 external132 external
117 view133 view
118 returns (uint32);134 returns (bool);
119135
136 /// Toggle user presence in contract allowlist
137 /// @param contractAddress Contract to change allowlist of
138 /// @param user Which user presence should be toggled
139 /// @param isAllowed `true` if user should be allowed to be sponsored
140 /// or call this contract, `false` otherwise
141 /// @dev Only contract owner can change this setting
142 /// @dev EVM selector for this function is: 0x4706cc1c,
120 /// Selector: allowed(address,address) 5c658165143 /// or in textual repr: toggleAllowed(address,address,bool)
121 function allowed(address contractAddress, address user)144 function toggleAllowed(
145 address contractAddress,
146 address user,
147 bool isAllowed
122 external148 ) external;
123 view149
124 returns (bool);150 /// Is this contract has allowlist access enabled
125151 /// @dev Allowlist always can have users, and it is used for two purposes:
152 /// in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist
153 /// in case of allowlist access enabled, only users from allowlist may call this contract
154 /// @param contractAddress Contract to get allowlist access of
155 /// @return bool Is specified contract has allowlist access enabled
156 /// @dev EVM selector for this function is: 0xc772ef6c,
126 /// Selector: allowlistEnabled(address) c772ef6c157 /// or in textual repr: allowlistEnabled(address)
127 function allowlistEnabled(address contractAddress)158 function allowlistEnabled(address contractAddress)
128 external159 external
129 view160 view
130 returns (bool);161 returns (bool);
131162
163 /// Toggle contract allowlist access
164 /// @param contractAddress Contract to change allowlist access of
165 /// @param enabled Should allowlist access to be enabled?
166 /// @dev EVM selector for this function is: 0x36de20f5,
132 /// Selector: toggleAllowlist(address,bool) 36de20f5167 /// or in textual repr: toggleAllowlist(address,bool)
133 function toggleAllowlist(address contractAddress, bool enabled) external;168 function toggleAllowlist(address contractAddress, bool enabled) external;
134
135 /// Selector: toggleAllowed(address,address,bool) 4706cc1c
136 function toggleAllowed(
137 address contractAddress,
138 address user,
139 bool isAllowed
140 ) external;
141}169}
170
171/// @dev anonymous struct
172struct Tuple0 {
173 address field_0;
174 uint256 field_1;
175}
142176
modifiedtests/src/eth/util/contractHelpersAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/util/contractHelpersAbi.json
+++ b/tests/src/eth/util/contractHelpersAbi.json
@@ -197,19 +197,6 @@
   },
   {
     "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      }
-    ],
-    "name": "sponsoringMode",
-    "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],
-    "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [
       { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }
     ],
     "name": "supportsInterface",