Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lint issue after merge #163

Merged
merged 13 commits into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions cmd/fund/fund.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"math/big"
"net/http"
"os"
Expand Down Expand Up @@ -55,31 +55,30 @@ func getChainIDFromNode(chainRPC string) (int64, error) {
payload := `{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}`

// Create the HTTP request
req, err := http.NewRequest("POST", chainRPC, strings.NewReader(payload))
if err != nil {
return 0, err
req, ReqErr := http.NewRequest("POST", chainRPC, strings.NewReader(payload))
if ReqErr != nil {
return 0, ReqErr
}

// Set the required headers
req.Header.Set("Content-Type", "application/json")

// Send the request
resp, err := client.Do(req)
if err != nil {
return 0, err
resp, doErr := client.Do(req)
if doErr != nil {
return 0, doErr
}
defer resp.Body.Close()

// Read the response body
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return 0, err
body, readErr := io.ReadAll(resp.Body) // Replace ioutil.ReadAll with io.ReadAll
if readErr != nil {
return 0, readErr
}

// Parse the JSON response
var result map[string]interface{}
if err := json.Unmarshal(body, &result); err != nil {
return 0, err
if jsonErr := json.Unmarshal(body, &result); jsonErr != nil {
return 0, jsonErr
}

// Extract the chain ID from the response
Expand All @@ -89,9 +88,9 @@ func getChainIDFromNode(chainRPC string) (int64, error) {
}

// Convert the chain ID from hex to int64
int64ChainID, err := strconv.ParseInt(chainIDHex, 0, 64)
if err != nil {
return 0, err
int64ChainID, parseErr := strconv.ParseInt(chainIDHex, 0, 64)
if parseErr != nil {
return 0, parseErr
}

return int64ChainID, nil
Expand Down