forked from Kava-Labs/kava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kavamint_builder.go
59 lines (46 loc) · 1.57 KB
/
kavamint_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package testutil
import (
"time"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/mage-coven/mage/app"
mageminttypes "github.com/mage-coven/mage/x/magemint/types"
)
// MagemintGenesisBuilder is a tool for creating a mint genesis state.
// Helper methods add values onto a default genesis state.
// All methods are immutable and return updated copies of the builder.
type MagemintGenesisBuilder struct {
mageminttypes.GenesisState
}
var _ GenesisBuilder = (*MagemintGenesisBuilder)(nil)
func NewMagemintGenesisBuilder() MagemintGenesisBuilder {
gen := mageminttypes.DefaultGenesisState()
gen.Params.CommunityPoolInflation = sdk.ZeroDec()
gen.Params.StakingRewardsApy = sdk.ZeroDec()
return MagemintGenesisBuilder{
GenesisState: *gen,
}
}
func (builder MagemintGenesisBuilder) Build() mageminttypes.GenesisState {
return builder.GenesisState
}
func (builder MagemintGenesisBuilder) BuildMarshalled(cdc codec.JSONCodec) app.GenesisState {
built := builder.Build()
return app.GenesisState{
mageminttypes.ModuleName: cdc.MustMarshalJSON(&built),
}
}
func (builder MagemintGenesisBuilder) WithPreviousBlockTime(t time.Time) MagemintGenesisBuilder {
builder.PreviousBlockTime = t
return builder
}
func (builder MagemintGenesisBuilder) WithStakingRewardsApy(apy sdk.Dec) MagemintGenesisBuilder {
builder.Params.StakingRewardsApy = apy
return builder
}
func (builder MagemintGenesisBuilder) WithCommunityPoolInflation(
inflation sdk.Dec,
) MagemintGenesisBuilder {
builder.Params.CommunityPoolInflation = inflation
return builder
}