diff --git a/app/ante.go b/app/ante.go index 74ceab68e..833458883 100644 --- a/app/ante.go +++ b/app/ante.go @@ -4,23 +4,23 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" "github.com/bandprotocol/chain/v2/x/globalfee/feechecker" + globalfeekeeper "github.com/bandprotocol/chain/v2/x/globalfee/keeper" oraclekeeper "github.com/bandprotocol/chain/v2/x/oracle/keeper" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ) // HandlerOptions extend the SDK's AnteHandler options by requiring the IBC // channel keeper. type HandlerOptions struct { ante.HandlerOptions - OracleKeeper *oraclekeeper.Keeper - IBCKeeper *ibckeeper.Keeper - GlobalFeeSubspace paramtypes.Subspace - StakingKeeper *stakingkeeper.Keeper + OracleKeeper *oraclekeeper.Keeper + IBCKeeper *ibckeeper.Keeper + StakingKeeper *stakingkeeper.Keeper + GlobalfeeKeeper *globalfeekeeper.Keeper } func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { @@ -39,6 +39,9 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { if options.IBCKeeper == nil { return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "IBC keeper is required for AnteHandler") } + if options.GlobalfeeKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "Globalfee keeper is required for AnteHandler") + } sigGasConsumer := options.SigGasConsumer if sigGasConsumer == nil { @@ -46,13 +49,9 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { } if options.TxFeeChecker == nil { - if options.GlobalFeeSubspace.Name() == "" { - return nil, sdkerrors.Wrap(sdkerrors.ErrNotFound, "globalfee param store is required for AnteHandler") - } - feeChecker := feechecker.NewFeeChecker( options.OracleKeeper, - options.GlobalFeeSubspace, + options.GlobalfeeKeeper, options.StakingKeeper, ) options.TxFeeChecker = feeChecker.CheckTxFeeWithMinGasPrices diff --git a/app/app.go b/app/app.go index d058937ee..f88253c91 100644 --- a/app/app.go +++ b/app/app.go @@ -9,7 +9,7 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" - + owasm "github.com/bandprotocol/go-owasm/api" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + cosmosnodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" @@ -112,8 +113,6 @@ import ( "github.com/rakyll/statik/fs" "github.com/spf13/cast" - owasm "github.com/bandprotocol/go-owasm/api" - "github.com/bandprotocol/chain/v2/app/keepers" "github.com/bandprotocol/chain/v2/app/upgrades" "github.com/bandprotocol/chain/v2/app/upgrades/v2_6" @@ -122,10 +121,11 @@ import ( bandbank "github.com/bandprotocol/chain/v2/x/bank" bandbankkeeper "github.com/bandprotocol/chain/v2/x/bank/keeper" "github.com/bandprotocol/chain/v2/x/globalfee" + globalfeekeeper "github.com/bandprotocol/chain/v2/x/globalfee/keeper" + globalfeetypes "github.com/bandprotocol/chain/v2/x/globalfee/types" "github.com/bandprotocol/chain/v2/x/oracle" oraclekeeper "github.com/bandprotocol/chain/v2/x/oracle/keeper" oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types" - cosmosnodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" ) const ( @@ -285,6 +285,7 @@ func NewBandApp( icahosttypes.StoreKey, group.StoreKey, oracletypes.StoreKey, + globalfeetypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -526,6 +527,12 @@ func NewBandApp( // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper + app.GlobalfeeKeeper = globalfeekeeper.NewKeeper( + appCodec, + keys[globalfeetypes.StoreKey], + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + /**** Module Options ****/ // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. @@ -593,7 +600,7 @@ func NewBandApp( transferModule, icaModule, oracleModule, - globalfee.NewAppModule(app.GetSubspace(globalfee.ModuleName)), + globalfee.NewAppModule(app.GlobalfeeKeeper), ) // NOTE: Oracle module must occur before distr as it takes some fee to distribute to active oracle validators. // NOTE: During begin block slashing happens after distr.BeginBlocker so that there is nothing left @@ -623,7 +630,7 @@ func NewBandApp( paramstypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, - globalfee.ModuleName, + globalfeetypes.ModuleName, ) app.mm.SetOrderEndBlockers( crisistypes.ModuleName, @@ -648,7 +655,7 @@ func NewBandApp( upgradetypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, - globalfee.ModuleName, + globalfeetypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are // properly initialized with tokens from genesis accounts. @@ -679,7 +686,7 @@ func NewBandApp( vestingtypes.ModuleName, consensusparamtypes.ModuleName, oracletypes.ModuleName, - globalfee.ModuleName, + globalfeetypes.ModuleName, ) app.mm.RegisterInvariants(app.CrisisKeeper) @@ -721,10 +728,10 @@ func NewBandApp( FeegrantKeeper: app.FeegrantKeeper, SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, - OracleKeeper: &app.OracleKeeper, - IBCKeeper: app.IBCKeeper, - GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), - StakingKeeper: app.StakingKeeper, + OracleKeeper: &app.OracleKeeper, + IBCKeeper: app.IBCKeeper, + StakingKeeper: app.StakingKeeper, + GlobalfeeKeeper: &app.GlobalfeeKeeper, }, ) if err != nil { @@ -959,7 +966,6 @@ func initParamsKeeper( paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) paramsKeeper.Subspace(oracletypes.ModuleName) - paramsKeeper.Subspace(globalfee.ModuleName) return paramsKeeper } diff --git a/app/genesis.go b/app/genesis.go index dc684a196..df0d11b55 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -38,7 +38,6 @@ import ( ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" "github.com/bandprotocol/chain/v2/app/upgrades/v2_6" - "github.com/bandprotocol/chain/v2/x/globalfee" globalfeetypes "github.com/bandprotocol/chain/v2/x/globalfee/types" "github.com/bandprotocol/chain/v2/x/oracle" oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types" @@ -109,6 +108,6 @@ func NewDefaultGenesisState() GenesisState { ibctransafertypes.ModuleName: ibctransfer.AppModuleBasic{}.DefaultGenesis(cdc), icatypes.ModuleName: cdc.MustMarshalJSON(icaGenesis), oracletypes.ModuleName: oracle.AppModuleBasic{}.DefaultGenesis(cdc), - globalfee.ModuleName: cdc.MustMarshalJSON(globalfeeGenesis), + globalfeetypes.ModuleName: cdc.MustMarshalJSON(globalfeeGenesis), } } diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 2bc74b49e..5f48bf8c4 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -1,6 +1,7 @@ package keepers import ( + globalfeekeeper "github.com/bandprotocol/chain/v2/x/globalfee/keeper" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" @@ -47,6 +48,7 @@ type AppKeepers struct { GroupKeeper groupkeeper.Keeper OracleKeeper oraclekeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper + GlobalfeeKeeper globalfeekeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper diff --git a/app/upgrades/v2_6/constants.go b/app/upgrades/v2_6/constants.go index 47b07a59a..fac25fab8 100644 --- a/app/upgrades/v2_6/constants.go +++ b/app/upgrades/v2_6/constants.go @@ -1,9 +1,6 @@ package v2_6 import ( - "github.com/bandprotocol/chain/v2/app/upgrades" - "github.com/bandprotocol/chain/v2/x/globalfee" - oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" @@ -15,6 +12,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/group" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + + "github.com/bandprotocol/chain/v2/app/upgrades" + globalfeetypes "github.com/bandprotocol/chain/v2/x/globalfee/types" + oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types" ) const UpgradeName = "v2_6" @@ -23,7 +24,7 @@ var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, CreateUpgradeHandler: CreateUpgradeHandler, StoreUpgrades: storetypes.StoreUpgrades{ - Added: []string{group.StoreKey, globalfee.ModuleName}, + Added: []string{group.StoreKey, globalfeetypes.StoreKey}, }, } diff --git a/app/upgrades/v2_6/upgrades.go b/app/upgrades/v2_6/upgrades.go index 8ebc9e848..829195e1e 100644 --- a/app/upgrades/v2_6/upgrades.go +++ b/app/upgrades/v2_6/upgrades.go @@ -3,7 +3,6 @@ package v2_6 import ( "github.com/bandprotocol/chain/v2/app/keepers" "github.com/bandprotocol/chain/v2/app/upgrades" - "github.com/bandprotocol/chain/v2/x/globalfee" globalfeetypes "github.com/bandprotocol/chain/v2/x/globalfee/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" @@ -26,16 +25,18 @@ func CreateUpgradeHandler( } keepers.ICAHostKeeper.SetParams(ctx, hostParams) - minGasPriceGenesisState := &globalfeetypes.GenesisState{ - Params: globalfeetypes.Params{ - MinimumGasPrices: sdk.DecCoins{sdk.NewDecCoinFromDec("uband", sdk.NewDecWithPrec(25, 4))}, - }, + vm, err := mm.RunMigrations(ctx, configurator, fromVM) + if err != nil { + return nil, err } - am.GetSubspace(globalfee.ModuleName).SetParamSet(ctx, &minGasPriceGenesisState.Params) - // set version of globalfee so that it won't run initgenesis again - fromVM["globalfee"] = 1 + err = keepers.GlobalfeeKeeper.SetParams(ctx, globalfeetypes.Params{ + MinimumGasPrices: sdk.DecCoins{sdk.NewDecCoinFromDec("uband", sdk.NewDecWithPrec(25, 4))}, + }) + if err != nil { + return nil, err + } - return mm.RunMigrations(ctx, configurator, fromVM) + return vm, nil } } diff --git a/proto/globalfee/v1beta1/query.proto b/proto/globalfee/v1beta1/query.proto index 3bb3bb603..bedf4df25 100644 --- a/proto/globalfee/v1beta1/query.proto +++ b/proto/globalfee/v1beta1/query.proto @@ -3,28 +3,23 @@ package globalfee.v1beta1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/base/v1beta1/coin.proto"; +import "globalfee/v1beta1/genesis.proto"; option go_package = "github.com/bandprotocol/chain/v2/x/globalfee/types"; // Query defines the gRPC querier service. service Query { - rpc MinimumGasPrices(QueryMinimumGasPricesRequest) returns (QueryMinimumGasPricesResponse) { - option (google.api.http).get = "/globalfee/v1beta1/minimum_gas_prices"; + // Params queries parameters of globalfee module + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/globalfee/v1beta1/params"; } } -// QueryMinimumGasPricesRequest is the request type for the -// Query/MinimumGasPrices RPC method. -message QueryMinimumGasPricesRequest {} +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} -// QueryMinimumGasPricesResponse is the response type for the -// Query/MinimumGasPrices RPC method. -message QueryMinimumGasPricesResponse { - repeated cosmos.base.v1beta1.DecCoin minimum_gas_prices = 1 [ - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "minimum_gas_prices,omitempty", - (gogoproto.moretags) = "yaml:\"minimum_gas_prices\"", - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" - ]; +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // pagination defines an optional pagination for the request. + Params params = 1 [(gogoproto.nullable) = false]; } diff --git a/proto/globalfee/v1beta1/tx.proto b/proto/globalfee/v1beta1/tx.proto new file mode 100644 index 000000000..23013eee4 --- /dev/null +++ b/proto/globalfee/v1beta1/tx.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; +package globalfee.v1beta1; + +option go_package = "github.com/bandprotocol/chain/v2/x/globalfee/types"; + +import "cosmos/msg/v1/msg.proto"; +import "globalfee/v1beta1/genesis.proto"; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +// Msg defines the x/globalfee Msg service. +service Msg { + // UpdateParams defines a governance operation for updating the x/globalfee module + // parameters. + // + // Since: cosmos-sdk 0.47 + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); +} + +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the x/globalfee parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [(gogoproto.nullable) = false]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParamsResponse {} diff --git a/x/globalfee/alias.go b/x/globalfee/alias.go deleted file mode 100644 index da80f9309..000000000 --- a/x/globalfee/alias.go +++ /dev/null @@ -1,9 +0,0 @@ -package globalfee - -import ( - "github.com/bandprotocol/chain/v2/x/globalfee/types" -) - -const ( - ModuleName = types.ModuleName -) diff --git a/x/globalfee/client/cli/query.go b/x/globalfee/client/cli/query.go index e4a4c999f..63d57ceef 100644 --- a/x/globalfee/client/cli/query.go +++ b/x/globalfee/client/cli/query.go @@ -11,22 +11,22 @@ import ( func GetQueryCmd() *cobra.Command { queryCmd := &cobra.Command{ Use: types.ModuleName, - Short: "Querying commands for the global fee module", + Short: "Querying commands for the globalfee module", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } queryCmd.AddCommand( - GetCmdShowMinimumGasPrices(), + GetQueryCmdParams(), ) return queryCmd } -func GetCmdShowMinimumGasPrices() *cobra.Command { +func GetQueryCmdParams() *cobra.Command { cmd := &cobra.Command{ - Use: "minimum-gas-prices", - Short: "Show minimum gas prices", - Long: "Show all minimum gas prices", + Use: "params", + Short: "Show params", + Long: "Show parameter of globalfee module", Aliases: []string{"min"}, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { @@ -36,7 +36,7 @@ func GetCmdShowMinimumGasPrices() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.MinimumGasPrices(cmd.Context(), &types.QueryMinimumGasPricesRequest{}) + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) if err != nil { return err } diff --git a/x/globalfee/feechecker/feechecker.go b/x/globalfee/feechecker/feechecker.go index 73b1ca437..18d7b7bed 100644 --- a/x/globalfee/feechecker/feechecker.go +++ b/x/globalfee/feechecker/feechecker.go @@ -1,40 +1,34 @@ package feechecker import ( - "errors" "math" + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/authz" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - "github.com/bandprotocol/chain/v2/x/globalfee" - "github.com/bandprotocol/chain/v2/x/globalfee/types" + "github.com/bandprotocol/chain/v2/x/globalfee/keeper" oraclekeeper "github.com/bandprotocol/chain/v2/x/oracle/keeper" oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ) type FeeChecker struct { - OracleKeeper *oraclekeeper.Keeper - GlobalMinFee globalfee.ParamSource - StakingKeeper *stakingkeeper.Keeper + OracleKeeper *oraclekeeper.Keeper + GlobalfeeKeeper *keeper.Keeper + StakingKeeper *stakingkeeper.Keeper } func NewFeeChecker( oracleKeeper *oraclekeeper.Keeper, - globalfeeSubspace paramtypes.Subspace, + globalfeeKeeper *keeper.Keeper, stakingKeeper *stakingkeeper.Keeper, ) FeeChecker { - if !globalfeeSubspace.HasKeyTable() { - panic("global fee paramspace was not set up via module") - } - return FeeChecker{ - OracleKeeper: oracleKeeper, - GlobalMinFee: globalfeeSubspace, - StakingKeeper: stakingKeeper, + OracleKeeper: oracleKeeper, + GlobalfeeKeeper: globalfeeKeeper, + StakingKeeper: stakingKeeper, } } @@ -44,7 +38,7 @@ func (fc FeeChecker) CheckTxFeeWithMinGasPrices( ) (sdk.Coins, int64, error) { feeTx, ok := tx.(sdk.FeeTx) if !ok { - return nil, 0, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") + return nil, 0, errors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") } feeCoins := feeTx.GetFee() @@ -70,17 +64,19 @@ func (fc FeeChecker) CheckTxFeeWithMinGasPrices( // Calculate all fees from all gas prices gas := feeTx.GetGas() - allFees := make(sdk.Coins, len(allGasPrices)) - if !minGasPrices.IsZero() { + var allFees sdk.Coins + if !allGasPrices.IsZero() { glDec := sdk.NewDec(int64(gas)) - for i, gp := range minGasPrices { - fee := gp.Amount.Mul(glDec) - allFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) + for _, gp := range allGasPrices { + if !gp.IsZero() { + fee := gp.Amount.Mul(glDec) + allFees = append(allFees, sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())) + } } } if !allFees.IsZero() && !feeCoins.IsAnyGTE(allFees) { - return nil, 0, sdkerrors.Wrapf( + return nil, 0, errors.Wrapf( sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, @@ -117,9 +113,7 @@ func (fc FeeChecker) GetGlobalMinGasPrices(ctx sdk.Context) (sdk.DecCoins, error err error ) - if fc.GlobalMinFee.Has(ctx, types.ParamStoreKeyMinGasPrices) { - fc.GlobalMinFee.Get(ctx, types.ParamStoreKeyMinGasPrices, &globalMinGasPrices) - } + globalMinGasPrices = fc.GlobalfeeKeeper.GetParams(ctx).MinimumGasPrices // global fee is empty set, set global fee to 0uband (bondDenom) if len(globalMinGasPrices) == 0 { globalMinGasPrices, err = fc.DefaultZeroGlobalFee(ctx) @@ -131,7 +125,7 @@ func (fc FeeChecker) GetGlobalMinGasPrices(ctx sdk.Context) (sdk.DecCoins, error func (fc FeeChecker) DefaultZeroGlobalFee(ctx sdk.Context) ([]sdk.DecCoin, error) { bondDenom := fc.GetBondDenom(ctx) if bondDenom == "" { - return nil, errors.New("empty staking bond denomination") + return nil, errors.Wrap(sdkerrors.ErrNotFound, "empty staking bond denomination") } return []sdk.DecCoin{sdk.NewDecCoinFromDec(bondDenom, sdk.NewDec(0))}, nil diff --git a/x/globalfee/feechecker/feechecker_test.go b/x/globalfee/feechecker/feechecker_test.go index 9700e06ef..b525670b1 100644 --- a/x/globalfee/feechecker/feechecker_test.go +++ b/x/globalfee/feechecker/feechecker_test.go @@ -5,13 +5,12 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/authz" "github.com/stretchr/testify/suite" "github.com/bandprotocol/chain/v2/testing/testapp" - "github.com/bandprotocol/chain/v2/x/globalfee" "github.com/bandprotocol/chain/v2/x/globalfee/feechecker" "github.com/bandprotocol/chain/v2/x/oracle/types" - "github.com/cosmos/cosmos-sdk/x/authz" ) var ( @@ -82,7 +81,7 @@ func (suite *FeeCheckerTestSuite) SetupTest() { suite.FeeChecker = feechecker.NewFeeChecker( &oracleKeeper, - app.GetSubspace(globalfee.ModuleName), + &app.GlobalfeeKeeper, app.StakingKeeper, ) } diff --git a/x/globalfee/feechecker/utils_test.go b/x/globalfee/feechecker/utils_test.go index 62cb40f91..c7b5ef8a8 100644 --- a/x/globalfee/feechecker/utils_test.go +++ b/x/globalfee/feechecker/utils_test.go @@ -3,9 +3,10 @@ package feechecker_test import ( "testing" - "github.com/bandprotocol/chain/v2/x/globalfee/feechecker" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + + "github.com/bandprotocol/chain/v2/x/globalfee/feechecker" ) type utilsTestSuite struct { diff --git a/x/globalfee/genesis_test.go b/x/globalfee/genesis_test.go index 267657930..78dd07b41 100644 --- a/x/globalfee/genesis_test.go +++ b/x/globalfee/genesis_test.go @@ -2,21 +2,10 @@ package globalfee import ( "testing" - "time" - dbm "github.com/cometbft/cometbft-db" - "github.com/cometbft/cometbft/libs/log" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - - "github.com/bandprotocol/chain/v2/x/globalfee/types" ) func TestDefaultGenesis(t *testing.T) { @@ -72,60 +61,3 @@ func TestValidateGenesis(t *testing.T) { }) } } - -func TestInitExportGenesis(t *testing.T) { - specs := map[string]struct { - src string - exp types.GenesisState - }{ - "single fee": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}]}}`, - exp: types.GenesisState{ - Params: types.Params{MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1)))}, - }, - }, - "multiple fee options": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}, {"denom":"BLX", "amount":"0.001"}]}}`, - exp: types.GenesisState{ - Params: types.Params{MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1)), - sdk.NewDecCoinFromDec("BLX", sdk.NewDecWithPrec(1, 3)))}, - }, - }, - "no fee set": { - src: `{"params":{}}`, - exp: types.GenesisState{Params: types.Params{MinimumGasPrices: sdk.DecCoins{}}}, - }, - } - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - ctx, encCfg, subspace := setupTestStore(t) - m := NewAppModule(subspace) - m.InitGenesis(ctx, encCfg.Codec, []byte(spec.src)) - gotJSON := m.ExportGenesis(ctx, encCfg.Codec) - var got types.GenesisState - require.NoError(t, encCfg.Codec.UnmarshalJSON(gotJSON, &got)) - assert.Equal(t, spec.exp, got, string(gotJSON)) - }) - } -} - -func setupTestStore(t *testing.T) (sdk.Context, moduletestutil.TestEncodingConfig, paramstypes.Subspace) { - db := dbm.NewMemDB() - ms := store.NewCommitMultiStore(db) - encCfg := moduletestutil.MakeTestEncodingConfig() - keyParams := sdk.NewKVStoreKey(paramstypes.StoreKey) - tkeyParams := sdk.NewTransientStoreKey(paramstypes.TStoreKey) - ms.MountStoreWithDB(keyParams, storetypes.StoreTypeIAVL, db) - ms.MountStoreWithDB(tkeyParams, storetypes.StoreTypeTransient, db) - require.NoError(t, ms.LoadLatestVersion()) - - paramsKeeper := paramskeeper.NewKeeper(encCfg.Codec, encCfg.Amino, keyParams, tkeyParams) - - ctx := sdk.NewContext(ms, tmproto.Header{ - Height: 1234567, - Time: time.Date(2020, time.April, 22, 12, 0, 0, 0, time.UTC), - }, false, log.NewNopLogger()) - - subspace := paramsKeeper.Subspace(ModuleName).WithKeyTable(types.ParamKeyTable()) - return ctx, encCfg, subspace -} diff --git a/x/globalfee/grpc_query.go b/x/globalfee/grpc_query.go deleted file mode 100644 index be4bea317..000000000 --- a/x/globalfee/grpc_query.go +++ /dev/null @@ -1,40 +0,0 @@ -package globalfee - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/bandprotocol/chain/v2/x/globalfee/types" -) - -var _ types.QueryServer = &Querier{} - -// ParamSource is a read only subset of paramtypes.Subspace -type ParamSource interface { - Get(ctx sdk.Context, key []byte, ptr interface{}) - Has(ctx sdk.Context, key []byte) bool -} - -type Querier struct { - paramSource ParamSource -} - -func NewGrpcQuerier(paramSource ParamSource) Querier { - return Querier{paramSource: paramSource} -} - -// MinimumGasPrices return minimum gas prices -func (q Querier) MinimumGasPrices( - stdCtx context.Context, - _ *types.QueryMinimumGasPricesRequest, -) (*types.QueryMinimumGasPricesResponse, error) { - var minGasPrices sdk.DecCoins - ctx := sdk.UnwrapSDKContext(stdCtx) - if q.paramSource.Has(ctx, types.ParamStoreKeyMinGasPrices) { - q.paramSource.Get(ctx, types.ParamStoreKeyMinGasPrices, &minGasPrices) - } - return &types.QueryMinimumGasPricesResponse{ - MinimumGasPrices: minGasPrices, - }, nil -} diff --git a/x/globalfee/grpc_query_test.go b/x/globalfee/grpc_query_test.go deleted file mode 100644 index fdd196bbb..000000000 --- a/x/globalfee/grpc_query_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package globalfee - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/bandprotocol/chain/v2/x/globalfee/types" -) - -func TestQueryMinimumGasPrices(t *testing.T) { - specs := map[string]struct { - setupStore func(ctx sdk.Context, s paramtypes.Subspace) - expMin sdk.DecCoins - }{ - "one coin": { - setupStore: func(ctx sdk.Context, s paramtypes.Subspace) { - s.SetParamSet(ctx, &types.Params{ - MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.OneInt())), - }) - }, - expMin: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.OneInt())), - }, - "multiple coins": { - setupStore: func(ctx sdk.Context, s paramtypes.Subspace) { - s.SetParamSet(ctx, &types.Params{ - MinimumGasPrices: sdk.NewDecCoins( - sdk.NewDecCoin("ALX", sdk.OneInt()), - sdk.NewDecCoin("BLX", sdk.NewInt(2)), - ), - }) - }, - expMin: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.OneInt()), sdk.NewDecCoin("BLX", sdk.NewInt(2))), - }, - "no min gas price set": { - setupStore: func(ctx sdk.Context, s paramtypes.Subspace) { - s.SetParamSet(ctx, &types.Params{}) - }, - }, - "no param set": { - setupStore: func(ctx sdk.Context, s paramtypes.Subspace) { - }, - }, - } - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - ctx, _, subspace := setupTestStore(t) - spec.setupStore(ctx, subspace) - q := NewGrpcQuerier(subspace) - gotResp, gotErr := q.MinimumGasPrices(sdk.WrapSDKContext(ctx), nil) - require.NoError(t, gotErr) - require.NotNil(t, gotResp) - assert.Equal(t, spec.expMin, gotResp.MinimumGasPrices) - }) - } -} diff --git a/x/globalfee/keeper/genesis.go b/x/globalfee/keeper/genesis.go new file mode 100644 index 000000000..330402d92 --- /dev/null +++ b/x/globalfee/keeper/genesis.go @@ -0,0 +1,20 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bandprotocol/chain/v2/x/globalfee/types" +) + +// InitGenesis new globalfee genesis +func (keeper Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { + if err := keeper.SetParams(ctx, data.Params); err != nil { + panic(err) + } +} + +// ExportGenesis returns a GenesisState for a given context. +func (keeper Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + params := keeper.GetParams(ctx) + return types.NewGenesisState(params) +} diff --git a/x/globalfee/keeper/genesis_test.go b/x/globalfee/keeper/genesis_test.go new file mode 100644 index 000000000..c24285b1d --- /dev/null +++ b/x/globalfee/keeper/genesis_test.go @@ -0,0 +1,81 @@ +package keeper_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/stretchr/testify/suite" + + "github.com/bandprotocol/chain/v2/x/globalfee" + "github.com/bandprotocol/chain/v2/x/globalfee/keeper" + "github.com/bandprotocol/chain/v2/x/globalfee/types" +) + +type GenesisTestSuite struct { + suite.Suite + + sdkCtx sdk.Context + keeper keeper.Keeper + cdc codec.BinaryCodec + key *storetypes.KVStoreKey +} + +func TestGenesisTestSuite(t *testing.T) { + suite.Run(t, new(GenesisTestSuite)) +} + +func (s *GenesisTestSuite) SetupTest() { + key := sdk.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test")) + encCfg := moduletestutil.MakeTestEncodingConfig(globalfee.AppModuleBasic{}) + + // gomock initializations + s.cdc = codec.NewProtoCodec(encCfg.InterfaceRegistry) + s.sdkCtx = testCtx.Ctx + s.key = key + + s.keeper = keeper.NewKeeper(s.cdc, key, authtypes.NewModuleAddress(govtypes.ModuleName).String()) +} + +func (s *GenesisTestSuite) TestImportExportGenesis() { + specs := map[string]struct { + src string + exp types.GenesisState + }{ + "single fee": { + src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}]}}`, + exp: types.GenesisState{ + Params: types.Params{MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1)))}, + }, + }, + "multiple fee options": { + src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}, {"denom":"BLX", "amount":"0.001"}]}}`, + exp: types.GenesisState{ + Params: types.Params{MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1)), + sdk.NewDecCoinFromDec("BLX", sdk.NewDecWithPrec(1, 3)))}, + }, + }, + "no fee set": { + src: `{"params":{}}`, + exp: types.GenesisState{Params: types.Params{MinimumGasPrices: nil}}, + }, + } + for name, spec := range specs { + s.Run(name, func() { + genesisState := &spec.exp + s.keeper.InitGenesis(s.sdkCtx, genesisState) + + params := s.keeper.GetParams(s.sdkCtx) + s.Require().Equal(genesisState.Params, params) + + genesisState2 := s.keeper.ExportGenesis(s.sdkCtx) + s.Require().Equal(genesisState, genesisState2) + }) + } +} diff --git a/x/globalfee/keeper/grpc_query.go b/x/globalfee/keeper/grpc_query.go new file mode 100644 index 000000000..e3306ee21 --- /dev/null +++ b/x/globalfee/keeper/grpc_query.go @@ -0,0 +1,24 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bandprotocol/chain/v2/x/globalfee/types" +) + +var _ types.QueryServer = &Querier{} + +type Querier struct { + Keeper +} + +// Params return parameters of globalfee module +func (q Querier) Params(stdCtx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(stdCtx) + + return &types.QueryParamsResponse{ + Params: q.GetParams(ctx), + }, nil +} diff --git a/x/globalfee/keeper/grpc_query_test.go b/x/globalfee/keeper/grpc_query_test.go new file mode 100644 index 000000000..39aa29be7 --- /dev/null +++ b/x/globalfee/keeper/grpc_query_test.go @@ -0,0 +1,73 @@ +package keeper_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/bandprotocol/chain/v2/x/globalfee/keeper" + "github.com/bandprotocol/chain/v2/x/globalfee/types" +) + +func TestQueryParams(t *testing.T) { + specs := map[string]struct { + setupStore func(ctx sdk.Context, k keeper.Keeper) + expMin sdk.DecCoins + }{ + "one coin": { + setupStore: func(ctx sdk.Context, k keeper.Keeper) { + k.SetParams(ctx, types.Params{ + MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.OneInt())), + }) + }, + expMin: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.OneInt())), + }, + "multiple coins": { + setupStore: func(ctx sdk.Context, k keeper.Keeper) { + k.SetParams(ctx, types.Params{ + MinimumGasPrices: sdk.NewDecCoins( + sdk.NewDecCoin("ALX", sdk.OneInt()), + sdk.NewDecCoin("BLX", sdk.NewInt(2)), + ), + }) + }, + expMin: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.OneInt()), sdk.NewDecCoin("BLX", sdk.NewInt(2))), + }, + "no min gas price set": { + setupStore: func(ctx sdk.Context, k keeper.Keeper) { + k.SetParams(ctx, types.Params{}) + }, + }, + "no param set": { + setupStore: func(ctx sdk.Context, k keeper.Keeper) { + }, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + encCfg := moduletestutil.MakeTestEncodingConfig() + key := sdk.NewKVStoreKey(types.StoreKey) + ctx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test")).Ctx + + k := keeper.NewKeeper( + encCfg.Codec, + key, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + q := keeper.Querier{Keeper: k} + spec.setupStore(ctx, k) + gotResp, gotErr := q.Params(sdk.WrapSDKContext(ctx), nil) + + require.NoError(t, gotErr) + require.NotNil(t, gotResp) + assert.Equal(t, spec.expMin, gotResp.Params.MinimumGasPrices) + }) + } +} diff --git a/x/globalfee/keeper/keeper.go b/x/globalfee/keeper/keeper.go new file mode 100644 index 000000000..f6163c535 --- /dev/null +++ b/x/globalfee/keeper/keeper.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bandprotocol/chain/v2/x/globalfee/types" +) + +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + + authority string +} + +func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, authority string) Keeper { + return Keeper{ + storeKey: storeKey, + cdc: cdc, + authority: authority, + } +} + +func (k *Keeper) GetAuthority() string { + return k.authority +} + +// SetParams sets the x/globalfee module parameters. +func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { + if err := p.Validate(); err != nil { + return err + } + + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&p) + store.Set(types.ParamsKeyPrefix, bz) + + return nil +} + +// GetParams returns the current x/globalfee module parameters. +func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKeyPrefix) + if bz == nil { + return p + } + + k.cdc.MustUnmarshal(bz, &p) + return p +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} diff --git a/x/globalfee/keeper/keeper_test.go b/x/globalfee/keeper/keeper_test.go new file mode 100644 index 000000000..91a0e2402 --- /dev/null +++ b/x/globalfee/keeper/keeper_test.go @@ -0,0 +1,87 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/bandprotocol/chain/v2/x/globalfee" + "github.com/bandprotocol/chain/v2/x/globalfee/keeper" + "github.com/bandprotocol/chain/v2/x/globalfee/types" +) + +type IntegrationTestSuite struct { + suite.Suite + + globalfeeKeeper keeper.Keeper + ctx sdk.Context + msgServer types.MsgServer +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} + +func (s *IntegrationTestSuite) SetupTest() { + encCfg := moduletestutil.MakeTestEncodingConfig(globalfee.AppModuleBasic{}) + key := sdk.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test")) + s.ctx = testCtx.Ctx + + s.globalfeeKeeper = keeper.NewKeeper( + encCfg.Codec, + key, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + s.Require().Equal(testCtx.Ctx.Logger().With("module", "x/"+types.ModuleName), + s.globalfeeKeeper.Logger(testCtx.Ctx)) + + err := s.globalfeeKeeper.SetParams(s.ctx, types.DefaultParams()) + s.Require().NoError(err) + + s.msgServer = keeper.NewMsgServerImpl(s.globalfeeKeeper) +} + +func (s *IntegrationTestSuite) TestParams() { + testCases := []struct { + name string + input types.Params + expectErr bool + }{ + { + name: "set full valid params", + input: types.Params{ + MinimumGasPrices: sdk.NewDecCoins( + sdk.NewDecCoin("ALX", sdk.NewInt(1)), + sdk.NewDecCoinFromDec("BLX", sdk.NewDecWithPrec(1, 3)), + ), + }, + expectErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + expected := s.globalfeeKeeper.GetParams(s.ctx) + err := s.globalfeeKeeper.SetParams(s.ctx, tc.input) + if tc.expectErr { + s.Require().Error(err) + } else { + expected = tc.input + s.Require().NoError(err) + } + + p := s.globalfeeKeeper.GetParams(s.ctx) + s.Require().Equal(expected, p) + }) + } +} diff --git a/x/globalfee/keeper/msg_server.go b/x/globalfee/keeper/msg_server.go new file mode 100644 index 000000000..71d54ca18 --- /dev/null +++ b/x/globalfee/keeper/msg_server.go @@ -0,0 +1,45 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/bandprotocol/chain/v2/x/globalfee/types" +) + +type msgServer struct { + Keeper +} + +var _ types.MsgServer = msgServer{} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +// UpdateParams updates the params. +func (ms msgServer) UpdateParams( + goCtx context.Context, + req *types.MsgUpdateParams, +) (*types.MsgUpdateParamsResponse, error) { + if ms.authority != req.Authority { + return nil, errors.Wrapf( + govtypes.ErrInvalidSigner, + "invalid authority; expected %s, got %s", + ms.authority, + req.Authority, + ) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + if err := ms.SetParams(ctx, req.Params); err != nil { + return nil, err + } + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/globalfee/keeper/msg_server_test.go b/x/globalfee/keeper/msg_server_test.go new file mode 100644 index 000000000..85e5066a6 --- /dev/null +++ b/x/globalfee/keeper/msg_server_test.go @@ -0,0 +1,48 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bandprotocol/chain/v2/x/globalfee/types" +) + +func (s *IntegrationTestSuite) TestUpdateParams() { + testCases := []struct { + name string + request *types.MsgUpdateParams + expectErr bool + }{ + { + name: "set invalid authority", + request: &types.MsgUpdateParams{ + Authority: "foo", + }, + expectErr: true, + }, + { + name: "set full valid params", + request: &types.MsgUpdateParams{ + Authority: s.globalfeeKeeper.GetAuthority(), + Params: types.Params{ + MinimumGasPrices: sdk.NewDecCoins( + sdk.NewDecCoin("ALX", sdk.NewInt(1)), + sdk.NewDecCoinFromDec("BLX", sdk.NewDecWithPrec(1, 3)), + ), + }, + }, + expectErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + _, err := s.msgServer.UpdateParams(s.ctx, tc.request) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + } + }) + } +} diff --git a/x/globalfee/module.go b/x/globalfee/module.go index cdc20bdd6..020701537 100644 --- a/x/globalfee/module.go +++ b/x/globalfee/module.go @@ -4,21 +4,24 @@ import ( "context" "encoding/json" + "cosmossdk.io/errors" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" "github.com/bandprotocol/chain/v2/x/globalfee/client/cli" + "github.com/bandprotocol/chain/v2/x/globalfee/keeper" "github.com/bandprotocol/chain/v2/x/globalfee/types" ) +// ConsensusVersion defines the current x/globalfee module consensus version. +const ConsensusVersion = 1 + var ( _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleGenesis = AppModule{} @@ -32,10 +35,18 @@ func (a AppModuleBasic) Name() string { return types.ModuleName } +// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(r codectypes.InterfaceRegistry) { + types.RegisterInterfaces(r) +} + func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(&types.GenesisState{ - Params: types.DefaultParams(), - }) + return cdc.MustMarshalJSON(types.DefaultGenesisState()) } func (a AppModuleBasic) ValidateGenesis( @@ -48,13 +59,12 @@ func (a AppModuleBasic) ValidateGenesis( if err != nil { return err } - if err := data.Params.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "params") + + if err := data.Params.Validate(); err != nil { + return errors.Wrap(err, "params") } - return nil -} -func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + return nil } func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { @@ -69,21 +79,18 @@ func (a AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -func (a AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { -} - type AppModule struct { AppModuleBasic - paramSpace paramstypes.Subspace + + keeper keeper.Keeper } // NewAppModule constructor -func NewAppModule(paramSpace paramstypes.Subspace) *AppModule { - if !paramSpace.HasKeyTable() { - paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) +func NewAppModule(keeper keeper.Keeper) *AppModule { + return &AppModule{ + AppModuleBasic: AppModuleBasic{}, + keeper: keeper, } - - return &AppModule{paramSpace: paramSpace} } func (a AppModule) InitGenesis( @@ -93,21 +100,22 @@ func (a AppModule) InitGenesis( ) []abci.ValidatorUpdate { var genesisState types.GenesisState marshaler.MustUnmarshalJSON(message, &genesisState) - a.paramSpace.SetParamSet(ctx, &genesisState.Params) - return nil + + a.keeper.InitGenesis(ctx, &genesisState) + return []abci.ValidatorUpdate{} } func (a AppModule) ExportGenesis(ctx sdk.Context, marshaler codec.JSONCodec) json.RawMessage { - var genState types.GenesisState - a.paramSpace.GetParamSet(ctx, &genState.Params) - return marshaler.MustMarshalJSON(&genState) + genState := a.keeper.ExportGenesis(ctx) + return marshaler.MustMarshalJSON(genState) } func (a AppModule) RegisterInvariants(registry sdk.InvariantRegistry) { } func (a AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterQueryServer(cfg.QueryServer(), NewGrpcQuerier(a.paramSpace)) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(a.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), keeper.Querier{Keeper: a.keeper}) } func (a AppModule) BeginBlock(context sdk.Context, block abci.RequestBeginBlock) { @@ -122,5 +130,5 @@ func (a AppModule) EndBlock(context sdk.Context, block abci.RequestEndBlock) []a // introduced by the module. To avoid wrong/empty versions, the initial version // should be set to 1. func (a AppModule) ConsensusVersion() uint64 { - return 1 + return ConsensusVersion } diff --git a/x/globalfee/types/codec.go b/x/globalfee/types/codec.go new file mode 100644 index 000000000..d4ed7385d --- /dev/null +++ b/x/globalfee/types/codec.go @@ -0,0 +1,30 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(Params{}, "globalfee/Params", nil) + legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "globalfee/MsgUpdateParams") +} + +// RegisterInterfaces registers the interfaces types with the interface registry. +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgUpdateParams{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} diff --git a/x/globalfee/types/genesis.go b/x/globalfee/types/genesis.go index a87d8d989..5c749ab79 100644 --- a/x/globalfee/types/genesis.go +++ b/x/globalfee/types/genesis.go @@ -3,8 +3,8 @@ package types import ( "encoding/json" + "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) // NewGenesisState - Create a new genesis state @@ -32,8 +32,8 @@ func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMe } func ValidateGenesis(data GenesisState) error { - if err := data.Params.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "globalfee params") + if err := data.Params.Validate(); err != nil { + return errors.Wrap(err, "globalfee params") } return nil diff --git a/x/globalfee/types/keys.go b/x/globalfee/types/keys.go index 71b43267d..f79244713 100644 --- a/x/globalfee/types/keys.go +++ b/x/globalfee/types/keys.go @@ -5,4 +5,11 @@ const ( ModuleName = "globalfee" QuerierRoute = ModuleName + + // StoreKey to be used when creating the KVStore. + StoreKey = ModuleName +) + +var ( + ParamsKeyPrefix = []byte{0x01} ) diff --git a/x/globalfee/types/msgs.go b/x/globalfee/types/msgs.go new file mode 100644 index 000000000..27ecb6f9c --- /dev/null +++ b/x/globalfee/types/msgs.go @@ -0,0 +1,32 @@ +package types + +import ( + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.Msg = &MsgUpdateParams{} + +// GetSignBytes implements the LegacyMsg interface. +func (m MsgUpdateParams) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgUpdateParams message. +func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(m.Authority) + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data. +func (m *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return errors.Wrap(err, "invalid authority address") + } + + if err := m.Params.Validate(); err != nil { + return err + } + + return nil +} diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index d2b5f985f..c983c714a 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -1,43 +1,33 @@ package types import ( + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -// ParamStoreKeyMinGasPrices store key -var ParamStoreKeyMinGasPrices = []byte("MinimumGasPricesParam") +// NewParams returns Params instance with the given values. +func NewParams(minimumGasPrices sdk.DecCoins) Params { + return Params{ + MinimumGasPrices: minimumGasPrices, + } +} // DefaultParams returns default parameters func DefaultParams() Params { return Params{MinimumGasPrices: sdk.DecCoins{}} } -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -// ValidateBasic performs basic validation. -func (p Params) ValidateBasic() error { - return validateMinimumGasPrices(p.MinimumGasPrices) -} - -// ParamSetPairs returns the parameter set pairs. -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair( - ParamStoreKeyMinGasPrices, &p.MinimumGasPrices, validateMinimumGasPrices, - ), - } -} - // this requires the fee non-negative func validateMinimumGasPrices(i interface{}) error { v, ok := i.(sdk.DecCoins) if !ok { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "type: %T, expected sdk.DecCoins", i) + return errors.Wrapf(sdkerrors.ErrInvalidType, "type: %T, expected sdk.DecCoins", i) } return v.Validate() } + +func (p Params) Validate() error { + return validateMinimumGasPrices(p.MinimumGasPrices) +} diff --git a/x/globalfee/types/query.pb.go b/x/globalfee/types/query.pb.go index 9a20b0632..e85fbe20a 100644 --- a/x/globalfee/types/query.pb.go +++ b/x/globalfee/types/query.pb.go @@ -6,8 +6,6 @@ package types import ( context "context" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -31,23 +29,22 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryMinimumGasPricesRequest is the request type for the -// Query/MinimumGasPrices RPC method. -type QueryMinimumGasPricesRequest struct { +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { } -func (m *QueryMinimumGasPricesRequest) Reset() { *m = QueryMinimumGasPricesRequest{} } -func (m *QueryMinimumGasPricesRequest) String() string { return proto.CompactTextString(m) } -func (*QueryMinimumGasPricesRequest) ProtoMessage() {} -func (*QueryMinimumGasPricesRequest) Descriptor() ([]byte, []int) { +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_6d5fd101df5712fa, []int{0} } -func (m *QueryMinimumGasPricesRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryMinimumGasPricesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryMinimumGasPricesRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -57,36 +54,36 @@ func (m *QueryMinimumGasPricesRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryMinimumGasPricesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryMinimumGasPricesRequest.Merge(m, src) +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) } -func (m *QueryMinimumGasPricesRequest) XXX_Size() int { +func (m *QueryParamsRequest) XXX_Size() int { return m.Size() } -func (m *QueryMinimumGasPricesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryMinimumGasPricesRequest.DiscardUnknown(m) +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryMinimumGasPricesRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo -// QueryMinimumGasPricesResponse is the response type for the -// Query/MinimumGasPrices RPC method. -type QueryMinimumGasPricesResponse struct { - MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // pagination defines an optional pagination for the request. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` } -func (m *QueryMinimumGasPricesResponse) Reset() { *m = QueryMinimumGasPricesResponse{} } -func (m *QueryMinimumGasPricesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryMinimumGasPricesResponse) ProtoMessage() {} -func (*QueryMinimumGasPricesResponse) Descriptor() ([]byte, []int) { +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_6d5fd101df5712fa, []int{1} } -func (m *QueryMinimumGasPricesResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryMinimumGasPricesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryMinimumGasPricesResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -96,59 +93,53 @@ func (m *QueryMinimumGasPricesResponse) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *QueryMinimumGasPricesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryMinimumGasPricesResponse.Merge(m, src) +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) } -func (m *QueryMinimumGasPricesResponse) XXX_Size() int { +func (m *QueryParamsResponse) XXX_Size() int { return m.Size() } -func (m *QueryMinimumGasPricesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryMinimumGasPricesResponse.DiscardUnknown(m) +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryMinimumGasPricesResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo -func (m *QueryMinimumGasPricesResponse) GetMinimumGasPrices() github_com_cosmos_cosmos_sdk_types.DecCoins { +func (m *QueryParamsResponse) GetParams() Params { if m != nil { - return m.MinimumGasPrices + return m.Params } - return nil + return Params{} } func init() { - proto.RegisterType((*QueryMinimumGasPricesRequest)(nil), "globalfee.v1beta1.QueryMinimumGasPricesRequest") - proto.RegisterType((*QueryMinimumGasPricesResponse)(nil), "globalfee.v1beta1.QueryMinimumGasPricesResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "globalfee.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "globalfee.v1beta1.QueryParamsResponse") } func init() { proto.RegisterFile("globalfee/v1beta1/query.proto", fileDescriptor_6d5fd101df5712fa) } var fileDescriptor_6d5fd101df5712fa = []byte{ - // 385 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xb1, 0x6a, 0xdb, 0x40, - 0x18, 0xc7, 0x75, 0x2d, 0xed, 0xa0, 0x2e, 0xae, 0xe8, 0xd0, 0x1a, 0xf9, 0x54, 0x04, 0xa5, 0x85, - 0xd6, 0x77, 0xb5, 0xba, 0x75, 0x74, 0x0b, 0x5d, 0x5a, 0x68, 0x3d, 0x76, 0x31, 0x27, 0xf9, 0x22, - 0x1f, 0xd1, 0xdd, 0x27, 0xfb, 0x4e, 0x26, 0x5a, 0xf3, 0x04, 0x81, 0xbc, 0x42, 0xa6, 0x0c, 0x79, - 0x82, 0x3c, 0x80, 0x47, 0x43, 0x96, 0x4c, 0x4a, 0xb0, 0x33, 0x65, 0xcc, 0x13, 0x04, 0x4b, 0x76, - 0x62, 0x2c, 0x12, 0x32, 0xdd, 0xc1, 0xef, 0xff, 0xf1, 0xe7, 0xff, 0xff, 0x3e, 0xbb, 0x15, 0x27, - 0x10, 0xb2, 0x64, 0x87, 0x73, 0x3a, 0xe9, 0x84, 0xdc, 0xb0, 0x0e, 0x1d, 0x65, 0x7c, 0x9c, 0x93, - 0x74, 0x0c, 0x06, 0x9c, 0xd7, 0x77, 0x98, 0xac, 0x70, 0xf3, 0x4d, 0x0c, 0x31, 0x94, 0x94, 0x2e, - 0x7f, 0x95, 0xb0, 0xe9, 0xc6, 0x00, 0x71, 0xc2, 0x29, 0x4b, 0x05, 0x65, 0x4a, 0x81, 0x61, 0x46, - 0x80, 0xd2, 0x2b, 0x8a, 0x23, 0xd0, 0x12, 0x34, 0x0d, 0x99, 0xbe, 0xf7, 0x89, 0x40, 0xa8, 0x8a, - 0xfb, 0xd8, 0x76, 0xff, 0x2d, 0x5d, 0xff, 0x08, 0x25, 0x64, 0x26, 0x7f, 0x31, 0xfd, 0x77, 0x2c, - 0x22, 0xae, 0x7b, 0x7c, 0x94, 0x71, 0x6d, 0xfc, 0x02, 0xd9, 0xad, 0x07, 0x04, 0x3a, 0x05, 0xa5, - 0xb9, 0x73, 0x8a, 0x6c, 0x47, 0x56, 0xb0, 0x1f, 0x33, 0xdd, 0x4f, 0x4b, 0xfc, 0x16, 0xbd, 0x7f, - 0xfe, 0xe9, 0x55, 0xe0, 0x92, 0xca, 0x9f, 0x2c, 0xfd, 0xd7, 0x41, 0xc8, 0x4f, 0x1e, 0xfd, 0x00, - 0xa1, 0xba, 0xe9, 0xb4, 0xf0, 0xac, 0xeb, 0xc2, 0x73, 0xeb, 0xf3, 0x5f, 0x40, 0x0a, 0xc3, 0x65, - 0x6a, 0xf2, 0x9b, 0xc2, 0x7b, 0x97, 0x33, 0x99, 0x7c, 0xf7, 0xeb, 0x2a, 0xff, 0xf8, 0xc2, 0xfb, - 0x1c, 0x0b, 0x33, 0xcc, 0x42, 0x12, 0x81, 0xa4, 0xab, 0xb0, 0xd5, 0xd3, 0xd6, 0x83, 0x5d, 0x6a, - 0xf2, 0x94, 0xeb, 0xb5, 0xa1, 0xee, 0x35, 0xe4, 0x56, 0x8c, 0xe0, 0x04, 0xd9, 0x2f, 0xca, 0x80, - 0xce, 0x11, 0xb2, 0x1b, 0xdb, 0x29, 0x1d, 0x4a, 0x6a, 0x7b, 0x20, 0x8f, 0x15, 0xd6, 0xfc, 0xfa, - 0xf4, 0x81, 0xaa, 0x40, 0xbf, 0xbd, 0x7f, 0x76, 0x75, 0xf8, 0xec, 0xa3, 0xf3, 0x81, 0xd6, 0x2f, - 0xa2, 0x1e, 0xb9, 0xfb, 0x7b, 0x3a, 0xc7, 0x68, 0x36, 0xc7, 0xe8, 0x72, 0x8e, 0xd1, 0xc1, 0x02, - 0x5b, 0xb3, 0x05, 0xb6, 0xce, 0x17, 0xd8, 0xfa, 0x1f, 0x6c, 0x34, 0x11, 0x32, 0x35, 0x28, 0x37, - 0x1c, 0x41, 0x42, 0xa3, 0x21, 0x13, 0x8a, 0x4e, 0x02, 0xba, 0xb7, 0x61, 0x51, 0x36, 0x13, 0xbe, - 0x2c, 0x45, 0xdf, 0x6e, 0x03, 0x00, 0x00, 0xff, 0xff, 0x76, 0x1d, 0x08, 0xbe, 0x8e, 0x02, 0x00, - 0x00, + // 290 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4d, 0xcf, 0xc9, 0x4f, + 0x4a, 0xcc, 0x49, 0x4b, 0x4d, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x2c, + 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0x4b, 0xeb, 0x41, 0xa5, + 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xb2, 0xfa, 0x20, 0x16, 0x44, 0xa1, 0x94, 0x4c, 0x7a, + 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x7e, 0x62, 0x41, 0xa6, 0x7e, 0x62, 0x5e, 0x5e, 0x7e, 0x49, 0x62, + 0x49, 0x66, 0x7e, 0x5e, 0x31, 0x54, 0x56, 0x1e, 0xd3, 0x96, 0xf4, 0xd4, 0xbc, 0xd4, 0xe2, 0x4c, + 0xa8, 0x02, 0x25, 0x11, 0x2e, 0xa1, 0x40, 0x90, 0xb5, 0x01, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x41, + 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x4a, 0x7e, 0x5c, 0xc2, 0x28, 0xa2, 0xc5, 0x05, 0xf9, 0x79, + 0xc5, 0xa9, 0x42, 0xe6, 0x5c, 0x6c, 0x05, 0x60, 0x11, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, + 0x49, 0x3d, 0x0c, 0x57, 0xea, 0x41, 0xb4, 0x38, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0x55, + 0x6e, 0xd4, 0xcc, 0xc8, 0xc5, 0x0a, 0x36, 0x50, 0xa8, 0x8a, 0x8b, 0x0d, 0xa2, 0x42, 0x48, 0x15, + 0x8b, 0x66, 0x4c, 0xa7, 0x48, 0xa9, 0x11, 0x52, 0x06, 0x71, 0x9b, 0x92, 0x62, 0xd3, 0xe5, 0x27, + 0x93, 0x99, 0xa4, 0x85, 0x24, 0xf5, 0x31, 0xbd, 0x0c, 0x71, 0x85, 0x93, 0xcf, 0x89, 0x47, 0x72, + 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, + 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, + 0xe7, 0xe7, 0xea, 0x27, 0x25, 0xe6, 0xa5, 0x80, 0xc3, 0x26, 0x39, 0x3f, 0x47, 0x3f, 0x39, 0x23, + 0x31, 0x33, 0x4f, 0xbf, 0xcc, 0x48, 0xbf, 0x02, 0xc9, 0xd8, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, + 0x36, 0xb0, 0x22, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc8, 0xea, 0x91, 0xf7, 0xc9, 0x01, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -163,7 +154,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - MinimumGasPrices(ctx context.Context, in *QueryMinimumGasPricesRequest, opts ...grpc.CallOption) (*QueryMinimumGasPricesResponse, error) + // Params queries parameters of globalfee module + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) } type queryClient struct { @@ -174,9 +166,9 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) MinimumGasPrices(ctx context.Context, in *QueryMinimumGasPricesRequest, opts ...grpc.CallOption) (*QueryMinimumGasPricesResponse, error) { - out := new(QueryMinimumGasPricesResponse) - err := c.cc.Invoke(ctx, "/globalfee.v1beta1.Query/MinimumGasPrices", in, out, opts...) +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/globalfee.v1beta1.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -185,35 +177,36 @@ func (c *queryClient) MinimumGasPrices(ctx context.Context, in *QueryMinimumGasP // QueryServer is the server API for Query service. type QueryServer interface { - MinimumGasPrices(context.Context, *QueryMinimumGasPricesRequest) (*QueryMinimumGasPricesResponse, error) + // Params queries parameters of globalfee module + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) MinimumGasPrices(ctx context.Context, req *QueryMinimumGasPricesRequest) (*QueryMinimumGasPricesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method MinimumGasPrices not implemented") +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_MinimumGasPrices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryMinimumGasPricesRequest) +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).MinimumGasPrices(ctx, in) + return srv.(QueryServer).Params(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/globalfee.v1beta1.Query/MinimumGasPrices", + FullMethod: "/globalfee.v1beta1.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).MinimumGasPrices(ctx, req.(*QueryMinimumGasPricesRequest)) + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) } return interceptor(ctx, in, info, handler) } @@ -223,15 +216,15 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "MinimumGasPrices", - Handler: _Query_MinimumGasPrices_Handler, + MethodName: "Params", + Handler: _Query_Params_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "globalfee/v1beta1/query.proto", } -func (m *QueryMinimumGasPricesRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -241,12 +234,12 @@ func (m *QueryMinimumGasPricesRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryMinimumGasPricesRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryMinimumGasPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -254,7 +247,7 @@ func (m *QueryMinimumGasPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *QueryMinimumGasPricesResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -264,30 +257,26 @@ func (m *QueryMinimumGasPricesResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryMinimumGasPricesResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryMinimumGasPricesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.MinimumGasPrices) > 0 { - for iNdEx := len(m.MinimumGasPrices) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.MinimumGasPrices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -302,7 +291,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryMinimumGasPricesRequest) Size() (n int) { +func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 } @@ -311,18 +300,14 @@ func (m *QueryMinimumGasPricesRequest) Size() (n int) { return n } -func (m *QueryMinimumGasPricesResponse) Size() (n int) { +func (m *QueryParamsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.MinimumGasPrices) > 0 { - for _, e := range m.MinimumGasPrices { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -332,7 +317,7 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryMinimumGasPricesRequest) Unmarshal(dAtA []byte) error { +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -355,10 +340,10 @@ func (m *QueryMinimumGasPricesRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryMinimumGasPricesRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryMinimumGasPricesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -382,7 +367,7 @@ func (m *QueryMinimumGasPricesRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryMinimumGasPricesResponse) Unmarshal(dAtA []byte) error { +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -405,15 +390,15 @@ func (m *QueryMinimumGasPricesResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryMinimumGasPricesResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryMinimumGasPricesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinimumGasPrices", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -440,8 +425,7 @@ func (m *QueryMinimumGasPricesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MinimumGasPrices = append(m.MinimumGasPrices, types.DecCoin{}) - if err := m.MinimumGasPrices[len(m.MinimumGasPrices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/globalfee/types/query.pb.gw.go b/x/globalfee/types/query.pb.gw.go index e39226a46..2bddbd2b8 100644 --- a/x/globalfee/types/query.pb.gw.go +++ b/x/globalfee/types/query.pb.gw.go @@ -33,20 +33,20 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_MinimumGasPrices_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryMinimumGasPricesRequest +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest var metadata runtime.ServerMetadata - msg, err := client.MinimumGasPrices(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_MinimumGasPrices_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryMinimumGasPricesRequest +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest var metadata runtime.ServerMetadata - msg, err := server.MinimumGasPrices(ctx, &protoReq) + msg, err := server.Params(ctx, &protoReq) return msg, metadata, err } @@ -57,7 +57,7 @@ func local_request_Query_MinimumGasPrices_0(ctx context.Context, marshaler runti // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_MinimumGasPrices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -68,7 +68,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_MinimumGasPrices_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -76,7 +76,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_MinimumGasPrices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -121,7 +121,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_MinimumGasPrices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -130,14 +130,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_MinimumGasPrices_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_MinimumGasPrices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -145,9 +145,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_MinimumGasPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"globalfee", "v1beta1", "minimum_gas_prices"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"globalfee", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_MinimumGasPrices_0 = runtime.ForwardResponseMessage + forward_Query_Params_0 = runtime.ForwardResponseMessage ) diff --git a/x/globalfee/types/tx.pb.go b/x/globalfee/types/tx.pb.go new file mode 100644 index 000000000..20dbfbb77 --- /dev/null +++ b/x/globalfee/types/tx.pb.go @@ -0,0 +1,604 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: globalfee/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +type MsgUpdateParams struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/globalfee parameters to update. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_453c6a09831c9f6b, []int{0} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_453c6a09831c9f6b, []int{1} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateParams)(nil), "globalfee.v1beta1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "globalfee.v1beta1.MsgUpdateParamsResponse") +} + +func init() { proto.RegisterFile("globalfee/v1beta1/tx.proto", fileDescriptor_453c6a09831c9f6b) } + +var fileDescriptor_453c6a09831c9f6b = []byte{ + // 328 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xcf, 0xc9, 0x4f, + 0x4a, 0xcc, 0x49, 0x4b, 0x4d, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, + 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0xcb, 0xe9, 0x41, 0xe5, 0xa4, 0xc4, 0x93, + 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, 0xad, + 0x94, 0x3c, 0xa6, 0x39, 0xe9, 0xa9, 0x79, 0xa9, 0xc5, 0x99, 0xc5, 0x50, 0x05, 0x22, 0xe9, 0xf9, + 0xe9, 0xf9, 0x60, 0xa6, 0x3e, 0x88, 0x05, 0x15, 0x95, 0x84, 0x98, 0x17, 0x0f, 0x91, 0x80, 0x70, + 0x20, 0x52, 0x4a, 0x93, 0x18, 0xb9, 0xf8, 0x7d, 0x8b, 0xd3, 0x43, 0x0b, 0x52, 0x12, 0x4b, 0x52, + 0x03, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0x85, 0xcc, 0xb8, 0x38, 0x13, 0x4b, 0x4b, 0x32, 0xf2, 0x8b, + 0x32, 0x4b, 0x2a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x9d, 0x24, 0x2e, 0x6d, 0xd1, 0x15, 0x81, + 0x6a, 0x74, 0x4c, 0x49, 0x29, 0x4a, 0x2d, 0x2e, 0x0e, 0x2e, 0x29, 0xca, 0xcc, 0x4b, 0x0f, 0x42, + 0x28, 0x15, 0x32, 0xe7, 0x62, 0x2b, 0x00, 0x9b, 0x20, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, + 0xa9, 0x87, 0xe1, 0x35, 0x3d, 0x88, 0x15, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x95, + 0x5b, 0xf1, 0x35, 0x3d, 0xdf, 0xa0, 0x85, 0x30, 0x48, 0x49, 0x92, 0x4b, 0x1c, 0xcd, 0x4d, 0x41, + 0xa9, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x46, 0xa9, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0x71, + 0x5c, 0x3c, 0x28, 0x4e, 0x56, 0xc2, 0x62, 0x15, 0x9a, 0x11, 0x52, 0x5a, 0x84, 0xd5, 0xc0, 0xac, + 0x71, 0xf2, 0x39, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, + 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xa3, 0xf4, 0xcc, + 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xa4, 0xc4, 0xbc, 0x14, 0x70, 0x30, 0x26, + 0xe7, 0xe7, 0xe8, 0x27, 0x67, 0x24, 0x66, 0xe6, 0xe9, 0x97, 0x19, 0xe9, 0x57, 0xe8, 0x23, 0x62, + 0xa9, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xac, 0xc8, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, + 0x1b, 0x18, 0xb3, 0x37, 0x07, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // UpdateParams defines a governance operation for updating the x/globalfee module + // parameters. + // + // Since: cosmos-sdk 0.47 + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/globalfee.v1beta1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // UpdateParams defines a governance operation for updating the x/globalfee module + // parameters. + // + // Since: cosmos-sdk 0.47 + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/globalfee.v1beta1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "globalfee.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "globalfee/v1beta1/tx.proto", +} + +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +)