refactor: x/group 0.47 audit (#14290)
This commit is contained in:
parent
b634182ed5
commit
b46d838502
@ -57,7 +57,7 @@ func execFromString(execStr string) group.Exec {
|
||||
return exec
|
||||
}
|
||||
|
||||
// CLIProposal defines a Msg-based group proposal for CLI purposes.
|
||||
// Proposal defines a Msg-based group proposal for CLI purposes.
|
||||
type Proposal struct {
|
||||
GroupPolicyAddress string `json:"group_policy_address"`
|
||||
// Messages defines an array of sdk.Msgs proto-JSON-encoded as Anys.
|
||||
|
||||
@ -6,15 +6,15 @@ import (
|
||||
)
|
||||
|
||||
type AccountKeeper interface {
|
||||
// Return a new account with the next account number. Does not save the new account to the store.
|
||||
// NewAccount returns a new account with the next account number. Does not save the new account to the store.
|
||||
NewAccount(sdk.Context, authtypes.AccountI) authtypes.AccountI
|
||||
|
||||
// Retrieve an account from the store.
|
||||
// GetAccount retrieves an account from the store.
|
||||
GetAccount(sdk.Context, sdk.AccAddress) authtypes.AccountI
|
||||
|
||||
// Set an account in the store.
|
||||
// SetAccount sets an account in the store.
|
||||
SetAccount(sdk.Context, authtypes.AccountI)
|
||||
// Remove an account in the store.
|
||||
// RemoveAccount removes an account in the store.
|
||||
RemoveAccount(ctx sdk.Context, acc authtypes.AccountI)
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package keeper
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
@ -41,11 +42,11 @@ func (s Keeper) doExecuteMsgs(ctx sdk.Context, router *baseapp.MsgServiceRouter,
|
||||
for i, msg := range msgs {
|
||||
handler := s.router.Handler(msg)
|
||||
if handler == nil {
|
||||
return nil, sdkerrors.Wrapf(errors.ErrInvalid, "no message handler found for %q", sdk.MsgTypeURL(msg))
|
||||
return nil, errorsmod.Wrapf(errors.ErrInvalid, "no message handler found for %q", sdk.MsgTypeURL(msg))
|
||||
}
|
||||
r, err := handler(ctx, msg)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrapf(err, "message %s at position %d", sdk.MsgTypeURL(msg), i)
|
||||
return nil, errorsmod.Wrapf(err, "message %s at position %d", sdk.MsgTypeURL(msg), i)
|
||||
}
|
||||
// Handler should always return non-nil sdk.Result.
|
||||
if r == nil {
|
||||
@ -67,7 +68,7 @@ func ensureMsgAuthZ(msgs []sdk.Msg, groupPolicyAcc sdk.AccAddress) error {
|
||||
// but we prefer to loop through all GetSigners just to be sure.
|
||||
for _, acct := range msgs[i].GetSigners() {
|
||||
if !groupPolicyAcc.Equals(acct) {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "msg does not have group policy authorization; expected %s, got %s", groupPolicyAcc.String(), acct.String())
|
||||
return errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "msg does not have group policy authorization; expected %s, got %s", groupPolicyAcc.String(), acct.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
@ -17,9 +21,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/group/module"
|
||||
grouptestutil "github.com/cosmos/cosmos-sdk/x/group/testutil"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
|
||||
@ -9,9 +9,8 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
|
||||
modulev1 "cosmossdk.io/api/cosmos/group/module/v1"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/depinject"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/codec"
|
||||
errors "github.com/cosmos/cosmos-sdk/x/group/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/internal/math"
|
||||
)
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package group_test
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
||||
@ -8,13 +8,13 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
)
|
||||
|
||||
// extends `AccountKeeper` from expected_keepers.
|
||||
// AccountKeeper extends `AccountKeeper` from expected_keepers.
|
||||
type AccountKeeper interface {
|
||||
group.AccountKeeper
|
||||
}
|
||||
|
||||
// extends `BankKeeper` from expected_keepers.
|
||||
// extends bank `MsgServer` to mock `Send` and to register handlers in MsgServiceRouter
|
||||
// BankKeeper extends `BankKeeper` from expected_keepers and bank `MsgServer` to mock `Send` and
|
||||
// to register handlers in MsgServiceRouter
|
||||
type BankKeeper interface {
|
||||
group.BankKeeper
|
||||
bank.MsgServer
|
||||
|
||||
Loading…
Reference in New Issue
Block a user