123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566#![recursion_limit = "1024"]67#![cfg_attr(not(feature = "std"), no_std)]68#![allow(69 clippy::too_many_arguments,70 clippy::unnecessary_mut_passed,71 clippy::unused_unit72)]7374extern crate alloc;7576use frame_support::{77 decl_module, decl_storage, decl_error, decl_event,78 dispatch::DispatchResult,79 ensure, fail,80 weights::{Weight},81 pallet_prelude::{DispatchResultWithPostInfo, ConstU32},82 BoundedVec,83};84use scale_info::TypeInfo;85use frame_system::{self as system, ensure_signed};86use sp_std::{vec, vec::Vec};87use up_data_structs::{88 MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,89 MAX_PROPERTIES_PER_ITEM, MAX_PROPERTY_KEY_LENGTH, MAX_PROPERTY_VALUE_LENGTH,90 MAX_COLLECTION_PROPERTIES_SIZE, COLLECTION_ADMINS_LIMIT, MAX_TOKEN_PROPERTIES_SIZE,91 CreateItemData, CollectionLimits, CollectionPermissions, CollectionId, CollectionMode, TokenId,92 CreateCollectionData, CreateItemExData, budget, Property, PropertyKey, PropertyKeyPermission,93};94use pallet_evm::{account::CrossAccountId};95use pallet_common::{96 CollectionHandle, Pallet as PalletCommon, CommonWeightInfo, dispatch::dispatch_tx,97 dispatch::CollectionDispatch, RefungibleExtensionsWeightInfo,98};99pub mod eth;100101#[cfg(feature = "runtime-benchmarks")]102pub mod benchmarking;103pub mod weights;104use weights::WeightInfo;105106107pub const NESTING_BUDGET: u32 = 5;108109decl_error! {110 111 pub enum Error for Module<T: Config> {112 113 CollectionDecimalPointLimitExceeded,114 115 EmptyArgument,116 117 RepartitionCalledOnNonRefungibleCollection,118 }119}120121122pub trait Config: system::Config + pallet_common::Config + Sized + TypeInfo {123 124 type RuntimeEvent: From<Event<Self>> + Into<<Self as frame_system::Config>::RuntimeEvent>;125126 127 type WeightInfo: WeightInfo;128129 130 type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;131132 133 type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;134}135136decl_event! {137 pub enum Event<T>138 where139 <T as frame_system::Config>::AccountId,140 {141 142 143 144 145 CollectionSponsorRemoved(CollectionId),146147 148 149 150 151 152 CollectionSponsorSet(CollectionId, AccountId),153154 }155}156157type SelfWeightOf<T> = <T as Config>::WeightInfo;158159160161162163164165166167168169170171172173174175176177178179180181decl_storage! {182 trait Store for Module<T: Config> as Unique {183184 185 186 ChainVersion: u64;187 188189 190 191 192 pub CreateItemBasket get(fn create_item_basket): map hasher(blake2_128_concat) (CollectionId, T::AccountId) => Option<T::BlockNumber>;193 194 pub NftTransferBasket get(fn nft_transfer_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;195 196 pub FungibleTransferBasket get(fn fungible_transfer_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;197 198 pub ReFungibleTransferBasket get(fn refungible_transfer_basket): nmap hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;199 200201 202 203 #[deprecated]204 pub VariableMetaDataBasket get(fn variable_meta_data_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;205 206 pub TokenPropertyBasket get(fn token_property_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;207208 209 pub NftApproveBasket get(fn nft_approve_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;210 211 pub FungibleApproveBasket get(fn fungible_approve_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;212 213 pub RefungibleApproveBasket get(fn refungible_approve_basket): nmap hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;214 }215}216217decl_module! {218 219 pub struct Module<T: Config> for enum Call220 where221 origin: T::RuntimeOrigin222 {223 type Error = Error<T>;224225 #[doc = "A maximum number of levels of depth in the token nesting tree."]226 const NESTING_BUDGET: u32 = NESTING_BUDGET;227228 #[doc = "Maximal length of a collection name."]229 const MAX_COLLECTION_NAME_LENGTH: u32 = MAX_COLLECTION_NAME_LENGTH;230231 #[doc = "Maximal length of a collection description."]232 const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = MAX_COLLECTION_DESCRIPTION_LENGTH;233234 #[doc = "Maximal length of a token prefix."]235 const MAX_TOKEN_PREFIX_LENGTH: u32 = MAX_TOKEN_PREFIX_LENGTH;236237 #[doc = "Maximum admins per collection."]238 const COLLECTION_ADMINS_LIMIT: u32 = COLLECTION_ADMINS_LIMIT;239240 #[doc = "Maximal length of a property key."]241 const MAX_PROPERTY_KEY_LENGTH: u32 = MAX_PROPERTY_KEY_LENGTH;242243 #[doc = "Maximal length of a property value."]244 const MAX_PROPERTY_VALUE_LENGTH: u32 = MAX_PROPERTY_VALUE_LENGTH;245246 #[doc = "A maximum number of token properties."]247 const MAX_PROPERTIES_PER_ITEM: u32 = MAX_PROPERTIES_PER_ITEM;248249 #[doc = "Maximum size for all collection properties."]250 const MAX_COLLECTION_PROPERTIES_SIZE: u32 = MAX_COLLECTION_PROPERTIES_SIZE;251252 #[doc = "Maximum size of all token properties."]253 const MAX_TOKEN_PROPERTIES_SIZE: u32 = MAX_TOKEN_PROPERTIES_SIZE;254255 #[doc = "Default NFT collection limit."]256 const NFT_DEFAULT_COLLECTION_LIMITS: CollectionLimits = CollectionLimits::with_default_limits(CollectionMode::NFT);257258 #[doc = "Default RFT collection limit."]259 const RFT_DEFAULT_COLLECTION_LIMITS: CollectionLimits = CollectionLimits::with_default_limits(CollectionMode::ReFungible);260261 #[doc = "Default FT collection limit."]262 const FT_DEFAULT_COLLECTION_LIMITS: CollectionLimits = CollectionLimits::with_default_limits(CollectionMode::Fungible(0));263264265 pub fn deposit_event() = default;266267 fn on_initialize(_now: T::BlockNumber) -> Weight {268 Weight::zero()269 }270271 fn on_runtime_upgrade() -> Weight {272 Weight::zero()273 }274275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 #[weight = <SelfWeightOf<T>>::create_collection()]298 #[deprecated(note = "`create_collection_ex` is more up-to-date and advanced, prefer it instead")]299 pub fn create_collection(300 origin,301 collection_name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,302 collection_description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,303 token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,304 mode: CollectionMode305 ) -> DispatchResult {306 let data: CreateCollectionData<T::AccountId> = CreateCollectionData {307 name: collection_name,308 description: collection_description,309 token_prefix,310 mode,311 ..Default::default()312 };313 Self::create_collection_ex(origin, data)314 }315316 317 318 319 320 321 322 323 324 325 326 327 #[weight = <SelfWeightOf<T>>::create_collection()]328 pub fn create_collection_ex(origin, data: CreateCollectionData<T::AccountId>) -> DispatchResult {329 let sender = ensure_signed(origin)?;330331 332 let sender = T::CrossAccountId::from_sub(sender);333 let _id = T::CollectionDispatch::create(sender.clone(), sender, data, Default::default())?;334335 Ok(())336 }337338 339 340 341 342 343 344 345 346 347 #[weight = <SelfWeightOf<T>>::destroy_collection()]348 pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {349 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);350351 Self::destroy_collection_internal(sender, collection_id)352 }353354 355 356 357 358 359 360 361 362 363 364 365 #[weight = <SelfWeightOf<T>>::add_to_allow_list()]366 pub fn add_to_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{367368 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);369 let collection = <CollectionHandle<T>>::try_get(collection_id)?;370 collection.check_is_internal()?;371372 <PalletCommon<T>>::toggle_allowlist(373 &collection,374 &sender,375 &address,376 true,377 )?;378379 Ok(())380 }381382 383 384 385 386 387 388 389 390 391 392 393 #[weight = <SelfWeightOf<T>>::remove_from_allow_list()]394 pub fn remove_from_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{395396 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);397 let collection = <CollectionHandle<T>>::try_get(collection_id)?;398 collection.check_is_internal()?;399400 <PalletCommon<T>>::toggle_allowlist(401 &collection,402 &sender,403 &address,404 false,405 )?;406407 Ok(())408 }409410 411 412 413 414 415 416 417 418 419 420 #[weight = <SelfWeightOf<T>>::change_collection_owner()]421 pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult {422 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);423 let new_owner = T::CrossAccountId::from_sub(new_owner);424 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;425 target_collection.change_owner(sender, new_owner.clone())426 }427428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 #[weight = <SelfWeightOf<T>>::add_collection_admin()]445 pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin_id: T::CrossAccountId) -> DispatchResult {446 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);447 let collection = <CollectionHandle<T>>::try_get(collection_id)?;448 <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin_id, true)449 }450451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 #[weight = <SelfWeightOf<T>>::remove_collection_admin()]466 pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::CrossAccountId) -> DispatchResult {467 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);468 let collection = <CollectionHandle<T>>::try_get(collection_id)?;469 <PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)470 }471472 473 474 475 476 477 478 479 480 481 482 483 484 485 #[weight = <SelfWeightOf<T>>::set_collection_sponsor()]486 pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {487 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);488 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;489 target_collection.set_sponsor(&sender, new_sponsor.clone())490 }491492 493 494 495 496 497 498 499 500 501 502 503 504 505 #[weight = <SelfWeightOf<T>>::confirm_sponsorship()]506 pub fn confirm_sponsorship(origin, collection_id: CollectionId) -> DispatchResult {507 let sender = ensure_signed(origin)?;508 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;509 target_collection.confirm_sponsorship(&sender)510 }511512 513 514 515 516 517 518 519 520 521 #[weight = <SelfWeightOf<T>>::remove_collection_sponsor()]522 pub fn remove_collection_sponsor(origin, collection_id: CollectionId) -> DispatchResult {523 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);524 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;525 target_collection.remove_sponsor(&sender)526 }527528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 #[weight = T::CommonWeightInfo::create_item()]547 pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {548 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);549 let budget = budget::Value::new(NESTING_BUDGET);550551 dispatch_tx::<T, _>(collection_id, |d| d.create_item(sender, owner, data, &budget))552 }553554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 #[weight = T::CommonWeightInfo::create_multiple_items(&items_data)]573 pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {574 ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);575 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);576 let budget = budget::Value::new(NESTING_BUDGET);577578 dispatch_tx::<T, _>(collection_id, |d| d.create_multiple_items(sender, owner, items_data, &budget))579 }580581 582 583 584 585 586 587 588 589 590 591 592 593 #[weight = T::CommonWeightInfo::set_collection_properties(properties.len() as u32)]594 pub fn set_collection_properties(595 origin,596 collection_id: CollectionId,597 properties: Vec<Property>598 ) -> DispatchResultWithPostInfo {599 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);600601 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);602603 dispatch_tx::<T, _>(collection_id, |d| d.set_collection_properties(sender, properties))604 }605606 607 608 609 610 611 612 613 614 615 616 617 618 #[weight = T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32)]619 pub fn delete_collection_properties(620 origin,621 collection_id: CollectionId,622 property_keys: Vec<PropertyKey>,623 ) -> DispatchResultWithPostInfo {624 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);625626 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);627628 dispatch_tx::<T, _>(collection_id, |d| d.delete_collection_properties(&sender, property_keys))629 }630631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 #[weight = T::CommonWeightInfo::set_token_properties(properties.len() as u32)]650 pub fn set_token_properties(651 origin,652 collection_id: CollectionId,653 token_id: TokenId,654 properties: Vec<Property>655 ) -> DispatchResultWithPostInfo {656 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);657658 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);659 let budget = budget::Value::new(NESTING_BUDGET);660661 dispatch_tx::<T, _>(collection_id, |d| d.set_token_properties(sender, token_id, properties, &budget))662 }663664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 #[weight = T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32)]680 pub fn delete_token_properties(681 origin,682 collection_id: CollectionId,683 token_id: TokenId,684 property_keys: Vec<PropertyKey>685 ) -> DispatchResultWithPostInfo {686 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);687688 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);689 let budget = budget::Value::new(NESTING_BUDGET);690691 dispatch_tx::<T, _>(collection_id, |d| d.delete_token_properties(sender, token_id, property_keys, &budget))692 }693694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 #[weight = T::CommonWeightInfo::set_token_property_permissions(property_permissions.len() as u32)]710 pub fn set_token_property_permissions(711 origin,712 collection_id: CollectionId,713 property_permissions: Vec<PropertyKeyPermission>,714 ) -> DispatchResultWithPostInfo {715 ensure!(!property_permissions.is_empty(), Error::<T>::EmptyArgument);716717 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);718719 dispatch_tx::<T, _>(collection_id, |d| d.set_token_property_permissions(&sender, property_permissions))720 }721722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 #[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]738 pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {739 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);740 let budget = budget::Value::new(NESTING_BUDGET);741742 dispatch_tx::<T, _>(collection_id, |d| d.create_multiple_items_ex(sender, data, &budget))743 }744745 746 747 748 749 750 751 752 753 754 755 #[weight = <SelfWeightOf<T>>::set_transfers_enabled_flag()]756 pub fn set_transfers_enabled_flag(origin, collection_id: CollectionId, value: bool) -> DispatchResult {757 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);758 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;759 target_collection.check_is_internal()?;760 target_collection.check_is_owner(&sender)?;761762 763764 target_collection.limits.transfers_enabled = Some(value);765 target_collection.save()766 }767768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 #[weight = T::CommonWeightInfo::burn_item()]785 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {786 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);787788 let post_info = dispatch_tx::<T, _>(collection_id, |d| d.burn_item(sender, item_id, value))?;789 if value == 1 {790 <NftTransferBasket<T>>::remove(collection_id, item_id);791 <NftApproveBasket<T>>::remove(collection_id, item_id);792 }793 794 795 796 Ok(post_info)797 }798799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 #[weight = T::CommonWeightInfo::burn_from()]823 pub fn burn_from(origin, collection_id: CollectionId, from: T::CrossAccountId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {824 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);825 let budget = budget::Value::new(NESTING_BUDGET);826827 dispatch_tx::<T, _>(collection_id, |d| d.burn_from(sender, from, item_id, value, &budget))828 }829830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 #[weight = T::CommonWeightInfo::transfer()]852 pub fn transfer(origin, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {853 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);854 let budget = budget::Value::new(NESTING_BUDGET);855856 dispatch_tx::<T, _>(collection_id, |d| d.transfer(sender, recipient, item_id, value, &budget))857 }858859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 #[weight = T::CommonWeightInfo::approve()]875 pub fn approve(origin, spender: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, amount: u128) -> DispatchResultWithPostInfo {876 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);877878 dispatch_tx::<T, _>(collection_id, |d| d.approve(sender, spender, item_id, amount))879 }880881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 #[weight = T::CommonWeightInfo::transfer_from()]906 pub fn transfer_from(origin, from: T::CrossAccountId, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResultWithPostInfo {907 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);908 let budget = budget::Value::new(NESTING_BUDGET);909910 dispatch_tx::<T, _>(collection_id, |d| d.transfer_from(sender, from, recipient, item_id, value, &budget))911 }912913 914 915 916 917 918 919 920 921 922 923 924 925 #[weight = <SelfWeightOf<T>>::set_collection_limits()]926 pub fn set_collection_limits(927 origin,928 collection_id: CollectionId,929 new_limit: CollectionLimits,930 ) -> DispatchResult {931 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);932 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;933 <PalletCommon<T>>::update_limits(&sender, &mut target_collection, new_limit)934 }935936 937 938 939 940 941 942 943 944 945 946 947 948 #[weight = <SelfWeightOf<T>>::set_collection_limits()]949 pub fn set_collection_permissions(950 origin,951 collection_id: CollectionId,952 new_permission: CollectionPermissions,953 ) -> DispatchResult {954 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);955 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;956 <PalletCommon<T>>::update_permissions(957 &sender,958 &mut target_collection,959 new_permission960 )961 }962963 964 965 966 967 968 969 970 971 972 973 974 #[weight = T::RefungibleExtensionsWeightInfo::repartition()]975 pub fn repartition(976 origin,977 collection_id: CollectionId,978 token_id: TokenId,979 amount: u128,980 ) -> DispatchResultWithPostInfo {981 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);982 dispatch_tx::<T, _>(collection_id, |d| {983 if let Some(refungible_extensions) = d.refungible_extensions() {984 refungible_extensions.repartition(&sender, token_id, amount)985 } else {986 fail!(<Error<T>>::RepartitionCalledOnNonRefungibleCollection)987 }988 })989 }990991 992 993 994 995 996 997 998 999 1000 #[weight = T::CommonWeightInfo::set_allowance_for_all()]1001 pub fn set_allowance_for_all(1002 origin,1003 collection_id: CollectionId,1004 operator: T::CrossAccountId,1005 approve: bool,1006 ) -> DispatchResultWithPostInfo {1007 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1008 dispatch_tx::<T, _>(collection_id, |d| {1009 d.set_allowance_for_all(sender, operator, approve)1010 })1011 }1012 }1013}10141015impl<T: Config> Pallet<T> {1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 pub fn force_set_sponsor(sponsor: T::AccountId, collection_id: CollectionId) -> DispatchResult {1026 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1027 target_collection.force_set_sponsor(sponsor.clone())1028 }10291030 1031 1032 1033 1034 1035 1036 1037 1038 pub fn force_remove_collection_sponsor(collection_id: CollectionId) -> DispatchResult {1039 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1040 target_collection.force_remove_sponsor()1041 }10421043 #[inline(always)]1044 pub(crate) fn destroy_collection_internal(1045 sender: T::CrossAccountId,1046 collection_id: CollectionId,1047 ) -> DispatchResult {1048 let collection = <CollectionHandle<T>>::try_get(collection_id)?;1049 collection.check_is_internal()?;10501051 T::CollectionDispatch::destroy(sender, collection)?;10521053 1054 10551056 let _ = <NftTransferBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1057 let _ = <FungibleTransferBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1058 let _ = <ReFungibleTransferBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);10591060 let _ = <NftApproveBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1061 let _ = <FungibleApproveBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1062 let _ = <RefungibleApproveBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);10631064 Ok(())1065 }1066}