Skip to content

Commit

Permalink
refactor: rename pkr module to pubkey module
Browse files Browse the repository at this point in the history
chore: add missing proto files and lint

test: improve add key msg validation and unit tests

fix: use comet private key type to save to file

style: lint

refactor: replace some user defined errors with sdk ones
  • Loading branch information
hacheigriega committed Sep 5, 2024
1 parent 3600fe3 commit e3f9d5e
Show file tree
Hide file tree
Showing 36 changed files with 586 additions and 376 deletions.
24 changes: 12 additions & 12 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ import (
dataproxy "github.com/sedaprotocol/seda-chain/x/data-proxy"
dataproxykeeper "github.com/sedaprotocol/seda-chain/x/data-proxy/keeper"
dataproxytypes "github.com/sedaprotocol/seda-chain/x/data-proxy/types"
"github.com/sedaprotocol/seda-chain/x/pkr"
pkrkeeper "github.com/sedaprotocol/seda-chain/x/pkr/keeper"
pkrtypes "github.com/sedaprotocol/seda-chain/x/pkr/types"
"github.com/sedaprotocol/seda-chain/x/pubkey"
pubkeykeeper "github.com/sedaprotocol/seda-chain/x/pubkey/keeper"
pubkeytypes "github.com/sedaprotocol/seda-chain/x/pubkey/types"
"github.com/sedaprotocol/seda-chain/x/staking"
stakingkeeper "github.com/sedaprotocol/seda-chain/x/staking/keeper"
"github.com/sedaprotocol/seda-chain/x/tally"
Expand Down Expand Up @@ -186,7 +186,7 @@ var (
ibcfee.AppModuleBasic{},
transfer.AppModuleBasic{},
wasmstorage.AppModuleBasic{},
pkr.AppModuleBasic{},
pubkey.AppModuleBasic{},
ica.AppModuleBasic{},
crisis.AppModuleBasic{},
packetforward.AppModuleBasic{},
Expand Down Expand Up @@ -250,7 +250,7 @@ type App struct {
WasmStorageKeeper wasmstoragekeeper.Keeper
TallyKeeper tallykeeper.Keeper
DataProxyKeeper dataproxykeeper.Keeper
PkrKeeper pkrkeeper.Keeper
PubKeyKeeper pubkeykeeper.Keeper

mm *module.Manager
bmm module.BasicManager
Expand Down Expand Up @@ -315,7 +315,7 @@ func NewApp(
feegrant.StoreKey, evidencetypes.StoreKey, circuittypes.StoreKey, authzkeeper.StoreKey, group.StoreKey,
capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey,
wasmtypes.StoreKey, icahosttypes.StoreKey, icacontrollertypes.StoreKey, packetforwardtypes.StoreKey,
crisistypes.StoreKey, wasmstoragetypes.StoreKey, dataproxytypes.StoreKey, pkrtypes.StoreKey,
crisistypes.StoreKey, wasmstoragetypes.StoreKey, dataproxytypes.StoreKey, pubkeytypes.StoreKey,
)

memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -635,9 +635,9 @@ func NewApp(
app.TallyKeeper = tallykeeper.NewKeeper(app.WasmStorageKeeper, contractKeeper, app.WasmKeeper)

app.DataProxyKeeper = *dataproxykeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[dataproxytypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.PkrKeeper = *pkrkeeper.NewKeeper(
app.PubKeyKeeper = *pubkeykeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[pkrtypes.StoreKey]),
runtime.NewKVStoreService(keys[pubkeytypes.StoreKey]),
app.StakingKeeper,
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
)
Expand Down Expand Up @@ -756,7 +756,7 @@ func NewApp(
wasmstorage.NewAppModule(appCodec, app.WasmStorageKeeper),
tally.NewAppModule(app.TallyKeeper),
dataproxy.NewAppModule(appCodec, app.DataProxyKeeper),
pkr.NewAppModule(appCodec, app.PkrKeeper),
pubkey.NewAppModule(appCodec, app.PubKeyKeeper),
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, nil), // always be last to make sure that it checks for all invariants and not only part of them
)

Expand Down Expand Up @@ -814,7 +814,7 @@ func NewApp(
wasmstoragetypes.ModuleName,
tallytypes.ModuleName,
dataproxytypes.ModuleName,
pkrtypes.ModuleName,
pubkeytypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand Down Expand Up @@ -846,7 +846,7 @@ func NewApp(
wasmstoragetypes.ModuleName,
tallytypes.ModuleName,
dataproxytypes.ModuleName,
pkrtypes.ModuleName,
pubkeytypes.ModuleName,
)

// NOTE: The genutils module must occur after sdkstaking so that pools are
Expand Down Expand Up @@ -884,7 +884,7 @@ func NewApp(
wasmstoragetypes.ModuleName,
tallytypes.ModuleName,
dataproxytypes.ModuleName,
pkrtypes.ModuleName,
pubkeytypes.ModuleName,
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
app.mm.SetOrderExportGenesis(genesisModuleOrder...)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
syntax = "proto3";
package sedachain.pkr.v1;
package sedachain.pubkey.v1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "sedachain/pkr/v1/pkr.proto";
import "sedachain/pubkey/v1/pubkey.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/pkr/types";
option go_package = "github.com/sedaprotocol/seda-chain/x/pubkey/types";

// GenesisState defines pkr module's genesis state.
// GenesisState defines pubkey module's genesis state.
message GenesisState {
repeated ValidatorPubKeys validator_pub_keys = 1 [(gogoproto.nullable) = false];
}

// ValidatorPubKeys defines a validator's list of registered public keys
// primarily used in the x/pkr genesis state.
// primarily used in the x/pubkey genesis state.
message ValidatorPubKeys {
string validator_addr = 1 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];
repeated IndexedPubKey indexed_pub_keys = 2 [(gogoproto.nullable) = false];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
syntax = "proto3";
package sedachain.pkr.v1;
package sedachain.pubkey.v1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/pkr/types";
option go_package = "github.com/sedaprotocol/seda-chain/x/pubkey/types";

// IndexPubKeyPair defines an index - public key pair.
message IndexedPubKey {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
syntax = "proto3";
package sedachain.pkr.v1;
package sedachain.pubkey.v1;

import "google/api/annotations.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "sedachain/pkr/v1/genesis.proto";
import "sedachain/pubkey/v1/genesis.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/pkr/types";
option go_package = "github.com/sedaprotocol/seda-chain/x/pubkey/types";

// Query defines the gRPC querier service.
service Query {
// ValidatorKeys returns a given validator's registered keys.
rpc ValidatorKeys(QueryValidatorKeysRequest)
returns (QueryValidatorKeysResponse) {
option (google.api.http).get = "/seda-chain/pkr/validator_keys/{validator_addr}";
option (google.api.http).get = "/seda-chain/pubkey/validator_keys/{validator_addr}";
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
syntax = "proto3";
package sedachain.pkr.v1;
package sedachain.pubkey.v1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "sedachain/pkr/v1/pkr.proto";
import "sedachain/pubkey/v1/pubkey.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/pkr/types";
option go_package = "github.com/sedaprotocol/seda-chain/x/pubkey/types";

// Msg defines the pkr Msg service.
// Msg defines the pubkey Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;

Expand Down
2 changes: 1 addition & 1 deletion scripts/mockgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ fi
# Generate mocks for the given package
$mockgen_cmd -source=$GOPATH/pkg/mod/github.com/\!cosm\!wasm/wasmd@v0.50.0/x/wasm/types/exported_keepers.go -package testutil -destination x/wasm-storage/keeper/testutil/wasm_keepers_mock.go
$mockgen_cmd -source=x/wasm-storage/types/expected_keepers.go -package testutil -destination x/wasm-storage/keeper/testutil/expected_keepers_mock.go
$mockgen_cmd -source=x/pkr/types/expected_keepers.go -package testutil -destination x/pkr/keeper/testutil/expected_keepers_mock.go
$mockgen_cmd -source=x/pubkey/types/expected_keepers.go -package testutil -destination x/pubkey/keeper/testutil/expected_keepers_mock.go
87 changes: 0 additions & 87 deletions x/pkr/keeper/msg_server_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions x/pkr/types/errors.go

This file was deleted.

4 changes: 2 additions & 2 deletions x/pkr/client/cli/query.go → x/pubkey/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"

"github.com/sedaprotocol/seda-chain/x/pkr/types"
"github.com/sedaprotocol/seda-chain/x/pubkey/types"
)

// GetQueryCmd returns the CLI query commands for this module
func GetQueryCmd(_ string) *cobra.Command {
func GetQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
Expand Down
Loading

0 comments on commit e3f9d5e

Please sign in to comment.