-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
refactor(x/bank/v2): migrate to handlers #21659
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6a010f9
updates
julienrbrt 73f8d0a
Merge branch 'main' into julien/bank-handlers
julienrbrt 7fd8741
updates
julienrbrt c2bc89f
Merge branch 'main' into julien/bank-handlers
julienrbrt aa96109
disable autocli
julienrbrt 7e611b5
Merge branch 'main' into julien/bank-handlers
julienrbrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,36 @@ | ||
package bankv2 | ||
|
||
import ( | ||
"fmt" | ||
|
||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" | ||
"cosmossdk.io/x/bank/v2/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/version" | ||
) | ||
|
||
// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface. | ||
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { | ||
return &autocliv1.ModuleOptions{ | ||
Query: &autocliv1.ServiceCommandDescriptor{ | ||
Service: types.Query_serviceDesc.ServiceName, | ||
RpcCommandOptions: []*autocliv1.RpcCommandOptions{ | ||
{ | ||
RpcMethod: "Params", | ||
Use: "params", | ||
Short: "Query current bank/v2 parameters", | ||
}, | ||
}, | ||
}, | ||
Tx: &autocliv1.ServiceCommandDescriptor{ | ||
Service: types.Msg_serviceDesc.ServiceName, | ||
EnhanceCustomCommand: true, | ||
RpcCommandOptions: []*autocliv1.RpcCommandOptions{ | ||
{ | ||
RpcMethod: "UpdateParams", | ||
Use: "update-params-proposal <params>", | ||
Short: "Submit a proposal to update bank module params. Note: the entire params must be provided.", | ||
Example: fmt.Sprintf(`%s tx bank update-params-proposal '{ }'`, version.AppName), | ||
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}}, | ||
GovProposal: true, | ||
}, | ||
}, | ||
}, | ||
} | ||
return nil // Disable AutoCLI until https://github.com/cosmos/cosmos-sdk/issues/21682 is resolved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tracked by #21682 |
||
// return &autocliv1.ModuleOptions{ | ||
// Query: &autocliv1.ServiceCommandDescriptor{ | ||
// Service: "cosmos.bank.v2.Query", | ||
// RpcCommandOptions: []*autocliv1.RpcCommandOptions{ | ||
// { | ||
// RpcMethod: "Params", | ||
// Use: "params", | ||
// Short: "Query current bank/v2 parameters", | ||
// }, | ||
// }, | ||
// }, | ||
// Tx: &autocliv1.ServiceCommandDescriptor{ | ||
// Service: "cosmos.bank.v2.Msg", | ||
// EnhanceCustomCommand: true, | ||
// RpcCommandOptions: []*autocliv1.RpcCommandOptions{ | ||
// { | ||
// RpcMethod: "UpdateParams", | ||
// Use: "update-params-proposal <params>", | ||
// Short: "Submit a proposal to update bank module params. Note: the entire params must be provided.", | ||
// Example: fmt.Sprintf(`%s tx bank update-params-proposal '{ }'`, version.AppName), | ||
// PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}}, | ||
// GovProposal: true, | ||
// }, | ||
// }, | ||
// }, | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package keeper | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"errors" | ||
"fmt" | ||
|
||
"cosmossdk.io/x/bank/v2/types" | ||
) | ||
|
||
type handlers struct { | ||
*Keeper | ||
} | ||
|
||
// NewHandlers creates a new bank/v2 handlers | ||
func NewHandlers(k *Keeper) handlers { | ||
return handlers{k} | ||
} | ||
|
||
// UpdateParams updates the parameters of the bank/v2 module. | ||
func (h handlers) MsgUpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { | ||
authorityBytes, err := h.addressCodec.StringToBytes(msg.Authority) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if !bytes.Equal(h.authority, authorityBytes) { | ||
expectedAuthority, err := h.addressCodec.BytesToString(h.authority) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return nil, fmt.Errorf("invalid authority; expected %s, got %s", expectedAuthority, msg.Authority) | ||
} | ||
|
||
if err := msg.Params.Validate(); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := h.params.Set(ctx, msg.Params); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &types.MsgUpdateParamsResponse{}, nil | ||
} | ||
|
||
// QueryParams queries the parameters of the bank/v2 module. | ||
func (h handlers) QueryParams(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { | ||
if req == nil { | ||
return nil, errors.New("empty request") | ||
} | ||
|
||
params, err := h.params.Get(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &types.QueryParamsResponse{Params: params}, nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracked by #21683