Add registry module commands to set and get records (#5)

Reviewed-on: deep-stack/laconic2d#5
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
2024-02-16 06:40:42 +00:00
committed by ashwin
parent de489a4d21
commit 5e68c7d9b3
19 changed files with 1280 additions and 36 deletions
+32 -3
View File
@@ -3,7 +3,8 @@ package module
import (
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
"cosmossdk.io/client/v2/autocli"
// registryv1 "git.vdb.to/cerc-io/laconic2d/api/cerc/registry/v1"
registryv1 "git.vdb.to/cerc-io/laconic2d/api/cerc/registry/v1"
)
var _ autocli.HasAutoCLIConfig = AppModule{}
@@ -11,7 +12,35 @@ var _ autocli.HasAutoCLIConfig = AppModule{}
// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
return &autocliv1.ModuleOptions{
Query: nil,
Tx: nil,
Query: &autocliv1.ServiceCommandDescriptor{
Service: registryv1.Query_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Params",
Use: "params",
Short: "Get the current registry parameters",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{},
},
{
RpcMethod: "Records",
Use: "list",
Short: "List records",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{},
},
{
RpcMethod: "GetRecord",
Use: "get [record-id]",
Short: "Get record info by record id",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "id"},
},
},
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: registryv1.Msg_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{},
EnhanceCustomCommand: true, // Allow additional manual commands
},
}
}
+9 -2
View File
@@ -7,6 +7,7 @@ import (
"cosmossdk.io/core/appmodule"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
@@ -15,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
registrytypes "git.vdb.to/cerc-io/laconic2d/x/registry"
"git.vdb.to/cerc-io/laconic2d/x/registry/client/cli"
"git.vdb.to/cerc-io/laconic2d/x/registry/keeper"
)
@@ -115,8 +117,8 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries.
func (am AppModule) RegisterServices(cfg module.Configurator) {
// Register servers
// registrytypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
// registrytypes.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper))
registrytypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
registrytypes.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper))
}
// appmodule.HasEndBlocker
@@ -124,3 +126,8 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
func (am AppModule) EndBlock(ctx context.Context) error {
return EndBlocker(ctx, am.keeper)
}
// Get the root tx command of this module
func (AppModule) GetTxCmd() *cobra.Command {
return cli.GetTxCmd()
}