mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2025-02-22 16:00:37 +01:00
fix: process contract creations
This commit is contained in:
parent
db62baddef
commit
9c8a4e3d1b
@ -230,12 +230,12 @@ func bootstrapCache() error {
|
||||
}
|
||||
|
||||
for _, address := range ko.MustStrings("bootstrap.watchlist") {
|
||||
if err := cache.Add(ctx, address); err != nil {
|
||||
if err := cache.Add(ctx, ethutils.HexToAddress(address).Hex()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for _, address := range ko.MustStrings("bootstrap.blacklist") {
|
||||
if err := cache.Remove(ctx, address); err != nil {
|
||||
if err := cache.Remove(ctx, ethutils.HexToAddress(address).Hex()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ func HandleContractCreation() router.ContractCreationHandlerFunc {
|
||||
Success: ccp.Success,
|
||||
Timestamp: ccp.Timestamp,
|
||||
TxHash: ccp.TxHash,
|
||||
TxType: contractCreationEventName,
|
||||
Payload: map[string]any{
|
||||
"from": ccp.From,
|
||||
},
|
||||
|
@ -88,14 +88,13 @@ func (p *Processor) ProcessBlock(ctx context.Context, blockNumber uint64) error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if exists && tx.To() != nil {
|
||||
if exists {
|
||||
if err := p.router.ProcessContractCreation(
|
||||
ctx,
|
||||
router.ContractCreationPayload{
|
||||
From: from.Hex(),
|
||||
Block: blockNumber,
|
||||
ContractAddress: tx.To().Hex(),
|
||||
ContractAddress: receipt.ContractAddress.Hex(),
|
||||
Timestamp: block.Time(),
|
||||
TxHash: receipt.TxHash.Hex(),
|
||||
Success: true,
|
||||
@ -105,63 +104,62 @@ func (p *Processor) ProcessBlock(ctx context.Context, blockNumber uint64) error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if receipt.Status == 0 {
|
||||
tx, err := p.chain.GetTransaction(ctx, receipt.TxHash)
|
||||
if err != nil && !errors.Is(err, context.Canceled) {
|
||||
return fmt.Errorf("get transaction error: tx %s: %v", receipt.TxHash.Hex(), err)
|
||||
if receipt.Status == 0 {
|
||||
tx, err := p.chain.GetTransaction(ctx, receipt.TxHash)
|
||||
if err != nil && !errors.Is(err, context.Canceled) {
|
||||
return fmt.Errorf("get transaction error: tx %s: %v", receipt.TxHash.Hex(), err)
|
||||
}
|
||||
if tx.To() == nil {
|
||||
from, err := types.Sender(types.LatestSignerForChainID(tx.ChainId()), tx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("transaction decode error: tx %s: %v", receipt.TxHash.Hex(), err)
|
||||
}
|
||||
|
||||
if tx.To() == nil {
|
||||
exists, err := p.cache.Exists(ctx, from.Hex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if exists {
|
||||
if err := p.router.ProcessContractCreation(
|
||||
ctx,
|
||||
router.ContractCreationPayload{
|
||||
From: from.Hex(),
|
||||
Block: blockNumber,
|
||||
ContractAddress: receipt.ContractAddress.Hex(),
|
||||
Timestamp: block.Time(),
|
||||
TxHash: receipt.TxHash.Hex(),
|
||||
Success: false,
|
||||
},
|
||||
); err != nil && !errors.Is(err, context.Canceled) {
|
||||
return fmt.Errorf("route reverted contract creation error: tx %s: %v", receipt.TxHash.Hex(), err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
exists, err := p.cache.Exists(ctx, tx.To().Hex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if exists {
|
||||
from, err := types.Sender(types.LatestSignerForChainID(tx.ChainId()), tx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("transaction decode error: tx %s: %v", receipt.TxHash.Hex(), err)
|
||||
}
|
||||
|
||||
exists, err := p.cache.Exists(ctx, from.Hex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if exists {
|
||||
if err := p.router.ProcessContractCreation(
|
||||
ctx,
|
||||
router.ContractCreationPayload{
|
||||
From: from.Hex(),
|
||||
Block: blockNumber,
|
||||
ContractAddress: tx.To().Hex(),
|
||||
Timestamp: block.Time(),
|
||||
TxHash: receipt.TxHash.Hex(),
|
||||
Success: false,
|
||||
},
|
||||
); err != nil && !errors.Is(err, context.Canceled) {
|
||||
return fmt.Errorf("route reverted contract creation error: tx %s: %v", receipt.TxHash.Hex(), err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
exists, err := p.cache.Exists(ctx, tx.To().Hex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if exists {
|
||||
from, err := types.Sender(types.LatestSignerForChainID(tx.ChainId()), tx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("transaction decode error: tx %s: %v", receipt.TxHash.Hex(), err)
|
||||
}
|
||||
|
||||
if err := p.router.ProcessInputData(
|
||||
ctx,
|
||||
router.InputDataPayload{
|
||||
From: from.Hex(),
|
||||
InputData: common.Bytes2Hex(tx.Data()),
|
||||
Block: blockNumber,
|
||||
ContractAddress: tx.To().Hex(),
|
||||
Timestamp: block.Time(),
|
||||
TxHash: receipt.TxHash.Hex(),
|
||||
},
|
||||
); err != nil && !errors.Is(err, context.Canceled) {
|
||||
return fmt.Errorf("route revert transaction error: tx %s: %v", receipt.TxHash.Hex(), err)
|
||||
}
|
||||
if err := p.router.ProcessInputData(
|
||||
ctx,
|
||||
router.InputDataPayload{
|
||||
From: from.Hex(),
|
||||
InputData: common.Bytes2Hex(tx.Data()),
|
||||
Block: blockNumber,
|
||||
ContractAddress: tx.To().Hex(),
|
||||
Timestamp: block.Time(),
|
||||
TxHash: receipt.TxHash.Hex(),
|
||||
},
|
||||
); err != nil && !errors.Is(err, context.Canceled) {
|
||||
return fmt.Errorf("route revert transaction error: tx %s: %v", receipt.TxHash.Hex(), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user