-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor: CType Utility and Split Metadata and Schema #231
Conversation
Need to clean up the types used within the functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks pretty good, but I would get rid of the unnecessary functions.
Can we also keep the tests, which are removed here: https://github.com/KILTprotocol/sdk-js/pull/205/files?
src/containers/Tasks/SubmitLegitimations/SubmitLegitimations.tsx
Outdated
Show resolved
Hide resolved
I have added the test into the file, but they don't work. |
Please put the ctypeutils in the |
I made changes accordingly, additionally. I was testing the changes in splitting the ctype metadata and schema. These were closely related and I felt I needed to be added at the same time. They work, but I had to take some checks off. I am trying to think of a way to fix the any. |
@@ -127,7 +127,7 @@ class SelectCTypes extends React.Component<Props, State> { | |||
return { | |||
baseValue: `${cType.cType.hash}`, | |||
label: <CTypePresentation cTypeHash={cType.cType.hash} />, | |||
value: `${cType.cType.metadata.title.default} ${cType.cType.hash}`, | |||
value: `${cType.cType.schema.$id} ${cType.cType.hash}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since ctype
is of type CTypeMetadata
, we should be able to get the title from the metadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LeonFLK plz check this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good overall. Some nitpicks and a big name refactoring ;)
@@ -127,7 +127,7 @@ class SelectCTypes extends React.Component<Props, State> { | |||
return { | |||
baseValue: `${cType.cType.hash}`, | |||
label: <CTypePresentation cTypeHash={cType.cType.hash} />, | |||
value: `${cType.cType.metadata.title.default} ${cType.cType.hash}`, | |||
value: `${cType.cType.schema.$id} ${cType.cType.hash}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since ctype
is of type CTypeMetadata
, we should be able to get the title from the metadata
src/components/AttestedClaimVerificationView/AttestedClaimVerificationView.tsx
Show resolved
Hide resolved
|
||
const partialClaim = { | ||
const partialClaim: IPartialClaim = { | ||
cTypeHash: cType.cType.hash as string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need the as string
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not part of this ticket / PR
}) | ||
result.required.push(key) | ||
}) | ||
Object.entries(ctype.cType.schema.properties as object).forEach( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove the properties as object
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not part of this ticket
@@ -13,8 +15,9 @@ export interface ICTypeInput { | |||
properties: object[] // TO DO: need to refine what properties are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be an Array of objects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not part of this ticket
src/utils/CtypeUtils/CtypeUtils.ts
Outdated
result.properties[key].title = getLocalized(value.title, lang) | ||
result.required.push(key) | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this handled in another way now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good already, just some small remarks
@@ -127,7 +127,7 @@ class SelectCTypes extends React.Component<Props, State> { | |||
return { | |||
baseValue: `${cType.cType.hash}`, | |||
label: <CTypePresentation cTypeHash={cType.cType.hash} />, | |||
value: `${cType.cType.metadata.title.default} ${cType.cType.hash}`, | |||
value: `${cType.cType.schema.$id} ${cType.cType.hash}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LeonFLK plz check this
@@ -13,8 +15,9 @@ export interface ICTypeInput { | |||
properties: object[] // TO DO: need to refine what properties are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not part of this ticket
|
||
const partialClaim = { | ||
const partialClaim: IPartialClaim = { | ||
cTypeHash: cType.cType.hash as string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not part of this ticket / PR
}) | ||
result.required.push(key) | ||
}) | ||
Object.entries(ctype.cType.schema.properties as object).forEach( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not part of this ticket
I looked at the code with Dudley, and we found that Do we want to remove it? |
src/containers/Tasks/SubmitLegitimations/SubmitLegitimations.tsx
Outdated
Show resolved
Hide resolved
Regarding the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes https://github.com/KILTprotocol/ticket/issues/15
Removed CTypeUtils functions from the SDK
Added them into the demo client.
How to test:
Connect to the chain with the changes, did some test and went through the various Ctype and claims functionality.
You will need to use the Link function and pull this version of the SDK KILTprotocol/sdk-js#211 in order to test.
Then, periodically test the ctype and claims.
Along with the dev tools, though I think they aren't working correctly in the first place.
Checklist: