difftreelog
NFTPAR-107: RustDocs for All Externally Callable Methods.
in: master
1 file changed
pallets/nft/src/lib.rsdiffbeforeafterboth221 where221 where222 AccountId = <T as system::Trait>::AccountId,222 AccountId = <T as system::Trait>::AccountId,223 {223 {224 /// New collection was created225 /// 226 /// # Arguments227 /// 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),234235 /// New item was created.236 /// 237 /// # Arguments238 /// 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),243244 /// Collection item was burned.245 /// 246 /// # Arguments247 /// 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 0245 }270 }246271247 // 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 /// # Permissions275 /// 276 /// * Anyone.277 /// 278 /// # Arguments279 /// 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 ID251 #[weight = 0]288 #[weight = 0]252 pub fn create_collection(origin,289 pub fn create_collection(origin,316 Ok(())353 Ok(())317 }354 }318355356 /// **DANGEROUS**: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose real money.357 /// 358 /// # Permissions359 /// 360 /// * Collection Owner.361 /// 362 /// # Arguments363 /// 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 {321367334 Ok(())380 Ok(())335 }381 }336382383 /// Add an address to white list.384 /// 385 /// # Permissions386 /// 387 /// * Collection Owner388 /// * Collection Admin389 /// 390 /// # Arguments391 /// 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{339397357 Ok(())415 Ok(())358 }416 }359417418 /// Remove an address from white list.419 /// 420 /// # Permissions421 /// 422 /// * Collection Owner423 /// * Collection Admin424 /// 425 /// # Arguments426 /// 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{362432375 Ok(())445 Ok(())376 }446 }377447448 /// Toggle between normal and white list access for the methods with access for `Anyone`.449 /// 450 /// # Permissions451 /// 452 /// * Collection Owner.453 /// 454 /// # Arguments455 /// 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) -> DispatchResult380 {461 {388 Ok(())469 Ok(())389 }470 }390471472 /// Allows Anyone to create tokens if:473 /// * White List is enabled, and474 /// * Address is added to white list, and475 /// * This method was called with True parameter476 /// 477 /// # Permissions478 /// * Collection Owner479 ///480 /// # Arguments481 /// 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) -> DispatchResult393 {487 {401 Ok(())495 Ok(())402 }496 }403497498 /// Change the owner of the collection.499 /// 500 /// # Permissions501 /// 502 /// * Collection Owner.503 /// 504 /// # Arguments505 /// 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 {406511413 Ok(())518 Ok(())414 }519 }415520521 /// 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 /// # Permissions525 /// 526 /// * Collection Owner.527 /// * Collection Admin.528 /// 529 /// # Arguments530 /// 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 {418536432 Ok(())550 Ok(())433 }551 }434552553 /// 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 /// # Permissions556 /// 557 /// * Collection Owner.558 /// * Collection Admin.559 /// 560 /// # Arguments561 /// 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 {437567448 Ok(())578 Ok(())449 }579 }450580581 /// # Permissions582 /// 583 /// * Collection Owner584 /// 585 /// # Arguments586 /// 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 {453592463 Ok(())602 Ok(())464 }603 }465604605 /// # Permissions606 /// 607 /// * Sponsor.608 /// 609 /// # Arguments610 /// 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 {468614479 Ok(())625 Ok(())480 }626 }481627628 /// Switch back to pay-per-own-transaction model.629 ///630 /// # Permissions631 ///632 /// * Collection owner.633 /// 634 /// # Arguments635 /// 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 {484639494 Ok(())649 Ok(())495 }650 }496651652 /// This method creates a concrete instance of NFT Collection created with CreateCollection method.653 /// 654 /// # Permissions655 /// 656 /// * Collection Owner.657 /// * Collection Admin.658 /// * Anyone if659 /// * White List is enabled, and660 /// * Address is added to white list, and661 /// * MintPermission is enabled (see SetMintPermission method)662 /// 663 /// # Arguments664 /// 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 {499672564 Ok(())737 Ok(())565 }738 }566739740 /// Destroys a concrete instance of NFT.741 /// 742 /// # Permissions743 /// 744 /// * Collection Owner.745 /// * Collection Admin.746 /// * Current NFT Owner.747 /// 748 /// # Arguments749 /// 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 {569755594 Ok(())780 Ok(())595 }781 }596782783 /// Change ownership of the token.784 /// 785 /// # Permissions786 /// 787 /// * Collection Owner788 /// * Collection Admin789 /// * Current NFT owner790 ///791 /// # Arguments792 /// 793 /// * recipient: Address of token recipient.794 /// 795 /// * collection_id.796 /// 797 /// * item_id: ID of the item798 /// * Non-Fungible Mode: Required.799 /// * Fungible Mode: Ignored.800 /// * Re-Fungible Mode: Required.801 /// 802 /// * value: Amount to transfer.803 /// * Non-Fungible Mode: Ignored804 /// * Fungible Mode: Must specify transferred amount805 /// * 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 {599808621 Ok(())830 Ok(())622 }831 }623832833 /// Set, change, or remove approved address to transfer the ownership of the NFT.834 /// 835 /// # Permissions836 /// 837 /// * Collection Owner838 /// * Collection Admin839 /// * Current NFT owner840 /// 841 /// # Arguments842 /// 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 {626850660 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 /// # Permissions890 /// * Collection Owner891 /// * Collection Admin892 /// * Current NFT owner893 /// * Address approved by current NFT owner894 /// 895 /// # Arguments896 /// 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 {665908701 Ok(())944 Ok(())702 }945 }703946947 ///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 {706950716 Ok(())960 Ok(())717 }961 }718962963 /// Set off-chain data schema.964 /// 965 /// # Permissions966 /// 967 /// * Collection Owner968 /// * Collection Admin969 /// 970 /// # Arguments971 /// 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,