-
Notifications
You must be signed in to change notification settings - Fork 0
/
staking_builder.go
38 lines (29 loc) · 994 Bytes
/
staking_builder.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
package testutil
import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/furya-official/mage/app"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
// StakingGenesisBuilder is a tool for creating a staking genesis state.
// Helper methods add values onto a default genesis state.
// All methods are immutable and return updated copies of the builder.
type StakingGenesisBuilder struct {
stakingtypes.GenesisState
}
var _ GenesisBuilder = (*StakingGenesisBuilder)(nil)
func NewStakingGenesisBuilder() StakingGenesisBuilder {
gen := stakingtypes.DefaultGenesisState()
gen.Params.BondDenom = "umage"
return StakingGenesisBuilder{
GenesisState: *gen,
}
}
func (builder StakingGenesisBuilder) Build() stakingtypes.GenesisState {
return builder.GenesisState
}
func (builder StakingGenesisBuilder) BuildMarshalled(cdc codec.JSONCodec) app.GenesisState {
built := builder.Build()
return app.GenesisState{
stakingtypes.ModuleName: cdc.MustMarshalJSON(&built),
}
}