Skip to content

Commit

Permalink
run fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Satoshi-Kusumoto committed Aug 2, 2021
1 parent e9e86fd commit 9a58864
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions pallets/nft/src/impl_nonfungibles.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@

//! Implementations for `nonfungibles` traits.

use super::*;
use frame_support::{
traits::tokens::nonfungibles::{Inspect, Transfer},
};
use frame_support::traits::tokens::nonfungibles::{Inspect, Transfer};
use sp_runtime::DispatchResult;

impl<T: Config> Inspect<<T as frame_system::Config>::AccountId> for Pallet<T> {
Expand All @@ -15,7 +12,7 @@ impl<T: Config> Inspect<<T as frame_system::Config>::AccountId> for Pallet<T> {
class: &Self::ClassId,
instance: &Self::InstanceId,
) -> Option<<T as frame_system::Config>::AccountId> {
orml_nft::Pallet::<T>::tokens(class, instance).map(|a| a.owner)
orml_nft::Pallet::<T>::tokens(class, instance).map(|a| a.owner)
}

fn class_owner(class: &Self::ClassId) -> Option<<T as frame_system::Config>::AccountId> {
Expand Down Expand Up @@ -48,20 +45,20 @@ impl<T: Config> Inspect<<T as frame_system::Config>::AccountId> for Pallet<T> {
fn class_attribute(class: &Self::ClassId, key: &[u8]) -> Option<Vec<u8>> {
if key.is_empty() {
// We make the empty key map to the instance metadata value.
orml_nft::Pallet::<T>::classes(class).map(|a| a.metadata.into())
orml_nft::Pallet::<T>::classes(class).map(|a| a.metadata.into())
} else {
return None
return None
}
}

/// Returns `true` if the asset `instance` of `class` may be transferred.
///
/// Default implementation is that all assets are transferable.
fn can_transfer(class: &Self::ClassId, instance: &Self::InstanceId) -> bool {
match orml_nft::Pallet::<T>::classes(class) {
Some(class) => class.data.properties.0.contains(ClassProperty::Transferable),
_ => false,
}
match orml_nft::Pallet::<T>::classes(class) {
Some(class) => class.data.properties.0.contains(ClassProperty::Transferable),
_ => false,
}
}
}

Expand All @@ -71,8 +68,10 @@ impl<T: Config> Transfer<T::AccountId> for Pallet<T> {
instance: &Self::InstanceId,
destination: &T::AccountId,
) -> DispatchResult {
let from = orml_nft::Pallet::<T>::tokens(class, instance).map(|a| a.owner).ok_or(Error::<T>::TokenIdNotFound)?;
let from = orml_nft::Pallet::<T>::tokens(class, instance)
.map(|a| a.owner)
.ok_or(Error::<T>::TokenIdNotFound)?;
Self::do_transfer(&from, &destination, (*class, *instance))?;
Ok(())
Ok(())
}
}

0 comments on commit 9a58864

Please sign in to comment.