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

difftreelog

wip collectionAdmin migrating

rkv2022-09-26parent: #bebe784.patch.diff
in: master

1 file changed

modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
13// You should have received a copy of the GNU General Public License13// You should have received a copy of the GNU General Public License
14// 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/>.
1515
16import {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';
2829
29describe('Add collection admins', () => {30describe('Add collection admins', () => {
31 let donor: IKeyringPair;
32
33 before(async function() {
34 await usingEthPlaygrounds(async (_helper, privateKey) => {
35 donor = privateKey('//Alice');
36 });
37 });
38
30 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);
3843
39 const newAdmin = createEthAccount(web3);44 const newAdmin = helper.eth.createAccount();
40 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);45
41 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 });
4651
47 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);
5556
56 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();
5959
60 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 });