--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4290,9 +4290,6 @@
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
-dependencies = [
- "spin",
-]
[[package]]
name = "lazycell"
@@ -5920,7 +5917,6 @@
"frame-benchmarking",
"frame-support",
"frame-system",
- "lazy_static",
"pallet-evm",
"pallet-evm-coder-substrate",
"parity-scale-codec 3.1.2",
--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -27,7 +27,6 @@
scale-info = { version = "2.0.1", default-features = false, features = [
"derive",
] }
-lazy_static = { version = "1.4.0", default-features = false, features = ["spin_no_std"] }
[features]
default = ["std"]
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -15,7 +15,7 @@
// along with Unique Network. If not, see .
use evm_coder::{
- solidity_interface,
+ solidity_interface, solidity,
types::*,
execution::{Result, Error},
};
@@ -88,40 +88,64 @@
Ok(())
}
- fn set_limit(&mut self, caller: caller, limit: string, value: string) -> Result {
+ #[solidity(rename_selector = "setLimit")]
+ fn set_int_limit(&mut self, caller: caller, limit: string, value: uint32) -> Result {
check_is_owner(caller, self)?;
let mut limits = self.limits.clone();
match limit.as_str() {
"accountTokenOwnershipLimit" => {
- limits.account_token_ownership_limit = parse_int(value)?;
+ limits.account_token_ownership_limit = Some(value);
}
"sponsoredDataSize" => {
- limits.sponsored_data_size = parse_int(value)?;
+ limits.sponsored_data_size = Some(value);
}
"sponsoredDataRateLimit" => {
- limits.sponsored_data_rate_limit =
- Some(SponsoringRateLimit::Blocks(parse_int(value)?.unwrap()));
+ limits.sponsored_data_rate_limit = Some(SponsoringRateLimit::Blocks(value));
}
"tokenLimit" => {
- limits.token_limit = parse_int(value)?;
+ limits.token_limit = Some(value);
}
"sponsorTransferTimeout" => {
- limits.sponsor_transfer_timeout = parse_int(value)?;
+ limits.sponsor_transfer_timeout = Some(value);
}
"sponsorApproveTimeout" => {
- limits.sponsor_approve_timeout = parse_int(value)?;
+ limits.sponsor_approve_timeout = Some(value);
}
+ _ => {
+ return Err(Error::Revert(format!(
+ "Unknown integer limit \"{}\"",
+ limit
+ )))
+ }
+ }
+ self.limits = >::clamp_limits(self.mode.clone(), &self.limits, limits)
+ .map_err(dispatch_to_evm::)?;
+ save(self);
+ Ok(())
+ }
+
+ #[solidity(rename_selector = "setLimit")]
+ fn set_bool_limit(&mut self, caller: caller, limit: string, value: bool) -> Result {
+ check_is_owner(caller, self)?;
+ let mut limits = self.limits.clone();
+
+ match limit.as_str() {
"ownerCanTransfer" => {
- limits.owner_can_transfer = parse_bool(value)?;
+ limits.owner_can_transfer = Some(value);
}
"ownerCanDestroy" => {
- limits.owner_can_destroy = parse_bool(value)?;
+ limits.owner_can_destroy = Some(value);
}
"transfersEnabled" => {
- limits.transfers_enabled = parse_bool(value)?;
+ limits.transfers_enabled = Some(value);
}
- _ => return Err(Error::Revert(format!("Unknown limit \"{}\"", limit))),
+ _ => {
+ return Err(Error::Revert(format!(
+ "Unknown boolean limit \"{}\"",
+ limit
+ )))
+ }
}
self.limits = >::clamp_limits(self.mode.clone(), &self.limits, limits)
.map_err(dispatch_to_evm::)?;
@@ -146,16 +170,9 @@
>::insert(collection.id, collection.collection.clone());
}
-fn parse_int(value: string) -> Result