Skip to content

Commit

Permalink
fix(assets,delegation): stateless validate cli
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 committed May 30, 2024
1 parent 79df9e5 commit 0649300
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
14 changes: 12 additions & 2 deletions x/assets/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,14 @@ func QueStakerAssetInfos() *cobra.Command {
return err
}

stakerID := args[0]
if _, _, err := types.ValidateID(stakerID, false, false); err != nil {
return errorsmod.Wrap(types.ErrInvalidCliCmdArg, err.Error())
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryStakerAssetInfo{
StakerID: strings.ToLower(args[0]),
StakerID: strings.ToLower(stakerID),
}
res, err := queryClient.QueStakerAssetInfos(context.Background(), req)
if err != nil {
Expand Down Expand Up @@ -340,9 +345,14 @@ func QueStakerExoCoreAddr() *cobra.Command {
return err
}

stakerID := args[0]
if _, _, err := types.ValidateID(stakerID, false, false); err != nil {
return errorsmod.Wrap(types.ErrInvalidCliCmdArg, err.Error())
}

queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryStakerExCoreAddr{
Staker: strings.ToLower(args[0]),
Staker: strings.ToLower(stakerID),
}
res, err := queryClient.QueStakerExoCoreAddr(context.Background(), req)
if err != nil {
Expand Down
13 changes: 10 additions & 3 deletions x/delegation/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,18 @@ func QueryDelegationInfo() *cobra.Command {
if err != nil {
return err
}

stakerID := strings.ToLower(args[0])
if _, _, err := types.ValidateID(stakerID, false, false); err != nil {
return errorsmod.Wrap(types.ErrInvalidCliCmdArg, err.Error())
}
assetID := strings.ToLower(args[1])
if _, _, err := types.ValidateID(assetID, false, false); err != nil {
return errorsmod.Wrap(types.ErrInvalidCliCmdArg, err.Error())
}
queryClient := delegationtype.NewQueryClient(clientCtx)
req := &delegationtype.DelegationInfoReq{
StakerID: strings.ToLower(args[0]),
AssetID: strings.ToLower(args[1]),
StakerID: strings.ToLower(stakerID),
AssetID: strings.ToLower(assetID),
}
res, err := queryClient.QueryDelegationInfo(context.Background(), req)
if err != nil {
Expand Down

0 comments on commit 0649300

Please sign in to comment.