difftreelog
wip collectionAdmin migrating
in: master
1 file changed
tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth13// You should have received a copy of the GNU General Public License13// You should have received a copy of the GNU General Public License14// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.14// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.151516import {expect} from 'chai';16import {IKeyringPair} from '@polkadot/types/types';17import privateKey from '../substrate/privateKey';17import privateKey from '../substrate/privateKey';18import {UNIQUE} from '../util/helpers';18import {UNIQUE} from '../util/helpers';19import {19import {25 itWeb3,25 itWeb3,26 recordEthFee,26 recordEthFee,27} from './util/helpers';27} from './util/helpers';28import {usingEthPlaygrounds, itEth, expect} from './util/playgrounds';282929describe('Add collection admins', () => {30describe('Add collection admins', () => {31 let donor: IKeyringPair;3233 before(async function() {34 await usingEthPlaygrounds(async (_helper, privateKey) => {35 donor = privateKey('//Alice');36 });37 });3830 itWeb3('Add admin by owner', async ({api, web3, privateKeyWrapper}) => {39 itEth('Add admin by owner', async ({helper}) => {31 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);40 const owner = await helper.eth.createAccountWithBalance(donor);32 const collectionHelper = evmCollectionHelpers(web3, owner);33 34 const result = await collectionHelper.methods41 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');35 .createNonfungibleCollection('A', 'B', 'C')36 .send();37 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);42 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);384339 const newAdmin = createEthAccount(web3);44 const newAdmin = helper.eth.createAccount();40 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);4541 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();46 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();42 const adminList = await api.rpc.unique.adminlist(collectionId);47 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);43 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())48 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())44 .to.be.eq(newAdmin.toLocaleLowerCase());49 .to.be.eq(newAdmin.toLocaleLowerCase());45 });50 });465147 itWeb3('Add substrate admin by owner', async ({api, web3, privateKeyWrapper}) => {52 itEth('Add substrate admin by owner', async ({helper}) => {48 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);53 const owner = await helper.eth.createAccountWithBalance(donor);49 const collectionHelper = evmCollectionHelpers(web3, owner);50 51 const result = await collectionHelper.methods54 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');52 .createNonfungibleCollection('A', 'B', 'C')53 .send();54 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);55 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);555656 const newAdmin = privateKeyWrapper('//Alice');57 const [newAdmin] = await helper.arrange.createAccounts([10n], donor);57 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);58 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();58 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();595960 const adminList = await api.rpc.unique.adminlist(collectionId);60 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);61 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())61 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())62 .to.be.eq(newAdmin.address.toLocaleLowerCase());62 .to.be.eq(newAdmin.address.toLocaleLowerCase());63 });63 });