difftreelog
wip collectionAdmin to be fixed
in: master
1 file changed
tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth14// 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 {IKeyringPair} from '@polkadot/types/types';16import {IKeyringPair} from '@polkadot/types/types';17import privateKey from '../substrate/privateKey';18import {UNIQUE} from '../util/helpers';17import {UNIQUE} from '../util/helpers';19import {18import {20 createEthAccount,21 createEthAccountWithBalance,22 evmCollection,23 evmCollectionHelpers,24 getCollectionAddressFromResult,25 itWeb3,26 recordEthFee,19 recordEthFee,27} from './util/helpers';20} from './util/helpers';28import {usingEthPlaygrounds, itEth, expect} from './util/playgrounds';21import {usingEthPlaygrounds, itEth, expect} from './util/playgrounds';62 .to.be.eq(newAdmin.address.toLocaleLowerCase());55 .to.be.eq(newAdmin.address.toLocaleLowerCase());63 });56 });645758 //FIXME:65 itWeb3('Verify owner or admin', async ({api, web3, privateKeyWrapper}) => {59 itEth('Verify owner or admin', async ({helper}) => {66 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);60 const owner = await helper.eth.createAccountWithBalance(donor);67 const collectionHelper = evmCollectionHelpers(web3, owner);6869 const result = await collectionHelper.methods61 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');70 .createNonfungibleCollection('A', 'B', 'C')71 .send();72 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);736274 const newAdmin = createEthAccount(web3);63 const newAdmin = helper.eth.createAccount();75 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);64 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);76 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.false;65 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.false;77 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();66 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();78 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;67 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;79 });68 });806981 itWeb3('(!negative tests!) Add admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {70 itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {82 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);83 const collectionHelper = evmCollectionHelpers(web3, owner);8485 const result = await collectionHelper.methods71 const owner = await helper.eth.createAccountWithBalance(donor);86 .createNonfungibleCollection('A', 'B', 'C')87 .send();88 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);72 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');897390 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);74 const admin = await helper.eth.createAccountWithBalance(donor);91 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);75 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);92 await collectionEvm.methods.addCollectionAdmin(admin).send();76 await collectionEvm.methods.addCollectionAdmin(admin).send();937794 const user = createEthAccount(web3);78 const user = helper.eth.createAccount();95 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))79 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))96 .to.be.rejectedWith('NoPermission');80 .to.be.rejectedWith('NoPermission');978198 const adminList = await api.rpc.unique.adminlist(collectionId);82 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);99 expect(adminList.length).to.be.eq(1);83 expect(adminList.length).to.be.eq(1);100 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())84 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())101 .to.be.eq(admin.toLocaleLowerCase());85 .to.be.eq(admin.toLocaleLowerCase());102 });86 });10387104 itWeb3('(!negative tests!) Add admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {88 itEth('(!negative tests!) Add admin by USER is not allowed', async ({helper}) => {105 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);106 const collectionHelper = evmCollectionHelpers(web3, owner);107108 const result = await collectionHelper.methods89 const owner = await helper.eth.createAccountWithBalance(donor);109 .createNonfungibleCollection('A', 'B', 'C')110 .send();111 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);90 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');11291113 const notAdmin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);92 const notAdmin = await helper.eth.createAccountWithBalance(donor);114 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);93 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);11594116 const user = createEthAccount(web3);95 const user = helper.eth.createAccount();117 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))96 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))118 .to.be.rejectedWith('NoPermission');97 .to.be.rejectedWith('NoPermission');11998120 const adminList = await api.rpc.unique.adminlist(collectionId);99 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);121 expect(adminList.length).to.be.eq(0);100 expect(adminList.length).to.be.eq(0);122 });101 });123102124 itWeb3('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {103 itEth('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({helper}) => {125 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);126 const collectionHelper = evmCollectionHelpers(web3, owner);127128 const result = await collectionHelper.methods104 const owner = await helper.eth.createAccountWithBalance(donor);129 .createNonfungibleCollection('A', 'B', 'C')130 .send();131 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);105 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');132106133 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);107 const admin = await helper.eth.createAccountWithBalance(donor);134 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);108 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);135 await collectionEvm.methods.addCollectionAdmin(admin).send();109 await collectionEvm.methods.addCollectionAdmin(admin).send();136110137 const notAdmin = privateKey('//Alice');111 const [notAdmin] = await helper.arrange.createAccounts([10n], donor);138 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))112 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))139 .to.be.rejectedWith('NoPermission');113 .to.be.rejectedWith('NoPermission');140114141 const adminList = await api.rpc.unique.adminlist(collectionId);115 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);142 expect(adminList.length).to.be.eq(1);116 expect(adminList.length).to.be.eq(1);143 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())117 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())144 .to.be.eq(admin.toLocaleLowerCase());118 .to.be.eq(admin.toLocaleLowerCase());145 });119 });146120147 itWeb3('(!negative tests!) Add substrate admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {121 itEth('(!negative tests!) Add substrate admin by USER is not allowed', async ({helper}) => {148 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);149 const collectionHelper = evmCollectionHelpers(web3, owner);150151 const result = await collectionHelper.methods122 const owner = await helper.eth.createAccountWithBalance(donor);152 .createNonfungibleCollection('A', 'B', 'C')153 .send();154 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);123 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');155124156 const notAdmin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);125 const notAdmin0 = await helper.eth.createAccountWithBalance(donor);157 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);126 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);158 const notAdmin1 = privateKey('//Alice');127 const [notAdmin1] = await helper.arrange.createAccounts([10n], donor);159 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))128 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))160 .to.be.rejectedWith('NoPermission');129 .to.be.rejectedWith('NoPermission');161130162 const adminList = await api.rpc.unique.adminlist(collectionId);131 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);163 expect(adminList.length).to.be.eq(0);132 expect(adminList.length).to.be.eq(0);164 });133 });165});134});166135167describe('Remove collection admins', () => {136describe('Remove collection admins', () => {137 let donor: IKeyringPair;138139 before(async function() {140 await usingEthPlaygrounds(async (_helper, privateKey) => {141 donor = privateKey('//Alice');142 });143 });144168 itWeb3('Remove admin by owner', async ({api, web3, privateKeyWrapper}) => {145 itEth('Remove admin by owner', async ({helper}) => {169 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);170 const collectionHelper = evmCollectionHelpers(web3, owner);171172 const result = await collectionHelper.methods146 const owner = await helper.eth.createAccountWithBalance(donor);173 .createNonfungibleCollection('A', 'B', 'C')174 .send();175 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);147 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');176148177 const newAdmin = createEthAccount(web3);149 const newAdmin = helper.eth.createAccount();178 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);150 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);179 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();151 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();152180 {153 {181 const adminList = await api.rpc.unique.adminlist(collectionId);154 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);182 expect(adminList.length).to.be.eq(1);155 expect(adminList.length).to.be.eq(1);183 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())156 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())184 .to.be.eq(newAdmin.toLocaleLowerCase());157 .to.be.eq(newAdmin.toLocaleLowerCase());185 }158 }186159187 await collectionEvm.methods.removeCollectionAdmin(newAdmin).send();160 await collectionEvm.methods.removeCollectionAdmin(newAdmin).send();188 const adminList = await api.rpc.unique.adminlist(collectionId);161 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);189 expect(adminList.length).to.be.eq(0);162 expect(adminList.length).to.be.eq(0);190 });163 });191164192 itWeb3('Remove substrate admin by owner', async ({api, web3, privateKeyWrapper}) => {165 itEth('Remove substrate admin by owner', async ({helper}) => {193 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);166 const owner = await helper.eth.createAccountWithBalance(donor);194 const collectionHelper = evmCollectionHelpers(web3, owner);195196 const result = await collectionHelper.methods167 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');197 .createNonfungibleCollection('A', 'B', 'C')168198 .send();199 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);169 const [newAdmin] = await helper.arrange.createAccounts([10n], donor);200201 const newAdmin = privateKeyWrapper('//Alice');202 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);170 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);203 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();171 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();204 {172 {205 const adminList = await api.rpc.unique.adminlist(collectionId);173 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);206 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())174 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())207 .to.be.eq(newAdmin.address.toLocaleLowerCase());175 .to.be.eq(newAdmin.address.toLocaleLowerCase());208 }176 }209177210 await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();178 await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();211 const adminList = await api.rpc.unique.adminlist(collectionId);179 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);212 expect(adminList.length).to.be.eq(0);180 expect(adminList.length).to.be.eq(0);213 });181 });214182215 itWeb3('(!negative tests!) Remove admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {183 itEth('(!negative tests!) Remove admin by ADMIN is not allowed', async ({helper}) => {216 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);217 const collectionHelper = evmCollectionHelpers(web3, owner);218219 const result = await collectionHelper.methods184 const owner = await helper.eth.createAccountWithBalance(donor);220 .createNonfungibleCollection('A', 'B', 'C')221 .send();222 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);185 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');223186224 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);187 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);225188226 const admin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);189 const admin0 = await helper.eth.createAccountWithBalance(donor);227 await collectionEvm.methods.addCollectionAdmin(admin0).send();190 await collectionEvm.methods.addCollectionAdmin(admin0).send();228 const admin1 = createEthAccount(web3);191 const admin1 = await helper.eth.createAccountWithBalance(donor);229 await collectionEvm.methods.addCollectionAdmin(admin1).send();192 await collectionEvm.methods.addCollectionAdmin(admin1).send();230193231 await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))194 await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))232 .to.be.rejectedWith('NoPermission');195 .to.be.rejectedWith('NoPermission');233 {196 {234 const adminList = await api.rpc.unique.adminlist(collectionId);197 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);235 expect(adminList.length).to.be.eq(2);198 expect(adminList.length).to.be.eq(2);236 expect(adminList.toString().toLocaleLowerCase())199 expect(adminList.toString().toLocaleLowerCase())237 .to.be.deep.contains(admin0.toLocaleLowerCase())200 .to.be.deep.contains(admin0.toLocaleLowerCase())238 .to.be.deep.contains(admin1.toLocaleLowerCase());201 .to.be.deep.contains(admin1.toLocaleLowerCase());239 }202 }240 });203 });241204242 itWeb3('(!negative tests!) Remove admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {205 itEth('(!negative tests!) Remove admin by USER is not allowed', async ({helper}) => {243 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);244 const collectionHelper = evmCollectionHelpers(web3, owner);245246 const result = await collectionHelper.methods206 const owner = await helper.eth.createAccountWithBalance(donor);247 .createNonfungibleCollection('A', 'B', 'C')248 .send();249 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);207 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');250208251 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);209 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);252210253 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);211 const admin = await helper.eth.createAccountWithBalance(donor);254 await collectionEvm.methods.addCollectionAdmin(admin).send();212 await collectionEvm.methods.addCollectionAdmin(admin).send();255 const notAdmin = createEthAccount(web3);213 const notAdmin = helper.eth.createAccount();256214257 await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))215 await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))258 .to.be.rejectedWith('NoPermission');216 .to.be.rejectedWith('NoPermission');259 {217 {260 const adminList = await api.rpc.unique.adminlist(collectionId);218 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);261 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())219 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())262 .to.be.eq(admin.toLocaleLowerCase());220 .to.be.eq(admin.toLocaleLowerCase());263 expect(adminList.length).to.be.eq(1);221 expect(adminList.length).to.be.eq(1);264 }222 }265 });223 });266224267 itWeb3('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {225 itEth('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({helper}) => {268 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);226 const owner = await helper.eth.createAccountWithBalance(donor);269 const collectionHelper = evmCollectionHelpers(web3, owner);270271 const result = await collectionHelper.methods227 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');272 .createNonfungibleCollection('A', 'B', 'C')228273 .send();274 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);229 const [adminSub] = await helper.arrange.createAccounts([10n], donor);275276 const adminSub = privateKeyWrapper('//Alice');277 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);230 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);278 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();231 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();279 const adminEth = await createEthAccountWithBalance(api, web3, privateKeyWrapper);232 const adminEth = await helper.eth.createAccountWithBalance(donor);280 await collectionEvm.methods.addCollectionAdmin(adminEth).send();233 await collectionEvm.methods.addCollectionAdmin(adminEth).send();281234282 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))235 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))283 .to.be.rejectedWith('NoPermission');236 .to.be.rejectedWith('NoPermission');284237285 const adminList = await api.rpc.unique.adminlist(collectionId);238 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);286 expect(adminList.length).to.be.eq(2);239 expect(adminList.length).to.be.eq(2);287 expect(adminList.toString().toLocaleLowerCase())240 expect(adminList.toString().toLocaleLowerCase())288 .to.be.deep.contains(adminSub.address.toLocaleLowerCase())241 .to.be.deep.contains(adminSub.address.toLocaleLowerCase())289 .to.be.deep.contains(adminEth.toLocaleLowerCase());242 .to.be.deep.contains(adminEth.toLocaleLowerCase());290 });243 });291244292 itWeb3('(!negative tests!) Remove substrate admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {245 itEth('(!negative tests!) Remove substrate admin by USER is not allowed', async ({helper}) => {293 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);246 const owner = await helper.eth.createAccountWithBalance(donor);294 const collectionHelper = evmCollectionHelpers(web3, owner);295296 const result = await collectionHelper.methods247 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');297 .createNonfungibleCollection('A', 'B', 'C')248298 .send();299 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);249 const [adminSub] = await helper.arrange.createAccounts([10n], donor);300301 const adminSub = privateKeyWrapper('//Alice');302 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);250 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);303 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();251 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();304 const notAdminEth = await createEthAccountWithBalance(api, web3, privateKeyWrapper);252 const notAdminEth = await helper.eth.createAccountWithBalance(donor);305253306 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))254 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))307 .to.be.rejectedWith('NoPermission');255 .to.be.rejectedWith('NoPermission');308256309 const adminList = await api.rpc.unique.adminlist(collectionId);257 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);310 expect(adminList.length).to.be.eq(1);258 expect(adminList.length).to.be.eq(1);311 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())259 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())312 .to.be.eq(adminSub.address.toLocaleLowerCase());260 .to.be.eq(adminSub.address.toLocaleLowerCase());313 });261 });314});262});315263316describe('Change owner tests', () => {264describe('Change owner tests', () => {265 let donor: IKeyringPair;266267 before(async function() {268 await usingEthPlaygrounds(async (_helper, privateKey) => {269 donor = privateKey('//Alice');270 });271 });272317 itWeb3('Change owner', async ({api, web3, privateKeyWrapper}) => {273 itEth('Change owner', async ({helper}) => {318 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);274 const owner = await helper.eth.createAccountWithBalance(donor);319 const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);275 const newOwner = await helper.eth.createAccountWithBalance(donor);320 const collectionHelper = evmCollectionHelpers(web3, owner);321 const result = await collectionHelper.methods276 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');322 .createNonfungibleCollection('A', 'B', 'C')323 .send();324 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);325 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);277 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);326278327 await collectionEvm.methods.setOwner(newOwner).send();279 await collectionEvm.methods.setOwner(newOwner).send();328280329 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;281 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;330 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.true;282 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.true;331 });283 });332284333 itWeb3('change owner call fee', async ({web3, api, privateKeyWrapper}) => {285 itEth('change owner call fee', async ({helper}) => {334 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);286 const owner = await helper.eth.createAccountWithBalance(donor);335 const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);287 const newOwner = await helper.eth.createAccountWithBalance(donor);336 const collectionHelper = evmCollectionHelpers(web3, owner);337 const result = await collectionHelper.methods288 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');338 .createNonfungibleCollection('A', 'B', 'C')339 .send();340 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);341 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);289 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);342290343 const cost = await recordEthFee(api, owner, () => collectionEvm.methods.setOwner(newOwner).send());291 const cost = await recordEthFee(helper.api!, owner, () => collectionEvm.methods.setOwner(newOwner).send());344 expect(cost < BigInt(0.2 * Number(UNIQUE)));292 expect(cost < BigInt(0.2 * Number(UNIQUE)));345 expect(cost > 0);293 expect(cost > 0);346 });294 });347295296 //FIXME348 itWeb3('(!negative tests!) call setOwner by non owner', async ({api, web3, privateKeyWrapper}) => {297 itEth('(!negative tests!) call setOwner by non owner', async ({helper}) => {349 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);298 const owner = await helper.eth.createAccountWithBalance(donor);350 const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);299 const newOwner = await helper.eth.createAccountWithBalance(donor);351 const collectionHelper = evmCollectionHelpers(web3, owner);352 const result = await collectionHelper.methods300 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');353 .createNonfungibleCollection('A', 'B', 'C')354 .send();355 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);356 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);301 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);357302358 await expect(collectionEvm.methods.setOwner(newOwner).send({from: newOwner})).to.be.rejected;303 await expect(collectionEvm.methods.setOwner(newOwner).send({from: newOwner})).to.be.rejected;359 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;304 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;360 });305 });361});306});362307363describe('Change substrate owner tests', () => {308describe('Change substrate owner tests', () => {309 let donor: IKeyringPair;310311 before(async function() {312 await usingEthPlaygrounds(async (_helper, privateKey) => {313 donor = privateKey('//Alice');314 });315 });316317 //FIXME364 itWeb3('Change owner', async ({api, web3, privateKeyWrapper}) => {318 itEth('Change owner', async ({helper}) => {365 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);319 const owner = await helper.eth.createAccountWithBalance(donor);366 const newOwner = privateKeyWrapper('//Alice');367 const collectionHelper = evmCollectionHelpers(web3, owner);368 const result = await collectionHelper.methods320 const [newOwner] = await helper.arrange.createAccounts([10n], donor);369 .createNonfungibleCollection('A', 'B', 'C')370 .send();371 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);321 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');372 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);322 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);373323374 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.true;324 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.true;375 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;325 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;380 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.true;330 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.true;381 });331 });382332383 itWeb3('change owner call fee', async ({web3, api, privateKeyWrapper}) => {333 itEth('change owner call fee', async ({helper}) => {384 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);334 const owner = await helper.eth.createAccountWithBalance(donor);385 const newOwner = privateKeyWrapper('//Alice');386 const collectionHelper = evmCollectionHelpers(web3, owner);387 const result = await collectionHelper.methods335 const [newOwner] = await helper.arrange.createAccounts([10n], donor);388 .createNonfungibleCollection('A', 'B', 'C')389 .send();390 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);336 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');391 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);337 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);392338393 const cost = await recordEthFee(api, owner, () => collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send());339 const cost = await recordEthFee(helper.api!, owner, () => collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send());394 expect(cost < BigInt(0.2 * Number(UNIQUE)));340 expect(cost < BigInt(0.2 * Number(UNIQUE)));395 expect(cost > 0);341 expect(cost > 0);396 });342 });397343344 //FIXME398 itWeb3('(!negative tests!) call setOwner by non owner', async ({api, web3, privateKeyWrapper}) => {345 itEth('(!negative tests!) call setOwner by non owner', async ({helper}) => {399 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);346 const owner = await helper.eth.createAccountWithBalance(donor);400 const otherReceiver = await createEthAccountWithBalance(api, web3, privateKeyWrapper);347 const otherReceiver = await helper.eth.createAccountWithBalance(donor);401 const newOwner = privateKeyWrapper('//Alice');402 const collectionHelper = evmCollectionHelpers(web3, owner);403 const result = await collectionHelper.methods348 const [newOwner] = await helper.arrange.createAccounts([10n], donor);404 .createNonfungibleCollection('A', 'B', 'C')405 .send();406 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);349 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');407 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);350 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);408351409 await expect(collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send({from: otherReceiver})).to.be.rejected;352 await expect(collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send({from: otherReceiver})).to.be.rejected;410 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;353 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;