@@ -6,13 +6,15 @@ import (
6
6
"io/ioutil"
7
7
"os"
8
8
"strconv"
9
+ "time"
9
10
10
11
"github.com/spf13/cobra"
11
12
12
13
"github.com/cosmos/cosmos-sdk/client"
13
14
"github.com/cosmos/cosmos-sdk/client/flags"
14
15
"github.com/cosmos/cosmos-sdk/client/tx"
15
16
sdk "github.com/cosmos/cosmos-sdk/types"
17
+ "github.com/cosmos/cosmos-sdk/types/errors"
16
18
"github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
17
19
)
18
20
@@ -40,6 +42,7 @@ func GetTxCmd() *cobra.Command {
40
42
NewMsgCreatePermanentLockedAccountCmd (),
41
43
NewMsgCreatePeriodicVestingAccountCmd (),
42
44
NewMsgCreateClawbackVestingAccountCmd (),
45
+ NewMsgCreateCliffVestingAccountCmd (),
43
46
NewMsgClawbackCmd (),
44
47
)
45
48
@@ -377,3 +380,50 @@ func NewMsgClawbackCmd() *cobra.Command {
377
380
flags .AddTxFlagsToCmd (cmd )
378
381
return cmd
379
382
}
383
+
384
+ // NewMsgCreateDelayedVestingAccountCmd returns a CLI command handler for creating a
385
+ // NewMsgCreateDelayedVestingAccountCmd transaction.
386
+ // This is hacky, but meant to mitigate the pain of a very specific use case.
387
+ // Namely, make it easy to make cliff locks to an address.
388
+ func NewMsgCreateCliffVestingAccountCmd () * cobra.Command {
389
+ cmd := & cobra.Command {
390
+ Use : "create-cliff-vesting-account [to_address] [amount] [cliff_duration]" ,
391
+ Short : "Create a new cliff vesting account funded with an allocation of tokens." ,
392
+ Long : `Create a new delayed vesting account funded with an allocation of tokens. All vesting accouts created will have their start time
393
+ set by the committed block's time. The cliff duration should be specified in hours.` ,
394
+ Args : cobra .ExactArgs (3 ),
395
+ RunE : func (cmd * cobra.Command , args []string ) error {
396
+ clientCtx , err := client .GetClientTxContext (cmd )
397
+ if err != nil {
398
+ return err
399
+ }
400
+ toAddr , err := sdk .AccAddressFromBech32 (args [0 ])
401
+ if err != nil {
402
+ return err
403
+ }
404
+
405
+ amount , err := sdk .ParseCoinsNormalized (args [1 ])
406
+ if err != nil {
407
+ return err
408
+ }
409
+
410
+ cliffDuration , err := time .ParseDuration (args [2 ])
411
+ if err != nil {
412
+ err = errors .Wrap (err , "duration incorrectly formatted, see https://pkg.go.dev/time#ParseDuration" )
413
+ return err
414
+ }
415
+ cliffVesting := true
416
+
417
+ endTime := time .Now ().Add (cliffDuration )
418
+ endEpochTime := endTime .Unix ()
419
+
420
+ msg := types .NewMsgCreateVestingAccount (clientCtx .GetFromAddress (), toAddr , amount , endEpochTime , cliffVesting )
421
+
422
+ return tx .GenerateOrBroadcastTxCLI (clientCtx , cmd .Flags (), msg )
423
+ },
424
+ }
425
+
426
+ flags .AddTxFlagsToCmd (cmd )
427
+
428
+ return cmd
429
+ }
0 commit comments