feat: handle contract creation (#43)

* feat: add contract creation handler

* fix: process contract creations

* fix: redis keys name
This commit is contained in:
2024-10-07 15:12:58 +03:00
committed by GitHub
parent 4b2ad3daf9
commit 05d142664d
6 changed files with 124 additions and 15 deletions

View File

@@ -0,0 +1,28 @@
package handler
import (
"context"
"github.com/grassrootseconomics/eth-tracker/pkg/event"
"github.com/grassrootseconomics/eth-tracker/pkg/router"
)
const contractCreationEventName = "CONTRACT_CREATION"
func HandleContractCreation() router.ContractCreationHandlerFunc {
return func(ctx context.Context, ccp router.ContractCreationPayload, c router.Callback) error {
contractCreationEvent := event.Event{
Block: ccp.Block,
ContractAddress: ccp.ContractAddress,
Success: ccp.Success,
Timestamp: ccp.Timestamp,
TxHash: ccp.TxHash,
TxType: contractCreationEventName,
Payload: map[string]any{
"from": ccp.From,
},
}
return c(ctx, contractCreationEvent)
}
}