Skip to content

Commit

Permalink
Merge branch 'main' into julien/nft-decouple-simapp
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Jun 13, 2022
2 parents db33df9 + b786d5d commit 1fee74c
Show file tree
Hide file tree
Showing 8 changed files with 643 additions and 14 deletions.
504 changes: 504 additions & 0 deletions api/cosmos/evidence/module/v1/module.pulsar.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions proto/cosmos/evidence/module/v1/module.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";

package cosmos.evidence.module.v1;

import "cosmos/app/v1alpha1/module.proto";

// Module is the config object of the evidence module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/cosmos/cosmos-sdk/x/evidence"
};
}
10 changes: 1 addition & 9 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func NewSimApp(
&app.NFTKeeper,
&app.SlashingKeeper,
&app.MintKeeper,
&app.EvidenceKeeper,
&msgServiceRouter,
); err != nil {
panic(err)
Expand All @@ -238,7 +239,6 @@ func NewSimApp(
distrtypes.StoreKey,
govtypes.StoreKey,
upgradetypes.StoreKey,
evidencetypes.StoreKey,
group.StoreKey,
)
// NOTE: The testingkey is just mounted for testing purposes. Actual applications should
Expand Down Expand Up @@ -296,13 +296,6 @@ func NewSimApp(
// set the governance module account as the authority for conducting upgrades
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, app.keys[upgradetypes.StoreKey], app.appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())

// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
app.appCodec, app.keys[evidencetypes.StoreKey], app.StakingKeeper, app.SlashingKeeper,
)
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper

/**** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
Expand All @@ -317,7 +310,6 @@ func NewSimApp(
gov.NewAppModule(app.appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
distr.NewAppModule(app.appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
groupmodule.NewAppModule(app.appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
); err != nil {
panic(err)
Expand Down
4 changes: 4 additions & 0 deletions simapp/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,7 @@ modules:
- name: mint
config:
"@type": cosmos.mint.module.v1.Module

- name: evidence
config:
"@type": cosmos.evidence.module.v1.Module
9 changes: 6 additions & 3 deletions x/evidence/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ package testutil
import (
"testing"

"github.com/cosmos/cosmos-sdk/testutil/network"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/x/evidence/testutil"
)

func TestIntegrationTestSuite(t *testing.T) {
cfg := network.DefaultConfig()
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg.NumValidators = 1
suite.Run(t, NewIntegrationTestSuite(cfg))
}
48 changes: 46 additions & 2 deletions x/evidence/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ import (
"fmt"
"math/rand"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"cosmossdk.io/core/appmodule"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/depinject"
"github.com/cosmos/cosmos-sdk/runtime"
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

modulev1 "cosmossdk.io/api/cosmos/evidence/module/v1"
eviclient "github.com/cosmos/cosmos-sdk/x/evidence/client"
"github.com/cosmos/cosmos-sdk/x/evidence/client/cli"
"github.com/cosmos/cosmos-sdk/x/evidence/keeper"
Expand Down Expand Up @@ -71,7 +77,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the evidence module.
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
panic(err)
}
Expand Down Expand Up @@ -203,3 +209,41 @@ func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
return nil
}

//
// New App Wiring Setup
//

func init() {
appmodule.Register(&modulev1.Module{},
appmodule.Provide(provideModuleBasic, provideModule),
)
}

func provideModuleBasic() runtime.AppModuleBasicWrapper {
return runtime.WrapAppModuleBasic(AppModuleBasic{})
}

type evidenceInputs struct {
depinject.In

Key *store.KVStoreKey
Cdc codec.Codec

StakingKeeper types.StakingKeeper
SlashingKeeper types.SlashingKeeper
}

type evidenceOutputs struct {
depinject.Out

EvidenceKeeper keeper.Keeper
Module runtime.AppModuleWrapper
}

func provideModule(in evidenceInputs) evidenceOutputs {
k := keeper.NewKeeper(in.Cdc, in.Key, in.StakingKeeper, in.SlashingKeeper)
m := NewAppModule(*k)

return evidenceOutputs{EvidenceKeeper: *k, Module: runtime.WrapAppModule(m)}
}
50 changes: 50 additions & 0 deletions x/evidence/testutil/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
modules:
- name: runtime
config:
"@type": cosmos.app.runtime.v1alpha1.Module

app_name: EvidenceApp

begin_blockers: [slashing, evidence, staking, auth, bank, genutil, params]
end_blockers: [staking, auth, bank, slashing, genutil, evidence, params]
init_genesis: [auth, bank, staking, slashing, genutil, evidence, params]

- name: auth
config:
"@type": cosmos.auth.module.v1.Module
bech32_prefix: cosmos
module_account_permissions:
- account: fee_collector
- account: bonded_tokens_pool
permissions: [burner, staking]
- account: not_bonded_tokens_pool
permissions: [burner, staking]
- account: nft

- name: bank
config:
"@type": cosmos.bank.module.v1.Module

- name: params
config:
"@type": cosmos.params.module.v1.Module

- name: tx
config:
"@type": cosmos.tx.module.v1.Module

- name: staking
config:
"@type": cosmos.staking.module.v1.Module

- name: slashing
config:
"@type": cosmos.slashing.module.v1.Module

- name: genutil
config:
"@type": cosmos.genutil.module.v1.Module

- name: evidence
config:
"@type": cosmos.evidence.module.v1.Module
20 changes: 20 additions & 0 deletions x/evidence/testutil/app_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package testutil

import (
_ "embed"

"cosmossdk.io/core/appconfig"
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/evidence"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/slashing"
_ "github.com/cosmos/cosmos-sdk/x/staking"
)

//go:embed app.yaml
var appConfig []byte

var AppConfig = appconfig.LoadYAML(appConfig)

0 comments on commit 1fee74c

Please sign in to comment.