Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CTypes to iterms #399

Merged
merged 2 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/messaging/src/Message.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ describe('Messaging Utilities', () => {
delegationId: undefined,
quote: quoteAttesterSigned,
prerequisiteClaims: undefined,
cTypes: undefined,
}
// Compressed Submit Terms Contentƒ
compressedSubmitTermsContent = [
Expand All @@ -350,6 +351,7 @@ describe('Messaging Utilities', () => {
undefined,
compressedResultAttesterSignedQuote,
undefined,
undefined,
]
// Reject terms Content
rejectTermsContent = {
Expand Down
5 changes: 5 additions & 0 deletions packages/messaging/src/Message.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export function errorCheckMessageBody(body: MessageBody): boolean | void {
'Submit terms pre-requisite claims invalid'
)
}
if (body.content.cTypes) {
body.content.cTypes.map((val) => CTypeUtils.errorCheck(val))
}
break
}
case Message.BodyType.REJECT_TERMS: {
Expand Down Expand Up @@ -305,6 +308,7 @@ export function compressMessage(body: MessageBody): CompressedMessageBody {
? QuoteUtils.compressAttesterSignedQuote(body.content.quote)
: undefined,
body.content.prerequisiteClaims,
body.content.cTypes?.map((val) => CTypeUtils.compress(val)),
]
break
}
Expand Down Expand Up @@ -432,6 +436,7 @@ export function decompressMessage(body: CompressedMessageBody): MessageBody {
? QuoteUtils.decompressAttesterSignedQuote(body[1][3])
: undefined,
prerequisiteClaims: body[1][4],
cTypes: body[1][5]?.map((val) => CTypeUtils.decompress(val)),
}

break
Expand Down
6 changes: 4 additions & 2 deletions packages/types/src/Terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import type { IAttestedClaim, CompressedAttestedClaim } from './AttestedClaim'
import type { ICType } from './CType'
import type { CompressedCType, ICType } from './CType'
import type { IDelegationBaseNode } from './Delegation'
import type {
IQuoteAttesterSigned,
Expand All @@ -19,12 +19,14 @@ export interface ITerms {
delegationId?: IDelegationBaseNode['id']
quote?: IQuoteAttesterSigned
prerequisiteClaims?: ICType['hash']
cTypes?: ICType[]
}

export type CompressedTerms = [
CompressedPartialClaim,
CompressedAttestedClaim[],
IDelegationBaseNode['id'] | undefined,
CompressedQuoteAttesterSigned | undefined,
ICType['hash'] | undefined
ICType['hash'] | undefined,
CompressedCType[] | undefined
]