Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
refactor: tested everything and updated all
Browse files Browse the repository at this point in the history
  • Loading branch information
Dudleyneedham committed Feb 27, 2020
1 parent 364c4f7 commit ed9bf24
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src/components/DevTools/data/cTypes.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion src/utils/CtypeUtils/CTypeUtlis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/CtypeUtils/CtypeInputSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
15 changes: 9 additions & 6 deletions src/utils/CtypeUtils/CtypeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
Expand Down Expand Up @@ -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 }
}
/**
Expand Down

0 comments on commit ed9bf24

Please sign in to comment.