diff --git a/src/components/DevTools/data/cTypes.json b/src/components/DevTools/data/cTypes.json index efefc9bf..879576a7 100644 --- a/src/components/DevTools/data/cTypes.json +++ b/src/components/DevTools/data/cTypes.json @@ -1,9 +1,8 @@ { "DRIVERS_LICENSE": { "schema": { - "$id": "kilt:ctype:0x1", + "$id": "DriversLicense", "$schema": "http://kilt-protocol.org/draft-01/ctype#", - "title": "DriversLicense", "properties": { "name": { "type": "string" @@ -39,9 +38,8 @@ }, "IS_OFFICIAL": { "schema": { - "$id": "kilt:ctype:0x2", + "$id": "IsOfficial", "$schema": "http://kilt-protocol.org/draft-01/ctype#", - "title": "Official ID", "properties": {}, "type": "object" }, diff --git a/src/utils/CtypeUtils/CTypeUtlis.spec.ts b/src/utils/CtypeUtils/CTypeUtlis.spec.ts index f9a3d29e..bf450f49 100644 --- a/src/utils/CtypeUtils/CTypeUtlis.spec.ts +++ b/src/utils/CtypeUtils/CTypeUtlis.spec.ts @@ -4,7 +4,7 @@ import { getCTypeInputModel, } from './CtypeUtils' import * as sdk from '@kiltprotocol/sdk-js' -import { ICType, ICTypeInput } from '../../types/Ctype' +import { ICTypeInput } from '../../types/Ctype' describe('CType', () => { const ctypeModel = { diff --git a/src/utils/CtypeUtils/CtypeInputSchema.ts b/src/utils/CtypeUtils/CtypeInputSchema.ts index e227f9d1..dc4ecd39 100644 --- a/src/utils/CtypeUtils/CtypeInputSchema.ts +++ b/src/utils/CtypeUtils/CtypeInputSchema.ts @@ -14,8 +14,8 @@ export const CTypeInputModel = { title: 'Schema', type: 'string', format: 'uri', - enum: ['http://kilt-protocol.org/draft-01/ctype-input#'], - default: 'http://kilt-protocol.org/draft-01/ctype-input#', + enum: ['http://kilt-protocol.org/draft-01/ctype#'], + default: 'http://kilt-protocol.org/draft-01/ctype#', readonly: true, className: 'hidden', }, diff --git a/src/utils/CtypeUtils/CtypeUtils.ts b/src/utils/CtypeUtils/CtypeUtils.ts index 8e83e969..4e9fc4eb 100644 --- a/src/utils/CtypeUtils/CtypeUtils.ts +++ b/src/utils/CtypeUtils/CtypeUtils.ts @@ -21,10 +21,10 @@ export const fromInputModel = (ctypeInput: ICTypeInput): ICTypeWithMetadata => { if (!sdk.CTypeUtils.verifySchema(ctypeInput, CTypeInputModel)) { throw new Error('CType input does not correspond to input model schema') } + const schema: sdk.ICType['schema'] = { - $id: 'kilt:ctype:0x1', + $id: ctypeInput.$id, $schema: CTypeInputModel.properties.$schema.default, - title: ctypeInput.$id, properties: {}, type: 'object', } @@ -52,19 +52,22 @@ export const fromInputModel = (ctypeInput: ICTypeInput): ICTypeWithMetadata => { }, } }) + schema.properties = properties - const ctype: sdk.ICType = { + const rawCtype: sdk.ICType = { schema, owner: ctypeInput.owner, - hash: sdk.CTypeUtils.getHashForSchema(schema), + hash: '', } + + const sdkCType = sdk.CType.fromCType(rawCtype) + const sdkCTypeMetadata: sdk.ICTypeMetadata = { metadata: sdkMetadata, - ctypeHash: ctype.hash, + ctypeHash: sdkCType.hash, } - const sdkCType = sdk.CType.fromCType(ctype) return { cType: sdkCType, metaData: sdkCTypeMetadata } } /**