feat: add quoter updated handler

This commit is contained in:
Mohamed Sohail 2025-07-03 10:55:44 +03:00
parent 5cf5f9894c
commit ef28ec1298
Signed by: kamikazechaser
GPG Key ID: 7DD45520C01CD85D
2 changed files with 68 additions and 0 deletions

View File

@ -27,6 +27,7 @@ func bootstrapEventRouter(cacheProvider cache.Cache, pubCB router.Callback) *rou
router.RegisterLogRoute(w3.H("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"), handler.HandleTokenTransferLog(handlerContainer))
router.RegisterLogRoute(w3.H("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"), handler.HandleTokenApproveLog(handlerContainer))
router.RegisterLogRoute(w3.H("0x5f7542858008eeb041631f30e6109ae94b83a58e9a58261dd2c42c508850f939"), handler.HandleTokenTransferFromLog(handlerContainer))
router.RegisterLogRoute(w3.H("0x06526a30af2ff868c2686df12e95844d8ae300416bbec5d5ccc2d2f4afdb17a0"), handler.HandleQuoterUpdatedLog())
router.RegisterInputDataRoute("63e4bff4", handler.HandleFaucetGiveInputData())
router.RegisterInputDataRoute("de82efb4", handler.HandleFaucetGiveInputData())
@ -44,6 +45,7 @@ func bootstrapEventRouter(cacheProvider cache.Cache, pubCB router.Callback) *rou
router.RegisterInputDataRoute("a9059cbb", handler.HandleTokenTransferInputData(handlerContainer))
router.RegisterInputDataRoute("23b872dd", handler.HandleTokenTransferInputData(handlerContainer))
router.RegisterInputDataRoute("095ea7b3", handler.HandleTokenApproveInputData(handlerContainer))
router.RegisterInputDataRoute("f912c64b", handler.HandleQuoterUpdatedInputData())
return router
}

View File

@ -0,0 +1,66 @@
package handler
import (
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/grassrootseconomics/eth-tracker/pkg/event"
"github.com/grassrootseconomics/eth-tracker/pkg/router"
"github.com/lmittmann/w3"
)
const quoterUpdatedEventName = "QUOTER_UPDATED"
var (
quoterUpdatedEvent = w3.MustNewEvent("QuoterUpdated(address indexed newQuoter)")
quoterUpdatedSig = w3.MustNewFunc("setQuoter(address)", "")
)
func HandleQuoterUpdatedLog() router.LogHandlerFunc {
return func(ctx context.Context, lp router.LogPayload, c router.Callback) error {
var newQuoter common.Address
if err := quoterUpdatedEvent.DecodeArgs(lp.Log, &newQuoter); err != nil {
return err
}
quoterUpdatedEvent := event.Event{
Index: lp.Log.Index,
Block: lp.Log.BlockNumber,
ContractAddress: lp.Log.Address.Hex(),
Success: true,
Timestamp: lp.Timestamp,
TxHash: lp.Log.TxHash.Hex(),
TxType: quoterUpdatedEventName,
Payload: map[string]any{
"newQuoter": newQuoter.Hex(),
},
}
return c(ctx, quoterUpdatedEvent)
}
}
func HandleQuoterUpdatedInputData() router.InputDataHandlerFunc {
return func(ctx context.Context, idp router.InputDataPayload, c router.Callback) error {
var newQuoter common.Address
if err := quoterUpdatedSig.DecodeArgs(w3.B(idp.InputData), &newQuoter); err != nil {
return err
}
quoterUpdatedEvent := event.Event{
Block: idp.Block,
ContractAddress: idp.ContractAddress,
Success: false,
Timestamp: idp.Timestamp,
TxHash: idp.TxHash,
TxType: quoterUpdatedEventName,
Payload: map[string]any{
"newQuoter": newQuoter.Hex(),
},
}
return c(ctx, quoterUpdatedEvent)
}
}