Skip to content

Commit

Permalink
hook up CLI client
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed May 25, 2024
1 parent d853a40 commit ebe84c4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions x/manifest/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func NewTxCmd() *cobra.Command {
}

txCmd.AddCommand(
MsgBurnCoins(),
MsgUpdateParams(),
MsgDeployStakeholderPayout(),
)
Expand Down Expand Up @@ -117,6 +118,43 @@ func MsgDeployStakeholderPayout() *cobra.Command {
return cmd
}

// MsgBurnCoins returns a CLI command handler for burning held coins.
func MsgBurnCoins() *cobra.Command {
cmd := &cobra.Command{
Use: "burn-coins [coins]",
Short: "Burn held coins",
Example: `burn-coins 50000umfx,100other`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err

Check warning on line 131 in x/manifest/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/manifest/client/cli/tx.go#L129-L131

Added lines #L129 - L131 were not covered by tests
}

sender := cliCtx.GetFromAddress()

Check warning on line 134 in x/manifest/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/manifest/client/cli/tx.go#L134

Added line #L134 was not covered by tests

coins, err := sdk.ParseCoinsNormalized(args[0])
if err != nil {
return err

Check warning on line 138 in x/manifest/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/manifest/client/cli/tx.go#L136-L138

Added lines #L136 - L138 were not covered by tests
}

msg := &types.MsgBurnHeldBalance{
Sender: sender.String(),
BurnCoins: coins,

Check warning on line 143 in x/manifest/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/manifest/client/cli/tx.go#L141-L143

Added lines #L141 - L143 were not covered by tests
}

if err := msg.Validate(); err != nil {
return err

Check warning on line 147 in x/manifest/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/manifest/client/cli/tx.go#L146-L147

Added lines #L146 - L147 were not covered by tests
}

return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg)

Check warning on line 150 in x/manifest/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/manifest/client/cli/tx.go#L150

Added line #L150 was not covered by tests
},
}

flags.AddTxFlagsToCmd(cmd)
return cmd
}

// fromStrToStakeholders converts a string to a slice of StakeHolders.
// ex: address:1_000_000,address2:99_000_000
func fromStrToStakeholders(s string) ([]*types.StakeHolders, error) {
Expand Down

0 comments on commit ebe84c4

Please sign in to comment.