difftreelog
Merge pull request #194 from UniqueNetwork/feature/getSponsoringRateLimit-helper
in: master
Add getSponsoringRateLimit helper
5 files changed
Makefilediffbeforeafterboth--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,10 @@
-.PHONY: _eth_codegen
-_eth_codegen:
+.PHONY: _help
+_help:
+ @echo "regenerate_solidity - generate stubs/interfaces for contracts defined in native (via evm-coder)"
+ @echo "evm_stubs - recompile contract stubs"
+ @echo "bench - run frame-benchmarking"
+ @echo " bench-evm-migration"
+ @echo " bench-nft"
.PHONY: regenerate_solidity
regenerate_solidity:
pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -8,7 +8,7 @@
};
use frame_support::traits::Get;
use up_sponsorship::SponsorshipHandler;
-use sp_std::vec::Vec;
+use sp_std::{convert::TryInto, vec::Vec};
struct ContractHelpers<T: Config>(SubstrateRecorder<T>);
@@ -50,6 +50,13 @@
Ok(())
}
+ fn get_sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {
+ self.0.consume_sload()?;
+ Ok(<SponsoringRateLimit<T>>::get(contract_address)
+ .try_into()
+ .map_err(|_| "rate limit > u32::MAX")?)
+ }
+
fn allowed(&self, contract_address: address, user: address) -> Result<bool> {
self.0.consume_sload()?;
Ok(<Pallet<T>>::allowed(contract_address, user, true))
pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/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
@@ -52,6 +52,18 @@
dummy = 0;
}
+ // Selector: getSponsoringRateLimit(address) 610cfabd
+ function getSponsoringRateLimit(address contractAddress)
+ public
+ view
+ returns (uint32)
+ {
+ require(false, stub_error);
+ contractAddress;
+ dummy;
+ return 0;
+ }
+
// Selector: allowed(address,address) 5c658165
function allowed(address contractAddress, address user)
public
tests/src/eth/api/ContractHelpers.soldiffbeforeafterboth28 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)28 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)29 external;29 external;3031 // Selector: getSponsoringRateLimit(address) 610cfabd32 function getSponsoringRateLimit(address contractAddress)33 external34 view35 returns (uint32);303631 // Selector: allowed(address,address) 5c65816537 // Selector: allowed(address,address) 5c65816532 function allowed(address contractAddress, address user)38 function allowed(address contractAddress, address user)