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.rsdiffbeforeafterboth97 }97 }98}98}99100impl From<bool> for OptionUint {101 fn from(value: bool) -> Self {102 Self {103 status: true,104 value: if value {105 uint256::from(1)106 } else {107 Default::default()108 },109 }110 }111}99112100impl From<Option<bool>> for OptionUint {113impl From<Option<bool>> for OptionUint {101 fn from(value: Option<bool>) -> Self {114 fn from(value: Option<bool>) -> Self {102 match value {115 match value {103 Some(value) => Self {116 Some(value) => Self::from(value),104 status: true,105 value: if value {106 uint256::from(1)107 } else {108 Default::default()109 },110 },111 None => Self {117 None => Self {112 status: false,118 status: false,113 value: Default::default(),119 value: Default::default(),241}247}242248243impl CollectionLimit {249impl CollectionLimit {244 /// Make [`CollectionLimit`] from [`CollectionLimitField`] and int value.250 /// Create [`CollectionLimit`] from field and value.245 pub fn from_int(field: CollectionLimitField, value: u32) -> Self {251 pub fn new<T>(field: CollectionLimitField, value: T) -> Self246 Self {252 where247 field,248 value: value.into(),249 }250 }251252 /// Make [`CollectionLimit`] from [`CollectionLimitField`] and optional int value.253 pub fn from_opt_int(field: CollectionLimitField, value: Option<u32>) -> Self {253 OptionUint: From<T>,254 Self {255 field,256 value: value.into(),257 }258 }259260 /// Make [`CollectionLimit`] from [`CollectionLimitField`] and bool value.261 pub fn from_opt_bool(field: CollectionLimitField, value: Option<bool>) -> Self {254 {262 Self {255 Self {263 field,256 field,264 value: value.into(),257 value: value.into(),