From 7e9e8858b43321eb3b26b9d3ea941be138161c39 Mon Sep 17 00:00:00 2001 From: Grigoriy Simonov Date: Tue, 13 Sep 2022 09:03:56 +0000 Subject: [PATCH] chore: add posibility to define different limits for methods in the future --- --- a/pallets/evm-contract-helpers/src/eth.rs +++ b/pallets/evm-contract-helpers/src/eth.rs @@ -263,7 +263,7 @@ } fn get_sponsoring_fee_limit(&self, contract_address: address) -> Result { - Ok(>::get(contract_address)) + Ok(>::get(contract_address, 0xffffffff)) } /// Is specified user present in contract allow list @@ -413,7 +413,7 @@ } } - let sponsored_fee_limit = >::get(contract_address); + let sponsored_fee_limit = >::get(contract_address, 0xffffffff); if call_context.max_fee > sponsored_fee_limit { return None; --- a/pallets/evm-contract-helpers/src/lib.rs +++ b/pallets/evm-contract-helpers/src/lib.rs @@ -121,9 +121,11 @@ /// * **Key2** - sponsored user address. /// * **Value** - last sponsored block number. #[pallet::storage] - pub(super) type SponsoringFeeLimit = StorageMap< - Hasher = Twox128, - Key = H160, + pub(super) type SponsoringFeeLimit = StorageDoubleMap< + Hasher1 = Twox128, + Key1 = H160, + Hasher2 = Blake2_128Concat, + Key2 = u32, Value = U256, QueryKind = ValueQuery, OnEmpty = T::DefaultSponsoringFeeLimit, @@ -367,7 +369,7 @@ /// Set maximum for gas limit of transaction pub fn set_sponsoring_fee_limit(contract: H160, fee_limit: U256) { - >::insert(contract, fee_limit); + >::insert(contract, 0xffffffff, fee_limit); } /// Is user added to allowlist, or he is owner of specified contract -- gitstuff