-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
autocli.go
76 lines (72 loc) · 2.89 KB
/
autocli.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package authz
import (
"fmt"
authzv1beta1 "cosmossdk.io/api/cosmos/authz/v1beta1"
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
"github.com/cosmos/cosmos-sdk/version"
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
)
// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
return &autocliv1.ModuleOptions{
Query: &autocliv1.ServiceCommandDescriptor{
Service: authzv1beta1.Query_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Grants",
Use: "grants [granter-addr] [grantee-addr] <msg-type-url>",
Short: "Query grants for a granter-grantee pair and optionally a msg-type-url",
Long: "Query authorization grants for a granter-grantee pair. If msg-type-url is set, it will select grants only for that msg type.",
Example: fmt.Sprintf("%s query authz grants cosmos1skj.. cosmos1skjwj.. %s", version.AppName, bank.SendAuthorization{}.MsgTypeURL()),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "granter"},
{ProtoField: "grantee"},
{ProtoField: "msg_type_url", Optional: true},
},
},
{
RpcMethod: "GranterGrants",
Use: "grants-by-granter [granter-addr]",
Short: "Query authorization grants granted by granter",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "granter"},
},
},
{
RpcMethod: "GranteeGrants",
Use: "grants-by-grantee [grantee-addr]",
Short: "Query authorization grants granted to a grantee",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "grantee"},
},
},
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: authzv1beta1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: false, // use custom commands only until v0.51
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Exec",
Use: "exec [msg-json-file] --from [grantee]",
Short: "Execute tx on behalf of granter account",
Example: fmt.Sprintf("$ %s tx authz exec msg.json --from grantee\n $ %[1]s tx bank send [granter] [recipient] [amount] --generate-only | jq .body.messages > msg.json && %[1]s tx authz exec msg.json --from grantee", version.AppName),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "msgs", Varargs: true},
},
},
{
RpcMethod: "Revoke",
Use: "revoke [grantee] [msg-type-url] --from [granter]",
Short: `Revoke authorization from a granter to a grantee`,
Example: fmt.Sprintf(`%s tx authz revoke cosmos1skj.. %s --from=cosmos1skj..`,
version.AppName, bank.SendAuthorization{}.MsgTypeURL()),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "grantee"},
{ProtoField: "msg_type_url"},
},
},
},
},
}
}