pump and pump swap errTx parser
This commit is contained in:
@@ -3,7 +3,6 @@ package parser
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
types "github.com/thloyi/pump-parser"
|
||||
)
|
||||
|
||||
@@ -23,24 +22,14 @@ func NewPumpHandler(cb func(*types.Tx)) *PumpHandler {
|
||||
func (h *PumpHandler) HandleMessage(rawTx *types.RawTx) {
|
||||
if rawTx.Meta.Err != nil {
|
||||
// Notify the channel about the failed transaction
|
||||
beforeSolBalance := decimal.Zero
|
||||
afterSolBalance := decimal.Zero
|
||||
if rawTx.Meta.PreBalances != nil && len(rawTx.Meta.PreBalances) > 0 {
|
||||
beforeSolBalance = decimal.NewFromUint64(rawTx.Meta.PreBalances[0]).Div(decimal.NewFromInt(1e9))
|
||||
var parsedTx = &types.Tx{}
|
||||
parsedTx.SetRawTx(rawTx)
|
||||
err := parsedTx.Parser()
|
||||
if err != nil {
|
||||
fmt.Printf("parser failed tx error: %s, block: %d tx: %s\n", err, rawTx.Slot, rawTx.TxHash())
|
||||
return
|
||||
}
|
||||
if rawTx.Meta.PostBalances != nil && len(rawTx.Meta.PostBalances) > 0 {
|
||||
afterSolBalance = decimal.NewFromUint64(rawTx.Meta.PostBalances[0]).Div(decimal.NewFromInt(1e9))
|
||||
}
|
||||
h.callback(&types.Tx{
|
||||
TxHash: (*[64]byte)((rawTx.Transaction.Signatures[0][:])),
|
||||
Err: rawTx.Meta.Err,
|
||||
Signer: rawTx.GetSigner(),
|
||||
Block: rawTx.Slot,
|
||||
BlockIndex: uint64(rawTx.IndexWithinBlock),
|
||||
|
||||
BeforeSolBalance: beforeSolBalance,
|
||||
AfterSOLBalance: afterSolBalance,
|
||||
})
|
||||
h.callback(parsedTx)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user