Skip to content

Commit

Permalink
Patch/failed blocks fixes (#538)
Browse files Browse the repository at this point in the history
* Add staking type to cryptotaxcalculator withdraw delegator rewards parsers

* Add tokenfactory change admin to ignore list. Improve poolmanager parser for more edge cases
  • Loading branch information
pharr117 authored Mar 22, 2024
1 parent b6bf428 commit b2a559a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ var messageTypeIgnorer = map[string]interface{}{
tokenfactory.MsgCreateDenom: nil,
tokenfactory.MsgSetBeforeSendHook: nil,
tokenfactory.MsgSetDenomMetadata: nil,
tokenfactory.MsgChangeAdmin: nil,

////////////////////////////////////////////////////
/////// Possible Taxable Events, future work ///////
Expand Down
14 changes: 12 additions & 2 deletions cosmos/modules/tx/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,18 @@ func ParseTransferEvent(evt LogMessageEvent) ([]TransferEvent, error) {
return nil, err
}

// validate the transfer event
if transferEvent.Recipient == "" || transferEvent.Sender == "" || transferEvent.Amount == "" {
// Osmosis tends to emit large volumes of empty transfer events, just skip these
if transferEvent.Recipient == "" && transferEvent.Sender == "" && transferEvent.Amount == "" {
continue
}

// We skip empty amounts as well
if transferEvent.Amount == "" {
continue
}

// we require a transfer actually have addresses
if transferEvent.Recipient == "" || transferEvent.Sender == "" {
return nil, errInvalidTransfer
}

Expand Down
4 changes: 2 additions & 2 deletions osmosis/modules/poolmanager/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (sf *WrapperMsgSwapExactAmountIn) HandleMsg(msgType string, msg sdk.Msg, lo

parsed := false

if tokensSwappedEvt == nil {
if tokensSwappedEvt != nil {

// The last route in the hops gives the token out denom and pool ID for the final output
lastRoute := sf.OsmosisMsgSwapExactAmountIn.Routes[len(sf.OsmosisMsgSwapExactAmountIn.Routes)-1]
Expand All @@ -159,7 +159,7 @@ func (sf *WrapperMsgSwapExactAmountIn) HandleMsg(msgType string, msg sdk.Msg, lo
// We will attempt to get the last transfer event that executed for the sender
// We are scoping it for now so as not to blast all the way to the beginning but to address
// poolmanager CosmWasm pool executions that seem to send some small amount to a different address right at the end
for i := len(transferEvents) - 1; !parsed && len(transferEvents)-2 >= 0 && i >= len(transferEvents)-2; i-- {
for i := len(transferEvents) - 1; !parsed && i >= len(transferEvents)-2 && i >= 0; i-- {
lastParsedIndex = i
transferEvt := &transferEvents[i]

Expand Down
1 change: 1 addition & 0 deletions osmosis/modules/tokenfactory/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
MsgBurn = "/osmosis.tokenfactory.v1beta1.MsgBurn"
MsgSetDenomMetadata = "/osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata"
MsgSetBeforeSendHook = "/osmosis.tokenfactory.v1beta1.MsgSetBeforeSendHook"
MsgChangeAdmin = "/osmosis.tokenfactory.v1beta1.MsgChangeAdmin"
)

// Create interface definition for MsgMint
Expand Down

0 comments on commit b2a559a

Please sign in to comment.