git.delta.rocks / unique-network / refs/commits / 8556bf031c94

difftreelog

NFTPAR-107: RustDocs for All Externally Callable Methods.

sotmorskiy2020-10-07parent: #ab1a681.patch.diff
in: master

1 file changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
221 where221 where
222 AccountId = <T as system::Trait>::AccountId,222 AccountId = <T as system::Trait>::AccountId,
223 {223 {
224 /// New collection was created
225 ///
226 /// # Arguments
227 ///
228 /// * collection_id: Globally unique identifier of newly created collection.
229 ///
230 /// * mode: [CollectionMode] converted into u8.
231 ///
232 /// * account_id: Collection owner.
224 Created(u64, u8, AccountId),233 Created(u64, u8, AccountId),
234
235 /// New item was created.
236 ///
237 /// # Arguments
238 ///
239 /// * collection_id: Id of the collection where item was created.
240 ///
241 /// * item_id: Id of an item. Unique within the collection.
225 ItemCreated(u64, u64),242 ItemCreated(u64, u64),
243
244 /// Collection item was burned.
245 ///
246 /// # Arguments
247 ///
248 /// collection_id.
249 ///
250 /// item_id: Identifier of burned NFT.
226 ItemDestroyed(u64, u64),251 ItemDestroyed(u64, u64),
227 }252 }
228);253);
244 0269 0
245 }270 }
246271
247 // Create collection of NFT with given parameters272 /// This method creates a Collection of NFTs. Each Token may have multiple properties encoded as an array of bytes of certain length. The initial owner and admin of the collection are set to the address that signed the transaction. Both addresses can be changed later.
248 //273 ///
249 // @param customDataSz size of custom data in each collection item274 /// # Permissions
275 ///
276 /// * Anyone.
277 ///
278 /// # Arguments
279 ///
280 /// * collection_name: UTF-16 string with collection name (limit 64 characters), will be stored as zero-terminated.
281 ///
282 /// * collection_description: UTF-16 string with collection description (limit 256 characters), will be stored as zero-terminated.
283 ///
284 /// * token_prefix: UTF-8 string with token prefix.
285 ///
286 /// * mode: [CollectionMode] collection type and type dependent data.
250 // returns collection ID287 // returns collection ID
251 #[weight = 0]288 #[weight = 0]
252 pub fn create_collection(origin,289 pub fn create_collection(origin,
316 Ok(())353 Ok(())
317 }354 }
318355
356 /// **DANGEROUS**: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose real money.
357 ///
358 /// # Permissions
359 ///
360 /// * Collection Owner.
361 ///
362 /// # Arguments
363 ///
364 /// * collection_id: collection to destroy.
319 #[weight = 0]365 #[weight = 0]
320 pub fn destroy_collection(origin, collection_id: u64) -> DispatchResult {366 pub fn destroy_collection(origin, collection_id: u64) -> DispatchResult {
321367
334 Ok(())380 Ok(())
335 }381 }
336382
383 /// Add an address to white list.
384 ///
385 /// # Permissions
386 ///
387 /// * Collection Owner
388 /// * Collection Admin
389 ///
390 /// # Arguments
391 ///
392 /// * collection_id.
393 ///
394 /// * address.
337 #[weight = 0]395 #[weight = 0]
338 pub fn add_to_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{396 pub fn add_to_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{
339397
357 Ok(())415 Ok(())
358 }416 }
359417
418 /// Remove an address from white list.
419 ///
420 /// # Permissions
421 ///
422 /// * Collection Owner
423 /// * Collection Admin
424 ///
425 /// # Arguments
426 ///
427 /// * collection_id.
428 ///
429 /// * address.
360 #[weight = 0]430 #[weight = 0]
361 pub fn remove_from_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{431 pub fn remove_from_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{
362432
375 Ok(())445 Ok(())
376 }446 }
377447
448 /// Toggle between normal and white list access for the methods with access for `Anyone`.
449 ///
450 /// # Permissions
451 ///
452 /// * Collection Owner.
453 ///
454 /// # Arguments
455 ///
456 /// * collection_id.
457 ///
458 /// * mode: [AccessMode]
378 #[weight = 0]459 #[weight = 0]
379 pub fn set_public_access_mode(origin, collection_id: u64, mode: AccessMode) -> DispatchResult460 pub fn set_public_access_mode(origin, collection_id: u64, mode: AccessMode) -> DispatchResult
380 {461 {
388 Ok(())469 Ok(())
389 }470 }
390471
472 /// Allows Anyone to create tokens if:
473 /// * White List is enabled, and
474 /// * Address is added to white list, and
475 /// * This method was called with True parameter
476 ///
477 /// # Permissions
478 /// * Collection Owner
479 ///
480 /// # Arguments
481 ///
482 /// * collection_id.
483 ///
484 /// * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.
391 #[weight = 0]485 #[weight = 0]
392 pub fn set_mint_permission(origin, collection_id: u64, mint_permission: bool) -> DispatchResult486 pub fn set_mint_permission(origin, collection_id: u64, mint_permission: bool) -> DispatchResult
393 {487 {
401 Ok(())495 Ok(())
402 }496 }
403497
498 /// Change the owner of the collection.
499 ///
500 /// # Permissions
501 ///
502 /// * Collection Owner.
503 ///
504 /// # Arguments
505 ///
506 /// * collection_id.
507 ///
508 /// * new_owner.
404 #[weight = 0]509 #[weight = 0]
405 pub fn change_collection_owner(origin, collection_id: u64, new_owner: T::AccountId) -> DispatchResult {510 pub fn change_collection_owner(origin, collection_id: u64, new_owner: T::AccountId) -> DispatchResult {
406511
413 Ok(())518 Ok(())
414 }519 }
415520
521 /// Adds an admin of the Collection.
522 /// NFT Collection can be controlled by multiple admin addresses (some which can also be servers, for example). Admins can issue and burn NFTs, as well as add and remove other admins, but cannot change NFT or Collection ownership.
523 ///
524 /// # Permissions
525 ///
526 /// * Collection Owner.
527 /// * Collection Admin.
528 ///
529 /// # Arguments
530 ///
531 /// * collection_id: ID of the Collection to add admin for.
532 ///
533 /// * new_admin_id: Address of new admin to add.
416 #[weight = 0]534 #[weight = 0]
417 pub fn add_collection_admin(origin, collection_id: u64, new_admin_id: T::AccountId) -> DispatchResult {535 pub fn add_collection_admin(origin, collection_id: u64, new_admin_id: T::AccountId) -> DispatchResult {
418536
432 Ok(())550 Ok(())
433 }551 }
434552
553 /// Remove admin address of the Collection. An admin address can remove itself. List of admins may become empty, in which case only Collection Owner will be able to add an Admin.
554 ///
555 /// # Permissions
556 ///
557 /// * Collection Owner.
558 /// * Collection Admin.
559 ///
560 /// # Arguments
561 ///
562 /// * collection_id: ID of the Collection to remove admin for.
563 ///
564 /// * account_id: Address of admin to remove.
435 #[weight = 0]565 #[weight = 0]
436 pub fn remove_collection_admin(origin, collection_id: u64, account_id: T::AccountId) -> DispatchResult {566 pub fn remove_collection_admin(origin, collection_id: u64, account_id: T::AccountId) -> DispatchResult {
437567
448 Ok(())578 Ok(())
449 }579 }
450580
581 /// # Permissions
582 ///
583 /// * Collection Owner
584 ///
585 /// # Arguments
586 ///
587 /// * collection_id.
588 ///
589 /// * new_sponsor.
451 #[weight = 0]590 #[weight = 0]
452 pub fn set_collection_sponsor(origin, collection_id: u64, new_sponsor: T::AccountId) -> DispatchResult {591 pub fn set_collection_sponsor(origin, collection_id: u64, new_sponsor: T::AccountId) -> DispatchResult {
453592
463 Ok(())602 Ok(())
464 }603 }
465604
605 /// # Permissions
606 ///
607 /// * Sponsor.
608 ///
609 /// # Arguments
610 ///
611 /// * collection_id.
466 #[weight = 0]612 #[weight = 0]
467 pub fn confirm_sponsorship(origin, collection_id: u64) -> DispatchResult {613 pub fn confirm_sponsorship(origin, collection_id: u64) -> DispatchResult {
468614
479 Ok(())625 Ok(())
480 }626 }
481627
628 /// Switch back to pay-per-own-transaction model.
629 ///
630 /// # Permissions
631 ///
632 /// * Collection owner.
633 ///
634 /// # Arguments
635 ///
636 /// * collection_id.
482 #[weight = 0]637 #[weight = 0]
483 pub fn remove_collection_sponsor(origin, collection_id: u64) -> DispatchResult {638 pub fn remove_collection_sponsor(origin, collection_id: u64) -> DispatchResult {
484639
494 Ok(())649 Ok(())
495 }650 }
496651
652 /// This method creates a concrete instance of NFT Collection created with CreateCollection method.
653 ///
654 /// # Permissions
655 ///
656 /// * Collection Owner.
657 /// * Collection Admin.
658 /// * Anyone if
659 /// * White List is enabled, and
660 /// * Address is added to white list, and
661 /// * MintPermission is enabled (see SetMintPermission method)
662 ///
663 /// # Arguments
664 ///
665 /// * collection_id: ID of the collection.
666 ///
667 /// * properties: Array of bytes that contains NFT properties. Since NFT Module is agnostic of properties meaning, it is treated purely as an array of bytes.
668 ///
669 /// * owner: Address, initial owner of the NFT.
497 #[weight = 0]670 #[weight = 0]
498 pub fn create_item(origin, collection_id: u64, properties: Vec<u8>, owner: T::AccountId) -> DispatchResult {671 pub fn create_item(origin, collection_id: u64, properties: Vec<u8>, owner: T::AccountId) -> DispatchResult {
499672
564 Ok(())737 Ok(())
565 }738 }
566739
740 /// Destroys a concrete instance of NFT.
741 ///
742 /// # Permissions
743 ///
744 /// * Collection Owner.
745 /// * Collection Admin.
746 /// * Current NFT Owner.
747 ///
748 /// # Arguments
749 ///
750 /// * collection_id: ID of the collection.
751 ///
752 /// * item_id: ID of NFT to burn.
567 #[weight = 0]753 #[weight = 0]
568 pub fn burn_item(origin, collection_id: u64, item_id: u64) -> DispatchResult {754 pub fn burn_item(origin, collection_id: u64, item_id: u64) -> DispatchResult {
569755
594 Ok(())780 Ok(())
595 }781 }
596782
783 /// Change ownership of the token.
784 ///
785 /// # Permissions
786 ///
787 /// * Collection Owner
788 /// * Collection Admin
789 /// * Current NFT owner
790 ///
791 /// # Arguments
792 ///
793 /// * recipient: Address of token recipient.
794 ///
795 /// * collection_id.
796 ///
797 /// * item_id: ID of the item
798 /// * Non-Fungible Mode: Required.
799 /// * Fungible Mode: Ignored.
800 /// * Re-Fungible Mode: Required.
801 ///
802 /// * value: Amount to transfer.
803 /// * Non-Fungible Mode: Ignored
804 /// * Fungible Mode: Must specify transferred amount
805 /// * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)
597 #[weight = 0]806 #[weight = 0]
598 pub fn transfer(origin, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64) -> DispatchResult {807 pub fn transfer(origin, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64) -> DispatchResult {
599808
621 Ok(())830 Ok(())
622 }831 }
623832
833 /// Set, change, or remove approved address to transfer the ownership of the NFT.
834 ///
835 /// # Permissions
836 ///
837 /// * Collection Owner
838 /// * Collection Admin
839 /// * Current NFT owner
840 ///
841 /// # Arguments
842 ///
843 /// * approved: Address that is approved to transfer this NFT or zero (if needed to remove approval).
844 ///
845 /// * collection_id.
846 ///
847 /// * item_id: ID of the item.
624 #[weight = 0]848 #[weight = 0]
625 pub fn approve(origin, approved: T::AccountId, collection_id: u64, item_id: u64) -> DispatchResult {849 pub fn approve(origin, approved: T::AccountId, collection_id: u64, item_id: u64) -> DispatchResult {
626850
660 Ok(())884 Ok(())
661 }885 }
662886
887 /// Change ownership of a NFT on behalf of the owner. See Approve method for additional information. After this method executes, the approval is removed so that the approved address will not be able to transfer this NFT again from this owner.
888 ///
889 /// # Permissions
890 /// * Collection Owner
891 /// * Collection Admin
892 /// * Current NFT owner
893 /// * Address approved by current NFT owner
894 ///
895 /// # Arguments
896 ///
897 /// * from: Address that owns token.
898 ///
899 /// * recipient: Address of token recipient.
900 ///
901 /// * collection_id.
902 ///
903 /// * item_id: ID of the item.
904 ///
905 /// * value: Amount to transfer.
663 #[weight = 0]906 #[weight = 0]
664 pub fn transfer_from(origin, from: T::AccountId, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64 ) -> DispatchResult {907 pub fn transfer_from(origin, from: T::AccountId, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64 ) -> DispatchResult {
665908
701 Ok(())944 Ok(())
702 }945 }
703946
947 ///
704 #[weight = 0]948 #[weight = 0]
705 pub fn safe_transfer_from(origin, collection_id: u64, item_id: u64, new_owner: T::AccountId) -> DispatchResult {949 pub fn safe_transfer_from(origin, collection_id: u64, item_id: u64, new_owner: T::AccountId) -> DispatchResult {
706950
716 Ok(())960 Ok(())
717 }961 }
718962
963 /// Set off-chain data schema.
964 ///
965 /// # Permissions
966 ///
967 /// * Collection Owner
968 /// * Collection Admin
969 ///
970 /// # Arguments
971 ///
972 /// * collection_id.
973 ///
974 /// * schema: String representing the offchain data schema.
719 #[weight = 0]975 #[weight = 0]
720 pub fn set_offchain_schema(976 pub fn set_offchain_schema(
721 origin,977 origin,