git.delta.rocks / unique-network / refs/commits / b7135593579f

difftreelog

chore remove URI ttp from clean collections

Grigoriy Simonov2022-10-13parent: #48f9593.patch.diff
in: master

4 files changed

modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
30};30};
31use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};31use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};
32use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};32use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};
33use sp_std::vec;
33use up_data_structs::{34use up_data_structs::{
34 CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,35 CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,
35 CollectionMode, PropertyValue,36 CollectionMode, PropertyValue,
96 base_uri_value: PropertyValue,97 base_uri_value: PropertyValue,
97 add_properties: bool,98 add_properties: bool,
98) -> Result<CreateCollectionData<T::AccountId>> {99) -> Result<CreateCollectionData<T::AccountId>> {
99 let mut properties = up_data_structs::CollectionPropertiesVec::default();100 let token_property_permissions = if add_properties {
100 let mut token_property_permissions =101 vec![
101 up_data_structs::CollectionPropertiesPermissionsVec::default();
102
103 token_property_permissions
104 .try_push(up_data_structs::PropertyKeyPermission {102 up_data_structs::PropertyKeyPermission {
105 key: key::url(),103 key: key::url(),
106 permission: up_data_structs::PropertyPermission {104 permission: up_data_structs::PropertyPermission {
107 mutable: true,105 mutable: true,
108 collection_admin: true,106 collection_admin: true,
109 token_owner: false,107 token_owner: false,
110 },108 },
111 })109 },
110 up_data_structs::PropertyKeyPermission {
111 key: key::suffix(),
112 permission: up_data_structs::PropertyPermission {
113 mutable: true,
114 collection_admin: true,
115 token_owner: false,
116 },
117 },
118 ]
119 .try_into()
112 .map_err(|e| Error::Revert(format!("{:?}", e)))?;120 .map_err(|e| Error::Revert(format!("{:?}", e)))?
113121 } else {
122 up_data_structs::CollectionPropertiesPermissionsVec::default()
123 };
114 if add_properties {124 let properties = if add_properties {
115 token_property_permissions
116 .try_push(up_data_structs::PropertyKeyPermission {
117 key: key::suffix(),
118 permission: up_data_structs::PropertyPermission {
119 mutable: true,
120 collection_admin: true,
121 token_owner: false,
122 },
123 })
124 .map_err(|e| Error::Revert(format!("{:?}", e)))?;
125
126 properties125 let mut properties = vec![
127 .try_push(up_data_structs::Property {126 up_data_structs::Property {
128 key: key::schema_name(),127 key: key::schema_name(),
129 value: property_value::erc721(),128 value: property_value::erc721(),
130 })129 },
131 .map_err(|e| Error::Revert(format!("{:?}", e)))?;130 up_data_structs::Property {
132131 key: key::schema_version(),
132 value: property_value::schema_version(),
133 },
134 up_data_structs::Property {
135 key: key::erc721_metadata(),
136 value: property_value::erc721_metadata_supported(),
137 },
138 ];
139 if !base_uri_value.is_empty() {
133 properties140 properties.push(up_data_structs::Property {
134 .try_push(up_data_structs::Property {
135 key: key::schema_version(),141 key: key::base_uri(),
136 value: property_value::schema_version(),142 value: base_uri_value,
137 })143 })
138 .map_err(|e| Error::Revert(format!("{:?}", e)))?;144 }
139
140 properties145 properties
141 .try_push(up_data_structs::Property {146 .try_into()
142 key: key::erc721_metadata(),
143 value: property_value::erc721_metadata_supported(),
144 })
145 .map_err(|e| Error::Revert(format!("{:?}", e)))?;147 .map_err(|e| Error::Revert(format!("{:?}", e)))?
146
147 if !base_uri_value.is_empty() {
148 properties
149 .try_push(up_data_structs::Property {
150 key: key::base_uri(),
151 value: base_uri_value,
152 })
153 .map_err(|e| Error::Revert(format!("{:?}", e)))?;
154 }
155 }148 } else {
149 up_data_structs::CollectionPropertiesVec::default()
150 };
156151
157 let data = CreateCollectionData {152 let data = CreateCollectionData {
158 name,153 name,
deletedtests/src/eth/api/UniqueRFT.soldiffbeforeafterboth

no changes

modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
50 expect(data.raw.tokenPrefix).to.be.eq(prefix);50 expect(data.raw.tokenPrefix).to.be.eq(prefix);
51 expect(data.raw.mode).to.be.eq('NFT');51 expect(data.raw.mode).to.be.eq('NFT');
52
53 const options = await collection.getOptions();
54
55 expect(options.tokenPropertyPermissions).to.be.empty;
52 });56 });
57
58 itEth('Create collection with properties', async ({helper}) => {
59 const owner = await helper.eth.createAccountWithBalance(donor);
60
61 const name = 'CollectionEVM';
62 const description = 'Some description';
63 const prefix = 'token prefix';
64 const baseUri = 'BaseURI';
65
66 // todo:playgrounds this might fail when in async environment.
67 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
68 const {collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);
69 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
70
71 const collection = helper.nft.getCollectionObject(collectionId);
72 const data = (await collection.getData())!;
73
74 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
75 expect(collectionId).to.be.eq(collectionCountAfter);
76 expect(data.name).to.be.eq(name);
77 expect(data.description).to.be.eq(description);
78 expect(data.raw.tokenPrefix).to.be.eq(prefix);
79 expect(data.raw.mode).to.be.eq('NFT');
80
81 const options = await collection.getOptions();
82 expect(options.tokenPropertyPermissions).to.be.deep.equal([
83 {
84 key: 'URI',
85 permission: {mutable: true, collectionAdmin: true, tokenOwner: false},
86 },
87 {
88 key: 'URISuffix',
89 permission: {mutable: true, collectionAdmin: true, tokenOwner: false},
90 },
91 ]);
92 });
5393
54 // todo:playgrounds this test will fail when in async environment.94 // todo:playgrounds this test will fail when in async environment.
55 itEth('Check collection address exist', async ({helper}) => {95 itEth('Check collection address exist', async ({helper}) => {
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
42 const {collectionId} = await helper.eth.createRFTCollection(owner, name, description, prefix);42 const {collectionId} = await helper.eth.createRFTCollection(owner, name, description, prefix);
43 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;43 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
44 44
45 const collection = helper.rft.getCollectionObject(collectionId);
45 const data = (await helper.rft.getData(collectionId))!;46 const data = (await collection.getData())!;
4647
47 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);48 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
48 expect(collectionId).to.be.eq(collectionCountAfter);49 expect(collectionId).to.be.eq(collectionCountAfter);
51 expect(data.raw.tokenPrefix).to.be.eq(prefix);52 expect(data.raw.tokenPrefix).to.be.eq(prefix);
52 expect(data.raw.mode).to.be.eq('ReFungible');53 expect(data.raw.mode).to.be.eq('ReFungible');
54
55 const options = await collection.getOptions();
56
57 expect(options.tokenPropertyPermissions).to.be.empty;
53 });58 });
59
60
61
62 itEth('Create collection with properties', async ({helper}) => {
63 const owner = await helper.eth.createAccountWithBalance(donor);
64
65 const name = 'CollectionEVM';
66 const description = 'Some description';
67 const prefix = 'token prefix';
68 const baseUri = 'BaseURI';
69
70 // todo:playgrounds this might fail when in async environment.
71 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
72 const {collectionId} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, name, description, prefix, baseUri);
73 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
74
75 const collection = helper.rft.getCollectionObject(collectionId);
76 const data = (await collection.getData())!;
77
78 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
79 expect(collectionId).to.be.eq(collectionCountAfter);
80 expect(data.name).to.be.eq(name);
81 expect(data.description).to.be.eq(description);
82 expect(data.raw.tokenPrefix).to.be.eq(prefix);
83 expect(data.raw.mode).to.be.eq('ReFungible');
84
85 const options = await collection.getOptions();
86 expect(options.tokenPropertyPermissions).to.be.deep.equal([
87 {
88 key: 'URI',
89 permission: {mutable: true, collectionAdmin: true, tokenOwner: false},
90 },
91 {
92 key: 'URISuffix',
93 permission: {mutable: true, collectionAdmin: true, tokenOwner: false},
94 },
95 ]);
96 });
5497
55 // todo:playgrounds this test will fail when in async environment.98 // todo:playgrounds this test will fail when in async environment.
56 itEth('Check collection address exist', async ({helper}) => {99 itEth('Check collection address exist', async ({helper}) => {