-
Notifications
You must be signed in to change notification settings - Fork 115
[+] Anchoring schemas to CORD Network #245
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
base: main
Are you sure you want to change the base?
Conversation
java/registry/src/main/java/dev/sunbirdrc/registry/helper/RegistryHelper.java
Outdated
Show resolved
Hide resolved
6b1691f to
79e6ede
Compare
CyberCitizen01
left a comment
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 think unnecessary spaces, comments and debug print statements should be removed.
java/registry/src/main/java/dev/sunbirdrc/registry/controller/RegistryEntityController.java
Outdated
Show resolved
Hide resolved
java/registry/src/main/java/dev/sunbirdrc/registry/controller/RegistryEntityController.java
Outdated
Show resolved
Hide resolved
java/registry/src/main/java/dev/sunbirdrc/registry/helper/RegistryHelper.java
Outdated
Show resolved
Hide resolved
c6086c7 to
d47a8d5
Compare
amarts
left a comment
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.
LGTM.
I feel someone with more Java experience should review it once. Need a reference to documentation on this in commit log (or as a comment)
d47a8d5 to
02a5fba
Compare
C4GT 2023 | CORD Network #Issue
Anchoring schemas to the cord network
How It Works
If you are using docker, then instead of localhost, either you can try adding
dhiagentordocker gateway urlapplication.yml should be like this

In order to create schemas in sunbird-rc, we are required to hit this endpoint :
/api/v1/Schema.I have added an environment variable
anchor_to_cord, which needs to be set to true if you want to anchor the schema to the chainJust when you hit the endpoint
api/v1/Schema, once the definitionsManager of SunbirdRc confirms that no other schema with same name exists, then we go for anchoring it to the cord chain.In order to anchor it to the chain, we need to hit the
api/v1/schemaendpoint of Issuer Agent, which accepts the following schema :{ "title":"", "description":" ", "property":{ // schema } }descriptionproperty as well.In the RegistryHelper.java
a. I have defined this function
b. This function creates a proper json structure to pass as a request body to the
api/v1/schemaendpoint of Issuerand calls the
anchorSchemaAPI()andanchorRegistryAPI()defined in the same file.public JsonNode anchorSchemaAPI(JsonNode obj) throws Exception{ JsonNode schema=apiHelper(obj,issuer_schema_url); return schema; } /** Anchors registry to the CORD NETWORK ,*/ public JsonNode anchorRegistryAPI(JsonNode obj) throws Exception{ JsonNode registryDetails=apiHelper(obj,issuer_registry_url); return registryDetails; }In the RegistryEntityController, under the mapping
api/v1/{entityName}, I have added the following codeScreenshots
Schema creation & anchoring to chain
If you hit the

api/v1/Schema/{id}endpoint, this is the response and you can see it works just fine.