From 19eb968680abc58637ab4a3a07b48454d6168893 Mon Sep 17 00:00:00 2001 From: C H Date: Wed, 11 Sep 2024 15:26:33 +0800 Subject: [PATCH] Revisit grid routes export --- x/grid/keeper/genesis.go | 13 +++++++++++++ x/grid/keeper/keeper.go | 7 +++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/x/grid/keeper/genesis.go b/x/grid/keeper/genesis.go index 521b35ea..5dd8ef9d 100644 --- a/x/grid/keeper/genesis.go +++ b/x/grid/keeper/genesis.go @@ -17,6 +17,19 @@ func InitGenesis(ctx sdk.Context, k Keeper, data types.GenesisState) { } } +// TODO fix empty case +//"grid" : { +// "routes" : [{ +// "destination" : "", +// "value" : [], +// "source" : "", +// "name" : "" +// }], +// "params" : { +// "max_routes" : 16 +// } +//} + func ExportGenesis(ctx sdk.Context, k Keeper) *types.GenesisState { params := k.GetParams(ctx) routes := k.GetAllRoutes(ctx) diff --git a/x/grid/keeper/keeper.go b/x/grid/keeper/keeper.go index 7fdd79a4..d3d093e4 100644 --- a/x/grid/keeper/keeper.go +++ b/x/grid/keeper/keeper.go @@ -2,7 +2,6 @@ package keeper import ( "fmt" - storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cometbft/cometbft/libs/log" @@ -270,7 +269,11 @@ func (k Keeper) IterateAllRoutes(ctx sdk.Context, cb func(route types.Route) (st defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - route := types.MustUnmarshalRoute(k.cdc, iterator.Value()) + route, err := types.UnmarshalRoute(k.cdc, iterator.Value()) + if err != nil { + // TODO revisit this error handling + continue + } if cb(route) { break }