-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 05d1426 Author: 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 commit 4b2ad3d Author: 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](knadh/koanf@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> commit f1086fc Author: 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 commit fd59d28 Author: Mohammed Sohail <sohailsameja@gmail.com> Date: Mon Oct 7 09:49:01 2024 +0300 feat: add custodial registration proxy handler
- Loading branch information
1 parent
8e3e027
commit 725c18c
Showing
12 changed files
with
206 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package handler | ||
|
||
import ( | ||
"context" | ||
|
||
"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 custodialRegistrationEventName = "CUSTODIAL_REGISTRATION" | ||
|
||
var ( | ||
custodialRegistrationEvent = w3.MustNewEvent("NewRegistration(address indexed subject)") | ||
custodialRegistrationSig = w3.MustNewFunc("register(address)", "") | ||
) | ||
|
||
func HandleCustodialRegistrationLog() router.LogHandlerFunc { | ||
return func(ctx context.Context, lp router.LogPayload, c router.Callback) error { | ||
var account common.Address | ||
|
||
if err := custodialRegistrationEvent.DecodeArgs(lp.Log, &account); err != nil { | ||
return err | ||
} | ||
|
||
custodialRegistrationEvent := 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: custodialRegistrationEventName, | ||
Payload: map[string]any{ | ||
"account": account.Hex(), | ||
}, | ||
} | ||
|
||
return c(ctx, custodialRegistrationEvent) | ||
} | ||
} | ||
|
||
func HandleCustodialRegistrationInputData() router.InputDataHandlerFunc { | ||
return func(ctx context.Context, idp router.InputDataPayload, c router.Callback) error { | ||
var account common.Address | ||
|
||
if err := custodialRegistrationSig.DecodeArgs(w3.B(idp.InputData), &account); err != nil { | ||
return err | ||
} | ||
|
||
custodialRegistrationEvent := event.Event{ | ||
Block: idp.Block, | ||
ContractAddress: idp.ContractAddress, | ||
Success: false, | ||
Timestamp: idp.Timestamp, | ||
TxHash: idp.TxHash, | ||
TxType: custodialRegistrationEventName, | ||
Payload: map[string]any{ | ||
"account": account.Hex(), | ||
}, | ||
} | ||
|
||
return c(ctx, custodialRegistrationEvent) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters