github.com/okex/exchain@v1.8.0/libs/ibc-go/testing/simapp/adapter/staking/module.go (about)

     1  package staking
     2  
     3  import (
     4  	"encoding/json"
     5  	sdk "github.com/okex/exchain/libs/cosmos-sdk/types"
     6  	types2 "github.com/okex/exchain/libs/cosmos-sdk/x/staking/types"
     7  	"github.com/okex/exchain/libs/ibc-go/testing/simapp/adapter"
     8  	abci "github.com/okex/exchain/libs/tendermint/abci/types"
     9  	"github.com/okex/exchain/x/staking"
    10  	"github.com/okex/exchain/x/staking/types"
    11  )
    12  
    13  type StakingModule struct {
    14  	staking.AppModule
    15  
    16  	keeper       staking.Keeper
    17  	accKeeper    types.AccountKeeper
    18  	supplyKeeper types.SupplyKeeper
    19  }
    20  
    21  func TNewStakingModule(keeper staking.Keeper, accKeeper types.AccountKeeper,
    22  	supplyKeeper types.SupplyKeeper) StakingModule {
    23  
    24  	s := staking.NewAppModule(keeper, accKeeper, supplyKeeper)
    25  
    26  	return StakingModule{
    27  		s,
    28  		keeper,
    29  		accKeeper,
    30  		supplyKeeper,
    31  	}
    32  }
    33  
    34  func (s StakingModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
    35  	var genesisState staking.GenesisState
    36  	adapter.ModuleCdc.MustUnmarshalJSON(data, &genesisState)
    37  	genesisState.Params = types.DefaultParams()
    38  	genesisState.Params.UnbondingTime = types2.DefaultUnbondingTime
    39  
    40  	return staking.InitGenesis(ctx, s.keeper, s.accKeeper, s.supplyKeeper, genesisState)
    41  }