-
Notifications
You must be signed in to change notification settings - Fork 3
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
A common event type between TS and Py #146
Comments
@kelvin-wong do you have any idea about this? |
It's a good idea! For the Python backend, we are already defined schemas to validate the event messages. From the framework we used, there is a library that could convert those schemas into JSON schema definitions. I think it could be easy for TypeScript to generate interfaces from JSON schemas. |
Great! So the JSON schema would be generated from Py backend into shared lib (maybe |
@apolkingg8 FYR {
"title": "My Schema",
"definitions": {
"DisputeCreatedEvent": {
"title": "DisputeCreatedEvent",
"type": "object",
"properties": {
"type": {
"title": "Type",
"type": "string"
},
"party1": {
"title": "Party1",
"type": "string"
},
"party2": {
"title": "Party2",
"type": "string"
},
"contract": {
"title": "Contract",
"type": "string"
},
"id": {
"title": "Id",
"type": "string"
},
"judgeContract": {
"title": "Judgecontract",
"type": "string"
}
},
"required": [
"type",
"party1",
"party2",
"contract",
"id",
"judgeContract"
]
},
"EvidenceSubmittedEvent": {
"title": "EvidenceSubmittedEvent",
"type": "object",
"properties": {
"type": {
"title": "Type",
"type": "string"
},
"party1": {
"title": "Party1",
"type": "string"
},
"party2": {
"title": "Party2",
"type": "string"
},
"contract": {
"title": "Contract",
"type": "string"
},
"id": {
"title": "Id",
"type": "string"
},
"judgeContract": {
"title": "Judgecontract",
"type": "string"
},
"evidenceUrl": {
"title": "Evidenceurl",
"type": "string"
},
"submitter": {
"title": "Submitter",
"type": "string"
}
},
"required": [
"type",
"party1",
"party2",
"contract",
"id",
"judgeContract",
"evidenceUrl",
"submitter"
]
},
"PaymentCreatedEvent": {
"title": "PaymentCreatedEvent",
"type": "object",
"properties": {
"type": {
"title": "Type",
"type": "string"
},
"party1": {
"title": "Party1",
"type": "string"
},
"party2": {
"title": "Party2",
"type": "string"
},
"contract": {
"title": "Contract",
"type": "string"
},
"id": {
"title": "Id",
"type": "string"
},
"judgeContract": {
"title": "Judgecontract",
"type": "string"
},
"token": {
"title": "Token",
"type": "string"
},
"discount": {
"title": "Discount",
"minimum": 0,
"maximum": 100,
"type": "integer"
},
"ethPaid": {
"title": "Ethpaid",
"type": "string"
}
},
"required": [
"type",
"party1",
"party2",
"contract",
"id",
"judgeContract",
"token",
"discount",
"ethPaid"
]
}
}
} |
My instinct is that this can be auto-generated from the smart contract ABI. Maybe we can have a simple script to do that from generated ABIs in I'm not sure if the contract actually generates ABIs to |
🎉 This issue has been resolved in version 1.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Add some common event type definitions (maybe JSON) that we can generate TypeScript interfaces and Python classes from this.
The text was updated successfully, but these errors were encountered: