Skip to content

Commit

Permalink
fix(logic): re-introduce descriptor for CLI (lost with migration)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamel committed Jan 19, 2024
1 parent 16158ae commit 060972d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
44 changes: 44 additions & 0 deletions x/logic/autocli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package logic

import (
"fmt"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"

"github.com/cosmos/cosmos-sdk/version"

"github.com/okp4/okp4d/x/logic/types"
)

// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface for the logic module.
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
return &autocliv1.ModuleOptions{
Query: &autocliv1.ServiceCommandDescriptor{
Service: types.GrpcQueryServiceDesc().ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Ask",
Use: "ask [query]",
Short: "Executes a logic query and returns the solution(s) found.",
Long: `Executes the [query] and return the solution(s) found.
Optionally, a program can be transmitted, which will be compiled before the query is processed.
Since the query is without any side-effect, the query is not executed in the context of a transaction and no fee
is charged for this, but the execution is constrained by the current limits configured in the module (that you can
query).`,
Example: fmt.Sprintf(`$ %s query %s ask "chain_id(X)." # returns the chain-id`,
version.AppName,
types.ModuleName),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "query"}},
FlagOptions: map[string]*autocliv1.FlagOptions{
"program": {
Shorthand: "p",
Usage: "The program to compile before the query.",
},
},
},
},
},
}
}
9 changes: 9 additions & 0 deletions x/logic/types/types.go
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
package types

import "google.golang.org/grpc"

// GrpcQueryServiceDesc represents the query server's RPC service specification.
// This gives access to the service name and method names needed for stargate
// queries.
func GrpcQueryServiceDesc() grpc.ServiceDesc {
return _QueryService_serviceDesc
}

0 comments on commit 060972d

Please sign in to comment.