Skip to content

Commit 7d03f9e

Browse files
committed
Revert "improve abi parsing (#213)"
This reverts commit 856a78e, reversing changes made to 3c3e03d.
1 parent 856a78e commit 7d03f9e

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

internal/common/abi.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package common
22

33
import (
44
"fmt"
5-
"io"
65
"net/http"
76
"regexp"
87
"strings"
@@ -12,13 +11,11 @@ import (
1211
config "github.com/thirdweb-dev/indexer/configs"
1312

1413
"github.com/ethereum/go-ethereum/accounts/abi"
15-
"github.com/rs/zerolog/log"
1614
)
1715

1816
var (
19-
httpClient *http.Client
20-
httpClientOnce sync.Once
21-
jsonDecodeMutex sync.Mutex
17+
httpClient *http.Client
18+
httpClientOnce sync.Once
2219
)
2320

2421
func getHTTPClient() *http.Client {
@@ -69,23 +66,11 @@ func GetABIForContract(chainId string, contract string) (*abi.ABI, error) {
6966
return nil, fmt.Errorf("failed to get contract abi: unexpected status code %d", resp.StatusCode)
7067
}
7168

72-
// Read the entire response body
73-
body, err := io.ReadAll(resp.Body)
69+
abi, err := abi.JSON(resp.Body)
7470
if err != nil {
75-
return nil, fmt.Errorf("failed to read contract abi response: %v", err)
76-
}
77-
78-
// Protect JSON decoding with a mutex
79-
jsonDecodeMutex.Lock()
80-
defer jsonDecodeMutex.Unlock()
81-
82-
// Parse the ABI
83-
parsedABI, err := abi.JSON(strings.NewReader(string(body)))
84-
if err != nil {
85-
log.Warn().Err(err).Str("contract", contract).Str("chainId", chainId).Msg("Failed to parse contract ABI")
8671
return nil, fmt.Errorf("failed to load contract abi: %v", err)
8772
}
88-
return &parsedABI, nil
73+
return &abi, nil
8974
}
9075

9176
func ConstructEventABI(signature string) (*abi.Event, error) {

0 commit comments

Comments
 (0)