diff --git a/app/app.go b/app/app.go index 37f821cea7..61bcf54f00 100644 --- a/app/app.go +++ b/app/app.go @@ -264,6 +264,7 @@ func GenModuleBasics() module.BasicManager { ibcfee.AppModuleBasic{}, evm.AppModuleBasic{}, feemarket.AppModuleBasic{}, + e2ee.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic gravity.AppModuleBasic{}, cronos.AppModuleBasic{}, @@ -751,6 +752,7 @@ func New( vestingtypes.ModuleName, cronostypes.ModuleName, consensusparamtypes.ModuleName, + e2eetypes.ModuleName, } endBlockersOrder := []string{ crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, @@ -774,6 +776,7 @@ func New( vestingtypes.ModuleName, cronostypes.ModuleName, consensusparamtypes.ModuleName, + e2eetypes.ModuleName, } // NOTE: The genutils module must occur after staking so that pools are // properly initialized with tokens from genesis accounts. diff --git a/app/upgrades.go b/app/upgrades.go index 6de0298728..ff49aa5d69 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -1,7 +1,10 @@ package app import ( + "fmt" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" diff --git a/x/e2ee/client/cli/encrypt.go b/x/e2ee/client/cli/encrypt.go index e6f7318aac..7800d30011 100644 --- a/x/e2ee/client/cli/encrypt.go +++ b/x/e2ee/client/cli/encrypt.go @@ -1,6 +1,7 @@ package cli import ( + "context" "errors" "io" "os" @@ -40,7 +41,7 @@ func EncryptCommand() *cobra.Command { // query encryption key from chain state client := types.NewQueryClient(clientCtx) - rsp, err := client.Keys(clientCtx.CmdContext, &types.KeysRequest{ + rsp, err := client.Keys(context.Background(), &types.KeysRequest{ Addresses: recs, }) if err != nil { diff --git a/x/e2ee/keeper/keeper.go b/x/e2ee/keeper/keeper.go index 343c46c517..131534e6fe 100644 --- a/x/e2ee/keeper/keeper.go +++ b/x/e2ee/keeper/keeper.go @@ -60,7 +60,7 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) var keys []types.EncryptionKeyEntry for ; iter.Valid(); iter.Next() { - address := sdk.AccAccress(iter.Key()).String() + address := sdk.AccAddress(iter.Key()).String() key := iter.Value() keys = append(keys, types.EncryptionKeyEntry{ Address: address, @@ -84,11 +84,11 @@ func (k Keeper) Keys(ctx context.Context, requests *types.KeysRequest) (*types.K store := sdk.UnwrapSDKContext(ctx).KVStore(k.storeKey) var rsp types.KeysResponse for _, address := range requests.Addresses { - bz, err := k.addressCodec.StringToBytes(address) + addr, err := sdk.AccAddressFromBech32(address) if err != nil { return nil, err } - value := store.Get(types.KeyPrefix(bz)) + value := store.Get(types.KeyPrefix(addr)) rsp.Keys = append(rsp.Keys, string(value)) } diff --git a/x/e2ee/keyring/keyring.go b/x/e2ee/keyring/keyring.go index 44b4bd6b8e..88332b5bf9 100644 --- a/x/e2ee/keyring/keyring.go +++ b/x/e2ee/keyring/keyring.go @@ -77,7 +77,7 @@ func New( PassPrefix: prefix, }) default: - return nil, errorsmod.Wrap(sdkkeyring.ErrUnknownBacked, backend) + return nil, fmt.Errorf("unknown keyring backend %v", backend) } if err != nil { @@ -148,7 +148,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) { for { failureCounter++ if failureCounter > maxPassphraseEntryAttempts { - return "", sdkkeyring.ErrMaxPassPhraseAttempts + return "", fmt.Errorf("too many failed passphrase attempts") } buf := bufio.NewReader(buf) diff --git a/x/e2ee/module.go b/x/e2ee/module.go index c91f233d6e..8b8ec9655f 100644 --- a/x/e2ee/module.go +++ b/x/e2ee/module.go @@ -21,10 +21,8 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ module.HasGenesisBasics = AppModuleBasic{} - _ module.HasName = AppModuleBasic{} + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} // this line is used by starport scaffolding # ibc/module/interface ) @@ -82,6 +80,16 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r } } +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return nil +} + // ---------------------------------------------------------------------------- // AppModule // ---------------------------------------------------------------------------- diff --git a/x/e2ee/types/msg.go b/x/e2ee/types/msg.go index a18c0b0b4b..3ca682ef08 100644 --- a/x/e2ee/types/msg.go +++ b/x/e2ee/types/msg.go @@ -6,6 +6,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +var ( + _ sdk.Msg = (*MsgRegisterEncryptionKey)(nil) +) + func (m *MsgRegisterEncryptionKey) ValidateBasic() error { if m.Address == "" { return fmt.Errorf("address cannot be empty") @@ -19,3 +23,11 @@ func (m *MsgRegisterEncryptionKey) ValidateBasic() error { } return nil } + +func (m *MsgRegisterEncryptionKey) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Address) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +}