mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2026-05-16 10:01:46 +02:00
Merge branch 'cel2' into celo-old-geth
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,
|
||||
|
||||
@@ -30,7 +30,7 @@ func HandleTokenTransferLog(hc *HandlerContainer) router.LogHandlerFunc {
|
||||
return err
|
||||
}
|
||||
|
||||
proceed, err := hc.checkTransferWithinNetwork(ctx, lp.Log.Address.Hex(), from.Hex(), to.Hex())
|
||||
proceed, err := hc.checkWithinNetwork(ctx, lp.Log.Address.Hex(), from.Hex(), to.Hex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func HandleTokenTransferInputData(hc *HandlerContainer) router.InputDataHandlerF
|
||||
return err
|
||||
}
|
||||
|
||||
proceed, err := hc.checkTransferWithinNetwork(ctx, idp.ContractAddress, idp.From, to.Hex())
|
||||
proceed, err := hc.checkWithinNetwork(ctx, idp.ContractAddress, idp.From, to.Hex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func HandleTokenTransferInputData(hc *HandlerContainer) router.InputDataHandlerF
|
||||
return err
|
||||
}
|
||||
|
||||
proceed, err := hc.checkTransferWithinNetwork(ctx, idp.ContractAddress, from.Hex(), to.Hex())
|
||||
proceed, err := hc.checkWithinNetwork(ctx, idp.ContractAddress, from.Hex(), to.Hex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -125,12 +125,3 @@ func HandleTokenTransferInputData(hc *HandlerContainer) router.InputDataHandlerF
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (hc *HandlerContainer) checkTransferWithinNetwork(ctx context.Context, contractAddress string, from string, to string) (bool, error) {
|
||||
exists, err := hc.cache.ExistsNetwork(ctx, contractAddress, from, to)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
12
internal/handler/within_network.go
Normal file
12
internal/handler/within_network.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package handler
|
||||
|
||||
import "context"
|
||||
|
||||
func (hc *HandlerContainer) checkWithinNetwork(ctx context.Context, contractAddress string, from string, to string) (bool, error) {
|
||||
exists, err := hc.cache.ExistsNetwork(ctx, contractAddress, from, to)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return exists, nil
|
||||
}
|
||||
Reference in New Issue
Block a user