Browse Source

Merge pull request #3292 from ignazio-bovo/olympia_fix_NftIssuanceDisabled

Olympia fix nft issuance disabled
shamil-gadelshin 3 years ago
parent
commit
d740547230

+ 53 - 34
runtime-modules/content/src/lib.rs

@@ -2,7 +2,8 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 #![recursion_limit = "256"]
 // Internal Substrate warning (decl_event).
-#![allow(clippy::unused_unit)]
+// TODO RHODES: remove dead code
+#![allow(clippy::unused_unit, dead_code)]
 
 #[cfg(test)]
 mod tests;
@@ -707,14 +708,15 @@ decl_module! {
                 Storage::<T>::upload_data_objects(params)?;
             }
 
-            let nft_status = params.auto_issue_nft
-                .as_ref()
-                .map_or(
-                    Ok(None),
-                    |issuance_params| {
-                        Some(Self::construct_owned_nft(issuance_params)).transpose()
-                    }
-            )?;
+            // TODO RHODES: enable after open auction fix
+            // let nft_status = params.auto_issue_nft
+            //     .as_ref()
+            //     .map_or(
+            //         Ok(None),
+            //         |issuance_params| {
+            //             Some(Self::construct_owned_nft(issuance_params)).transpose()
+            //         }
+            // )?;
 
             // create the video struct
             let video: Video<T> = VideoRecord {
@@ -722,7 +724,8 @@ decl_module! {
                 is_censored: false,
                 enable_comments: params.enable_comments,
                 video_post_id:  None,
-                nft_status,
+                // TODO RHODES: enable after open auction fix
+                nft_status: None,
             };
 
             //
@@ -783,6 +786,19 @@ decl_module! {
                 )?;
             }
 
+
+            // TODO RHODES: enable after open auction fix
+            // let nft_status = params.auto_issue_nft
+            //     .as_ref()
+            //     .map_or(
+            //         Ok(None),
+            //         |issuance_params| {
+            //             ensure!(video.nft_status.is_none(), Error::<T>::NftAlreadyExists);
+            //             Some(Self::construct_owned_nft(issuance_params)).transpose()
+            //         }
+            // )?;
+
+
             //
             // == MUTATION SAFE ==
             //
@@ -1300,40 +1316,43 @@ decl_module! {
             actor: ContentActor<T::CuratorGroupId, T::CuratorId, T::MemberId>,
             video_id: T::VideoId,
             params: NftIssuanceParameters<T>
-        ) {
-            let sender = ensure_signed(origin)?;
+        ) -> DispatchResult {
+            // TODO RHODES: remove after open auction fix
+            Err(DispatchError::Other("nft issuance disabled"))
 
-            // Ensure given video exists
-            let video = Self::ensure_video_exists(&video_id)?;
+            // let sender = ensure_signed(origin)?;
 
-            // Ensure have not been issued yet
-            video.ensure_nft_is_not_issued::<T>()?;
+            // // Ensure given video exists
+            // let video = Self::ensure_video_exists(&video_id)?;
 
-            let channel_id = video.in_channel;
+            // // Ensure have not been issued yet
+            // video.ensure_nft_is_not_issued::<T>()?;
 
-            // Ensure channel exists, retrieve channel owner
-            let channel = Self::ensure_channel_exists(&channel_id)?;
+            // let channel_id = video.in_channel;
 
-            ensure_actor_authorized_to_update_channel_assets::<T>(&sender, &actor, &channel)?;
+            // // Ensure channel exists, retrieve channel owner
+            // let channel = Self::ensure_channel_exists(&channel_id)?;
 
-            // The content owner will be..
-            let nft_status = Self::construct_owned_nft(&params)?;
+            // ensure_actor_authorized_to_update_channel_assets::<T>(&sender, &actor, &channel)?;
 
-            //
-            // == MUTATION SAFE ==
-            //
+            // // The content owner will be..
+            // let nft_status = Self::construct_owned_nft(&params)?;
 
-            // Issue Nft
-            let video = video.set_nft_status(nft_status);
+            // //
+            // // == MUTATION SAFE ==
+            // //
 
-            // Update the video
-            VideoById::<T>::insert(video_id, video);
+            // // Issue Nft
+            // let video = video.set_nft_status(nft_status);
+
+            // // Update the video
+            // VideoById::<T>::insert(video_id, video);
 
-            Self::deposit_event(RawEvent::NftIssued(
-                actor,
-                video_id,
-                params,
-            ));
+            // Self::deposit_event(RawEvent::NftIssued(
+            //     actor,
+            //     video_id,
+            //     params,
+            // ));
         }
 
         /// Start video nft auction

+ 2 - 1
runtime-modules/content/src/tests/mod.rs

@@ -5,6 +5,7 @@ mod curators;
 mod fixtures;
 mod merkle;
 mod mock;
-mod nft;
+// TODO RHODES: enable after open auction fix
+//mod nft;
 mod posts;
 mod videos;

+ 32 - 31
runtime-modules/content/src/tests/videos.rs

@@ -5,37 +5,38 @@ use super::mock::*;
 use crate::*;
 use frame_support::{assert_err, assert_ok};
 
-#[test]
-fn delete_video_nft_is_issued() {
-    with_default_mock_builder(|| {
-        // Run to block one to see emitted events
-        run_to_block(1);
-
-        let video_id = Content::next_video_id();
-        create_initial_storage_buckets_helper();
-        increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE);
-        create_default_member_owned_channel_with_video();
-
-        // Issue nft
-        assert_ok!(Content::issue_nft(
-            Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
-            ContentActor::Member(DEFAULT_MEMBER_ID),
-            video_id,
-            NftIssuanceParameters::<Test>::default(),
-        ));
-
-        // Make an attempt to delete a video, which has an nft issued already.
-        assert_err!(
-            Content::delete_video(
-                Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
-                ContentActor::Member(DEFAULT_MEMBER_ID),
-                video_id,
-                BTreeSet::new(),
-            ),
-            Error::<Test>::NftAlreadyExists
-        );
-    })
-}
+// TODO RHODES : enable after open auction fix
+// #[test]
+// fn delete_video_nft_is_issued() {
+//     with_default_mock_builder(|| {
+//         // Run to block one to see emitted events
+//         run_to_block(1);
+
+//         let video_id = Content::next_video_id();
+//         create_initial_storage_buckets_helper();
+//         increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE);
+//         create_default_member_owned_channel_with_video();
+
+//         // Issue nft
+//         assert_ok!(Content::issue_nft(
+//             Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
+//             ContentActor::Member(DEFAULT_MEMBER_ID),
+//             video_id,
+//             NftIssuanceParameters::<Test>::default(),
+//         ));
+
+//         // Make an attempt to delete a video, which has an nft issued already.
+//         assert_err!(
+//             Content::delete_video(
+//                 Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
+//                 ContentActor::Member(DEFAULT_MEMBER_ID),
+//                 video_id,
+//                 BTreeSet::new(),
+//             ),
+//             Error::<Test>::NftAlreadyExists
+//         );
+//     })
+// }
 
 #[test]
 fn curators_can_censor_videos() {