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

NFT Lock Mechanism #76

Merged
merged 21 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
935ba04
Add the Uniques pallet temporarily for dev purposes
HashWarlock Mar 1, 2022
644475b
Create the dependency injection trait Locker and default check_should…
HashWarlock Mar 10, 2022
8a2cb9c
Implement Locker trait in RMRK core pallet and add lock logic to down…
HashWarlock Mar 11, 2022
cc03548
Merge branch 'main' into feat/nft-lock-logic
HashWarlock Mar 11, 2022
ba1f9dd
Fix merge errors and update cargo.toml file dependencies
HashWarlock Mar 11, 2022
6fc947a
Add check_should_lock function to do_equip and check for both collect…
HashWarlock Mar 11, 2022
f208429
Add Locker trait to mock for equip pallet
HashWarlock Mar 11, 2022
bf8279f
Add a test to directly call Uniques do_transfer function
HashWarlock Mar 11, 2022
28f7890
Temporarily use substrate branch with Uniques locker trait implementa…
HashWarlock Mar 13, 2022
dfe3ca1
Updates to change impl function of Locker to is_locked and correct so…
HashWarlock Mar 14, 2022
ad3f45f
Updated functions to use Locker trait from frame_support::traits
HashWarlock Mar 16, 2022
59e4e0c
Merge branch 'main' into feat/nft-lock-logic
HashWarlock Mar 17, 2022
d312c69
Update files using wrong Locker trait
HashWarlock Mar 17, 2022
62a5e94
Update Cargo file
HashWarlock Mar 17, 2022
3d0aac2
Merge branch 'main' into feat/nft-lock-logic
HashWarlock Mar 18, 2022
2238e68
Update to functions and run cargo fmt for formatting
HashWarlock Mar 18, 2022
01de754
Moved Locker trait to tokens trait folder
HashWarlock Mar 23, 2022
fc73928
Update Cargo with latest
HashWarlock Mar 23, 2022
668b178
Update base before updating cargo
HashWarlock May 5, 2022
053d87b
Merge to update branch
HashWarlock May 5, 2022
f5155fc
Update to polkadot-v0.9.22 along with code dependencies and tests fro…
HashWarlock May 18, 2022
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
333 changes: 176 additions & 157 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/pallets/rmrk-market.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Buy a listed NFT. Ensure that the NFT is available for purchase and has not rece
```rust
collection_id: CollectionId,
nft_id: NftId
amount: Option<BalanceOf<T>>
```

### **list**
Expand Down
56 changes: 28 additions & 28 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,44 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
clap = { version = "3.0", features = ["derive"] }

sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17", features = ["wasmtime"] }
sp-core = { version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-executor = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17", features = ["wasmtime"] }
sc-service = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17", features = ["wasmtime"] }
sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-keystore = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-finality-grandpa = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-finality-grandpa = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-runtime = { version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-cli = { version = "0.10.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait", features = ["wasmtime"] }
sp-core = { version = "5.0.0", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sc-executor = { version = "0.10.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait", features = ["wasmtime"] }
sc-service = { version = "0.10.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait", features = ["wasmtime"] }
sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sc-keystore = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-consensus = { version = "0.10.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sc-consensus = { version = "0.10.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sc-finality-grandpa = { version = "0.10.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-finality-grandpa = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-runtime = { version = "5.0.0", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }

# These dependencies are used for the node template"s RPCs
jsonrpc-core = "18.0.0"
sc-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sc-rpc = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-api = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }

# These dependencies are used for runtime benchmarking
frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }

# Local Dependencies
rmrk-substrate-runtime = { version = "4.0.0-dev", path = "../runtime" }

[build-dependencies]
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }

[features]
default = []
Expand Down
1 change: 0 additions & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ pub fn development_config() -> Result<ChainSpec, String> {
))
}


pub fn local_testnet_config() -> Result<ChainSpec, String> {
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;

Expand Down
2 changes: 1 addition & 1 deletion node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ pub enum Subcommand {
/// The custom benchmark subcommand benchmarking runtime pallets.
#[clap(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
}
}
23 changes: 12 additions & 11 deletions pallets/rmrk-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,28 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
serde = { version = "1.0.111", default-features = false, features = ["derive"] }
sp-runtime = { default-features = false, version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-std = { default-features = false, version = "4.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-runtime = { default-features = false, version = "5.0.0", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-std = { default-features = false, version = "4.0.0", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = [
"derive",
] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
frame-support = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17"}
frame-system = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
frame-benchmarking = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17", optional = true }
frame-support = { default-features = false, version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait"}
frame-system = { default-features = false, version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
frame-benchmarking = { default-features = false, version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait", optional = true }

pallet-uniques = { default-features = false, version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
pallet-balances = { default-features = false, version = "4.0.0-dev", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }

pallet-uniques = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
pallet-balances = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }

# Local Dependencies
rmrk-traits = { default-features = false, version = "0.0.1", path = "../../traits" }

[dev-dependencies]
sp-core = { default-features = false, version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-io = { default-features = false, version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-runtime = { default-features = false, version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-std = { default-features = false, version = "4.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.17" }
sp-core = { default-features = false, version = "5.0.0", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-io = { default-features = false, version = "5.0.0", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-runtime = { default-features = false, version = "5.0.0", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }
sp-std = { default-features = false, version = "4.0.0", git = "https://github.com/HashWarlock/substrate.git", branch = "hw-uniques-locker-trait" }

[features]
default = ["std"]
Expand Down
57 changes: 47 additions & 10 deletions pallets/rmrk-core/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use super::*;
use codec::{Codec, Decode, Encode};
use frame_support::traits::tokens::Locker;
use sp_runtime::{
traits::{Saturating, TrailingZeroInput},
ArithmeticError,
Expand All @@ -20,7 +21,8 @@ where
nft_id: NftId,
priorities: Vec<Vec<u8>>,
) -> DispatchResult {
// TODO : Check NFT lock status
// Check NFT lock status
ensure!(!Pallet::<T>::is_locked(collection_id, nft_id), pallet_uniques::Error::<T>::Locked);
let mut bounded_priorities = Vec::<BoundedVec<u8, T::StringLimit>>::new();
for priority in priorities {
let bounded_priority = Self::to_bounded_string(priority)?;
Expand All @@ -47,7 +49,11 @@ where
Collections::<T>::get(&collection_id).ok_or(Error::<T>::NoAvailableCollectionId)?;
ensure!(collection.issuer == sender, Error::<T>::NoPermission);
if let Some(nft_id) = &maybe_nft_id {
// TODO: Check NFT lock status
// Check NFT lock status
ensure!(
!Pallet::<T>::is_locked(collection_id, *nft_id),
pallet_uniques::Error::<T>::Locked
);
let (root_owner, _) = Pallet::<T>::lookup_root_owner(collection_id, *nft_id)?;
ensure!(root_owner == collection.issuer, Error::<T>::NoPermission);
}
Expand All @@ -56,7 +62,9 @@ where
}
}

impl<T: Config> Resource<BoundedVec<u8, T::StringLimit>, T::AccountId, BoundedResource<T::ResourceSymbolLimit>> for Pallet<T>
impl<T: Config>
Resource<BoundedVec<u8, T::StringLimit>, T::AccountId, BoundedResource<T::ResourceSymbolLimit>>
for Pallet<T>
where
T: pallet_uniques::Config<ClassId = CollectionId, InstanceId = NftId>,
{
Expand All @@ -74,6 +82,8 @@ where
parts: Option<Vec<PartId>>,
) -> DispatchResult {
let (root_owner, _) = Pallet::<T>::lookup_root_owner(collection_id, nft_id)?;
// Check NFT lock status
ensure!(!Pallet::<T>::is_locked(collection_id, nft_id), pallet_uniques::Error::<T>::Locked);

let empty =
base.is_none() &&
Expand All @@ -82,7 +92,10 @@ where
thumb.is_none();
ensure!(!empty, Error::<T>::EmptyResource);

let res = ResourceInfo::<BoundedVec<u8, T::ResourceSymbolLimit>, BoundedVec<u8, T::StringLimit>> {
let res = ResourceInfo::<
BoundedVec<u8, T::ResourceSymbolLimit>,
BoundedVec<u8, T::StringLimit>,
> {
id: resource_id.clone(),
base,
src,
Expand All @@ -106,8 +119,8 @@ where
) -> DispatchResult {
let (root_owner, _) = Pallet::<T>::lookup_root_owner(collection_id, nft_id)?;
ensure!(root_owner == sender, Error::<T>::NoPermission);
// TODO: Check NFT lock status

// Check NFT lock status
ensure!(!Pallet::<T>::is_locked(collection_id, nft_id), pallet_uniques::Error::<T>::Locked);
Resources::<T>::try_mutate_exists(
(collection_id, nft_id, resource_id.clone()),
|resource| -> DispatchResult {
Expand All @@ -123,7 +136,8 @@ where
}
}

impl<T: Config> Collection<StringLimitOf<T>, BoundedCollectionSymbolOf<T>, T::AccountId> for Pallet<T>
impl<T: Config> Collection<StringLimitOf<T>, BoundedCollectionSymbolOf<T>, T::AccountId>
for Pallet<T>
where
T: pallet_uniques::Config<ClassId = CollectionId, InstanceId = NftId>,
{
Expand Down Expand Up @@ -197,7 +211,7 @@ where
) -> sp_std::result::Result<(CollectionId, NftId), DispatchError> {
let nft_id = Self::get_next_nft_id(collection_id)?;
let collection = Self::collections(collection_id).ok_or(Error::<T>::CollectionUnknown)?;

// Prevent minting when next NFT id is greater than the collection max.
if let Some(max) = collection.max {
ensure!(nft_id < max, Error::<T>::CollectionFullOrLocked);
Expand All @@ -208,7 +222,13 @@ where

let owner_as_maybe_account = AccountIdOrCollectionNftTuple::AccountId(owner.clone());

let nft = NftInfo { owner: owner_as_maybe_account, recipient, royalty, metadata, equipped: false };
let nft = NftInfo {
owner: owner_as_maybe_account,
recipient,
royalty,
metadata,
equipped: false,
};

Nfts::<T>::insert(collection_id, nft_id, nft);
NftsByOwner::<T>::append(owner, (collection_id, nft_id));
Expand All @@ -232,7 +252,7 @@ where
ensure!(max_recursions > 0, Error::<T>::TooManyRecursions);
Nfts::<T>::remove(collection_id, nft_id);

for _ in Resources::<T>::drain_prefix((collection_id, nft_id)) {}
for _ in Resources::<T>::drain_prefix((collection_id, nft_id)) {}

let kids = Children::<T>::take((collection_id, nft_id));
for (child_collection_id, child_nft_id) in kids {
Expand Down Expand Up @@ -411,6 +431,15 @@ where
}
}

impl<T: Config> Locker<CollectionId, NftId> for Pallet<T>
where
T: pallet_uniques::Config<ClassId = CollectionId, InstanceId = NftId>,
{
fn is_locked(collection_id: CollectionId, nft_id: NftId) -> bool {
Lock::<T>::get((collection_id, nft_id))
}
}

impl<T: Config> Pallet<T>
where
T: pallet_uniques::Config<ClassId = CollectionId, InstanceId = NftId>,
Expand Down Expand Up @@ -617,4 +646,12 @@ where
Ok(current_id)
})
}

pub fn set_lock(nft: (CollectionId, NftId), lock_status: bool) -> bool {
Lock::<T>::mutate(nft, |lock| {
*lock = lock_status;
*lock
});
lock_status
}
}
30 changes: 20 additions & 10 deletions pallets/rmrk-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use sp_std::{convert::TryInto, vec::Vec};

use rmrk_traits::{
primitives::*, AccountIdOrCollectionNftTuple, Collection, CollectionInfo, Nft, NftInfo,
Priority, Property,
ResourceInfo,
Resource
Priority, Property, Resource, ResourceInfo,
};
use sp_std::result::Result;

Expand All @@ -33,7 +31,8 @@ pub type InstanceInfoOf<T> = NftInfo<

pub type BoundedCollectionSymbolOf<T> = BoundedVec<u8, <T as Config>::CollectionSymbolLimit>;

pub type ResourceOf<T, R> = ResourceInfo::<BoundedVec<u8, R>, BoundedVec<u8, <T as pallet_uniques::Config>::StringLimit>>;
pub type ResourceOf<T, R> =
ResourceInfo<BoundedVec<u8, R>, BoundedVec<u8, <T as pallet_uniques::Config>::StringLimit>>;

pub type StringLimitOf<T> = BoundedVec<u8, <T as pallet_uniques::Config>::StringLimit>;

Expand Down Expand Up @@ -84,8 +83,12 @@ pub mod pallet {
#[pallet::storage]
#[pallet::getter(fn collections)]
/// Stores collections info
pub type Collections<T: Config> =
StorageMap<_, Twox64Concat, CollectionId, CollectionInfo<StringLimitOf<T>, BoundedCollectionSymbolOf<T>, T::AccountId>>;
pub type Collections<T: Config> = StorageMap<
_,
Twox64Concat,
CollectionId,
CollectionInfo<StringLimitOf<T>, BoundedCollectionSymbolOf<T>, T::AccountId>,
>;

#[pallet::storage]
#[pallet::getter(fn get_nfts_by_owner)]
Expand Down Expand Up @@ -131,8 +134,7 @@ pub mod pallet {
(
NMapKey<Blake2_128Concat, CollectionId>,
NMapKey<Blake2_128Concat, NftId>,
NMapKey<Blake2_128Concat, BoundedResource<T::ResourceSymbolLimit>>
,
NMapKey<Blake2_128Concat, BoundedResource<T::ResourceSymbolLimit>>,
),
ResourceOf<T, T::ResourceSymbolLimit>,
OptionQuery,
Expand All @@ -152,6 +154,11 @@ pub mod pallet {
OptionQuery,
>;

#[pallet::storage]
#[pallet::getter(fn lock)]
/// Lock for NFTs
pub type Lock<T: Config> = StorageMap<_, Twox64Concat, (CollectionId, NftId), bool, ValueQuery>;

#[pallet::pallet]
#[pallet::without_storage_info]
#[pallet::generate_store(pub(super) trait Store)]
Expand Down Expand Up @@ -566,7 +573,7 @@ pub mod pallet {
slot,
license,
thumb,
parts
parts,
)?;

Self::deposit_event(Event::ResourceAdded { nft_id, resource_id });
Expand All @@ -583,7 +590,10 @@ pub mod pallet {
resource_id: BoundedResource<T::ResourceSymbolLimit>,
) -> DispatchResult {
let sender = ensure_signed(origin.clone())?;
ensure!(Resources::<T>::get((collection_id, nft_id, resource_id.clone())).is_some(), Error::<T>::ResourceDoesntExist);
ensure!(
Resources::<T>::get((collection_id, nft_id, resource_id.clone())).is_some(),
Error::<T>::ResourceDoesntExist
);

let (owner, _) = Pallet::<T>::lookup_root_owner(collection_id, nft_id)?;
ensure!(owner == sender, Error::<T>::NoPermission);
Expand Down
Loading