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

Rfp #110

Merged
merged 56 commits into from
May 20, 2024
Merged

Rfp #110

merged 56 commits into from
May 20, 2024

Conversation

PolyProgrammist
Copy link
Collaborator

@PolyProgrammist PolyProgrammist commented Apr 27, 2024

Summary by CodeRabbit

  • New Features

    • Introduced Request for Proposals (RFP) functionality, including methods to add, edit, and retrieve RFPs.
    • Added support for global labels and their management.
    • Enhanced proposal management with new fields and methods for updating proposal labels and timelines.
  • Improvements

    • Updated dependencies to support new features, including enabling unstable features in near-sdk.
  • Bug Fixes

    • Improved data structure handling for better performance and reliability in managing proposals and RFPs.

Copy link

coderabbitai bot commented May 2, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The update brings significant enhancements to the project by enabling the "unstable" feature in the near-sdk dependency and expanding the functionality related to Request for Proposals (RFPs). It introduces new modules, structs, and methods to manage RFPs, update proposals, and handle contract migrations.

Changes

Files Change Summary
Cargo.toml Modified near-sdk dependency to include features = ["unstable"].
src/lib.rs Added pub mod rfp, new fields in Contract, and several new methods for managing RFPs.
src/migrations.rs Introduced ContractV11 and added unsafe_add_rfp() function.
src/proposal/mod.rs Added RFPId import, new ProposalBodyV1 struct, updated VersionedProposalBody, and new methods for proposal updates.
src/rfp/mod.rs Added new modules, structs, enums, and methods for handling RFPs and their snapshots.

🐇✨ In code's embrace, new features bloom,
With RFPs, our project zooms.
Contracts grow, evolve, and shine,
Proposals dance in structured line.
A leap ahead, with changes vast,
Our software's future, now steadfast. 🚀


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
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@PolyProgrammist PolyProgrammist marked this pull request as ready for review May 2, 2024 08:40
@PolyProgrammist PolyProgrammist requested a review from frol May 2, 2024 08:40
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Out of diff range and nitpick comments (2)
src/proposal/repost.rs (2)

Line range hint 8-24: Optimize cloning operations in proposal_repost_text.

Similar to the RFP repost function, consider reducing the use of clone() when accessing the latest version of the proposal body. This could improve performance, especially if the body is large.


Line range hint 27-49: Ensure efficient JSON handling in repost_internal and publish_to_socialdb_feed.

The JSON construction in repost_internal could be optimized by avoiding redundant conversions to strings. Additionally, ensure that the division of gas in publish_to_socialdb_feed is appropriate and does not lead to gas exhaustion.

src/rfp/repost.rs Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between d74fe92 and 3b71c5b.
Files selected for processing (1)
  • src/lib.rs (19 hunks)
Additional comments not posted (15)
src/lib.rs (15)

Line range hint 9-22: Addition of the rfp module and related imports looks good.


58-60: New fields for managing RFPs in the Contract struct are correctly added and initialized.

Also applies to: 83-85


169-183: New methods for retrieving RFPs are correctly implemented.


348-407: The add_rfp method is well-implemented with necessary checks.


420-428: The set_rfp_block_height_callback method is correctly implemented.


459-465: The get_rfps_by_label method is correctly implemented.


519-522: The is_allowed_to_write_rfps method is correctly implemented.


932-941: The edit_rfp method is well-implemented with necessary checks.


943-963: The cancel_rfp method is correctly implemented and handles related proposals.


965-974: The edit_rfp_timeline method is correctly implemented.


976-1062: The edit_rfp_internal method is well-implemented with necessary checks.


1082-1087: The get_rfp_linked_proposals method is correctly implemented.


1089-1104: The set_global_labels method is correctly implemented.


1403-1412: The get_moderators method is correctly implemented.


1420-1431: The LabelInfo and LabelInfoExtended structs are correctly defined and implemented.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Out of diff range and nitpick comments (9)
src/lib.rs (9)

9-9: Add a comment explaining the purpose of the rfp module.

pub mod rfp; // Module for managing Requests for Proposals (RFPs)

169-172: Consider adding a comment to explain the purpose of the get_rfps method.

/// Retrieves all RFPs.
pub fn get_rfps(&self) -> Vec<VersionedRFP> {

174-177: Consider adding a comment to explain the purpose of the get_rfp method.

/// Retrieves a specific RFP by its ID.
pub fn get_rfp(&self, rfp_id: RFPId) -> VersionedRFP {

179-182: Consider adding a comment to explain the purpose of the get_all_rfp_ids method.

/// Retrieves all RFP IDs.
pub fn get_all_rfp_ids(&self) -> Vec<RFPId> {

420-429: Consider adding a comment to explain the purpose of the set_rfp_block_height_callback method.

/// Callback to set the block height for an RFP.
pub fn set_rfp_block_height_callback(

460-466: Consider adding a comment to explain the purpose of the get_rfps_by_label method.

/// Retrieves RFPs by a specific label.
pub fn get_rfps_by_label(&self, label: String) -> Vec<RFPId> {

520-523: Consider adding a comment to explain the purpose of the is_allowed_to_write_rfps method.

/// Checks if the editor is allowed to write RFPs.
pub fn is_allowed_to_write_rfps(&self, editor: AccountId) -> bool {

1078-1083: Consider adding a comment to explain the purpose of the get_rfp_linked_proposals method.

/// Retrieves proposals linked to a specific RFP.
pub fn get_rfp_linked_proposals(&self, rfp_id: RFPId) -> Vec<ProposalId> {

1399-1408: Consider adding a comment to explain the purpose of the get_moderators method.

/// Retrieves the list of moderators.
fn get_moderators(&self) -> HashSet<AccountId> {
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3b71c5b and 90e5616.
Files selected for processing (1)
  • src/lib.rs (19 hunks)
Additional comments not posted (7)
src/lib.rs (7)

83-85: Ensure the initialization of rfps, label_to_rfps, and global_labels_info is correct.


348-407: Ensure proper error handling and validation in the add_rfp method.


933-942: Ensure proper error handling and validation in the edit_rfp method.


944-964: Ensure proper error handling and validation in the cancel_rfp method.


966-975: Ensure proper error handling and validation in the edit_rfp_timeline method.


977-1058: Ensure proper error handling and validation in the edit_rfp_internal method.


1085-1100: Ensure proper error handling and validation in the set_global_labels method.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 90e5616 and 67ec21a.
Files selected for processing (1)
  • src/lib.rs (19 hunks)
Additional comments not posted (10)
src/lib.rs (10)

9-9: Ensure the new rfp module is correctly integrated and follows the project's module organization conventions.


Line range hint 70-85: Ensure the new fields for RFP management are correctly initialized and follow best practices.


169-172: Ensure the get_rfps method is correctly implemented and follows best practices.


174-177: Ensure the get_rfp method is correctly implemented and follows best practices.


348-399: Ensure the add_rfp method is correctly implemented and follows best practices.


925-934: Ensure the edit_rfp method is correctly implemented and follows best practices.


936-956: Ensure the cancel_rfp method is correctly implemented and follows best practices.


958-967: Ensure the edit_rfp_timeline method is correctly implemented and follows best practices.


452-458: Ensure the get_rfps_by_label method is correctly implemented and follows best practices.


1062-1077: Ensure the set_global_labels method is correctly implemented and follows best practices.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 67ec21a and 04187bb.
Files selected for processing (3)
  • src/lib.rs (20 hunks)
  • src/proposal/mod.rs (4 hunks)
  • src/rfp/mod.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/rfp/mod.rs
Additional comments not posted (13)
src/proposal/mod.rs (5)

8-10: Ensure that the new imports are necessary and used within the file.

Please verify that the Contract, str_serializers, and rfp::RFPId imports are utilized within this module.


88-107: The ProposalBodyV1 struct is well-defined and follows the existing pattern. Ensure that all necessary fields are included.


113-115: The VersionedProposalBody enum correctly includes the new V1 variant, maintaining backward compatibility.


117-133: The From implementations for ProposalBodyV0 and ProposalBodyV1 ensure proper conversion between versions and handle the conversion logic appropriately.

Also applies to: 145-149


167-169: The latest_version method in VersionedProposalBody is straightforward and correctly implemented.

src/lib.rs (8)

Line range hint 70-85: Initialization logic for new fields related to RFPs looks good.


161-163: The get_rfps method implementation looks good.


165-167: The get_rfp method implementation looks good.


334-384: The add_rfp method implementation looks good and includes necessary checks.


709-717: The edit_rfp method implementation looks good.


719-738: The cancel_rfp method implementation looks good and includes necessary logic for handling related proposals.


433-438: The get_rfps_by_label method implementation looks good.


397-406: The set_rfp_block_height_callback method implementation looks good.

Comment on lines +20 to +22
use rfp::{
RFPId, RFPSnapshot, TimelineStatus as RFPTimelineStatus, VersionedRFP, VersionedRFPBody, RFP,
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider grouping related imports together for better readability. For example, group all rfp related imports together.

use rfp::{
    RFPId, RFPSnapshot, TimelineStatus as RFPTimelineStatus, VersionedRFP, VersionedRFPBody, RFP,
};

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
use rfp::{
RFPId, RFPSnapshot, TimelineStatus as RFPTimelineStatus, VersionedRFP, VersionedRFPBody, RFP,
};
use rfp::{
RFPId, RFPSnapshot, TimelineStatus as RFPTimelineStatus, VersionedRFP, VersionedRFPBody, RFP,
};

src/proposal/mod.rs Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 04187bb and 138f923.
Files selected for processing (2)
  • src/lib.rs (20 hunks)
  • src/rfp/mod.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/rfp/mod.rs
Additional comments not posted (14)
src/lib.rs (14)

161-163: The get_rfps method looks good. Ensure that the VersionedRFP type is correctly handled in the calling code.


165-167: The get_rfp method looks good. Ensure that the RFPId type is correctly handled in the calling code.


169-171: The get_all_rfp_ids method looks good. Ensure that the RFPId type is correctly handled in the calling code.


334-384: The add_rfp method is well-implemented. Ensure that the VersionedRFPBody type is correctly handled in the calling code and that the required permissions are properly managed.


397-406: The set_rfp_block_height_callback method is well-implemented. Ensure that the SetReturnType type is correctly handled in the calling code.


433-438: The get_rfps_by_label method looks good. Ensure that the RFPId type is correctly handled in the calling code.


487-489: The is_allowed_to_write_rfps method is well-implemented. Ensure that the required permissions are properly managed.


709-717: The edit_rfp method is well-implemented. Ensure that the VersionedRFPBody type is correctly handled in the calling code and that the required permissions are properly managed.


739-746: The edit_rfp_timeline method is well-implemented. Ensure that the RFPTimelineStatus type is correctly handled in the calling code and that the required permissions are properly managed.


752-761: The get_global_labels method is well-implemented. Ensure that the LabelInfoExtended type is correctly handled in the calling code.


763-767: The get_rfp_linked_proposals method looks good. Ensure that the RFPId and ProposalId types are correctly handled in the calling code.


769-781: The set_global_labels method is well-implemented. Ensure that the LabelInfoExtended type is correctly handled in the calling code and that the required permissions are properly managed.


1098-1101: The LabelInfo struct is well-defined. Ensure that the optional fields are correctly handled in the calling code.


1103-1108: The LabelInfoExtended struct is well-defined. Ensure that the optional fields are correctly handled in the calling code.

src/lib.rs Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 138f923 and e3aef28.
Files selected for processing (4)
  • src/lib.rs (20 hunks)
  • src/migrations.rs (12 hunks)
  • src/proposal/mod.rs (4 hunks)
  • src/rfp/mod.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/rfp/mod.rs
Additional comments not posted (7)
src/proposal/mod.rs (5)

90-107: ProposalBodyV1 struct looks good and correctly extends ProposalBodyV0 with the linked_rfp field.


113-115: VersionedProposalBody enum is well-defined with variants for V0 and V1.


117-133: The From implementations for ProposalBodyV0, ProposalBodyV1, and VersionedProposalBody are correctly implemented.

Also applies to: 145-149, 160-163


166-169: The latest_version method in VersionedProposalBody is correctly implemented to return ProposalBodyV1.


Line range hint 172-180: The get_subscribers function is well-implemented to extract subscribers from ProposalBodyV1.

src/migrations.rs (2)

652-687: The unsafe_add_rfp function correctly handles the migration to include RFP-related fields in the contract state.


692-709: The ContractV11 struct is well-defined and includes necessary fields for managing RFPs.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e3aef28 and 59aeb8a.
Files selected for processing (3)
  • Cargo.toml (1 hunks)
  • src/lib.rs (20 hunks)
  • src/migrations.rs (13 hunks)
Files skipped from review due to trivial changes (1)
  • Cargo.toml
Additional comments not posted (4)
src/migrations.rs (2)

691-710: LGTM! The ContractV11 struct definition is consistent with the previous versions and includes the new fields for RFP management.


816-819: LGTM! The migration logic for StateVersion::V10 to StateVersion::V11 is correctly added to the unsafe_migrate function.

src/lib.rs (2)

9-9: The import statement for the rfp module is correctly added and grouped with related imports.


59-61: The new fields rfps, label_to_rfps, and global_labels_info are correctly added to the Contract struct and initialized in the new method.

src/migrations.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 59aeb8a and bf792fa.
Files selected for processing (1)
  • src/rfp/mod.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/rfp/mod.rs

src/rfp/repost.rs Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between bf792fa and 9b7baba.
Files selected for processing (1)
  • src/lib.rs (20 hunks)
Additional comments not posted (12)
src/lib.rs (12)

9-9: Added pub mod rfp to expose RFP-related functionality.


20-22: Grouped RFP-related imports for better organization and readability.


59-61: Added new fields to the Contract struct to support RFP functionality.


84-86: Initialized new fields in the Contract constructor.


162-164: Method get_rfps retrieves all RFPs. Consider handling potential errors when converting the Vector to a Vec.


166-168: Method get_rfp retrieves a specific RFP by ID. Consider handling potential errors more gracefully.


170-172: Method get_all_rfp_ids retrieves all RFP IDs. Consider handling potential errors when converting the Vector length.


381-390: Method set_rfp_block_height_callback sets the block height for an RFP. Consider handling potential errors more gracefully.


417-422: Method get_rfps_by_label retrieves RFPs by label. Consider handling potential errors more gracefully.


471-473: Method is_allowed_to_write_rfps checks if the editor is allowed to write RFPs. Consider handling potential errors more gracefully.


693-701: Method edit_rfp edits an RFP. Consider handling potential errors more gracefully.


736-745: Method get_global_labels retrieves global labels. Consider handling potential errors more gracefully.

Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the last round of review. Please, address these several comments and let's get it merged

src/lib.rs Outdated Show resolved Hide resolved
src/rfp/mod.rs Outdated Show resolved Hide resolved
src/rfp/mod.rs Outdated Show resolved Hide resolved
src/rfp/repost.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PolyProgrammist Great job! Thanks for addressing the review comments quickly.

@frol frol merged commit b68c0c2 into NEAR-DevHub:main May 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants