difftreelog
chore fix code review requests
in: master
2 files changed
crates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth--- a/crates/evm-coder/procedural/src/solidity_interface.rs
+++ b/crates/evm-coder/procedural/src/solidity_interface.rs
@@ -648,20 +648,15 @@
.unwrap_or_else(|| cases::camelcase::to_camel_case(&ident.to_string()));
let mut selector_str = camel_name.clone();
selector_str.push('(');
- let mut normal_args_count = 0u32;
- let mut has_value_args = false;
- for arg in args.iter() {
- if arg.is_value() {
- has_value_args = true;
- } else if !arg.is_special() {
- if normal_args_count != 0 {
- selector_str.push(',');
- }
- write!(selector_str, "{}", arg.selector_ty()).unwrap();
- normal_args_count = normal_args_count.saturating_add(1);
+ let mut has_normal_args = false;
+ for (i, arg) in args.iter().filter(|arg| !arg.is_special()).enumerate() {
+ if i != 0 {
+ selector_str.push(',');
}
+ write!(selector_str, "{}", arg.selector_ty()).unwrap();
+ has_normal_args = true;
}
- let has_normal_args = normal_args_count > 0;
+ let has_value_args = args.iter().any(|a| a.is_value());
selector_str.push(')');
let selector = fn_selector_str(&selector_str);
pallets/unique/src/eth/mod.rsdiffbeforeafterboth173 base_uri_value,173 base_uri_value,174 add_properties,174 add_properties,175 )?;175 )?;176 let value = value.as_u128();177 let creation_price: Result<u128> = T::CollectionCreationPrice::get()176 check_sent_amount_equals_collection_creation_price::<T>(value)?;178 .try_into()179 .map_err(|_| "collection creation price should be convertible to u128".into());180 if value != creation_price? {181 return Err("Sent amount not equals to collection creation price".into());182 }183 let collection_helpers_address = T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());177 let collection_helpers_address = T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());184178185 let collection_id = T::CollectionDispatch::create(caller.clone(), collection_helpers_address, data)179 let collection_id = T::CollectionDispatch::create(caller.clone(), collection_helpers_address, data)188 Ok(address)182 Ok(address)189}183}184185fn check_sent_amount_equals_collection_creation_price<T: Config>(value: value) -> Result<()> {186 let value = value.as_u128();187 let creation_price: u128 = T::CollectionCreationPrice::get()188 .try_into()189 .map_err(|_| ()) // workaround for `expect` requiring `Debug` trait190 .expect("Collection creation price should be convertible to u128");191 if value != creation_price {192 return Err(format!("Sent amount not equals to collection creation price ({0})", creation_price).into());193 }194 Ok(())195}190196191/// @title Contract, which allows users to operate with collections197/// @title Contract, which allows users to operate with collections192#[solidity_interface(name = CollectionHelpers, events(CollectionHelpersEvents))]198#[solidity_interface(name = CollectionHelpers, events(CollectionHelpersEvents))]218 Default::default(),224 Default::default(),219 false,225 false,220 )?;226 )?;221 let value = value.as_u128();222 let creation_price: Result<u128> = T::CollectionCreationPrice::get()227 check_sent_amount_equals_collection_creation_price::<T>(value)?;223 .try_into()224 .map_err(|_| "collection creation price should be convertible to u128".into());225 let creation_price = creation_price?;226 if value != creation_price {227 return Err(format!("Sent amount not equals to collection creation price ({0})", creation_price).into());228 }229 let collection_helpers_address = T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());228 let collection_helpers_address = T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());230 let collection_id =229 let collection_id =231 T::CollectionDispatch::create(caller, collection_helpers_address, data).map_err(dispatch_to_evm::<T>)?;230 T::CollectionDispatch::create(caller, collection_helpers_address, data).map_err(dispatch_to_evm::<T>)?;255 base_uri_value,254 base_uri_value,256 true,255 true,257 )?;256 )?;258 let value = value.as_u128();259 let creation_price: Result<u128> = T::CollectionCreationPrice::get()257 check_sent_amount_equals_collection_creation_price::<T>(value)?;260 .try_into()261 .map_err(|_| "collection creation price should be convertible to u128".into());262 if value != creation_price? {263 return Err("Sent amount not equals to collection creation price".into());264 }265 let collection_helpers_address = T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());258 let collection_helpers_address = T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());266 let collection_id = T::CollectionDispatch::create(caller, collection_helpers_address, data)259 let collection_id = T::CollectionDispatch::create(caller, collection_helpers_address, data)267 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;260 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;