difftreelog
fix PR
in: master
2 files changed
pallets/common/src/erc.rsdiffbeforeafterboth285 let limits = &self.collection.limits;285 let limits = &self.collection.limits;286286287 Ok(vec![287 Ok(vec![288 eth::CollectionLimit::from_opt_int(288 eth::CollectionLimit::new(289 eth::CollectionLimitField::AccountTokenOwnership,289 eth::CollectionLimitField::AccountTokenOwnership,290 limits.account_token_ownership_limit,290 limits.account_token_ownership_limit,291 ),291 ),292 eth::CollectionLimit::from_opt_int(292 eth::CollectionLimit::new(293 eth::CollectionLimitField::SponsoredDataSize,293 eth::CollectionLimitField::SponsoredDataSize,294 limits.sponsored_data_size,294 limits.sponsored_data_size,295 ),295 ),296 limits296 limits297 .sponsored_data_rate_limit297 .sponsored_data_rate_limit298 .and_then(|limit| {298 .and_then(|limit| {299 if let SponsoringRateLimit::Blocks(blocks) = limit {299 if let SponsoringRateLimit::Blocks(blocks) = limit {300 Some(eth::CollectionLimit::from_int(300 Some(eth::CollectionLimit::new::<u32>(301 eth::CollectionLimitField::SponsoredDataRateLimit,301 eth::CollectionLimitField::SponsoredDataRateLimit,302 blocks,302 blocks,303 ))303 ))304 } else {304 } else {305 None305 None306 }306 }307 })307 })308 .unwrap_or(eth::CollectionLimit::from_int(308 .unwrap_or(eth::CollectionLimit::new::<u32>(309 eth::CollectionLimitField::SponsoredDataRateLimit,309 eth::CollectionLimitField::SponsoredDataRateLimit,310 Default::default(),310 Default::default(),311 )),311 )),312 eth::CollectionLimit::from_opt_int(312 eth::CollectionLimit::new(eth::CollectionLimitField::TokenLimit, limits.token_limit),313 eth::CollectionLimitField::TokenLimit,314 limits.token_limit,315 ),316 eth::CollectionLimit::from_opt_int(313 eth::CollectionLimit::new(317 eth::CollectionLimitField::SponsorTransferTimeout,314 eth::CollectionLimitField::SponsorTransferTimeout,318 limits.sponsor_transfer_timeout,315 limits.sponsor_transfer_timeout,319 ),316 ),320 eth::CollectionLimit::from_opt_int(317 eth::CollectionLimit::new(321 eth::CollectionLimitField::SponsorApproveTimeout,318 eth::CollectionLimitField::SponsorApproveTimeout,322 limits.sponsor_approve_timeout,319 limits.sponsor_approve_timeout,323 ),320 ),324 eth::CollectionLimit::from_opt_bool(321 eth::CollectionLimit::new(325 eth::CollectionLimitField::OwnerCanTransfer,322 eth::CollectionLimitField::OwnerCanTransfer,326 limits.owner_can_transfer,323 limits.owner_can_transfer,327 ),324 ),328 eth::CollectionLimit::from_opt_bool(325 eth::CollectionLimit::new(329 eth::CollectionLimitField::OwnerCanDestroy,326 eth::CollectionLimitField::OwnerCanDestroy,330 limits.owner_can_destroy,327 limits.owner_can_destroy,331 ),328 ),332 eth::CollectionLimit::from_opt_bool(329 eth::CollectionLimit::new(333 eth::CollectionLimitField::TransferEnabled,330 eth::CollectionLimitField::TransferEnabled,334 limits.transfers_enabled,331 limits.transfers_enabled,335 ),332 ),pallets/common/src/eth.rsdiffbeforeafterboth--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -97,17 +97,23 @@
}
}
+impl From<bool> for OptionUint {
+ fn from(value: bool) -> Self {
+ Self {
+ status: true,
+ value: if value {
+ uint256::from(1)
+ } else {
+ Default::default()
+ },
+ }
+ }
+}
+
impl From<Option<bool>> for OptionUint {
fn from(value: Option<bool>) -> Self {
match value {
- Some(value) => Self {
- status: true,
- value: if value {
- uint256::from(1)
- } else {
- Default::default()
- },
- },
+ Some(value) => Self::from(value),
None => Self {
status: false,
value: Default::default(),
@@ -241,30 +247,16 @@
}
impl CollectionLimit {
- /// Make [`CollectionLimit`] from [`CollectionLimitField`] and int value.
- pub fn from_int(field: CollectionLimitField, value: u32) -> Self {
- Self {
- field,
- value: value.into(),
- }
- }
-
- /// Make [`CollectionLimit`] from [`CollectionLimitField`] and optional int value.
- pub fn from_opt_int(field: CollectionLimitField, value: Option<u32>) -> Self {
- Self {
- field,
- value: value.into(),
- }
- }
-
- /// Make [`CollectionLimit`] from [`CollectionLimitField`] and bool value.
- pub fn from_opt_bool(field: CollectionLimitField, value: Option<bool>) -> Self {
+ /// Create [`CollectionLimit`] from field and value.
+ pub fn new<T>(field: CollectionLimitField, value: T) -> Self
+ where
+ OptionUint: From<T>,
+ {
Self {
field,
value: value.into(),
}
}
-
/// Whether the field contains a value.
pub fn has_value(&self) -> bool {
self.value.status