git.delta.rocks / unique-network / refs/commits / 50ea33350503

difftreelog

Cleanup borrowin in check_white_list

Greg Zaitsev2020-10-02parent: #3f41342.patch.diff
in: master

1 file changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
502 let target_collection = <Collection<T>>::get(collection_id);502 let target_collection = <Collection<T>>::get(collection_id);
503503
504 if !Self::is_owner_or_admin_permissions(collection_id, sender.clone()) {504 if !Self::is_owner_or_admin_permissions(collection_id, sender.clone()) {
505 ensure!(target_collection.mint_mode == true, "Collection is not in mint mode");505 ensure!(target_collection.mint_mode == true, "Public minting is not allowed for this collection");
506 Self::check_white_list(collection_id, owner.clone())?;506 Self::check_white_list(collection_id, &owner)?;
507 Self::check_white_list(collection_id, &sender)?;
507 }508 }
508509
509 match target_collection.mode510 match target_collection.mode
576 "Only item owner, collection owner and admins can modify item");577 "Only item owner, collection owner and admins can modify item");
577578
578 if target_collection.access == AccessMode::WhiteList {579 if target_collection.access == AccessMode::WhiteList {
579 Self::check_white_list(collection_id, sender.clone())?;580 Self::check_white_list(collection_id, &sender)?;
580 }581 }
581582
582 match target_collection.mode583 match target_collection.mode
605 "Only item owner, collection owner and admins can modify item");606 "Only item owner, collection owner and admins can modify item");
606607
607 if target_collection.access == AccessMode::WhiteList {608 if target_collection.access == AccessMode::WhiteList {
608 Self::check_white_list(collection_id, sender.clone())?;609 Self::check_white_list(collection_id, &sender)?;
609 Self::check_white_list(collection_id, recipient.clone())?;610 Self::check_white_list(collection_id, &recipient)?;
610 }611 }
611612
612 match target_collection.mode613 match target_collection.mode
632 "Only item owner, collection owner and admins can approve");633 "Only item owner, collection owner and admins can approve");
633634
634 if target_collection.access == AccessMode::WhiteList {635 if target_collection.access == AccessMode::WhiteList {
635 Self::check_white_list(collection_id, sender.clone())?;636 Self::check_white_list(collection_id, &sender)?;
636 Self::check_white_list(collection_id, approved.clone())?;637 Self::check_white_list(collection_id, &approved)?;
637 }638 }
638639
639 // amount param stub640 // amount param stub
679 "Only item owner, collection owner and admins can modify items");680 "Only item owner, collection owner and admins can modify items");
680681
681 if target_collection.access == AccessMode::WhiteList {682 if target_collection.access == AccessMode::WhiteList {
682 Self::check_white_list(collection_id, sender.clone())?;683 Self::check_white_list(collection_id, &sender)?;
683 Self::check_white_list(collection_id, recipient.clone())?;684 Self::check_white_list(collection_id, &recipient)?;
684 }685 }
685686
686 // remove approve687 // remove approve
935 }936 }
936 }937 }
937938
938 fn check_white_list(collection_id: u64, address: T::AccountId) -> DispatchResult {939 fn check_white_list(collection_id: u64, address: &T::AccountId) -> DispatchResult {
939940
940 let mes = "Address is not in white list";941 let mes = "Address is not in white list";
941 ensure!(<WhiteList<T>>::contains_key(collection_id), mes);942 ensure!(<WhiteList<T>>::contains_key(collection_id), mes);
942 let wl = <WhiteList<T>>::get(collection_id);943 let wl = <WhiteList<T>>::get(collection_id);
943 ensure!(wl.contains(&address.clone()), mes);944 ensure!(wl.contains(address), mes);
944945
945 Ok(())946 Ok(())
946 }947 }