/
module.go
74 lines (58 loc) · 2.17 KB
/
module.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package app
import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/cosmos/cosmos-sdk/x/mint"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/celinium-network/celinium/app/params"
)
// bankModule defines a custom wrapper around the x/bank module's AppModuleBasic
// implementation to provide custom default genesis state.
var DefaultUnbondingTime = stakingtypes.DefaultUnbondingTime
type bankModule struct {
bank.AppModuleBasic
}
// DefaultGenesis returns custom x/bank module genesis state.
func (bankModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
genState := banktypes.DefaultGenesisState()
return cdc.MustMarshalJSON(genState)
}
// stakingModule wraps the x/staking module in order to overwrite specific
// ModuleManager APIs.
type stakingModule struct {
staking.AppModuleBasic
}
// DefaultGenesis returns custom x/staking module genesis state.
func (stakingModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
stakingParams := stakingtypes.DefaultParams()
stakingParams.BondDenom = params.DefaultBondDenom
stakingParams.UnbondingTime = DefaultUnbondingTime
return cdc.MustMarshalJSON(&stakingtypes.GenesisState{
Params: stakingParams,
})
}
type crisisModule struct {
crisis.AppModuleBasic
}
// DefaultGenesis returns custom x/crisis module genesis state.
func (crisisModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(&crisistypes.GenesisState{
ConstantFee: sdk.NewCoin(params.DefaultBondDenom, sdk.NewInt(1000)),
})
}
type mintModule struct {
mint.AppModuleBasic
}
// DefaultGenesis returns custom x/mint module genesis state.
func (mintModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
genState := minttypes.DefaultGenesisState()
genState.Params.MintDenom = params.DefaultBondDenom
return cdc.MustMarshalJSON(genState)
}