Skip to content

Commit

Permalink
Return chainregistry type directly instead of nested dict for GetChain (
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol1696 authored Apr 6, 2023
1 parent 06ffe8a commit 7ef722d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions proto/registry/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ service Registry {
rpc ListChains(google.protobuf.Empty) returns (ResponseChains) {
option (google.api.http) = { get: "/chains" };
}
rpc GetChain(RequestChain) returns (ResponseChain) {
rpc GetChain(RequestChain) returns (ChainRegistry) {
option (google.api.http) = { get: "/chains/{chain}" };
}
// ListChainPeers will fetch all the nodes and addresses
Expand Down Expand Up @@ -61,10 +61,6 @@ message RequestChain {
string chain = 1 [json_name = "chain"];
}

message ResponseChain {
ChainRegistry chain = 1 [json_name = "chain"];
}

message ResponseChainAssets {
string schema = 1 [json_name = "$schema"];
string chain_name = 2 [json_name = "chain_name"];
Expand Down
6 changes: 3 additions & 3 deletions registry/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (a *AppServer) ListChains(ctx context.Context, _ *emptypb.Empty) (*pb.Respo
return nil, err
}

chains = append(chains, resp.Chain)
chains = append(chains, resp)
}

return &pb.ResponseChains{Chains: chains}, nil
Expand All @@ -104,7 +104,7 @@ func (a *AppServer) ListChainIDs(ctx context.Context, _ *emptypb.Empty) (*pb.Res
// GetChain handles the incoming request for a single chain given the chain id
// Note, we use chain-id instead of chain type, since it is expected, that there
// can be multiple chains of same type by unique chain ids
func (a *AppServer) GetChain(ctx context.Context, requestChain *pb.RequestChain) (*pb.ResponseChain, error) {
func (a *AppServer) GetChain(ctx context.Context, requestChain *pb.RequestChain) (*pb.ChainRegistry, error) {
chainID := requestChain.Chain

filename := filepath.Join(a.config.ChainRegistry, chainID, "chain.json")
Expand Down Expand Up @@ -136,7 +136,7 @@ func (a *AppServer) GetChain(ctx context.Context, requestChain *pb.RequestChain)
}
chain.Apis = apis

return &pb.ResponseChain{Chain: chain}, nil
return chain, nil
}

func (a *AppServer) getChainPeers(ctx context.Context, client *ChainClient) (*pb.Peers, error) {
Expand Down

0 comments on commit 7ef722d

Please sign in to comment.