Skip to content

Commit

Permalink
feat: add error mapping to all methods in gRPC proxy client
Browse files Browse the repository at this point in the history
Previously, only `Get` method supported proper error mapping.
  • Loading branch information
tzdybal committed Oct 6, 2024
1 parent 25a3a03 commit 15443a3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions proxy/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (c *Client) MaxBlobSize(ctx context.Context) (uint64, error) {
req := &pbda.MaxBlobSizeRequest{}
resp, err := c.client.MaxBlobSize(ctx, req)
if err != nil {
return 0, err
return 0, tryToMapError(err)
}
return resp.MaxBlobSize, nil
}
Expand All @@ -70,7 +70,7 @@ func (c *Client) GetIDs(ctx context.Context, height uint64, namespace da.Namespa
req := &pbda.GetIdsRequest{Height: height, Namespace: &pbda.Namespace{Value: namespace}}
resp, err := c.client.GetIds(ctx, req)
if err != nil {
return nil, err
return nil, tryToMapError(err)
}

timestamp, err := types.TimestampFromProto(resp.Timestamp)
Expand Down Expand Up @@ -103,7 +103,7 @@ func (c *Client) Commit(ctx context.Context, blobs []da.Blob, namespace da.Names

resp, err := c.client.Commit(ctx, req)
if err != nil {
return nil, err
return nil, tryToMapError(err)
}

return commitsPB2DA(resp.Commitments), nil
Expand All @@ -119,7 +119,7 @@ func (c *Client) Submit(ctx context.Context, blobs []da.Blob, gasPrice float64,

resp, err := c.client.Submit(ctx, req)
if err != nil {
return nil, err
return nil, tryToMapError(err)
}

ids := make([]da.ID, len(resp.Ids))
Expand All @@ -141,7 +141,7 @@ func (c *Client) SubmitWithOptions(ctx context.Context, blobs []da.Blob, gasPric

resp, err := c.client.Submit(ctx, req)
if err != nil {
return nil, err
return nil, tryToMapError(err)
}

ids := make([]da.ID, len(resp.Ids))
Expand All @@ -160,5 +160,5 @@ func (c *Client) Validate(ctx context.Context, ids []da.ID, proofs []da.Proof, n
Namespace: &pbda.Namespace{Value: namespace},
}
resp, err := c.client.Validate(ctx, req)
return resp.Results, err
return resp.Results, tryToMapError(err)
}

0 comments on commit 15443a3

Please sign in to comment.