@@ -4,13 +4,12 @@ import (
44 "net/http"
55
66 "github.com/ethereum/go-ethereum/accounts/abi"
7- "github.com/ethereum/go-ethereum/crypto "
7+ gethCommon "github.com/ethereum/go-ethereum/common "
88 "github.com/gin-gonic/gin"
99 "github.com/rs/zerolog/log"
1010 "github.com/thirdweb-dev/indexer/api"
1111 config "github.com/thirdweb-dev/indexer/configs"
1212 "github.com/thirdweb-dev/indexer/internal/common"
13- "github.com/thirdweb-dev/indexer/internal/rpc"
1413 "github.com/thirdweb-dev/indexer/internal/storage"
1514)
1615
@@ -35,7 +34,7 @@ import (
3534// @Failure 500 {object} api.Error
3635// @Router /{chainId}/transactions [get]
3736func GetTransactions (c * gin.Context ) {
38- handleTransactionsRequest (c , "" , "" , nil )
37+ handleTransactionsRequest (c )
3938}
4039
4140// @Summary Get transactions by contract
@@ -60,8 +59,7 @@ func GetTransactions(c *gin.Context) {
6059// @Failure 500 {object} api.Error
6160// @Router /{chainId}/transactions/{to} [get]
6261func GetTransactionsByContract (c * gin.Context ) {
63- to := c .Param ("to" )
64- handleTransactionsRequest (c , to , "" , nil )
62+ handleTransactionsRequest (c )
6563}
6664
6765// @Summary Get transactions by contract and signature
@@ -87,32 +85,33 @@ func GetTransactionsByContract(c *gin.Context) {
8785// @Failure 500 {object} api.Error
8886// @Router /{chainId}/transactions/{to}/{signature} [get]
8987func GetTransactionsByContractAndSignature (c * gin.Context ) {
90- to := c .Param ("to" )
91- signature := c .Param ("signature" )
92- strippedSignature := common .StripPayload (signature )
93- functionABI , err := common .ConstructFunctionABI (signature )
94- if err != nil {
95- log .Debug ().Err (err ).Msgf ("Unable to construct function ABI for %s" , signature )
96- }
97- handleTransactionsRequest (c , to , strippedSignature , functionABI )
88+ handleTransactionsRequest (c )
9889}
9990
100- func handleTransactionsRequest (c * gin.Context , contractAddress , signature string , functionABI * abi. Method ) {
91+ func handleTransactionsRequest (c * gin.Context ) {
10192 chainId , err := api .GetChainId (c )
10293 if err != nil {
10394 api .BadRequestErrorHandler (c , err )
10495 return
10596 }
10697
98+ contractAddress := c .Param ("to" )
99+ signature := c .Param ("signature" )
100+
107101 queryParams , err := api .ParseQueryParams (c .Request )
108102 if err != nil {
109103 api .BadRequestErrorHandler (c , err )
110104 return
111105 }
112106
107+ var functionABI * abi.Method
113108 signatureHash := ""
114109 if signature != "" {
115- signatureHash = rpc .ExtractFunctionSelector (crypto .Keccak256Hash ([]byte (signature )).Hex ())
110+ functionABI , err = common .ConstructFunctionABI (signature )
111+ if err != nil {
112+ log .Debug ().Err (err ).Msgf ("Unable to construct function ABI for %s" , signature )
113+ }
114+ signatureHash = "0x" + gethCommon .Bytes2Hex (functionABI .ID )
116115 }
117116
118117 mainStorage , err := getMainStorage ()
0 commit comments