From dc500faa25b3a797c804e67dc3f0b45696f4e3f5 Mon Sep 17 00:00:00 2001 From: Hanjun Kim Date: Fri, 12 Jul 2024 01:31:02 +0900 Subject: [PATCH] fix: fix typos --- x/operators/client/cli/query.go | 14 +++++++------- x/operators/client/cli/tx.go | 26 +++++++++++++------------- x/operators/keeper/alias_functions.go | 6 +++--- x/operators/types/hooks.go | 2 +- x/pools/client/cli/query.go | 10 +++++----- x/pools/keeper/pools.go | 16 ++++++++-------- x/services/client/cli/tx.go | 6 +++--- x/services/types/models.go | 6 +++--- 8 files changed, 43 insertions(+), 43 deletions(-) diff --git a/x/operators/client/cli/query.go b/x/operators/client/cli/query.go index ef351be5..65c4a115 100644 --- a/x/operators/client/cli/query.go +++ b/x/operators/client/cli/query.go @@ -14,7 +14,7 @@ import ( // GetQueryCmd returns the command allowing to perform queries func GetQueryCmd() *cobra.Command { - servicesQueryCmd := &cobra.Command{ + queryCmd := &cobra.Command{ Use: types.ModuleName, Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), DisableFlagParsing: true, @@ -22,19 +22,19 @@ func GetQueryCmd() *cobra.Command { RunE: client.ValidateCmd, } - servicesQueryCmd.AddCommand( + queryCmd.AddCommand( getCmdQueryOperator(), getCmdQueryOperators(), getCmdQueryParams(), ) - return servicesQueryCmd + return queryCmd } // getCmdQueryOperator returns the command allowing to query an operator func getCmdQueryOperator() *cobra.Command { cmd := &cobra.Command{ - Use: "operator [service-id]", + Use: "operator [operator-id]", Short: "Query the operator with the given id", Example: fmt.Sprintf(`%s query %s operator 1`, version.AppName, types.ModuleName), Args: cobra.ExactArgs(2), @@ -45,12 +45,12 @@ func getCmdQueryOperator() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - serviceID, err := types.ParseOperatorID(args[0]) + operatorID, err := types.ParseOperatorID(args[0]) if err != nil { return err } - res, err := queryClient.Operator(context.Background(), types.NewQueryOperatorRequest(serviceID)) + res, err := queryClient.Operator(context.Background(), types.NewQueryOperatorRequest(operatorID)) if err != nil { return err } @@ -64,7 +64,7 @@ func getCmdQueryOperator() *cobra.Command { return cmd } -// getCmdQueryOperators returns the command allowing to query services +// getCmdQueryOperators returns the command allowing to query operators func getCmdQueryOperators() *cobra.Command { cmd := &cobra.Command{ Use: "operators", diff --git a/x/operators/client/cli/tx.go b/x/operators/client/cli/tx.go index e58b45f2..2649f2e5 100644 --- a/x/operators/client/cli/tx.go +++ b/x/operators/client/cli/tx.go @@ -18,9 +18,9 @@ const ( flagPicture = "picture" ) -// GetTxCmd returns a new command to perform services transactions +// GetTxCmd returns a new command to perform operators transactions func GetTxCmd() *cobra.Command { - subspacesTxCmd := &cobra.Command{ + txCmd := &cobra.Command{ Use: types.ModuleName, Short: "Operators transaction subcommands", DisableFlagParsing: true, @@ -28,13 +28,13 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - subspacesTxCmd.AddCommand( + txCmd.AddCommand( GetCmdRegisterOperator(), GetCmdEditOperator(), GetCmdDeactivateOperator(), ) - return subspacesTxCmd + return txCmd } // GetCmdRegisterOperator returns the command allowing to register a new operator @@ -42,8 +42,8 @@ func GetCmdRegisterOperator() *cobra.Command { cmd := &cobra.Command{ Use: "register [name]", Args: cobra.ExactArgs(1), - Short: "Register a new service", - Long: `Register a new service having the given name. + Short: "Register a new operator", + Long: `Register a new operator having the given name. You can specify a website and a picture URL using the optional flags. The operator will be created with the sender as the admin.`, @@ -81,8 +81,8 @@ The operator will be created with the sender as the admin.`, }, } - cmd.Flags().String(flagWebsite, "", "The website of the service (optional)") - cmd.Flags().String(flagPicture, "", "The picture URL of the service (optional)") + cmd.Flags().String(flagWebsite, "", "The website of the operator (optional)") + cmd.Flags().String(flagPicture, "", "The picture URL of the operator (optional)") flags.AddTxFlagsToCmd(cmd) @@ -142,21 +142,21 @@ Only the fields that you provide will be updated`, }, } - cmd.Flags().String(flagMoniker, types.DoNotModify, "The new moniker of the service (optional)") - cmd.Flags().String(flagWebsite, types.DoNotModify, "The new website of the service (optional)") - cmd.Flags().String(flagPicture, types.DoNotModify, "The new picture URL of the service (optional)") + cmd.Flags().String(flagMoniker, types.DoNotModify, "The new moniker of the operator (optional)") + cmd.Flags().String(flagWebsite, types.DoNotModify, "The new website of the operator (optional)") + cmd.Flags().String(flagPicture, types.DoNotModify, "The new picture URL of the operator (optional)") flags.AddTxFlagsToCmd(cmd) return cmd } -// GetCmdDeactivateOperator returns the command allowing to deactivate an existing service +// GetCmdDeactivateOperator returns the command allowing to deactivate an existing operator func GetCmdDeactivateOperator() *cobra.Command { cmd := &cobra.Command{ Use: "deactivate [id]", Args: cobra.ExactArgs(1), - Short: "deactivate an existing service", + Short: "deactivate an existing operator", Example: fmt.Sprintf(`%s tx %s deactivate 1 --from alice`, version.AppName, types.ModuleName), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) diff --git a/x/operators/keeper/alias_functions.go b/x/operators/keeper/alias_functions.go index cdc3d8bd..775750c2 100644 --- a/x/operators/keeper/alias_functions.go +++ b/x/operators/keeper/alias_functions.go @@ -35,11 +35,11 @@ func (k *Keeper) IterateOperators(ctx sdk.Context, cb func(operator types.Operat } } -// GetOperators returns the services stored in the KVStore +// GetOperators returns the operators stored in the KVStore func (k *Keeper) GetOperators(ctx sdk.Context) []types.Operator { var operators []types.Operator - k.IterateOperators(ctx, func(service types.Operator) (stop bool) { - operators = append(operators, service) + k.IterateOperators(ctx, func(operator types.Operator) (stop bool) { + operators = append(operators, operator) return false }) return operators diff --git a/x/operators/types/hooks.go b/x/operators/types/hooks.go index 7d90944f..4e733932 100644 --- a/x/operators/types/hooks.go +++ b/x/operators/types/hooks.go @@ -9,7 +9,7 @@ import ( // Event Hooks // These can be utilized to communicate between an operators keeper // and another keeper which must take particular actions when -// services change state. The second keeper must implement this +// operators change state. The second keeper must implement this // interface, which then the operators keeper can call. // OperatorsHooks event hooks for operators objects (noalias) diff --git a/x/pools/client/cli/query.go b/x/pools/client/cli/query.go index aa47d27b..587d70e5 100644 --- a/x/pools/client/cli/query.go +++ b/x/pools/client/cli/query.go @@ -13,7 +13,7 @@ import ( // GetQueryCmd returns the command allowing to perform queries func GetQueryCmd() *cobra.Command { - servicesQueryCmd := &cobra.Command{ + queryCmd := &cobra.Command{ Use: types.ModuleName, Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), DisableFlagParsing: true, @@ -21,16 +21,16 @@ func GetQueryCmd() *cobra.Command { RunE: client.ValidateCmd, } - servicesQueryCmd.AddCommand( + queryCmd.AddCommand( getCmdQueryPoolByID(), getCmdQueryPoolByDenom(), getCmdQueryPools(), ) - return servicesQueryCmd + return queryCmd } -// getCmdQueryPoolByID returns the command allowing to query a service +// getCmdQueryPoolByID returns the command allowing to query a pool func getCmdQueryPoolByID() *cobra.Command { cmd := &cobra.Command{ Use: "pool [pool-id]", @@ -63,7 +63,7 @@ func getCmdQueryPoolByID() *cobra.Command { return cmd } -// getCmdQueryPoolByDenom returns the command allowing to query services +// getCmdQueryPoolByDenom returns the command allowing to query pool by denom func getCmdQueryPoolByDenom() *cobra.Command { cmd := &cobra.Command{ Use: "pool-by-denom [denom]", diff --git a/x/pools/keeper/pools.go b/x/pools/keeper/pools.go index 197155a4..ac1706c6 100644 --- a/x/pools/keeper/pools.go +++ b/x/pools/keeper/pools.go @@ -8,22 +8,22 @@ import ( "github.com/milkyway-labs/milkyway/x/pools/types" ) -// SetNextPoolID sets the next service ID to be used when registering a new Pool -func (k *Keeper) SetNextPoolID(ctx sdk.Context, serviceID uint32) { +// SetNextPoolID sets the next pool ID to be used when registering a new Pool +func (k *Keeper) SetNextPoolID(ctx sdk.Context, poolID uint32) { store := ctx.KVStore(k.storeKey) - store.Set(types.NextPoolIDKey, types.GetPoolIDBytes(serviceID)) + store.Set(types.NextPoolIDKey, types.GetPoolIDBytes(poolID)) } -// GetNextPoolID returns the next service ID to be used when registering a new Pool -func (k *Keeper) GetNextPoolID(ctx sdk.Context) (serviceID uint32, err error) { +// GetNextPoolID returns the next pool ID to be used when registering a new Pool +func (k *Keeper) GetNextPoolID(ctx sdk.Context) (poolID uint32, err error) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.NextPoolIDKey) if bz == nil { - return 0, errors.Wrapf(types.ErrInvalidGenesis, "initial service id not set") + return 0, errors.Wrapf(types.ErrInvalidGenesis, "initial pool id not set") } - serviceID = types.GetPoolIDFromBytes(bz) - return serviceID, nil + poolID = types.GetPoolIDFromBytes(bz) + return poolID, nil } // -------------------------------------------------------------------------------------------------------------------- diff --git a/x/services/client/cli/tx.go b/x/services/client/cli/tx.go index 8c0dccb9..fd6efa63 100644 --- a/x/services/client/cli/tx.go +++ b/x/services/client/cli/tx.go @@ -21,7 +21,7 @@ const ( // GetTxCmd returns a new command to perform services transactions func GetTxCmd() *cobra.Command { - subspacesTxCmd := &cobra.Command{ + txCmd := &cobra.Command{ Use: types.ModuleName, Short: "Services transaction subcommands", DisableFlagParsing: true, @@ -29,14 +29,14 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - subspacesTxCmd.AddCommand( + txCmd.AddCommand( GetCmdCreateService(), GetCmdUpdateService(), GetCmdActivateService(), GetCmdDeactivateService(), ) - return subspacesTxCmd + return txCmd } // GetCmdCreateService returns the command allowing to create a new service diff --git a/x/services/types/models.go b/x/services/types/models.go index 59d5ef7d..4249f326 100644 --- a/x/services/types/models.go +++ b/x/services/types/models.go @@ -106,9 +106,9 @@ func (s Service) SharesFromTokens(tokens sdk.Coin) (sdkmath.LegacyDec, error) { sharesDenom := s.GetSharesDenom(tokens.Denom) delegatorTokenShares := s.DelegatorShares.AmountOf(sharesDenom) - operatorTokenAmount := s.Tokens.AmountOf(tokens.Denom) + serviceTokenAmount := s.Tokens.AmountOf(tokens.Denom) - return delegatorTokenShares.MulInt(tokens.Amount).QuoInt(operatorTokenAmount), nil + return delegatorTokenShares.MulInt(tokens.Amount).QuoInt(serviceTokenAmount), nil } // AddTokensFromDelegation adds the given amount of tokens to the service's total tokens, @@ -123,7 +123,7 @@ func (s Service) AddTokensFromDelegation(amount sdk.Coins) (Service, sdk.DecCoin delegatorShares := s.DelegatorShares.AmountOf(sharesDenom) if delegatorShares.IsZero() { - // The first delegation to an operator sets the exchange rate to one + // The first delegation to a service sets the exchange rate to one tokenShares = sdk.NewDecCoin(sharesDenom, token.Amount) } else { shares, err := s.SharesFromTokens(token)