diff --git a/core/tx.go b/core/tx.go index 5eb1041..b1d1481 100644 --- a/core/tx.go +++ b/core/tx.go @@ -27,6 +27,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/incentives" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/lockup" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/superfluid" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/tokenfactory" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" "github.com/DefiantLabs/cosmos-tax-cli/tendermint/modules/liquidity" "github.com/DefiantLabs/cosmos-tax-cli/util" @@ -133,6 +134,11 @@ var messageTypeIgnorer = map[string]interface{}{ liquidity.MsgWithdrawWithinBatch: nil, liquidity.MsgSwapWithinBatch: nil, + // These tokenfactory module messages dont create taxable events + tokenfactory.MsgCreateDenom: nil, + tokenfactory.MsgSetBeforeSendHook: nil, + tokenfactory.MsgSetDenomMetadata: nil, + //////////////////////////////////////////////////// /////// Possible Taxable Events, future work /////// //////////////////////////////////////////////////// diff --git a/osmosis/handlers.go b/osmosis/handlers.go index 9576a03..239611d 100644 --- a/osmosis/handlers.go +++ b/osmosis/handlers.go @@ -6,6 +6,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/cosmwasmpool" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/tokenfactory" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" ) @@ -38,4 +39,6 @@ var MessageTypeHandler = map[string][]func() txTypes.CosmosMessage{ valsetpref.MsgUndelegateFromValidatorSet: {func() txTypes.CosmosMessage { return &valsetpref.WrapperMsgUndelegateFromValidatorSet{} }}, valsetpref.MsgWithdrawDelegationRewards: {func() txTypes.CosmosMessage { return &valsetpref.WrapperMsgWithdrawDelegationRewards{} }}, valsetpref.MsgUndelegateFromRebalancedValidatorSet: {func() txTypes.CosmosMessage { return &valsetpref.WrapperMsgUndelegateFromRebalancedValidatorSet{} }}, + tokenfactory.MsgMint: {func() txTypes.CosmosMessage { return &tokenfactory.WrapperMsgMint{} }}, + tokenfactory.MsgBurn: {func() txTypes.CosmosMessage { return &tokenfactory.WrapperMsgBurn{} }}, } diff --git a/osmosis/modules/tokenfactory/types.go b/osmosis/modules/tokenfactory/types.go new file mode 100644 index 0000000..e4af181 --- /dev/null +++ b/osmosis/modules/tokenfactory/types.go @@ -0,0 +1,109 @@ +package tokenfactory + +import ( + "fmt" + + parsingTypes "github.com/DefiantLabs/cosmos-tax-cli/cosmos/modules" + txModule "github.com/DefiantLabs/cosmos-tax-cli/cosmos/modules/tx" + "github.com/DefiantLabs/cosmos-tax-cli/util" + sdk "github.com/cosmos/cosmos-sdk/types" + tfTypes "github.com/osmosis-labs/osmosis/v21/x/tokenfactory/types" +) + +const ( + MsgCreateDenom = "/osmosis.tokenfactory.v1beta1.MsgCreateDenom" + MsgMint = "/osmosis.tokenfactory.v1beta1.MsgMint" + MsgBurn = "/osmosis.tokenfactory.v1beta1.MsgBurn" + MsgSetDenomMetadata = "/osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata" + MsgSetBeforeSendHook = "/osmosis.tokenfactory.v1beta1.MsgSetBeforeSendHook" +) + +// Create interface definition for MsgMint +type WrapperMsgMint struct { + txModule.Message + OsmosisMsgMint *tfTypes.MsgMint + Address string + CoinReceived sdk.Coin +} + +func (sf *WrapperMsgMint) String() string { + return fmt.Sprintf("MsgMint: %s received %s", + sf.Address, sf.CoinReceived.String()) +} + +func (sf *WrapperMsgMint) HandleMsg(msgType string, msg sdk.Msg, log *txModule.LogMessage) error { + sf.Type = msgType + sf.OsmosisMsgMint = msg.(*tfTypes.MsgMint) + + validLog := txModule.IsMessageActionEquals(sf.GetType(), log) + if !validLog { + return util.ReturnInvalidLog(msgType, log) + } + + // This logic is pulled from the Osmosis codebase of who gets minted to. + // See here: https://github.com/osmosis-labs/osmosis/blob/7c81b90825ab2efe92444ac167191b8d041e0c21/x/tokenfactory/keeper/msg_server.go#L63-L65 + + sf.Address = sf.OsmosisMsgMint.MintToAddress + + if sf.Address == "" { + sf.Address = sf.OsmosisMsgMint.Sender + } + + sf.CoinReceived = sf.OsmosisMsgMint.Amount + + return nil +} + +func (sf *WrapperMsgMint) ParseRelevantData() []parsingTypes.MessageRelevantInformation { + relevantData := make([]parsingTypes.MessageRelevantInformation, 1) + + relevantData[0] = parsingTypes.MessageRelevantInformation{ + AmountReceived: sf.CoinReceived.Amount.BigInt(), + DenominationReceived: sf.CoinReceived.Denom, + ReceiverAddress: sf.Address, + } + return relevantData +} + +type WrapperMsgBurn struct { + txModule.Message + OsmosisMsgBurn *tfTypes.MsgBurn + Address string + CoinSent sdk.Coin +} + +func (sf *WrapperMsgBurn) String() string { + return fmt.Sprintf("MsgBurn: %s sent %s", + sf.Address, sf.CoinSent.String()) +} + +func (sf *WrapperMsgBurn) HandleMsg(msgType string, msg sdk.Msg, log *txModule.LogMessage) error { + sf.Type = msgType + sf.OsmosisMsgBurn = msg.(*tfTypes.MsgBurn) + + validLog := txModule.IsMessageActionEquals(sf.GetType(), log) + if !validLog { + return util.ReturnInvalidLog(msgType, log) + } + + sf.Address = sf.OsmosisMsgBurn.BurnFromAddress + + if sf.Address == "" { + sf.Address = sf.OsmosisMsgBurn.Sender + } + + sf.CoinSent = sf.OsmosisMsgBurn.Amount + + return nil +} + +func (sf *WrapperMsgBurn) ParseRelevantData() []parsingTypes.MessageRelevantInformation { + relevantData := make([]parsingTypes.MessageRelevantInformation, 1) + + relevantData[0] = parsingTypes.MessageRelevantInformation{ + AmountSent: sf.CoinSent.Amount.BigInt(), + DenominationSent: sf.CoinSent.Denom, + SenderAddress: sf.Address, + } + return relevantData +}