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

A common event type between TS and Py #146

Closed
apolkingg8 opened this issue Nov 3, 2021 · 6 comments · Fixed by #155
Closed

A common event type between TS and Py #146

apolkingg8 opened this issue Nov 3, 2021 · 6 comments · Fixed by #155
Assignees
Labels
released utils Utilities and libraries

Comments

@apolkingg8
Copy link
Contributor

Add some common event type definitions (maybe JSON) that we can generate TypeScript interfaces and Python classes from this.

@apolkingg8
Copy link
Contributor Author

@kelvin-wong do you have any idea about this?

@kelvin-wong
Copy link
Collaborator

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.

@apolkingg8
Copy link
Contributor Author

Great! So the JSON schema would be generated from Py backend into shared lib (maybe libs/shared/util-event). May you show me an example of the generated JSON schema? I'll start working on this.

@apolkingg8 apolkingg8 self-assigned this Nov 3, 2021
@apolkingg8 apolkingg8 added the utils Utilities and libraries label Nov 3, 2021
@kelvin-wong
Copy link
Collaborator

@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"
      ]
    }
  }
}

@solomondefi-dev
Copy link
Collaborator

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 /dist.

I'm not sure if the contract actually generates ABIs to /dist yet, but it should be doing so, anything build related belongs there.

apolkingg8 added a commit that referenced this issue Nov 5, 2021
apolkingg8 added a commit that referenced this issue Nov 5, 2021
apolkingg8 added a commit that referenced this issue Nov 9, 2021
apolkingg8 added a commit that referenced this issue Nov 9, 2021
apolkingg8 added a commit that referenced this issue Nov 9, 2021
apolkingg8 added a commit that referenced this issue Nov 9, 2021
apolkingg8 added a commit that referenced this issue Nov 9, 2021
apolkingg8 added a commit that referenced this issue Nov 15, 2021
apolkingg8 added a commit that referenced this issue Nov 15, 2021
apolkingg8 added a commit that referenced this issue Nov 15, 2021
apolkingg8 added a commit that referenced this issue Nov 15, 2021
apolkingg8 added a commit that referenced this issue Nov 15, 2021
solomondefi-dev pushed a commit that referenced this issue Nov 17, 2021
solomondefi-dev pushed a commit that referenced this issue Nov 17, 2021
solomondefi-dev pushed a commit that referenced this issue Nov 17, 2021
@github-actions
Copy link

🎉 This issue has been resolved in version 1.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released utils Utilities and libraries
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants