Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Apr 30, 2024
1 parent 50d2c54 commit 21533c7
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down Expand Up @@ -751,6 +752,7 @@ func New(
vestingtypes.ModuleName,
cronostypes.ModuleName,
consensusparamtypes.ModuleName,
e2eetypes.ModuleName,
}
endBlockersOrder := []string{
crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName,
Expand All @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion x/e2ee/client/cli/encrypt.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"context"
"errors"
"io"
"os"
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions x/e2ee/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))
}

Expand Down
4 changes: 2 additions & 2 deletions x/e2ee/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 12 additions & 4 deletions x/e2ee/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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
// ----------------------------------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions x/e2ee/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

var (

Check failure on line 9 in x/e2ee/types/msg.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

File is not `gofumpt`-ed (gofumpt)
_ sdk.Msg = (*MsgRegisterEncryptionKey)(nil)
)

func (m *MsgRegisterEncryptionKey) ValidateBasic() error {
if m.Address == "" {
return fmt.Errorf("address cannot be empty")
Expand All @@ -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}
}

0 comments on commit 21533c7

Please sign in to comment.