diff --git a/usecase/parser/ibcmsg/ibcmsg.go b/usecase/parser/ibcmsg/ibcmsg.go index bf80a7db..bf618e3a 100644 --- a/usecase/parser/ibcmsg/ibcmsg.go +++ b/usecase/parser/ibcmsg/ibcmsg.go @@ -71,11 +71,15 @@ func parseRawMsgCreateTendermintLightClient( Signer: rawMsg.Signer, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, params.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCCreateClient( msgCommonParams, params, - )}, []string{params.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&txsResult.Log[msgIndex]) @@ -94,11 +98,15 @@ func parseRawMsgCreateTendermintLightClient( ClientType: event.MustGetAttributeByKey("client_type"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, params.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCCreateClient( msgCommonParams, params, - )}, []string{params.Signer} + )}, possibleSignerAddresses } func parseRawMsgCreateSoloMachineLightClient( @@ -121,11 +129,15 @@ func parseRawMsgCreateSoloMachineLightClient( Signer: rawMsg.Signer, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, params.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCCreateClient( msgCommonParams, params, - )}, []string{params.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&txsResult.Log[msgIndex]) @@ -144,11 +156,15 @@ func parseRawMsgCreateSoloMachineLightClient( ClientType: event.MustGetAttributeByKey("client_type"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, params.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCCreateClient( msgCommonParams, params, - )}, []string{params.Signer} + )}, possibleSignerAddresses } func ParseMsgConnectionOpenInit( @@ -160,13 +176,17 @@ func ParseMsgConnectionOpenInit( } if !parserParams.MsgCommonParams.TxSuccess { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, rawMessage.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCConnectionOpenInit( parserParams.MsgCommonParams, ibc_model.MsgConnectionOpenInitParams{ RawMsgConnectionOpenInit: rawMessage, }, - )}, []string{rawMessage.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -180,11 +200,15 @@ func ParseMsgConnectionOpenInit( ConnectionID: event.MustGetAttributeByKey("connection_id"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgConnectionOpenInitParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCConnectionOpenInit( parserParams.MsgCommonParams, msgConnectionOpenInitParams, - )}, []string{msgConnectionOpenInitParams.Signer} + )}, possibleSignerAddresses } func ParseMsgConnectionOpenTry( @@ -207,11 +231,15 @@ func ParseMsgConnectionOpenTry( MaybeTendermintClientState: &rawMsg.TendermintClientState, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgConnectionOpenTryParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCConnectionOpenTry( parserParams.MsgCommonParams, msgConnectionOpenTryParams, - )}, []string{msgConnectionOpenTryParams.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -226,11 +254,15 @@ func ParseMsgConnectionOpenTry( ConnectionID: event.MustGetAttributeByKey("connection_id"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgConnectionOpenTryParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCConnectionOpenTry( parserParams.MsgCommonParams, msgConnectionOpenTryParams, - )}, []string{msgConnectionOpenTryParams.Signer} + )}, possibleSignerAddresses } func ParseMsgConnectionOpenAck( @@ -253,11 +285,15 @@ func ParseMsgConnectionOpenAck( MaybeTendermintClientState: &rawMsg.TendermintClientState, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgConnectionOpenAckParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCConnectionOpenAck( parserParams.MsgCommonParams, msgConnectionOpenAckParams, - )}, []string{msgConnectionOpenAckParams.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -274,11 +310,15 @@ func ParseMsgConnectionOpenAck( CounterpartyClientID: event.MustGetAttributeByKey("counterparty_client_id"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgConnectionOpenAckParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCConnectionOpenAck( parserParams.MsgCommonParams, msgConnectionOpenAckParams, - )}, []string{msgConnectionOpenAckParams.Signer} + )}, possibleSignerAddresses } func ParseMsgConnectionOpenConfirm( @@ -290,13 +330,17 @@ func ParseMsgConnectionOpenConfirm( } if !parserParams.MsgCommonParams.TxSuccess { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, rawMsg.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCConnectionOpenConfirm( parserParams.MsgCommonParams, ibc_model.MsgConnectionOpenConfirmParams{ RawMsgConnectionOpenConfirm: rawMsg, }, - )}, []string{rawMsg.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -313,11 +357,15 @@ func ParseMsgConnectionOpenConfirm( CounterpartyConnectionID: event.MustGetAttributeByKey("counterparty_connection_id"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgConnectionOpenConfirmParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCConnectionOpenConfirm( parserParams.MsgCommonParams, msgConnectionOpenConfirmParams, - )}, []string{msgConnectionOpenConfirmParams.Signer} + )}, possibleSignerAddresses } func ParseMsgChannelOpenInit( @@ -329,13 +377,17 @@ func ParseMsgChannelOpenInit( } if !parserParams.MsgCommonParams.TxSuccess { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, rawMsg.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelOpenInit( parserParams.MsgCommonParams, ibc_model.MsgChannelOpenInitParams{ RawMsgChannelOpenInit: rawMsg, }, - )}, []string{rawMsg.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -351,11 +403,15 @@ func ParseMsgChannelOpenInit( ConnectionID: event.MustGetAttributeByKey("connection_id"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgChannelOpenInitParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelOpenInit( parserParams.MsgCommonParams, msgChannelOpenInitParams, - )}, []string{msgChannelOpenInitParams.Signer} + )}, possibleSignerAddresses } func ParseMsgChannelOpenTry( @@ -367,13 +423,18 @@ func ParseMsgChannelOpenTry( } if !parserParams.MsgCommonParams.TxSuccess { + + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, rawMsg.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelOpenTry( parserParams.MsgCommonParams, ibc_model.MsgChannelOpenTryParams{ RawMsgChannelOpenTry: rawMsg, }, - )}, []string{rawMsg.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -389,11 +450,15 @@ func ParseMsgChannelOpenTry( ConnectionID: event.MustGetAttributeByKey("connection_id"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgChannelOpenTryParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelOpenTry( parserParams.MsgCommonParams, msgChannelOpenTryParams, - )}, []string{msgChannelOpenTryParams.Signer} + )}, possibleSignerAddresses } func ParseMsgChannelOpenAck( @@ -405,13 +470,18 @@ func ParseMsgChannelOpenAck( } if !parserParams.MsgCommonParams.TxSuccess { + + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, rawMsg.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelOpenAck( parserParams.MsgCommonParams, ibc_model.MsgChannelOpenAckParams{ RawMsgChannelOpenAck: rawMsg, }, - )}, []string{rawMsg.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -427,11 +497,15 @@ func ParseMsgChannelOpenAck( ConnectionID: event.MustGetAttributeByKey("connection_id"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgChannelOpenAckParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelOpenAck( parserParams.MsgCommonParams, msgChannelOpenAckParams, - )}, []string{msgChannelOpenAckParams.Signer} + )}, possibleSignerAddresses } func ParseMsgChannelOpenConfirm( @@ -443,13 +517,17 @@ func ParseMsgChannelOpenConfirm( } if !parserParams.MsgCommonParams.TxSuccess { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, rawMsg.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelOpenConfirm( parserParams.MsgCommonParams, ibc_model.MsgChannelOpenConfirmParams{ RawMsgChannelOpenConfirm: rawMsg, }, - )}, []string{rawMsg.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -466,11 +544,15 @@ func ParseMsgChannelOpenConfirm( ConnectionID: event.MustGetAttributeByKey("connection_id"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgChannelOpenConfirmParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelOpenConfirm( parserParams.MsgCommonParams, msgChannelOpenConfirmParams, - )}, []string{msgChannelOpenConfirmParams.Signer} + )}, possibleSignerAddresses } func ParseMsgUpdateClient( @@ -520,11 +602,15 @@ func parseMsgUpdateTendermintLightClient( Signer: rawMsg.Signer, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, params.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCUpdateClient( msgCommonParams, params, - )}, []string{params.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&txsResult.Log[msgIndex]) @@ -542,11 +628,15 @@ func parseMsgUpdateTendermintLightClient( Signer: rawMsg.Signer, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, params.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCUpdateClient( msgCommonParams, params, - )}, []string{params.Signer} + )}, possibleSignerAddresses } func parseMsgUpdateSolomachineLightClient( @@ -570,11 +660,15 @@ func parseMsgUpdateSolomachineLightClient( Signer: rawMsg.Signer, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, params.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCUpdateClient( msgCommonParams, params, - )}, []string{params.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&txsResult.Log[msgIndex]) @@ -592,11 +686,15 @@ func parseMsgUpdateSolomachineLightClient( Signer: rawMsg.Signer, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, params.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCUpdateClient( msgCommonParams, params, - )}, []string{params.Signer} + )}, possibleSignerAddresses } func mustParseHeight(height string) ibc_model.Height { @@ -622,12 +720,16 @@ func ParseMsgTransfer( } if !parserParams.MsgCommonParams.TxSuccess { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, rawMsg.Sender) + return []command.Command{command_usecase.NewCreateMsgIBCTransferTransfer( parserParams.MsgCommonParams, ibc_model.MsgTransferParams{ RawMsgTransfer: rawMsg, }, - )}, []string{rawMsg.Sender} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -653,11 +755,15 @@ func ParseMsgTransfer( PacketData: fungiblePacketData, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgTransferParams.Sender) + return []command.Command{command_usecase.NewCreateMsgIBCTransferTransfer( parserParams.MsgCommonParams, msgTransferParams, - )}, []string{msgTransferParams.Sender} + )}, possibleSignerAddresses } func ParseMsgRecvPacket( @@ -690,11 +796,15 @@ func ParseMsgRecvPacket( }, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgRecvPacketParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCRecvPacket( parserParams.MsgCommonParams, msgRecvPacketParams, - )}, []string{msgRecvPacketParams.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -718,11 +828,15 @@ func ParseMsgRecvPacket( PacketSequence: typeconv.MustAtou64(recvPacketEvent.MustGetAttributeByKey("packet_sequence")), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgAlreadyRelayedRecvPacketParams.Signer) + return []command.Command{command_usecase.NewCreateMsgAlreadyRelayedIBCRecvPacket( parserParams.MsgCommonParams, msgAlreadyRelayedRecvPacketParams, - )}, []string{msgAlreadyRelayedRecvPacketParams.Signer} + )}, possibleSignerAddresses } var maybeDenominationTrace *ibc_model.MsgRecvPacketFungibleTokenDenominationTrace @@ -758,11 +872,15 @@ func ParseMsgRecvPacket( PacketAck: packetAck, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgRecvPacketParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCRecvPacket( parserParams.MsgCommonParams, msgRecvPacketParams, - )}, []string{msgRecvPacketParams.Signer} + )}, possibleSignerAddresses } func ParseMsgAcknowledgement( @@ -795,11 +913,15 @@ func ParseMsgAcknowledgement( }, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgAcknowledgementParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCAcknowledgement( parserParams.MsgCommonParams, msgAcknowledgementParams, - )}, []string{msgAcknowledgementParams.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -825,11 +947,15 @@ func ParseMsgAcknowledgement( ConnectionID: acknowledgePacketEvent.MustGetAttributeByKey("packet_connection"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgAlreadyRelayedAcknowledgementParams.Signer) + return []command.Command{command_usecase.NewCreateMsgAlreadyRelayedIBCAcknowledgement( parserParams.MsgCommonParams, msgAlreadyRelayedAcknowledgementParams, - )}, []string{msgAlreadyRelayedAcknowledgementParams.Signer} + )}, possibleSignerAddresses } var success bool @@ -869,11 +995,15 @@ func ParseMsgAcknowledgement( ConnectionID: acknowledgePacketEvent.MustGetAttributeByKey("packet_connection"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgAcknowledgementParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCAcknowledgement( parserParams.MsgCommonParams, msgAcknowledgementParams, - )}, []string{msgAcknowledgementParams.Signer} + )}, possibleSignerAddresses } func IsPacketMsgTransfer( @@ -916,11 +1046,15 @@ func ParseMsgTimeout( MessageType: "MsgTransfer", } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgTimeoutParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCTimeout( parserParams.MsgCommonParams, msgTimeoutParams, - )}, []string{msgTimeoutParams.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -958,18 +1092,23 @@ func ParseMsgTimeout( } timeoutEvent := log.GetEventByType("timeout") + + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgTimeoutParams.Signer) + if timeoutEvent == nil { return []command.Command{command_usecase.NewCreateMsgAlreadyRelayedIBCTimeout( parserParams.MsgCommonParams, msgTimeoutParams, - )}, []string{msgTimeoutParams.Signer} + )}, possibleSignerAddresses } else { return []command.Command{command_usecase.NewCreateMsgIBCTimeout( parserParams.MsgCommonParams, msgTimeoutParams, - )}, []string{msgTimeoutParams.Signer} + )}, possibleSignerAddresses } } @@ -994,11 +1133,15 @@ func ParseMsgTimeoutOnClose( MessageType: "MsgTransfer", } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgTimeoutOnCloseParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCTimeoutOnClose( parserParams.MsgCommonParams, msgTimeoutOnCloseParams, - )}, []string{msgTimeoutOnCloseParams.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -1036,18 +1179,23 @@ func ParseMsgTimeoutOnClose( } timeoutEvent := log.GetEventByType("timeout") + + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgTimeoutOnCloseParams.Signer) + if timeoutEvent == nil { return []command.Command{command_usecase.NewCreateMsgAlreadyRelayedIBCTimeoutOnClose( parserParams.MsgCommonParams, msgTimeoutOnCloseParams, - )}, []string{msgTimeoutOnCloseParams.Signer} + )}, possibleSignerAddresses } else { return []command.Command{command_usecase.NewCreateMsgIBCTimeoutOnClose( parserParams.MsgCommonParams, msgTimeoutOnCloseParams, - )}, []string{msgTimeoutOnCloseParams.Signer} + )}, possibleSignerAddresses } } @@ -1060,13 +1208,17 @@ func ParseMsgChannelCloseInit( } if !parserParams.MsgCommonParams.TxSuccess { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, rawMsg.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelCloseInit( parserParams.MsgCommonParams, ibc_model.MsgChannelCloseInitParams{ RawMsgChannelCloseInit: rawMsg, }, - )}, []string{rawMsg.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -1083,11 +1235,15 @@ func ParseMsgChannelCloseInit( ConnectionID: event.MustGetAttributeByKey("connection_id"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgChannelCloseInitParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelCloseInit( parserParams.MsgCommonParams, msgChannelCloseInitParams, - )}, []string{msgChannelCloseInitParams.Signer} + )}, possibleSignerAddresses } func ParseMsgChannelCloseConfirm( @@ -1099,13 +1255,17 @@ func ParseMsgChannelCloseConfirm( } if !parserParams.MsgCommonParams.TxSuccess { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, rawMsg.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelCloseConfirm( parserParams.MsgCommonParams, ibc_model.MsgChannelCloseConfirmParams{ RawMsgChannelCloseConfirm: rawMsg, }, - )}, []string{rawMsg.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -1122,9 +1282,13 @@ func ParseMsgChannelCloseConfirm( ConnectionID: event.MustGetAttributeByKey("connection_id"), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgChannelCloseConfirmParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCChannelCloseConfirm( parserParams.MsgCommonParams, msgChannelCloseConfirmParams, - )}, []string{msgChannelCloseConfirmParams.Signer} + )}, possibleSignerAddresses } diff --git a/usecase/parser/msg.go b/usecase/parser/msg.go index 765e301b..d2a90c10 100644 --- a/usecase/parser/msg.go +++ b/usecase/parser/msg.go @@ -140,6 +140,7 @@ func ParseBlockTxsMsgToCommands( Msg: msg, MsgIndex: msgIndex, ParserManager: parserManager, + Logger: parserManager.GetLogger(), }) } addresses = append(addresses, possibleSignerAddresses...) @@ -176,14 +177,18 @@ func ParseMsgMultiSend( ) ([]command.Command, []string) { rawInputs, _ := parserParams.Msg["inputs"].([]interface{}) inputs := make([]model.MsgMultiSendInput, 0, len(rawInputs)) - addresses := make([]string, 0, len(rawInputs)) + possibleSignerAddresses := make([]string, 0, len(rawInputs)) for _, rawInput := range rawInputs { input, _ := rawInput.(map[string]interface{}) + + if fromAddress, ok := input["address"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, fromAddress.(string)) + } + inputs = append(inputs, model.MsgMultiSendInput{ Address: input["address"].(string), Amount: tmcosmosutils.MustNewCoinsFromAmountInterface(input["coins"].([]interface{})), }) - addresses = append(addresses, input["address"].(string)) } rawOutputs, _ := parserParams.Msg["outputs"].([]interface{}) @@ -203,12 +208,20 @@ func ParseMsgMultiSend( Inputs: inputs, Outputs: outputs, }, - )}, addresses + )}, possibleSignerAddresses } func ParseMsgSetWithdrawAddress( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if delegatorAddress, ok := parserParams.Msg["delegator_address"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, delegatorAddress.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgSetWithdrawAddress( parserParams.MsgCommonParams, @@ -216,12 +229,20 @@ func ParseMsgSetWithdrawAddress( DelegatorAddress: parserParams.Msg["delegator_address"].(string), WithdrawAddress: parserParams.Msg["withdraw_address"].(string), }, - )}, []string{parserParams.Msg["delegator_address"].(string)} + )}, possibleSignerAddresses } func ParseMsgWithdrawDelegatorReward( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if delegatorAddress, ok := parserParams.Msg["delegator_address"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, delegatorAddress.(string)) + } + } + if !parserParams.MsgCommonParams.TxSuccess { delegatorAddress, _ := parserParams.Msg["delegator_address"].(string) return []command.Command{command_usecase.NewCreateMsgWithdrawDelegatorReward( @@ -233,7 +254,7 @@ func ParseMsgWithdrawDelegatorReward( RecipientAddress: delegatorAddress, Amount: coin.NewEmptyCoins(), }, - )}, []string{delegatorAddress} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) var recipient string @@ -257,12 +278,20 @@ func ParseMsgWithdrawDelegatorReward( RecipientAddress: recipient, Amount: amount, }, - )}, []string{parserParams.Msg["delegator_address"].(string)} + )}, possibleSignerAddresses } func ParseMsgWithdrawValidatorCommission( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if validatorAddress, ok := parserParams.Msg["validator_address"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, validatorAddress.(string)) + } + } + if !parserParams.MsgCommonParams.TxSuccess { return []command.Command{command_usecase.NewCreateMsgWithdrawValidatorCommission( parserParams.MsgCommonParams, @@ -272,7 +301,7 @@ func ParseMsgWithdrawValidatorCommission( RecipientAddress: "", Amount: coin.NewEmptyCoins(), }, - )}, []string{parserParams.Msg["validator_address"].(string)} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) var recipient string @@ -295,12 +324,20 @@ func ParseMsgWithdrawValidatorCommission( RecipientAddress: recipient, Amount: amount, }, - )}, []string{parserParams.Msg["validator_address"].(string)} + )}, possibleSignerAddresses } func ParseMsgFundCommunityPool( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if depositor, ok := parserParams.Msg["depositor"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, depositor.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgFundCommunityPool( parserParams.MsgCommonParams, @@ -308,7 +345,7 @@ func ParseMsgFundCommunityPool( Depositor: parserParams.Msg["depositor"].(string), Amount: tmcosmosutils.MustNewCoinsFromAmountInterface(parserParams.Msg["amount"].([]interface{})), }, - )}, []string{parserParams.Msg["depositor"].(string)} + )}, possibleSignerAddresses } func ParseMsgSubmitProposal( @@ -324,20 +361,19 @@ func ParseMsgSubmitProposal( } var cmds []command.Command - var addresses = []string{} + var possibleSignerAddresses = []string{} if proposalContent.Type == "/cosmos.params.v1beta1.ParameterChangeProposal" { - cmds, addresses = parseMsgSubmitParamChangeProposal(parserParams.MsgCommonParams.TxSuccess, parserParams.TxsResult, parserParams.MsgIndex, parserParams.MsgCommonParams, parserParams.Msg, rawContent) + cmds, possibleSignerAddresses = parseMsgSubmitParamChangeProposal(parserParams.MsgCommonParams.TxSuccess, parserParams.TxsResult, parserParams.MsgIndex, parserParams.MsgCommonParams, parserParams.Msg, rawContent) } else if proposalContent.Type == "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal" { - cmds, addresses = parseMsgSubmitCommunityFundSpendProposal(parserParams.MsgCommonParams.TxSuccess, parserParams.TxsResult, parserParams.MsgIndex, parserParams.MsgCommonParams, parserParams.Msg, rawContent) + cmds, possibleSignerAddresses = parseMsgSubmitCommunityFundSpendProposal(parserParams.MsgCommonParams.TxSuccess, parserParams.TxsResult, parserParams.MsgIndex, parserParams.MsgCommonParams, parserParams.Msg, rawContent) } else if proposalContent.Type == "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal" { - cmds, addresses = parseMsgSubmitSoftwareUpgradeProposal(parserParams.MsgCommonParams.TxSuccess, parserParams.TxsResult, parserParams.MsgIndex, parserParams.MsgCommonParams, parserParams.Msg, rawContent) + cmds, possibleSignerAddresses = parseMsgSubmitSoftwareUpgradeProposal(parserParams.MsgCommonParams.TxSuccess, parserParams.TxsResult, parserParams.MsgIndex, parserParams.MsgCommonParams, parserParams.Msg, rawContent) } else if proposalContent.Type == "/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal" { - cmds, addresses = parseMsgSubmitCancelSoftwareUpgradeProposal(parserParams.MsgCommonParams.TxSuccess, parserParams.TxsResult, parserParams.MsgIndex, parserParams.MsgCommonParams, parserParams.Msg, rawContent) + cmds, possibleSignerAddresses = parseMsgSubmitCancelSoftwareUpgradeProposal(parserParams.MsgCommonParams.TxSuccess, parserParams.TxsResult, parserParams.MsgIndex, parserParams.MsgCommonParams, parserParams.Msg, rawContent) } else if proposalContent.Type == "/cosmos.gov.v1beta1.TextProposal" { - cmds, addresses = parseMsgSubmitTextProposal(parserParams.MsgCommonParams.TxSuccess, parserParams.TxsResult, parserParams.MsgIndex, parserParams.MsgCommonParams, parserParams.Msg, rawContent) - // FIXME: https://github.com/crypto-com/chain-indexing/issues/707 - //} else { - // panic(fmt.Sprintf("unrecognzied govenance proposal type `%s`", proposalContent.Type)) + cmds, possibleSignerAddresses = parseMsgSubmitTextProposal(parserParams.MsgCommonParams.TxSuccess, parserParams.TxsResult, parserParams.MsgIndex, parserParams.MsgCommonParams, parserParams.Msg, rawContent) + } else { + parserParams.Logger.Errorf("unrecognzied govenance proposal type `%s`", proposalContent.Type) } if parserParams.MsgCommonParams.TxSuccess { @@ -354,7 +390,7 @@ func ParseMsgSubmitProposal( } } - return cmds, addresses + return cmds, possibleSignerAddresses } func parseMsgSubmitParamChangeProposal( @@ -370,6 +406,14 @@ func parseMsgSubmitParamChangeProposal( panic("error decoding param change proposal content") } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if msg != nil { + if proposer, ok := msg["proposer"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, proposer.(string)) + } + } + if !txSuccess { return []command.Command{command_usecase.NewCreateMsgSubmitParamChangeProposal( msgCommonParams, @@ -382,7 +426,7 @@ func parseMsgSubmitParamChangeProposal( msg["initial_deposit"].([]interface{}), ), }, - )}, []string{msg["proposer"].(string)} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&txsResult.Log[msgIndex]) event := log.GetEventByType("submit_proposal") @@ -405,7 +449,7 @@ func parseMsgSubmitParamChangeProposal( msg["initial_deposit"].([]interface{}), ), }, - )}, []string{msg["proposer"].(string)} + )}, possibleSignerAddresses } func parseMsgSubmitCommunityFundSpendProposal( @@ -428,6 +472,14 @@ func parseMsgSubmitCommunityFundSpendProposal( Amount: tmcosmosutils.MustNewCoinsFromAmountInterface(rawProposalContent.Amount), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if msg != nil { + if proposer, ok := msg["proposer"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, proposer.(string)) + } + } + if !txSuccess { return []command.Command{command_usecase.NewCreateMsgSubmitCommunityPoolSpendProposal( msgCommonParams, @@ -440,7 +492,7 @@ func parseMsgSubmitCommunityFundSpendProposal( msg["initial_deposit"].([]interface{}), ), }, - )}, []string{msg["proposer"].(string)} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&txsResult.Log[msgIndex]) // When there is no reward withdrew, `transfer` event would not exist @@ -464,7 +516,7 @@ func parseMsgSubmitCommunityFundSpendProposal( msg["initial_deposit"].([]interface{}), ), }, - )}, []string{msg["proposer"].(string)} + )}, possibleSignerAddresses } func parseMsgSubmitSoftwareUpgradeProposal( @@ -496,6 +548,14 @@ func parseMsgSubmitSoftwareUpgradeProposal( }, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if msg != nil { + if proposer, ok := msg["proposer"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, proposer.(string)) + } + } + if !txSuccess { return []command.Command{command_usecase.NewCreateMsgSubmitSoftwareUpgradeProposal( msgCommonParams, @@ -508,7 +568,7 @@ func parseMsgSubmitSoftwareUpgradeProposal( msg["initial_deposit"].([]interface{}), ), }, - )}, []string{msg["proposer"].(string)} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&txsResult.Log[msgIndex]) // When there is no reward withdrew, `transfer` event would not exist @@ -532,7 +592,7 @@ func parseMsgSubmitSoftwareUpgradeProposal( msg["initial_deposit"].([]interface{}), ), }, - )}, []string{msg["proposer"].(string)} + )}, possibleSignerAddresses } func parseMsgSubmitCancelSoftwareUpgradeProposal( @@ -548,6 +608,14 @@ func parseMsgSubmitCancelSoftwareUpgradeProposal( panic("error decoding software upgrade proposal content") } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if msg != nil { + if proposer, ok := msg["proposer"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, proposer.(string)) + } + } + if !txSuccess { return []command.Command{command_usecase.NewCreateMsgSubmitCancelSoftwareUpgradeProposal( msgCommonParams, @@ -560,7 +628,7 @@ func parseMsgSubmitCancelSoftwareUpgradeProposal( msg["initial_deposit"].([]interface{}), ), }, - )}, []string{msg["proposer"].(string)} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&txsResult.Log[msgIndex]) // When there is no reward withdrew, `transfer` event would not exist @@ -584,7 +652,7 @@ func parseMsgSubmitCancelSoftwareUpgradeProposal( msg["initial_deposit"].([]interface{}), ), }, - )}, []string{msg["proposer"].(string)} + )}, possibleSignerAddresses } func parseMsgSubmitTextProposal( @@ -600,6 +668,14 @@ func parseMsgSubmitTextProposal( panic("error decoding text proposal content") } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if msg != nil { + if proposer, ok := msg["proposer"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, proposer.(string)) + } + } + if !txSuccess { return []command.Command{command_usecase.NewCreateMsgSubmitTextProposal( msgCommonParams, @@ -612,7 +688,7 @@ func parseMsgSubmitTextProposal( msg["initial_deposit"].([]interface{}), ), }, - )}, []string{msg["proposer"].(string)} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&txsResult.Log[msgIndex]) // When there is no reward withdrew, `transfer` event would not exist @@ -636,12 +712,21 @@ func parseMsgSubmitTextProposal( msg["initial_deposit"].([]interface{}), ), }, - )}, []string{msg["proposer"].(string)} + )}, possibleSignerAddresses } func ParseMsgVote( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if voter, ok := parserParams.Msg["voter"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, voter.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgVote( parserParams.MsgCommonParams, @@ -650,7 +735,7 @@ func ParseMsgVote( Voter: parserParams.Msg["voter"].(string), Option: parserParams.Msg["option"].(string), }, - )}, []string{parserParams.Msg["voter"].(string)} + )}, possibleSignerAddresses } func ParseMsgDeposit( @@ -666,6 +751,14 @@ func ParseMsgDeposit( }, )} + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if depositor, ok := parserParams.Msg["depositor"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, depositor.(string)) + } + } + if parserParams.MsgCommonParams.TxSuccess { log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) logEvents := log.GetEventsByType("proposal_deposit") @@ -683,7 +776,7 @@ func ParseMsgDeposit( } } - return cmds, []string{parserParams.Msg["depositor"].(string)} + return cmds, possibleSignerAddresses } func ParseMsgDelegate( @@ -695,6 +788,14 @@ func ParseMsgDelegate( amount = coin.Coin{} } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if delegatorAddress, ok := parserParams.Msg["delegator_address"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, delegatorAddress.(string)) + } + } + if !parserParams.MsgCommonParams.TxSuccess { return []command.Command{command_usecase.NewCreateMsgDelegate( parserParams.MsgCommonParams, @@ -705,7 +806,7 @@ func ParseMsgDelegate( Amount: amount, AutoClaimedRewards: coin.Coin{}, }, - )}, []string{parserParams.Msg["delegator_address"].(string)} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -735,7 +836,7 @@ func ParseMsgDelegate( Amount: amount, AutoClaimedRewards: autoClaimedRewards, }, - )}, []string{parserParams.Msg["delegator_address"].(string)} + )}, possibleSignerAddresses } func ParseMsgUndelegate( @@ -747,6 +848,14 @@ func ParseMsgUndelegate( amount = coin.Coin{} } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if delegatorAddress, ok := parserParams.Msg["delegator_address"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, delegatorAddress.(string)) + } + } + if !parserParams.MsgCommonParams.TxSuccess { return []command.Command{command_usecase.NewCreateMsgUndelegate( parserParams.MsgCommonParams, @@ -758,7 +867,7 @@ func ParseMsgUndelegate( Amount: amount, AutoClaimedRewards: coin.Coin{}, }, - )}, []string{parserParams.Msg["delegator_address"].(string)} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) // When there is no reward withdrew, `transfer` event would not exist @@ -800,7 +909,7 @@ func ParseMsgUndelegate( Amount: amount, AutoClaimedRewards: autoClaimedRewards, }, - )}, []string{parserParams.Msg["delegator_address"].(string)} + )}, possibleSignerAddresses } func ParseMsgBeginRedelegate( @@ -812,6 +921,14 @@ func ParseMsgBeginRedelegate( amount = coin.Coin{} } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if delegatorAddress, ok := parserParams.Msg["delegator_address"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, delegatorAddress.(string)) + } + } + if !parserParams.MsgCommonParams.TxSuccess { return []command.Command{command_usecase.NewCreateMsgBeginRedelegate( parserParams.MsgCommonParams, @@ -823,7 +940,7 @@ func ParseMsgBeginRedelegate( Amount: amount, AutoClaimedRewards: coin.Coin{}, }, - )}, []string{parserParams.Msg["delegator_address"].(string)} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -854,19 +971,27 @@ func ParseMsgBeginRedelegate( Amount: amount, AutoClaimedRewards: autoClaimedRewards, }, - )}, []string{parserParams.Msg["delegator_address"].(string)} + )}, possibleSignerAddresses } func ParseMsgUnjail( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if validatorAddr, ok := parserParams.Msg["validator_addr"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, validatorAddr.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgUnjail( parserParams.MsgCommonParams, model.MsgUnjailParams{ ValidatorAddr: parserParams.Msg["validator_addr"].(string), }, - )}, []string{parserParams.Msg["validator_addr"].(string)} + )}, possibleSignerAddresses } func parseGenesisGenTxsMsgCreateValidator( @@ -966,6 +1091,17 @@ func ParseMsgCreateValidator( } } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if delegatorAddress, ok := parserParams.Msg["delegator_address"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, delegatorAddress.(string)) + } + if validatorAddress, ok := parserParams.Msg["validator_address"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, validatorAddress.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgCreateValidator( parserParams.MsgCommonParams, @@ -978,7 +1114,7 @@ func ParseMsgCreateValidator( TendermintPubkey: tendermintPubkey["key"].(string), Amount: amount, }, - )}, []string{parserParams.Msg["delegator_address"].(string), parserParams.Msg["validator_address"].(string)} + )}, possibleSignerAddresses } func ParseMsgEditValidator( @@ -1004,6 +1140,15 @@ func ParseMsgEditValidator( if parserParams.Msg["min_self_delegation"] != nil { maybeMinSelfDelegation = primptr.String(parserParams.Msg["min_self_delegation"].(string)) } + + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if validatorAddress, ok := parserParams.Msg["validator_address"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, validatorAddress.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgEditValidator( parserParams.MsgCommonParams, @@ -1013,12 +1158,20 @@ func ParseMsgEditValidator( MaybeCommissionRate: maybeCommissionRate, MaybeMinSelfDelegation: maybeMinSelfDelegation, }, - )}, []string{parserParams.Msg["validator_address"].(string)} + )}, possibleSignerAddresses } func ParseMsgNFTIssueDenom( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if sender, ok := parserParams.Msg["sender"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, sender.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgNFTIssueDenom( parserParams.MsgCommonParams, @@ -1028,12 +1181,20 @@ func ParseMsgNFTIssueDenom( Schema: parserParams.Msg["schema"].(string), Sender: parserParams.Msg["sender"].(string), }, - )}, []string{parserParams.Msg["sender"].(string)} + )}, possibleSignerAddresses } func ParseMsgNFTMintNFT( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if sender, ok := parserParams.Msg["sender"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, sender.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgNFTMintNFT( parserParams.MsgCommonParams, @@ -1046,12 +1207,20 @@ func ParseMsgNFTMintNFT( Sender: parserParams.Msg["sender"].(string), Recipient: parserParams.Msg["recipient"].(string), }, - )}, []string{parserParams.Msg["sender"].(string)} + )}, possibleSignerAddresses } func ParseMsgNFTTransferNFT( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if sender, ok := parserParams.Msg["sender"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, sender.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgNFTTransferNFT( parserParams.MsgCommonParams, @@ -1061,12 +1230,20 @@ func ParseMsgNFTTransferNFT( Sender: parserParams.Msg["sender"].(string), Recipient: parserParams.Msg["recipient"].(string), }, - )}, []string{parserParams.Msg["sender"].(string)} + )}, possibleSignerAddresses } func ParseMsgNFTEditNFT( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if sender, ok := parserParams.Msg["sender"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, sender.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgNFTEditNFT( parserParams.MsgCommonParams, @@ -1078,12 +1255,20 @@ func ParseMsgNFTEditNFT( Data: parserParams.Msg["data"].(string), Sender: parserParams.Msg["sender"].(string), }, - )}, []string{parserParams.Msg["sender"].(string)} + )}, possibleSignerAddresses } func ParseMsgNFTBurnNFT( parserParams utils.CosmosParserParams, ) ([]command.Command, []string) { + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if parserParams.Msg != nil { + if sender, ok := parserParams.Msg["sender"]; ok { + possibleSignerAddresses = append(possibleSignerAddresses, sender.(string)) + } + } + return []command.Command{command_usecase.NewCreateMsgNFTBurnNFT( parserParams.MsgCommonParams, @@ -1092,7 +1277,7 @@ func ParseMsgNFTBurnNFT( TokenId: parserParams.Msg["id"].(string), Sender: parserParams.Msg["sender"].(string), }, - )}, []string{parserParams.Msg["sender"].(string)} + )}, possibleSignerAddresses } func ParseMsgGrant( @@ -1140,22 +1325,39 @@ func parseRawMsgSendGrant( MaybeSendGrant: &rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + + if params.MaybeSendGrant != nil { + if params.MaybeSendGrant.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeSendGrant.Granter) + } + } + return []command.Command{command_usecase.NewCreateMsgGrant( msgCommonParams, params, - )}, []string{params.MaybeSendGrant.Granter} + )}, possibleSignerAddresses } params := model.MsgGrantParams{ MaybeSendGrant: &rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if params.MaybeSendGrant != nil { + if params.MaybeSendGrant.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeSendGrant.Granter) + } + } + return []command.Command{command_usecase.NewCreateMsgGrant( msgCommonParams, params, - )}, []string{params.MaybeSendGrant.Granter} + )}, possibleSignerAddresses } func parseRawMsgStackGrant( @@ -1186,22 +1388,38 @@ func parseRawMsgStackGrant( MaybeStakeGrant: &rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if params.MaybeStakeGrant != nil { + if params.MaybeStakeGrant.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeStakeGrant.Granter) + } + } + return []command.Command{command_usecase.NewCreateMsgGrant( msgCommonParams, params, - )}, []string{params.MaybeSendGrant.Granter} + )}, possibleSignerAddresses } params := model.MsgGrantParams{ MaybeStakeGrant: &rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if params.MaybeStakeGrant != nil { + if params.MaybeStakeGrant.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeStakeGrant.Granter) + } + } + return []command.Command{command_usecase.NewCreateMsgGrant( msgCommonParams, params, - )}, []string{params.MaybeStakeGrant.Granter} + )}, possibleSignerAddresses } func parseRawMsgGenericGrant( @@ -1232,10 +1450,12 @@ func parseRawMsgGenericGrant( MaybeGenericGrant: &rawMsg, } - // Getting possible signer address from Msh + // Getting possible signer address from Msg var possibleSignerAddresses []string - if params.MaybeSendGrant != nil { - possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeSendGrant.Granter) + if params.MaybeGenericGrant != nil { + if params.MaybeGenericGrant.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeGenericGrant.Granter) + } } return []command.Command{command_usecase.NewCreateMsgGrant( @@ -1251,8 +1471,10 @@ func parseRawMsgGenericGrant( // Getting possible signer address from Msg var possibleSignerAddresses []string - if params.MaybeSendGrant != nil { - possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeSendGrant.Granter) + if params.MaybeGenericGrant != nil { + if params.MaybeGenericGrant.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeGenericGrant.Granter) + } } return []command.Command{command_usecase.NewCreateMsgGrant( @@ -1289,22 +1511,34 @@ func ParseMsgRevoke( RawMsgRevoke: rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if revokeParams.RawMsgRevoke.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, revokeParams.RawMsgRevoke.Granter) + } + return []command.Command{command_usecase.NewCreateMsgRevoke( parserParams.MsgCommonParams, revokeParams, - )}, []string{revokeParams.Granter} + )}, possibleSignerAddresses } revokeParams := model.MsgRevokeParams{ RawMsgRevoke: rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if revokeParams.RawMsgRevoke.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, revokeParams.RawMsgRevoke.Granter) + } + return []command.Command{command_usecase.NewCreateMsgRevoke( parserParams.MsgCommonParams, revokeParams, - )}, []string{revokeParams.Granter} + )}, possibleSignerAddresses } func ParseMsgExec( @@ -1336,11 +1570,17 @@ func ParseMsgExec( innerCommands := parseMsgExecInnerMsgs(parserParams) + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if execParams.RawMsgExec.Grantee != "" { + possibleSignerAddresses = append(possibleSignerAddresses, execParams.RawMsgExec.Grantee) + } + return append([]command.Command{command_usecase.NewCreateMsgExec( parserParams.MsgCommonParams, execParams, - )}, innerCommands...), []string{rawMsg.Grantee} + )}, innerCommands...), possibleSignerAddresses } execParams := model.MsgExecParams{ @@ -1349,11 +1589,17 @@ func ParseMsgExec( innerCommands := parseMsgExecInnerMsgs(parserParams) + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if execParams.RawMsgExec.Grantee != "" { + possibleSignerAddresses = append(possibleSignerAddresses, execParams.RawMsgExec.Grantee) + } + return append([]command.Command{command_usecase.NewCreateMsgExec( parserParams.MsgCommonParams, execParams, - )}, innerCommands...), []string{rawMsg.Grantee} + )}, innerCommands...), possibleSignerAddresses } func parseMsgExecInnerMsgs( @@ -1442,22 +1688,38 @@ func parseRawMsgGrantBasicAllowance( MaybeBasicAllowance: &rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if params.MaybeBasicAllowance != nil { + if params.MaybeBasicAllowance.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeBasicAllowance.Granter) + } + } + return []command.Command{command_usecase.NewCreateMsgGrantAllowance( msgCommonParams, params, - )}, []string{params.MaybeBasicAllowance.Granter} + )}, possibleSignerAddresses } params := model.MsgGrantAllowanceParams{ MaybeBasicAllowance: &rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if params.MaybeBasicAllowance != nil { + if params.MaybeBasicAllowance.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeBasicAllowance.Granter) + } + } + return []command.Command{command_usecase.NewCreateMsgGrantAllowance( msgCommonParams, params, - )}, []string{params.MaybeBasicAllowance.Granter} + )}, possibleSignerAddresses } func parseRawMsgGrantPeriodicAllowance( @@ -1488,22 +1750,38 @@ func parseRawMsgGrantPeriodicAllowance( MaybePeriodicAllowance: &rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if params.MaybePeriodicAllowance != nil { + if params.MaybePeriodicAllowance.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybePeriodicAllowance.Granter) + } + } + return []command.Command{command_usecase.NewCreateMsgGrantAllowance( msgCommonParams, params, - )}, []string{params.MaybeBasicAllowance.Granter} + )}, possibleSignerAddresses } params := model.MsgGrantAllowanceParams{ MaybePeriodicAllowance: &rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if params.MaybePeriodicAllowance != nil { + if params.MaybePeriodicAllowance.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybePeriodicAllowance.Granter) + } + } + return []command.Command{command_usecase.NewCreateMsgGrantAllowance( msgCommonParams, params, - )}, []string{params.MaybeBasicAllowance.Granter} + )}, possibleSignerAddresses } func parseRawMsgGrantAllowedMsgAllowance( @@ -1534,22 +1812,38 @@ func parseRawMsgGrantAllowedMsgAllowance( MaybeAllowedMsgAllowance: &rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if params.MaybeAllowedMsgAllowance != nil { + if params.MaybeAllowedMsgAllowance.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeAllowedMsgAllowance.Granter) + } + } + return []command.Command{command_usecase.NewCreateMsgGrantAllowance( msgCommonParams, params, - )}, []string{params.MaybeBasicAllowance.Granter} + )}, possibleSignerAddresses } params := model.MsgGrantAllowanceParams{ MaybeAllowedMsgAllowance: &rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if params.MaybeAllowedMsgAllowance != nil { + if params.MaybeAllowedMsgAllowance.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, params.MaybeAllowedMsgAllowance.Granter) + } + } + return []command.Command{command_usecase.NewCreateMsgGrantAllowance( msgCommonParams, params, - )}, []string{params.MaybeBasicAllowance.Granter} + )}, possibleSignerAddresses } func ParseMsgRevokeAllowance( @@ -1579,22 +1873,34 @@ func ParseMsgRevokeAllowance( RawMsgRevokeAllowance: rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if revokeAllowanceParams.RawMsgRevokeAllowance.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, revokeAllowanceParams.RawMsgRevokeAllowance.Granter) + } + return []command.Command{command_usecase.NewCreateMsgRevokeAllowance( parserParams.MsgCommonParams, revokeAllowanceParams, - )}, []string{revokeAllowanceParams.Granter} + )}, possibleSignerAddresses } revokeAllowanceParams := model.MsgRevokeAllowanceParams{ RawMsgRevokeAllowance: rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if revokeAllowanceParams.RawMsgRevokeAllowance.Granter != "" { + possibleSignerAddresses = append(possibleSignerAddresses, revokeAllowanceParams.RawMsgRevokeAllowance.Granter) + } + return []command.Command{command_usecase.NewCreateMsgRevokeAllowance( parserParams.MsgCommonParams, revokeAllowanceParams, - )}, []string{revokeAllowanceParams.Granter} + )}, possibleSignerAddresses } func ParseMsgCreateVestingAccount( @@ -1624,20 +1930,32 @@ func ParseMsgCreateVestingAccount( RawMsgCreateVestingAccount: rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if msgCreateVestingAccountParams.RawMsgCreateVestingAccount.FromAddress != "" { + possibleSignerAddresses = append(possibleSignerAddresses, msgCreateVestingAccountParams.RawMsgCreateVestingAccount.FromAddress) + } + return []command.Command{command_usecase.NewCreateMsgCreateVestingAccount( parserParams.MsgCommonParams, msgCreateVestingAccountParams, - )}, []string{msgCreateVestingAccountParams.FromAddress} + )}, possibleSignerAddresses } msgCreateVestingAccountParams := model.MsgCreateVestingAccountParams{ RawMsgCreateVestingAccount: rawMsg, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + if msgCreateVestingAccountParams.RawMsgCreateVestingAccount.FromAddress != "" { + possibleSignerAddresses = append(possibleSignerAddresses, msgCreateVestingAccountParams.RawMsgCreateVestingAccount.FromAddress) + } + return []command.Command{command_usecase.NewCreateMsgCreateVestingAccount( parserParams.MsgCommonParams, msgCreateVestingAccountParams, - )}, []string{msgCreateVestingAccountParams.FromAddress} + )}, possibleSignerAddresses } diff --git a/usecase/parser/utils/parsermanager.go b/usecase/parser/utils/parsermanager.go index e4c0a183..45d43c78 100644 --- a/usecase/parser/utils/parsermanager.go +++ b/usecase/parser/utils/parsermanager.go @@ -46,6 +46,7 @@ type CosmosParserParams struct { MsgIndex int Msg map[string]interface{} ParserManager *CosmosParserManager + Logger applogger.Logger } func NewCosmosParserManager(params CosmosParserManagerParams) *CosmosParserManager { diff --git a/usecase/parser/v0_42_7/ibcmsg/ibcmsg.go b/usecase/parser/v0_42_7/ibcmsg/ibcmsg.go index 4f57380e..eee291fe 100644 --- a/usecase/parser/v0_42_7/ibcmsg/ibcmsg.go +++ b/usecase/parser/v0_42_7/ibcmsg/ibcmsg.go @@ -61,11 +61,15 @@ func ParseMsgRecvPacket( }, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgRecvPacketParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCRecvPacket( parserParams.MsgCommonParams, msgRecvPacketParams, - )}, []string{msgRecvPacketParams.Signer} + )}, possibleSignerAddresses } log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) @@ -93,11 +97,15 @@ func ParseMsgRecvPacket( PacketSequence: typeconv.MustAtou64(recvPacketEvent.MustGetAttributeByKey("packet_sequence")), } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgAlreadyRelayedRecvPacketParams.Signer) + return []command.Command{command_usecase.NewCreateMsgAlreadyRelayedIBCRecvPacket( parserParams.MsgCommonParams, msgAlreadyRelayedRecvPacketParams, - )}, []string{msgAlreadyRelayedRecvPacketParams.Signer} + )}, possibleSignerAddresses } var maybeDenominationTrace *ibc_model.MsgRecvPacketFungibleTokenDenominationTrace @@ -133,9 +141,13 @@ func ParseMsgRecvPacket( PacketAck: packetAck, } + // Getting possible signer address from Msg + var possibleSignerAddresses []string + possibleSignerAddresses = append(possibleSignerAddresses, msgRecvPacketParams.Signer) + return []command.Command{command_usecase.NewCreateMsgIBCRecvPacket( parserParams.MsgCommonParams, msgRecvPacketParams, - )}, []string{msgRecvPacketParams.Signer} + )}, possibleSignerAddresses }