fn transfer_ownership(x: i64, y: i64, prev_owner: Option<T::AccountId>, new_owner: T::AccountId) -> Result {
        if let Some(prev_owner) = prev_owner {
            let prev_owner_pixel_count = Self::owned_pixel_count(&prev_owner);
            let new_pixel_count = prev_owner_pixel_count.checked_sub(1).ok_or("Overflow removing old pixel from user")?;
            <OwnedPixelArray<T>>::remove((prev_owner.clone(), new_pixel_count));
            <OwnedPixelCount<T>>::insert(&prev_owner, new_pixel_count);
        }

        let owned_pixel_count = Self::owned_pixel_count(&new_owner);
        let new_owned_pixel_count = owned_pixel_count.checked_add(1).ok_or("Overflow buying new pixel for user")?;

        <OwnedPixelArray<T>>::insert((new_owner.clone(), owned_pixel_count), (x,y));
        <OwnedPixelCount<T>>::insert(&new_owner, new_owned_pixel_count);
        <PixelOwner<T>>::insert((x,y), &new_owner); // will overwrite previous owner if exists
        Ok(())
    }
/// Transfer pixel ownership from previous to new owner
/// Removes pixel from owned pixels array and decreases owned pixels count
Transfer pixel ownership from previous to new owner
Removes pixel from owned pixels array and decreases owned pixels count
Transfer pixel ownership from previous to new owner Removes pixel from owned pixels array and decreases owned pixels count
fn transfer_ownership(x: i64, y: i64, prev_owner: Option<T::AccountId>, new_owner: T::AccountId) -> Result {
        if let Some(prev_owner) = prev_owner {
            let prev_owner_pixel_count = Self::owned_pixel_count(&prev_owner);
            let new_pixel_count = prev_owner_pixel_count.checked_sub(1).ok_or("Overflow removing old pixel from user")?;
            <OwnedPixelArray<T>>::remove((prev_owner.clone(), new_pixel_count));
            <OwnedPixelCount<T>>::insert(&prev_owner, new_pixel_count);
        }
        let owned_pixel_count = Self::owned_pixel_count(&new_owner);
        let new_owned_pixel_count = owned_pixel_count.checked_add(1).ok_or("Overflow buying new pixel for user")?;
        <OwnedPixelArray<T>>::insert((new_owner.clone(), owned_pixel_count), (x,y));
        <OwnedPixelCount<T>>::insert(&new_owner, new_owned_pixel_count);
        <PixelOwner<T>>::insert((x,y), &new_owner); // will overwrite previous owner if exists
        Ok(())
    }
fn transfer_ownership ( x : i64 , y : i64 , prev_owner : Option < T :: AccountId > , new_owner : T :: AccountId ) -> Result { if let Some ( prev_owner ) = prev_owner { let prev_owner_pixel_count = Self :: owned_pixel_count ( & prev_owner ) ; let new_pixel_count = prev_owner_pixel_count . checked_sub ( 1 ) . ok_or ( " " ) ? ; < OwnedPixelArray < T > > :: remove ( ( prev_owner . clone ( ) , new_pixel_count ) ) ; < OwnedPixelCount < T > > :: insert ( & prev_owner , new_pixel_count ) ; } let owned_pixel_count = Self :: owned_pixel_count ( & new_owner ) ; let new_owned_pixel_count = owned_pixel_count . checked_add ( 1 ) . ok_or ( " " ) ? ; < OwnedPixelArray < T > > :: insert ( ( new_owner . clone ( ) , owned_pixel_count ) , ( x , y ) ) ; < OwnedPixelCount < T > > :: insert ( & new_owner , new_owned_pixel_count ) ; < PixelOwner < T > > :: insert ( ( x , y ) , & new_owner ) ; // will overwrite previous owner if exists Ok ( ( ) ) }
Transfer pixel ownership from previous to new owner
Removes pixel from owned pixels array and decreases owned pixels count
Transfer pixel ownership from previous to new owner Removes pixel from owned pixels array and decreases owned pixels count
x
i64
y
i64
prev_owner
Option<T::AccountId>
new_owner
T::AccountId