difftreelog
Add '.' to allowed symbols in property names
in: master
2 files changed
primitives/data-structs/src/lib.rsdiffbeforeafterboth784 for byte in key.as_slice().iter() {784 for byte in key.as_slice().iter() {785 let byte = *byte;785 let byte = *byte;786786787 if !byte.is_ascii_alphanumeric() && byte != b'_' && byte != b'-' {787 if !byte.is_ascii_alphanumeric() && byte != b'_' && byte != b'-' && byte != b'.' {788 return Err(PropertiesError::InvalidCharacterInPropertyKey);788 return Err(PropertiesError::InvalidCharacterInPropertyKey);789 }789 }790 }790 }tests/src/nesting/properties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/properties.test.ts
+++ b/tests/src/nesting/properties.test.ts
@@ -106,6 +106,58 @@
});
});
+ it('Check valid names for collection properties keys', async () => {
+ await usingApi(async api => {
+ const events = await executeTransaction(api, bob, api.tx.unique.createCollectionEx({mode: 'NFT'}));
+ const {collectionId} = getCreateCollectionResult(events);
+
+ // alpha symbols
+ await expect(executeTransaction(
+ api,
+ bob,
+ api.tx.unique.setCollectionProperties(collectionId, [{key: 'alpha'}]),
+ )).to.not.be.rejected;
+
+ // numeric symbols
+ await expect(executeTransaction(
+ api,
+ bob,
+ api.tx.unique.setCollectionProperties(collectionId, [{key: '123'}]),
+ )).to.not.be.rejected;
+
+ // underscore symbol
+ await expect(executeTransaction(
+ api,
+ bob,
+ api.tx.unique.setCollectionProperties(collectionId, [{key: 'black_hole'}]),
+ )).to.not.be.rejected;
+
+ // dash symbol
+ await expect(executeTransaction(
+ api,
+ bob,
+ api.tx.unique.setCollectionProperties(collectionId, [{key: 'semi-automatic'}]),
+ )).to.not.be.rejected;
+
+ // underscore symbol
+ await expect(executeTransaction(
+ api,
+ bob,
+ api.tx.unique.setCollectionProperties(collectionId, [{key: 'build.rs'}]),
+ )).to.not.be.rejected;
+
+ const propertyKeys = ['alpha', '123', 'black_hole', 'semi-automatic', 'build.rs'];
+ const properties = (await api.rpc.unique.collectionProperties(collectionId, propertyKeys)).toHuman();
+ expect(properties).to.be.deep.equal([
+ {key: 'alpha', value: ''},
+ {key: '123', value: ''},
+ {key: 'black_hole', value: ''},
+ {key: 'semi-automatic', value: ''},
+ {key: 'build.rs', value: ''},
+ ]);
+ });
+ });
+
it('Changes properties of a collection', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess();
@@ -241,7 +293,7 @@
const invalidProperties = [
[{key: 'electron', value: 'negative'}, {key: 'string theory', value: 'understandable'}],
- [{key: 'Mr.Sandman', value: 'Bring me a gene'}],
+ [{key: 'Mr/Sandman', value: 'Bring me a gene'}],
[{key: 'déjà vu', value: 'hmm...'}],
];