-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new tool for dumping failed heights from db to json file * Add parser and handler for MsgCreateCosmwasmPool that gets the amount spent for the address that created the pool * Add missing ignore list entry for MsgVoteWeighted * Improve pool manager swap exact amount in to prefer token_swapped event but fallback to transfer event if it fails * Reorganize Osmosis gamm parser package for easier development * Split poolmodels creation messages out of reorganized creates gamm file for more reorg * Add stableswap pool creation message parser and handlers * Add more ignore list entries for other message types * Add new parser for msgswapexactamountin that fixes errors produced by event emissions containing empty strings for amount values
- Loading branch information
Showing
19 changed files
with
2,396 additions
and
1,988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package cosmwasmpool | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
parsingTypes "github.com/DefiantLabs/cosmos-indexer/cosmos/modules" | ||
txModule "github.com/DefiantLabs/cosmos-indexer/cosmos/modules/tx" | ||
"github.com/DefiantLabs/cosmos-indexer/util" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
cosmwasmPoolModelTypes "github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/model" | ||
) | ||
|
||
const ( | ||
MsgCreateCosmWasmPool = "/osmosis.cosmwasmpool.v1beta1.MsgCreateCosmWasmPool" | ||
) | ||
|
||
type WrapperMsgCreateCosmWasmPool struct { | ||
txModule.Message | ||
OsmosisMsgCreateCosmWasmPool *cosmwasmPoolModelTypes.MsgCreateCosmWasmPool | ||
Address string | ||
TokensSpent sdk.Coins | ||
} | ||
|
||
func (sf *WrapperMsgCreateCosmWasmPool) String() string { | ||
var tokensSpent []string | ||
if !(len(sf.TokensSpent) == 0) { | ||
for _, v := range sf.TokensSpent { | ||
tokensSpent = append(tokensSpent, v.String()) | ||
} | ||
} | ||
return fmt.Sprintf("MsgCreateCosmWasmPool: %s created pool and spent %s", | ||
sf.Address, strings.Join(tokensSpent, ", ")) | ||
} | ||
|
||
func (sf *WrapperMsgCreateCosmWasmPool) HandleMsg(msgType string, msg sdk.Msg, log *txModule.LogMessage) error { | ||
sf.Type = msgType | ||
sf.OsmosisMsgCreateCosmWasmPool = msg.(*cosmwasmPoolModelTypes.MsgCreateCosmWasmPool) | ||
|
||
validLog := txModule.IsMessageActionEquals(sf.GetType(), log) | ||
if !validLog { | ||
return util.ReturnInvalidLog(msgType, log) | ||
} | ||
|
||
coinSpentEvents := txModule.GetEventsWithType("coin_spent", log) | ||
if len(coinSpentEvents) == 0 { | ||
return &txModule.MessageLogFormatError{MessageType: msgType, Log: fmt.Sprintf("%+v", log)} | ||
} | ||
|
||
senderCoinsSpentStrings := txModule.GetCoinsSpent(sf.OsmosisMsgCreateCosmWasmPool.Sender, coinSpentEvents) | ||
|
||
for _, coinSpentString := range senderCoinsSpentStrings { | ||
coinsSpent, err := sdk.ParseCoinsNormalized(coinSpentString) | ||
if err != nil { | ||
return errors.New("error parsing coins spent from event") | ||
} | ||
|
||
sf.TokensSpent = append(sf.TokensSpent, coinsSpent...) | ||
} | ||
|
||
sf.Address = sf.OsmosisMsgCreateCosmWasmPool.Sender | ||
|
||
return nil | ||
} | ||
|
||
func (sf *WrapperMsgCreateCosmWasmPool) ParseRelevantData() []parsingTypes.MessageRelevantInformation { | ||
relevantData := make([]parsingTypes.MessageRelevantInformation, 0) | ||
for _, token := range sf.TokensSpent { | ||
if token.Amount.IsPositive() { | ||
relevantData = append(relevantData, parsingTypes.MessageRelevantInformation{ | ||
AmountSent: token.Amount.BigInt(), | ||
DenominationSent: token.Denom, | ||
SenderAddress: sf.Address, | ||
}) | ||
} | ||
} | ||
return relevantData | ||
} |
Oops, something went wrong.