mirror of
https://github.com/luxfi/explorer.git
synced 2026-09-24 00:25:12 +00:00
fix: direct-luxd /ext/bc/ -> /v1/bc/ (luxd is /v1-only)
luxd v1.34.x serves chain RPC at /v1/bc/*; /ext/bc/* 404s. mdns.go discovers luxd nodes directly (base = http://<host>:<port> from mDNS) and constructs their per-chain RPC + platform.getBlockchains routes — these are direct-luxd calls, so they move to /v1/bc/. registry_test.go fixtures use localhost:9650 direct-luxd URLs, flipped to match. Public-gateway URLs (api.lux.network in chains.example.yaml / README.md) are left as /ext — the public gateway still accepts /ext externally. Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
+2
-2
@@ -81,7 +81,7 @@ chains:
|
||||
- slug: bchain
|
||||
name: B-Chain
|
||||
type: dag
|
||||
rpc: ${LUX_RPC:-https://api.lux.network}/ext/bc/B
|
||||
rpc: ${LUX_RPC:-https://api.lux.network}/v1/bc/B
|
||||
coin: LUX
|
||||
enabled: true
|
||||
|
||||
@@ -95,7 +95,7 @@ chains:
|
||||
- slug: tchain
|
||||
name: T-Chain
|
||||
type: dag
|
||||
rpc: ${LUX_RPC:-https://api.lux.network}/ext/bc/T
|
||||
rpc: ${LUX_RPC:-https://api.lux.network}/v1/bc/T
|
||||
coin: LUX
|
||||
enabled: true
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ func (r *ChainRegistry) probeNode(host string, port int, brand string) {
|
||||
r.Add(ChainConfig{
|
||||
Slug: slug,
|
||||
Name: name,
|
||||
RPC: fmt.Sprintf("%s/ext/bc/%s/rpc", base, id),
|
||||
RPC: fmt.Sprintf("%s/v1/bc/%s/rpc", base, id),
|
||||
Type: chainType,
|
||||
Source: "mdns",
|
||||
Default: isDefault,
|
||||
@@ -126,7 +126,7 @@ func (r *ChainRegistry) probeNode(host string, port int, brand string) {
|
||||
// probeNodeLegacy uses platform.getBlockchains + per-chain RPC probe for older nodes
|
||||
// that don't support info.getChains.
|
||||
func (r *ChainRegistry) probeNodeLegacy(base, brand string) {
|
||||
chains, err := rpcCall(base+"/ext/bc/P", "platform.getBlockchains", nil)
|
||||
chains, err := rpcCall(base+"/v1/bc/P", "platform.getBlockchains", nil)
|
||||
if err != nil {
|
||||
log.Printf("[mdns] %s: cannot query platform either, giving up", base)
|
||||
return
|
||||
@@ -149,7 +149,7 @@ func (r *ChainRegistry) probeNodeLegacy(base, brand string) {
|
||||
continue
|
||||
}
|
||||
|
||||
rpcURL := fmt.Sprintf("%s/ext/bc/%s/rpc", base, id)
|
||||
rpcURL := fmt.Sprintf("%s/v1/bc/%s/rpc", base, id)
|
||||
if !probeRPC(rpcURL) {
|
||||
continue
|
||||
}
|
||||
|
||||
+7
-7
@@ -16,7 +16,7 @@ func TestRegistryAddAndList(t *testing.T) {
|
||||
err := r.Add(ChainConfig{
|
||||
Slug: "cchain",
|
||||
Name: "C-Chain",
|
||||
RPC: "http://localhost:9650/ext/bc/C/rpc",
|
||||
RPC: "http://localhost:9650/v1/bc/C/rpc",
|
||||
Type: "evm",
|
||||
Source: "config",
|
||||
})
|
||||
@@ -131,7 +131,7 @@ func TestRegistryDefaultType(t *testing.T) {
|
||||
|
||||
func TestRegistryLoadFromEnv(t *testing.T) {
|
||||
r := NewChainRegistry()
|
||||
r.LoadFromEnv("cchain:http://localhost:9650/ext/bc/C/rpc,zoo:http://localhost:9650/ext/bc/Zoo/rpc")
|
||||
r.LoadFromEnv("cchain:http://localhost:9650/v1/bc/C/rpc,zoo:http://localhost:9650/v1/bc/Zoo/rpc")
|
||||
|
||||
if r.Count() != 2 {
|
||||
t.Fatalf("expected 2 chains, got %d", r.Count())
|
||||
@@ -145,13 +145,13 @@ func TestRegistryLoadFromFile(t *testing.T) {
|
||||
- slug: cchain
|
||||
name: C-Chain
|
||||
chain_id: 96369
|
||||
rpc: http://localhost:9650/ext/bc/C/rpc
|
||||
rpc: http://localhost:9650/v1/bc/C/rpc
|
||||
type: evm
|
||||
default: true
|
||||
- slug: zoo
|
||||
name: Zoo
|
||||
chain_id: 200200
|
||||
rpc: http://localhost:9650/ext/bc/Zoo/rpc
|
||||
rpc: http://localhost:9650/v1/bc/Zoo/rpc
|
||||
type: evm
|
||||
`), 0644)
|
||||
|
||||
@@ -199,7 +199,7 @@ func TestHandleAddAndRemove(t *testing.T) {
|
||||
r := NewChainRegistry()
|
||||
|
||||
// Add
|
||||
payload := `{"slug":"cchain","name":"C-Chain","rpc":"http://localhost:9650/ext/bc/C/rpc","type":"evm"}`
|
||||
payload := `{"slug":"cchain","name":"C-Chain","rpc":"http://localhost:9650/v1/bc/C/rpc","type":"evm"}`
|
||||
req := httptest.NewRequest("POST", "/v1/explorer/admin/chains", bytes.NewBufferString(payload))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
w := httptest.NewRecorder()
|
||||
@@ -355,7 +355,7 @@ func TestHTTPIntegration(t *testing.T) {
|
||||
}
|
||||
|
||||
// Add
|
||||
addPayload := `{"slug":"cchain","name":"C-Chain","chain_id":96369,"rpc":"http://localhost:9650/ext/bc/C/rpc","type":"evm","default":true}`
|
||||
addPayload := `{"slug":"cchain","name":"C-Chain","chain_id":96369,"rpc":"http://localhost:9650/v1/bc/C/rpc","type":"evm","default":true}`
|
||||
resp, err = client.Post(ts.URL+"/v1/explorer/admin/chains", "application/json", bytes.NewBufferString(addPayload))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -377,7 +377,7 @@ func TestHTTPIntegration(t *testing.T) {
|
||||
}
|
||||
|
||||
// Update
|
||||
updatePayload := `{"name":"Lux C-Chain","rpc":"http://new:9650/ext/bc/C/rpc"}`
|
||||
updatePayload := `{"name":"Lux C-Chain","rpc":"http://new:9650/v1/bc/C/rpc"}`
|
||||
updateReq, _ := http.NewRequest("PUT", ts.URL+"/v1/explorer/admin/chains/cchain", bytes.NewBufferString(updatePayload))
|
||||
updateReq.Header.Set("Content-Type", "application/json")
|
||||
resp, err = client.Do(updateReq)
|
||||
|
||||
Reference in New Issue
Block a user