-
Notifications
You must be signed in to change notification settings - Fork 6
/
genesis_utils.go
51 lines (44 loc) · 1.51 KB
/
genesis_utils.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
45
46
47
48
49
50
51
package cfevesting
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"time"
"github.com/chain4energy/c4e-chain/x/cfevesting/types"
)
func GenerateGenesisVestingTypes(numberOfVestingTypes int, startId int) []types.GenesisVestingType {
vts := GenerateVestingTypes(numberOfVestingTypes, startId)
result := []types.GenesisVestingType{}
for _, vt := range vts {
gvt := types.GenesisVestingType{
Name: vt.Name,
LockupPeriod: vt.LockupPeriod.Nanoseconds() / int64(time.Hour),
LockupPeriodUnit: types.Day,
VestingPeriod: vt.VestingPeriod.Nanoseconds() / int64(time.Hour),
VestingPeriodUnit: types.Day,
Free: sdk.MustNewDecFromStr("0.05"),
}
result = append(result, gvt)
}
return result
}
func GenerateGenesisVestingTypesForAccounVestingPools(accountVestingPools []*types.AccountVestingPools) []types.GenesisVestingType {
vt := GenerateVestingTypes(1, 1)[0]
m := make(map[string]types.GenesisVestingType)
result := []types.GenesisVestingType{}
for _, av := range accountVestingPools {
for _, v := range av.VestingPools {
gvt := types.GenesisVestingType{
Name: v.VestingType,
LockupPeriod: vt.LockupPeriod.Nanoseconds() / int64(time.Hour),
LockupPeriodUnit: types.Day,
VestingPeriod: vt.VestingPeriod.Nanoseconds() / int64(time.Hour),
VestingPeriodUnit: types.Day,
Free: sdk.MustNewDecFromStr("0.05"),
}
m[v.VestingType] = gvt
}
}
for _, gvt := range m {
result = append(result, gvt)
}
return result
}