-
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
feat(bank/v2): create module boilerplate #21559
Changes from 6 commits
2dc193d
a181f48
1a8b807
65f4b86
a5db3b8
d1cdfcf
ffefbac
6110c3d
67156b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,9 @@ import ( | |
_ "cosmossdk.io/x/authz/module" // import for side-effects | ||
_ "cosmossdk.io/x/bank" // import for side-effects | ||
banktypes "cosmossdk.io/x/bank/types" | ||
_ "cosmossdk.io/x/bank/v2" // import for side-effects | ||
bankv2types "cosmossdk.io/x/bank/v2/types" | ||
bankmodulev2 "cosmossdk.io/x/bank/v2/types/module" | ||
_ "cosmossdk.io/x/circuit" // import for side-effects | ||
circuittypes "cosmossdk.io/x/circuit/types" | ||
_ "cosmossdk.io/x/consensus" // import for side-effects | ||
|
@@ -66,8 +69,7 @@ import ( | |
|
||
"github.com/cosmos/cosmos-sdk/runtime" | ||
_ "github.com/cosmos/cosmos-sdk/testutil/x/counter" // import for side-effects | ||
countertypes "github.com/cosmos/cosmos-sdk/testutil/x/counter/types" | ||
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects | ||
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
_ "github.com/cosmos/cosmos-sdk/x/auth/vesting" // import for side-effects | ||
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" | ||
|
@@ -153,6 +155,7 @@ var ( | |
accounts.ModuleName, | ||
authtypes.ModuleName, | ||
banktypes.ModuleName, | ||
bankv2types.ModuleName, | ||
distrtypes.ModuleName, | ||
stakingtypes.ModuleName, | ||
slashingtypes.ModuleName, | ||
|
@@ -284,10 +287,9 @@ var ( | |
Name: epochstypes.ModuleName, | ||
Config: appconfig.WrapAny(&epochsmodulev1.Module{}), | ||
}, | ||
// This module is only used for testing the depinject gogo x pulsar module registration. | ||
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. bank/v2 uses gogoproto for app config, so we don't need to test with counter |
||
{ | ||
Name: countertypes.ModuleName, | ||
Config: appconfig.WrapAny(&countertypes.Module{}), | ||
Name: bankv2types.ModuleName, | ||
Config: appconfig.WrapAny(&bankmodulev2.Module{}), | ||
}, | ||
}, | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
|
||
package cosmos.bank.module.v2; | ||
|
||
import "cosmos/app/v1alpha1/module.proto"; | ||
|
||
option go_package = "cosmossdk.io/x/bank/v2/types/module"; | ||
|
||
// Module is the config object of the bank module. | ||
message Module { | ||
option (cosmos.app.v1alpha1.module) = { | ||
go_import: "cosmossdk.io/x/bank/v2" | ||
}; | ||
|
||
// authority defines the custom module authority. If not set, defaults to the governance module. | ||
string authority = 1; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
syntax = "proto3"; | ||
package cosmos.bank.v2; | ||
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. Directory structure does not match package declaration. According to the static analysis tool, files with the package Toolsbuf
|
||
|
||
option go_package = "cosmossdk.io/x/bank/v2/types"; | ||
|
||
// Params defines the parameters for the bank/v2 module. | ||
message Params {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto3"; | ||
package cosmos.bank.v2; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos/bank/v2/bank.proto"; | ||
import "amino/amino.proto"; | ||
|
||
option go_package = "cosmossdk.io/x/bank/v2/types"; | ||
|
||
// GenesisState defines the bank/v2 module's genesis state. | ||
message GenesisState { | ||
// params defines all the parameters of the module. | ||
Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
syntax = "proto3"; | ||
package cosmos.bank.v2; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "cosmos/query/v1/query.proto"; | ||
import "amino/amino.proto"; | ||
import "cosmos/bank/v2/bank.proto"; | ||
|
||
option go_package = "cosmossdk.io/x/bank/v2/types"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
// Params queries the parameters of x/bank module. | ||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { | ||
option (cosmos.query.v1.module_query_safe) = true; | ||
option (google.api.http).get = "/cosmos/bank/v2/params"; | ||
} | ||
} | ||
|
||
// QueryParamsRequest defines the request type for querying x/bank/v2 parameters. | ||
message QueryParamsRequest {} | ||
|
||
// QueryParamsResponse defines the response type for querying x/bank/v2 parameters. | ||
message QueryParamsResponse { | ||
// params provides the parameters of the bank module. | ||
Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
syntax = "proto3"; | ||
package cosmos.bank.v2; | ||
|
||
import "gogoproto/gogo.proto"; | ||
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. Issue: Missing import file. The import statement for Please verify the existence of the Toolsbuf
|
||
import "cosmos/bank/v2/bank.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmos/msg/v1/msg.proto"; | ||
import "amino/amino.proto"; | ||
|
||
option go_package = "cosmossdk.io/x/bank/v2/types"; | ||
|
||
// Msg defines the bank Msg service. | ||
service Msg { | ||
option (cosmos.msg.v1.service) = true; | ||
|
||
// UpdateParams defines a governance operation for updating the x/bank/v2 module parameters. | ||
// The authority is defined in the keeper. | ||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse) {} | ||
} | ||
|
||
// MsgUpdateParams is the Msg/UpdateParams request type. | ||
message MsgUpdateParams { | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
|
||
julienrbrt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// authority is the address that controls the module (defaults to x/gov unless overwritten). | ||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; | ||
|
||
// params defines the x/bank parameters to update. | ||
// NOTE: All parameters must be supplied. | ||
Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; | ||
} | ||
|
||
// MsgUpdateParamsResponse defines the response structure for executing a MsgUpdateParams message. | ||
message MsgUpdateParamsResponse {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- | ||
Guiding Principles: | ||
Changelogs are for humans, not machines. | ||
There should be an entry for every single version. | ||
The same types of changes should be grouped. | ||
Versions and sections should be linkable. | ||
The latest version comes first. | ||
The release date of each version is displayed. | ||
Mention whether you follow Semantic Versioning. | ||
Usage: | ||
Change log entries are to be added to the Unreleased section under the | ||
appropriate stanza (see below). Each entry should ideally include a tag and | ||
the Github issue reference in the following format: | ||
* (<tag>) [#<issue-number>] Changelog message. | ||
Types of changes (Stanzas): | ||
"Features" for new features. | ||
"Improvements" for changes in existing functionality. | ||
"Deprecated" for soon-to-be removed features. | ||
"Bug Fixes" for any bug fixes. | ||
"API Breaking" for breaking exported APIs used by developers building on SDK. | ||
Ref: https://keepachangelog.com/en/1.0.0/ | ||
--> | ||
|
||
# Changelog | ||
|
||
## [Unreleased] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
julienrbrt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sidebar_position: 1 | ||
--- | ||
|
||
# `x/bank/v2` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
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.
Ensure correct integration of bank/v2 module in the application configuration.
The configuration for
bankv2types.ModuleName
andbankmodulev2.Module
has been added to the application's module configuration. This is a crucial part of integrating the new module into the application, ensuring it is loaded and configured correctly at runtime.bankv2types.ModuleName
andbankmodulev2.Module
are correctly defined and that they integrate seamlessly with the rest of the application.Given the complexity and importance of this integration, consider adding more detailed unit tests to cover the new configurations and ensure they do not disrupt existing functionalities.
Would you like me to help draft some unit tests for this new module configuration?
Also applies to: 291-292