git.delta.rocks / unique-network / refs/commits / 48f959311e08

difftreelog

chore code review requests

Grigoriy Simonov2022-10-12parent: #f8de52d.patch.diff
in: master

8 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -709,9 +709,6 @@
 		/// Value "1" ERC721 metadata supported.
 		pub const ERC721_METADATA_SUPPORTED: &[u8] = b"1";
 
-		/// Value "0" ERC721 metadata supported.
-		pub const ERC721_METADATA_UNSUPPORTED: &[u8] = b"0";
-
 		/// Value for [`ERC721_METADATA`].
 		pub fn erc721() -> up_data_structs::PropertyValue {
 			property_value_from_bytes(ERC721_METADATA).expect(EXPECT_CONVERT_ERROR)
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -104,7 +104,7 @@
 		.try_push(up_data_structs::PropertyKeyPermission {
 			key: key::url(),
 			permission: up_data_structs::PropertyPermission {
-				mutable: false,
+				mutable: true,
 				collection_admin: true,
 				token_owner: false,
 			},
@@ -115,17 +115,6 @@
 		token_property_permissions
 			.try_push(up_data_structs::PropertyKeyPermission {
 				key: key::suffix(),
-				permission: up_data_structs::PropertyPermission {
-					mutable: true,
-					collection_admin: true,
-					token_owner: false,
-				},
-			})
-			.map_err(|e| Error::Revert(format!("{:?}", e)))?;
-
-		token_property_permissions
-			.try_push(up_data_structs::PropertyKeyPermission {
-				key: key::url(),
 				permission: up_data_structs::PropertyPermission {
 					mutable: true,
 					collection_admin: true,
modifiedtests/src/deprecated-helpers/helpers.tsdiffbeforeafterboth
--- a/tests/src/deprecated-helpers/helpers.ts
+++ b/tests/src/deprecated-helpers/helpers.ts
@@ -433,7 +433,6 @@
   mode: {type: 'NFT'},
   name: 'name',
   tokenPrefix: 'prefix',
-  properties: [{key: 'ERC721Metadata', value: '1'}],
 };
 
 export async function
modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -80,7 +80,7 @@
     await usingEthPlaygrounds(async (helper, privateKey) => {
       const donor = privateKey('//Alice');
       const [alice] = await helper.arrange.createAccounts([10n], donor);
-      ({collectionId: collection} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));
+      ({collectionId: collection} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test', properties: [{key: 'ERC721Metadata', value: '1'}]}));
       minter = helper.eth.createAccount();
     });
   });
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -501,7 +501,7 @@
 
   itEth('Returns collection name', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});
+    const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE', properties: [{key: 'ERC721Metadata', value: '1'}]});
 
     const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
     const name = await contract.methods.name().call();
@@ -510,7 +510,7 @@
 
   itEth('Returns symbol name', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});
+    const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE', properties: [{key: 'ERC721Metadata', value: '1'}]});
 
     const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
     const symbol = await contract.methods.symbol().call();
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -377,7 +377,7 @@
 
   itEth('Returns collection name', async ({helper}) => {
     const caller = helper.eth.createAccount();
-    const collection = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '11'});
+    const collection = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '11', properties: [{key: 'ERC721Metadata', value: '1'}]});
     
     const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);
     const name = await contract.methods.name().call();
@@ -386,7 +386,7 @@
 
   itEth('Returns symbol name', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
-    const {collectionId} = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '12'});
+    const {collectionId} = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '12', properties: [{key: 'ERC721Metadata', value: '1'}]});
     const contract = helper.ethNativeContract.collectionById(collectionId, 'rft', caller);
     const symbol = await contract.methods.symbol().call();
     expect(symbol).to.equal('12');
modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
35 expect(collectionOption).is.not.null;35 expect(collectionOption).is.not.null;
36 let collection = collectionOption;36 let collection = collectionOption;
37 expect(collection.tokenPropertyPermissions).to.be.empty;37 expect(collection.tokenPropertyPermissions).to.be.empty;
38 expect(collection.properties).to.be.deep.equal([{key: 'ERC721Metadata', value: '1'}]);38 expect(collection.properties).to.be.empty;
3939
40 const propertyPermissions = [40 const propertyPermissions = [
41 {key: 'mindgame', permission: {collectionAdmin: true, mutable: false, tokenOwner: true}},41 {key: 'mindgame', permission: {collectionAdmin: true, mutable: false, tokenOwner: true}},
44 await expect(await baseCollection.setTokenPropertyPermissions(alice, propertyPermissions)).to.be.true;44 await expect(await baseCollection.setTokenPropertyPermissions(alice, propertyPermissions)).to.be.true;
4545
46 const collectionProperties = [46 const collectionProperties = [
47 {key: 'ERC721Metadata', value: '1'},
48 {key: 'black_hole', value: 'LIGO'},47 {key: 'black_hole', value: 'LIGO'},
49 {key: 'electron', value: 'come bond'}, 48 {key: 'electron', value: 'come bond'},
50 ];49 ];
80 itSub('Properties are initially empty', async ({helper}) => {79 itSub('Properties are initially empty', async ({helper}) => {
81 const collection = await helper.nft.mintCollection(alice);80 const collection = await helper.nft.mintCollection(alice);
82 const properties = await collection.getProperties();81 const properties = await collection.getProperties();
83 expect(properties).to.be.deep.equal([{82 expect(properties).to.be.empty;
84 'key': 'ERC721Metadata',
85 'value': '1',
86 }]);
87 });83 });
8884
89 async function testSetsPropertiesForCollection(collection: UniqueBaseCollection) {85 async function testSetsPropertiesForCollection(collection: UniqueBaseCollection) {
201 .to.be.rejectedWith(/common\.NoPermission/);197 .to.be.rejectedWith(/common\.NoPermission/);
202198
203 const properties = await collection.getProperties();199 const properties = await collection.getProperties();
204 expect(properties).to.be.deep.equal([{200 expect(properties).to.be.empty;
205 'key': 'ERC721Metadata',
206 'value': '1',
207 }]);
208 }201 }
209202
210 itSub('Fails to set properties in a NFT collection if not its onwer/administrator', async ({helper}) => {203 itSub('Fails to set properties in a NFT collection if not its onwer/administrator', async ({helper}) => {
257 to.be.rejectedWith(/common\.PropertyLimitReached/);250 to.be.rejectedWith(/common\.PropertyLimitReached/);
258251
259 const properties = await collection.getProperties();252 const properties = await collection.getProperties();
260 expect(properties).to.be.deep.equal([{253 expect(properties).to.be.empty;
261 'key': 'ERC721Metadata',
262 'value': '1',
263 }]);
264 }254 }
265255
266 itSub('Fails to set more properties than it is allowed (NFT)', async ({helper}) => {256 itSub('Fails to set more properties than it is allowed (NFT)', async ({helper}) => {
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -1297,7 +1297,6 @@
   async mintCollection(signer: TSigner, collectionOptions: ICollectionCreationOptions, mode: 'NFT' | 'RFT'): Promise<UniqueBaseCollection> {
     collectionOptions = JSON.parse(JSON.stringify(collectionOptions)) as ICollectionCreationOptions; // Clone object
     collectionOptions.mode = (mode === 'NFT') ? {nft: null} : {refungible: null};
-    collectionOptions.properties = collectionOptions.properties || [{key: 'ERC721Metadata', value: '1'}];
     for (const key of ['name', 'description', 'tokenPrefix']) {
       if (typeof collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] === 'string') collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] = this.helper.util.str2vec(collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] as string);
     }