mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 23:35:19 +00:00
a073238f34
* module files * proto types * types and generated proto types * keeper * client scaffold * add savings module to app * remove placeholder types file * implement rest and add to module * update proto types * validation for supported denoms * generate updates proto types * update comments * update comments * remove unused imports from proto files * regenerate proto files * update proto types * client * deposit type and generated proto types * deposit keeper methods + tests * update savings module file * update app.go + test common * remove abci * remove refs to other modules * remove endblocker call * genesis init test for module account * update genesis test with params * add get/set params test * fix up keeper test * use params getter * simplify if/else statement * fix: add msgServer to keeper * fix: register deposit message * update deposit test * wrap invalid deposit denom error msg Co-authored-by: karzak <kjydavis3@gmail.com>
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/version"
|
|
|
|
"github.com/kava-labs/kava/x/savings/types"
|
|
)
|
|
|
|
// GetTxCmd returns the transaction commands for this module
|
|
func GetTxCmd() *cobra.Command {
|
|
savingsTxCmd := &cobra.Command{
|
|
Use: types.ModuleName,
|
|
Short: "savings transactions subcommands",
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: client.ValidateCmd,
|
|
}
|
|
|
|
cmds := []*cobra.Command{
|
|
getCmdDeposit(),
|
|
}
|
|
|
|
for _, cmd := range cmds {
|
|
flags.AddTxFlagsToCmd(cmd)
|
|
}
|
|
|
|
savingsTxCmd.AddCommand(cmds...)
|
|
|
|
return savingsTxCmd
|
|
}
|
|
|
|
func getCmdDeposit() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "deposit [amount]",
|
|
Short: "deposit coins to savings",
|
|
Example: fmt.Sprintf(
|
|
`%s tx %s savings 10000000bnb --from <key>`, version.AppName, types.ModuleName,
|
|
),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
clientCtx, err := client.GetClientTxContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
amount, err := sdk.ParseCoinsNormalized(args[0])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
msg := types.NewMsgDeposit(clientCtx.GetFromAddress(), amount)
|
|
if err := msg.ValidateBasic(); err != nil {
|
|
return err
|
|
}
|
|
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
|
},
|
|
}
|
|
}
|