Skip to content

Commit

Permalink
Merge branch 'main' into taztingo/remove-internal-helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Taztingo authored Jun 3, 2024
2 parents 4229c6f + 3c46a40 commit 4f3534d
Show file tree
Hide file tree
Showing 15 changed files with 678 additions and 235 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Fix unit tests for ibchooks [#1980](https://github.com/provenance-io/provenance/pull/1980).
* Replace deprecated wasm features [#1988](https://github.com/provenance-io/provenance/pull/1988).
* Add `UpdateParams` and `Params` query rpc endpoints to modules.
* `exchange` add `UpdateParams` endpoint and deprecate `GovUpdateParams` [#2017](https://github.com/provenance-io/provenance/pull/2017).
* `ibchooks` add `UpdateParams` endpoint and `Params` query endpoint [#2006](https://github.com/provenance-io/provenance/pull/2006).
* `ibcratelimit` add `UpdateParams` endpoint and deprecate `GovUpdateParams` [#1984](https://github.com/provenance-io/provenance/pull/1984).
* `attribute` add `UpdateParams` endpoint and cli [#1987](https://github.com/provenance-io/provenance/pull/1987).
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105681,6 +105681,8 @@ definitions:
description: >-
MsgGovUpdateParamsResponse is a response message for the GovUpdateParams
endpoint.

Deprecated: Use MsgUpdateParamsResponse instead.
provenance.exchange.v1.MsgMarketCommitmentSettleResponse:
type: object
description: >-
Expand Down Expand Up @@ -105759,6 +105761,11 @@ definitions:
description: >-
MsgRejectPaymentsResponse is a response message for the RejectPayments
endpoint.
provenance.exchange.v1.MsgUpdateParamsResponse:
type: object
description: >-
MsgUpdateParamsResponse is a response message for the GovUpdateParams
endpoint.
provenance.hold.v1.AccountHold:
type: object
properties:
Expand Down
29 changes: 27 additions & 2 deletions proto/provenance/exchange/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ service Msg {
rpc GovCloseMarket(MsgGovCloseMarketRequest) returns (MsgGovCloseMarketResponse);

// GovUpdateParams is a governance proposal endpoint for updating the exchange module's params.
rpc GovUpdateParams(MsgGovUpdateParamsRequest) returns (MsgGovUpdateParamsResponse);
// Deprecated: Use UpdateParams instead.
rpc GovUpdateParams(MsgGovUpdateParamsRequest) returns (MsgGovUpdateParamsResponse) {
option deprecated = true;
};

// UpdateParams is a governance proposal endpoint for updating the exchange module's params.
rpc UpdateParams(MsgUpdateParamsRequest) returns (MsgUpdateParamsResponse);
}

// MsgCreateAskRequest is a request message for the CreateAsk endpoint.
Expand Down Expand Up @@ -670,7 +676,9 @@ message MsgGovCloseMarketRequest {
message MsgGovCloseMarketResponse {}

// MsgGovUpdateParamsRequest is a request message for the GovUpdateParams endpoint.
// Deprecated: Use MsgUpdateParamsRequest instead.
message MsgGovUpdateParamsRequest {
option deprecated = true;
option (cosmos.msg.v1.signer) = "authority";

// authority should be the governance module account address.
Expand All @@ -681,4 +689,21 @@ message MsgGovUpdateParamsRequest {
}

// MsgGovUpdateParamsResponse is a response message for the GovUpdateParams endpoint.
message MsgGovUpdateParamsResponse {}
// Deprecated: Use MsgUpdateParamsResponse instead.
message MsgGovUpdateParamsResponse {
option deprecated = true;
}

// MsgGovUpdateParamsRequest is a request message for the GovUpdateParams endpoint.
message MsgUpdateParamsRequest {
option (cosmos.msg.v1.signer) = "authority";

// authority should be the governance module account address.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// params are the new param values to set
Params params = 2 [(gogoproto.nullable) = false];
}

// MsgUpdateParamsResponse is a response message for the GovUpdateParams endpoint.
message MsgUpdateParamsResponse {}
14 changes: 7 additions & 7 deletions x/exchange/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func CmdTx() *cobra.Command {
CmdTxGovCreateMarket(),
CmdTxGovManageFees(),
CmdTxGovCloseMarket(),
CmdTxGovUpdateParams(),
CmdTxUpdateParams(),
)

return cmd
Expand Down Expand Up @@ -437,17 +437,17 @@ func CmdTxGovCloseMarket() *cobra.Command {
return cmd
}

// CmdTxGovUpdateParams creates the gov-update-params sub-command for the exchange tx command.
func CmdTxGovUpdateParams() *cobra.Command {
// CmdTxUpdateParams creates the gov-update-params sub-command for the exchange tx command.
func CmdTxUpdateParams() *cobra.Command {
cmd := &cobra.Command{
Use: "gov-update-params",
Aliases: []string{"gov-params", "update-params", "params"},
Use: "update-params",
Aliases: []string{"gov-params", "gov-update-params", "params"},
Short: "Submit a governance proposal to update the exchange module params",
RunE: govTxRunE(MakeMsgGovUpdateParams),
RunE: govTxRunE(MakeMsgUpdateParams),
}

flags.AddTxFlagsToCmd(cmd)
govcli.AddGovPropFlagsToCmd(cmd)
SetupCmdTxGovUpdateParams(cmd)
SetupCmdTxUpdateParams(cmd)
return cmd
}
10 changes: 5 additions & 5 deletions x/exchange/client/cli/tx_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -1182,8 +1182,8 @@ func MakeMsgGovCloseMarket(_ client.Context, flagSet *pflag.FlagSet, _ []string)
return msg, errors.Join(errs...)
}

// SetupCmdTxGovUpdateParams adds all the flags needed for MakeMsgGovUpdateParams.
func SetupCmdTxGovUpdateParams(cmd *cobra.Command) {
// SetupCmdTxUpdateParams adds all the flags needed for MakeMsgUpdateParams.
func SetupCmdTxUpdateParams(cmd *cobra.Command) {
cmd.Flags().String(FlagAuthority, "", "The authority address to use (defaults to the governance module account)")
cmd.Flags().Uint32(FlagDefault, 0, "The default split (required)")
cmd.Flags().StringSlice(FlagSplit, nil, "The denom-splits (repeatable)")
Expand All @@ -1207,10 +1207,10 @@ Example <split>: nhash:500`,
cmd.Args = cobra.NoArgs
}

// MakeMsgGovUpdateParams reads all the SetupCmdTxGovUpdateParams flags and creates the desired Msg.
// MakeMsgUpdateParams reads all the SetupCmdTxUpdateParams flags and creates the desired Msg.
// Satisfies the msgMaker type.
func MakeMsgGovUpdateParams(_ client.Context, flagSet *pflag.FlagSet, _ []string) (*exchange.MsgGovUpdateParamsRequest, error) {
msg := &exchange.MsgGovUpdateParamsRequest{}
func MakeMsgUpdateParams(_ client.Context, flagSet *pflag.FlagSet, _ []string) (*exchange.MsgUpdateParamsRequest, error) {
msg := &exchange.MsgUpdateParamsRequest{}

errs := make([]error, 3)
msg.Authority, errs[0] = ReadFlagAuthority(flagSet)
Expand Down
24 changes: 12 additions & 12 deletions x/exchange/client/cli/tx_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2734,10 +2734,10 @@ func TestMakeMsgGovCloseMarket(t *testing.T) {
}
}

func TestSetupCmdTxGovUpdateParams(t *testing.T) {
func TestSetupCmdTxUpdateParams(t *testing.T) {
runSetupTestCase(t, setupTestCase{
name: "SetupCmdTxGovUpdateParams",
setup: cli.SetupCmdTxGovUpdateParams,
name: "SetupCmdTxUpdateParams",
setup: cli.SetupCmdTxUpdateParams,
expFlags: []string{
cli.FlagAuthority, cli.FlagDefault, cli.FlagSplit,
},
Expand All @@ -2755,18 +2755,18 @@ Example <split>: nhash:500`,
})
}

func TestMakeMsgGovUpdateParams(t *testing.T) {
td := txMakerTestDef[*exchange.MsgGovUpdateParamsRequest]{
makerName: "MakeMsgGovUpdateParams",
maker: cli.MakeMsgGovUpdateParams,
setup: cli.SetupCmdTxGovUpdateParams,
func TestMakeMsgUpdateParams(t *testing.T) {
td := txMakerTestDef[*exchange.MsgUpdateParamsRequest]{
makerName: "MakeMsgUpdateParams",
maker: cli.MakeMsgUpdateParams,
setup: cli.SetupCmdTxUpdateParams,
}

tests := []txMakerTestCase[*exchange.MsgGovUpdateParamsRequest]{
tests := []txMakerTestCase[*exchange.MsgUpdateParamsRequest]{
{
name: "some errors",
flags: []string{"--split", "jack,14"},
expMsg: &exchange.MsgGovUpdateParamsRequest{
expMsg: &exchange.MsgUpdateParamsRequest{
Authority: cli.AuthorityAddr.String(),
Params: exchange.Params{DenomSplits: []exchange.DenomSplit{}},
},
Expand All @@ -2779,7 +2779,7 @@ func TestMakeMsgGovUpdateParams(t *testing.T) {
name: "no splits",
clientCtx: client.Context{FromAddress: sdk.AccAddress("FromAddress_________")},
flags: []string{"--default", "501"},
expMsg: &exchange.MsgGovUpdateParamsRequest{
expMsg: &exchange.MsgUpdateParamsRequest{
Authority: cli.AuthorityAddr.String(),
Params: exchange.Params{DefaultSplit: 501},
},
Expand All @@ -2790,7 +2790,7 @@ func TestMakeMsgGovUpdateParams(t *testing.T) {
flags: []string{
"--split", "banana:99", "--default", "105",
"--authority", "Jeff", "--split", "apple:333,plum:555"},
expMsg: &exchange.MsgGovUpdateParamsRequest{
expMsg: &exchange.MsgUpdateParamsRequest{
Authority: "Jeff",
Params: exchange.Params{
DefaultSplit: 105,
Expand Down
4 changes: 2 additions & 2 deletions x/exchange/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ func (s *CmdTestSuite) TestCmdTxGovCloseMarket() {
}
}

func (s *CmdTestSuite) TestCmdTxGovUpdateParams() {
func (s *CmdTestSuite) TestCmdTxUpdateParams() {
tests := []txCmdTestCase{
{
name: "cmd error",
Expand All @@ -1780,7 +1780,7 @@ func (s *CmdTestSuite) TestCmdTxGovUpdateParams() {
{
name: "prop created",
preRun: func() ([]string, func(*sdk.TxResponse)) {
expMsg := &exchange.MsgGovUpdateParamsRequest{
expMsg := &exchange.MsgUpdateParamsRequest{
Authority: cli.AuthorityAddr.String(),
Params: exchange.Params{
DefaultSplit: 777,
Expand Down
12 changes: 10 additions & 2 deletions x/exchange/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"errors"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -415,7 +416,14 @@ func (k MsgServer) GovCloseMarket(goCtx context.Context, msg *exchange.MsgGovClo
}

// GovUpdateParams is a governance proposal endpoint for updating the exchange module's params.
func (k MsgServer) GovUpdateParams(goCtx context.Context, msg *exchange.MsgGovUpdateParamsRequest) (*exchange.MsgGovUpdateParamsResponse, error) {
//
//nolint:staticcheck // SA1019 Suppress warning for deprecated MsgGovUpdateParamsRequest usage
func (k MsgServer) GovUpdateParams(_ context.Context, _ *exchange.MsgGovUpdateParamsRequest) (*exchange.MsgGovUpdateParamsResponse, error) {
return nil, errors.New("deprecated and unusable")
}

// UpdateParams is a governance proposal endpoint for updating the exchange module's params.
func (k MsgServer) UpdateParams(goCtx context.Context, msg *exchange.MsgUpdateParamsRequest) (*exchange.MsgUpdateParamsResponse, error) {
if err := k.ValidateAuthority(msg.Authority); err != nil {
return nil, err
}
Expand All @@ -424,5 +432,5 @@ func (k MsgServer) GovUpdateParams(goCtx context.Context, msg *exchange.MsgGovUp
k.SetParams(ctx, &msg.Params)
k.emitEvent(ctx, exchange.NewEventParamsUpdated())

return &exchange.MsgGovUpdateParamsResponse{}, nil
return &exchange.MsgUpdateParamsResponse{}, nil
}
24 changes: 12 additions & 12 deletions x/exchange/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5434,21 +5434,21 @@ func (s *TestSuite) TestMsgServer_GovCloseMarket() {
}
}

func (s *TestSuite) TestMsgServer_GovUpdateParams() {
testDef := msgServerTestDef[exchange.MsgGovUpdateParamsRequest, exchange.MsgGovUpdateParamsResponse, struct{}]{
endpointName: "GovUpdateParams",
endpoint: keeper.NewMsgServer(s.k).GovUpdateParams,
expResp: &exchange.MsgGovUpdateParamsResponse{},
followup: func(msg *exchange.MsgGovUpdateParamsRequest, _ struct{}) {
func (s *TestSuite) TestMsgServer_UpdateParams() {
testDef := msgServerTestDef[exchange.MsgUpdateParamsRequest, exchange.MsgUpdateParamsResponse, struct{}]{
endpointName: "UpdateParams",
endpoint: keeper.NewMsgServer(s.k).UpdateParams,
expResp: &exchange.MsgUpdateParamsResponse{},
followup: func(msg *exchange.MsgUpdateParamsRequest, _ struct{}) {
actParams := s.k.GetParams(s.ctx)
s.Assert().Equal(&msg.Params, actParams, "GetParams")
},
}

tests := []msgServerTestCase[exchange.MsgGovUpdateParamsRequest, struct{}]{
tests := []msgServerTestCase[exchange.MsgUpdateParamsRequest, struct{}]{
{
name: "wrong authority",
msg: exchange.MsgGovUpdateParamsRequest{
msg: exchange.MsgUpdateParamsRequest{
Authority: s.addr5.String(),
Params: exchange.Params{},
},
Expand All @@ -5461,7 +5461,7 @@ func (s *TestSuite) TestMsgServer_GovUpdateParams() {
setup: func() {
s.k.SetParams(s.ctx, nil)
},
msg: exchange.MsgGovUpdateParamsRequest{
msg: exchange.MsgUpdateParamsRequest{
Authority: s.k.GetAuthority(),
Params: exchange.Params{
DefaultSplit: 333,
Expand All @@ -5477,7 +5477,7 @@ func (s *TestSuite) TestMsgServer_GovUpdateParams() {
setup: func() {
s.k.SetParams(s.ctx, exchange.DefaultParams())
},
msg: exchange.MsgGovUpdateParamsRequest{
msg: exchange.MsgUpdateParamsRequest{
Authority: s.k.GetAuthority(),
Params: *exchange.DefaultParams(),
},
Expand All @@ -5490,7 +5490,7 @@ func (s *TestSuite) TestMsgServer_GovUpdateParams() {
setup: func() {
s.k.SetParams(s.ctx, exchange.DefaultParams())
},
msg: exchange.MsgGovUpdateParamsRequest{
msg: exchange.MsgUpdateParamsRequest{
Authority: s.k.GetAuthority(),
Params: exchange.Params{
DefaultSplit: 333,
Expand All @@ -5509,7 +5509,7 @@ func (s *TestSuite) TestMsgServer_GovUpdateParams() {
DenomSplits: []exchange.DenomSplit{{Denom: "cherry", Split: 4}},
})
},
msg: exchange.MsgGovUpdateParamsRequest{
msg: exchange.MsgUpdateParamsRequest{
Authority: s.k.GetAuthority(),
Params: exchange.Params{
DefaultSplit: 345,
Expand Down
5 changes: 5 additions & 0 deletions x/exchange/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var AllRequestMsgs = []sdk.Msg{
(*MsgGovManageFeesRequest)(nil),
(*MsgGovCloseMarketRequest)(nil),
(*MsgGovUpdateParamsRequest)(nil),
(*MsgUpdateParamsRequest)(nil),
}

// createPaymentGetSignersFunc returns a custom GetSigners function for a Msg that has a signer in a Payment.
Expand Down Expand Up @@ -743,6 +744,10 @@ func (m MsgGovCloseMarketRequest) ValidateBasic() error {
}

func (m MsgGovUpdateParamsRequest) ValidateBasic() error {
return errors.New("deprecated and unusable")
}

func (m MsgUpdateParamsRequest) ValidateBasic() error {
errs := make([]error, 0, 2)
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
errs = append(errs, fmt.Errorf("invalid authority: %w", err))
Expand Down
Loading

0 comments on commit 4f3534d

Please sign in to comment.