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: updated doc changes #63

Merged
merged 1 commit into from
Feb 26, 2025
Merged
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
23 changes: 17 additions & 6 deletions src/controller/credential_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,22 +395,25 @@ export async function udpateDocumentHashonChain(
try {
const fileHash = req?.body.filehash;
const identifierReq = req?.body.identifier;
if (!req.params.id) {
return res.status(400).json({ err: 'Please enter correct id' });
if (!fileHash) {
return res.status(400).json({ err: 'Please enter valid document' });
}
if (!identifierReq) {
return res.status(400).json({ err: 'Please enter valid identifier' });
}
const api = Cord.ConfigService.get('api');
if (!CHAIN_SPACE_ID) {
return res.status(400).json({ err: 'chain space id not' });
}
const statementDetails = await Cord.Statement.getDetailsfromChain(
req.params.id
identifierReq
);
if (statementDetails?.digest) {
const digest = statementDetails.digest.replace(/^0x/, '');
const elementUri = `${statementDetails.uri}:digest`;
const elementUri = `${statementDetails.uri}:{digest}`;
const updatedStatementEntry = Cord.Statement.buildFromUpdateProperties(
elementUri as `stmt:cord:${string}`,
statementDetails?.digest,
fileHash,
CHAIN_SPACE_ID as `space:cord:${string}`,
issuerDid.uri
);
Expand All @@ -431,7 +434,15 @@ export async function udpateDocumentHashonChain(
);
console.log(`✅ Statement element registered - ${updatedStatement}`);

return res.status(200).json({ result: { msg: 'Successfully update' } });
const updatedStatementDetails = await api.query.statement.statements(
updatedStatementEntry.elementUri
);
return res.status(200).json({
result: {
identifier: updatedStatementEntry.elementUri,
blockHash: updatedStatementDetails.createdAtHash?.toString(),
},
});
} else {
return res.status(400).json({ err: 'Unable to find the digest' });
}
Expand Down