-
Notifications
You must be signed in to change notification settings - Fork 40
/
genesis.go
40 lines (31 loc) · 846 Bytes
/
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
package deposit
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/sentinel-official/hub/x/deposit/keeper"
"github.com/sentinel-official/hub/x/deposit/types"
)
func InitGenesis(ctx sdk.Context, k keeper.Keeper, state types.GenesisState) {
for _, deposit := range state {
k.SetDeposit(ctx, deposit)
}
}
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
return k.GetDeposits(ctx, 0, 0)
}
func ValidateGenesis(state types.GenesisState) error {
for _, deposit := range state {
if err := deposit.Validate(); err != nil {
return err
}
}
deposits := make(map[string]bool)
for _, deposit := range state {
address := deposit.Address.String()
if deposits[address] {
return fmt.Errorf("found duplicate deposit address %s", address)
}
deposits[address] = true
}
return nil
}