Skip to content

Commit

Permalink
chore: api cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Feb 23, 2024
1 parent 4b73e31 commit d12707b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 43 deletions.
22 changes: 0 additions & 22 deletions crypto/codec/cmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,3 @@ func ToCmtPubKeyInterface(pk cryptotypes.PubKey) (cmtcrypto.PubKey, error) {

return encoding.PubKeyFromProto(tmProtoPk)
}

// ----------------------

// Deprecated: use FromCmtProtoPublicKey instead.
func FromTmProtoPublicKey(protoPk cmtprotocrypto.PublicKey) (cryptotypes.PubKey, error) {
return FromCmtProtoPublicKey(protoPk)
}

// Deprecated: use ToCmtProtoPublicKey instead.
func ToTmProtoPublicKey(pk cryptotypes.PubKey) (cmtprotocrypto.PublicKey, error) {
return ToCmtProtoPublicKey(pk)
}

// Deprecated: use FromCmtPubKeyInterface instead.
func FromTmPubKeyInterface(tmPk cmtcrypto.PubKey) (cryptotypes.PubKey, error) {
return FromCmtPubKeyInterface(tmPk)
}

// Deprecated: use ToCmtPubKeyInterface instead.
func ToTmPubKeyInterface(pk cryptotypes.PubKey) (cmtcrypto.PubKey, error) {
return ToCmtPubKeyInterface(pk)
}
16 changes: 4 additions & 12 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ type HasConsensusVersion interface {
ConsensusVersion() uint64
}

// HasABCIEndblock is a released typo of HasABCIEndBlock.
// Deprecated: use HasABCIEndBlock instead.
type HasABCIEndblock HasABCIEndBlock

// HasABCIEndBlock is the interface for modules that need to run code at the end of the block.
type HasABCIEndBlock interface {
AppModule
Expand All @@ -140,7 +136,7 @@ type HasABCIEndBlock interface {
// Manager defines a module manager that provides the high level utility for managing and executing
// operations for a group of modules
type Manager struct {
Modules map[string]interface{} // interface{} is used now to support the legacy AppModule as well as new core appmodule.AppModule.
Modules map[string]appmodule.AppModule
OrderInitGenesis []string
OrderExportGenesis []string
OrderPreBlockers []string
Expand All @@ -153,7 +149,7 @@ type Manager struct {

// NewManager creates a new Manager object.
func NewManager(modules ...AppModule) *Manager {
moduleMap := make(map[string]interface{})
moduleMap := make(map[string]appmodule.AppModule)
modulesStr := make([]string, 0, len(modules))
preBlockModulesStr := make([]string, 0)
for _, module := range modules {
Expand Down Expand Up @@ -183,7 +179,7 @@ func NewManager(modules ...AppModule) *Manager {
// NewManagerFromMap creates a new Manager object from a map of module names to module implementations.
// This method should be used for apps and modules which have migrated to the cosmossdk.io/core.appmodule.AppModule API.
func NewManagerFromMap(moduleMap map[string]appmodule.AppModule) *Manager {
simpleModuleMap := make(map[string]interface{})
simpleModuleMap := make(map[string]appmodule.AppModule)
modulesStr := make([]string, 0, len(simpleModuleMap))
preBlockModulesStr := make([]string, 0)
for name, module := range moduleMap {
Expand Down Expand Up @@ -767,12 +763,8 @@ func (m *Manager) EndBlock(ctx sdk.Context) (sdk.EndBlock, error) {
return sdk.EndBlock{}, errors.New("validator EndBlock updates already set by a previous module")
}

for _, updates := range moduleValUpdates {
validatorUpdates = append(validatorUpdates, abci.ValidatorUpdate{PubKey: updates.PubKey, Power: updates.Power})
}
validatorUpdates = append(validatorUpdates, moduleValUpdates...)
}
} else {
continue
}
}

Expand Down
5 changes: 3 additions & 2 deletions types/module/module_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"sort"
"testing"

"cosmossdk.io/core/appmodule"
"github.com/stretchr/testify/suite"
)

Expand All @@ -17,7 +18,7 @@ type TestSuite struct {

func (s *TestSuite) TestAssertNoForgottenModules() {
m := Manager{
Modules: map[string]interface{}{"a": nil, "b": nil},
Modules: map[string]appmodule.AppModule{"a": nil, "b": nil},
}
tcs := []struct {
name string
Expand All @@ -42,7 +43,7 @@ func (s *TestSuite) TestAssertNoForgottenModules() {

func (s *TestSuite) TestModuleNames() {
m := Manager{
Modules: map[string]interface{}{"a": nil, "b": nil},
Modules: map[string]appmodule.AppModule{"a": nil, "b": nil},
}
ms := m.ModuleNames()
sort.Strings(ms)
Expand Down
3 changes: 1 addition & 2 deletions x/staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ func (am AppModule) BeginBlock(ctx context.Context) error {
return am.keeper.BeginBlocker(ctx)
}

// EndBlock returns the end blocker for the staking module. It returns no validator
// updates.
// EndBlock returns the end blocker for the staking module.
func (am AppModule) EndBlock(ctx context.Context) ([]abci.ValidatorUpdate, error) {
return am.keeper.EndBlocker(ctx)
}
5 changes: 0 additions & 5 deletions x/staking/types/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,6 @@ func (v Validator) ConsPubKey() (cryptotypes.PubKey, error) {
return pk, nil
}

// Deprecated: use CmtConsPublicKey instead
func (v Validator) TmConsPublicKey() (cmtprotocrypto.PublicKey, error) {
return v.CmtConsPublicKey()
}

// CmtConsPublicKey casts Validator.ConsensusPubkey to cmtprotocrypto.PubKey.
func (v Validator) CmtConsPublicKey() (cmtprotocrypto.PublicKey, error) {
pk, err := v.ConsPubKey()
Expand Down

0 comments on commit d12707b

Please sign in to comment.