difftreelog
fix documents TODOs
in: master
1 file changed
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth659 return (await this.helper.callRpc('api.rpc.unique.effectiveCollectionLimits', [collectionId])).toJSON();659 return (await this.helper.callRpc('api.rpc.unique.effectiveCollectionLimits', [collectionId])).toJSON();660 }660 }661661662 /**662 /**663 * Burns the collection if the signer has sufficient permissions and collection is empty.663 * Burns the collection if the signer has sufficient permissions and collection is empty.664 * 664 * 665 * @param signer keyring of signer665 * @param signer keyring of signer666 * @param collectionId ID of collection666 * @param collectionId ID of collection667 * @param label extra label for log667 * @param label extra label for log668 * @example await helper.collection.burn(aliceKeyring, 3);668 * @example await helper.collection.burn(aliceKeyring, 3);669 * @returns bool true on success669 * @returns ```true``` if extrinsic success, otherwise ```false```670 */670 */671 async burn(signer: TSigner, collectionId: number, label?: string): Promise<boolean> {671 async burn(signer: TSigner, collectionId: number, label?: string): Promise<boolean> {672 if(typeof label === 'undefined') label = `collection #${collectionId}`;672 if(typeof label === 'undefined') label = `collection #${collectionId}`;673 const result = await this.helper.executeExtrinsic(673 const result = await this.helper.executeExtrinsic(679 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'CollectionDestroyed', label);679 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'CollectionDestroyed', label);680 }680 }681681682 /**682 /**683 * Sets the sponsor for the collection (Requires the Substrate address).683 * Sets the sponsor for the collection (Requires the Substrate address).684 * 684 * 685 * @param signer keyring of signer685 * @param signer keyring of signer686 * @param collectionId ID of collection686 * @param collectionId ID of collection687 * @param sponsorAddress Sponsor substrate address687 * @param sponsorAddress Sponsor substrate address688 * @param label extra label for log688 * @param label extra label for log689 * @example setSponsor(aliceKeyring, 10, "5DyN4Y92vZCjv38fg...")689 * @example setSponsor(aliceKeyring, 10, "5DyN4Y92vZCjv38fg...")690 * @returns bool true on success690 * @returns ```true``` if extrinsic success, otherwise ```false```691 */691 */692 async setSponsor(signer: TSigner, collectionId: number, sponsorAddress: TSubstrateAccount, label?: string): Promise<boolean> {692 async setSponsor(signer: TSigner, collectionId: number, sponsorAddress: TSubstrateAccount, label?: string): Promise<boolean> {693 if(typeof label === 'undefined') label = `collection #${collectionId}`;693 if(typeof label === 'undefined') label = `collection #${collectionId}`;694 const result = await this.helper.executeExtrinsic(694 const result = await this.helper.executeExtrinsic(700 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionSponsorSet', label);700 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionSponsorSet', label);701 }701 }702702703 /**703 /**704 * Confirms consent to sponsor the collection on behalf of the signer.704 * Confirms consent to sponsor the collection on behalf of the signer.705 * 705 * 706 * @param signer keyring of signer706 * @param signer keyring of signer707 * @param collectionId ID of collection707 * @param collectionId ID of collection708 * @param label extra label for log708 * @param label extra label for log709 * @example confirmSponsorship(aliceKeyring, 10)709 * @example confirmSponsorship(aliceKeyring, 10)710 * @returns bool true on success710 * @returns ```true``` if extrinsic success, otherwise ```false```711 */711 */712 async confirmSponsorship(signer: TSigner, collectionId: number, label?: string): Promise<boolean> {712 async confirmSponsorship(signer: TSigner, collectionId: number, label?: string): Promise<boolean> {713 if(typeof label === 'undefined') label = `collection #${collectionId}`;713 if(typeof label === 'undefined') label = `collection #${collectionId}`;714 const result = await this.helper.executeExtrinsic(714 const result = await this.helper.executeExtrinsic(720 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'SponsorshipConfirmed', label);720 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'SponsorshipConfirmed', label);721 }721 }722722723 /**723 /**724 * Sets the limits of the collection. At least one limit must be specified for a correct call.724 * Sets the limits of the collection. At least one limit must be specified for a correct call.725 * 725 * 726 * @param signer keyring of signer726 * @param signer keyring of signer727 * @param collectionId ID of collection727 * @param collectionId ID of collection728 * @param limits collection limits object728 * @param limits collection limits object729 * @param label extra label for log729 * @param label extra label for log730 * @example730 * @example731 * await setLimits(731 * await setLimits(732 * aliceKeyring,732 * aliceKeyring,733 * 10,733 * 10,734 * {734 * {735 * sponsorTransferTimeout: 0,735 * sponsorTransferTimeout: 0,736 * ownerCanDestroy: false736 * ownerCanDestroy: false737 * }737 * }738 * )738 * )739 * @returns bool true on success739 * @returns ```true``` if extrinsic success, otherwise ```false```740 */740 */741 async setLimits(signer: TSigner, collectionId: number, limits: ICollectionLimits, label?: string): Promise<boolean> {741 async setLimits(signer: TSigner, collectionId: number, limits: ICollectionLimits, label?: string): Promise<boolean> {742 if(typeof label === 'undefined') label = `collection #${collectionId}`;742 if(typeof label === 'undefined') label = `collection #${collectionId}`;743 const result = await this.helper.executeExtrinsic(743 const result = await this.helper.executeExtrinsic(749 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionLimitSet', label);749 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionLimitSet', label);750 }750 }751751752 /**752 /**753 * Changes the owner of the collection to the new Substrate address.753 * Changes the owner of the collection to the new Substrate address.754 * 754 * 755 * @param signer keyring of signer755 * @param signer keyring of signer756 * @param collectionId ID of collection756 * @param collectionId ID of collection757 * @param ownerAddress substrate address of new owner757 * @param ownerAddress substrate address of new owner758 * @param label extra label for log758 * @param label extra label for log759 * @example changeOwner(aliceKeyring, 10, "5DyN4Y92vZCjv38fg...")759 * @example changeOwner(aliceKeyring, 10, "5DyN4Y92vZCjv38fg...")760 * @returns bool true on success760 * @returns ```true``` if extrinsic success, otherwise ```false```761 */761 */762 async changeOwner(signer: TSigner, collectionId: number, ownerAddress: TSubstrateAccount, label?: string): Promise<boolean> {762 async changeOwner(signer: TSigner, collectionId: number, ownerAddress: TSubstrateAccount, label?: string): Promise<boolean> {763 if(typeof label === 'undefined') label = `collection #${collectionId}`;763 if(typeof label === 'undefined') label = `collection #${collectionId}`;764 const result = await this.helper.executeExtrinsic(764 const result = await this.helper.executeExtrinsic(770 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionOwnedChanged', label);770 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionOwnedChanged', label);771 }771 }772772773 /**773 /**774 * Adds a collection administrator. 774 * Adds a collection administrator. 775 * 775 * 776 * @param signer keyring of signer776 * @param signer keyring of signer777 * @param collectionId ID of collection777 * @param collectionId ID of collection778 * @param adminAddressObj Administrator address (substrate or ethereum)778 * @param adminAddressObj Administrator address (substrate or ethereum)779 * @param label extra label for log779 * @param label extra label for log780 * @example addAdmin(aliceKeyring, 10, {Substrate: "5DyN4Y92vZCjv38fg..."})780 * @example addAdmin(aliceKeyring, 10, {Substrate: "5DyN4Y92vZCjv38fg..."})781 * @returns bool true on success781 * @returns ```true``` if extrinsic success, otherwise ```false```782 */782 */783 async addAdmin(signer: TSigner, collectionId: number, adminAddressObj: ICrossAccountId, label?: string): Promise<boolean> {783 async addAdmin(signer: TSigner, collectionId: number, adminAddressObj: ICrossAccountId, label?: string): Promise<boolean> {784 if(typeof label === 'undefined') label = `collection #${collectionId}`;784 if(typeof label === 'undefined') label = `collection #${collectionId}`;785 const result = await this.helper.executeExtrinsic(785 const result = await this.helper.executeExtrinsic(791 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionAdminAdded', label);791 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionAdminAdded', label);792 }792 }793793794 /**794 /**795 * Removes a collection administrator.795 * Removes a collection administrator.796 * 796 * 797 * @param signer keyring of signer797 * @param signer keyring of signer798 * @param collectionId ID of collection798 * @param collectionId ID of collection799 * @param adminAddressObj Administrator address (substrate or ethereum)799 * @param adminAddressObj Administrator address (substrate or ethereum)800 * @param label extra label for log800 * @param label extra label for log801 * @example removeAdmin(aliceKeyring, 10, {Substrate: "5DyN4Y92vZCjv38fg..."})801 * @example removeAdmin(aliceKeyring, 10, {Substrate: "5DyN4Y92vZCjv38fg..."})802 * @returns bool true on success802 * @returns ```true``` if extrinsic success, otherwise ```false```803 */803 */804 async removeAdmin(signer: TSigner, collectionId: number, adminAddressObj: ICrossAccountId, label?: string): Promise<boolean> {804 async removeAdmin(signer: TSigner, collectionId: number, adminAddressObj: ICrossAccountId, label?: string): Promise<boolean> {805 if(typeof label === 'undefined') label = `collection #${collectionId}`;805 if(typeof label === 'undefined') label = `collection #${collectionId}`;806 const result = await this.helper.executeExtrinsic(806 const result = await this.helper.executeExtrinsic(812 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionAdminRemoved', label);812 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionAdminRemoved', label);813 }813 }814814815 /**815 /**816 * Sets onchain permissions for selected collection.816 * Sets onchain permissions for selected collection.817 * 817 * 818 * @param signer keyring of signer818 * @param signer keyring of signer819 * @param collectionId ID of collection819 * @param collectionId ID of collection820 * @param permissions collection permissions object820 * @param permissions collection permissions object821 * @param label extra label for log821 * @param label extra label for log822 * @example setPermissions(aliceKeyring, 10, TODO);822 * @example setPermissions(aliceKeyring, 10, {access:'AllowList', mintMode: true, nesting: {collectionAdmin: true, tokenOwner: true}});823 * @returns bool true on success823 * @returns ```true``` if extrinsic success, otherwise ```false```824 */824 */825 async setPermissions(signer: TSigner, collectionId: number, permissions: ICollectionPermissions, label?: string): Promise<boolean> {825 async setPermissions(signer: TSigner, collectionId: number, permissions: ICollectionPermissions, label?: string): Promise<boolean> {826 if(typeof label === 'undefined') label = `collection #${collectionId}`;826 if(typeof label === 'undefined') label = `collection #${collectionId}`;827 const result = await this.helper.executeExtrinsic(827 const result = await this.helper.executeExtrinsic(833 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionPermissionSet', label);833 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionPermissionSet', label);834 }834 }835835836 /**836 /**837 * Enables nesting for selected collection. If `restricted` set, you can nest only tokens from specified collections.837 * Enables nesting for selected collection. If `restricted` set, you can nest only tokens from specified collections.838 * 838 * 839 * @param signer keyring of signer839 * @param signer keyring of signer840 * @param collectionId ID of collection840 * @param collectionId ID of collection841 * @param permissions nesting permissions object841 * @param permissions nesting permissions object842 * @param label extra label for log842 * @param label extra label for log843 * @example enableNesting(aliceKeyring, 10, TODO);843 * @example enableNesting(aliceKeyring, 10, {collectionAdmin: true, tokenOwner: true});844 * @returns bool true on success844 * @returns ```true``` if extrinsic success, otherwise ```false```845 */845 */846 async enableNesting(signer: TSigner, collectionId: number, permissions: INestingPermissions, label?: string): Promise<boolean> {846 async enableNesting(signer: TSigner, collectionId: number, permissions: INestingPermissions, label?: string): Promise<boolean> {847 return await this.setPermissions(signer, collectionId, {nesting: permissions}, label);847 return await this.setPermissions(signer, collectionId, {nesting: permissions}, label);848 }848 }849849850 /**850 /**851 * Disables nesting for selected collection.851 * Disables nesting for selected collection.852 * 852 * 853 * @param signer keyring of signer853 * @param signer keyring of signer854 * @param collectionId ID of collection854 * @param collectionId ID of collection855 * @param label extra label for log855 * @param label extra label for log856 * @example disableNesting(aliceKeyring, 10);856 * @example disableNesting(aliceKeyring, 10);857 * @returns bool true on success857 * @returns ```true``` if extrinsic success, otherwise ```false```858 */858 */859 async disableNesting(signer: TSigner, collectionId: number, label?: string): Promise<boolean> {859 async disableNesting(signer: TSigner, collectionId: number, label?: string): Promise<boolean> {860 return await this.setPermissions(signer, collectionId, {nesting: {tokenOwner: false, collectionAdmin: false}}, label);860 return await this.setPermissions(signer, collectionId, {nesting: {tokenOwner: false, collectionAdmin: false}}, label);861 }861 }862862863 /**863 /**864 * Sets onchain properties to the collection.864 * Sets onchain properties to the collection.865 * 865 * 866 * @param signer keyring of signer866 * @param signer keyring of signer867 * @param collectionId ID of collection867 * @param collectionId ID of collection868 * @param properties array of property objects868 * @param properties array of property objects869 * @param label extra label for log869 * @param label extra label for log870 * @example870 * @example setProperties(aliceKeyring, 10, [{key: "gender", value: "male"}]);871 * setProperties(aliceKeyring, 10, TODO)871 * @returns ```true``` if extrinsic success, otherwise ```false```872 * @returns bool true on success872 */873 */874 async setProperties(signer: TSigner, collectionId: number, properties: IProperty[], label?: string): Promise<boolean> {873 async setProperties(signer: TSigner, collectionId: number, properties: IProperty[], label?: string): Promise<boolean> {875 if(typeof label === 'undefined') label = `collection #${collectionId}`;874 if(typeof label === 'undefined') label = `collection #${collectionId}`;876 const result = await this.helper.executeExtrinsic(875 const result = await this.helper.executeExtrinsic(882 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'CollectionPropertySet', label);881 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'CollectionPropertySet', label);883 }882 }884883885 /**884 /**886 * Deletes onchain properties from the collection.885 * Deletes onchain properties from the collection.887 * 886 * 888 * @param signer keyring of signer887 * @param signer keyring of signer889 * @param collectionId ID of collection888 * @param collectionId ID of collection890 * @param propertyKeys array of property keys to delete889 * @param propertyKeys array of property keys to delete891 * @param label890 * @param label892 * @example deleteProperties(aliceKeyring, 10, TODO)891 * @example deleteProperties(aliceKeyring, 10, ["gender", "age"]);893 * @returns 892 * @returns ```true``` if extrinsic success, otherwise ```false```894 */893 */895 async deleteProperties(signer: TSigner, collectionId: number, propertyKeys: string[], label?: string): Promise<boolean> {894 async deleteProperties(signer: TSigner, collectionId: number, propertyKeys: string[], label?: string): Promise<boolean> {896 if(typeof label === 'undefined') label = `collection #${collectionId}`;895 if(typeof label === 'undefined') label = `collection #${collectionId}`;897 const result = await this.helper.executeExtrinsic(896 const result = await this.helper.executeExtrinsic(973 return {success: burnedTokens.success, token: burnedTokens.tokens.length > 0 ? burnedTokens.tokens[0] : null};972 return {success: burnedTokens.success, token: burnedTokens.tokens.length > 0 ? burnedTokens.tokens[0] : null};974 }973 }975974976 /**975 /**977 * Destroys a concrete instance of NFT on behalf of the owner976 * Destroys a concrete instance of NFT on behalf of the owner978 * 977 * 979 * @param signer keyring of signer978 * @param signer keyring of signer980 * @param collectionId ID of collection979 * @param collectionId ID of collection981 * @param fromAddressObj address on behalf of which the token will be burnt980 * @param fromAddressObj address on behalf of which the token will be burnt982 * @param tokenId ID of token981 * @param tokenId ID of token983 * @param label 982 * @param label 984 * @param amount amount of tokens to be burned. For NFT must be set to 1n983 * @param amount amount of tokens to be burned. For NFT must be set to 1n985 * @example burnTokenFrom(aliceKeyring, 10, {Substrate: "5DyN4Y92vZCjv38fg..."}, 5, {Ethereum: "0x9F0583DbB85..."})984 * @example burnTokenFrom(aliceKeyring, 10, {Substrate: "5DyN4Y92vZCjv38fg..."}, 5, {Ethereum: "0x9F0583DbB85..."})986 * @returns ```true``` if extrinsic success. Otherwise ```false```985 * @returns ```true``` if extrinsic success, otherwise ```false```987 */986 */988 async burnTokenFrom(signer: TSigner, collectionId: number, fromAddressObj: ICrossAccountId, tokenId: number, label?: string, amount=1n): Promise<boolean> {987 async burnTokenFrom(signer: TSigner, collectionId: number, fromAddressObj: ICrossAccountId, tokenId: number, label?: string, amount=1n): Promise<boolean> {989 if(typeof label === 'undefined') label = `collection #${collectionId}`;988 if(typeof label === 'undefined') label = `collection #${collectionId}`;990 const burnResult = await this.helper.executeExtrinsic(989 const burnResult = await this.helper.executeExtrinsic(996 return burnedTokens.success && burnedTokens.tokens.length > 0;995 return burnedTokens.success && burnedTokens.tokens.length > 0;997 }996 }998997999 /**998 /**1000 * Set, change, or remove approved address to transfer the ownership of the NFT.999 * Set, change, or remove approved address to transfer the ownership of the NFT.1001 * 1000 * 1002 * @param signer keyring of signer1001 * @param signer keyring of signer1003 * @param collectionId ID of collection1002 * @param collectionId ID of collection1004 * @param tokenId ID of token1003 * @param tokenId ID of token1005 * @param toAddressObj 1004 * @param toAddressObj 1006 * @param label 1005 * @param label 1007 * @param amount amount of token to be approved. For NFT must be set to 1n1006 * @param amount amount of token to be approved. For NFT must be set to 1n1008 * @returns ```true``` if extrinsic success. Otherwise ```false```1007 * @returns ```true``` if extrinsic success, otherwise ```false```1009 */1008 */1010 async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, label?: string, amount=1n) {1009 async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, label?: string, amount=1n) {1011 if(typeof label === 'undefined') label = `collection #${collectionId}`;1010 if(typeof label === 'undefined') label = `collection #${collectionId}`;1012 const approveResult = await this.helper.executeExtrinsic(1011 const approveResult = await this.helper.executeExtrinsic(1018 return this.helper.util.findCollectionInEvents(approveResult.result.events, collectionId, 'common', 'Approved', label);1017 return this.helper.util.findCollectionInEvents(approveResult.result.events, collectionId, 'common', 'Approved', label);1019 }1018 }102010191021 /**1020 /**1022 * TODO1021 * Get amount of RFT pieces approved to transfer1023 * @param collectionId ID of collection1022 * @param collectionId ID of collection1024 * @param tokenId ID of token1023 * @param tokenId ID of token1025 * @param toAccountObj 1024 * @param toAccountObj 1026 * @param fromAccountObj1025 * @param fromAccountObj1027 * @example getTokenApprovedPieces(10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."}, {Substrate: "5ERZNF88Mm7UGfPP3mdG..."})1026 * @example getTokenApprovedPieces(10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."}, {Substrate: "5ERZNF88Mm7UGfPP3mdG..."})1028 * @returns number of approved to transfer pieces1027 * @returns number of approved to transfer pieces1029 */1028 */1030 async getTokenApprovedPieces(collectionId: number, tokenId: number, toAccountObj: ICrossAccountId, fromAccountObj: ICrossAccountId): Promise<bigint> {1029 async getTokenApprovedPieces(collectionId: number, tokenId: number, toAccountObj: ICrossAccountId, fromAccountObj: ICrossAccountId): Promise<bigint> {1031 return (await this.helper.callRpc('api.rpc.unique.allowance', [collectionId, fromAccountObj, toAccountObj, tokenId])).toBigInt();1030 return (await this.helper.callRpc('api.rpc.unique.allowance', [collectionId, fromAccountObj, toAccountObj, tokenId])).toBigInt();1032 }1031 }1054}1053}105510541056class NFTnRFT extends CollectionGroup {1055class NFTnRFT extends CollectionGroup {1057 /**1056 /**1058 * Get tokens owned by account1057 * Get tokens owned by account1059 * 1058 * 1060 * @param collectionId ID of collection1059 * @param collectionId ID of collection1061 * @param addressObj tokens owner1060 * @param addressObj tokens owner1062 * @example getTokensByAddress(10, {Substrate: "5DyN4Y92vZCjv38fg..."})1061 * @example getTokensByAddress(10, {Substrate: "5DyN4Y92vZCjv38fg..."})1063 * @returns array of token ids owned by account TODO for RFT?1062 * @returns array of token ids owned by account1064 */1063 */1065 async getTokensByAddress(collectionId: number, addressObj: ICrossAccountId): Promise<number[]> {1064 async getTokensByAddress(collectionId: number, addressObj: ICrossAccountId): Promise<number[]> {1066 return (await this.helper.callRpc('api.rpc.unique.accountTokens', [collectionId, addressObj])).toJSON();1065 return (await this.helper.callRpc('api.rpc.unique.accountTokens', [collectionId, addressObj])).toJSON();1067 }1066 }106810671069 /**1068 /**1070 * Get token data1069 * Get token data1071 * @param collectionId ID of collection1070 * @param collectionId ID of collection1072 * @param tokenId ID of token1071 * @param tokenId ID of token1073 * @param blockHashAt 1072 * @param blockHashAt 1074 * @param propertyKeys TODO1073 * @param propertyKeys1075 * @example getToken(10, 5);1074 * @example getToken(10, 5);1076 * @returns human readable token data 1075 * @returns human readable token data 1077 */1076 */1078 async getToken(collectionId: number, tokenId: number, blockHashAt?: string, propertyKeys?: string[]): Promise<{1077 async getToken(collectionId: number, tokenId: number, blockHashAt?: string, propertyKeys?: string[]): Promise<{1079 properties: IProperty[];1078 properties: IProperty[];1080 owner: ICrossAccountId;1079 owner: ICrossAccountId;1124 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'PropertyPermissionSet', label);1123 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'PropertyPermissionSet', label);1125 }1124 }112611251127 /**1126 /**1128 * Set token properties1127 * Set token properties1129 * @param signer keyring of signer1128 * @param signer keyring of signer1130 * @param collectionId ID of collection1129 * @param collectionId ID of collection1131 * @param tokenId ID of token1130 * @param tokenId ID of token1132 * @param properties 1131 * @param properties 1133 * @param label 1132 * @param label 1134 * @example setTokenProperties(aliceKeyring, 10, 5, [{key: "gender", value: "female"}, {key: "age", value: "23"}])1133 * @example setTokenProperties(aliceKeyring, 10, 5, [{key: "gender", value: "female"}, {key: "age", value: "23"}])1135 * @returns true if extrinsic success, otherwise false1134 * @returns ```true``` if extrinsic success, otherwise ```false```1136 */1135 */1137 async setTokenProperties(signer: TSigner, collectionId: number, tokenId: number, properties: IProperty[], label?: string): Promise<boolean> {1136 async setTokenProperties(signer: TSigner, collectionId: number, tokenId: number, properties: IProperty[], label?: string): Promise<boolean> {1138 if(typeof label === 'undefined') label = `token #${tokenId} from collection #${collectionId}`;1137 if(typeof label === 'undefined') label = `token #${tokenId} from collection #${collectionId}`;1139 const result = await this.helper.executeExtrinsic(1138 const result = await this.helper.executeExtrinsic(1145 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'TokenPropertySet', label);1144 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'TokenPropertySet', label);1146 }1145 }114711461148 /**1147 /**1149 * Delete the provided properties of a token1148 * Delete the provided properties of a token1150 * @param signer keyring of signer1149 * @param signer keyring of signer1151 * @param collectionId ID of collection1150 * @param collectionId ID of collection1152 * @param tokenId ID of token1151 * @param tokenId ID of token1153 * @param propertyKeys property keys to be deleted 1152 * @param propertyKeys property keys to be deleted 1154 * @param label 1153 * @param label 1155 * @example deleteTokenProperties(aliceKeyring, 10, 5, ["gender", "age"])1154 * @example deleteTokenProperties(aliceKeyring, 10, 5, ["gender", "age"])1156 * @returns true if extrinsic success, otherwise false1155 * @returns ```true``` if extrinsic success, otherwise ```false```1157 */1156 */1158 async deleteTokenProperties(signer: TSigner, collectionId: number, tokenId: number, propertyKeys: string[], label?: string): Promise<boolean> {1157 async deleteTokenProperties(signer: TSigner, collectionId: number, tokenId: number, propertyKeys: string[], label?: string): Promise<boolean> {1159 if(typeof label === 'undefined') label = `token #${tokenId} from collection #${collectionId}`;1158 if(typeof label === 'undefined') label = `token #${tokenId} from collection #${collectionId}`;1160 const result = await this.helper.executeExtrinsic(1159 const result = await this.helper.executeExtrinsic(1166 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'TokenPropertyDeleted', label);1165 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'TokenPropertyDeleted', label);1167 }1166 }116811671169 /**1168 /**1170 * Mint new collection1169 * Mint new collection1171 * @param signer keyring of signer1170 * @param signer keyring of signer1172 * @param collectionOptions TODO1171 * @param collectionOptions basic collection options and properties 1173 * @param mode NFT or RFT type of a collection1172 * @param mode NFT or RFT type of a collection1174 * @param errorLabel 1173 * @param errorLabel 1175 * @example mintCollection(aliceKeyring, TODO, "NFT")1174 * @example mintCollection(aliceKeyring, {name: 'New', description: "New collection", tokenPrefix: "NEW"}, "NFT")1176 * @returns object of the created collection1175 * @returns object of the created collection1177 */1176 */1178 async mintCollection(signer: TSigner, collectionOptions: ICollectionCreationOptions, mode: 'NFT' | 'RFT', errorLabel = 'Unable to mint collection'): Promise<UniqueCollectionBase> {1177 async mintCollection(signer: TSigner, collectionOptions: ICollectionCreationOptions, mode: 'NFT' | 'RFT', errorLabel = 'Unable to mint collection'): Promise<UniqueCollectionBase> {1179 collectionOptions = JSON.parse(JSON.stringify(collectionOptions)) as ICollectionCreationOptions; // Clone object1178 collectionOptions = JSON.parse(JSON.stringify(collectionOptions)) as ICollectionCreationOptions; // Clone object1180 collectionOptions.mode = (mode === 'NFT') ? {nft: null} : {refungible: null};1179 collectionOptions.mode = (mode === 'NFT') ? {nft: null} : {refungible: null};1239 return crossAccountIdFromLower(owner.toJSON());1238 return crossAccountIdFromLower(owner.toJSON());1240 }1239 }124112401242 /**1241 /**1243 * Is token approved to transfer1242 * Is token approved to transfer1244 * @param collectionId ID of collection1243 * @param collectionId ID of collection1245 * @param tokenId ID of token1244 * @param tokenId ID of token1246 * @param toAccountObj TODO1245 * @param toAccountObj address to be approved1247 * @returns TODO 1246 * @returns ```true``` if extrinsic success, otherwise ```false```1248 */1247 */1249 async isTokenApproved(collectionId: number, tokenId: number, toAccountObj: ICrossAccountId): Promise<boolean> {1248 async isTokenApproved(collectionId: number, tokenId: number, toAccountObj: ICrossAccountId): Promise<boolean> {1250 return (await this.getTokenApprovedPieces(collectionId, tokenId, toAccountObj, await this.getTokenOwner(collectionId, tokenId))) === 1n;1249 return (await this.getTokenApprovedPieces(collectionId, tokenId, toAccountObj, await this.getTokenOwner(collectionId, tokenId))) === 1n;1251 }1250 }125212511253 /**1252 /**1254 * Changes the owner of the token.1253 * Changes the owner of the token.1255 * 1254 * 1256 * @param signer keyring of signer1255 * @param signer keyring of signer1257 * @param collectionId ID of collection1256 * @param collectionId ID of collection1258 * @param tokenId ID of token1257 * @param tokenId ID of token1259 * @param addressObj address of a new owner1258 * @param addressObj address of a new owner1260 * @example transferToken(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."})1259 * @example transferToken(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."})1261 * @returns true if extrinsic success, otherwise false1260 * @returns ```true``` if extrinsic success, otherwise ```false```1262 */1261 */1263 async transferToken(signer: TSigner, collectionId: number, tokenId: number, addressObj: ICrossAccountId): Promise<boolean> {1262 async transferToken(signer: TSigner, collectionId: number, tokenId: number, addressObj: ICrossAccountId): Promise<boolean> {1264 return await super.transferToken(signer, collectionId, tokenId, addressObj, 1n);1263 return await super.transferToken(signer, collectionId, tokenId, addressObj, 1n);1265 }1264 }126612651267 /**1266 /**1268 * 1267 * 1269 * Change ownership of a NFT on behalf of the owner. 1268 * Change ownership of a NFT on behalf of the owner. 1270 * 1269 * 1271 * @param signer keyring of signer1270 * @param signer keyring of signer1272 * @param collectionId ID of collection1271 * @param collectionId ID of collection1273 * @param tokenId ID of token1272 * @param tokenId ID of token1274 * @param fromAddressObj address on behalf of which the token will be sent1273 * @param fromAddressObj address on behalf of which the token will be sent1275 * @param toAddressObj new token owner1274 * @param toAddressObj new token owner1276 * @example transferTokenFrom(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."}, {Ethereum: "0x9F0583DbB85..."})1275 * @example transferTokenFrom(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."}, {Ethereum: "0x9F0583DbB85..."})1277 * @returns true if extrinsic success, otherwise false1276 * @returns ```true``` if extrinsic success, otherwise ```false```1278 */1277 */1279 async transferTokenFrom(signer: TSigner, collectionId: number, tokenId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId): Promise<boolean> {1278 async transferTokenFrom(signer: TSigner, collectionId: number, tokenId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId): Promise<boolean> {1280 return await super.transferTokenFrom(signer, collectionId, tokenId, fromAddressObj, toAddressObj, 1n);1279 return await super.transferTokenFrom(signer, collectionId, tokenId, fromAddressObj, toAddressObj, 1n);1281 }1280 }1324 });1323 });1325 }1324 }132613251327 /**1326 /**1328 * Nest one token into another1327 * Nest one token into another1329 * @param signer keyring of signer1328 * @param signer keyring of signer1330 * @param tokenObj token to be nested1329 * @param tokenObj token to be nested1331 * @param rootTokenObj token to be parent1330 * @param rootTokenObj token to be parent1332 * @param label 1331 * @param label 1333 * @example nestToken(aliceKeyring, {collectionId: 10, tokenId: 5}, {collectionId: 10, tokenId: 4});1332 * @example nestToken(aliceKeyring, {collectionId: 10, tokenId: 5}, {collectionId: 10, tokenId: 4});1334 * @returns true if extrinsic success, otherwise false1333 * @returns ```true``` if extrinsic success, otherwise ```false```1335 */1334 */1336 async nestToken(signer: TSigner, tokenObj: IToken, rootTokenObj: IToken, label='nest token'): Promise<boolean> {1335 async nestToken(signer: TSigner, tokenObj: IToken, rootTokenObj: IToken, label='nest token'): Promise<boolean> {1337 const rootTokenAddress = {Ethereum: this.helper.util.getNestingTokenAddress(rootTokenObj.collectionId, rootTokenObj.tokenId)};1336 const rootTokenAddress = {Ethereum: this.helper.util.getNestingTokenAddress(rootTokenObj.collectionId, rootTokenObj.tokenId)};1338 const result = await this.transferToken(signer, tokenObj.collectionId, tokenObj.tokenId, rootTokenAddress);1337 const result = await this.transferToken(signer, tokenObj.collectionId, tokenObj.tokenId, rootTokenAddress);1342 return result;1341 return result;1343 }1342 }134413431345 /**1344 /**1346 * Remove token from nested state1345 * Remove token from nested state1347 * @param signer keyring of signer1346 * @param signer keyring of signer1348 * @param tokenObj token to unnest1347 * @param tokenObj token to unnest1349 * @param rootTokenObj parent of a token1348 * @param rootTokenObj parent of a token1350 * @param toAddressObj address of a new token owner 1349 * @param toAddressObj address of a new token owner 1351 * @param label 1350 * @param label 1352 * @example unnestToken(aliceKeyring, {collectionId: 10, tokenId: 5}, {collectionId: 10, tokenId: 4}, {Substrate: "5DyN4Y92vZCjv38fg..."});1351 * @example unnestToken(aliceKeyring, {collectionId: 10, tokenId: 5}, {collectionId: 10, tokenId: 4}, {Substrate: "5DyN4Y92vZCjv38fg..."});1353 * @returns true if extrinsic success, otherwise false1352 * @returns ```true``` if extrinsic success, otherwise ```false```1354 */1353 */1355 async unnestToken(signer: TSigner, tokenObj: IToken, rootTokenObj: IToken, toAddressObj: ICrossAccountId, label='unnest token'): Promise<boolean> {1354 async unnestToken(signer: TSigner, tokenObj: IToken, rootTokenObj: IToken, toAddressObj: ICrossAccountId, label='unnest token'): Promise<boolean> {1356 const rootTokenAddress = {Ethereum: this.helper.util.getNestingTokenAddress(rootTokenObj.collectionId, rootTokenObj.tokenId)};1355 const rootTokenAddress = {Ethereum: this.helper.util.getNestingTokenAddress(rootTokenObj.collectionId, rootTokenObj.tokenId)};1357 const result = await this.transferTokenFrom(signer, tokenObj.collectionId, tokenObj.tokenId, rootTokenAddress, toAddressObj);1356 const result = await this.transferTokenFrom(signer, tokenObj.collectionId, tokenObj.tokenId, rootTokenAddress, toAddressObj);1402 return this.getTokenObject(data.collectionId, createdTokens.tokens[0].tokenId);1401 return this.getTokenObject(data.collectionId, createdTokens.tokens[0].tokenId);1403 }1402 }140414031405 /**1404 /**1406 * Mint multiple NFT tokens1405 * Mint multiple NFT tokens1407 * @param signer keyring of signer1406 * @param signer keyring of signer1408 * @param collectionId ID of collection1407 * @param collectionId ID of collection1409 * @param tokens array of tokens with owner and properties1408 * @param tokens array of tokens with owner and properties1410 * @param label 1409 * @param label 1411 * @example 1410 * @example 1412 * mintMultipleTokens(aliceKeyring, 10, [{1411 * mintMultipleTokens(aliceKeyring, 10, [{1413 * owner: {Substrate: "5DyN4Y92vZCjv38fg..."},1412 * owner: {Substrate: "5DyN4Y92vZCjv38fg..."},1414 * properties: [{key: "gender", value: "male"},{key: "age", value: "45"}],1413 * properties: [{key: "gender", value: "male"},{key: "age", value: "45"}],1415 * },{1414 * },{1416 * owner: {Ethereum: "0x9F0583DbB855d..."},1415 * owner: {Ethereum: "0x9F0583DbB855d..."},1417 * properties: [{key: "gender", value: "female"},{key: "age", value: "22"}],1416 * properties: [{key: "gender", value: "female"},{key: "age", value: "22"}],1418 * }]);1417 * }]);1419 * @returns true if extrinsic success, otherwise false1418 * @returns ```true``` if extrinsic success, otherwise ```false```1420 */1419 */1421 async mintMultipleTokens(signer: TSigner, collectionId: number, tokens: {owner: ICrossAccountId, properties?: IProperty[]}[], label?: string): Promise<UniqueNFTToken[]> {1420 async mintMultipleTokens(signer: TSigner, collectionId: number, tokens: {owner: ICrossAccountId, properties?: IProperty[]}[], label?: string): Promise<UniqueNFTToken[]> {1422 if(typeof label === 'undefined') label = `collection #${collectionId}`;1421 if(typeof label === 'undefined') label = `collection #${collectionId}`;1423 const creationResult = await this.helper.executeExtrinsic(1422 const creationResult = await this.helper.executeExtrinsic(1477 return await super.burnToken(signer, collectionId, tokenId, label, 1n);1476 return await super.burnToken(signer, collectionId, tokenId, label, 1n);1478 }1477 }147914781480 /**1479 /**1481 * Set, change, or remove approved address to transfer the ownership of the NFT.1480 * Set, change, or remove approved address to transfer the ownership of the NFT.1482 * 1481 * 1483 * @param signer keyring of signer1482 * @param signer keyring of signer1484 * @param collectionId ID of collection1483 * @param collectionId ID of collection1485 * @param tokenId ID of token1484 * @param tokenId ID of token1486 * @param toAddressObj address to approve1485 * @param toAddressObj address to approve1487 * @param label 1486 * @param label 1488 * @example approveToken(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."})1487 * @example approveToken(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."})1489 * @returns ```true``` if extrinsic success. Otherwise ```false```1488 * @returns ```true``` if extrinsic success, otherwise ```false```1490 */1489 */1491 async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, label?: string) {1490 async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, label?: string) {1492 return super.approveToken(signer, collectionId, tokenId, toAddressObj, label, 1n);1491 return super.approveToken(signer, collectionId, tokenId, toAddressObj, label, 1n);1493 }1492 }1539 return (await this.helper.callRpc('api.rpc.unique.balance', [collectionId, addressObj, tokenId])).toBigInt();1538 return (await this.helper.callRpc('api.rpc.unique.balance', [collectionId, addressObj, tokenId])).toBigInt();1540 }1539 }154115401542 /**1541 /**1543 * Transfer pieces of token to another address1542 * Transfer pieces of token to another address1544 * @param signer keyring of signer1543 * @param signer keyring of signer1545 * @param collectionId ID of collection1544 * @param collectionId ID of collection1546 * @param tokenId ID of token1545 * @param tokenId ID of token1547 * @param addressObj address of a new owner1546 * @param addressObj address of a new owner1548 * @param amount number of pieces to be transfered1547 * @param amount number of pieces to be transfered1549 * @example transferTokenFrom(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."}, 2000n)1548 * @example transferTokenFrom(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."}, 2000n)1550 * @returns true if extrinsic success, otherwise false1549 * @returns ```true``` if extrinsic success, otherwise ```false```1551 */1550 */1552 async transferToken(signer: TSigner, collectionId: number, tokenId: number, addressObj: ICrossAccountId, amount=100n): Promise<boolean> {1551 async transferToken(signer: TSigner, collectionId: number, tokenId: number, addressObj: ICrossAccountId, amount=100n): Promise<boolean> {1553 return await super.transferToken(signer, collectionId, tokenId, addressObj, amount);1552 return await super.transferToken(signer, collectionId, tokenId, addressObj, amount);1554 }1553 }155515541556 /**1555 /**1557 * Change ownership of some pieces of RFT on behalf of the owner. 1556 * Change ownership of some pieces of RFT on behalf of the owner. 1558 * @param signer keyring of signer1557 * @param signer keyring of signer1559 * @param collectionId ID of collection1558 * @param collectionId ID of collection1560 * @param tokenId ID of token1559 * @param tokenId ID of token1561 * @param fromAddressObj address on behalf of which the token will be sent1560 * @param fromAddressObj address on behalf of which the token will be sent1562 * @param toAddressObj new token owner1561 * @param toAddressObj new token owner1563 * @param amount number of pieces to be transfered1562 * @param amount number of pieces to be transfered1564 * @example transferTokenFrom(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."}, {Substrate: "5DfhbVfww7ThF8q6f3i..."}, 2000n)1563 * @example transferTokenFrom(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."}, {Substrate: "5DfhbVfww7ThF8q6f3i..."}, 2000n)1565 * @returns true if extrinsic success, otherwise false1564 * @returns ```true``` if extrinsic success, otherwise ```false```1566 */1565 */1567 async transferTokenFrom(signer: TSigner, collectionId: number, tokenId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId, amount=100n): Promise<boolean> {1566 async transferTokenFrom(signer: TSigner, collectionId: number, tokenId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId, amount=100n): Promise<boolean> {1568 return await super.transferTokenFrom(signer, collectionId, tokenId, fromAddressObj, toAddressObj, amount);1567 return await super.transferTokenFrom(signer, collectionId, tokenId, fromAddressObj, toAddressObj, amount);1569 }1568 }1754 return this.getCollectionObject(this.helper.util.extractCollectionIdFromCreationResult(creationResult, errorLabel));1753 return this.getCollectionObject(this.helper.util.extractCollectionIdFromCreationResult(creationResult, errorLabel));1755 }1754 }175617551757 /**1756 /**1758 * Mint tokens1757 * Mint tokens1759 * @param signer keyring of signer1758 * @param signer keyring of signer1760 * @param collectionId ID of collection1759 * @param collectionId ID of collection1761 * @param owner address owner of new tokens1760 * @param owner address owner of new tokens1762 * @param amount amount of tokens to be meanted1761 * @param amount amount of tokens to be meanted1763 * @param label 1762 * @param label 1764 * @example mintTokens(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq"}, 1000n);1763 * @example mintTokens(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq"}, 1000n);1765 * @returns ```true``` if extrinsic success. Otherwise ```false``` 1764 * @returns ```true``` if extrinsic success, otherwise ```false``` 1766 */1765 */1767 async mintTokens(signer: TSigner, collectionId: number, owner: ICrossAccountId | string, amount: bigint, label?: string): Promise<boolean> {1766 async mintTokens(signer: TSigner, collectionId: number, owner: ICrossAccountId | string, amount: bigint, label?: string): Promise<boolean> {1768 if(typeof label === 'undefined') label = `collection #${collectionId}`;1767 if(typeof label === 'undefined') label = `collection #${collectionId}`;1769 const creationResult = await this.helper.executeExtrinsic(1768 const creationResult = await this.helper.executeExtrinsic(1789 * @returns array of newly created RFT tokens1788 * @returns array of newly created RFT tokens1790 */1789 */179117901792 /**1791 /**1793 * Mint multiple Fungible tokens with one owner TODO For what??1792 * Mint multiple Fungible tokens with one owner1794 * @param signer keyring of signer1793 * @param signer keyring of signer1795 * @param collectionId ID of collection1794 * @param collectionId ID of collection1796 * @param owner tokens owner1795 * @param owner tokens owner1797 * @param tokens array of tokens with properties and pieces1796 * @param tokens array of tokens with properties and pieces1798 * @param label 1797 * @param label 1799 * @returns 1798 * @returns ```true``` if extrinsic success, otherwise ```false``` 1800 */1799 */1801 async mintMultipleTokensWithOneOwner(signer: TSigner, collectionId: number, owner: ICrossAccountId, tokens: {value: bigint}[], label?: string): Promise<boolean> {1800 async mintMultipleTokensWithOneOwner(signer: TSigner, collectionId: number, owner: ICrossAccountId, tokens: {value: bigint}[], label?: string): Promise<boolean> {1802 if(typeof label === 'undefined') label = `collection #${collectionId}`;1801 if(typeof label === 'undefined') label = `collection #${collectionId}`;1803 const rawTokens = [];1802 const rawTokens = [];1834 return (await this.helper.callRpc('api.rpc.unique.balance', [collectionId, addressObj, 0])).toBigInt();1833 return (await this.helper.callRpc('api.rpc.unique.balance', [collectionId, addressObj, 0])).toBigInt();1835 }1834 }183618351837 /**1836 /**1838 * Transfer tokens to address1837 * Transfer tokens to address1839 * @param signer keyring of signer1838 * @param signer keyring of signer1840 * @param collectionId ID of collection1839 * @param collectionId ID of collection1841 * @param toAddressObj address recepient1840 * @param toAddressObj address recepient1842 * @param amount amount of tokens to be sent1841 * @param amount amount of tokens to be sent1843 * @example transfer(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, 1000n);1842 * @example transfer(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, 1000n);1844 * @returns ```true``` if extrinsic success. Otherwise ```false``` 1843 * @returns ```true``` if extrinsic success, otherwise ```false``` 1845 */1844 */1846 async transfer(signer: TSigner, collectionId: number, toAddressObj: ICrossAccountId, amount: bigint) {1845 async transfer(signer: TSigner, collectionId: number, toAddressObj: ICrossAccountId, amount: bigint) {1847 return await super.transferToken(signer, collectionId, 0, toAddressObj, amount);1846 return await super.transferToken(signer, collectionId, 0, toAddressObj, amount);1848 }1847 }184918481850 /**1849 /**1851 * Transfer some tokens on behalf of the owner.1850 * Transfer some tokens on behalf of the owner.1852 * @param signer keyring of signer1851 * @param signer keyring of signer1853 * @param collectionId ID of collection1852 * @param collectionId ID of collection1854 * @param fromAddressObj address on behalf of which tokens will be sent1853 * @param fromAddressObj address on behalf of which tokens will be sent1855 * @param toAddressObj address where token to be sent1854 * @param toAddressObj address where token to be sent1856 * @param amount number of tokens to be sent1855 * @param amount number of tokens to be sent1857 * @example transferFrom(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, {Substrate: "5DfhbVfww7ThF8q6f3ij..."}, 10000n);1856 * @example transferFrom(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, {Substrate: "5DfhbVfww7ThF8q6f3ij..."}, 10000n);1858 * @returns ```true``` if extrinsic success. Otherwise ```false``` 1857 * @returns ```true``` if extrinsic success, otherwise ```false``` 1859 */1858 */1860 async transferFrom(signer: TSigner, collectionId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId, amount: bigint) {1859 async transferFrom(signer: TSigner, collectionId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId, amount: bigint) {1861 return await super.transferTokenFrom(signer, collectionId, 0, fromAddressObj, toAddressObj, amount);1860 return await super.transferTokenFrom(signer, collectionId, 0, fromAddressObj, toAddressObj, amount);1862 }1861 }186318621864 /**1863 /**1865 * Destroy some amount of tokens1864 * Destroy some amount of tokens1866 * @param signer keyring of signer1865 * @param signer keyring of signer1867 * @param collectionId ID of collection1866 * @param collectionId ID of collection1868 * @param amount amount of tokens to be destroyed1867 * @param amount amount of tokens to be destroyed1869 * @param label 1868 * @param label 1870 * @example burnTokens(aliceKeyring, 10, 1000n);1869 * @example burnTokens(aliceKeyring, 10, 1000n);1871 * @returns ```true``` if extrinsic success. Otherwise ```false``` 1870 * @returns ```true``` if extrinsic success, otherwise ```false``` 1872 */1871 */1873 async burnTokens(signer: IKeyringPair, collectionId: number, amount=100n, label?: string): Promise<boolean> {1872 async burnTokens(signer: IKeyringPair, collectionId: number, amount=100n, label?: string): Promise<boolean> {1874 return (await super.burnToken(signer, collectionId, 0, label, amount)).success;1873 return (await super.burnToken(signer, collectionId, 0, label, amount)).success;1875 }1874 }187618751877 /**1876 /**1878 * Burn some tokens on behalf of the owner.1877 * Burn some tokens on behalf of the owner.1879 * @param signer keyring of signer1878 * @param signer keyring of signer1880 * @param collectionId ID of collection1879 * @param collectionId ID of collection1881 * @param fromAddressObj address on behalf of which tokens will be burnt1880 * @param fromAddressObj address on behalf of which tokens will be burnt1882 * @param amount amount of tokens to be burnt1881 * @param amount amount of tokens to be burnt1883 * @param label 1882 * @param label 1884 * @example burnTokensFrom(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, 1000n);1883 * @example burnTokensFrom(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, 1000n);1885 * @returns ```true``` if extrinsic success. Otherwise ```false``` 1884 * @returns ```true``` if extrinsic success, otherwise ```false``` 1886 */1885 */1887 async burnTokensFrom(signer: IKeyringPair, collectionId: number, fromAddressObj: ICrossAccountId, amount=100n, label?: string): Promise<boolean> {1886 async burnTokensFrom(signer: IKeyringPair, collectionId: number, fromAddressObj: ICrossAccountId, amount=100n, label?: string): Promise<boolean> {1888 return await super.burnTokenFrom(signer, collectionId, fromAddressObj, 0, label, amount);1887 return await super.burnTokenFrom(signer, collectionId, fromAddressObj, 0, label, amount);1889 }1888 }189018891891 /**1890 /**1892 * TODO for what?1891 * 1893 * @param collectionId 1892 * @param collectionId 1894 * @returns 1893 * @returns 1895 */1894 */1896 async getTotalPieces(collectionId: number): Promise<bigint> {1895 async getTotalPieces(collectionId: number): Promise<bigint> {1897 return (await this.helper.callRpc('api.rpc.unique.totalPieces', [collectionId, 0])).unwrap().toBigInt();1896 return (await this.helper.callRpc('api.rpc.unique.totalPieces', [collectionId, 0])).unwrap().toBigInt();1898 }1897 }189918981900 /**1899 /**1901 * Set, change, or remove approved address to transfer tokens.1900 * Set, change, or remove approved address to transfer tokens.1902 * 1901 * 1903 * @param signer keyring of signer1902 * @param signer keyring of signer1904 * @param collectionId ID of collection1903 * @param collectionId ID of collection1905 * @param toAddressObj address to be approved1904 * @param toAddressObj address to be approved1906 * @param amount amount of tokens to be approved1905 * @param amount amount of tokens to be approved1907 * @param label 1906 * @param label 1908 * @example approveTokens(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, 1000n)1907 * @example approveTokens(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, 1000n)1909 * @returns ```true``` if extrinsic success. Otherwise ```false``` 1908 * @returns ```true``` if extrinsic success, otherwise ```false``` 1910 */1909 */1911 async approveTokens(signer: IKeyringPair, collectionId: number, toAddressObj: ICrossAccountId, amount=100n, label?: string) {1910 async approveTokens(signer: IKeyringPair, collectionId: number, toAddressObj: ICrossAccountId, amount=100n, label?: string) {1912 return super.approveToken(signer, collectionId, 0, toAddressObj, label, amount);1911 return super.approveToken(signer, collectionId, 0, toAddressObj, label, amount);1913 }1912 }191419131915 /**1914 /**1916 * TODO why pieces??1915 * Get amount of fungible tokens approved to transfer1917 * @param collectionId 1916 * @param collectionId ID of collection1918 * @param fromAddressObj 1917 * @param fromAddressObj owner of tokens1919 * @param toAddressObj 1918 * @param toAddressObj the address approved for the transfer of tokens on behalf of the owner1920 * @returns 1919 * @returns number of tokens approved for the transfer1921 */1920 */1922 async getApprovedTokens(collectionId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId) {1921 async getApprovedTokens(collectionId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId) {1923 return super.getTokenApprovedPieces(collectionId, 0, toAddressObj, fromAddressObj);1922 return super.getTokenApprovedPieces(collectionId, 0, toAddressObj, fromAddressObj);1924 }1923 }1999 return (await this.helper.callRpc('api.rpc.eth.getBalance', [address])).toBigInt();1998 return (await this.helper.callRpc('api.rpc.eth.getBalance', [address])).toBigInt();2000 }1999 }200120002002 /**2001 /**2003 * Transfer tokens to substrate address2002 * Transfer tokens to substrate address2004 * @param signer keyring of signer2003 * @param signer keyring of signer2005 * @param address substrate address of a recepient2004 * @param address substrate address of a recepient2006 * @param amount amount of tokens to be transfered2005 * @param amount amount of tokens to be transfered2007 * @example transferToSubstrate(aliceKeyring, "5GrwvaEF5zXb26Fz...", 100_000_000_000n);2006 * @example transferToSubstrate(aliceKeyring, "5GrwvaEF5zXb26Fz...", 100_000_000_000n);2008 * @returns true if extrinsic success, otherwise false2007 * @returns ```true``` if extrinsic success, otherwise ```false```2009 */2008 */2010 async transferToSubstrate(signer: TSigner, address: TSubstrateAccount, amount: bigint | string): Promise<boolean> {2009 async transferToSubstrate(signer: TSigner, address: TSubstrateAccount, amount: bigint | string): Promise<boolean> {2011 const result = await this.helper.executeExtrinsic(signer, 'api.tx.balances.transfer', [address, amount], true, `Unable to transfer balance from ${this.helper.getSignerAddress(signer)} to ${address}`);2010 const result = await this.helper.executeExtrinsic(signer, 'api.tx.balances.transfer', [address, amount], true, `Unable to transfer balance from ${this.helper.getSignerAddress(signer)} to ${address}`);20122011