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

Automatically generate/update Status.js and RequestType.js #1145

Open
11 tasks
janaakhterov opened this issue Jun 1, 2022 · 2 comments
Open
11 tasks

Automatically generate/update Status.js and RequestType.js #1145

janaakhterov opened this issue Jun 1, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Issues which are ideal for a first time or new project contributor. hacktoberfest Issues shown by lists for the Hacktoberfest and made for newcomers to do the first contribution. p3

Comments

@janaakhterov
Copy link
Contributor

janaakhterov commented Jun 1, 2022

🆕🐥 First Timers Only

This issue is reserved for people who have never contributed to Hedera or any open source project in general.
We know that creating a pull request (PR) is a major barrier for new contributors.
The goal of this issue and all other issues labeled by 'good first issue' is to help you make your first contribution to Hedera.

👾 Description of the issue

Problem

Currently, both Status.js and RequestType.js must be manually updated whenever new statuses or request types are introduced. While tools and scripts can streamline this process, it still requires manual execution and oversight. In particular, files like Status.js are prone to human error when manually updating the various status codes and response codes associated with Hedera transactions. Automating this process would eliminate the need for human intervention, ensure accuracy, and save time when new statuses or request types are added to the Hedera system.

For example, Status.js currently contains manually hardcoded status codes:

case Status.Ok:
  return "OK";
case Status.InvalidTransaction:
  return "INVALID_TRANSACTION";
case Status.PayerAccountNotFound:
  return "PAYER_ACCOUNT_NOT_FOUND"

Here are examples for manually adding the statuses:
Example 1
Example 2
Example 3

If a new status code is introduced in the Hedera protobuf definitions, this file would need to be manually updated to reflect that change.

Solution

Automate the generation or updating of Status.js and RequestType.js by connecting the process directly to the Hedera protobuf definitions. This way, whenever new status codes or request types are introduced in the protobuf schema, the corresponding JavaScript files will be automatically updated or regenerated. This could be done by writing a script that parses the protobuf definitions and generates the JavaScript constants, ensuring that all relevant status codes and request types are always up-to-date.

Steps to Implement

  1. Create or modify a script to parse the Hedera protobuf definitions (such as ResponseCodeEnum).
  2. The script should automatically generate or update the content of Status.js and RequestType.js, appending new statuses and request types as needed.
  3. Integrate this script into the build or CI/CD pipeline so that the files are always updated whenever new protobuf definitions are added.

Additional Context

Given that Hedera is tightly integrated with protobuf, having the ability to pull in new status codes from the protobuf schema directly into the JavaScript files would ensure consistency across the ecosystem, especially during frequent updates.

Affected Environment

Hedera SDK Version: Any
Operating System: Platform-independent (process needs to work across all environments)

📋 Step by step guide to do a contribution

If you have never contributed to an open source project at GitHub, the following step-by-step guide will introduce you to the workflow. More information and concrete samples for shell commands for each step can be found in our CONTRIBUTING.md file.
A more detailed general documentation of the GitHub PR workflow can be found here.

  • Claim this issue: Comment below that you are interested in working on the issue
  • Wait for assignment: A community member with the given rights will add you as an assignee of the issue
  • Fork the repository: You can do that in GitHub (by simply clicking the 'fork' button).
  • Check out the forked repository
  • Create a feature branch for the issue. We do not have a hard naming definition for branches but it is best practice to prefix the branch name with the issue id.
  • Solve the issue in your branch.
  • Commit your changes: Here, it is needed to add sign-off information to the commit to accept the "Developer Certificate of Origin" (https://developercertificate.org). More details can be found in our CONTRIBUTING.md
  • Start a Pull Request (PR): We have a pattern for naming pull requests that a GitHub Action checks. We use that pattern to support the creation of automatic release notes.
  • Check GitHub Actions: Several GitHub Actions will be triggered automatically for each PR. If a GitHub Action fails and you do not understand the cause of that error do not hesitate to add a comment to the PR and ask the Hedera developer community for support.
  • Wait for reviews: Members of the Hedera developer community will review your PR. If a reviewer finds any missing pieces or a problem, he or she will start a discussion with you and describe the next steps for solving the problem.
  • You did it 🎉: We will merge the fix in the develop branch. Thanks for being part of the Hedera community as an open-source contributor ❤️

🎉 Contribute to Hacktoberfest

Solve this issue as part of the Hacktoberfest event and get a chance to receive cool goodies like a T-Shirt. 🎽

🤔 Additional Information

If you have any questions, just ask us directly in this issue by adding a comment. You can join our community chat at Discord. A general manual about open-source contributions can be found here.

@janaakhterov janaakhterov added the enhancement New feature or request label Jun 1, 2022
@SimiHunjan SimiHunjan moved this to Backlog in SDK Sprint Board Jun 2, 2022
@SimiHunjan SimiHunjan added the p2 label Jun 2, 2022
@SimiHunjan SimiHunjan added this to the v2.17.0-beta.1 milestone Jun 2, 2022
@janaakhterov janaakhterov modified the milestones: v2.16.0, 2.17.0 Jun 21, 2022
@SimiHunjan SimiHunjan moved this from Backlog to Sprint Backlog in SDK Sprint Board Jul 5, 2022
@janaakhterov janaakhterov modified the milestones: 2.17.0-beta.1, 2.17.0 Jul 6, 2022
@janaakhterov
Copy link
Contributor Author

Something to note here, with Java auto-generating these files already the hick-up we faced was when the protobufs renamed HederaFunctionality.Prng -> HederaFunctionality.UtilPrng. This would cause (and did cause) a breaking change in Java. So, the question is, should the SDKs keep up to date with the names in the protobufs for certain enums such as ResponseCodeEnum and HederaFunctionality, or should the SDKs hard-code a name?

@janaakhterov janaakhterov modified the milestones: 2.17.1, 2.17.2 Aug 1, 2022
@janaakhterov janaakhterov modified the milestones: 2.18.0, 2.18.1 Aug 15, 2022
@janaakhterov janaakhterov modified the milestones: 2.18.1, 2.18.2 Aug 29, 2022
@SimiHunjan SimiHunjan modified the milestones: 2.18.2, 2.18.3 Sep 19, 2022
@janaakhterov janaakhterov modified the milestones: 2.18.3, 2.18.4 Oct 3, 2022
@SimiHunjan SimiHunjan modified the milestones: 2.18.4, 2.18.5 Oct 17, 2022
@agadzhalov agadzhalov added the good first issue candidate Issues that can become a good first issue but need more description/context. label Sep 4, 2024
@hendrikebbers hendrikebbers added good first issue Issues which are ideal for a first time or new project contributor. hacktoberfest Issues shown by lists for the Hacktoberfest and made for newcomers to do the first contribution. and removed good first issue candidate Issues that can become a good first issue but need more description/context. labels Oct 17, 2024
@hendrikebbers
Copy link
Member

We discussed about the issue in the hackathon today and have some questions about status and requestType. Before somebody work on the issues we should check if we can find a better solution. See hashgraph/hedera-sdk-java#2040

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Issues which are ideal for a first time or new project contributor. hacktoberfest Issues shown by lists for the Hacktoberfest and made for newcomers to do the first contribution. p3
Projects
Status: Sprint Backlog
Development

No branches or pull requests

5 participants