Skip to content

Commit

Permalink
CNS-252: extract API names through func
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-lava committed Jan 29, 2023
1 parent 8b7091a commit 2bd84e1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions x/spec/keeper/grpc_query_show_all_chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ func (k Keeper) ShowAllChains(goCtx context.Context, req *types.QueryShowAllChai
expectedInterfaces := k.GetExpectedInterfacesForSpec(ctx, chainId)

// copy the expectedInterfaces's keys (which are the interface names) to a string list
var apiInterfacesNames []string
for apiInterfacesName := range expectedInterfaces {
apiInterfacesNames = append(apiInterfacesNames, apiInterfacesName)
}
apiInterfacesNames := getInterfacesNamesFromMap(expectedInterfaces)

// create a chainInfoEntry which includes the chain's name, ID and enabled interfaces
chainInfoEntry := types.ShowAllChainsInfoStruct{ChainName: chainName, ChainID: chainId, EnabledApiInterfaces: apiInterfacesNames}
Expand All @@ -44,3 +41,12 @@ func (k Keeper) ShowAllChains(goCtx context.Context, req *types.QueryShowAllChai

return &types.QueryShowAllChainsResponse{ChainInfoList: chainInfoList}, nil
}

func getInterfacesNamesFromMap(expectedInterfaces map[string]bool) []string {
var apiInterfacesNames []string
for apiInterfacesName := range expectedInterfaces {
apiInterfacesNames = append(apiInterfacesNames, apiInterfacesName)
}

return apiInterfacesNames
}

0 comments on commit 2bd84e1

Please sign in to comment.