Skip to content

Commit

Permalink
docs: easier message body creation (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjwelde authored May 7, 2021
1 parent 7857713 commit 81a427e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
12 changes: 5 additions & 7 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ KILT contains a simple messaging system and we describe it through the following
First, we create the request for attestation message which the Claimer encrypts with the public key of the Attester:

```typescript
import Kilt, { IRequestAttestationForClaim } from '@kiltprotocol/sdk-js'
import Kilt, { MessageBody } from '@kiltprotocol/sdk-js'

const messageBody: IRequestAttestationForClaim = {
const messageBody: MessageBody = {
content: { requestForAttestation },
type: Kilt.Message.BodyType.REQUEST_ATTESTATION_FOR_CLAIM,
}
Expand Down Expand Up @@ -435,9 +435,7 @@ AttestedClaim {
The Attester has to send the `attestedClaim` object back to the Claimer in the following message:

```typescript
import { ISubmitAttestationForClaim } from '@kiltprotocol/sdk-js'

const messageBodyBack: ISubmitAttestationForClaim = {
const messageBodyBack: MessageBody = {
content: attestedClaim,
type: Kilt.Message.BodyType.SUBMIT_ATTESTATION_FOR_CLAIM,
}
Expand Down Expand Up @@ -501,7 +499,7 @@ This is an **important feature for the privacy of a claimer** as this enables th
### 6.1. Request presentation for CTYPE

```typescript
const messageBodyForClaimer: IRequestClaimsForCTypes = {
const messageBodyForClaimer: MessageBody = {
type: Kilt.Message.BodyType.REQUEST_CLAIMS_FOR_CTYPES,
content: { ctypes: [ctype.hash] },
}
Expand All @@ -521,7 +519,7 @@ const copiedCredential = Kilt.AttestedClaim.fromAttestedClaim(
)
copiedCredential.request.removeClaimProperties(['age'])

const messageBodyForVerifier: ISubmitClaimsForCTypes = {
const messageBodyForVerifier: MessageBody = {
content: [copiedCredential],
type: Kilt.Message.BodyType.SUBMIT_CLAIMS_FOR_CTYPES,
}
Expand Down
13 changes: 5 additions & 8 deletions docs/getting-started.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import Kilt from '@kiltprotocol/sdk-js'
import type {
SubmittableExtrinsic,
IRequestForAttestation,
IRequestAttestationForClaim,
IRequestClaimsForCTypes,
ISubmitAttestationForClaim,
ISubmitClaimsForCTypes,
MessageBody,
} from '@kiltprotocol/sdk-js'

const NODE_URL = 'ws://127.0.0.1:9944'
Expand Down Expand Up @@ -101,7 +98,7 @@ async function main(): Promise<void> {
)

/* First, we create the request for an attestation message in which the Claimer automatically encodes the message with the public key of the Attester: */
const messageBody: IRequestAttestationForClaim = {
const messageBody: MessageBody = {
content: { requestForAttestation },
type: Kilt.Message.BodyType.REQUEST_ATTESTATION_FOR_CLAIM,
}
Expand Down Expand Up @@ -151,7 +148,7 @@ async function main(): Promise<void> {
console.log(attestedClaim)

/* The Attester has to send the `attestedClaim` object back to the Claimer in the following message: */
const messageBodyBack: ISubmitAttestationForClaim = {
const messageBodyBack: MessageBody = {
content: attestedClaim,
type: Kilt.Message.BodyType.SUBMIT_ATTESTATION_FOR_CLAIM,
}
Expand Down Expand Up @@ -181,7 +178,7 @@ async function main(): Promise<void> {
const verifier = Kilt.Identity.buildFromMnemonic(verifierMnemonic)

/* 6.1. Request presentation for CTYPE */
const messageBodyForClaimer: IRequestClaimsForCTypes = {
const messageBodyForClaimer: MessageBody = {
type: Kilt.Message.BodyType.REQUEST_CLAIMS_FOR_CTYPES,
content: [{ cTypeHash: ctype.hash }],
}
Expand All @@ -199,7 +196,7 @@ async function main(): Promise<void> {
)
copiedCredential.request.removeClaimProperties(['age'])

const messageBodyForVerifier: ISubmitClaimsForCTypes = {
const messageBodyForVerifier: MessageBody = {
content: [copiedCredential],
type: Kilt.Message.BodyType.SUBMIT_CLAIMS_FOR_CTYPES,
}
Expand Down

0 comments on commit 81a427e

Please sign in to comment.