From 88ebebb192c6f20661ee14213b86dfac9577600c Mon Sep 17 00:00:00 2001 From: YashK Date: Tue, 19 Nov 2024 16:07:58 +0530 Subject: [PATCH] fix: calculated dynamically the path to endpoints.json file --- RPC/rpc.go | 11 +++++++++-- endpoints.json | 5 +---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/RPC/rpc.go b/RPC/rpc.go index ce1afc33..53c02a19 100644 --- a/RPC/rpc.go +++ b/RPC/rpc.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "razor/logger" + "runtime" "sort" "strings" "sync" @@ -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) diff --git a/endpoints.json b/endpoints.json index bddd3552..82bee1a2 100644 --- a/endpoints.json +++ b/endpoints.json @@ -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" ] \ No newline at end of file