mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2025-02-23 16:08:42 +01:00
release(1.3.0-rc): Merge branch 'master' into cel2
This commit is contained in:
commit
6f850bb1d4
@ -25,6 +25,7 @@ func bootstrapEventRouter(cacheProvider cache.Cache, pubCB router.Callback) *rou
|
|||||||
router.RegisterLogRoute(w3.H("0xab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8"), handler.HandleTokenMintLog())
|
router.RegisterLogRoute(w3.H("0xab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8"), handler.HandleTokenMintLog())
|
||||||
router.RegisterLogRoute(w3.H("0x894e56e1dac400b4475c83d8af0f0aa44de17c62764bd82f6e768a504e242461"), handler.HandleCustodialRegistrationLog())
|
router.RegisterLogRoute(w3.H("0x894e56e1dac400b4475c83d8af0f0aa44de17c62764bd82f6e768a504e242461"), handler.HandleCustodialRegistrationLog())
|
||||||
router.RegisterLogRoute(w3.H("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"), handler.HandleTokenTransferLog(handlerContainer))
|
router.RegisterLogRoute(w3.H("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"), handler.HandleTokenTransferLog(handlerContainer))
|
||||||
|
router.RegisterLogRoute(w3.H("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"), handler.HandleTokenApproveLog())
|
||||||
|
|
||||||
router.RegisterInputDataRoute("63e4bff4", handler.HandleFaucetGiveInputData())
|
router.RegisterInputDataRoute("63e4bff4", handler.HandleFaucetGiveInputData())
|
||||||
router.RegisterInputDataRoute("de82efb4", handler.HandleFaucetGiveInputData())
|
router.RegisterInputDataRoute("de82efb4", handler.HandleFaucetGiveInputData())
|
||||||
@ -41,6 +42,7 @@ func bootstrapEventRouter(cacheProvider cache.Cache, pubCB router.Callback) *rou
|
|||||||
router.RegisterInputDataRoute("4420e486", handler.HandleCustodialRegistrationInputData())
|
router.RegisterInputDataRoute("4420e486", handler.HandleCustodialRegistrationInputData())
|
||||||
router.RegisterInputDataRoute("a9059cbb", handler.HandleTokenTransferInputData(handlerContainer))
|
router.RegisterInputDataRoute("a9059cbb", handler.HandleTokenTransferInputData(handlerContainer))
|
||||||
router.RegisterInputDataRoute("23b872dd", handler.HandleTokenTransferInputData(handlerContainer))
|
router.RegisterInputDataRoute("23b872dd", handler.HandleTokenTransferInputData(handlerContainer))
|
||||||
|
router.RegisterInputDataRoute("095ea7b3", handler.HandleTokenApproveInputData())
|
||||||
|
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
|
78
internal/handler/token_approve.go
Normal file
78
internal/handler/token_approve.go
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"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 approveEventName = "TOKEN_APPROVE"
|
||||||
|
|
||||||
|
var (
|
||||||
|
tokenApproveEvent = w3.MustNewEvent("Approval(address indexed _owner, address indexed _spender, uint256 _value)")
|
||||||
|
tokenApproveToSig = w3.MustNewFunc("approve(address, uint256)", "bool")
|
||||||
|
)
|
||||||
|
|
||||||
|
func HandleTokenApproveLog() router.LogHandlerFunc {
|
||||||
|
return func(ctx context.Context, lp router.LogPayload, c router.Callback) error {
|
||||||
|
var (
|
||||||
|
owner common.Address
|
||||||
|
spender common.Address
|
||||||
|
value big.Int
|
||||||
|
)
|
||||||
|
|
||||||
|
if err := tokenApproveEvent.DecodeArgs(lp.Log, &owner, &spender, &value); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenApproveEvent := 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: approveEventName,
|
||||||
|
Payload: map[string]any{
|
||||||
|
"owner": owner.Hex(),
|
||||||
|
"spender": spender.Hex(),
|
||||||
|
"value": value.String(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return c(ctx, tokenApproveEvent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func HandleTokenApproveInputData() router.InputDataHandlerFunc {
|
||||||
|
return func(ctx context.Context, idp router.InputDataPayload, c router.Callback) error {
|
||||||
|
var (
|
||||||
|
spender common.Address
|
||||||
|
value big.Int
|
||||||
|
)
|
||||||
|
|
||||||
|
if err := tokenApproveToSig.DecodeArgs(w3.B(idp.InputData), &spender, &value); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenApproveEvent := event.Event{
|
||||||
|
Block: idp.Block,
|
||||||
|
ContractAddress: idp.ContractAddress,
|
||||||
|
Success: false,
|
||||||
|
Timestamp: idp.Timestamp,
|
||||||
|
TxHash: idp.TxHash,
|
||||||
|
TxType: approveEventName,
|
||||||
|
Payload: map[string]any{
|
||||||
|
"owner": idp.From,
|
||||||
|
"spender": spender.Hex(),
|
||||||
|
"value": value.String(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return c(ctx, tokenApproveEvent)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user