1234import {expect} from 'chai';5import privateKey from '../substrate/privateKey';6import {7 createEthAccount,8 createEthAccountWithBalance, 9 evmCollection, 10 evmCollectionHelpers, 11 getCollectionAddressFromResult, 12 itWeb3,13} from './util/helpers';141516171819202122232425262728describe.only('Add collection admins', () => {29 itWeb3('Add admin by owner', async ({api, web3}) => {30 const owner = await createEthAccountWithBalance(api, web3);31 const collectionHelper = evmCollectionHelpers(web3, owner);32 33 const result = await collectionHelper.methods34 .createNonfungibleCollection('A', 'B', 'C')35 .send();36 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);3738 const newAdmin = await createEthAccount(web3);39 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);40 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();41 const adminList = await api.rpc.unique.adminlist(collectionId);42 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())43 .to.be.eq(newAdmin.toLocaleLowerCase());44 });4546 itWeb3('Add substrate admin by owner', async ({api, web3}) => {47 const owner = await createEthAccountWithBalance(api, web3);48 const collectionHelper = evmCollectionHelpers(web3, owner);49 50 const result = await collectionHelper.methods51 .createNonfungibleCollection('A', 'B', 'C')52 .send();53 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);5455 const newAdmin = privateKey('//Alice');56 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);57 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();58 const adminList = await api.rpc.unique.adminlist(collectionId);59 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())60 .to.be.eq(newAdmin.address.toLocaleLowerCase());61 });6263 itWeb3('(!negative tests!) Add admin by admin is not allowed', async ({api, web3}) => {64 const owner = await createEthAccountWithBalance(api, web3);65 const collectionHelper = evmCollectionHelpers(web3, owner);66 67 const result = await collectionHelper.methods68 .createNonfungibleCollection('A', 'B', 'C')69 .send();70 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);7172 const admin = await createEthAccountWithBalance(api, web3);73 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);74 await collectionEvm.methods.addCollectionAdmin(admin).send();75 {76 const adminList = await api.rpc.unique.adminlist(collectionId);77 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())78 .to.be.eq(admin.toLocaleLowerCase());79 }80 81 const user = await createEthAccount(web3);82 await collectionEvm.methods.addCollectionAdmin(user).send({from: admin});83 const adminList = await api.rpc.unique.adminlist(collectionId);84 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())85 .to.be.eq(admin.toLocaleLowerCase());86 expect(adminList.length).to.be.eq(1);87 });88});