--- a/pallets/common/src/erc.rs +++ b/pallets/common/src/erc.rs @@ -14,7 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Unique Network. If not, see . -use evm_coder::{solidity_interface, types::*, execution::{Result, Error}}; +use evm_coder::{ + solidity_interface, + types::*, + execution::{Result, Error}, +}; pub use pallet_evm::{PrecompileOutput, PrecompileResult, account::CrossAccountId}; use pallet_evm_coder_substrate::dispatch_to_evm; use sp_core::{H160, U256}; @@ -66,11 +70,7 @@ Ok(prop.to_vec()) } - fn eth_set_sponsor( - &mut self, - caller: caller, - sponsor: address, - ) -> Result { + fn eth_set_sponsor(&mut self, caller: caller, sponsor: address) -> Result { check_is_owner(caller, self)?; let sponsor = T::CrossAccountId::from_eth(sponsor); @@ -88,44 +88,40 @@ Ok(()) } - fn set_limit( - &mut self, - caller: caller, - limit: string, - value: string, - ) -> Result { + fn set_limit(&mut self, caller: caller, limit: string, value: string) -> 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)?; - }, + } "sponsoredDataSize" => { limits.sponsored_data_size = parse_int(value)?; - }, + } "sponsoredDataRateLimit" => { - limits.sponsored_data_rate_limit = Some(SponsoringRateLimit::Blocks(parse_int(value)?.unwrap())); - }, + limits.sponsored_data_rate_limit = + Some(SponsoringRateLimit::Blocks(parse_int(value)?.unwrap())); + } "tokenLimit" => { limits.token_limit = parse_int(value)?; - }, + } "sponsorTransferTimeout" => { limits.sponsor_transfer_timeout = parse_int(value)?; - }, + } "sponsorApproveTimeout" => { limits.sponsor_approve_timeout = parse_int(value)?; - }, + } "ownerCanTransfer" => { limits.owner_can_transfer = parse_bool(value)?; - }, + } "ownerCanDestroy" => { limits.owner_can_destroy = parse_bool(value)?; - }, + } "transfersEnabled" => { limits.transfers_enabled = parse_bool(value)?; - }, - _ => return Err(Error::Revert(format!("Unknown limit \"{}\"", limit))) + } + _ => return Err(Error::Revert(format!("Unknown limit \"{}\"", limit))), } self.limits = limits; save(self); @@ -150,13 +146,15 @@ } fn parse_int(value: string) -> Result> { - value.parse::() + value + .parse::() .map_err(|e| Error::Revert(format!("Int value \"{}\" parse error: {}", value, e))) .map(|value| Some(value)) } fn parse_bool(value: string) -> Result> { - value.parse::() + value + .parse::() .map_err(|e| Error::Revert(format!("Bool value \"{}\" parse error: {}", value, e))) .map(|value| Some(value)) -} \ No newline at end of file +} --- a/pallets/evm-contract-helpers/src/eth.rs +++ b/pallets/evm-contract-helpers/src/eth.rs @@ -20,7 +20,7 @@ use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder}; use pallet_evm::{ ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, - account::CrossAccountId + account::CrossAccountId, }; use sp_core::H160; use crate::{ --- a/pallets/nonfungible/src/common.rs +++ b/pallets/nonfungible/src/common.rs @@ -23,6 +23,7 @@ }; use pallet_common::{ CommonCollectionOperations, CommonWeightInfo, with_weight, weights::WeightInfo as _, + PropertyKeyPermission, }; use sp_runtime::DispatchError; use sp_std::vec::Vec; --- a/pallets/nonfungible/src/erc.rs +++ b/pallets/nonfungible/src/erc.rs @@ -21,7 +21,10 @@ }; use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight}; use frame_support::BoundedVec; -use up_data_structs::{TokenId, SchemaVersion, PropertyPermission, PropertyKeyPermission, Property, CollectionId, PropertyKey, CollectionPropertiesVec}; +use up_data_structs::{ + TokenId, SchemaVersion, PropertyPermission, PropertyKeyPermission, Property, CollectionId, + PropertyKey, CollectionPropertiesVec, +}; use pallet_evm_coder_substrate::dispatch_to_evm; use sp_core::{H160, U256}; use sp_std::vec::Vec; @@ -382,11 +385,15 @@ } let mut properties = CollectionPropertiesVec::default(); - properties.try_push(Property{ - key, - value: token_uri.into_bytes().try_into() - .map_err(|_| "token uri is too long")? - }).map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?; + properties + .try_push(Property { + key, + value: token_uri + .into_bytes() + .try_into() + .map_err(|_| "token uri is too long")?, + }) + .map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?; >::create_item( self, @@ -407,10 +414,14 @@ } } -fn get_token_permission(collection_id: CollectionId, key: &PropertyKey) -> Result { +fn get_token_permission( + collection_id: CollectionId, + key: &PropertyKey, +) -> Result { let token_property_permissions = CollectionPropertyPermissions::::try_get(collection_id) .map_err(|_| Error::Revert("No permissions for collection".into()))?; - let a = token_property_permissions.get(key) + let a = token_property_permissions + .get(key) .map(|p| p.clone()) .ok_or_else(|| Error::Revert("No permission for tokenURI".into()))?; Ok(a) --- a/pallets/unique/src/eth/mod.rs +++ b/pallets/unique/src/eth/mod.rs @@ -83,11 +83,11 @@ collection_admin: true, token_owner: false, }; - let mut token_property_permissions = up_data_structs::CollectionPropertiesPermissionsVec::default(); - token_property_permissions.try_push(up_data_structs::PropertyKeyPermission{ - key, - permission, - }).map_err(|e| Error::Revert(format!("{:?}", e)))?; + let mut token_property_permissions = + up_data_structs::CollectionPropertiesPermissionsVec::default(); + token_property_permissions + .try_push(up_data_structs::PropertyKeyPermission { key, permission }) + .map_err(|e| Error::Revert(format!("{:?}", e)))?; let data = CreateCollectionData { name, --- a/runtime/opal/src/lib.rs +++ b/runtime/opal/src/lib.rs @@ -49,8 +49,8 @@ // A few exports that help ease life for downstream crates. pub use pallet_balances::Call as BalancesCall; pub use pallet_evm::{ - EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _, OnMethodCall, - Account as EVMAccount, FeeCalculator, GasWeightMapping, + EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _, + OnMethodCall, Account as EVMAccount, FeeCalculator, GasWeightMapping, }; pub use frame_support::{ construct_runtime, match_types,