2021-06-08 15:19:12 +00:00
|
|
|
package swap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2021-07-15 14:42:30 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2021-08-18 12:51:09 +00:00
|
|
|
|
2024-05-01 03:17:24 +00:00
|
|
|
"github.com/0glabs/0g-chain/x/swap/keeper"
|
|
|
|
"github.com/0glabs/0g-chain/x/swap/types"
|
2021-06-08 15:19:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// InitGenesis initializes story state from genesis file
|
2022-01-08 00:39:27 +00:00
|
|
|
func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
|
2021-06-08 15:19:12 +00:00
|
|
|
if err := gs.Validate(); err != nil {
|
2022-01-08 00:39:27 +00:00
|
|
|
panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err))
|
2021-06-08 15:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
k.SetParams(ctx, gs.Params)
|
2021-07-15 14:42:30 +00:00
|
|
|
for _, pr := range gs.PoolRecords {
|
|
|
|
k.SetPool(ctx, pr)
|
|
|
|
}
|
|
|
|
for _, sh := range gs.ShareRecords {
|
|
|
|
k.SetDepositorShares(ctx, sh)
|
|
|
|
}
|
2021-06-08 15:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ExportGenesis exports the genesis state
|
2022-01-08 00:39:27 +00:00
|
|
|
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
|
2021-06-08 15:19:12 +00:00
|
|
|
params := k.GetParams(ctx)
|
2021-07-15 14:42:30 +00:00
|
|
|
pools := k.GetAllPools(ctx)
|
|
|
|
shares := k.GetAllDepositorShares(ctx)
|
2022-01-08 00:39:27 +00:00
|
|
|
|
2021-07-15 14:42:30 +00:00
|
|
|
return types.NewGenesisState(params, pools, shares)
|
2021-06-08 15:19:12 +00:00
|
|
|
}
|