mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2026-04-23 09:14:40 +02:00
Squashed commit of the following:
commit05d142664dAuthor: Mohamed Sohail 天明 <sohailsameja@gmail.com> Date: Mon Oct 7 15:12:58 2024 +0300 feat: handle contract creation (#43) * feat: add contract creation handler * fix: process contract creations * fix: redis keys name commit4b2ad3daf9Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Oct 7 15:12:15 2024 +0300 build(deps): bump github.com/knadh/koanf/providers/env (#37) Bumps [github.com/knadh/koanf/providers/env](https://github.com/knadh/koanf) from 0.1.0 to 1.0.0. - [Release notes](https://github.com/knadh/koanf/releases) - [Commits](https://github.com/knadh/koanf/compare/v0.1.0...v1.0.0) --- updated-dependencies: - dependency-name: github.com/knadh/koanf/providers/env dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commitf1086fcdc1Author: Mohamed Sohail 天明 <sohailsameja@gmail.com> Date: Mon Oct 7 10:07:11 2024 +0300 feat: optimize exists to check multiple keys in one call (#40) * closes #32 commitfd59d286f5Author: Mohammed Sohail <sohailsameja@gmail.com> Date: Mon Oct 7 09:49:01 2024 +0300 feat: add custodial registration proxy handler
This commit is contained in:
@@ -25,8 +25,18 @@ type (
|
||||
TxHash string
|
||||
}
|
||||
|
||||
LogHandlerFunc func(context.Context, LogPayload, Callback) error
|
||||
InputDataHandlerFunc func(context.Context, InputDataPayload, Callback) error
|
||||
ContractCreationPayload struct {
|
||||
From string
|
||||
ContractAddress string
|
||||
Block uint64
|
||||
Timestamp uint64
|
||||
TxHash string
|
||||
Success bool
|
||||
}
|
||||
|
||||
LogHandlerFunc func(context.Context, LogPayload, Callback) error
|
||||
InputDataHandlerFunc func(context.Context, InputDataPayload, Callback) error
|
||||
ContractCreationHandlerFunc func(context.Context, ContractCreationPayload, Callback) error
|
||||
|
||||
LogRouteEntry struct {
|
||||
Signature common.Hash
|
||||
@@ -39,17 +49,19 @@ type (
|
||||
}
|
||||
|
||||
Router struct {
|
||||
callbackFn Callback
|
||||
logHandlers map[common.Hash]LogRouteEntry
|
||||
inputDataHandlers map[string]InputDataEntry
|
||||
callbackFn Callback
|
||||
logHandlers map[common.Hash]LogRouteEntry
|
||||
inputDataHandlers map[string]InputDataEntry
|
||||
contractCreationHandler ContractCreationHandlerFunc
|
||||
}
|
||||
)
|
||||
|
||||
func New(callbackFn Callback) *Router {
|
||||
return &Router{
|
||||
callbackFn: callbackFn,
|
||||
logHandlers: make(map[common.Hash]LogRouteEntry),
|
||||
inputDataHandlers: make(map[string]InputDataEntry),
|
||||
callbackFn: callbackFn,
|
||||
logHandlers: make(map[common.Hash]LogRouteEntry),
|
||||
inputDataHandlers: make(map[string]InputDataEntry),
|
||||
contractCreationHandler: nil,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +79,10 @@ func (r *Router) RegisterInputDataRoute(signature string, handlerFunc InputDataH
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Router) RegisterContractCreationHandler(handlerFunc ContractCreationHandlerFunc) {
|
||||
r.contractCreationHandler = handlerFunc
|
||||
}
|
||||
|
||||
func (r *Router) ProcessLog(ctx context.Context, payload LogPayload) error {
|
||||
handler, ok := r.logHandlers[payload.Log.Topics[0]]
|
||||
if ok {
|
||||
@@ -88,3 +104,7 @@ func (r *Router) ProcessInputData(ctx context.Context, payload InputDataPayload)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Router) ProcessContractCreation(ctx context.Context, payload ContractCreationPayload) error {
|
||||
return r.contractCreationHandler(ctx, payload, r.callbackFn)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user