git.delta.rocks / unique-network / refs/commits / 4cd5a263848f

difftreelog

deleteCollectionProperties multiple properties case

Max Andreev2022-12-06parent: #9764f29.patch.diff
in: master
+ combine with deleteCollectionProperty

1 file changed

modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
50 }));50 }));
5151
5252
53 // Soft-deprecated: deleteCollectionProperty
54 [{method: 'deleteCollectionProperties', methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},
55 {method: 'deleteCollectionProperty', methodParams: ['testKey1'], expectedProps: [{key: 'testKey2', value: 'testValue2'}, {key: 'testKey3', value: 'testValue3'}]},
56 ].map(testCase =>
53 itEth('Can be deleted', async({helper}) => {57 itEth(`Collection properties can be deleted: ${testCase.method}`, async({helper}) => {
58 const properties = [
59 {key: 'testKey1', value: 'testValue1'},
60 {key: 'testKey2', value: 'testValue2'},
61 {key: 'testKey3', value: 'testValue3'}];
54 const caller = await helper.eth.createAccountWithBalance(donor);62 const caller = await helper.eth.createAccountWithBalance(donor);
55 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: [{key: 'testKey', value: 'testValue'}]});63 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties});
5664
57 await collection.addAdmin(alice, {Ethereum: caller});65 await collection.addAdmin(alice, {Ethereum: caller});
5866
59 const address = helper.ethAddress.fromCollectionId(collection.collectionId);67 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
60 const contract = helper.ethNativeContract.collection(address, 'nft', caller);68 const contract = helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty');
6169
62 await contract.methods.deleteCollectionProperties(['testKey']).send({from: caller});70 await contract.methods[testCase.method](...testCase.methodParams).send({from: caller});
6371
64 const raw = (await collection.getData())?.raw;72 const raw = (await collection.getData())?.raw;
6573
66 expect(raw.properties.length).to.equal(0);74 expect(raw.properties.length).to.equal(testCase.expectedProps.length);
75 expect(raw.properties).to.deep.equal(testCase.expectedProps);
67 });76 }));
6877
69 itEth('Can be read', async({helper}) => {78 itEth('Can be read', async({helper}) => {
70 const caller = helper.eth.createAccount();79 const caller = helper.eth.createAccount();
77 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));86 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));
78 });87 });
79
80 // Soft-deprecated
81 itEth('Collection property can be deleted', async({helper}) => {
82 const caller = await helper.eth.createAccountWithBalance(donor);
83 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: [{key: 'testKey', value: 'testValue'}]});
84
85 await collection.addAdmin(alice, {Ethereum: caller});
86
87 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
88 const contract = helper.ethNativeContract.collection(address, 'nft', caller, true);
89
90 await contract.methods.deleteCollectionProperty('testKey').send({from: caller});
91
92 const raw = (await collection.getData())?.raw;
93
94 expect(raw.properties.length).to.equal(0);
95 });
96});88});
9789
98describe('Supports ERC721Metadata', () => {90describe('Supports ERC721Metadata', () => {