Skip to content

Commit

Permalink
Merge pull request #36 from KyberNetwork/add_log
Browse files Browse the repository at this point in the history
add log to check error parser
  • Loading branch information
ngocthanh1389 authored Apr 5, 2024
2 parents c6a4d6f + 246066c commit 7b20cd7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions internal/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ func (w *Worker) Run(ctx context.Context) error {
continue
}
if err := w.processMessages(m); err != nil {
w.l.Errorw("Error when proccess msg", "error", err)
return err
}
if err := w.listener.Ack(ctx, m); err != nil {
w.l.Errorw("Error when ack msg", "error", err)
return err
}
}
Expand All @@ -69,6 +71,7 @@ func (w *Worker) processMessages(m []evmlistenerclient.Message) error {
}
order, err := ps.Parse(convert.ToETHLog(log), block.Timestamp)
if err != nil {
w.l.Errorw("error when parse log", "log", log, "order", order, "err", err)
continue
}
insertOrders = append(insertOrders, order)
Expand Down
7 changes: 3 additions & 4 deletions pkg/parser/oneinch/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (p *Parser) Parse(log ethereumTypes.Log, blockTime uint64) (storage.TradeLo
}
order, err = p.detectOneInchRfqTrade(order)
if err != nil {
return storage.TradeLog{}, err
return order, err
}
return order, nil
}
Expand Down Expand Up @@ -137,7 +137,6 @@ func (p *Parser) detectOneInchRfqTrade(order storage.TradeLog) (storage.TradeLog
}

order, err = p.recursiveDetectOneInchRFQTrades(order, traceCall)

if err != nil {
return order, err
}
Expand All @@ -149,9 +148,8 @@ func (p *Parser) recursiveDetectOneInchRFQTrades(tradeLog storage.TradeLog, trac
var (
err error
)
isOneInchRFQTrade := p.isOneInchRFQTrades(tradeLog.MakerTokenAmount, tradeLog.OrderHash, traceCall)

if isOneInchRFQTrade {
if p.isOneInchRFQTrades(tradeLog.MakerTokenAmount, tradeLog.OrderHash, traceCall) {
return p.ParseFromInternalCall(tradeLog, traceCall)
}

Expand All @@ -178,6 +176,7 @@ func (p *Parser) isOneInchRFQTrades(makingAmountOrder string, orderHash string,
if err != nil {
return false
}

return orderHash == orderHashFromOutput && makingAmount == makingAmountOrder
}
return false
Expand Down
9 changes: 5 additions & 4 deletions pkg/parser/oneinchv6/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (p *Parser) Parse(log ethereumTypes.Log, blockTime uint64) (storage.TradeLo
}
order, err = p.detectOneInchRfqTrade(order)
if err != nil {
return storage.TradeLog{}, err
return order, err
}
return order, nil
}
Expand Down Expand Up @@ -133,6 +133,7 @@ func (p *Parser) detectOneInchRfqTrade(order storage.TradeLog) (storage.TradeLog
traceCall types.CallFrame
err error
)

traceCall, err = p.traceCalls.GetTraceCall(order.TxHash)
if err != nil {
return order, err
Expand All @@ -151,8 +152,7 @@ func (p *Parser) recursiveDetectOneInchRFQTrades(tradeLog storage.TradeLog, trac
var (
err error
)
isOneInchRFQTrade := p.isOneInchRFQTrades(tradeLog.OrderHash, traceCall, count)
if isOneInchRFQTrade {
if p.isOneInchRFQTrades(tradeLog.OrderHash, traceCall, count) {
return p.ParseFromInternalCall(tradeLog, traceCall)
}

Expand All @@ -162,6 +162,7 @@ func (p *Parser) recursiveDetectOneInchRFQTrades(tradeLog storage.TradeLog, trac
return tradeLog, nil
}
}

return tradeLog, ErrNotFoundTraceCall
}

Expand Down Expand Up @@ -230,5 +231,5 @@ func (p *Parser) decodeOutput(output string) (string, string, string, error) {
}

func (p *Parser) Exchange() string {
return parser.Ex1Inch
return parser.Ex1InchV6
}
1 change: 1 addition & 0 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
ExHashflow = "hashflow"
ExKsRFQ = "kyberswapRFQ"
Ex1Inch = "1inch"
Ex1InchV6 = "1inchV6"
ExHashflowV3 = "hashflowV3"
ExParaswapTaker = "paraswap_taker"
ExUniswapX = "uniswapx"
Expand Down

0 comments on commit 7b20cd7

Please sign in to comment.