From dab97ed352f697828b16e2a28254c8ba4668e1ee Mon Sep 17 00:00:00 2001 From: Marko Date: Wed, 12 Jul 2023 17:09:02 +0200 Subject: [PATCH] chore: remove unused getsigner functions (#16937) --- x/auth/types/msgs.go | 13 ---- x/auth/vesting/types/msgs.go | 21 ------ x/bank/types/msgs_test.go | 8 --- x/circuit/types/msgs.go | 18 ----- x/crisis/types/msgs.go | 13 ---- x/gov/types/v1beta1/msgs.go | 6 -- x/group/msgs.go | 125 ++--------------------------------- x/slashing/types/msg.go | 12 ---- 8 files changed, 5 insertions(+), 211 deletions(-) delete mode 100644 x/auth/types/msgs.go diff --git a/x/auth/types/msgs.go b/x/auth/types/msgs.go deleted file mode 100644 index 8beea7684e68..000000000000 --- a/x/auth/types/msgs.go +++ /dev/null @@ -1,13 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ sdk.Msg = &MsgUpdateParams{} - -// GetSigners returns the expected signers for a MsgUpdateParams message. -func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { - addr, _ := sdk.AccAddressFromBech32(msg.Authority) - return []sdk.AccAddress{addr} -} diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index 3d31b05bb26d..296fa8845921 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -21,12 +21,6 @@ func NewMsgCreateVestingAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coin } } -// GetSigners returns the expected signers for a MsgCreateVestingAccount. -func (msg MsgCreateVestingAccount) GetSigners() []sdk.AccAddress { - addr, _ := sdk.AccAddressFromBech32(msg.FromAddress) - return []sdk.AccAddress{addr} -} - // NewMsgCreatePermanentLockedAccount returns a reference to a new MsgCreatePermanentLockedAccount. func NewMsgCreatePermanentLockedAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgCreatePermanentLockedAccount { return &MsgCreatePermanentLockedAccount{ @@ -36,12 +30,6 @@ func NewMsgCreatePermanentLockedAccount(fromAddr, toAddr sdk.AccAddress, amount } } -// GetSigners returns the expected signers for a MsgCreatePermanentLockedAccount. -func (msg MsgCreatePermanentLockedAccount) GetSigners() []sdk.AccAddress { - from, _ := sdk.AccAddressFromBech32(msg.FromAddress) - return []sdk.AccAddress{from} -} - // NewMsgCreatePeriodicVestingAccount returns a reference to a new MsgCreatePeriodicVestingAccount. func NewMsgCreatePeriodicVestingAccount(fromAddr, toAddr sdk.AccAddress, startTime int64, periods []Period) *MsgCreatePeriodicVestingAccount { return &MsgCreatePeriodicVestingAccount{ @@ -51,12 +39,3 @@ func NewMsgCreatePeriodicVestingAccount(fromAddr, toAddr sdk.AccAddress, startTi VestingPeriods: periods, } } - -// GetSigners returns the expected signers for a MsgCreatePeriodicVestingAccount. -func (msg MsgCreatePeriodicVestingAccount) GetSigners() []sdk.AccAddress { - from, err := sdk.AccAddressFromBech32(msg.FromAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{from} -} diff --git a/x/bank/types/msgs_test.go b/x/bank/types/msgs_test.go index 2b2b6d35e53f..98fc399b67c6 100644 --- a/x/bank/types/msgs_test.go +++ b/x/bank/types/msgs_test.go @@ -133,14 +133,6 @@ func TestNewMsgSetSendEnabled(t *testing.T) { } } -func TestMsgSendGetSigners(t *testing.T) { - from := sdk.AccAddress([]byte("input111111111111111")) - msg := NewMsgSend(from, sdk.AccAddress{}, sdk.NewCoins()) - res := msg.GetSigners() - require.Equal(t, 1, len(res)) - require.True(t, from.Equals(res[0])) -} - func TestMsgSetSendEnabledGetSignBytes(t *testing.T) { msg := NewMsgSetSendEnabled("cartman", []*SendEnabled{{"casafiestacoin", false}, {"kylecoin", true}}, nil) expected := `{"type":"cosmos-sdk/MsgSetSendEnabled","value":{"authority":"cartman","send_enabled":[{"denom":"casafiestacoin"},{"denom":"kylecoin","enabled":true}]}}` diff --git a/x/circuit/types/msgs.go b/x/circuit/types/msgs.go index 0f23cf14cb6a..0e39b00c5f6b 100644 --- a/x/circuit/types/msgs.go +++ b/x/circuit/types/msgs.go @@ -19,12 +19,6 @@ func NewMsgAuthorizeCircuitBreaker(granter, grantee string, permission *Permissi } } -// Route Implements Msg. -func (m MsgAuthorizeCircuitBreaker) Route() string { return sdk.MsgTypeURL(&m) } - -// Type Implements Msg. -func (m MsgAuthorizeCircuitBreaker) Type() string { return sdk.MsgTypeURL(&m) } - // NewMsgTripCircuitBreaker creates a new MsgTripCircuitBreaker instance. func NewMsgTripCircuitBreaker(authority string, urls []string) *MsgTripCircuitBreaker { return &MsgTripCircuitBreaker{ @@ -33,12 +27,6 @@ func NewMsgTripCircuitBreaker(authority string, urls []string) *MsgTripCircuitBr } } -// Route Implements Msg. -func (m MsgTripCircuitBreaker) Route() string { return sdk.MsgTypeURL(&m) } - -// Type Implements Msg. -func (m MsgTripCircuitBreaker) Type() string { return sdk.MsgTypeURL(&m) } - // NewMsgResetCircuitBreaker creates a new MsgResetCircuitBreaker instance. func NewMsgResetCircuitBreaker(authority string, urls []string) *MsgResetCircuitBreaker { return &MsgResetCircuitBreaker{ @@ -46,9 +34,3 @@ func NewMsgResetCircuitBreaker(authority string, urls []string) *MsgResetCircuit MsgTypeUrls: urls, } } - -// Route Implements Msg. -func (m MsgResetCircuitBreaker) Route() string { return sdk.MsgTypeURL(&m) } - -// Type Implements Msg. -func (m MsgResetCircuitBreaker) Type() string { return sdk.MsgTypeURL(&m) } diff --git a/x/crisis/types/msgs.go b/x/crisis/types/msgs.go index 9d2e3c7350ae..b62eaaf023a0 100644 --- a/x/crisis/types/msgs.go +++ b/x/crisis/types/msgs.go @@ -18,20 +18,7 @@ func NewMsgVerifyInvariant(sender sdk.AccAddress, invModeName, invRoute string) } } -// get the bytes for the message signer to sign on -func (msg MsgVerifyInvariant) GetSigners() []sdk.AccAddress { - sender, _ := sdk.AccAddressFromBech32(msg.Sender) - return []sdk.AccAddress{sender} -} - // FullInvariantRoute - get the messages full invariant route func (msg MsgVerifyInvariant) FullInvariantRoute() string { return msg.InvariantModuleName + "/" + msg.InvariantRoute } - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { - authority, _ := sdk.AccAddressFromBech32(msg.Authority) - return []sdk.AccAddress{authority} -} diff --git a/x/gov/types/v1beta1/msgs.go b/x/gov/types/v1beta1/msgs.go index ddcce3ed6405..1f8a62019f05 100644 --- a/x/gov/types/v1beta1/msgs.go +++ b/x/gov/types/v1beta1/msgs.go @@ -39,12 +39,6 @@ func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sd // GetInitialDeposit returns the initial deposit of MsgSubmitProposal. func (m *MsgSubmitProposal) GetInitialDeposit() sdk.Coins { return m.InitialDeposit } -// GetProposer returns the proposer address of MsgSubmitProposal. -func (m *MsgSubmitProposal) GetProposer() sdk.AccAddress { - proposer, _ := sdk.AccAddressFromBech32(m.Proposer) - return proposer -} - // GetContent returns the content of MsgSubmitProposal. func (m *MsgSubmitProposal) GetContent() Content { content, ok := m.Content.GetCachedValue().(Content) diff --git a/x/group/msgs.go b/x/group/msgs.go index e8b58534923e..59793d79adb3 100644 --- a/x/group/msgs.go +++ b/x/group/msgs.go @@ -3,8 +3,6 @@ package group import ( "github.com/cosmos/gogoproto/proto" - errorsmod "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -34,49 +32,21 @@ var ( _ types.UnpackInterfacesMessage = MsgCreateGroupWithPolicy{} ) -// GetSigners returns the expected signers for a MsgCreateGroup. -func (m MsgCreateGroup) GetSigners() []sdk.AccAddress { - admin := sdk.MustAccAddressFromBech32(m.Admin) - - return []sdk.AccAddress{admin} -} - -// GetSigners returns the expected signers for a MsgUpdateGroupAdmin. -func (m MsgUpdateGroupAdmin) GetSigners() []sdk.AccAddress { - admin := sdk.MustAccAddressFromBech32(m.Admin) - - return []sdk.AccAddress{admin} -} - -// GetGroupID gets the group id of the MsgUpdateGroupAdmin. -func (m *MsgUpdateGroupAdmin) GetGroupID() uint64 { - return m.GroupId -} - -// GetSigners returns the expected signers for a MsgUpdateGroupMetadata. -func (m MsgUpdateGroupMetadata) GetSigners() []sdk.AccAddress { - admin := sdk.MustAccAddressFromBech32(m.Admin) - - return []sdk.AccAddress{admin} -} - // GetGroupID gets the group id of the MsgUpdateGroupMetadata. func (m *MsgUpdateGroupMetadata) GetGroupID() uint64 { return m.GroupId } -// GetSigners returns the expected signers for a MsgUpdateGroupMembers. -func (m MsgUpdateGroupMembers) GetSigners() []sdk.AccAddress { - admin := sdk.MustAccAddressFromBech32(m.Admin) - - return []sdk.AccAddress{admin} -} - // GetGroupID gets the group id of the MsgUpdateGroupMembers. func (m *MsgUpdateGroupMembers) GetGroupID() uint64 { return m.GroupId } +// GetGroupID gets the group id of the MsgUpdateGroupAdmin. +func (m *MsgUpdateGroupAdmin) GetGroupID() uint64 { + return m.GroupId +} + // NewMsgCreateGroupWithPolicy creates a new MsgCreateGroupWithPolicy. func NewMsgCreateGroupWithPolicy(admin string, members []MemberRequest, groupMetadata, groupPolicyMetadata string, groupPolicyAsAdmin bool, decisionPolicy DecisionPolicy) (*MsgCreateGroupWithPolicy, error) { m := &MsgCreateGroupWithPolicy{ @@ -118,25 +88,6 @@ func (m MsgCreateGroupWithPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) e return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } -// GetSigners returns the expected signers for a MsgCreateGroupWithPolicy. -func (m MsgCreateGroupWithPolicy) GetSigners() []sdk.AccAddress { - admin := sdk.MustAccAddressFromBech32(m.Admin) - return []sdk.AccAddress{admin} -} - -// GetSigners returns the expected signers for a MsgCreateGroupPolicy. -func (m MsgCreateGroupPolicy) GetSigners() []sdk.AccAddress { - admin := sdk.MustAccAddressFromBech32(m.Admin) - return []sdk.AccAddress{admin} -} - -// GetSigners returns the expected signers for a MsgUpdateGroupPolicyAdmin. -func (m MsgUpdateGroupPolicyAdmin) GetSigners() []sdk.AccAddress { - admin := sdk.MustAccAddressFromBech32(m.Admin) - - return []sdk.AccAddress{admin} -} - // NewMsgUpdateGroupPolicyDecisionPolicy creates a new MsgUpdateGroupPolicyDecisionPolicy. func NewMsgUpdateGroupPolicyDecisionPolicy(admin, address sdk.AccAddress, decisionPolicy DecisionPolicy) (*MsgUpdateGroupPolicyDecisionPolicy, error) { m := &MsgUpdateGroupPolicyDecisionPolicy{ @@ -164,13 +115,6 @@ func (m *MsgUpdateGroupPolicyDecisionPolicy) SetDecisionPolicy(decisionPolicy De return nil } -// GetSigners returns the expected signers for a MsgUpdateGroupPolicyDecisionPolicy. -func (m MsgUpdateGroupPolicyDecisionPolicy) GetSigners() []sdk.AccAddress { - admin := sdk.MustAccAddressFromBech32(m.Admin) - - return []sdk.AccAddress{admin} -} - // GetDecisionPolicy gets the decision policy of MsgUpdateGroupPolicyDecisionPolicy. func (m *MsgUpdateGroupPolicyDecisionPolicy) GetDecisionPolicy() (DecisionPolicy, error) { decisionPolicy, ok := m.DecisionPolicy.GetCachedValue().(DecisionPolicy) @@ -187,13 +131,6 @@ func (m MsgUpdateGroupPolicyDecisionPolicy) UnpackInterfaces(unpacker types.AnyU return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } -// GetSigners returns the expected signers for a MsgUpdateGroupPolicyMetadata. -func (m MsgUpdateGroupPolicyMetadata) GetSigners() []sdk.AccAddress { - admin := sdk.MustAccAddressFromBech32(m.Admin) - - return []sdk.AccAddress{admin} -} - // NewMsgCreateGroupPolicy creates a new MsgCreateGroupPolicy. func NewMsgCreateGroupPolicy(admin sdk.AccAddress, group uint64, metadata string, decisionPolicy DecisionPolicy) (*MsgCreateGroupPolicy, error) { m := &MsgCreateGroupPolicy{ @@ -265,30 +202,6 @@ func NewMsgSubmitProposal(address string, proposers []string, msgs []sdk.Msg, me return m, nil } -// GetSigners returns the expected signers for a MsgSubmitProposal. -func (m MsgSubmitProposal) GetSigners() []sdk.AccAddress { - addrs, err := m.getProposerAccAddresses() - if err != nil { - panic(err) - } - - return addrs -} - -// getProposerAccAddresses returns the proposers as `[]sdk.AccAddress`. -func (m *MsgSubmitProposal) getProposerAccAddresses() ([]sdk.AccAddress, error) { - addrs := make([]sdk.AccAddress, len(m.Proposers)) - for i, proposer := range m.Proposers { - addr, err := sdk.AccAddressFromBech32(proposer) - if err != nil { - return nil, errorsmod.Wrap(err, "proposers") - } - addrs[i] = addr - } - - return addrs, nil -} - // SetMsgs packs msgs into Any's func (m *MsgSubmitProposal) SetMsgs(msgs []sdk.Msg) error { anys, err := tx.SetMsgs(msgs) @@ -308,31 +221,3 @@ func (m MsgSubmitProposal) GetMsgs() ([]sdk.Msg, error) { func (m MsgSubmitProposal) UnpackInterfaces(unpacker types.AnyUnpacker) error { return tx.UnpackInterfaces(unpacker, m.Messages) } - -// GetSigners returns the expected signers for a MsgWithdrawProposal. -func (m MsgWithdrawProposal) GetSigners() []sdk.AccAddress { - admin := sdk.MustAccAddressFromBech32(m.Address) - - return []sdk.AccAddress{admin} -} - -// GetSigners returns the expected signers for a MsgVote. -func (m MsgVote) GetSigners() []sdk.AccAddress { - addr := sdk.MustAccAddressFromBech32(m.Voter) - - return []sdk.AccAddress{addr} -} - -// GetSigners returns the expected signers for a MsgExec. -func (m MsgExec) GetSigners() []sdk.AccAddress { - signer := sdk.MustAccAddressFromBech32(m.Executor) - - return []sdk.AccAddress{signer} -} - -// GetSigners returns the expected signers for a MsgLeaveGroup -func (m MsgLeaveGroup) GetSigners() []sdk.AccAddress { - signer := sdk.MustAccAddressFromBech32(m.Address) - - return []sdk.AccAddress{signer} -} diff --git a/x/slashing/types/msg.go b/x/slashing/types/msg.go index ed2604e6257e..d70bb2d3c046 100644 --- a/x/slashing/types/msg.go +++ b/x/slashing/types/msg.go @@ -16,15 +16,3 @@ func NewMsgUnjail(validatorAddr sdk.ValAddress) *MsgUnjail { ValidatorAddr: validatorAddr.String(), } } - -// GetSigners returns the expected signers for MsgUnjail. -func (msg MsgUnjail) GetSigners() []sdk.AccAddress { - valAddr, _ := sdk.ValAddressFromBech32(msg.ValidatorAddr) - return []sdk.AccAddress{sdk.AccAddress(valAddr)} -} - -// GetSigners returns the expected signers for a MsgUpdateParams message. -func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { - addr, _ := sdk.AccAddressFromBech32(msg.Authority) - return []sdk.AccAddress{addr} -}