difftreelog
fix PR
in: master
3 files changed
tests/src/eth/events.test.tsdiffbeforeafterboth19import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';19import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';20import {IEvent, TCollectionMode} from '../util/playgrounds/types';20import {IEvent, TCollectionMode} from '../util/playgrounds/types';21import {Pallets, requirePalletsOrSkip} from '../util';21import {Pallets, requirePalletsOrSkip} from '../util';22import {NormalizedEvent} from './util/playgrounds/types';22import {EthTokenPermissions, NormalizedEvent} from './util/playgrounds/types';232324let donor: IKeyringPair;24let donor: IKeyringPair;25 25 119 ethEvents.push(event);119 ethEvents.push(event);120 });120 });121 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);121 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);122 await collection.methods.setTokenPropertyPermissions([['testKey', [[0, true], [1, true], [2, true]]]]).send({from: owner});122 await collection.methods.setTokenPropertyPermissions([123 ['A', [124 [EthTokenPermissions.Mutable, true], 125 [EthTokenPermissions.TokenOwner, true], 126 [EthTokenPermissions.CollectionAdmin, true]],127 ],128 ]).send({from: owner});123 await helper.wait.newBlocks(1);129 await helper.wait.newBlocks(1);124 expect(ethEvents).to.be.like([130 expect(ethEvents).to.be.like([374 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);380 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);375 const result = await collection.methods.mint(owner).send({from: owner});381 const result = await collection.methods.mint(owner).send({from: owner});376 const tokenId = result.events.Transfer.returnValues.tokenId;382 const tokenId = result.events.Transfer.returnValues.tokenId;377 await collection.methods.setTokenPropertyPermissions([['A', [[0, true], [1, true], [2, true]]]]).send({from: owner});383 await collection.methods.setTokenPropertyPermissions([384 ['A', [385 [EthTokenPermissions.Mutable, true], 386 [EthTokenPermissions.TokenOwner, true], 387 [EthTokenPermissions.CollectionAdmin, true]],388 ],389 ]).send({from: owner});378390379391tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth20import {ITokenPropertyPermission} from '../util/playgrounds/types';20import {ITokenPropertyPermission} from '../util/playgrounds/types';21import {Pallets} from '../util';21import {Pallets} from '../util';22import {UniqueNFTCollection, UniqueNFToken, UniqueRFTCollection} from '../util/playgrounds/unique';22import {UniqueNFTCollection, UniqueNFToken, UniqueRFTCollection} from '../util/playgrounds/unique';23import {EthTokenPermissions} from './util/playgrounds/types';232424describe('EVM token properties', () => {25describe('EVM token properties', () => {25 let donor: IKeyringPair;26 let donor: IKeyringPair;36 {mode: 'nft' as const, requiredPallets: []},37 {mode: 'nft' as const, requiredPallets: []},37 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},38 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},38 ].map(testCase =>39 ].map(testCase =>39 itEth.ifWithPallets.only(`[${testCase.mode}] Set and get token property permissions`, testCase.requiredPallets, async({helper}) => {40 itEth.ifWithPallets(`[${testCase.mode}] Set and get token property permissions`, testCase.requiredPallets, async({helper}) => {40 const owner = await helper.eth.createAccountWithBalance(donor);41 const owner = await helper.eth.createAccountWithBalance(donor);41 const caller = await helper.ethCrossAccount.createAccountWithBalance(donor);42 const caller = await helper.ethCrossAccount.createAccountWithBalance(donor);42 for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {43 for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {43 const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');44 const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');44 const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);45 const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);45 await collection.methods.addCollectionAdminCross(caller).send({from: owner});46 await collection.methods.addCollectionAdminCross(caller).send({from: owner});464747 await collection.methods.setTokenPropertyPermissions([['testKey', [[0, mutable], [1, tokenOwner], [2, collectionAdmin]]]]).send({from: caller.eth});48 await collection.methods.setTokenPropertyPermissions([48 49 ['testKey', [50 [EthTokenPermissions.Mutable, mutable], 51 [EthTokenPermissions.TokenOwner, tokenOwner], 52 [EthTokenPermissions.CollectionAdmin, collectionAdmin]],53 ],54 ]).send({from: caller.eth});55 49 expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([{56 expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([{52 }]);59 }]);536054 expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([61 expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([55 ['testKey', [['0', mutable], ['1', tokenOwner], ['2', collectionAdmin]]],62 ['testKey', [63 [EthTokenPermissions.Mutable.toString(), mutable], 64 [EthTokenPermissions.TokenOwner.toString(), tokenOwner], 65 [EthTokenPermissions.CollectionAdmin.toString(), collectionAdmin]],66 ],56 ]);67 ]);57 }68 }tests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth202021export type EthProperty = string[];21export type EthProperty = string[];22222323export enum EthTokenPermissions {24 Mutable,25 TokenOwner,26 CollectionAdmin27}