mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2026-05-19 19:10:56 +02:00
feat: add within network check for approve events
This commit is contained in:
@@ -17,7 +17,7 @@ var (
|
||||
tokenApproveToSig = w3.MustNewFunc("approve(address, uint256)", "bool")
|
||||
)
|
||||
|
||||
func HandleTokenApproveLog() router.LogHandlerFunc {
|
||||
func HandleTokenApproveLog(hc *HandlerContainer) router.LogHandlerFunc {
|
||||
return func(ctx context.Context, lp router.LogPayload, c router.Callback) error {
|
||||
var (
|
||||
owner common.Address
|
||||
@@ -29,6 +29,14 @@ func HandleTokenApproveLog() router.LogHandlerFunc {
|
||||
return err
|
||||
}
|
||||
|
||||
proceed, err := hc.checkWithinNetwork(ctx, lp.Log.Address.Hex(), owner.Hex(), spender.Hex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !proceed {
|
||||
return nil
|
||||
}
|
||||
|
||||
tokenApproveEvent := event.Event{
|
||||
Index: lp.Log.Index,
|
||||
Block: lp.Log.BlockNumber,
|
||||
@@ -48,7 +56,7 @@ func HandleTokenApproveLog() router.LogHandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func HandleTokenApproveInputData() router.InputDataHandlerFunc {
|
||||
func HandleTokenApproveInputData(hc *HandlerContainer) router.InputDataHandlerFunc {
|
||||
return func(ctx context.Context, idp router.InputDataPayload, c router.Callback) error {
|
||||
var (
|
||||
spender common.Address
|
||||
@@ -59,6 +67,14 @@ func HandleTokenApproveInputData() router.InputDataHandlerFunc {
|
||||
return err
|
||||
}
|
||||
|
||||
proceed, err := hc.checkWithinNetwork(ctx, idp.ContractAddress, idp.From, spender.Hex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !proceed {
|
||||
return nil
|
||||
}
|
||||
|
||||
tokenApproveEvent := event.Event{
|
||||
Block: idp.Block,
|
||||
ContractAddress: idp.ContractAddress,
|
||||
|
||||
Reference in New Issue
Block a user