Skip to content

Commit

Permalink
add partial unlocking flag for cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mconcat committed Mar 7, 2022
1 parent bff6f64 commit 151990d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions x/lockup/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
const (
FlagDuration = "duration"
FlagMinDuration = "min-duration"
FlagAmount = "amount"
)

// FlagSetLockTokens returns flags for LockTokens msg builder
Expand All @@ -18,6 +19,13 @@ func FlagSetLockTokens() *flag.FlagSet {
return fs
}

func FlagSetUnlockTokens() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)

fs.String(FlagAmount, "", "The amount to be unlocked. e.g. 1osmo")
return fs
}

func FlagSetMinDuration() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)

Expand Down
17 changes: 16 additions & 1 deletion x/lockup/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,31 @@ func NewBeginUnlockByIDCmd() *cobra.Command {
return err
}

coins := sdk.Coins(nil)
amountStr, err := cmd.Flags().GetString(FlagAmount)
if err != nil {
return err
}

if amountStr != "" {
coins, err = sdk.ParseCoinsNormalized(amountStr)
if err != nil {
return err
}
}

msg := types.NewMsgBeginUnlocking(
clientCtx.GetFromAddress(),
uint64(id),
nil,
coins,
)

return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg)
},
}

cmd.Flags().AddFlagSet(FlagSetUnlockTokens())

flags.AddTxFlagsToCmd(cmd)
return cmd
}

0 comments on commit 151990d

Please sign in to comment.