Skip to content

Commit 20ad08f

Browse files
authored
Merge pull request #26 from ethpandaops/feat/expose-service-urls
feat(config): include service URLs from cartographoor
2 parents 33a0cda + 6f55f32 commit 20ad08f

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

internal/api/config.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ type ConfigResponse struct {
2424

2525
// NetworkInfo represents network metadata.
2626
type NetworkInfo struct {
27-
Name string `json:"name"` // "mainnet", "sepolia", etc.
28-
DisplayName string `json:"display_name"` // "Mainnet", "Sepolia", etc.
29-
ChainID int64 `json:"chain_id"`
30-
GenesisTime int64 `json:"genesis_time"`
31-
GenesisDelay int64 `json:"genesis_delay"` // Genesis delay in seconds
32-
Forks Forks `json:"forks"`
27+
Name string `json:"name"` // "mainnet", "sepolia", etc.
28+
DisplayName string `json:"display_name"` // "Mainnet", "Sepolia", etc.
29+
ChainID int64 `json:"chain_id"`
30+
GenesisTime int64 `json:"genesis_time"`
31+
GenesisDelay int64 `json:"genesis_delay"` // Genesis delay in seconds
32+
Forks Forks `json:"forks"`
33+
ServiceUrls map[string]string `json:"service_urls"` // Map of service name to URL
3334
}
3435

3536
// Forks contains fork information for a network (API response format with snake_case).
@@ -123,6 +124,7 @@ func (h *ConfigHandler) buildNetworks(ctx context.Context) []NetworkInfo {
123124
var (
124125
chainID, genesisTime, genesisDelay int64
125126
forks Forks
127+
serviceUrls map[string]string
126128
)
127129

128130
if net.ChainID != nil {
@@ -137,11 +139,13 @@ func (h *ConfigHandler) buildNetworks(ctx context.Context) []NetworkInfo {
137139
genesisDelay = *net.GenesisDelay
138140
}
139141

140-
// Get forks from cartographoor if available (forks not in config.yaml yet)
142+
// Get forks and serviceUrls from cartographoor if available
141143
if h.provider != nil {
142144
if cartNet, exists := h.provider.GetNetwork(ctx, net.Name); exists {
143145
// Transform cartographoor.Forks to API Forks
144146
forks = transformForks(cartNet.Forks)
147+
// Copy serviceUrls from cartographoor
148+
serviceUrls = cartNet.ServiceUrls
145149
}
146150
}
147151

@@ -161,6 +165,7 @@ func (h *ConfigHandler) buildNetworks(ctx context.Context) []NetworkInfo {
161165
GenesisTime: genesisTime,
162166
GenesisDelay: genesisDelay,
163167
Forks: forks,
168+
ServiceUrls: serviceUrls,
164169
})
165170
}
166171

internal/cartographoor/service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func (s *Service) processNetworks(
108108
GenesisDelay: rawNet.GenesisConfig.GenesisDelay,
109109
Forks: rawNet.Forks,
110110
TargetURL: targetURL,
111+
ServiceUrls: rawNet.ServiceUrls,
111112
LastUpdated: rawNet.LastUpdated,
112113
}
113114
}

internal/cartographoor/types.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ type CartographoorResponse struct {
2222
// RawNetwork represents a network entry in the cartographoor JSON.
2323
// Only parses essential fields - network name comes from map key.
2424
type RawNetwork struct {
25-
Status string `json:"status"`
26-
ChainID int64 `json:"chainId"`
27-
LastUpdated time.Time `json:"lastUpdated"`
28-
GenesisConfig GenesisConfig `json:"genesisConfig"`
29-
Forks Forks `json:"forks"`
25+
Status string `json:"status"`
26+
ChainID int64 `json:"chainId"`
27+
LastUpdated time.Time `json:"lastUpdated"`
28+
GenesisConfig GenesisConfig `json:"genesisConfig"`
29+
Forks Forks `json:"forks"`
30+
ServiceUrls map[string]string `json:"serviceUrls"` // Map of service name to URL
3031
}
3132

3233
// GenesisConfig contains genesis configuration.
@@ -58,11 +59,12 @@ type Network struct {
5859
DisplayName string
5960
Description string
6061
Status string
61-
ChainID int64 // Integer chain ID
62-
GenesisTime int64 // Unix timestamp
63-
GenesisDelay int64 // Genesis delay in seconds
64-
Forks Forks // Fork information
65-
TargetURL string // CBT API URL constructed from network name
62+
ChainID int64 // Integer chain ID
63+
GenesisTime int64 // Unix timestamp
64+
GenesisDelay int64 // Genesis delay in seconds
65+
Forks Forks // Fork information
66+
TargetURL string // CBT API URL constructed from network name
67+
ServiceUrls map[string]string // Map of service name to URL
6668
LastUpdated time.Time
6769
}
6870

0 commit comments

Comments
 (0)