difftreelog
Add '.' to allowed symbols in property names
in: master
2 files changed
primitives/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);
}
}
tests/src/nesting/properties.test.tsdiffbeforeafterboth106 });106 });107 });107 });108109 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);113114 // alpha symbols115 await expect(executeTransaction(116 api, 117 bob, 118 api.tx.unique.setCollectionProperties(collectionId, [{key: 'alpha'}]), 119 )).to.not.be.rejected;120121 // numeric symbols122 await expect(executeTransaction(123 api, 124 bob, 125 api.tx.unique.setCollectionProperties(collectionId, [{key: '123'}]), 126 )).to.not.be.rejected;127128 // underscore symbol129 await expect(executeTransaction(130 api, 131 bob, 132 api.tx.unique.setCollectionProperties(collectionId, [{key: 'black_hole'}]), 133 )).to.not.be.rejected;134135 // dash symbol136 await expect(executeTransaction(137 api, 138 bob, 139 api.tx.unique.setCollectionProperties(collectionId, [{key: 'semi-automatic'}]), 140 )).to.not.be.rejected;141142 // underscore symbol143 await expect(executeTransaction(144 api, 145 bob, 146 api.tx.unique.setCollectionProperties(collectionId, [{key: 'build.rs'}]), 147 )).to.not.be.rejected;148149 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 });108160109 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 => {241293242 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