@@ -2,7 +2,6 @@ package common
22
33import (
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
1816var (
19- httpClient * http.Client
20- httpClientOnce sync.Once
21- jsonDecodeMutex sync.Mutex
17+ httpClient * http.Client
18+ httpClientOnce sync.Once
2219)
2320
2421func 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
9176func ConstructEventABI (signature string ) (* abi.Event , error ) {
0 commit comments