-
Notifications
You must be signed in to change notification settings - Fork 42
/
genesis.go
39 lines (32 loc) · 1015 Bytes
/
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
39
package resource
import (
"fmt"
"github.com/cheqd/cheqd-node/x/resource/keeper"
"github.com/cheqd/cheqd-node/x/resource/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// InitGenesis initializes the resource module's state from a provided genesis
// state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState *types.GenesisState) {
for _, resource := range genState.Resources {
if err := k.SetResource(&ctx, resource); err != nil {
panic(fmt.Sprintf("Cannot set resource case: %s", err.Error()))
}
}
// set fee params
k.SetParams(ctx, *genState.FeeParams)
}
// ExportGenesis returns the cheqd module's exported genesis.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
// Get all resource
resourceList, err := k.GetAllResources(&ctx)
if err != nil {
panic(fmt.Sprintf("Cannot get all resource: %s", err.Error()))
}
// get fee params
feeParams := k.GetParams(ctx)
return &types.GenesisState{
Resources: resourceList,
FeeParams: &feeParams,
}
}