mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2026-05-15 09:47:13 +02:00
fix: process contract creations
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user