Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: NFT migration pallet #321

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
619 changes: 339 additions & 280 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "r
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }

# Substrate Primitive Dependencies (node - only)
sc-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
Expand Down
11 changes: 3 additions & 8 deletions modules/bridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use sp_core::H256;
use sp_runtime::traits::AccountIdConversion;
use sp_runtime::{traits::IdentityLookup, ModuleError, Perbill};

use core_primitives::{Attributes, CollectionType, NFTTrait, NftClassData, NftMetadata, TokenType};
use core_primitives::{Attributes, CollectionType, NFTTrait, NftAssetData, NftClassData, NftMetadata, TokenType};
use primitives::{
continuum::MapTrait, Amount, ClassId, EstateId, FungibleTokenId, GroupCollectionId, MapSpotId, TokenId,
UndeployedLandBlockId,
Expand Down Expand Up @@ -383,16 +383,11 @@ impl NFTTrait<AccountId, Balance> for MockNFTHandler {
CLASS_FUND_ID
}

fn get_nft_detail(_asset_id: (Self::ClassId, Self::TokenId)) -> Result<NftClassData<Balance>, DispatchError> {
let new_data = NftClassData {
fn get_nft_detail(_asset_id: (Self::ClassId, Self::TokenId)) -> Result<NftAssetData<Balance>, DispatchError> {
let new_data = NftAssetData {
deposit: 0,
attributes: test_attributes(1),
token_type: TokenType::Transferable,
collection_type: CollectionType::Collectable,
is_locked: false,
royalty_fee: Perbill::from_percent(0u32),
mint_limit: None,
total_minted_tokens: 0u32,
};
Ok(new_data)
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/auction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1362,8 +1362,8 @@ pub mod pallet {
social_currency_id: FungibleTokenId,
) -> DispatchResult {
// Get royalty fee
let nft_details = T::NFTHandler::get_nft_detail((asset_id.0, asset_id.1))?;
let royalty_fee: Self::Balance = nft_details.royalty_fee * *high_bid_price;
let class_details = T::NFTHandler::get_nft_class_detail(asset_id.0)?;
let royalty_fee: Self::Balance = class_details.royalty_fee * *high_bid_price;
let class_fund = T::NFTHandler::get_class_fund(&asset_id.0);

// Transfer loyalty fee from winner to class fund pot
Expand Down
9 changes: 2 additions & 7 deletions pallets/estate/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,16 +425,11 @@ impl NFTTrait<AccountId, Balance> for MockNFTHandler {
CLASS_FUND_ID
}

fn get_nft_detail(_asset_id: (Self::ClassId, Self::TokenId)) -> Result<NftClassData<Balance>, DispatchError> {
let new_data = NftClassData {
fn get_nft_detail(_asset_id: (Self::ClassId, Self::TokenId)) -> Result<NftAssetData<Balance>, DispatchError> {
let new_data = NftAssetData {
deposit: 0,
attributes: test_attributes(1),
token_type: TokenType::Transferable,
collection_type: CollectionType::Collectable,
is_locked: false,
royalty_fee: Perbill::from_percent(0u32),
mint_limit: None,
total_minted_tokens: 0u32,
};
Ok(new_data)
}
Expand Down
11 changes: 3 additions & 8 deletions pallets/governance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use sp_std::collections::btree_map::BTreeMap;

use metaverse_primitive::{
Attributes, CollectionType, MetaverseInfo as MetaversePrimitiveInfo, MetaverseLandTrait, MetaverseMetadata,
MetaverseTrait, NFTTrait, NftClassData, NftMetadata, TokenType,
MetaverseTrait, NFTTrait, NftAssetData, NftClassData, NftMetadata, TokenType,
};
use primitives::{Amount, ClassId, FungibleTokenId, GroupCollectionId, TokenId};
use sp_runtime::BuildStorage;
Expand Down Expand Up @@ -351,16 +351,11 @@ impl NFTTrait<AccountId, Balance> for MockNFTHandler {
CLASS_FUND_ID
}

fn get_nft_detail(_asset_id: (Self::ClassId, Self::TokenId)) -> Result<NftClassData<Balance>, DispatchError> {
let new_data = NftClassData {
fn get_nft_detail(_asset_id: (Self::ClassId, Self::TokenId)) -> Result<NftAssetData<Balance>, DispatchError> {
let new_data = NftAssetData {
deposit: 0,
attributes: test_attributes(1),
token_type: TokenType::Transferable,
collection_type: CollectionType::Collectable,
is_locked: false,
royalty_fee: Perbill::from_percent(0u32),
mint_limit: None,
total_minted_tokens: 0u32,
};
Ok(new_data)
}
Expand Down
9 changes: 2 additions & 7 deletions pallets/metaverse/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,11 @@ impl NFTTrait<AccountId, Balance> for MockNFTHandler {
CLASS_FUND_ID
}

fn get_nft_detail(_asset_id: (Self::ClassId, Self::TokenId)) -> Result<NftClassData<Balance>, DispatchError> {
let new_data = NftClassData {
fn get_nft_detail(_asset_id: (Self::ClassId, Self::TokenId)) -> Result<NftAssetData<Balance>, DispatchError> {
let new_data = NftAssetData {
deposit: 0,
attributes: test_attributes(1),
token_type: TokenType::Transferable,
collection_type: CollectionType::Collectable,
is_locked: false,
royalty_fee: Perbill::from_percent(0u32),
mint_limit: None,
total_minted_tokens: 0u32,
};
Ok(new_data)
}
Expand Down
57 changes: 57 additions & 0 deletions pallets/nft-migration/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[package]
authors = ["Metaverse Network <https://github.com/bit-country>"]
description = "Metaverse Network NFT migration pallet."
edition = "2021"
homepage = "https://metaverse.network"
license = "Unlicense"
name = "pallet-nft-migration"
repository = "https://github.com/bit-country"
version = "2.0.0-rc6"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { workspace = true, package = "parity-scale-codec" }
scale-info = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

frame-support = { workspace = true }
frame-system = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }

pallet-balances = { workspace = true }

core-primitives = { path = "../../traits/core-primitives", default-features = false }
primitives = { package = "bit-country-primitives", path = "../../primitives/metaverse", default-features = false }

[dev-dependencies]
sp-core = { workspace = true }
sp-io = { workspace = true }
smallvec = { workspace = true }
orml-tokens = { workspace = true, default-features = true }
orml-nft = { workspace = true, default-features = true }
orml-traits = { workspace = true, default-features = true }
pallet-nft = { path = "../nft" }
currencies = { path = "../currencies" }
pallet-proxy = { workspace = true, default-features = true }
auction-manager = { package = "auction-manager", path = "../../traits/auction-manager" }

[features]
runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"sp-runtime/std",
"sp-std/std",
"frame-support/std",
"frame-system/std",
"frame-benchmarking/std",
"pallet-balances/std",
]
22 changes: 22 additions & 0 deletions pallets/nft-migration/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#![cfg(feature = "runtime-benchmarks")]

use super::*;
use sp_std::prelude::*;
use sp_std::vec::*;

#[allow(unused)]
pub use crate::Pallet as NftMigrationModule;
use crate::{Call, Config};
use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_system::{Pallet as System, RawOrigin};
use sp_runtime::traits::{AccountIdConversion, Lookup, StaticLookup, UniqueSaturatedInto};

const SEED: u32 = 0;

benchmarks! {

start_migration {
}: _(RawOrigin::Root)

}
impl_benchmark_test_suite!(Pallet, crate::benchmarking::tests::new_test_ext(), crate::mock::Test);
Loading
Loading