Skip to content
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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pallets/deip_f_nft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pallet-assets = { git = "https://github.com/paritytech/substrate.git", branch =
pallet-uniques = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.13", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.13", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.13", default-features = false }

[features]
default = ["std"]
Expand All @@ -30,5 +29,4 @@ std = [
"pallet-uniques/std",
"scale-info/std",
"sp-core/std",
"sp-runtime/std",
]
2 changes: 1 addition & 1 deletion pallets/deip_f_nft/src/impl_asset_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use sp_core::H160;

use crate::{
CollectionRepo, Config, Error, FingerprintByFractionTokenId, FractionHolds, FractionRepo,
FractionalRepo, ItemRepo, NextCollectionId, Pallet, NextFTokenId
FractionalRepo, ItemRepo, NextCollectionId, NextFTokenId, Pallet,
};

impl<T: Config> FTImplT for Pallet<T> {
Expand Down
56 changes: 52 additions & 4 deletions pallets/deip_f_nft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,63 @@ pub mod pallet {
};
use frame_support::{
dispatch::DispatchResult,
migration::storage_key_iter,
pallet_prelude::{
Member, NMapKey, StorageDoubleMap, StorageMap, StorageNMap, StorageValue, ValueQuery,
Weight,
},
traits::IsType,
sp_runtime::traits::{AtLeast32BitUnsigned, Bounded, CheckedAdd, One, StaticLookup, Zero},
traits::{tokens::currency::Currency, Get, Hooks, IsType},
transactional, Blake2_128Concat, Parameter,
};
use frame_system::{ensure_signed, pallet_prelude::OriginFor};
use frame_system::{
ensure_signed,
pallet_prelude::{BlockNumberFor, OriginFor},
};
use sp_core::H160;
use sp_runtime::traits::{AtLeast32BitUnsigned, Bounded, StaticLookup};

#[doc(hidden)]
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_runtime_upgrade() -> Weight {
let reads = 0;
let writes = 0;

// NextFTokenId
let pallet = b"Assets";
let storage = b"Asset";
type DepositBalanceOf<T> = <<T as pallet_assets::Config>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::Balance;
let iterator = storage_key_iter::<
T::AssetId,
pallet_assets::AssetDetails<T::Balance, T::AccountId, DepositBalanceOf<T>>,
Blake2_128Concat,
>(pallet, storage);
let next_id = iterator
.map(|(id, _)| id)
.max()
.and_then(|id| id.checked_add(&One::one()))
.unwrap_or_else(Zero::zero);
NextFTokenId::<T>::put(next_id);

// CollectionRepo

// ItemRepo

// FingerprintByFractionTokenId

// FractionRepo

// FractionalRepo

// FractionHolds

// NextCollectionId

T::DbWeight::get().reads_writes(reads, writes)
}
}

#[pallet::config]
pub trait Config:
Expand All @@ -46,7 +94,7 @@ pub mod pallet {
type NFTFractionAmount: Member + Parameter + AtLeast32BitUnsigned + Copy + Default;

type InternalCollectionId: Member + Parameter + AtLeast32BitUnsigned + Copy + Default;
type InternalFTokenId: Member + Parameter + AtLeast32BitUnsigned + Copy + Default;
type InternalFTokenId: Member + Parameter + AtLeast32BitUnsigned + Copy + Default + One;

/// Pallet with low level control over fungible tokens.
type Fungibles: FTImplT<
Expand Down
3 changes: 1 addition & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ pub use frame_support::{
TransactionValidity, Weight,
},
parameter_types,
traits::fungibles::Inspect,
traits::{Everything, KeyOwnerProofSystem, StorageInfo},
traits::{fungibles::Inspect, Everything, KeyOwnerProofSystem, StorageInfo},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
IdentityFee,
Expand Down