Skip to content

Commit

Permalink
statment update - schema uri fix
Browse files Browse the repository at this point in the history
  • Loading branch information
smohan-dw authored and amarts committed Dec 1, 2023
1 parent 0dd57a1 commit 7d7d5b1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
16 changes: 10 additions & 6 deletions demo/src/func-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async function main() {
depth: null,
colors: true,
})
const schemaId = await Cord.Schema.dispatchToChain(
const schemaUri = await Cord.Schema.dispatchToChain(
schemaProperties.schema,
issuerDid.uri,
authorIdentity,
Expand All @@ -241,7 +241,7 @@ async function main() {
keyType: issuerKeys.authentication.type,
})
)
console.log(`✅ Schema - ${schemaId} - added!`)
console.log(`✅ Schema - ${schemaUri} - added!`)

console.log(`\n❄️ Query From Chain - Schema `)
const schemaFromChain = await Cord.Schema.fetchFromChain(
Expand Down Expand Up @@ -269,7 +269,8 @@ async function main() {
const statementEntry = Cord.Statement.buildFromProperties(
credHash,
space.uri,
issuerDid.uri
issuerDid.uri,
schemaUri
)
console.dir(statementEntry, {
depth: null,
Expand Down Expand Up @@ -325,7 +326,8 @@ async function main() {
statementEntry.elementUri,
credHash,
issuerDid.uri,
space.uri
space.uri,
schemaUri
)

if (verificationResult.isValid) {
Expand All @@ -344,10 +346,12 @@ async function main() {

if (anotherVerificationResult.isValid) {
console.log(
`✅ Verification successful! "${updatedStatementEntry.elementUri}" 🎉`
`\n✅ Verification successful! "${updatedStatementEntry.elementUri}" 🎉`
)
} else {
console.log(`🚫 Verification failed! - "${verificationResult.message}" 🚫`)
console.log(
`\n🚫 Verification failed! - "${verificationResult.message}" 🚫`
)
}

console.log(`\n❄️ Revoke Statement - ${updatedStatementEntry.elementUri}`)
Expand Down
1 change: 0 additions & 1 deletion packages/statement/src/Statement.chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ export async function fetchStatementDetailsfromChain(
)
}

console.log(statementDetails)
const schemaUri =
statementDetails.schemaUri !== undefined
? identifierToUri(statementDetails.schemaUri)
Expand Down
10 changes: 4 additions & 6 deletions packages/statement/src/Statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import type {
SpaceUri,
DidUri,
StatementUri,
PartialStatementEntry,
} from '@cord.network/types'
import { DataUtils, SDKErrors } from '@cord.network/utils'
import { checkIdentifier, updateStatementUri } from '@cord.network/identifier'
Expand Down Expand Up @@ -178,17 +179,15 @@ export function buildFromUpdateProperties(
stmtUri: StatementUri,
digest: HexString,
spaceUri: SpaceUri,
creatorUri: DidUri,
schemaUri?: SchemaUri
): IStatementEntry {
creatorUri: DidUri
): PartialStatementEntry {
const statementUri = updateStatementUri(stmtUri, digest)

// TODO fetch on-chain data and compare the update inputs
const statement = {
elementUri: statementUri,
digest,
creatorUri,
spaceUri,
schemaUri: schemaUri || undefined,
}
verifyDataStructure(statement)
return statement
Expand Down Expand Up @@ -251,7 +250,6 @@ export async function verifyAgainstProperties(
schemaUri?: SchemaUri
): Promise<{ isValid: boolean; message: string }> {
try {
console.log(stmtUri)
const statementStatus = await fetchStatementDetailsfromChain(stmtUri)

if (!statementStatus) {
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/Statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface IStatementEntry {
schemaUri?: SchemaUri | undefined
}

export type PartialStatementEntry = Omit<IStatementEntry, 'schemaUri'>

export interface IStatementDetails {
uri: StatementUri
digest: StatementDigest
Expand Down

0 comments on commit 7d7d5b1

Please sign in to comment.