forked from CosmWasm/wasmd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add proto files * Update proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto Co-authored-by: Dev Ojha <[email protected]> * update comments on proto * add other types files * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <[email protected]> * update errors to not start from 1 * add more comments * add logic * update app setup * add back query * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <[email protected]> * add migration * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <[email protected]> * address comment * Apply suggestions from code review Co-authored-by: Roman <[email protected]> Co-authored-by: Dev Ojha <[email protected]> * Apply suggestions from code review Co-authored-by: Roman <[email protected]> * address comments * removed mintTo and burnFrom * fixed typo * fix comments * metadata Validate() function * fix stuff * add mint restriction * remove unused argument from NewMsgBurn() * x/tokenfactory: cli * fix extra arguments * address comments * Apply suggestions from code review Co-authored-by: Roman <[email protected]> * ? * params * tests * add params command Co-authored-by: Dev Ojha <[email protected]> Co-authored-by: Aleksandr Bezobchuk <[email protected]> Co-authored-by: Roman <[email protected]>
- Loading branch information
1 parent
de17217
commit 6c866c8
Showing
3 changed files
with
316 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
// "strings" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
|
||
// "github.com/cosmos/cosmos-sdk/client/flags" | ||
// sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" | ||
) | ||
|
||
// GetQueryCmd returns the cli query commands for this module | ||
func GetQueryCmd() *cobra.Command { | ||
// Group tokenfactory queries under a subcommand | ||
cmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
cmd.AddCommand( | ||
GetParams(), | ||
GetCmdDenomAuthorityMetadata(), | ||
GetCmdDenomsFromCreator(), | ||
) | ||
|
||
return cmd | ||
} | ||
|
||
// GetParams returns the params for the module | ||
func GetParams() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "params [flags]", | ||
Short: "Get the params for the x/tokenfactory module", | ||
Args: cobra.ExactArgs(0), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} | ||
|
||
// GetCmdDenomAuthorityMetadata returns the authority metadata for a queried denom | ||
func GetCmdDenomAuthorityMetadata() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "denom-authority-metadata [denom] [flags]", | ||
Short: "Get the authority metadata for a specific denom", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
res, err := queryClient.DenomAuthorityMetadata(cmd.Context(), &types.QueryDenomAuthorityMetadataRequest{ | ||
Denom: args[0], | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} | ||
|
||
// GetCmdDenomsFromCreator a command to get a list of all tokens created by a specific creator address | ||
func GetCmdDenomsFromCreator() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "denoms-from-creator [creator address] [flags]", | ||
Short: "Returns a list of all tokens created by a specific creator address", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
res, err := queryClient.DenomsFromCreator(cmd.Context(), &types.QueryDenomsFromCreatorRequest{ | ||
Creator: args[0], | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
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/client/flags" | ||
"github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" | ||
) | ||
|
||
// GetTxCmd returns the transaction commands for this module | ||
func GetTxCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
cmd.AddCommand( | ||
NewCreateDenomCmd(), | ||
NewMintCmd(), | ||
NewBurnCmd(), | ||
// NewForceTransferCmd(), | ||
NewChangeAdminCmd(), | ||
) | ||
|
||
return cmd | ||
} | ||
|
||
// NewCreateDenomCmd broadcast MsgCreateDenom | ||
func NewCreateDenomCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "create-denom [nonce] [flags]", | ||
Short: "create a new denom from an account", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) | ||
|
||
msg := types.NewMsgCreateDenom( | ||
clientCtx.GetFromAddress().String(), | ||
args[0], | ||
) | ||
|
||
return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
return cmd | ||
} | ||
|
||
// NewMintCmd broadcast MsgMint | ||
func NewMintCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "mint [amount] [flags]", | ||
Short: "Mint a denom to an address. Must have admin authority to do so.", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) | ||
|
||
amount, err := sdk.ParseCoinNormalized(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
msg := types.NewMsgMint( | ||
clientCtx.GetFromAddress().String(), | ||
amount, | ||
) | ||
|
||
return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
return cmd | ||
} | ||
|
||
// NewBurnCmd broadcast MsgBurn | ||
func NewBurnCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "burn [amount] [flags]", | ||
Short: "Burn tokens from an address. Must have admin authority to do so.", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) | ||
|
||
amount, err := sdk.ParseCoinNormalized(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
msg := types.NewMsgBurn( | ||
clientCtx.GetFromAddress().String(), | ||
amount, | ||
) | ||
|
||
return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
return cmd | ||
} | ||
|
||
// // NewForceTransferCmd broadcast MsgForceTransfer | ||
// func NewForceTransferCmd() *cobra.Command { | ||
// cmd := &cobra.Command{ | ||
// Use: "force-transfer [amount] [transfer-from-address] [transfer-to-address] [flags]", | ||
// Short: "Force transfer tokens from one address to another address. Must have admin authority to do so.", | ||
// Args: cobra.ExactArgs(3), | ||
// RunE: func(cmd *cobra.Command, args []string) error { | ||
// clientCtx, err := client.GetClientTxContext(cmd) | ||
// if err != nil { | ||
// return err | ||
// } | ||
|
||
// txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) | ||
|
||
// amount, err := sdk.ParseCoinNormalized(args[0]) | ||
// if err != nil { | ||
// return err | ||
// } | ||
|
||
// msg := types.NewMsgForceTransfer( | ||
// clientCtx.GetFromAddress().String(), | ||
// amount, | ||
// args[1], | ||
// args[2], | ||
// ) | ||
|
||
// return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) | ||
// }, | ||
// } | ||
|
||
// flags.AddTxFlagsToCmd(cmd) | ||
// return cmd | ||
// } | ||
|
||
// NewChangeAdminCmd broadcast MsgChangeAdmin | ||
func NewChangeAdminCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "change-admin [denom] [new-admin-address] [flags]", | ||
Short: "Changes the admin address for a factory-created denom. Must have admin authority to do so.", | ||
Args: cobra.ExactArgs(2), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) | ||
|
||
msg := types.NewMsgChangeAdmin( | ||
clientCtx.GetFromAddress().String(), | ||
args[0], | ||
args[1], | ||
) | ||
|
||
return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters