From 451f224b345cd1442591879c523af76621162918 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 29 Sep 2023 12:52:41 +0530 Subject: [PATCH 1/6] removing the existing x/globalfee props --- app/app.go | 4 - docs/proto/proto-docs.md | 186 +++++------- .../stargaze/globalfee/v1/proposal.proto | 8 +- x/globalfee/client/cli/gov_tx.go | 204 ------------- x/globalfee/client/proposal_handler.go | 13 - x/globalfee/keeper/proposal_handler.go | 77 ----- x/globalfee/keeper/proposal_handler_test.go | 202 ------------- x/globalfee/types/proposal.go | 146 --------- x/globalfee/types/proposal.pb.go | 68 +++-- x/globalfee/types/proposal_test.go | 276 ------------------ x/globalfee/types/text_fixtures.go | 57 ---- 11 files changed, 106 insertions(+), 1135 deletions(-) delete mode 100644 x/globalfee/client/cli/gov_tx.go delete mode 100644 x/globalfee/client/proposal_handler.go delete mode 100644 x/globalfee/keeper/proposal_handler.go delete mode 100644 x/globalfee/keeper/proposal_handler_test.go delete mode 100644 x/globalfee/types/proposal.go delete mode 100644 x/globalfee/types/proposal_test.go delete mode 100644 x/globalfee/types/text_fixtures.go diff --git a/app/app.go b/app/app.go index c0b88690c..1cfd88d48 100644 --- a/app/app.go +++ b/app/app.go @@ -125,7 +125,6 @@ import ( cronmoduletypes "github.com/public-awesome/stargaze/v12/x/cron/types" globalfeemodule "github.com/public-awesome/stargaze/v12/x/globalfee" - globalfeeclient "github.com/public-awesome/stargaze/v12/x/globalfee/client" globalfeemodulekeeper "github.com/public-awesome/stargaze/v12/x/globalfee/keeper" globalfeemoduletypes "github.com/public-awesome/stargaze/v12/x/globalfee/types" @@ -195,8 +194,6 @@ func getGovProposalHandlers() []govclient.ProposalHandler { upgradeclient.LegacyCancelProposalHandler, ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler, cronclient.SetPrivilegeProposalHandler, cronclient.UnsetPrivilegeProposalHandler, - globalfeeclient.SetCodeAuthorizationProposalHandler, globalfeeclient.RemoveCodeAuthorizationProposalHandler, - globalfeeclient.SetContractAuthorizationProposalHandler, globalfeeclient.RemoveContractAuthorizationProposalHandler, // this line is used by starport scaffolding # stargate/app/govProposalHandler ) return govProposalHandlers @@ -662,7 +659,6 @@ func NewStargazeApp( app.GlobalFeeKeeper = globalfeemodulekeeper.NewKeeper(appCodec, keys[globalfeemoduletypes.StoreKey], app.GetSubspace(globalfeemoduletypes.ModuleName), app.WasmKeeper) globalfeeModule := globalfeemodule.NewAppModule(appCodec, app.GlobalFeeKeeper) - govRouter.AddRoute(globalfeemoduletypes.RouterKey, globalfeemodulekeeper.NewProposalHandler(app.GlobalFeeKeeper)) // The gov proposal types can be individually enabled if len(enabledProposals) != 0 { diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index f0e20217d..b6317b6d7 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,84 +4,63 @@ ## Table of Contents -- [publicawesome/stargaze/alloc/v1beta1/params.proto](#publicawesome/stargaze/alloc/v1beta1/params.proto) - - [DistributionProportions](#publicawesome.stargaze.alloc.v1beta1.DistributionProportions) - - [Params](#publicawesome.stargaze.alloc.v1beta1.Params) - - [WeightedAddress](#publicawesome.stargaze.alloc.v1beta1.WeightedAddress) +- [publicawesome/stargaze/mint/v1beta1/mint.proto](#publicawesome/stargaze/mint/v1beta1/mint.proto) + - [Minter](#publicawesome.stargaze.mint.v1beta1.Minter) + - [Params](#publicawesome.stargaze.mint.v1beta1.Params) -- [publicawesome/stargaze/alloc/v1beta1/genesis.proto](#publicawesome/stargaze/alloc/v1beta1/genesis.proto) - - [GenesisState](#publicawesome.stargaze.alloc.v1beta1.GenesisState) +- [publicawesome/stargaze/mint/v1beta1/genesis.proto](#publicawesome/stargaze/mint/v1beta1/genesis.proto) + - [GenesisState](#publicawesome.stargaze.mint.v1beta1.GenesisState) -- [publicawesome/stargaze/alloc/v1beta1/query.proto](#publicawesome/stargaze/alloc/v1beta1/query.proto) - - [QueryParamsRequest](#publicawesome.stargaze.alloc.v1beta1.QueryParamsRequest) - - [QueryParamsResponse](#publicawesome.stargaze.alloc.v1beta1.QueryParamsResponse) +- [publicawesome/stargaze/mint/v1beta1/query.proto](#publicawesome/stargaze/mint/v1beta1/query.proto) + - [QueryAnnualProvisionsRequest](#publicawesome.stargaze.mint.v1beta1.QueryAnnualProvisionsRequest) + - [QueryAnnualProvisionsResponse](#publicawesome.stargaze.mint.v1beta1.QueryAnnualProvisionsResponse) + - [QueryParamsRequest](#publicawesome.stargaze.mint.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#publicawesome.stargaze.mint.v1beta1.QueryParamsResponse) - - [Query](#publicawesome.stargaze.alloc.v1beta1.Query) + - [Query](#publicawesome.stargaze.mint.v1beta1.Query) -- [publicawesome/stargaze/alloc/v1beta1/tx.proto](#publicawesome/stargaze/alloc/v1beta1/tx.proto) - - [MsgCreateVestingAccount](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccount) - - [MsgCreateVestingAccountResponse](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccountResponse) - - [MsgFundFairburnPool](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPool) - - [MsgFundFairburnPoolResponse](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPoolResponse) - - - [Msg](#publicawesome.stargaze.alloc.v1beta1.Msg) +- [publicawesome/stargaze/mint/v1beta1/tx.proto](#publicawesome/stargaze/mint/v1beta1/tx.proto) + - [Msg](#publicawesome.stargaze.mint.v1beta1.Msg) - [Scalar Value Types](#scalar-value-types) - +

Top

-## publicawesome/stargaze/alloc/v1beta1/params.proto - +## publicawesome/stargaze/mint/v1beta1/mint.proto - -### DistributionProportions + +### Minter +Minter represents the minting state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `nft_incentives` | [string](#string) | | | -| `developer_rewards` | [string](#string) | | | -| `community_pool` | [string](#string) | | | +| `annual_provisions` | [string](#string) | | current annual expected provisions | - + ### Params - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `distribution_proportions` | [DistributionProportions](#publicawesome.stargaze.alloc.v1beta1.DistributionProportions) | | distribution_proportions defines the proportion of the minted denom | -| `weighted_developer_rewards_receivers` | [WeightedAddress](#publicawesome.stargaze.alloc.v1beta1.WeightedAddress) | repeated | addresses to receive developer rewards | -| `weighted_incentives_rewards_receivers` | [WeightedAddress](#publicawesome.stargaze.alloc.v1beta1.WeightedAddress) | repeated | addresses to receive incentive rewards | -| `supplement_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | SupplementAmount is the amount to be supplemented from the pool on top of newly minted coins. | - - - - - - - - -### WeightedAddress - +Params holds parameters for the mint module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `weight` | [string](#string) | | | +| `mint_denom` | [string](#string) | | type of coin to mint | +| `start_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | the time the chain starts | +| `initial_annual_provisions` | [string](#string) | | initial annual provisions | +| `reduction_factor` | [string](#string) | | factor to reduce inflation by each year | +| `blocks_per_year` | [uint64](#uint64) | | expected blocks per year | @@ -97,22 +76,23 @@ - +

Top

-## publicawesome/stargaze/alloc/v1beta1/genesis.proto +## publicawesome/stargaze/mint/v1beta1/genesis.proto - + ### GenesisState -GenesisState defines the alloc module's genesis state. +GenesisState defines the mint module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.alloc.v1beta1.Params) | | this line is used by starport scaffolding # genesis/proto/state | +| `minter` | [Minter](#publicawesome.stargaze.mint.v1beta1.Minter) | | minter is a space for holding current inflation information. | +| `params` | [Params](#publicawesome.stargaze.mint.v1beta1.Params) | | params defines all the paramaters of the module. | @@ -128,121 +108,89 @@ GenesisState defines the alloc module's genesis state. - +

Top

-## publicawesome/stargaze/alloc/v1beta1/query.proto +## publicawesome/stargaze/mint/v1beta1/query.proto - + -### QueryParamsRequest -QueryParamsRequest is the request type for the Query/Params RPC method. +### QueryAnnualProvisionsRequest +QueryAnnualProvisionsRequest is the request type for the +Query/AnnualProvisions RPC method. - + -### QueryParamsResponse -QueryParamsResponse is the response type for the Query/Params RPC method. +### QueryAnnualProvisionsResponse +QueryAnnualProvisionsResponse is the response type for the +Query/AnnualProvisions RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.alloc.v1beta1.Params) | | params defines the parameters of the module. | - - - +| `annual_provisions` | [bytes](#bytes) | | annual_provisions is the current minting annual provisions value. | - - - - - -### Query -Query defines the gRPC querier service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Params` | [QueryParamsRequest](#publicawesome.stargaze.alloc.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.alloc.v1beta1.QueryParamsResponse) | this line is used by starport scaffolding # 2 | GET|/stargaze/alloc/v1beta1/params| - - + +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. - -

Top

-## publicawesome/stargaze/alloc/v1beta1/tx.proto - + -### MsgCreateVestingAccount -MsgCreateVestingAccount defines a message that enables creating a vesting -account. +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `from_address` | [string](#string) | | | -| `to_address` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -| `start_time` | [int64](#int64) | | | -| `end_time` | [int64](#int64) | | | -| `delayed` | [bool](#bool) | | | - - - - - - - +| `params` | [Params](#publicawesome.stargaze.mint.v1beta1.Params) | | params defines the parameters of the module. | -### MsgCreateVestingAccountResponse -MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response -type. + + - - -### MsgFundFairburnPool -MsgFundFairburnPool allows an account to directly -fund the fee collector pool. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `sender` | [string](#string) | | | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | - + + +### Query +Query provides defines the gRPC querier service. +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Params` | [QueryParamsRequest](#publicawesome.stargaze.mint.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.mint.v1beta1.QueryParamsResponse) | Params returns the total set of minting parameters. | GET|/stargaze/mint/v1beta1/params| +| `AnnualProvisions` | [QueryAnnualProvisionsRequest](#publicawesome.stargaze.mint.v1beta1.QueryAnnualProvisionsRequest) | [QueryAnnualProvisionsResponse](#publicawesome.stargaze.mint.v1beta1.QueryAnnualProvisionsResponse) | AnnualProvisions current minting annual provisions value. | GET|/stargaze/mint/v1beta1/annual_provisions| - + -### MsgFundFairburnPoolResponse -MsgFundFairburnPoolResponse defines the Msg/MsgFundFairburnPool response -type. + +

Top

+## publicawesome/stargaze/mint/v1beta1/tx.proto @@ -252,15 +200,13 @@ type. - + ### Msg -Msg defines the alloc Msg service. +Msg defines the mint Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `CreateVestingAccount` | [MsgCreateVestingAccount](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccount) | [MsgCreateVestingAccountResponse](#publicawesome.stargaze.alloc.v1beta1.MsgCreateVestingAccountResponse) | CreateVestingAccount defines a method that enables creating a vesting account. | | -| `FundFairburnPool` | [MsgFundFairburnPool](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPool) | [MsgFundFairburnPoolResponse](#publicawesome.stargaze.alloc.v1beta1.MsgFundFairburnPoolResponse) | FundFairburnPool defines a method to allow an account to directly fund the fee collector module account. | | diff --git a/proto/publicawesome/stargaze/globalfee/v1/proposal.proto b/proto/publicawesome/stargaze/globalfee/v1/proposal.proto index 2e9f7f19e..2092690c3 100644 --- a/proto/publicawesome/stargaze/globalfee/v1/proposal.proto +++ b/proto/publicawesome/stargaze/globalfee/v1/proposal.proto @@ -8,7 +8,7 @@ import "publicawesome/stargaze/globalfee/v1/globalfee.proto"; option go_package = "github.com/public-awesome/stargaze/v12/x/globalfee/types"; message SetCodeAuthorizationProposal { - // option deprecated = true; + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; @@ -18,7 +18,7 @@ message SetCodeAuthorizationProposal { } message RemoveCodeAuthorizationProposal { - // option deprecated = true; + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; @@ -30,7 +30,7 @@ message RemoveCodeAuthorizationProposal { } message SetContractAuthorizationProposal { - // option deprecated = true; + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; @@ -40,7 +40,7 @@ message SetContractAuthorizationProposal { } message RemoveContractAuthorizationProposal { - // option deprecated = true; + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; diff --git a/x/globalfee/client/cli/gov_tx.go b/x/globalfee/client/cli/gov_tx.go deleted file mode 100644 index 612ea4e63..000000000 --- a/x/globalfee/client/cli/gov_tx.go +++ /dev/null @@ -1,204 +0,0 @@ -package cli - -import ( - "strconv" - "strings" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/gov/client/cli" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/public-awesome/stargaze/v12/x/globalfee/types" - "github.com/spf13/cobra" -) - -func CmdProposalSetCodeAuthorization() *cobra.Command { - cmd := &cobra.Command{ - Use: "set-code-authorization-proposal [code-id] [methods]", - Short: "Creates a proposal which creates or updates the gasless operation authorization for the given code id and for the provided methods", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - codeID, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return err - } - - methods := strings.Split(args[1], ",") - - prop := types.SetCodeAuthorizationProposal{ - Title: proposalTitle, - Description: proposalDescr, - CodeAuthorization: &types.CodeAuthorization{ - CodeID: codeID, - Methods: methods, - }, - } - - msg, err := govtypes.NewMsgSubmitProposal(&prop, deposit, clientCtx.GetFromAddress()) - if err != nil { - return err - } - if err = msg.ValidateBasic(); err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") - cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") //nolint:staticcheck - cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - - return cmd -} - -func CmdProposalRemoveCodeAuthorization() *cobra.Command { - cmd := &cobra.Command{ - Use: "remove-code-authorization-proposal [code-id]", - Short: "Creates a proposal which removes any previously set code authorizations", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - codeID, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return err - } - - content := types.RemoveCodeAuthorizationProposal{ - Title: proposalTitle, - Description: proposalDescr, - CodeID: codeID, - } - - msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress()) - if err != nil { - return err - } - if err = msg.ValidateBasic(); err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") - cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") //nolint:staticcheck - cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - - return cmd -} - -func CmdProposalSetContractAuthorization() *cobra.Command { - cmd := &cobra.Command{ - Use: "set-contract-authorization-proposal [contract-address] [methods]", - Short: "Creates a proposal which creates or updates the gasless operation authorization for the given contract address and for the provided methods", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - methods := strings.Split(args[1], ",") - - content := types.SetContractAuthorizationProposal{ - Title: proposalTitle, - Description: proposalDescr, - ContractAuthorization: &types.ContractAuthorization{ - ContractAddress: args[0], - Methods: methods, - }, - } - - msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress()) - if err != nil { - return err - } - if err = msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") - cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") //nolint:staticcheck - cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - - return cmd -} - -func CmdProposalRemoveContractAuthorization() *cobra.Command { - cmd := &cobra.Command{ - Use: "remove-contract-authorization-proposal [contract-address]", - Short: "Creates a proposal which removes any previously set contract authorizations", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - content := types.RemoveContractAuthorizationProposal{ - Title: proposalTitle, - Description: proposalDescr, - ContractAddress: args[0], - } - - msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress()) - if err != nil { - return err - } - if err = msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") - cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") //nolint:staticcheck - cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - - return cmd -} - -func getProposalInfo(cmd *cobra.Command) (client.Context, string, string, sdk.Coins, error) { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return client.Context{}, "", "", nil, err - } - - proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle) - if err != nil { - return clientCtx, proposalTitle, "", nil, err - } - - proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription) //nolint:staticcheck - if err != nil { - return client.Context{}, proposalTitle, proposalDescr, nil, err - } - - depositArg, err := cmd.Flags().GetString(cli.FlagDeposit) - if err != nil { - return client.Context{}, proposalTitle, proposalDescr, nil, err - } - - deposit, err := sdk.ParseCoinsNormalized(depositArg) - if err != nil { - return client.Context{}, proposalTitle, proposalDescr, deposit, err - } - - return clientCtx, proposalTitle, proposalDescr, deposit, nil -} diff --git a/x/globalfee/client/proposal_handler.go b/x/globalfee/client/proposal_handler.go deleted file mode 100644 index a510a479d..000000000 --- a/x/globalfee/client/proposal_handler.go +++ /dev/null @@ -1,13 +0,0 @@ -package client - -import ( - govclient "github.com/cosmos/cosmos-sdk/x/gov/client" - "github.com/public-awesome/stargaze/v12/x/globalfee/client/cli" -) - -var ( - SetCodeAuthorizationProposalHandler = govclient.NewProposalHandler(cli.CmdProposalSetCodeAuthorization) - RemoveCodeAuthorizationProposalHandler = govclient.NewProposalHandler(cli.CmdProposalRemoveCodeAuthorization) - SetContractAuthorizationProposalHandler = govclient.NewProposalHandler(cli.CmdProposalSetContractAuthorization) - RemoveContractAuthorizationProposalHandler = govclient.NewProposalHandler(cli.CmdProposalRemoveContractAuthorization) -) diff --git a/x/globalfee/keeper/proposal_handler.go b/x/globalfee/keeper/proposal_handler.go deleted file mode 100644 index ec6eb37b4..000000000 --- a/x/globalfee/keeper/proposal_handler.go +++ /dev/null @@ -1,77 +0,0 @@ -package keeper - -import ( - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/public-awesome/stargaze/v12/x/globalfee/types" -) - -type govKeeper interface { - SetCodeAuthorization(ctx sdk.Context, ca types.CodeAuthorization) error - DeleteCodeAuthorization(ctx sdk.Context, codeID uint64) - SetContractAuthorization(ctx sdk.Context, ca types.ContractAuthorization) error - DeleteContractAuthorization(ctx sdk.Context, contractAddr sdk.AccAddress) -} - -// NewProposalHandler creates a new governance Handler for wasm proposals -func NewProposalHandler(k Keeper) govtypes.Handler { - return NewProposalHandlerX(k) -} - -func NewProposalHandlerX(k govKeeper) govtypes.Handler { - return func(ctx sdk.Context, content govtypes.Content) error { - switch c := content.(type) { - case *types.SetCodeAuthorizationProposal: - return handleSetCodeAuthorizationProposal(ctx, k, *c) - case *types.RemoveCodeAuthorizationProposal: - return handleDeleteCodeAuthorizationProposal(ctx, k, *c) - case *types.SetContractAuthorizationProposal: - return handleSetContractAuthorizationProposal(ctx, k, *c) - case *types.RemoveContractAuthorizationProposal: - return handleDeleteContractAuthorizationProposal(ctx, k, *c) - default: - return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized globalfee srcProposal content type: %T", c) - } - } -} - -func handleSetCodeAuthorizationProposal(ctx sdk.Context, k govKeeper, p types.SetCodeAuthorizationProposal) error { - if err := p.ValidateBasic(); err != nil { - return err - } - - return k.SetCodeAuthorization(ctx, *p.GetCodeAuthorization()) -} - -func handleDeleteCodeAuthorizationProposal(ctx sdk.Context, k govKeeper, p types.RemoveCodeAuthorizationProposal) error { - if err := p.ValidateBasic(); err != nil { - return err - } - - k.DeleteCodeAuthorization(ctx, p.GetCodeID()) - return nil -} - -func handleSetContractAuthorizationProposal(ctx sdk.Context, k govKeeper, p types.SetContractAuthorizationProposal) error { - if err := p.ValidateBasic(); err != nil { - return err - } - - return k.SetContractAuthorization(ctx, *p.GetContractAuthorization()) -} - -func handleDeleteContractAuthorizationProposal(ctx sdk.Context, k govKeeper, p types.RemoveContractAuthorizationProposal) error { - if err := p.ValidateBasic(); err != nil { - return err - } - - contractAddr, err := sdk.AccAddressFromBech32(p.GetContractAddress()) - if err != nil { - return errorsmod.Wrap(err, "invalid contract address") - } - - k.DeleteContractAuthorization(ctx, contractAddr) - return nil -} diff --git a/x/globalfee/keeper/proposal_handler_test.go b/x/globalfee/keeper/proposal_handler_test.go deleted file mode 100644 index 52afa5a46..000000000 --- a/x/globalfee/keeper/proposal_handler_test.go +++ /dev/null @@ -1,202 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - legacygovtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/public-awesome/stargaze/v12/x/globalfee/keeper" - "github.com/public-awesome/stargaze/v12/x/globalfee/types" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestGovHandler(t *testing.T) { - var ( - capturedContractAddrs []string - capturedCodeIds []uint64 - ) - notHandler := func(ctx sdk.Context, content legacygovtypes.Content) error { - return sdkerrors.ErrUnknownRequest - } - - specs := map[string]struct { - wasmHandler legacygovtypes.Handler - setupGovKeeper func(*MockGovKeeper) - srcProposal legacygovtypes.Content - expErr *sdkerrors.Error - expCapturedAddrs []string - expCapturedCodeIds []uint64 - expCapturedGovContent []legacygovtypes.Content - }{ - "set code auth proposal": { - wasmHandler: notHandler, - setupGovKeeper: func(m *MockGovKeeper) { - m.SetCodeAuthorizationFn = func(ctx sdk.Context, ca types.CodeAuthorization) error { - capturedCodeIds = append(capturedCodeIds, ca.GetCodeID()) - return nil - } - }, - srcProposal: types.SetCodeAuthorizationProposalFixture(func(proposal *types.SetCodeAuthorizationProposal) { - proposal.CodeAuthorization = &types.CodeAuthorization{ - CodeID: 1, - Methods: []string{"*"}, - } - }), - expCapturedCodeIds: []uint64{1}, - }, - "invalid set code auth proposal rejected": { - wasmHandler: notHandler, - srcProposal: &types.SetCodeAuthorizationProposal{}, - expErr: govtypes.ErrInvalidProposalContent, - }, - "remove code auth proposal": { - wasmHandler: notHandler, - setupGovKeeper: func(m *MockGovKeeper) { - m.DeleteCodeAuthorizationFn = func(ctx sdk.Context, codeId uint64) { - // removing the codeIds - for i, v := range capturedCodeIds { - if v == codeId { - capturedCodeIds = append(capturedCodeIds[:i], capturedCodeIds[i+1:]...) - return - } - } - } - }, - srcProposal: types.RemoveCodeAuthorizationProposalFixture(func(proposal *types.RemoveCodeAuthorizationProposal) { - proposal.CodeID = 1 - }), - expCapturedCodeIds: nil, - }, - "invalid remove code auth proposal rejected": { - wasmHandler: notHandler, - srcProposal: &types.RemoveCodeAuthorizationProposal{}, - expErr: govtypes.ErrInvalidProposalContent, - }, - "set contract auth proposal": { - wasmHandler: notHandler, - setupGovKeeper: func(m *MockGovKeeper) { - m.SetContractAuthorizationFn = func(ctx sdk.Context, ca types.ContractAuthorization) error { - capturedContractAddrs = append(capturedContractAddrs, ca.GetContractAddress()) - return nil - } - }, - srcProposal: types.SetContractAuthorizationProposalFixture(func(proposal *types.SetContractAuthorizationProposal) { - proposal.ContractAuthorization = &types.ContractAuthorization{ - ContractAddress: "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du", - Methods: []string{"*"}, - } - }), - expCapturedAddrs: []string{"cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du"}, - }, - "invalid set contract auth proposal rejected": { - wasmHandler: notHandler, - srcProposal: &types.SetContractAuthorizationProposal{}, - expErr: govtypes.ErrInvalidProposalContent, - }, - "remove contract auth proposal": { - wasmHandler: notHandler, - setupGovKeeper: func(m *MockGovKeeper) { - m.DeleteContractAuthorizationFn = func(ctx sdk.Context, contractAddr sdk.AccAddress) { - // removing the contractAddresses - for i, v := range capturedContractAddrs { - if v == contractAddr.String() { - capturedContractAddrs = append(capturedContractAddrs[:i], capturedContractAddrs[i+1:]...) - return - } - } - } - }, - srcProposal: types.RemoveContractAuthorizationProposalFixture(func(proposal *types.RemoveContractAuthorizationProposal) { - proposal.ContractAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" - }), - expCapturedAddrs: nil, - }, - "invalid remove contract auth proposal rejected": { - wasmHandler: notHandler, - srcProposal: &types.RemoveContractAuthorizationProposal{}, - expErr: govtypes.ErrInvalidProposalContent, - }, - "nil content": { - wasmHandler: notHandler, - expErr: sdkerrors.ErrUnknownRequest, - }, - } - var ctx sdk.Context - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - capturedContractAddrs = nil - var mock MockGovKeeper - if spec.setupGovKeeper != nil { - spec.setupGovKeeper(&mock) - } - // when - router := &CapturingGovRouter{} - h := keeper.NewProposalHandlerX(mock) - gotErr := h(ctx, spec.srcProposal) - // then - require.True(t, spec.expErr.Is(gotErr), "exp %v but got #+v", spec.expErr, gotErr) - if spec.expCapturedCodeIds != nil { - assert.Equal(t, spec.expCapturedCodeIds, capturedCodeIds) - } else { - assert.Equal(t, spec.expCapturedAddrs, capturedContractAddrs) - } - assert.Equal(t, spec.expCapturedGovContent, router.captured) - }) - } -} - -type MockGovKeeper struct { - SetCodeAuthorizationFn func(ctx sdk.Context, ca types.CodeAuthorization) error - DeleteCodeAuthorizationFn func(ctx sdk.Context, codeId uint64) - SetContractAuthorizationFn func(ctx sdk.Context, ca types.ContractAuthorization) error - DeleteContractAuthorizationFn func(ctx sdk.Context, contractAddr sdk.AccAddress) -} - -func (m MockGovKeeper) SetCodeAuthorization(ctx sdk.Context, ca types.CodeAuthorization) error { - if m.SetCodeAuthorizationFn == nil { - panic("not expected to be called") - } - return m.SetCodeAuthorizationFn(ctx, ca) -} - -func (m MockGovKeeper) DeleteCodeAuthorization(ctx sdk.Context, codeId uint64) { - if m.DeleteCodeAuthorizationFn == nil { - panic("not expected to be called") - } - m.DeleteCodeAuthorizationFn(ctx, codeId) - return -} - -func (m MockGovKeeper) SetContractAuthorization(ctx sdk.Context, ca types.ContractAuthorization) error { - if m.SetContractAuthorizationFn == nil { - panic("not expected to be called") - } - return m.SetContractAuthorizationFn(ctx, ca) -} - -func (m MockGovKeeper) DeleteContractAuthorization(ctx sdk.Context, contractAddr sdk.AccAddress) { - if m.DeleteContractAuthorizationFn == nil { - panic("not expected to be called") - } - m.DeleteContractAuthorizationFn(ctx, contractAddr) - return -} - -type CapturingGovRouter struct { - legacygovtypes.Router - captured []legacygovtypes.Content -} - -func (m CapturingGovRouter) HasRoute(r string) bool { - return true -} - -func (m *CapturingGovRouter) GetRoute(path string) (h legacygovtypes.Handler) { - return func(ctx sdk.Context, content legacygovtypes.Content) error { - m.captured = append(m.captured, content) - return nil - } -} diff --git a/x/globalfee/types/proposal.go b/x/globalfee/types/proposal.go deleted file mode 100644 index 2fc12b00d..000000000 --- a/x/globalfee/types/proposal.go +++ /dev/null @@ -1,146 +0,0 @@ -package types - -import ( - "strings" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - legacygovtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" -) - -type ProposalType string - -const ( - ProposalTypeSetCodeAuthorization ProposalType = "ProposalTypeSetCodeAuthorization" - ProposalTypeRemoveCodeAuthorization ProposalType = "ProposalTypeRemoveCodeAuthorization" - ProposalTypeSetContractAuthorization ProposalType = "ProposalTypeSetContractAuthorization" - ProposalTypeRemoveContractAuthorization ProposalType = "ProposalTypeRemoveContractAuthorization" -) - -// EnableAllProposals contains all twasm gov types as keys. -var EnableAllProposals = []ProposalType{ - ProposalTypeSetCodeAuthorization, - ProposalTypeRemoveCodeAuthorization, - ProposalTypeSetContractAuthorization, - ProposalTypeRemoveContractAuthorization, -} - -func init() { // register new content types with the sdk - legacygovtypes.RegisterProposalType(string(ProposalTypeSetCodeAuthorization)) - legacygovtypes.RegisterProposalType(string(ProposalTypeRemoveCodeAuthorization)) - legacygovtypes.RegisterProposalType(string(ProposalTypeSetContractAuthorization)) - legacygovtypes.RegisterProposalType(string(ProposalTypeRemoveContractAuthorization)) - - // legacygovtypes.RegisterProposalTypeCodec(&SetCodeAuthorizationProposal{}, "globalfee/SetCodeAuthorizationProposal") - // legacygovtypes.RegisterProposalTypeCodec(&RemoveCodeAuthorizationProposal{}, "globalfee/RemoveCodeAuthorizationProposal") - // legacygovtypes.RegisterProposalTypeCodec(&SetContractAuthorizationProposal{}, "globalfee/SetContractAuthorizationProposal") - // legacygovtypes.RegisterProposalTypeCodec(&RemoveContractAuthorizationProposal{}, "globalfee/RemoveContractAuthorizationProposal") -} - -// ProposalRoute returns the routing key of a parameter change proposal. -func (p SetCodeAuthorizationProposal) ProposalRoute() string { return RouterKey } - -// ProposalType returns the type -func (p SetCodeAuthorizationProposal) ProposalType() string { - return string(ProposalTypeSetCodeAuthorization) -} - -// ValidateBasic validates the proposal -func (p SetCodeAuthorizationProposal) ValidateBasic() error { - if err := validateProposalCommons(p.Title, p.Description); err != nil { - return err - } - return p.CodeAuthorization.Validate() -} - -// MarshalYAML pretty prints the wasm byte code -func (p SetCodeAuthorizationProposal) MarshalYAML() (interface{}, error) { - return p, nil -} - -// ProposalRoute returns the routing key of a parameter change proposal. -func (p RemoveCodeAuthorizationProposal) ProposalRoute() string { return RouterKey } - -// ProposalType returns the type -func (p RemoveCodeAuthorizationProposal) ProposalType() string { - return string(ProposalTypeRemoveCodeAuthorization) -} - -// ValidateBasic validates the proposal -func (p RemoveCodeAuthorizationProposal) ValidateBasic() error { - return validateProposalCommons(p.Title, p.Description) -} - -// MarshalYAML pretty prints the wasm byte code -func (p RemoveCodeAuthorizationProposal) MarshalYAML() (interface{}, error) { - return p, nil -} - -// ProposalRoute returns the routing key of a parameter change proposal. -func (p SetContractAuthorizationProposal) ProposalRoute() string { return RouterKey } - -// ProposalType returns the type -func (p SetContractAuthorizationProposal) ProposalType() string { - return string(ProposalTypeSetContractAuthorization) -} - -// ValidateBasic validates the proposal -func (p SetContractAuthorizationProposal) ValidateBasic() error { - if err := validateProposalCommons(p.Title, p.Description); err != nil { - return err - } - return p.ContractAuthorization.Validate() -} - -// MarshalYAML pretty prints the wasm byte code -func (p SetContractAuthorizationProposal) MarshalYAML() (interface{}, error) { - return p, nil -} - -// ProposalRoute returns the routing key of a parameter change proposal. -func (p RemoveContractAuthorizationProposal) ProposalRoute() string { return RouterKey } - -// ProposalType returns the type -func (p RemoveContractAuthorizationProposal) ProposalType() string { - return string(ProposalTypeRemoveContractAuthorization) -} - -// ValidateBasic validates the proposal -func (p RemoveContractAuthorizationProposal) ValidateBasic() error { - if err := validateProposalCommons(p.Title, p.Description); err != nil { - return err - } - if _, err := sdk.AccAddressFromBech32(p.ContractAddress); err != nil { - return errorsmod.Wrap(err, "contract") - } - return nil -} - -// MarshalYAML pretty prints the wasm byte code -func (p RemoveContractAuthorizationProposal) MarshalYAML() (interface{}, error) { - return p, nil -} - -// common validations -func validateProposalCommons(title, description string) error { - if strings.TrimSpace(title) != title { - return errorsmod.Wrap(govtypes.ErrInvalidProposalContent, "proposal title must not start/end with white spaces") - } - if len(title) == 0 { - return errorsmod.Wrap(govtypes.ErrInvalidProposalContent, "proposal title cannot be blank") - } - if len(title) > legacygovtypes.MaxTitleLength { - return errorsmod.Wrapf(govtypes.ErrInvalidProposalContent, "proposal title is longer than max length of %d", legacygovtypes.MaxTitleLength) - } - if strings.TrimSpace(description) != description { - return errorsmod.Wrap(govtypes.ErrInvalidProposalContent, "proposal description must not start/end with white spaces") - } - if len(description) == 0 { - return errorsmod.Wrap(govtypes.ErrInvalidProposalContent, "proposal description cannot be blank") - } - if len(description) > legacygovtypes.MaxDescriptionLength { - return errorsmod.Wrapf(govtypes.ErrInvalidProposalContent, "proposal description is longer than max length of %d", legacygovtypes.MaxDescriptionLength) - } - return nil -} diff --git a/x/globalfee/types/proposal.pb.go b/x/globalfee/types/proposal.pb.go index 0c978593b..dfb71ab89 100644 --- a/x/globalfee/types/proposal.pb.go +++ b/x/globalfee/types/proposal.pb.go @@ -24,6 +24,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// Deprecated: Do not use. type SetCodeAuthorizationProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` @@ -84,6 +85,7 @@ func (m *SetCodeAuthorizationProposal) GetCodeAuthorization() *CodeAuthorization return nil } +// Deprecated: Do not use. type RemoveCodeAuthorizationProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` @@ -144,6 +146,7 @@ func (m *RemoveCodeAuthorizationProposal) GetCodeID() uint64 { return 0 } +// Deprecated: Do not use. type SetContractAuthorizationProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` @@ -204,6 +207,7 @@ func (m *SetContractAuthorizationProposal) GetContractAuthorization() *ContractA return nil } +// Deprecated: Do not use. type RemoveContractAuthorizationProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` @@ -276,38 +280,38 @@ func init() { } var fileDescriptor_b49a370918ffdc3b = []byte{ - // 494 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0x41, 0x6e, 0xd3, 0x40, - 0x14, 0xed, 0x04, 0x08, 0xea, 0x14, 0x41, 0xb1, 0xa0, 0xa4, 0xa1, 0xb5, 0xc3, 0x54, 0x42, 0xdd, - 0xd4, 0x56, 0x52, 0x81, 0xaa, 0xec, 0x30, 0x08, 0xa9, 0x3b, 0x64, 0x76, 0x6c, 0xaa, 0xf1, 0x78, - 0x70, 0x2d, 0xd9, 0xf9, 0x96, 0x67, 0x62, 0x68, 0xd7, 0x1c, 0x80, 0x05, 0x77, 0xe0, 0x02, 0xec, - 0xb8, 0x00, 0x62, 0xd5, 0x25, 0x62, 0x61, 0xa1, 0xe4, 0x00, 0x48, 0x3e, 0x01, 0xf2, 0x4c, 0xd2, - 0x9a, 0x26, 0x52, 0xb2, 0xcb, 0x6e, 0x3c, 0xff, 0xbd, 0xf9, 0xef, 0x3d, 0x7f, 0x7d, 0xdc, 0x4b, - 0x87, 0x7e, 0x1c, 0x31, 0xfa, 0x81, 0x0b, 0x48, 0xb8, 0x23, 0x24, 0xcd, 0x42, 0x7a, 0xce, 0x9d, - 0x30, 0x06, 0x9f, 0xc6, 0xef, 0x39, 0x77, 0xf2, 0xae, 0x93, 0x66, 0x90, 0x82, 0xa0, 0xb1, 0x9d, - 0x66, 0x20, 0xc1, 0xd8, 0xfb, 0x8f, 0x63, 0x4f, 0x39, 0xf6, 0x25, 0xc7, 0xce, 0xbb, 0xed, 0x07, - 0x21, 0x84, 0xa0, 0xf0, 0x4e, 0x75, 0xd2, 0xd4, 0xf6, 0x36, 0x03, 0x91, 0x80, 0x38, 0xd1, 0x05, - 0xfd, 0x31, 0x29, 0x1d, 0x2e, 0xa3, 0xe4, 0xaa, 0x85, 0x22, 0x91, 0xaf, 0x0d, 0xbc, 0xf3, 0x96, - 0xcb, 0x97, 0x10, 0xf0, 0x17, 0x43, 0x79, 0x0a, 0x59, 0x74, 0x4e, 0x65, 0x04, 0x83, 0x37, 0x13, - 0xc5, 0xc6, 0x53, 0x7c, 0x4b, 0x46, 0x32, 0xe6, 0x2d, 0xd4, 0x41, 0xfb, 0xeb, 0xee, 0x66, 0x59, - 0x58, 0x77,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0x8e, 0xc6, 0x6a, 0x03, 0x7c, 0x8d, 0x37, 0xaf, - 0xbc, 0x05, 0x41, 0xc6, 0x85, 0x50, 0xc9, 0xad, 0xbb, 0x8f, 0xcb, 0xc2, 0x7a, 0x74, 0xdd, 0xbd, - 0x46, 0x10, 0xef, 0xde, 0xa5, 0x6f, 0x7d, 0xb3, 0xc8, 0xb1, 0xeb, 0xfd, 0x18, 0x99, 0xe8, 0x62, - 0x64, 0xa2, 0x3f, 0x23, 0x13, 0x7d, 0x1e, 0x9b, 0x6b, 0x17, 0x63, 0x73, 0xed, 0xd7, 0xd8, 0x5c, - 0x7b, 0x77, 0x14, 0x46, 0xf2, 0x74, 0xe8, 0xdb, 0x0c, 0x12, 0x47, 0xff, 0xab, 0x83, 0x99, 0x8d, - 0x94, 0x77, 0x7b, 0xce, 0xc7, 0xda, 0x5e, 0x92, 0x67, 0x29, 0x17, 0x7e, 0x53, 0x6d, 0xa4, 0xc3, - 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x28, 0xf9, 0xf0, 0x52, 0x05, 0x00, 0x00, + // 493 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xce, 0x05, 0x08, 0xea, 0x15, 0x41, 0xb1, 0xa0, 0xa4, 0xa1, 0xb5, 0xc3, 0x55, 0x42, 0x5d, + 0x6a, 0x2b, 0xa9, 0x40, 0x55, 0x36, 0x0c, 0x42, 0xea, 0x86, 0xcc, 0xc6, 0x52, 0x5d, 0xce, 0x87, + 0x6b, 0xc9, 0xce, 0xb3, 0x7c, 0x17, 0x43, 0x3b, 0xf3, 0x03, 0x18, 0xf8, 0x13, 0xec, 0xac, 0xec, + 0x88, 0xa9, 0x23, 0x03, 0xb2, 0x50, 0xf2, 0x0b, 0xf0, 0x2f, 0x40, 0xbe, 0x4b, 0x5a, 0xd3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e3, 0x7c, 0x6a, 0x36, 0x7e, 0x4d, 0xcd, 0xc6, + 0xbb, 0xc3, 0x20, 0x94, 0x27, 0xe3, 0xa1, 0xcd, 0x20, 0x76, 0xf4, 0xff, 0xda, 0x5f, 0xd8, 0x4c, + 0x59, 0xaf, 0xef, 0x7c, 0xac, 0xec, 0x27, 0x79, 0x9a, 0x70, 0x31, 0x6c, 0xa9, 0xcd, 0x74, 0xf0, + 0x2f, 0x00, 0x00, 0xff, 0xff, 0x31, 0x03, 0x7f, 0xb4, 0x5a, 0x05, 0x00, 0x00, } func (m *SetCodeAuthorizationProposal) Marshal() (dAtA []byte, err error) { diff --git a/x/globalfee/types/proposal_test.go b/x/globalfee/types/proposal_test.go deleted file mode 100644 index b3124bf9c..000000000 --- a/x/globalfee/types/proposal_test.go +++ /dev/null @@ -1,276 +0,0 @@ -package types - -import ( - "strings" - "testing" - - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "gopkg.in/yaml.v2" -) - -func TestValidateSetCodeAuthorizationProposal(t *testing.T) { - specs := map[string]struct { - src *SetCodeAuthorizationProposal - expErr bool - }{ - "all good": { - src: SetCodeAuthorizationProposalFixture(), - }, - "base data missing": { - src: SetCodeAuthorizationProposalFixture(func(p *SetCodeAuthorizationProposal) { - p.Title = "" - }), - expErr: true, - }, - "code auth missing": { - src: SetCodeAuthorizationProposalFixture(func(p *SetCodeAuthorizationProposal) { - p.CodeAuthorization = &CodeAuthorization{} - }), - expErr: true, - }, - } - for msg, spec := range specs { - t.Run(msg, func(t *testing.T) { - err := spec.src.ValidateBasic() - if spec.expErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} - -func TestValidateRemoveCodeAuthorizationProposal(t *testing.T) { - specs := map[string]struct { - src *RemoveCodeAuthorizationProposal - expErr bool - }{ - "all good": { - src: RemoveCodeAuthorizationProposalFixture(), - }, - "base data missing": { - src: RemoveCodeAuthorizationProposalFixture(func(p *RemoveCodeAuthorizationProposal) { - p.Title = "" - }), - expErr: true, - }, - } - for msg, spec := range specs { - t.Run(msg, func(t *testing.T) { - err := spec.src.ValidateBasic() - if spec.expErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} - -func TestValidateSetContractAuthorizationProposal(t *testing.T) { - specs := map[string]struct { - src *SetContractAuthorizationProposal - expErr bool - }{ - "all good": { - src: SetContractAuthorizationProposalFixture(), - }, - "base data missing": { - src: SetContractAuthorizationProposalFixture(func(p *SetContractAuthorizationProposal) { - p.Title = "" - }), - expErr: true, - }, - "contract auth missing": { - src: SetContractAuthorizationProposalFixture(func(p *SetContractAuthorizationProposal) { - p.ContractAuthorization = &ContractAuthorization{} - }), - expErr: true, - }, - "contarct addr invalid": { - src: SetContractAuthorizationProposalFixture(func(p *SetContractAuthorizationProposal) { - p.ContractAuthorization = &ContractAuthorization{ - ContractAddress: "👻", - } - }), - expErr: true, - }, - } - for msg, spec := range specs { - t.Run(msg, func(t *testing.T) { - err := spec.src.ValidateBasic() - if spec.expErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} - -func TestValidateRemoveContractAuthorizationProposal(t *testing.T) { - specs := map[string]struct { - src *RemoveContractAuthorizationProposal - expErr bool - }{ - "all good": { - src: RemoveContractAuthorizationProposalFixture(), - }, - "base data missing": { - src: RemoveContractAuthorizationProposalFixture(func(p *RemoveContractAuthorizationProposal) { - p.Title = "" - }), - expErr: true, - }, - "contarct addr invalid": { - src: RemoveContractAuthorizationProposalFixture(func(p *RemoveContractAuthorizationProposal) { - p.ContractAddress = "👻" - }), - expErr: true, - }, - } - for msg, spec := range specs { - t.Run(msg, func(t *testing.T) { - err := spec.src.ValidateBasic() - if spec.expErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} - -func TestProposalYaml(t *testing.T) { - specs := map[string]struct { - src govtypes.Content - exp string - }{ - "set code authorization proposal": { - src: SetCodeAuthorizationProposalFixture(), - exp: `title: Foo -description: Bar -code_authorization: - code_id: 1 - methods: - - mint - - unlist -`, - }, - "remove code authorization proposal": { - src: RemoveCodeAuthorizationProposalFixture(), - exp: `title: Foo -description: Bar -code_id: 1 -`, - }, - "set contract authorization proposal": { - src: SetContractAuthorizationProposalFixture(), - exp: `title: Foo -description: Bar -contract_authorization: - contract_address: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du - methods: - - mint - - unlist -`, - }, - "remove contract authorization proposal": { - src: RemoveContractAuthorizationProposalFixture(), - exp: `title: Foo -description: Bar -contract_address: cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du -`, - }, - } - for msg, spec := range specs { - t.Run(msg, func(t *testing.T) { - v, err := yaml.Marshal(&spec.src) - require.NoError(t, err) - assert.Equal(t, spec.exp, string(v)) - }) - } -} - -func TestValidateProposalCommons(t *testing.T) { - type commonProposal struct { - Title, Description string - } - - specs := map[string]struct { - src commonProposal - expErr bool - }{ - "all good": {src: commonProposal{ - Title: "Foo", - Description: "Bar", - }}, - "prevent empty title": { - src: commonProposal{ - Description: "Bar", - }, - expErr: true, - }, - "prevent white space only title": { - src: commonProposal{ - Title: " ", - Description: "Bar", - }, - expErr: true, - }, - "prevent leading white spaces in title": { - src: commonProposal{ - Title: " Foo", - Description: "Bar", - }, - expErr: true, - }, - "prevent title exceeds max length ": { - src: commonProposal{ - Title: strings.Repeat("a", govtypes.MaxTitleLength+1), - Description: "Bar", - }, - expErr: true, - }, - "prevent empty description": { - src: commonProposal{ - Title: "Foo", - }, - expErr: true, - }, - "prevent leading white spaces in description": { - src: commonProposal{ - Title: "Foo", - Description: " Bar", - }, - expErr: true, - }, - "prevent white space only description": { - src: commonProposal{ - Title: "Foo", - Description: " ", - }, - expErr: true, - }, - "prevent descr exceeds max length ": { - src: commonProposal{ - Title: "Foo", - Description: strings.Repeat("a", govtypes.MaxDescriptionLength+1), - }, - expErr: true, - }, - } - for msg, spec := range specs { - t.Run(msg, func(t *testing.T) { - err := validateProposalCommons(spec.src.Title, spec.src.Description) - if spec.expErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} diff --git a/x/globalfee/types/text_fixtures.go b/x/globalfee/types/text_fixtures.go deleted file mode 100644 index 0e0915af7..000000000 --- a/x/globalfee/types/text_fixtures.go +++ /dev/null @@ -1,57 +0,0 @@ -package types - -func SetCodeAuthorizationProposalFixture(mutators ...func(*SetCodeAuthorizationProposal)) *SetCodeAuthorizationProposal { - p := &SetCodeAuthorizationProposal{ - Title: "Foo", - Description: "Bar", - CodeAuthorization: &CodeAuthorization{ - CodeID: 1, - Methods: []string{"mint", "unlist"}, - }, - } - for _, m := range mutators { - m(p) - } - return p -} - -func RemoveCodeAuthorizationProposalFixture(mutators ...func(*RemoveCodeAuthorizationProposal)) *RemoveCodeAuthorizationProposal { - p := &RemoveCodeAuthorizationProposal{ - Title: "Foo", - Description: "Bar", - CodeID: 1, - } - for _, m := range mutators { - m(p) - } - return p -} - -func SetContractAuthorizationProposalFixture(mutators ...func(*SetContractAuthorizationProposal)) *SetContractAuthorizationProposal { - const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" - p := &SetContractAuthorizationProposal{ - Title: "Foo", - Description: "Bar", - ContractAuthorization: &ContractAuthorization{ - ContractAddress: anyAddress, - Methods: []string{"mint", "unlist"}, - }, - } - for _, m := range mutators { - m(p) - } - return p -} - -func RemoveContractAuthorizationProposalFixture(mutators ...func(*RemoveContractAuthorizationProposal)) *RemoveContractAuthorizationProposal { - const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du" - p := &RemoveContractAuthorizationProposal{ - Title: "Foo", - Description: "Bar", - ContractAddress: anyAddress, - } - for _, m := range mutators { - m(p) - } - return p -} From 0db833273b723b6a1ab1dd76dae40f22caf8a081 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 29 Sep 2023 15:26:55 +0530 Subject: [PATCH 2/6] adding update globalfee params msg --- docs/proto/proto-docs.md | 429 ++++++++++++++--- .../stargaze/globalfee/v1/tx.proto | 15 + x/globalfee/keeper/keeper.go | 9 +- x/globalfee/keeper/msg_server.go | 31 ++ x/globalfee/types/tx.pb.go | 450 ++++++++++++++++-- 5 files changed, 844 insertions(+), 90 deletions(-) diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index b6317b6d7..15ffa2c82 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,63 +4,99 @@ ## Table of Contents -- [publicawesome/stargaze/mint/v1beta1/mint.proto](#publicawesome/stargaze/mint/v1beta1/mint.proto) - - [Minter](#publicawesome.stargaze.mint.v1beta1.Minter) - - [Params](#publicawesome.stargaze.mint.v1beta1.Params) +- [publicawesome/stargaze/globalfee/v1/globalfee.proto](#publicawesome/stargaze/globalfee/v1/globalfee.proto) + - [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) + - [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) + - [Params](#publicawesome.stargaze.globalfee.v1.Params) -- [publicawesome/stargaze/mint/v1beta1/genesis.proto](#publicawesome/stargaze/mint/v1beta1/genesis.proto) - - [GenesisState](#publicawesome.stargaze.mint.v1beta1.GenesisState) +- [publicawesome/stargaze/globalfee/v1/genesis.proto](#publicawesome/stargaze/globalfee/v1/genesis.proto) + - [GenesisState](#publicawesome.stargaze.globalfee.v1.GenesisState) -- [publicawesome/stargaze/mint/v1beta1/query.proto](#publicawesome/stargaze/mint/v1beta1/query.proto) - - [QueryAnnualProvisionsRequest](#publicawesome.stargaze.mint.v1beta1.QueryAnnualProvisionsRequest) - - [QueryAnnualProvisionsResponse](#publicawesome.stargaze.mint.v1beta1.QueryAnnualProvisionsResponse) - - [QueryParamsRequest](#publicawesome.stargaze.mint.v1beta1.QueryParamsRequest) - - [QueryParamsResponse](#publicawesome.stargaze.mint.v1beta1.QueryParamsResponse) +- [publicawesome/stargaze/globalfee/v1/proposal.proto](#publicawesome/stargaze/globalfee/v1/proposal.proto) + - [RemoveCodeAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.RemoveCodeAuthorizationProposal) + - [RemoveContractAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.RemoveContractAuthorizationProposal) + - [SetCodeAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.SetCodeAuthorizationProposal) + - [SetContractAuthorizationProposal](#publicawesome.stargaze.globalfee.v1.SetContractAuthorizationProposal) - - [Query](#publicawesome.stargaze.mint.v1beta1.Query) +- [publicawesome/stargaze/globalfee/v1/query.proto](#publicawesome/stargaze/globalfee/v1/query.proto) + - [QueryAuthorizationsRequest](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsRequest) + - [QueryAuthorizationsResponse](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsResponse) + - [QueryCodeAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationRequest) + - [QueryCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationResponse) + - [QueryContractAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationRequest) + - [QueryContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationResponse) + - [QueryParamsRequest](#publicawesome.stargaze.globalfee.v1.QueryParamsRequest) + - [QueryParamsResponse](#publicawesome.stargaze.globalfee.v1.QueryParamsResponse) -- [publicawesome/stargaze/mint/v1beta1/tx.proto](#publicawesome/stargaze/mint/v1beta1/tx.proto) - - [Msg](#publicawesome.stargaze.mint.v1beta1.Msg) + - [Query](#publicawesome.stargaze.globalfee.v1.Query) + +- [publicawesome/stargaze/globalfee/v1/tx.proto](#publicawesome/stargaze/globalfee/v1/tx.proto) + - [MsgRemoveCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorization) + - [MsgRemoveCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorizationResponse) + - [MsgRemoveContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorization) + - [MsgRemoveContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorizationResponse) + - [MsgSetCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorization) + - [MsgSetCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorizationResponse) + - [MsgSetContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorization) + - [MsgSetContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorizationResponse) + - [MsgUpdateParams](#publicawesome.stargaze.globalfee.v1.MsgUpdateParams) + - [MsgUpdateParamsResponse](#publicawesome.stargaze.globalfee.v1.MsgUpdateParamsResponse) + + - [Msg](#publicawesome.stargaze.globalfee.v1.Msg) - [Scalar Value Types](#scalar-value-types) - +

Top

-## publicawesome/stargaze/mint/v1beta1/mint.proto +## publicawesome/stargaze/globalfee/v1/globalfee.proto - + -### Minter -Minter represents the minting state. +### CodeAuthorization +Configuration for code Ids which can have zero gas operations | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `annual_provisions` | [string](#string) | | current annual expected provisions | +| `code_id` | [uint64](#uint64) | | authorized code ids | +| `methods` | [string](#string) | repeated | authorized contract operation methods | + + + +### ContractAuthorization +Configuration for contract addresses which can have zero gas operations + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `contract_address` | [string](#string) | | authorized contract addresses | +| `methods` | [string](#string) | repeated | authorized contract operation methods | - + + + + + + ### Params -Params holds parameters for the mint module. +Params holds parameters for the globalfee module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `mint_denom` | [string](#string) | | type of coin to mint | -| `start_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | the time the chain starts | -| `initial_annual_provisions` | [string](#string) | | initial annual provisions | -| `reduction_factor` | [string](#string) | | factor to reduce inflation by each year | -| `blocks_per_year` | [uint64](#uint64) | | expected blocks per year | +| `privileged_addresses` | [string](#string) | repeated | Addresses which are whitelisted to modify the gas free operations | +| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | Minimum stores the minimum gas price(s) for all TX on the chain. | @@ -76,23 +112,108 @@ Params holds parameters for the mint module. - +

Top

-## publicawesome/stargaze/mint/v1beta1/genesis.proto +## publicawesome/stargaze/globalfee/v1/genesis.proto - + ### GenesisState -GenesisState defines the mint module's genesis state. +GenesisState defines the globalfee module's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | Module params | +| `code_authorizations` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | repeated | Authorizations configured by code id | +| `contract_authorizations` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | repeated | Authorizations configured by contract addresses | + + + + + + + + + + + + + + + + +

Top

+ +## publicawesome/stargaze/globalfee/v1/proposal.proto + + + + + +### RemoveCodeAuthorizationProposal + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `code_id` | [uint64](#uint64) | | | + + + + + + + + +### RemoveContractAuthorizationProposal + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `contract_address` | [string](#string) | | | + + + + + + + + +### SetCodeAuthorizationProposal + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `minter` | [Minter](#publicawesome.stargaze.mint.v1beta1.Minter) | | minter is a space for holding current inflation information. | -| `params` | [Params](#publicawesome.stargaze.mint.v1beta1.Params) | | params defines all the paramaters of the module. | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `code_authorization` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | | | + + + + + + + + +### SetContractAuthorizationProposal + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `contract_authorization` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | | | @@ -108,59 +229,118 @@ GenesisState defines the mint module's genesis state. - +

Top

-## publicawesome/stargaze/mint/v1beta1/query.proto +## publicawesome/stargaze/globalfee/v1/query.proto + + - +### QueryAuthorizationsRequest -### QueryAnnualProvisionsRequest -QueryAnnualProvisionsRequest is the request type for the -Query/AnnualProvisions RPC method. - + + +### QueryAuthorizationsResponse -### QueryAnnualProvisionsResponse -QueryAnnualProvisionsResponse is the response type for the -Query/AnnualProvisions RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `annual_provisions` | [bytes](#bytes) | | annual_provisions is the current minting annual provisions value. | +| `code_authorizations` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | repeated | | +| `contract_authorizations` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | repeated | | + + + + + + + + +### QueryCodeAuthorizationRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code_id` | [uint64](#uint64) | | | + + + + + + + + +### QueryCodeAuthorizationResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `methods` | [string](#string) | repeated | | + + + + + + + + +### QueryContractAuthorizationRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `contract_address` | [string](#string) | | | + + - +### QueryContractAuthorizationResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `methods` | [string](#string) | repeated | | + + + + + + + ### QueryParamsRequest -QueryParamsRequest is the request type for the Query/Params RPC method. - + + ### QueryParamsResponse -QueryParamsResponse is the response type for the Query/Params RPC method. + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#publicawesome.stargaze.mint.v1beta1.Params) | | params defines the parameters of the module. | +| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | | @@ -173,24 +353,156 @@ QueryParamsResponse is the response type for the Query/Params RPC method. - + ### Query -Query provides defines the gRPC querier service. +Query defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Params` | [QueryParamsRequest](#publicawesome.stargaze.mint.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.mint.v1beta1.QueryParamsResponse) | Params returns the total set of minting parameters. | GET|/stargaze/mint/v1beta1/params| -| `AnnualProvisions` | [QueryAnnualProvisionsRequest](#publicawesome.stargaze.mint.v1beta1.QueryAnnualProvisionsRequest) | [QueryAnnualProvisionsResponse](#publicawesome.stargaze.mint.v1beta1.QueryAnnualProvisionsResponse) | AnnualProvisions current minting annual provisions value. | GET|/stargaze/mint/v1beta1/annual_provisions| +| `CodeAuthorization` | [QueryCodeAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationRequest) | [QueryCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryCodeAuthorizationResponse) | | GET|/stargaze/globalfee/v1/code_authorization/{code_id}| +| `ContractAuthorization` | [QueryContractAuthorizationRequest](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationRequest) | [QueryContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.QueryContractAuthorizationResponse) | | GET|/stargaze/globalfee/v1/contract_authorization/{contract_address}| +| `Params` | [QueryParamsRequest](#publicawesome.stargaze.globalfee.v1.QueryParamsRequest) | [QueryParamsResponse](#publicawesome.stargaze.globalfee.v1.QueryParamsResponse) | | GET|/stargaze/globalfee/v1/params| +| `Authorizations` | [QueryAuthorizationsRequest](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsRequest) | [QueryAuthorizationsResponse](#publicawesome.stargaze.globalfee.v1.QueryAuthorizationsResponse) | | GET|/stargaze/globalfee/v1/authorizations| - +

Top

-## publicawesome/stargaze/mint/v1beta1/tx.proto +## publicawesome/stargaze/globalfee/v1/tx.proto + + + + + +### MsgRemoveCodeAuthorization + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `code_id` | [uint64](#uint64) | | | + + + + + + + + +### MsgRemoveCodeAuthorizationResponse + + + + + + + + + +### MsgRemoveContractAuthorization + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `contract_address` | [string](#string) | | | + + + + + + + + +### MsgRemoveContractAuthorizationResponse + + + + + + + + + +### MsgSetCodeAuthorization + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `code_authorization` | [CodeAuthorization](#publicawesome.stargaze.globalfee.v1.CodeAuthorization) | | | + + + + + + + + +### MsgSetCodeAuthorizationResponse + + + + + + + + + +### MsgSetContractAuthorization + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `contract_authorization` | [ContractAuthorization](#publicawesome.stargaze.globalfee.v1.ContractAuthorization) | | | + + + + + + + + +### MsgSetContractAuthorizationResponse + + + + + + + + + +### MsgUpdateParams + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `params` | [Params](#publicawesome.stargaze.globalfee.v1.Params) | | NOTE: All parameters must be supplied. | + + + + + + + + +### MsgUpdateParamsResponse + + + + @@ -200,13 +512,18 @@ Query provides defines the gRPC querier service. - + ### Msg -Msg defines the mint Msg service. +Msg defines the alloc Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `SetCodeAuthorization` | [MsgSetCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorization) | [MsgSetCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorizationResponse) | | | +| `RemoveCodeAuthorization` | [MsgRemoveCodeAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorization) | [MsgRemoveCodeAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorizationResponse) | | | +| `SetContractAuthorization` | [MsgSetContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorization) | [MsgSetContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorizationResponse) | | | +| `RemoveContractAuthorization` | [MsgRemoveContractAuthorization](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorization) | [MsgRemoveContractAuthorizationResponse](#publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorizationResponse) | | | +| `UpdateParams` | [MsgUpdateParams](#publicawesome.stargaze.globalfee.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#publicawesome.stargaze.globalfee.v1.MsgUpdateParamsResponse) | | | diff --git a/proto/publicawesome/stargaze/globalfee/v1/tx.proto b/proto/publicawesome/stargaze/globalfee/v1/tx.proto index 479f5bc2f..ac06364ce 100644 --- a/proto/publicawesome/stargaze/globalfee/v1/tx.proto +++ b/proto/publicawesome/stargaze/globalfee/v1/tx.proto @@ -20,6 +20,9 @@ service Msg { rpc RemoveContractAuthorization(MsgRemoveContractAuthorization) returns (MsgRemoveContractAuthorizationResponse); + + rpc UpdateParams(MsgUpdateParams) + returns (MsgUpdateParamsResponse); } message MsgSetCodeAuthorization { @@ -53,3 +56,15 @@ message MsgRemoveContractAuthorization { } message MsgRemoveContractAuthorizationResponse {} + +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "sender"; + string sender = 1; + // NOTE: All parameters must be supplied. + Params params = 2 [ + (gogoproto.jsontag) = "params,omitempty", + (gogoproto.nullable) = false + ]; +} + +message MsgUpdateParamsResponse {} \ No newline at end of file diff --git a/x/globalfee/keeper/keeper.go b/x/globalfee/keeper/keeper.go index 5d49d3909..4e19c2487 100644 --- a/x/globalfee/keeper/keeper.go +++ b/x/globalfee/keeper/keeper.go @@ -18,10 +18,11 @@ type Keeper struct { paramStore paramTypes.Subspace storeKey storetypes.StoreKey wasmKeeper types.WasmKeeper + authority string // this should be the x/gov module account } // NewKeeper creates a new Keeper instance. -func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey, ps paramTypes.Subspace, wk types.WasmKeeper) Keeper { +func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey, ps paramTypes.Subspace, wk types.WasmKeeper, authority string) Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { ps = ps.WithKeyTable(types.ParamKeyTable()) @@ -32,6 +33,7 @@ func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey, ps paramTypes.Subs storeKey: storeKey, paramStore: ps, wasmKeeper: wk, + authority: authority, } } @@ -43,3 +45,8 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddr sdk.AccAddress) *wasmtypes.ContractInfo { return k.wasmKeeper.GetContractInfo(ctx, contractAddr) } + +// GetAuthority returns the x/wasm module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} diff --git a/x/globalfee/keeper/msg_server.go b/x/globalfee/keeper/msg_server.go index 0803ce1a0..2adb56d82 100644 --- a/x/globalfee/keeper/msg_server.go +++ b/x/globalfee/keeper/msg_server.go @@ -82,3 +82,34 @@ func (k msgServer) RemoveContractAuthorization(goCtx context.Context, msg *types k.Keeper.DeleteContractAuthorization(ctx, contractAddr) return &types.MsgRemoveContractAuthorizationResponse{}, nil } + +func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, err + } + + if msg.Sender != k.Keeper.GetAuthority() { + return nil, errorsmod.Wrap(types.ErrUnauthorized, "sender address is not authorized address to update module params") + } + + err = msg.GetParams().Validate() // need to explicitly validate as x/gov invokes this msg and it does not validate + if err != nil { + return nil, err + } + + k.SetParams(ctx, msg.GetParams()) + + return &types.MsgUpdateParamsResponse{}, nil +} + +// func (m msgServer) isAuthorized(ctx sdk.Context, actor string) bool { +// if actor == m.Keeper.GetAuthority() { +// return true +// } +// if m.Keeper.IsAdminAddress(ctx, actor) { +// return true +// } +// return false +// } diff --git a/x/globalfee/types/tx.pb.go b/x/globalfee/types/tx.pb.go index ab1f6c944..ad84daa77 100644 --- a/x/globalfee/types/tx.pb.go +++ b/x/globalfee/types/tx.pb.go @@ -383,6 +383,95 @@ func (m *MsgRemoveContractAuthorizationResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveContractAuthorizationResponse proto.InternalMessageInfo +type MsgUpdateParams struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` +} + +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_52e10c19bbdb4807, []int{8} +} +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) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +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_52e10c19bbdb4807, []int{9} +} +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((*MsgSetCodeAuthorization)(nil), "publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorization") proto.RegisterType((*MsgSetCodeAuthorizationResponse)(nil), "publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorizationResponse") @@ -392,6 +481,8 @@ func init() { proto.RegisterType((*MsgSetContractAuthorizationResponse)(nil), "publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorizationResponse") proto.RegisterType((*MsgRemoveContractAuthorization)(nil), "publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorization") proto.RegisterType((*MsgRemoveContractAuthorizationResponse)(nil), "publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorizationResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "publicawesome.stargaze.globalfee.v1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "publicawesome.stargaze.globalfee.v1.MsgUpdateParamsResponse") } func init() { @@ -399,39 +490,44 @@ func init() { } var fileDescriptor_52e10c19bbdb4807 = []byte{ - // 509 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcf, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0xb3, 0xfc, 0x09, 0xea, 0xf4, 0x00, 0x58, 0xa5, 0x89, 0x5c, 0xc9, 0x2d, 0x09, 0xa0, - 0x80, 0xc0, 0xab, 0xa4, 0x12, 0x42, 0x15, 0x12, 0xd0, 0x56, 0x82, 0x0a, 0xe5, 0xb2, 0xdc, 0xb8, - 0x20, 0x67, 0x3d, 0xdd, 0x5a, 0x8a, 0xb3, 0xc6, 0xbb, 0x09, 0xa5, 0x47, 0x9e, 0x80, 0x33, 0xd7, - 0x0a, 0xae, 0x70, 0xe1, 0x1d, 0x38, 0xf6, 0xc8, 0x09, 0xa1, 0xe4, 0xc0, 0x6b, 0xa0, 0x38, 0xb1, - 0x9b, 0x10, 0x3b, 0x72, 0x14, 0x6e, 0xf6, 0xee, 0xcc, 0x7c, 0xbf, 0xef, 0xd3, 0x68, 0xe1, 0x7e, - 0xd0, 0x6d, 0xb5, 0x3d, 0xee, 0xbc, 0x43, 0x25, 0x7d, 0xa4, 0x4a, 0x3b, 0xa1, 0x70, 0x4e, 0x90, - 0x8a, 0xb6, 0x6c, 0x39, 0xed, 0x43, 0x44, 0xda, 0xab, 0x53, 0x7d, 0x6c, 0x07, 0xa1, 0xd4, 0xd2, - 0xa8, 0x4e, 0x55, 0x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 0x37, 0x00, 0x00, 0xff, 0xff, 0x74, 0x98, 0x3a, 0x0f, 0x8d, 0x06, 0x00, 0x00, + // 592 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x51, 0x6b, 0xd3, 0x5e, + 0x18, 0xc6, 0x7b, 0xfe, 0x7f, 0x89, 0xec, 0x9d, 0xb0, 0x19, 0xe6, 0x5a, 0x33, 0x48, 0x67, 0xab, + 0x52, 0x75, 0x26, 0xb4, 0x13, 0x91, 0x31, 0x50, 0xbb, 0x81, 0x0e, 0x29, 0x48, 0xc4, 0x1b, 0x41, + 0xe4, 0x34, 0x39, 0x3b, 0x0b, 0x34, 0x3d, 0x31, 0xe7, 0xb4, 0x6e, 0xbb, 0xdc, 0x27, 0xf0, 0xc6, + 0x1b, 0x6f, 0x45, 0xf1, 0x4e, 0x6f, 0xfc, 0x0e, 0xbb, 0xdc, 0xa5, 0x57, 0x45, 0xda, 0x0b, 0xc1, + 0x4f, 0x21, 0x4d, 0xd3, 0x2c, 0x71, 0x49, 0x49, 0xad, 0x77, 0xc9, 0x39, 0xef, 0xfb, 0x3c, 0xbf, + 0xe7, 0x85, 0x97, 0x03, 0x6b, 0x6e, 0xa7, 0xd9, 0xb2, 0x4d, 0xfc, 0x86, 0x70, 0xe6, 0x10, 0x9d, + 0x0b, 0xec, 0x51, 0x7c, 0x48, 0x74, 0xda, 0x62, 0x4d, 0xdc, 0xda, 0x25, 0x44, 0xef, 0x56, 0x75, + 0xb1, 0xaf, 0xb9, 0x1e, 0x13, 0x4c, 0x2e, 0xc7, 0xaa, 0xb5, 0x71, 0xb5, 0x16, 0x56, 0x6b, 0xdd, + 0xaa, 0xb2, 0x44, 0x19, 0x65, 0x7e, 0xbd, 0x3e, 0xfc, 0x1a, 0xb5, 0x2a, 0x79, 0x93, 0x71, 0x87, + 0x71, 0xdd, 0xe1, 0x74, 0x28, 0xe9, 0x70,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xe8, 0x47, 0x5f, 0x45, 0x6f, 0x07, 0x6a, 0xee, 0x64, 0xa0, 0xe6, 0xbe, 0x0f, + 0xd4, 0xdc, 0x8b, 0x7b, 0xd4, 0x16, 0x7b, 0x9d, 0xa6, 0x66, 0x32, 0x47, 0x1f, 0x39, 0xdc, 0x3e, + 0xf3, 0x18, 0x76, 0xab, 0x35, 0x7d, 0x3f, 0xf2, 0x24, 0x8a, 0x03, 0x97, 0xf0, 0xa6, 0xe4, 0x3f, + 0x86, 0xeb, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xcb, 0x28, 0x60, 0xa2, 0xc5, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -450,6 +546,7 @@ type MsgClient interface { RemoveCodeAuthorization(ctx context.Context, in *MsgRemoveCodeAuthorization, opts ...grpc.CallOption) (*MsgRemoveCodeAuthorizationResponse, error) SetContractAuthorization(ctx context.Context, in *MsgSetContractAuthorization, opts ...grpc.CallOption) (*MsgSetContractAuthorizationResponse, error) RemoveContractAuthorization(ctx context.Context, in *MsgRemoveContractAuthorization, opts ...grpc.CallOption) (*MsgRemoveContractAuthorizationResponse, error) + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } type msgClient struct { @@ -496,12 +593,22 @@ func (c *msgClient) RemoveContractAuthorization(ctx context.Context, in *MsgRemo return out, nil } +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/publicawesome.stargaze.globalfee.v1.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 { SetCodeAuthorization(context.Context, *MsgSetCodeAuthorization) (*MsgSetCodeAuthorizationResponse, error) RemoveCodeAuthorization(context.Context, *MsgRemoveCodeAuthorization) (*MsgRemoveCodeAuthorizationResponse, error) SetContractAuthorization(context.Context, *MsgSetContractAuthorization) (*MsgSetContractAuthorizationResponse, error) RemoveContractAuthorization(context.Context, *MsgRemoveContractAuthorization) (*MsgRemoveContractAuthorizationResponse, error) + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -520,6 +627,9 @@ func (*UnimplementedMsgServer) SetContractAuthorization(ctx context.Context, req func (*UnimplementedMsgServer) RemoveContractAuthorization(ctx context.Context, req *MsgRemoveContractAuthorization) (*MsgRemoveContractAuthorizationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RemoveContractAuthorization not implemented") } +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) @@ -597,6 +707,24 @@ func _Msg_RemoveContractAuthorization_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +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: "/publicawesome.stargaze.globalfee.v1.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: "publicawesome.stargaze.globalfee.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -617,6 +745,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "RemoveContractAuthorization", Handler: _Msg_RemoveContractAuthorization_Handler, }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "publicawesome/stargaze/globalfee/v1/tx.proto", @@ -870,6 +1002,69 @@ func (m *MsgRemoveContractAuthorizationResponse) MarshalToSizedBuffer(dAtA []byt return len(dAtA) - i, nil } +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.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + 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 @@ -984,6 +1179,30 @@ func (m *MsgRemoveContractAuthorizationResponse) Size() (n int) { return n } +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + 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 } @@ -1641,6 +1860,171 @@ func (m *MsgRemoveContractAuthorizationResponse) Unmarshal(dAtA []byte) error { } return nil } +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 Sender", 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.Sender = 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 From df9ebed8ac4904b8da31418700c111967c0aa0ff Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 29 Sep 2023 18:16:47 +0530 Subject: [PATCH 3/6] updating the msgs to newer isAuthorized --- x/globalfee/keeper/msg_server.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/x/globalfee/keeper/msg_server.go b/x/globalfee/keeper/msg_server.go index 2adb56d82..dadbcd897 100644 --- a/x/globalfee/keeper/msg_server.go +++ b/x/globalfee/keeper/msg_server.go @@ -28,7 +28,7 @@ func (k msgServer) SetCodeAuthorization(goCtx context.Context, msg *types.MsgSet return nil, err } if !k.IsPrivilegedAddress(ctx, msg.Sender) { - return nil, errorsmod.Wrap(types.ErrUnauthorized, "sender address is not privileged address") + return nil, errorsmod.Wrap(types.ErrUnauthorized, "sender address is not authorized address to set code authorization") } err = k.Keeper.SetCodeAuthorization(ctx, *msg.CodeAuthorization) if err != nil { @@ -43,8 +43,8 @@ func (k msgServer) RemoveCodeAuthorization(goCtx context.Context, msg *types.Msg if err != nil { return nil, err } - if !k.IsPrivilegedAddress(ctx, msg.Sender) { - return nil, errorsmod.Wrap(types.ErrUnauthorized, "sender address is not privileged address") + if !k.isAuthorized(ctx, msg.Sender) { + return nil, errorsmod.Wrap(types.ErrUnauthorized, "sender address is not authorized address to remove code authorization") } k.Keeper.DeleteCodeAuthorization(ctx, msg.GetCodeID()) return &types.MsgRemoveCodeAuthorizationResponse{}, nil @@ -56,8 +56,8 @@ func (k msgServer) SetContractAuthorization(goCtx context.Context, msg *types.Ms if err != nil { return nil, err } - if !k.IsPrivilegedAddress(ctx, msg.Sender) { - return nil, errorsmod.Wrap(types.ErrUnauthorized, "sender address is not privileged address") + if !k.isAuthorized(ctx, msg.Sender) { + return nil, errorsmod.Wrap(types.ErrUnauthorized, "sender address is not authorized address to set contract authorization") } err = k.Keeper.SetContractAuthorization(ctx, *msg.ContractAuthorization) if err != nil { @@ -72,8 +72,8 @@ func (k msgServer) RemoveContractAuthorization(goCtx context.Context, msg *types if err != nil { return nil, err } - if !k.IsPrivilegedAddress(ctx, msg.Sender) { - return nil, errorsmod.Wrap(types.ErrUnauthorized, "sender address is not privileged address") + if !k.isAuthorized(ctx, msg.Sender) { + return nil, errorsmod.Wrap(types.ErrUnauthorized, "sender address is not authorized address to remove contract authorization") } contractAddr, err := sdk.AccAddressFromBech32(msg.ContractAddress) if err != nil { @@ -104,12 +104,12 @@ func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParam return &types.MsgUpdateParamsResponse{}, nil } -// func (m msgServer) isAuthorized(ctx sdk.Context, actor string) bool { -// if actor == m.Keeper.GetAuthority() { -// return true -// } -// if m.Keeper.IsAdminAddress(ctx, actor) { -// return true -// } -// return false -// } +func (m msgServer) isAuthorized(ctx sdk.Context, actor string) bool { + if actor == m.Keeper.GetAuthority() { + return true + } + if m.Keeper.IsPrivilegedAddress(ctx, actor) { + return true + } + return false +} From c547dd9b931746cf08527641000bb2f50a59eb56 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 29 Sep 2023 21:20:40 +0530 Subject: [PATCH 4/6] updating docs --- app/app.go | 8 +- testutil/keeper/globalfee.go | 1 + x/globalfee/keeper/msg_server.go | 6 +- x/globalfee/spec/05_client.md | 218 ++++++++++++++++++------------- 4 files changed, 141 insertions(+), 92 deletions(-) diff --git a/app/app.go b/app/app.go index 1cfd88d48..36e862f2f 100644 --- a/app/app.go +++ b/app/app.go @@ -657,7 +657,13 @@ func NewStargazeApp( cronModule := cronmodule.NewAppModule(appCodec, app.CronKeeper, app.WasmKeeper) govRouter.AddRoute(cronmoduletypes.RouterKey, cronmodulekeeper.NewProposalHandler(app.CronKeeper)) - app.GlobalFeeKeeper = globalfeemodulekeeper.NewKeeper(appCodec, keys[globalfeemoduletypes.StoreKey], app.GetSubspace(globalfeemoduletypes.ModuleName), app.WasmKeeper) + app.GlobalFeeKeeper = globalfeemodulekeeper.NewKeeper( + appCodec, + keys[globalfeemoduletypes.StoreKey], + app.GetSubspace(globalfeemoduletypes.ModuleName), + app.WasmKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) globalfeeModule := globalfeemodule.NewAppModule(appCodec, app.GlobalFeeKeeper) // The gov proposal types can be individually enabled diff --git a/testutil/keeper/globalfee.go b/testutil/keeper/globalfee.go index 27fcf3149..a935bfb16 100644 --- a/testutil/keeper/globalfee.go +++ b/testutil/keeper/globalfee.go @@ -79,6 +79,7 @@ func GlobalFeeKeeper(tb testing.TB) (keeper.Keeper, sdk.Context) { storeKey, subspace, wk, + "cosmos1a48wdtjn3egw7swhfkeshwdtjvs6hq9nlyrwut", // random addr for gov module ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/globalfee/keeper/msg_server.go b/x/globalfee/keeper/msg_server.go index dadbcd897..1f94a7522 100644 --- a/x/globalfee/keeper/msg_server.go +++ b/x/globalfee/keeper/msg_server.go @@ -104,11 +104,11 @@ func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParam return &types.MsgUpdateParamsResponse{}, nil } -func (m msgServer) isAuthorized(ctx sdk.Context, actor string) bool { - if actor == m.Keeper.GetAuthority() { +func (k msgServer) isAuthorized(ctx sdk.Context, actor string) bool { + if actor == k.Keeper.GetAuthority() { return true } - if m.Keeper.IsPrivilegedAddress(ctx, actor) { + if k.Keeper.IsPrivilegedAddress(ctx, actor) { return true } return false diff --git a/x/globalfee/spec/05_client.md b/x/globalfee/spec/05_client.md index 66c44f2bb..7255e6ada 100644 --- a/x/globalfee/spec/05_client.md +++ b/x/globalfee/spec/05_client.md @@ -94,6 +94,136 @@ contract_authorizations: - * ``` +### Gov + +```starsd tx gov submit-proposal proposal.json --from {user}``` + +You will need the x/gov module address to set as authority for the proposal. You can fetch it by running: `starsd q auth module-account gov` + +This will get you the following response + +```jsonc +account: + '@type': /cosmos.auth.v1beta1.ModuleAccount + base_account: + account_number: "7" + address: stars10d07y265gmmuvt4z0w9aw880jnsr700jw7ycaz // This is the address you need to use for authority value + pub_key: null + sequence: "0" + name: gov + permissions: + - burner +``` +The expected format of the proposal.json is below. + +#### Update Params + +```jsonc +{ + "messages": [ + { + "@type": "/publicawesome.stargaze.globalfee.v1.MsgUpdateParams", + "authority": "stars10d07y265gmmuvt4z0w9aw880jnsr700jw7ycaz", // x/gov address + "params": { // note: the entire params field needs to be filled + "privileged_addresses": [ + "stars1mzgucqnfr2l8cj5apvdpllhzt4zeuh2cyt4fdd" + ], + "minimum_gas_prices": [ + "1ustar" + ] + } + } + ], + "metadata": "metadata", + "deposit": "1000stake", + "title": "Update module params", + "summary": "This will update the module admins as well as the minimum gas price" +} +``` + +#### Set Code Authorization + +```jsonc +{ + "messages": [ + { + "@type": "/publicawesome.stargaze.globalfee.v1.MsgSetCodeAuthorization", + "sender": "stars10d07y265gmmuvt4z0w9aw880jnsr700jw7ycaz", // x/gov address + "code_authorization": { + "code_id": 1, + "methods": [ + "mint" + ] + } + } + ], + "metadata": "metadata", + "deposit": "1000stake", + "title": "Set Code Authorization", + "summary": "Set Code Authorization for all contracts of given code id" +} +``` + +#### Remove Code Authorization + +```jsonc +{ + "messages": [ + { + "@type": "/publicawesome.stargaze.globalfee.v1.MsgRemoveCodeAuthorization", + "sender": "stars10d07y265gmmuvt4z0w9aw880jnsr700jw7ycaz", // x/gov address + "code_id": 1 + } + ], + "metadata": "metadata", + "deposit": "1000stake", + "title": "Remove Code Authorization", + "summary": "Remove Code Authorization for all contracts of given code id" +} +``` + +#### Set Contract Authorization + +```jsonc +{ + "messages": [ + { + "@type": "/publicawesome.stargaze.globalfee.v1.MsgSetContractAuthorization", + "sender": "stars10d07y265gmmuvt4z0w9aw880jnsr700jw7ycaz", // x/gov address + "contract_authorization": { + "contract_address": "stars14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9srsl6sm", + "methods": [ + "*" + ] + } + } + ], + "metadata": "metadata", + "deposit": "1000stake", + "title": "Set Contract Authorization", + "summary": "Set contract Authorization for contract of given address" +} +``` + +#### Remove Contract Authorization + +```jsonc +{ + "messages": [ + { + "@type": "/publicawesome.stargaze.globalfee.v1.MsgRemoveContractAuthorization", + "sender": "stars10d07y265gmmuvt4z0w9aw880jnsr700jw7ycaz", // x/gov address + "contract_address": "stars14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9srsl6sm" + } + ], + "metadata": "metadata", + "deposit": "1000stake", + "title": "Remove Contract Authorization", + "summary": "Remove contract Authorization for contract of given address" +} +``` + + ### Transactions The `tx` commands allows a user to interact with the module. @@ -189,91 +319,3 @@ starsd tx globalfee remove-contract-authorization stars1fvhcnyddukcqfnt7nlwv3thm --from myAccountKey \ --fees 1500ustars ``` - -#### set-code-authorization-proposal - -Creates a gov proposal to create or update the zero gas fee operation authorization for the given code ID and for the provided methods. The methods should be comma separated values. - -Any stargaze address can perform this operation. - -Usage: - -```bash -starsd tx globalfee set-code-authorization-proposal [code-id] [methods] [flags] -``` - -Example: - -```bash -starsd tx globalfee set-code-authorization-proposal 3 "mint,unlist" \ - --title "Adding new code authorization" \ - --deposit 1000ustars \ - --from myAccountKey \ - --fees 1500ustars -``` - -#### remove-code-authorization-proposal - -Creates a gov proposal to remove the zero gas fee operation authorization for the given code ID. - -Any stargaze address can perform this operation. - -Usage: - -```bash -starsd tx globalfee remove-code-authorization-proposal [code-id] [flags] -``` - -Example: - -```bash -starsd tx globalfee remove-code-authorization-proposal 3 \ - --title "Removing the code authorization" \ - --deposit 1000ustars \ - --from myAccountKey \ - --fees 1500ustars -``` - -#### set-contract-authorization-proposal - -Creates a gov proposal to create or update the gasless operation authorization for the given contract adress and for the provided methods. The methods should be comma separated values. - -Any stargaze address can perform this operation. - -Usage: - -```bash -starsd tx globalfee set-contract-authorization-proposal [contract-address] [methods] [flags] -``` - -Example: - -```bash -starsd tx globalfee set-contract-authorization-proposal stars1fvhcnyddukcqfnt7nlwv3thm5we22lyxyxylr9h77cvgkcn43xfsvgv0pl "*" \ - --title "Adding new contract authorization" \ - --deposit 1000ustars \ - --from myAccountKey \ - --fees 1500ustars -``` - -#### remove-contract-authorization-proposal - -Creates a gov proposal to remove the zero gas fee operation authorization for the given contract adress. - -Any stargaze address can perform this operation. - -Usage: - -```bash -starsd tx globalfee remove-contract-authorization-proposal [contract-address] [flags] -``` - -Example: - -```bash -starsd tx globalfee remove-contract-authorization-proposal stars1fvhcnyddukcqfnt7nlwv3thm5we22lyxyxylr9h77cvgkcn43xfsvgv0pl \ - --title "Removing the contract authorization" \ - --deposit 1000ustars \ - --from myAccountKey \ - --fees 1500ustars -``` From a7085b3ff7a592b94477a14efb11a6427cff1165 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 29 Sep 2023 21:28:13 +0530 Subject: [PATCH 5/6] fix missing msg interface for MsgUpdateParams --- x/globalfee/types/codec.go | 2 ++ x/globalfee/types/params.go | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/x/globalfee/types/codec.go b/x/globalfee/types/codec.go index 77e38540a..6adf03745 100644 --- a/x/globalfee/types/codec.go +++ b/x/globalfee/types/codec.go @@ -15,6 +15,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgRemoveCodeAuthorization{}, "globalfee/MsgRemoveCodeAuthorization", nil) cdc.RegisterConcrete(&MsgSetContractAuthorization{}, "globalfee/MsgSetContractAuthorization", nil) cdc.RegisterConcrete(&MsgRemoveContractAuthorization{}, "globalfee/MsgRemoveContractAuthorization", nil) + cdc.RegisterConcrete(&MsgUpdateParams{}, "globalfee/MsgUpdateParams", nil) } // RegisterInterfaces registers interfaces types with the interface registry. @@ -24,6 +25,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &MsgRemoveCodeAuthorization{}, &MsgSetContractAuthorization{}, &MsgRemoveContractAuthorization{}, + &MsgUpdateParams{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index d7b645e0a..329e2a4b7 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -78,3 +78,51 @@ func (p Params) String() string { out, _ := yaml.Marshal(p) return string(out) } + +var ( + _ sdk.Msg = &MsgUpdateParams{} +) + +// msg types +const ( + TypeMsgUpdateParams = "update_params" +) + +func NewMsgUpdateParams(sender string, minimumGasPrices sdk.DecCoins, privilegedAddresses []string) *MsgUpdateParams { + return &MsgUpdateParams{ + Sender: sender, + Params: Params{ + MinimumGasPrices: minimumGasPrices, + PrivilegedAddresses: privilegedAddresses, + }, + } +} + +func (msg MsgUpdateParams) Route() string { + return RouterKey +} + +func (msg MsgUpdateParams) Type() string { + return TypeMsgUpdateParams +} + +func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg MsgUpdateParams) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +func (msg MsgUpdateParams) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + return msg.Params.Validate() +} From 496daee34c7211a799d9ad65b67a528ba5f02518 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 29 Sep 2023 21:29:19 +0530 Subject: [PATCH 6/6] fix lint --- x/globalfee/types/params.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index 329e2a4b7..59628734b 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -79,9 +79,7 @@ func (p Params) String() string { return string(out) } -var ( - _ sdk.Msg = &MsgUpdateParams{} -) +var _ sdk.Msg = &MsgUpdateParams{} // msg types const (