git.delta.rocks / unique-network / refs/commits / 7b97719205e4

difftreelog

Add '.' to allowed symbols in property names

Trubnikov Sergey2022-06-08parent: #c544a38.patch.diff
in: master

2 files changed

modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -784,7 +784,7 @@
 		for byte in key.as_slice().iter() {
 			let byte = *byte;
 
-			if !byte.is_ascii_alphanumeric() && byte != b'_' && byte != b'-' {
+			if !byte.is_ascii_alphanumeric() && byte != b'_' && byte != b'-' && byte != b'.' {
 				return Err(PropertiesError::InvalidCharacterInPropertyKey);
 			}
 		}
modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
106 });106 });
107 });107 });
108
109 it('Check valid names for collection properties keys', async () => {
110 await usingApi(async api => {
111 const events = await executeTransaction(api, bob, api.tx.unique.createCollectionEx({mode: 'NFT'}));
112 const {collectionId} = getCreateCollectionResult(events);
113
114 // alpha symbols
115 await expect(executeTransaction(
116 api,
117 bob,
118 api.tx.unique.setCollectionProperties(collectionId, [{key: 'alpha'}]),
119 )).to.not.be.rejected;
120
121 // numeric symbols
122 await expect(executeTransaction(
123 api,
124 bob,
125 api.tx.unique.setCollectionProperties(collectionId, [{key: '123'}]),
126 )).to.not.be.rejected;
127
128 // underscore symbol
129 await expect(executeTransaction(
130 api,
131 bob,
132 api.tx.unique.setCollectionProperties(collectionId, [{key: 'black_hole'}]),
133 )).to.not.be.rejected;
134
135 // dash symbol
136 await expect(executeTransaction(
137 api,
138 bob,
139 api.tx.unique.setCollectionProperties(collectionId, [{key: 'semi-automatic'}]),
140 )).to.not.be.rejected;
141
142 // underscore symbol
143 await expect(executeTransaction(
144 api,
145 bob,
146 api.tx.unique.setCollectionProperties(collectionId, [{key: 'build.rs'}]),
147 )).to.not.be.rejected;
148
149 const propertyKeys = ['alpha', '123', 'black_hole', 'semi-automatic', 'build.rs'];
150 const properties = (await api.rpc.unique.collectionProperties(collectionId, propertyKeys)).toHuman();
151 expect(properties).to.be.deep.equal([
152 {key: 'alpha', value: ''},
153 {key: '123', value: ''},
154 {key: 'black_hole', value: ''},
155 {key: 'semi-automatic', value: ''},
156 {key: 'build.rs', value: ''},
157 ]);
158 });
159 });
108160
109 it('Changes properties of a collection', async () => {161 it('Changes properties of a collection', async () => {
110 await usingApi(async api => {162 await usingApi(async api => {
241293
242 const invalidProperties = [294 const invalidProperties = [
243 [{key: 'electron', value: 'negative'}, {key: 'string theory', value: 'understandable'}],295 [{key: 'electron', value: 'negative'}, {key: 'string theory', value: 'understandable'}],
244 [{key: 'Mr.Sandman', value: 'Bring me a gene'}],296 [{key: 'Mr/Sandman', value: 'Bring me a gene'}],
245 [{key: 'déjà vu', value: 'hmm...'}],297 [{key: 'déjà vu', value: 'hmm...'}],
246 ];298 ];
247299