diff --git a/core/processor.go b/core/processor.go index c5c4332..7357c05 100644 --- a/core/processor.go +++ b/core/processor.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "math/big" + "time" "github.com/ethereum-optimism/optimism/indexer/config" "github.com/ethereum-optimism/optimism/op-bindings/bindings" @@ -242,33 +243,36 @@ func (b *Processor) FinalizeMessage(ctx context.Context, wi *WithdrawalInitiated return nil } -func (b *Processor) GetProvenTime(wi *WithdrawalInitiatedLog) (*big.Int, error) { +func (b *Processor) GetProvenTime(wi *WithdrawalInitiatedLog) (*time.Time, error) { optimismPortal, err := bindings.NewOptimismPortalCaller(b.cfg.L1Contracts.OptimismPortalProxy, b.L1Client) if err != nil { return nil, err } - receipt, err := b.L1Client.TransactionReceipt(context.Background(), common.HexToHash(wi.TransactionHash)) + receipt, err := b.L2Client.TransactionReceipt(context.Background(), common.HexToHash(wi.TransactionHash)) if err != nil { - return nil, err + return nil, fmt.Errorf("TransactionReceipt err: %v, wi: %v", err, wi) } withdrawal, err := b.toWithdrawal(wi, receipt) if err != nil { - return nil, err + return nil, fmt.Errorf("toWithdrawal err: %v, wi: %v", err, wi) } withdrawalHash, err := b.hashWithdrawal(withdrawal) if err != nil { - return nil, err + return nil, fmt.Errorf("hashWithdrawal err: %v, wi: %v", err, wi) } provenWithdrawal, err := optimismPortal.ProvenWithdrawals(nil, common.HexToHash(withdrawalHash)) if err != nil { - return nil, err + return nil, fmt.Errorf("optimismPortal.ProvenWithdrawals err: %v, wi: %v", err, wi) } - return provenWithdrawal.Timestamp, nil + unixTimestamp := provenWithdrawal.Timestamp.Int64() + t := time.Unix(unixTimestamp, 0) + b.log.Info("GetProvenTime", "time", t.String(), "unixTimestamp", unixTimestamp) + return &t, nil } func (b *Processor) hashWithdrawal(w *bindings.TypesWithdrawalTransaction) (string, error) {