git.delta.rocks / unique-network / refs/commits / e1ae4a6cdf40

difftreelog

add collection allow-list methods to playgrounds

Max Andreev2022-08-24parent: #15ab591.patch.diff
in: master

1 file changed

modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
524 return normalized;524 return normalized;
525 }525 }
526
527 /**
528 * Get the normalized addresses added to the collection allow-list.
529 * @param collectionId ID of collection
530 * @example await getAllowList(1)
531 * @returns array of allow-listed addresses
532 */
533 async getAllowList(collectionId: number): Promise<ICrossAccountId[]> {
534 const normalized = [];
535 const allowListed = (await this.helper.callRpc('api.rpc.unique.allowlist', [collectionId])).toHuman();
536 for (const address of allowListed) {
537 if (address.Substrate) normalized.push({Substrate: this.helper.address.normalizeSubstrate(address.Substrate)});
538 else normalized.push(address);
539 }
540 return normalized;
541 }
526542
527 /**543 /**
528 * Get the effective limits of the collection instead of null for default values544 * Get the effective limits of the collection instead of null for default values
667 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionAdminAdded', label);683 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'CollectionAdminAdded', label);
668 }684 }
685
686 /**
687 * Adds an address to allow list
688 * @param signer keyring of signer
689 * @param collectionId ID of collection
690 * @param addressObj address to add to the allow list
691 * @param label extra label for log
692 * @returns ```true``` if extrinsic success, otherwise ```false```
693 */
694 async addToAllowList(signer: TSigner, collectionId: number, addressObj: ICrossAccountId, label?: string): Promise<boolean> {
695 if(typeof label === 'undefined') label = `collection #${collectionId}`;
696 const result = await this.helper.executeExtrinsic(
697 signer,
698 'api.tx.unique.addToAllowList', [collectionId, addressObj],
699 true, `Unable to add address to allow list for ${label}`,
700 );
701
702 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'unique', 'AllowListAddressAdded');
703 }
669704
670 /**705 /**
671 * Removes a collection administrator.706 * Removes a collection administrator.
1992 return await this.helper.collection.getAdmins(this.collectionId);2027 return await this.helper.collection.getAdmins(this.collectionId);
1993 }2028 }
2029
2030 async getAllowList() {
2031 return await this.helper.collection.getAllowList(this.collectionId);
2032 }
19942033
1995 async getEffectiveLimits() {2034 async getEffectiveLimits() {
1996 return await this.helper.collection.getEffectiveLimits(this.collectionId);2035 return await this.helper.collection.getEffectiveLimits(this.collectionId);
2016 return await this.helper.collection.addAdmin(signer, this.collectionId, adminAddressObj, label);2055 return await this.helper.collection.addAdmin(signer, this.collectionId, adminAddressObj, label);
2017 }2056 }
2057
2058 async addToAllowList(signer: TSigner, addressObj: ICrossAccountId, label?: string) {
2059 return await this.helper.collection.addToAllowList(signer, this.collectionId, addressObj, label);
2060 }
20182061
2019 async removeAdmin(signer: TSigner, adminAddressObj: ICrossAccountId, label?: string) {2062 async removeAdmin(signer: TSigner, adminAddressObj: ICrossAccountId, label?: string) {
2020 return await this.helper.collection.removeAdmin(signer, this.collectionId, adminAddressObj, label);2063 return await this.helper.collection.removeAdmin(signer, this.collectionId, adminAddressObj, label);