-
Notifications
You must be signed in to change notification settings - Fork 262
/
genesis.go
38 lines (30 loc) · 1.07 KB
/
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
package minfee
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
params "github.com/cosmos/cosmos-sdk/x/params/keeper"
)
// DefaultGenesis returns the default genesis state.
func DefaultGenesis() *GenesisState {
return &GenesisState{
GlobalMinGasPrice: DefaultGlobalMinGasPrice,
}
}
// ValidateGenesis performs basic validation of genesis data returning an error for any failed validation criteria.
func ValidateGenesis(genesis *GenesisState) error {
if genesis.GlobalMinGasPrice.IsNegative() || genesis.GlobalMinGasPrice.IsZero() {
return fmt.Errorf("global min gas price cannot be negative: %g", genesis.GlobalMinGasPrice)
}
return nil
}
// ExportGenesis returns the minfee module's exported genesis.
func ExportGenesis(ctx sdk.Context, k params.Keeper) *GenesisState {
subspace, exists := k.GetSubspace(ModuleName)
if !exists {
panic("minfee subspace not set")
}
subspace = RegisterMinFeeParamTable(subspace)
var globalMinGasPrice sdk.Dec
subspace.Get(ctx, KeyGlobalMinGasPrice, &globalMinGasPrice)
return &GenesisState{GlobalMinGasPrice: globalMinGasPrice}
}