-
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(x/feegrant): add autocli options for tx #17959
Changes from 9 commits
a527e05
77f5068
d0c4b43
d4425b8
3dba583
504ac05
51c4972
b7fae09
a49862c
4a2880b
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 |
---|---|---|
|
@@ -39,17 +39,18 @@ func GetTxCmd(ac address.Codec) *cobra.Command { | |
|
||
feegrantTxCmd.AddCommand( | ||
NewCmdFeeGrant(ac), | ||
NewCmdRevokeFeegrant(ac), | ||
) | ||
|
||
return feegrantTxCmd | ||
} | ||
|
||
// NewCmdFeeGrant returns a CLI command handler to create a MsgGrantAllowance transaction. | ||
// This command is more powerful than AutoCLI generated command as it allows a better input validation. | ||
func NewCmdFeeGrant(ac address.Codec) *cobra.Command { | ||
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. this needs to stay or can be removed as well? 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. lets leave a comment on why this cant use autocli, same with other commands staying to prevent future people asking why and spending time on it 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. There is already a comment in the PR description. Do you mean have a comment in the code? 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. comment in the code |
||
cmd := &cobra.Command{ | ||
Use: "grant [granter_key_or_address] [grantee]", | ||
Short: "Grant Fee allowance to an address", | ||
Use: "grant [granter_key_or_address] [grantee]", | ||
Aliases: []string{"grant-allowance"}, | ||
Short: "Grant Fee allowance to an address", | ||
Long: strings.TrimSpace( | ||
fmt.Sprintf( | ||
`Grant authorization to pay fees from your address. Note, the '--from' flag is | ||
|
@@ -190,49 +191,6 @@ Examples: | |
return cmd | ||
} | ||
|
||
// NewCmdRevokeFeegrant returns a CLI command handler to create a MsgRevokeAllowance transaction. | ||
func NewCmdRevokeFeegrant(ac address.Codec) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "revoke [granter] [grantee]", | ||
Short: "revoke fee-grant", | ||
Long: strings.TrimSpace( | ||
fmt.Sprintf(`revoke fee grant from a granter to a grantee. Note, the '--from' flag is | ||
ignored as it is implied from [granter]. | ||
|
||
Example: | ||
$ %s tx %s revoke cosmos1skj.. cosmos1skj.. | ||
`, version.AppName, feegrant.ModuleName), | ||
), | ||
Args: cobra.ExactArgs(2), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := cmd.Flags().Set(flags.FlagFrom, args[0]); err != nil { | ||
return err | ||
} | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = ac.StringToBytes(args[1]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
granter, err := ac.BytesToString(clientCtx.GetFromAddress()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
msg := feegrant.NewMsgRevokeAllowance(granter, args[1]) | ||
|
||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
return cmd | ||
} | ||
|
||
func getPeriodReset(duration int64) time.Time { | ||
return time.Now().Add(getPeriod(duration)) | ||
} | ||
|
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.
As discussed yesterday in our sync @atheeshp.
This way, we can prevent a command to be created by having an alias as well instead of having to use skip.