Skip to content

Commit

Permalink
Merge pull request #134 from onomyprotocol/dong/updatewithaddress.Codec
Browse files Browse the repository at this point in the history
update psm: use address.Codec of accountkeeper
  • Loading branch information
DongLieu authored Jan 14, 2025
2 parents b5245d9 + 372a94f commit fda7329
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
8 changes: 1 addition & 7 deletions x/psm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"context"

"cosmossdk.io/collections"
"cosmossdk.io/core/address"
"cosmossdk.io/core/store"
"cosmossdk.io/log"
"cosmossdk.io/math"
Expand All @@ -20,7 +19,6 @@ import (
type (
Keeper struct {
cdc codec.BinaryCodec
addressCodec address.Codec
storeService store.KVStoreService
logger log.Logger

Expand All @@ -42,9 +40,7 @@ type (

func NewKeeper(
cdc codec.BinaryCodec,
// addressCodec address.Codec,
storeService store.KVStoreService,
// logger log.Logger,
authority string,

bankKeeper types.BankKeeper,
Expand All @@ -58,11 +54,9 @@ func NewKeeper(
sb := collections.NewSchemaBuilder(storeService)

k := Keeper{
cdc: cdc,
// addressCodec: addressCodec,
cdc: cdc,
storeService: storeService,
authority: authority,
// logger: logger,

BankKeeper: bankKeeper,
AccountKeeper: accountKeeper,
Expand Down
2 changes: 1 addition & 1 deletion x/psm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {
var _ types.MsgServer = msgServer{}

func (k msgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
if _, err := k.keeper.addressCodec.StringToBytes(req.Authority); err != nil {
if _, err := k.keeper.AccountKeeper.AddressCodec().StringToBytes(req.Authority); err != nil {
return nil, errorsmod.Wrap(err, "invalid authority address")
}

Expand Down
2 changes: 2 additions & 0 deletions x/psm/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package types
import (
"context"

addresscodec "cosmossdk.io/core/address"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// AccountKeeper defines the expected interface for the Account module.
type AccountKeeper interface {
AddressCodec() addresscodec.Codec
GetAccount(context.Context, sdk.AccAddress) sdk.AccountI // only used for simulation
GetModuleAddress(name string) sdk.AccAddress
// Methods imported from account should be defined here
Expand Down

0 comments on commit fda7329

Please sign in to comment.