1234567891011121314151617import {itEth, usingEthPlaygrounds, expect} from './util';18import {IKeyringPair} from '@polkadot/types/types';1920describe('EVM collection properties', () => {21 let donor: IKeyringPair;22 let alice: IKeyringPair;2324 before(async function() {25 await usingEthPlaygrounds(async (_helper, privateKey) => {26 donor = await privateKey({filename: __filename});27 [alice] = await _helper.arrange.createAccounts([10n], donor);28 });29 });3031 itEth('Can be set', async({helper}) => {32 const caller = await helper.eth.createAccountWithBalance(donor);33 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test'});34 await collection.addAdmin(alice, {Ethereum: caller});3536 const address = helper.ethAddress.fromCollectionId(collection.collectionId);37 const contract = helper.ethNativeContract.collection(address, 'nft', caller);3839 await contract.methods.setCollectionProperty('testKey', Buffer.from('testValue')).send({from: caller});4041 const raw = (await collection.getData())?.raw;4243 expect(raw.properties[0].value).to.equal('testValue');44 });4546 itEth('Can be deleted', async({helper}) => {47 const caller = await helper.eth.createAccountWithBalance(donor);48 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: [{key: 'testKey', value: 'testValue'}]});4950 await collection.addAdmin(alice, {Ethereum: caller});5152 const address = helper.ethAddress.fromCollectionId(collection.collectionId);53 const contract = helper.ethNativeContract.collection(address, 'nft', caller);5455 await contract.methods.deleteCollectionProperty('testKey').send({from: caller});5657 const raw = (await collection.getData())?.raw;5859 expect(raw.properties.length).to.equal(0);60 });6162 itEth('Can be read', async({helper}) => {63 const caller = helper.eth.createAccount();64 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: [{key: 'testKey', value: 'testValue'}]});6566 const address = helper.ethAddress.fromCollectionId(collection.collectionId);67 const contract = helper.ethNativeContract.collection(address, 'nft', caller);6869 const value = await contract.methods.collectionProperty('testKey').call();70 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));71 });72});