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

fix(btcstaking): restore AddReceiver/RemoveReceiver #47

Merged
merged 5 commits into from
Jun 17, 2024

Conversation

473n
Copy link
Contributor

@473n 473n commented Jun 17, 2024

Summary by CodeRabbit

  • New Features

    • Introduced functionality to add and remove receivers.
  • Deprecations

    • AddReceiver and RemoveReceiver methods now return deprecation errors, advising the use of UpdateParams instead.

Copy link

coderabbitai bot commented Jun 17, 2024

Warning

Rate limit exceeded

@473n has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 7 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 for further information.

Commits

Files that changed from the base of the PR and between fa216ed and ba7db67.

Walkthrough

Recent updates to the lorenzo/btcstaking module introduce new RPCs and message types to manage receivers. Specifically, MsgAddReceiver and MsgRemoveReceiver have been added for this purpose. Despite these additions, the msgServer struct's methods for adding and removing receivers now instruct users to utilize the UpdateParams method instead.

Changes

File Change Summary
proto/lorenzo/btcstaking/v1/tx.proto Added AddReceiver and RemoveReceiver RPCs, and defined associated messages.
x/btcstaking/keeper/msg_server.go Implemented AddReceiver and RemoveReceiver methods with deprecation warnings.
x/btcstaking/types/msg.go Introduced MsgRemoveReceiver and MsgAddReceiver message types, and added required methods.

Poem

In the realm where code does play,
New additions led the way.
Receivers here and receivers gone,
With new methods, code moves on.
Though deprecated paths we see,
UpdateParams is where to be!
Hopping through the code so clear,
A rabbit’s joy with changes near. 🐇✨


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.
    • @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 as 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.

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.

@473n 473n requested a review from sheldonleedev June 17, 2024 05:22
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c8314e4 and fa216ed.

Files ignored due to path filters (1)
  • x/btcstaking/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (3)
  • proto/lorenzo/btcstaking/v1/tx.proto (2 hunks)
  • x/btcstaking/keeper/msg_server.go (1 hunks)
  • x/btcstaking/types/msg.go (3 hunks)
Additional comments not posted (8)
x/btcstaking/types/msg.go (6)

6-6: Added import for errorsmod is appropriate given its use in error handling within the new message types.


17-18: The interface assertions for MsgRemoveReceiver and MsgAddReceiver ensure that these types correctly implement the sdk.Msg interface.


36-39: The GetSigners method for MsgAddReceiver correctly retrieves the address from the Authority field. Ensure that the Authority field is always set correctly as this method assumes it is in Bech32 format.


41-48: The ValidateBasic method for MsgAddReceiver adequately checks for the validity of the Authority address and the Receiver. The use of errorsmod.Wrap provides a clear error context.


51-54: Similar to MsgAddReceiver, the GetSigners method for MsgRemoveReceiver retrieves the signer's address. Consistency in handling addresses across message types is good practice.


56-63: The ValidateBasic method for MsgRemoveReceiver performs necessary validations on the Authority address and checks if the Receiver field is not empty, which is crucial for identifying the target receiver.

proto/lorenzo/btcstaking/v1/tx.proto (2)

20-23: The addition of AddReceiver and RemoveReceiver RPC methods in the service definition allows external clients to interact with these functionalities through gRPC. Ensure that the corresponding server implementations are correctly handling these calls.


70-86: The message types MsgAddReceiver and MsgRemoveReceiver are well-defined with necessary fields. The use of [ (cosmos_proto.scalar) = "cosmos.AddressString" ] ensures that the authority field is treated as a string representation of an address, which is consistent with Cosmos SDK standards.

Comment on lines 283 to 288
func (ms msgServer) AddReceiver(goCtx context.Context, req *types.MsgAddReceiver) (*types.MsgAddReceiverResponse, error) {
return nil, fmt.Errorf("deprecated, use UpdateParams instead")
}
func (ms msgServer) RemoveReceiver(goCtx context.Context, req *types.MsgRemoveReceiver) (*types.MsgRemoveReceiverResponse, error) {
return nil, fmt.Errorf("deprecated, use UpdateParams instead")
}
Copy link

Choose a reason for hiding this comment

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

The methods AddReceiver and RemoveReceiver are marked as deprecated and advise the use of UpdateParams instead. If these methods are not intended to be used, consider removing them or implementing a redirect mechanism within these methods to UpdateParams.

Comment on lines +70 to +79
message MsgAddReceiver {
option (cosmos.msg.v1.signer) = "authority";

string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

Receiver receiver = 2 [ (gogoproto.nullable) = false ];
}

message MsgAddReceiverResponse {}
message MsgRemoveReceiver {
Copy link
Contributor

Choose a reason for hiding this comment

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

MsgAddReceiver and MsgRemoveReceiver should be registered.example:

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
	// Register messages
	registry.RegisterImplementations(
		(*sdk.Msg)(nil),
		&MsgCreateBTCStaking{},
		&MsgBurnRequest{},
                &MsgAddReceiver{},
                &MsgRemoveReceiver{},
	)

	msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@sheldonleedev sheldonleedev merged commit f1a431d into main Jun 17, 2024
3 checks passed
@sheldonleedev sheldonleedev deleted the restore_add_receivers branch June 17, 2024 07:17
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.

4 participants