Skip to content

Commit

Permalink
fix(cosmos): properly fail when querying missing egress/mailbox
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 18, 2021
1 parent ae092a4 commit 0c1be92
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions golang/cosmos/x/swingset/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func (k Querier) Egress(c context.Context, req *types.QueryEgressRequest) (*type
ctx := sdk.UnwrapSDKContext(c)

egress := k.GetEgress(ctx, req.Peer)
if egress.Peer == nil {
return nil, status.Error(codes.NotFound, "egress not found")
}

return &egress, nil
}
Expand All @@ -62,6 +65,9 @@ func (k Querier) Mailbox(c context.Context, req *types.QueryMailboxRequest) (*ty
ctx := sdk.UnwrapSDKContext(c)

mb := k.GetMailbox(ctx, req.Peer.String())
if mb.Value == "" {
return nil, status.Error(codes.NotFound, "mailbox not found")
}

return &types.QueryStorageResponse{
Value: mb.Value,
Expand Down

0 comments on commit 0c1be92

Please sign in to comment.