/
genesis.go
44 lines (37 loc) · 1.02 KB
/
genesis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package vstorage
import (
"fmt"
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
)
func NewGenesisState() *types.GenesisState {
return &types.GenesisState{
Data: []*types.DataEntry{},
}
}
func ValidateGenesis(data *types.GenesisState) error {
if data == nil {
return nil
}
for _, entry := range data.Data {
if err := types.ValidatePath(entry.Path); err != nil {
return fmt.Errorf("genesis vstorage.data entry %q has invalid path format: %s", entry.Path, err)
}
}
return nil
}
func DefaultGenesisState() *types.GenesisState {
return &types.GenesisState{
Data: []*types.DataEntry{},
}
}
func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) []abci.ValidatorUpdate {
keeper.ImportStorage(ctx, data.Data)
return []abci.ValidatorUpdate{}
}
func ExportGenesis(ctx sdk.Context, keeper Keeper) *types.GenesisState {
gs := NewGenesisState()
gs.Data = keeper.ExportStorage(ctx)
return gs
}