浏览代码

Runtime: remove vnft_auction pallet

iorveth 3 年之前
父节点
当前提交
62234d6426

+ 0 - 1
Cargo.toml

@@ -16,7 +16,6 @@ members = [
 	"runtime-modules/token-minting",
 	"runtime-modules/working-group",
 	"runtime-modules/content",
-	"runtime-modules/vnft-auction",
 	"node",
 	"utils/chain-spec-builder/"
 ]

+ 0 - 36
runtime-modules/vnft-auction/Cargo.toml

@@ -1,36 +0,0 @@
-[package]
-name = 'pallet-vnft-auction'
-version = '3.1.1'
-authors = ['Joystream contributors']
-edition = '2018'
-
-[dependencies]
-serde = {version = '1.0.101', features = ['derive'], optional = true}
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62'}
-frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62'}
-codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62'}
-common = { package = 'pallet-common', default-features = false, path = '../common'}
-content = { package = 'pallet-content', default-features = false, path = '../content'}
-
-[dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62'}
-
-[features]
-default = ['std']
-std = [
-	'sp-std/std',
-	'sp-runtime/std',
-	'frame-support/std',
-	'frame-system/std',
-	'sp-arithmetic/std',
-	'codec/std',
-	'serde',
-	'common/std',
-	'timestamp/std',
-]

+ 0 - 56
runtime-modules/vnft-auction/src/errors.rs

@@ -1,56 +0,0 @@
-use crate::*;
-use frame_support::decl_error;
-
-decl_error! {
-    /// Content directory errors
-    pub enum Error for Module<T: Trait> {
-        /// Auction does not exist
-        AuctionDoesNotExist,
-        /// Vnft auction for given video_id have been started already
-        AuctionAlreadyStarted,
-        /// vNFT does not exist
-        VNFTDoesNotExist,
-        /// vNFT for given video id already exists
-        VNFTAlreadyExists,
-        /// Overflow or underflow error happened
-        OverflowOrUnderflowHappened,
-        /// Actor origin authorization error happened
-        ActorOriginAuthError,
-        /// Actor not authorized to issue nft
-        ActorNotAuthorizedToIssueNft,
-        /// Given origin does not own vnft
-        DoesNotOwnVNFT,
-        /// Royalty Upper Bound Exceeded
-        RoyaltyUpperBoundExceeded,
-        /// Royalty Lower Bound Exceeded
-        RoyaltyLowerBoundExceeded,
-        /// Round time upper bound exceeded
-        RoundTimeUpperBoundExceeded,
-        /// Round time lower bound exceeded
-        RoundTimeLowerBoundExceeded,
-        /// Starting price upper bound exceeded
-        StartingPriceUpperBoundExceeded,
-        /// Starting price lower bound exceeded
-        StartingPriceLowerBoundExceeded,
-        /// Auction bid step upper bound exceeded
-        AuctionBidStepUpperBoundExceeded,
-        /// Auction bid step lower bound exceeded
-        AuctionBidStepLowerBoundExceeded,
-        /// Insufficient balance
-        InsufficientBalance,
-        /// Invalid bid
-        InvalidBid,
-        /// Already active auction cannot be cancelled
-        ActionIsAlreadyActive,
-        /// Provided actor is not an auction auctioneer.
-        ActorIsNotAnAuctioneer,
-        /// Can not create aution for vNFT, which is already locked for transfer
-        PendingTransferFound,
-        /// No pending transfers for given vNFT
-        PendingTransferDoesNotExist,
-        /// Pending transfer for given vNFT already exists
-        PendingAlreadyExists,
-        // No incoming transfers for given vnft origin
-        NoIncomingTransfers
-    }
-}

+ 0 - 317
runtime-modules/vnft-auction/src/functions.rs

@@ -1,317 +0,0 @@
-use frame_support::StorageMap;
-
-use crate::*;
-
-impl<T: Trait> Module<T> {
-    /// Authorize auctioneer
-    pub(crate) fn authorize_auctioneer(
-        origin: T::Origin,
-        actor: &ContentActor<CuratorGroupId<T>, CuratorId<T>, MemberId<T>>,
-        auction_params: &AuctionParams<
-            T::VNFTId,
-            VideoId<T>,
-            <T as timestamp::Trait>::Moment,
-            BalanceOf<T>,
-        >,
-    ) -> Result<T::AccountId, DispatchError> {
-        if let AuctionMode::WithoutIsuance(vnft_id) = auction_params.auction_mode {
-            let vnft = Self::ensure_vnft_exists(vnft_id)?;
-
-            // Only members are supposed to start auctions for already existing nfts
-            if let ContentActor::Member(member_id) = actor {
-                let account_id = Self::authorize_participant(origin, *member_id)?;
-
-                vnft.ensure_ownership::<T>(&account_id)?;
-
-                Ok(account_id)
-            } else {
-                Err(Error::<T>::AuctionDoesNotExist.into())
-            }
-        } else {
-            // TODO: Move to common pallet
-            Self::authorize_content_actor(origin.clone(), actor)?;
-            let account_id = ensure_signed(origin)?;
-            Ok(account_id)
-        }
-    }
-
-    /// Authorize participant under given member id
-    pub(crate) fn authorize_participant(
-        origin: T::Origin,
-        member_id: MemberId<T>,
-    ) -> Result<T::AccountId, Error<T>> {
-        T::MemberOriginValidator::ensure_actor_origin(origin, member_id)
-            .map_err(|_| Error::<T>::ActorOriginAuthError)
-    }
-
-    /// Authorize content actor
-    pub(crate) fn authorize_content_actor(
-        origin: T::Origin,
-        actor: &ContentActor<CuratorGroupId<T>, CuratorId<T>, MemberId<T>>,
-    ) -> Result<(), Error<T>> {
-        // TODO: Move to common pallet
-        content::ensure_actor_authorized_to_create_channel::<T>(origin.clone(), actor)
-            .map_err(|_| Error::<T>::ActorNotAuthorizedToIssueNft)
-    }
-
-    /// Ensure auction participant has sufficient balance to make bid
-    pub(crate) fn ensure_has_sufficient_balance(
-        participant: &T::AccountId,
-        bid: BalanceOf<T>,
-    ) -> DispatchResult {
-        ensure!(
-            T::NftCurrencyProvider::can_reserve(participant, bid),
-            Error::<T>::InsufficientBalance
-        );
-        Ok(())
-    }
-
-    /// Safety/bound checks for auction parameters
-    pub(crate) fn validate_auction_params(
-        auction_params: &AuctionParams<
-            T::VNFTId,
-            VideoId<T>,
-            <T as timestamp::Trait>::Moment,
-            BalanceOf<T>,
-        >,
-    ) -> DispatchResult {
-        match auction_params.auction_mode {
-            AuctionMode::WithIssuance(video_id, Some(royalty), _) => {
-                Self::ensure_vnft_does_not_exist(video_id)?;
-                Self::ensure_royalty_bounds_satisfied(royalty)?;
-            }
-            AuctionMode::WithoutIsuance(vnft_id) => {
-                Self::ensure_pending_transfer_does_not_exist(vnft_id)?;
-            }
-            _ => (),
-        }
-
-        Self::ensure_round_time_bounds_satisfied(auction_params.round_time)?;
-        Self::ensure_starting_price_bounds_satisfied(auction_params.starting_price)?;
-        Self::ensure_bid_step_bounds_satisfied(auction_params.minimal_bid_step)?;
-
-        Ok(())
-    }
-
-    /// Ensure royalty bounds satisfied
-    pub(crate) fn ensure_royalty_bounds_satisfied(royalty: Perbill) -> DispatchResult {
-        ensure!(
-            royalty <= Self::max_creator_royalty(),
-            Error::<T>::RoyaltyUpperBoundExceeded
-        );
-        ensure!(
-            royalty >= Self::min_creator_royalty(),
-            Error::<T>::RoyaltyLowerBoundExceeded
-        );
-        Ok(())
-    }
-
-    /// Ensure bid step bounds satisfied
-    pub(crate) fn ensure_bid_step_bounds_satisfied(bid_step: BalanceOf<T>) -> DispatchResult {
-        ensure!(
-            bid_step <= Self::max_bid_step(),
-            Error::<T>::AuctionBidStepUpperBoundExceeded
-        );
-        ensure!(
-            bid_step >= Self::min_bid_step(),
-            Error::<T>::AuctionBidStepLowerBoundExceeded
-        );
-        Ok(())
-    }
-
-    /// Ensure royalty bounds satisfied
-    pub(crate) fn ensure_round_time_bounds_satisfied(round_time: T::Moment) -> DispatchResult {
-        ensure!(
-            round_time <= Self::max_round_time(),
-            Error::<T>::RoundTimeUpperBoundExceeded
-        );
-        ensure!(
-            round_time >= Self::min_round_time(),
-            Error::<T>::RoundTimeLowerBoundExceeded
-        );
-        Ok(())
-    }
-
-    /// Ensure royalty bounds satisfied
-    pub(crate) fn ensure_starting_price_bounds_satisfied(
-        starting_price: BalanceOf<T>,
-    ) -> DispatchResult {
-        ensure!(
-            starting_price >= Self::max_starting_price(),
-            Error::<T>::StartingPriceUpperBoundExceeded
-        );
-        ensure!(
-            starting_price <= Self::min_starting_price(),
-            Error::<T>::StartingPriceLowerBoundExceeded
-        );
-        Ok(())
-    }
-
-    /// Check whether auction for given video id exists
-    pub(crate) fn is_auction_exist(auction_id: AuctionId<VideoId<T>, T::VNFTId>) -> bool {
-        <AuctionById<T>>::contains_key(auction_id)
-    }
-
-    /// Ensure auction for given id exists
-    pub(crate) fn ensure_auction_exists(
-        auction_id: AuctionId<VideoId<T>, T::VNFTId>,
-    ) -> Result<Auction<T>, Error<T>> {
-        ensure!(
-            Self::is_auction_exist(auction_id),
-            Error::<T>::AuctionDoesNotExist
-        );
-        Ok(Self::auction_by_id(auction_id))
-    }
-
-    /// Whether pending tansfer exist
-    pub(crate) fn is_pending_transfer_exists(vnft_id: T::VNFTId) -> bool {
-        <PendingTransfers<T>>::iter_prefix_values(vnft_id).count() == 1
-    }
-
-    /// Ensure vNFT has pending transfer
-    pub(crate) fn ensure_pending_transfer_exists(vnft_id: T::VNFTId) -> DispatchResult {
-        ensure!(
-            Self::is_pending_transfer_exists(vnft_id),
-            Error::<T>::PendingTransferDoesNotExist
-        );
-        Ok(())
-    }
-
-    /// Ensure vNFT has no pending transfers
-    pub(crate) fn ensure_pending_transfer_does_not_exist(vnft_id: T::VNFTId) -> DispatchResult {
-        ensure!(
-            !Self::is_pending_transfer_exists(vnft_id),
-            Error::<T>::PendingAlreadyExists
-        );
-        Ok(())
-    }
-
-    /// Ensure new pending transfer for given participant available to proceed
-    pub(crate) fn ensure_new_pending_transfer_available(
-        vnft_id: T::VNFTId,
-        participant: MemberId<T>,
-    ) -> DispatchResult {
-        ensure!(
-            <PendingTransfers<T>>::contains_key(vnft_id, participant),
-            Error::<T>::NoIncomingTransfers
-        );
-        Ok(())
-    }
-
-    /// Ensure auction for given id does not exist
-    pub(crate) fn ensure_auction_does_not_exist(
-        auction_id: AuctionId<VideoId<T>, T::VNFTId>,
-    ) -> Result<Auction<T>, Error<T>> {
-        ensure!(
-            Self::is_auction_exist(auction_id),
-            Error::<T>::AuctionDoesNotExist
-        );
-        Ok(Self::auction_by_id(auction_id))
-    }
-
-    /// Ensure given vnft exists
-    pub(crate) fn ensure_vnft_exists(vnft_id: T::VNFTId) -> Result<VNFT<T::AccountId>, Error<T>> {
-        ensure!(
-            <VNFTById<T>>::contains_key(vnft_id),
-            Error::<T>::VNFTDoesNotExist
-        );
-        Ok(Self::vnft_by_vnft_id(vnft_id))
-    }
-
-    /// Ensure given video id vnft relation does not exist
-    pub(crate) fn ensure_vnft_does_not_exist(video_id: T::VideoId) -> DispatchResult {
-        ensure!(
-            !<VNFTIdByVideo<T>>::contains_key(video_id),
-            Error::<T>::VNFTAlreadyExists
-        );
-        Ok(())
-    }
-
-    /// Try complete auction when round time expired
-    pub(crate) fn try_complete_auction(auction: &Auction<T>) -> bool {
-        let now = timestamp::Module::<T>::now();
-        if (now - auction.last_bid_time) >= auction.round_time {
-            Self::complete_auction(auction);
-            true
-        } else {
-            false
-        }
-    }
-
-    /// Complete auction
-    pub(crate) fn complete_auction(auction: &Auction<T>) {
-        let auction_id = auction.auction_mode.get_auction_id();
-
-        // Remove auction entry
-        <AuctionById<T>>::remove(auction_id);
-
-        match auction.auction_mode.clone() {
-            AuctionMode::WithIssuance(video_id, royalty, _) => {
-                let last_bid = auction.last_bid;
-
-                // Slash last bidder bid and deposit it into auctioneer account
-                T::NftCurrencyProvider::slash_reserved(&auction.last_bidder, last_bid);
-                T::NftCurrencyProvider::deposit_creating(&auction.auctioneer_account_id, last_bid);
-
-                let creator_royalty = if let Some(royalty) = royalty {
-                    Some((auction.auctioneer_account_id.clone(), royalty))
-                } else {
-                    None
-                };
-
-                <Module<T>>::issue_vnft(auction.last_bidder.clone(), video_id, creator_royalty)
-            }
-            AuctionMode::WithoutIsuance(vnft_id) => {
-                <Module<T>>::complete_vnft_auction_transfer(auction, vnft_id)
-            }
-        }
-        Self::deposit_event(RawEvent::AuctionCompleted(auction.to_owned()));
-    }
-
-    /// Issue vnft and update mapping relations
-    pub(crate) fn issue_vnft(
-        who: T::AccountId,
-        video_id: T::VideoId,
-        creator_royalty: Option<(T::AccountId, Royalty)>,
-    ) {
-        // Issue vnft
-        let vnft_id = Self::next_video_nft_id();
-
-        <VNFTIdByVideo<T>>::insert(video_id, vnft_id);
-
-        <VNFTById<T>>::insert(vnft_id, VNFT::new(who, creator_royalty.clone()));
-
-        NextVNFTId::<T>::put(vnft_id + T::VNFTId::one());
-
-        Self::deposit_event(RawEvent::NftIssued(video_id, vnft_id, creator_royalty));
-    }
-
-    /// Complete vnft transfer
-    pub(crate) fn complete_vnft_auction_transfer(auction: &Auction<T>, vnft_id: T::VNFTId) {
-        let vnft = Self::vnft_by_vnft_id(vnft_id);
-        let last_bid = auction.last_bid;
-
-        if let Some((creator_account_id, creator_royalty)) = vnft.creator_royalty {
-            let royalty = creator_royalty * last_bid;
-
-            // Slash last bidder bid
-            T::NftCurrencyProvider::slash_reserved(&auction.last_bidder, last_bid);
-
-            // Deposit bid, exluding royalty amount into auctioneer account
-            T::NftCurrencyProvider::deposit_creating(
-                &auction.auctioneer_account_id,
-                last_bid - royalty,
-            );
-
-            // Deposit royalty into creator account
-            T::NftCurrencyProvider::deposit_creating(&creator_account_id, royalty);
-        } else {
-            // Slash last bidder bid and deposit it into auctioneer account
-            T::NftCurrencyProvider::slash_reserved(&auction.last_bidder, last_bid);
-
-            T::NftCurrencyProvider::deposit_creating(&auction.auctioneer_account_id, last_bid);
-        }
-
-        <VNFTById<T>>::mutate(vnft_id, |vnft| vnft.owner = auction.last_bidder.clone());
-    }
-}

+ 0 - 429
runtime-modules/vnft-auction/src/lib.rs

@@ -1,429 +0,0 @@
-// Ensure we're `no_std` when compiling for Wasm.
-#![cfg_attr(not(feature = "std"), no_std)]
-#![recursion_limit = "256"]
-
-mod errors;
-mod functions;
-mod types;
-pub use common::{origin::ActorOriginValidator, MembershipTypes};
-pub use content::{ContentActor, ContentActorAuthenticator};
-use errors::*;
-use frame_support::{
-    decl_event, decl_module, decl_storage,
-    dispatch::{DispatchError, DispatchResult},
-    ensure, Parameter,
-};
-pub use frame_system::ensure_signed;
-pub use functions::*;
-#[cfg(feature = "std")]
-pub use serde::{Deserialize, Serialize};
-use sp_arithmetic::traits::{BaseArithmetic, One, Zero};
-use sp_runtime::traits::{MaybeSerializeDeserialize, Member};
-use types::*;
-
-use codec::Codec;
-pub use codec::{Decode, Encode};
-use frame_support::traits::{Currency, ReservableCurrency};
-pub use sp_runtime::Perbill;
-
-pub trait NumericIdentifier:
-    Parameter
-    + Member
-    + BaseArithmetic
-    + Codec
-    + Default
-    + Copy
-    + Clone
-    + MaybeSerializeDeserialize
-    + Eq
-    + PartialEq
-    + Ord
-    + Zero
-{
-}
-
-impl NumericIdentifier for u64 {}
-
-type VideoId<T> = <T as content::Trait>::VideoId;
-
-pub trait Trait:
-    timestamp::Trait + content::Trait + content::ContentActorAuthenticator + MembershipTypes
-{
-    /// The overarching event type.
-    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
-
-    // NFT provider pallet
-    type VNFTId: NumericIdentifier;
-
-    // Payment provider
-    type NftCurrencyProvider: Currency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
-
-    // Member origin validator
-    type MemberOriginValidator: ActorOriginValidator<Self::Origin, MemberId<Self>, Self::AccountId>;
-}
-
-decl_storage! {
-    trait Store for Module<T: Trait> as Content {
-
-        /// Map, representing  VideoId -> VNFTId relation
-        pub VNFTIdByVideo get(fn vnft_id_by_video_id): map hasher(blake2_128_concat) VideoId<T> => T::VNFTId;
-
-        /// Map, representing  VNFTId -> VNFT relation
-        pub VNFTById get(fn vnft_by_vnft_id): map hasher(blake2_128_concat) T::VNFTId => VNFT<T::AccountId>;
-
-        /// Map, representing AuctionId -> Auction relation
-        pub AuctionById get (fn auction_by_id): map hasher(blake2_128_concat) AuctionId<VideoId<T>, T::VNFTId> => Auction<T>;
-
-        /// Representation for pending vNFT transfers, vnft_id => receiver
-        pub PendingTransfers get (fn pending_transfers): double_map
-            hasher(blake2_128_concat) T::VNFTId,
-            hasher(blake2_128_concat) MemberId<T> => ();
-
-        /// Next vNFT id
-        pub NextVNFTId get(fn next_video_nft_id) config(): T::VNFTId;
-
-        /// Min auction round time
-        pub MinRoundTime get(fn min_round_time) config(): T::Moment;
-
-        /// Max auction round time
-        pub MaxRoundTime get(fn max_round_time) config(): T::Moment;
-
-        /// Min auction staring price
-        pub MinStartingPrice get(fn min_starting_price) config(): BalanceOf<T>;
-
-        /// Max auction staring price
-        pub MaxStartingPrice get(fn max_starting_price) config(): BalanceOf<T>;
-
-        /// Min creator royalty
-        pub MinCreatorRoyalty get(fn min_creator_royalty) config(): Perbill;
-
-        /// Max creator royalty
-        pub MaxCreatorRoyalty get(fn max_creator_royalty) config(): Perbill;
-
-        /// Min auction bid step
-        pub MinBidStep get(fn min_bid_step) config(): BalanceOf<T>;
-
-        /// Max auction bid step
-        pub MaxBidStep get(fn max_bid_step) config(): BalanceOf<T>;
-    }
-}
-
-decl_module! {
-    pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        /// Predefined errors
-        type Error = Error<T>;
-
-        /// Initializing events
-        fn deposit_event() = default;
-
-        /// Start video auction
-        #[weight = 10_000_000] // TODO: adjust weight
-        pub fn start_video_auction(
-            origin,
-            auctioneer: ContentActor<CuratorGroupId<T>, CuratorId<T>, MemberId<T>>,
-            auction_params: AuctionParams<T::VNFTId, VideoId<T>, <T as timestamp::Trait>::Moment, BalanceOf<T>>,
-        ) {
-
-            let auctioneer_account_id = Self::authorize_auctioneer(origin, &auctioneer, &auction_params)?;
-
-            // Validate round_time & starting_price
-            Self::validate_auction_params(&auction_params)?;
-
-            let auction_id = auction_params.auction_mode.get_auction_id();
-
-            // Try complete auction
-            if Self::is_auction_exist(auction_id) {
-
-                let auction = Self::auction_by_id(auction_id);
-
-                // Try finalize already completed auction (issues new nft if required)
-                ensure!(Self::try_complete_auction(&auction), Error::<T>::AuctionAlreadyStarted);
-                return Ok(())
-            }
-
-            //
-            // == MUTATION SAFE ==
-            //
-
-            // Create new auction
-            let auction = AuctionRecord::new(auctioneer, auctioneer_account_id, auction_params.clone());
-
-            <AuctionById<T>>::insert(auction_id, auction);
-
-            // Trigger event
-            Self::deposit_event(RawEvent::AuctionStarted(auctioneer, auction_params));
-        }
-
-        /// Cancel video auction
-        #[weight = 10_000_000] // TODO: adjust weight
-        pub fn cancel_auction(
-            origin,
-            auctioneer: ContentActor<CuratorGroupId<T>, CuratorId<T>, MemberId<T>>,
-            auction_id: AuctionId<VideoId<T>, T::VNFTId>,
-        ) {
-
-            Self::authorize_content_actor(origin, &auctioneer)?;
-
-            // Ensure auction for given video id exists
-            let auction = Self::ensure_auction_exists(auction_id)?;
-
-            // Ensure given auction has no participants
-            auction.ensure_is_not_active::<T>()?;
-
-            // Ensure given conntent actor is auctioneer
-            auction.ensure_is_auctioneer::<T>(&auctioneer)?;
-
-            //
-            // == MUTATION SAFE ==
-            //
-
-            // Try complete previous auction
-            if Self::try_complete_auction(&auction) {
-                return Ok(())
-            }
-
-            <AuctionById<T>>::remove(auction_id);
-
-            // Trigger event
-            Self::deposit_event(RawEvent::AuctionCancelled(auctioneer, auction_id));
-        }
-
-        /// Make auction bid
-        #[weight = 10_000_000] // TODO: adjust weight
-        pub fn make_bid(
-            origin,
-            participant: MemberId<T>,
-            auction_id: AuctionId<VideoId<T>, T::VNFTId>,
-            bid: BalanceOf<T>,
-        ) {
-
-            let auction_participant = Self::authorize_participant(origin, participant)?;
-
-            // Ensure auction exists
-            let auction = Self::ensure_auction_exists(auction_id)?;
-
-
-            // Ensure bidder have sufficient balance amount to reserve for bid
-            Self::ensure_has_sufficient_balance(&auction_participant, bid)?;
-
-            // Ensure new bid is greater then last bid + minimal bid step
-            auction.ensure_is_valid_bid::<T>(bid)?;
-
-            //
-            // == MUTATION SAFE ==
-            //
-
-            // Try complete previous auction
-            if Self::try_complete_auction(&auction) {
-                return Ok(())
-            }
-
-            let last_bid_time = timestamp::Module::<T>::now();
-
-            // Unreserve previous bidder balance
-            T::NftCurrencyProvider::unreserve(&auction.last_bidder, auction.last_bid);
-
-            // Make auction bid & update auction data
-            let auction = match *&auction.buy_now_price {
-                // Instantly complete auction if bid is greater or equal then buy now price
-                Some(buy_now_price) if bid >= buy_now_price => {
-                    // Reseve balance for current bid
-                    // Can not fail, needed check made
-                    T::NftCurrencyProvider::reserve(&auction_participant, buy_now_price)?;
-
-                    let auction = auction.make_bid::<T>(auction_participant, buy_now_price, last_bid_time);
-                    Self::complete_auction(&auction);
-                    return Ok(())
-                }
-                _ => {
-                    // Reseve balance for current bid
-                    // Can not fail, needed check made
-                    T::NftCurrencyProvider::reserve(&auction_participant, bid)?;
-                    auction.make_bid::<T>(auction_participant, bid, last_bid_time)
-                }
-            };
-
-            <AuctionById<T>>::insert(auction_id, auction);
-
-            // Trigger event
-            Self::deposit_event(RawEvent::AuctionBidMade(participant, auction_id, bid));
-        }
-
-        /// Issue vNFT
-        #[weight = 10_000_000] // TODO: adjust weight
-        pub fn issue(
-            origin,
-            auctioneer: ContentActor<CuratorGroupId<T>, CuratorId<T>, MemberId<T>>,
-            video_id: T::VideoId,
-            royalty: Option<Royalty>,
-        ) {
-
-            // Authorize content actor
-            Self::authorize_content_actor(origin.clone(), &auctioneer)?;
-
-            let content_actor_account_id = ensure_signed(origin)?;
-
-            Self::ensure_vnft_does_not_exist(video_id)?;
-
-            // Enure royalty bounds satisfied, if provided
-            if let Some(royalty) = royalty {
-                Self::ensure_royalty_bounds_satisfied(royalty)?;
-            }
-
-            //
-            // == MUTATION SAFE ==
-            //
-
-            let auction_id = AuctionId::VideoId(video_id);
-
-            // Try complete auction
-            if Self::is_auction_exist(auction_id) {
-
-                let auction = Self::auction_by_id(auction_id);
-
-                // Try finalize already completed auction (issues new nft if required)
-                Self::try_complete_auction(&auction);
-                return Ok(())
-            }
-
-            // Issue vNFT
-
-            let royalty = royalty.map(|royalty| (content_actor_account_id.clone(), royalty));
-
-            Self::issue_vnft(content_actor_account_id, video_id, royalty);
-        }
-
-        /// Start vNFT transfer
-        #[weight = 10_000_000] // TODO: adjust weight
-        pub fn start_transfer(
-            origin,
-            vnft_id: T::VNFTId,
-            from: MemberId<T>,
-            to: MemberId<T>,
-        ) {
-
-            // Authorize participant under given member id
-            let from_account_id = Self::authorize_participant(origin, from)?;
-
-            // Ensure given vnft exists
-            let vnft = Self::ensure_vnft_exists(vnft_id)?;
-
-            // Ensure from_account_id is vnft owner
-            vnft.ensure_ownership::<T>(&from_account_id)?;
-
-            // Ensure there is no auction for given vnft
-            Self::ensure_auction_does_not_exist(AuctionId::VNFTId(vnft_id))?;
-
-            // Ensure pending transfer isn`t started
-            Self::ensure_pending_transfer_does_not_exist(vnft_id)?;
-
-            //
-            // == MUTATION SAFE ==
-            //
-
-            // Add vNFT transfer data to pending transfers storage
-            <PendingTransfers<T>>::insert(vnft_id, to, ());
-
-            // Trigger event
-            Self::deposit_event(RawEvent::TransferStarted(vnft_id, from, to));
-        }
-
-        /// Cancel vNFT transfer
-        #[weight = 10_000_000] // TODO: adjust weight
-        pub fn cancel_transfer(
-            origin,
-            vnft_id: T::VNFTId,
-            participant: MemberId<T>,
-        ) {
-
-            let participant_account_id = Self::authorize_participant(origin, participant)?;
-
-            Self::ensure_pending_transfer_exists(vnft_id)?;
-
-            let vnft = Self::ensure_vnft_exists(vnft_id)?;
-            vnft.ensure_ownership::<T>(&participant_account_id)?;
-
-            //
-            // == MUTATION SAFE ==
-            //
-
-            // Remove vNFT transfer data from pending transfers storage
-            // Safe to call, because we always have one transfers per vnft_id
-            <PendingTransfers<T>>::remove_prefix(vnft_id);
-
-            // Trigger event
-            Self::deposit_event(RawEvent::TransferCancelled(vnft_id, participant));
-        }
-
-        /// Accept incoming vNFT transfer
-        #[weight = 10_000_000] // TODO: adjust weight
-        pub fn accept_incoming_vnft(
-            origin,
-            vnft_id: T::VNFTId,
-            participant: MemberId<T>,
-        ) {
-
-            let participant_account_id = Self::authorize_participant(origin, participant)?;
-
-            Self::ensure_pending_transfer_exists(vnft_id)?;
-
-            // Ensure new pending transfer available to proceed
-            Self::ensure_new_pending_transfer_available(vnft_id, participant)?;
-
-            let mut vnft = Self::ensure_vnft_exists(vnft_id)?;
-
-            //
-            // == MUTATION SAFE ==
-            //
-
-            // Remove vNFT transfer data from pending transfers storage
-            // Safe to call, because we always have one transfers per vnft_id
-            <PendingTransfers<T>>::remove_prefix(vnft_id);
-
-
-            vnft.owner = participant_account_id;
-            <VNFTById<T>>::insert(vnft_id, vnft);
-
-            // Trigger event
-            Self::deposit_event(RawEvent::TransferAccepted(vnft_id, participant));
-        }
-    }
-}
-
-decl_event!(
-    pub enum Event<T>
-    where
-        VideoId = VideoId<T>,
-        AuctionId = AuctionId<<T as content::Trait>::VideoId, <T as Trait>::VNFTId>,
-        VNFTId = <T as Trait>::VNFTId,
-        Member = MemberId<T>,
-        Balance = BalanceOf<T>,
-        ContentActor = ContentActor<CuratorGroupId<T>, CuratorId<T>, MemberId<T>>,
-        AuctionParams = AuctionParams<
-            <T as Trait>::VNFTId,
-            VideoId<T>,
-            <T as timestamp::Trait>::Moment,
-            BalanceOf<T>,
-        >,
-        Auction = AuctionRecord<
-            <T as frame_system::Trait>::AccountId,
-            VideoId<T>,
-            <T as Trait>::VNFTId,
-            <T as timestamp::Trait>::Moment,
-            CuratorGroupId<T>,
-            CuratorId<T>,
-            MemberId<T>,
-            BalanceOf<T>,
-        >,
-        CreatorRoyalty = Option<(<T as frame_system::Trait>::AccountId, Royalty)>,
-    {
-        AuctionStarted(ContentActor, AuctionParams),
-        NftIssued(VideoId, VNFTId, CreatorRoyalty),
-        AuctionBidMade(Member, AuctionId, Balance),
-        AuctionCancelled(ContentActor, AuctionId),
-        AuctionCompleted(Auction),
-        TransferStarted(VNFTId, Member, Member),
-        TransferCancelled(VNFTId, Member),
-        TransferAccepted(VNFTId, Member),
-    }
-);

+ 0 - 220
runtime-modules/vnft-auction/src/types.rs

@@ -1,220 +0,0 @@
-use super::*;
-
-/// Metadata for vNFT issuance
-type Metadata = Vec<u8>;
-
-pub type BalanceOf<T> =
-    <<T as Trait>::NftCurrencyProvider as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
-
-pub type CuratorGroupId<T> = <T as ContentActorAuthenticator>::CuratorGroupId;
-pub type CuratorId<T> = <T as ContentActorAuthenticator>::CuratorId;
-pub type MemberId<T> = <T as MembershipTypes>::MemberId;
-
-/// Owner royalty
-pub type Royalty = Perbill;
-
-// Either new auction, which requires vNFT issance or auction for already existing nft.
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)]
-pub enum AuctionMode<VideoId: Default, VNFTId: Default> {
-    // Auction, where nft issued at the end
-    WithIssuance(VideoId, Option<Royalty>, Metadata),
-    // Auction for already existing nft
-    WithoutIsuance(VNFTId),
-}
-
-impl<VideoId: Default, VNFTId: Default> Default for AuctionMode<VideoId, VNFTId> {
-    fn default() -> Self {
-        Self::WithoutIsuance(VNFTId::default())
-    }
-}
-
-impl<VideoId: Default + Copy, VNFTId: Default + Copy> AuctionMode<VideoId, VNFTId> {
-    /// Get auction id from auction mode
-    pub fn get_auction_id(&self) -> AuctionId<VideoId, VNFTId> {
-        match &self {
-            AuctionMode::WithIssuance(video_id, ..) => AuctionId::VideoId(*video_id),
-            AuctionMode::WithoutIsuance(vnft_id) => AuctionId::VNFTId(*vnft_id),
-        }
-    }
-}
-
-/// AuctionId, represented either by video_id or vnft_id
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, Debug)]
-pub enum AuctionId<VideoId: Default + Copy, VNFTId: Default + Copy> {
-    VideoId(VideoId),
-    VNFTId(VNFTId),
-}
-
-impl<VideoId: Default + Copy, VNFTId: Default + Copy> Default for AuctionId<VideoId, VNFTId> {
-    fn default() -> Self {
-        Self::VideoId(VideoId::default())
-    }
-}
-
-/// Information on the auction being created.
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct AuctionRecord<
-    AccountId,
-    VideoId: Default,
-    VNFTId: Default,
-    Moment: BaseArithmetic + Copy,
-    CuratorGroupId: Default + Copy,
-    CuratorId: Default + Copy,
-    MemberId: Default + Copy,
-    Balance,
-> {
-    pub auctioneer: ContentActor<CuratorGroupId, CuratorId, MemberId>,
-    pub auctioneer_account_id: AccountId,
-    pub auction_mode: AuctionMode<VideoId, VNFTId>,
-    pub starting_price: Balance,
-    pub buy_now_price: Option<Balance>,
-    pub round_time: Moment,
-    pub minimal_bid_step: Balance,
-    pub last_bid_time: Moment,
-    pub last_bid: Balance,
-    pub last_bidder: AccountId,
-}
-
-impl<
-        AccountId: Default + PartialEq,
-        VideoId: Default,
-        VNFTId: Default,
-        Moment: BaseArithmetic + Copy + Default,
-        CuratorGroupId: Default + Copy + PartialEq,
-        CuratorId: Default + Copy + PartialEq,
-        MemberId: Default + Copy + PartialEq,
-        Balance: Default + BaseArithmetic,
-    >
-    AuctionRecord<AccountId, VideoId, VNFTId, Moment, CuratorGroupId, CuratorId, MemberId, Balance>
-{
-    /// Create a new auction record with provided parameters
-    pub fn new(
-        auctioneer: ContentActor<CuratorGroupId, CuratorId, MemberId>,
-        auctioneer_account_id: AccountId,
-        auction_params: AuctionParams<VNFTId, VideoId, Moment, Balance>,
-    ) -> Self {
-        let AuctionParams {
-            auction_mode,
-            round_time,
-            starting_price,
-            buy_now_price,
-            minimal_bid_step,
-            ..
-        } = auction_params;
-        Self {
-            auctioneer,
-            auctioneer_account_id,
-            auction_mode,
-            starting_price,
-            buy_now_price,
-            round_time,
-            minimal_bid_step,
-            last_bid_time: Moment::default(),
-            last_bid: Balance::default(),
-            last_bidder: AccountId::default(),
-        }
-    }
-
-    /// Ensure new bid is greater then last bid + minimal bid step
-    pub fn ensure_is_valid_bid<T: Trait>(&self, new_bid: Balance) -> DispatchResult {
-        // Always allow to buy now
-        match &self.buy_now_price {
-            Some(buy_now_price) if new_bid >= *buy_now_price => (),
-            // Ensure new bid is greater then last bid + minimal bid step
-            _ => ensure!(
-                self.last_bid
-                    .checked_add(&self.minimal_bid_step)
-                    .ok_or(Error::<T>::OverflowOrUnderflowHappened)?
-                    < new_bid,
-                Error::<T>::InvalidBid
-            ),
-        }
-
-        Ok(())
-    }
-
-    /// Make auction bid
-    pub fn make_bid<T: Trait>(
-        mut self,
-        who: AccountId,
-        bid: Balance,
-        last_bid_time: Moment,
-    ) -> Self {
-        self.last_bidder = who;
-        self.last_bid = bid;
-        self.last_bid_time = last_bid_time;
-        self
-    }
-
-    // We assume that default AccountId can not make any bids
-    fn is_active(&self) -> bool {
-        self.last_bidder.eq(&AccountId::default())
-    }
-
-    /// Ensure auction is not active
-    pub fn ensure_is_not_active<T: Trait>(&self) -> DispatchResult {
-        ensure!(self.is_active(), Error::<T>::ActionIsAlreadyActive);
-        Ok(())
-    }
-
-    /// Ensure provided account id is auctioneer
-    pub fn ensure_is_auctioneer<T: Trait>(
-        &self,
-        auctioneer: &ContentActor<CuratorGroupId, CuratorId, MemberId>,
-    ) -> DispatchResult {
-        ensure!(
-            self.auctioneer.eq(auctioneer),
-            Error::<T>::ActorIsNotAnAuctioneer
-        );
-        Ok(())
-    }
-}
-
-/// Auction alias type for simplification.
-pub type Auction<T> = AuctionRecord<
-    <T as frame_system::Trait>::AccountId,
-    VideoId<T>,
-    <T as Trait>::VNFTId,
-    <T as timestamp::Trait>::Moment,
-    CuratorGroupId<T>,
-    CuratorId<T>,
-    MemberId<T>,
-    BalanceOf<T>,
->;
-
-/// Parameters, needed for auction start
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct AuctionParams<VNFTId: Default, VideoId: Default, Moment, Balance> {
-    pub auction_mode: AuctionMode<VideoId, VNFTId>,
-    pub round_time: Moment,
-    pub starting_price: Balance,
-    pub minimal_bid_step: Balance,
-    pub buy_now_price: Option<Balance>,
-}
-
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct VNFT<AccountId: Default> {
-    pub owner: AccountId,
-    pub creator_royalty: Option<(AccountId, Royalty)>,
-}
-
-impl<AccountId: Default + PartialEq> VNFT<AccountId> {
-    /// Create new vNFT
-    pub fn new(owner: AccountId, creator_royalty: Option<(AccountId, Royalty)>) -> Self {
-        Self {
-            owner,
-            creator_royalty,
-        }
-    }
-
-    /// Ensure given account id is vnft owner
-    pub fn ensure_ownership<T: Trait>(&self, owner: &AccountId) -> DispatchResult {
-        ensure!(self.owner.eq(owner), Error::<T>::DoesNotOwnVNFT);
-        Ok(())
-    }
-}

+ 0 - 2
runtime/Cargo.toml

@@ -75,7 +75,6 @@ proposals-engine = { package = 'pallet-proposals-engine', default-features = fal
 proposals-discussion = { package = 'pallet-proposals-discussion', default-features = false, path = '../runtime-modules/proposals/discussion'}
 proposals-codex = { package = 'pallet-proposals-codex', default-features = false, path = '../runtime-modules/proposals/codex'}
 content = { package = 'pallet-content', default-features = false, path = '../runtime-modules/content' }
-vnft-auction = { package = 'pallet-vnft-auction', default-features = false, path = '../runtime-modules/vnft-auction' }
 
 [dev-dependencies]
 sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62'}
@@ -149,7 +148,6 @@ std = [
     'proposals-discussion/std',
     'proposals-codex/std',
     'content/std',
-    'vnft-auction/std',
 ]
 runtime-benchmarks = [
     "frame-system/runtime-benchmarks",