git.delta.rocks / unique-network / refs/commits / 3a27627da776

difftreelog

warning removed

str-mv2020-06-18parent: #bb1c5f7.patch.diff
in: master

3 files changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
1#![cfg_attr(not(feature = "std"), no_std)]1#![cfg_attr(not(feature = "std"), no_std)]
22
3use codec::{Decode, Encode};
3/// A FRAME pallet template with necessary imports4/// A FRAME pallet template with necessary imports
45
5/// Feel free to remove or edit this file as needed.6/// Feel free to remove or edit this file as needed.
9/// For more guidance on Substrate FRAME, see the example pallet10/// For more guidance on Substrate FRAME, see the example pallet
10/// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs11/// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs
11
12use frame_support::{12use frame_support::{decl_event, decl_module, decl_storage, dispatch::DispatchResult, ensure};
13 dispatch::DispatchResult, decl_module, decl_storage, decl_event,
14 ensure,
15};
16use frame_system::{self as system, ensure_signed };13use frame_system::{self as system, ensure_signed};
17use codec::{Encode, Decode};
18use sp_runtime::sp_std::prelude::Vec;14use sp_runtime::sp_std::prelude::Vec;
1915
20#[cfg(test)]16#[cfg(test)]
82decl_event!(78decl_event!(
83 pub enum Event<T> where AccountId = <T as system::Trait>::AccountId {79 pub enum Event<T>
80 where
81 AccountId = <T as system::Trait>::AccountId,
82 {
84 Created(u32, AccountId),83 Created(u32, AccountId),
85 }84 }
376 #[weight = frame_support::weights::SimpleDispatchInfo::default()]375 #[weight = frame_support::weights::SimpleDispatchInfo::default()]
377 pub fn transfer_from(origin, collection_id: u64, item_id: u64, new_owner: T::AccountId) -> DispatchResult {376 pub fn transfer_from(origin, collection_id: u64, item_id: u64, new_owner: T::AccountId) -> DispatchResult {
378
379 // let sender = ensure_signed(origin)?;
380 // ensure!(<Collection<T>>::contains_key(collection_id), "This collection does not exist");
381
382 // let target_collection = <Collection<T>>::get(collection_id);
383 // let is_owner = sender == target_collection.owner;
384
385 // ensure!(<ItemList<T>>::contains_key((collection_id, item_id)), "Item does not exists");
386 // let mut item = <ItemList<T>>::get((collection_id, item_id));
387
388 // if !is_owner
389 // {
390 // let no_perm_mes = "You do not have permissions to modify this collection";
391
392 // // check if item owner
393 // if item.owner != sender
394 // {
395 // ensure!(<AdminList<T>>::contains_key(collection_id), no_perm_mes);
396 // ensure!(<AdminList<T>>::get(collection_id).contains(&sender), no_perm_mes);
397 // }
398
399 // ensure!(<ApprovedList<T>>::contains_key((collection_id, item_id)), no_perm_mes);
400 // let list_itm = <ApprovedList<T>>::get((collection_id, item_id));
401 // ensure!(list_itm.contains(&new_owner.clone()), no_perm_mes);
402
403 // }
404
405377
406 let no_perm_mes = "You do not have permissions to modify this collection";378 let no_perm_mes = "You do not have permissions to modify this collection";
407 ensure!(<ApprovedList<T>>::contains_key((collection_id, item_id)), no_perm_mes);379 ensure!(<ApprovedList<T>>::contains_key((collection_id, item_id)), no_perm_mes);
408 let list_itm = <ApprovedList<T>>::get((collection_id, item_id));380 let list_itm = <ApprovedList<T>>::get((collection_id, item_id));
409 ensure!(list_itm.contains(&new_owner.clone()), no_perm_mes);381 ensure!(list_itm.contains(&new_owner.clone()), no_perm_mes);
410382
411 Self::transfer(origin, collection_id, item_id, new_owner);383 Self::transfer(origin, collection_id, item_id, new_owner)?;
412384
413 Ok(())385 Ok(())
414 }386 }
modifiedpallets/nft/src/mock.rsdiffbeforeafterboth
1// Creating mock runtime here1// Creating mock runtime here
22
3use crate::{Module, Trait};3use crate::{Module, Trait};
4use sp_core::H256;
5use frame_support::{impl_outer_origin, parameter_types, weights::Weight};4use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
5use frame_system as system;
6use sp_core::H256;
6use sp_runtime::{7use sp_runtime::{
8 testing::Header,
7 traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill,9 traits::{BlakeTwo256, IdentityLookup},
10 Perbill,
8};11};
9use frame_system as system;
1012
11impl_outer_origin! {13impl_outer_origin! {
12 pub enum Origin for Test {}14 pub enum Origin for Test {}
modifiedpallets/nft/src/tests.rsdiffbeforeafterboth
1// Tests to be written here1// Tests to be written here
2use crate::{ mock::*};2use crate::mock::*;
3use frame_support::{assert_ok, assert_noop};3use frame_support::{assert_noop, assert_ok};
44
5#[test]5#[test]
6fn create_collection_test() {6fn create_collection_test() {