From 0dffcab631fb205d940c2e918306022484a001b6 Mon Sep 17 00:00:00 2001 From: Matija Martinic Date: Tue, 26 Jul 2022 15:26:38 +0200 Subject: [PATCH] Get latest snapshot if no id is provided --- x/valset/keeper/grpc_query_get_snapshot_by_id.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/x/valset/keeper/grpc_query_get_snapshot_by_id.go b/x/valset/keeper/grpc_query_get_snapshot_by_id.go index fd151786..64190ad7 100644 --- a/x/valset/keeper/grpc_query_get_snapshot_by_id.go +++ b/x/valset/keeper/grpc_query_get_snapshot_by_id.go @@ -15,8 +15,15 @@ func (k Keeper) GetSnapshotByID(goCtx context.Context, req *types.QueryGetSnapsh } ctx := sdk.UnwrapSDKContext(goCtx) + var snapshot *types.Snapshot + var err error + + if req.SnapshotId == 0 { + snapshot, err = k.GetCurrentSnapshot(ctx) + } else { + snapshot, err = k.FindSnapshotByID(ctx, req.SnapshotId) + } - snapshot, err := k.FindSnapshotByID(ctx, req.SnapshotId) if err != nil { return nil, err }