Skip to content

Commit

Permalink
fix: calculated dynamically the path to endpoints.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
Yashk767 committed Nov 19, 2024
1 parent e9e7fda commit 88ebebb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 9 additions & 2 deletions RPC/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"razor/logger"
"runtime"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -91,8 +92,14 @@ func (m *RPCManager) RefreshEndpoints() error {
}

func InitializeRPCManager(provider string) (*RPCManager, error) {
// Fetch the absolute path to the PROJECT directory and locate endpoints.json file
projectDir := filepath.Join("..", "..") // Relative path from build output
// Locate the razor-go project directory dynamically
_, file, _, ok := runtime.Caller(0) // Get the current file (rpc.go) path
if !ok {
return nil, fmt.Errorf("failed to get the caller information")
}

// Move up to the razor-go project root
projectDir := filepath.Dir(filepath.Dir(file)) // This gets `razor-go` directory
endpointsFile := filepath.Join(projectDir, "endpoints.json")

fileData, err := os.ReadFile(endpointsFile)
Expand Down
5 changes: 1 addition & 4 deletions endpoints.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[
"https://andromeda02.skale.prod.chorus1.net:10072",
"https://skale-figment-9.skale.figment.io:10008",
"https://skale-figment-2.skale.figment.io:10072",
"https://node03.skale.prod.chorus1.net:10072"
"https://testnet.skalenodes.com/v1/juicy-low-small-testnet"
]

0 comments on commit 88ebebb

Please sign in to comment.