Skip to content

Commit

Permalink
feat(agd): Add install-bundle command
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed May 2, 2022
1 parent c9a3aca commit fca35fc
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions golang/cosmos/x/swingset/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func GetTxCmd(storeKey string) *cobra.Command {
swingsetTxCmd.AddCommand(
GetCmdDeliver(),
GetCmdProvisionOne(),
GetCmdInstallBundle(),
)

return swingsetTxCmd
Expand Down Expand Up @@ -85,6 +86,48 @@ func GetCmdDeliver() *cobra.Command {
return cmd
}

// GetCmdInstallBundle is the CLI command for constructing or sending an
// InstallBundle message in a transaction.
func GetCmdInstallBundle() *cobra.Command {
cmd := &cobra.Command{
Use: "install-bundle <JSON>/@<FILE>/-",
Args: cobra.ExactArgs(1),

RunE: func(cmd *cobra.Command, args []string) error {
cctx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

jsonIn := args[0]
if jsonIn[0] == '@' {
fname := args[0][1:]
if fname == "-" {
// Reading from stdin.
if _, err := fmt.Scanln(&jsonIn); err != nil {
return err
}
} else {
jsonBytes, err := ioutil.ReadFile(fname)
if err != nil {
return err
}
jsonIn = string(jsonBytes)
}
}

msg := types.NewMsgInstallBundle(jsonIn, cctx.GetFromAddress())
if err := msg.ValidateBasic(); err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(cctx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}

// GetCmdProvision is the CLI command for sending a Provision transaction
func GetCmdProvisionOne() *cobra.Command {
cmd := &cobra.Command{
Expand Down

0 comments on commit fca35fc

Please sign in to comment.