warden-protocol / wardenprotocol

Monorepo for the Warden Protocol.
https://wardenprotocol.org
Apache License 2.0
1.1k stars 112 forks source link

Improve precompiles typings by utilizing enums consistently #1077

Closed Svetomech closed 1 week ago

Svetomech commented 1 week ago

Summary by CodeRabbit

coderabbitai[bot] commented 1 week ago
📝 Walkthrough
📝 Walkthrough ## Walkthrough The changes in this pull request involve a comprehensive update to the ABI definitions, function signatures, and data types within the Ethereum smart contracts related to the Warden precompile. Key modifications include the addition of new events, the replacement of `int32` types with `uint8` for various fields, and the introduction of enumerations for better type safety. Additionally, the artifact generation process has been streamlined to directly compile Solidity files into ABI files, eliminating reliance on pre-existing JSON files. ## Changes | File | Change Summary | |-------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `precompiles/act/abi.json` | Complete replacement of ABI definitions; added events (`ActionStateChange`, `ActionVoted`, `CreateAction`, `CreateTemplate`, `UpdateTemplate`) and updated function signatures while preserving input/output structures for backward compatibility. | | `precompiles/justfile` | Added prerequisite `_tools` to check for `solc`; replaced JSON ABI generation with direct compilation from Solidity files using `solc`, outputting to a temporary directory and processing with `jq`. | | `precompiles/warden/IWarden.go` | Updated data types from `int32` to `uint8` for fields in various structs; synchronized ABI definitions with these changes; updated comments to reflect new data types. | | `precompiles/warden/IWarden.sol` | Changed struct fields from `int32` to enumerations (`KeyType`, `AddressType`, `KeyRequestStatus`, `SignRequestStatus`); updated event signatures and function parameters accordingly. | | `precompiles/warden/events.go` | Modified event handling methods to adjust data types and packing logic for events; ensured error handling consistency. | | `precompiles/warden/query_types.go` | Updated data types from `int32` to `uint8` in various structures; enhanced error handling in functions; refined pagination handling and data mapping methods. | | `tests/cases/warden_precompile.go` | Changed `KeyType` field type from `int32` to `uint8` in test assertions. | | `tests/cases/warden_precompile_action.go`| Updated function calls and assertions to use `uint8` instead of `int32` for `KeyType` and `Status` parameters to ensure consistency with updated definitions. | ## Possibly related PRs - **#321**: The changes in the main PR regarding the ABI definitions and function signatures for actions and templates are related to the new RPC method `NewAction` and the `MsgNewAction` message introduced in this PR, which also deals with actions. - **#422**: This PR includes changes to the `x/warden` module that may relate to the overall structure and functionality of actions and templates, which are also addressed in the main PR. - **#975**: The addition of the "slinky" precompiled contract in this PR is relevant as it introduces new functionality that could interact with the ABI changes made in the main PR. - **#1042**: The introduction of a new `BroadcastType` field in the `SignRequest` struct and related methods enhances the functionality of signature requests, which aligns with the changes made in the main PR regarding ABI definitions. - **#1047**: The modifications to the voting functionality in this PR, particularly the addition of the `tryVoteAsSender` method, relate to the action management changes in the main PR. - **#1072**: The introduction of the `BasicOrder` contract and its functionalities may interact with the ABI changes in the main PR, particularly in how orders and actions are managed. ## Suggested labels `protocol`, `protobuf`, `x-warden`, `docs` ## Suggested reviewers - backsapc - artur-abliazimov

[!WARNING]

Rate limit exceeded

@Svetomech has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 13 seconds before requesting another review.

⌛ How to resolve this issue? After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work? CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our [FAQ](https://docs.coderabbit.ai/faq) for further information.
📥 Commits Reviewing files that changed from the base of the PR and between 3270fe3f475965343afece0195579493439910b3 and 515b5697dda5be235d8d0c0f03e65cd4e65626c0.

📜 Recent review details **Configuration used: .coderabbit.yaml** **Review profile: CHILL**
📥 Commits Reviewing files that changed from the base of the PR and between 3270fe3f475965343afece0195579493439910b3 and 515b5697dda5be235d8d0c0f03e65cd4e65626c0.
📒 Files selected for processing (1) * `CHANGELOG.md` (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
CHANGELOG.md (1) Pattern `**/*.md`: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"
🔇 Additional comments (1)
CHANGELOG.md (1) `50-50`: **LGTM! The changelog entry is well-formatted and descriptive.** The entry correctly documents the consensus-breaking change of converting status fields from int32 to enums/uint8, with a clear explanation of the improvement in type safety and consistency. It follows the required format and is placed in the appropriate section.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
github-actions[bot] commented 1 week ago

Hey @Svetomech and thank you for opening this pull request! 👋🏼

It looks like you forgot to add a changelog entry for your changes. Make sure to add a changelog entry in the 'CHANGELOG.md' file.

vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **warden-help-center** | ⬜️ Ignored ([Inspect](https://vercel.com/qrdo-foundation/warden-help-center/AJDfQGrzkgC1p38GBqQ8kEakckiF)) | [Visit Preview](https://warden-help-center-git-improve-precompil-f9a612-qrdo-foundation.vercel.app) | | Nov 20, 2024 11:57am |