feb9790325
* WIP : added bond module tx and query cli commands * added bond module invariant * update the go.mod * addressed the pr changes * update to proto files * refactor: move the proto package version from `v1` to `v1beta1` for vulcanize modules * updated the readme file for bond module * refactor: address the pr changes
41 lines
946 B
Go
41 lines
946 B
Go
package bond
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
"github.com/tharsis/ethermint/x/bond/keeper"
|
|
"github.com/tharsis/ethermint/x/bond/types"
|
|
)
|
|
|
|
// InitGenesis initializes genesis state based on exported genesis
|
|
func InitGenesis(
|
|
ctx sdk.Context,
|
|
k keeper.Keeper, data types.GenesisState) []abci.ValidatorUpdate {
|
|
|
|
k.SetParams(ctx, data.Params)
|
|
|
|
for _, bond := range data.Bonds {
|
|
k.SaveBond(ctx, bond)
|
|
}
|
|
|
|
return []abci.ValidatorUpdate{}
|
|
}
|
|
|
|
// ExportGenesis - output genesis parameters
|
|
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState {
|
|
params := keeper.GetParams(ctx)
|
|
bonds := keeper.ListBonds(ctx)
|
|
|
|
return types.GenesisState{Params: params, Bonds: bonds}
|
|
}
|
|
|
|
// ValidateGenesis - validating the genesis data
|
|
func ValidateGenesis(data types.GenesisState) error {
|
|
err := data.Params.Validate()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|