diff --git a/usecase/parser/inner_msg.go b/usecase/parser/inner_msg.go new file mode 100644 index 00000000..464190f9 --- /dev/null +++ b/usecase/parser/inner_msg.go @@ -0,0 +1,161 @@ +package parser + +import ( + "fmt" + + "github.com/crypto-com/chain-indexing/usecase/model" + "github.com/crypto-com/chain-indexing/usecase/parser/utils" +) + +func ParseTxsResultsEvents( + msgs []interface{}, + logs []model.BlockResultsTxsResultLog, +) []model.BlockResultsTxsResultLog { + var resultLog []model.BlockResultsTxsResultLog + var parsedEvents *utils.ParsedTxsResultsEvents + + if len(msgs) == len(logs) || len(logs) <= 0 { + return logs + } + log := logs[0] + parsedEvents = utils.NewParsedTxsResultsEvents(log.Events) + + for innerMsgIndex, innerMsgInterface := range msgs { + innerMsg, ok := innerMsgInterface.(map[string]interface{}) + if !ok { + panic(fmt.Errorf("error parsing MsgExec.msgs[%v] to map[string]interface{}: %v", innerMsgIndex, innerMsgInterface)) + } + + innerMsgType, ok := innerMsg["@type"].(string) + if !ok { + panic(fmt.Errorf("error missing '@type' in MsgExec.msgs[%v]: %v", innerMsgIndex, innerMsg)) + } + + validateEvents := ParseInnerMsgsEvents(innerMsgType, innerMsgIndex, parsedEvents) + + log := model.BlockResultsTxsResultLog{ + MsgIndex: innerMsgIndex, + Events: validateEvents, + } + resultLog = append(resultLog, log) + } + + return resultLog +} + +func ParseInnerMsgsEvents( + innerMsgType string, + innerMsgIndex int, + parsedEvents *utils.ParsedTxsResultsEvents, +) []model.BlockResultsEvent { + var extractedEvents []model.BlockResultsEvent + switch innerMsgType { + + // bank + case "/cosmos.bank.v1beta1.MsgSend": + extractedEvents = MsgSend(parsedEvents, innerMsgIndex) + + // distribution + case "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress": + extractedEvents = MsgSetWithdrawAddress(parsedEvents, innerMsgIndex) + case "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward": + extractedEvents = MsgWithdrawDelegatorReward(parsedEvents, innerMsgIndex) + case "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission": + extractedEvents = MsgWithdrawValidatorCommission(parsedEvents, innerMsgIndex) + case "/cosmos.distribution.v1beta1.MsgFundCommunityPool": + extractedEvents = MsgFundCommunityPool(parsedEvents, innerMsgIndex) + } + + return extractedEvents +} + +func MsgSend(parsedEvents *utils.ParsedTxsResultsEvents, + innerMsgIndex int, +) []model.BlockResultsEvent { + eventTypes := []string{"coin_spent", "coin_received", "transfer", "message"} + + return extract(innerMsgIndex, eventTypes, []string{}, parsedEvents) +} + +func MsgSetWithdrawAddress(parsedEvents *utils.ParsedTxsResultsEvents, + innerMsgIndex int, +) []model.BlockResultsEvent { + eventTypes := []string{"set_withdraw_address", "message"} + + return extract(innerMsgIndex, eventTypes, []string{}, parsedEvents) +} + +func MsgWithdrawDelegatorReward(parsedEvents *utils.ParsedTxsResultsEvents, + innerMsgIndex int, +) []model.BlockResultsEvent { + eventTypes := []string{"coin_spent", "coin_received", "transfer", "message", "withdraw_rewards"} + + eventTypesNoTransfer := []string{ + "message", + "withdraw_rewards", + } + return extract(innerMsgIndex, eventTypes, eventTypesNoTransfer, parsedEvents) +} + +func MsgWithdrawValidatorCommission(parsedEvents *utils.ParsedTxsResultsEvents, + innerMsgIndex int, +) []model.BlockResultsEvent { + eventTypes := []string{"coin_spent", "coin_received", "transfer", "message", "withdraw_commission"} + + eventTypesNoTransfer := []string{"message", "withdraw_commission"} + + return extract(innerMsgIndex, eventTypes, eventTypesNoTransfer, parsedEvents) +} + +func MsgFundCommunityPool(parsedEvents *utils.ParsedTxsResultsEvents, + innerMsgIndex int, +) []model.BlockResultsEvent { + eventTypes := []string{"coin_spent", "coin_received", "transfer", "message"} + + eventTypesNoTransfer := []string{"message"} + + return extract(innerMsgIndex, eventTypes, eventTypesNoTransfer, parsedEvents) +} + +func extract(innerMsgIndex int, eventTypes []string, eventTypesRetry []string, parsedEvents *utils.ParsedTxsResultsEvents) []model.BlockResultsEvent { + // extract events + extractedEvents := getMsgEvents(innerMsgIndex, eventTypes, parsedEvents) + + // retry + if len(extractedEvents) <= 0 { + extractedEvents = getMsgEvents(innerMsgIndex, eventTypesRetry, parsedEvents) + } + + return extractedEvents +} + +func getMsgEvents(innerMsgIndex int, eventTypes []string, parsedEvents *utils.ParsedTxsResultsEvents) []model.BlockResultsEvent { + var extractedEvents []model.BlockResultsEvent + + for _, eventType := range eventTypes { + + events := parsedEvents.GetRawEvents() + + for _, event := range events { + splitBykey := utils.NewParsedTxsResultLogEventsSplitByKey(&event) + + rawEvent := splitBykey[innerMsgIndex].GetRawEvents() + keyIndex := splitBykey[innerMsgIndex].GetKeyIndex() + + var extractedAttributes model.BlockResultsEvent + + for _, key := range keyIndex { + extractedAttributes.Type = rawEvent.Type + extractedAttributes.Attributes = append(extractedAttributes.Attributes, rawEvent.Attributes[key]) + } + + // check attribute key + if rawEvent.Type == eventType { + extractedEvents = append(extractedEvents, extractedAttributes) + + } + } + } + + return extractedEvents +} diff --git a/usecase/parser/msg.go b/usecase/parser/msg.go index d2a90c10..0b17be5b 100644 --- a/usecase/parser/msg.go +++ b/usecase/parser/msg.go @@ -1,6 +1,7 @@ package parser import ( + "encoding/json" "fmt" "strconv" "time" @@ -121,15 +122,17 @@ func ParseBlockTxsMsgToCommands( // cosmos authz "/cosmos.authz.v1beta1.MsgGrant", "/cosmos.authz.v1beta1.MsgRevoke", - // FIXME: https://github.com/crypto-com/chain-indexing/issues/673 - //"/cosmos.authz.v1beta1.MsgExec", + "/cosmos.authz.v1beta1.MsgExec", // cosmos feegrant "/cosmos.feegrant.v1beta1.MsgGrantAllowance", "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", // cosmos vesting - "/cosmos.vesting.v1beta1.MsgCreateVestingAccount": + "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", + + // ethermint evm + "/ethermint.evm.v1.MsgEthereumTx": parser := parserManager.GetParser(utils.CosmosParserKey(msgType.(string)), utils.ParserBlockHeight(blockHeight)) msgCommands, possibleSignerAddresses = parser(utils.CosmosParserParams{ @@ -1615,6 +1618,14 @@ func parseMsgExecInnerMsgs( panic(fmt.Errorf("error parsing MsgExec.msgs to []interface{}: %v", parserParams.Msg["msgs"])) } + // group event by message type + if len(msgs) > 1 { + parserParams.TxsResult.Log = ParseTxsResultsEvents(msgs, parserParams.TxsResult.Log) + bytes, _ := json.Marshal(parserParams.TxsResult.Log) + rawLog, _ := json.Marshal(bytes) + parserParams.TxsResult.RawLog = string(rawLog) + } + for innerMsgIndex, innerMsgInterface := range msgs { innerMsg, ok := innerMsgInterface.(map[string]interface{}) if !ok { @@ -1628,13 +1639,15 @@ func parseMsgExecInnerMsgs( parser := parserParams.ParserManager.GetParser(utils.CosmosParserKey(innerMsgType), utils.ParserBlockHeight(blockHeight)) + parserParams.MsgCommonParams.MsgIndex = innerMsgIndex + msgCommands, _ := parser(utils.CosmosParserParams{ AddressPrefix: parserParams.AddressPrefix, StakingDenom: parserParams.StakingDenom, TxsResult: parserParams.TxsResult, MsgCommonParams: parserParams.MsgCommonParams, Msg: innerMsg, - MsgIndex: parserParams.MsgIndex, + MsgIndex: innerMsgIndex, ParserManager: parserParams.ParserManager, }) commands = append(commands, msgCommands...) @@ -1959,3 +1972,60 @@ func ParseMsgCreateVestingAccount( msgCreateVestingAccountParams, )}, possibleSignerAddresses } + +func ParseMsgEthereumTx( + parserParams utils.CosmosParserParams, +) ([]command.Command, []string) { + var rawMsg model.RawMsgEthereumTx + decoderConfig := &mapstructure.DecoderConfig{ + WeaklyTypedInput: true, + DecodeHook: mapstructure.ComposeDecodeHookFunc( + mapstructure.StringToTimeDurationHookFunc(), + mapstructure.StringToTimeHookFunc(time.RFC3339), + mapstructure_utils.StringToDurationHookFunc(), + mapstructure_utils.StringToByteSliceHookFunc(), + ), + Result: &rawMsg, + } + decoder, decoderErr := mapstructure.NewDecoder(decoderConfig) + if decoderErr != nil { + panic(fmt.Errorf("error creating RawMsgEthereumTx decoder: %v", decoderErr)) + } + if err := decoder.Decode(parserParams.Msg); err != nil { + panic(fmt.Errorf("error decoding RawMsgEthereumTx: %v", err)) + } + + if !parserParams.MsgCommonParams.TxSuccess { + // FIXME: https://github.com/crypto-com/chain-indexing/issues/730 + msgEthereumTxParams := model.MsgEthereumTxParams{ + RawMsgEthereumTx: rawMsg, + } + + // Getting possible signer address from Msg + var possibleSignerAddresses []string + // FIXME: https://github.com/crypto-com/chain-indexing/issues/729 + // possibleSignerAddresses = append(possibleSignerAddresses, msgEthereumTxParams.From) + + return []command.Command{command_usecase.NewCreateMsgEthereumTx( + parserParams.MsgCommonParams, + + msgEthereumTxParams, + )}, possibleSignerAddresses + } + + // FIXME: https://github.com/crypto-com/chain-indexing/issues/730 + msgEthereumTxParams := model.MsgEthereumTxParams{ + RawMsgEthereumTx: rawMsg, + } + + // Getting possible signer address from Msg + var possibleSignerAddresses []string + // FIXME: https://github.com/crypto-com/chain-indexing/issues/729 + // possibleSignerAddresses = append(possibleSignerAddresses, msgEthereumTxParams.From) + + return []command.Command{command_usecase.NewCreateMsgEthereumTx( + parserParams.MsgCommonParams, + + msgEthereumTxParams, + )}, possibleSignerAddresses +} diff --git a/usecase/parser/msg_exec_test.go b/usecase/parser/msg_exec_test.go index d0e99aac..999a6a14 100644 --- a/usecase/parser/msg_exec_test.go +++ b/usecase/parser/msg_exec_test.go @@ -12,11 +12,12 @@ import ( "github.com/crypto-com/chain-indexing/usecase/event" "github.com/crypto-com/chain-indexing/usecase/parser" usecase_parser_test "github.com/crypto-com/chain-indexing/usecase/parser/test" + usecase_parser_test_msg_exec "github.com/crypto-com/chain-indexing/usecase/parser/test/tx_msg_exec" "github.com/crypto-com/chain-indexing/usecase/parser/utils" ) var _ = Describe("ParseMsgCommands", func() { - XDescribe("MsgExec", func() { + Describe("MsgExec", func() { It("should parse Msg commands when there is MsgExec (inner message MsgSend) in the transaction", func() { expected := `{ "name": "MsgExecCreated", @@ -57,10 +58,10 @@ var _ = Describe("ParseMsgCommands", func() { txDecoder := utils.NewTxDecoder() block, _, _ := tendermint.ParseBlockResp(strings.NewReader( - usecase_parser_test.TX_MSG_EXEC_MSG_SEND_BLOCK_RESP, + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_SEND_BLOCK_RESP, )) blockResults, _ := tendermint.ParseBlockResultsResp(strings.NewReader( - usecase_parser_test.TX_MSG_EXEC_MSG_SEND_BLOCK_RESULTS_RESP, + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_SEND_BLOCK_RESULTS_RESP, )) accountAddressPrefix := "cro" @@ -145,10 +146,10 @@ var _ = Describe("ParseMsgCommands", func() { txDecoder := utils.NewTxDecoder() block, _, _ := tendermint.ParseBlockResp(strings.NewReader( - usecase_parser_test.TX_MSG_EXEC_MSG_DELEGATE_BLOCK_RESP, + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_DELEGATE_BLOCK_RESP, )) blockResults, _ := tendermint.ParseBlockResultsResp(strings.NewReader( - usecase_parser_test.TX_MSG_EXEC_MSG_DELEGATE_BLOCK_RESULTS_RESP, + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_DELEGATE_BLOCK_RESULTS_RESP, )) accountAddressPrefix := "cro" @@ -201,5 +202,495 @@ var _ = Describe("ParseMsgCommands", func() { Expect(possibleSignerAddresses).To(Equal([]string{"tcro15zh5tn7xjdecu4zjclsmlnlht5ead2mx84gau2"})) }) + + It("should parse Msg commands when there is MsgExec (inner message MsgSetWithdrawAddress) in the transaction", func() { + expected := ` + { + "name": "MsgExecCreated", + "version": 1, + "height": 292, + "uuid": "{UUID}", + "msgName": "MsgExec", + "txHash": "2DFF941C55DCA1FCDBDB7F38F84C9C7810C1E9F4709682D0570964D2BB79CD82", + "msgIndex": 0, + "params": { + "@type": "/cosmos.authz.v1beta1.MsgExec", + "grantee": "cro1406y009n43awa0e5n6t2t06a8tty9azpu9at25", + "msgs": [ + { + "@type": "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress" + } + ] + } + } + ` + + expectedInnerMsg := []string{` + { + "name": "MsgSetWithdrawAddressCreated", + "version": 1, + "height": 292, + "uuid": "{UUID}", + "msgName": "MsgSetWithdrawAddress", + "txHash": "2DFF941C55DCA1FCDBDB7F38F84C9C7810C1E9F4709682D0570964D2BB79CD82", + "msgIndex": 0, + "delegatorAddress": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "withdrawAddress": "cro1406y009n43awa0e5n6t2t06a8tty9azpu9at25" + }`} + + txDecoder := utils.NewTxDecoder() + block, _, _ := tendermint.ParseBlockResp(strings.NewReader( + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_SET_WITHDRAW_ADDRESS_BLOCK_RESP, + )) + blockResults, _ := tendermint.ParseBlockResultsResp(strings.NewReader( + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_SET_WITHDRAW_ADDRESS_BLOCK_RESULTS_RESP, + )) + + accountAddressPrefix := "cro" + stakingDenom := "basecro" + + pm := usecase_parser_test.InitParserManager() + + cmds, possibleSignerAddresses, err := parser.ParseBlockTxsMsgToCommands( + pm, + txDecoder, + block, + blockResults, + accountAddressPrefix, + stakingDenom, + ) + Expect(err).To(BeNil()) + Expect(cmds).To(HaveLen(2)) + + cmd := cmds[0] + Expect(cmd.Name()).To(Equal("CreateMsgExec")) + + untypedEvent, _ := cmd.Exec() + createMsgExecEvent := untypedEvent.(*event.MsgExec) + regex, _ := regexp.Compile("\n?\r?\\s?") + + Expect(json.MustMarshalToString(createMsgExecEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expected, ""), + "{UUID}", + createMsgExecEvent.UUID(), + -1, + ), + )) + + innerCmd := cmds[1] + Expect(innerCmd.Name()).To(Equal("CreateMsgSetWithdrawAddress")) + + untypedInnerEvent, _ := innerCmd.Exec() + createMsgSetWithdrawAddressEvent := untypedInnerEvent.(*event.MsgSetWithdrawAddress) + + Expect(json.MustMarshalToString(createMsgSetWithdrawAddressEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expectedInnerMsg[0], ""), + "{UUID}", + createMsgSetWithdrawAddressEvent.UUID(), + -1, + ), + )) + + Expect(possibleSignerAddresses).To(Equal([]string{"cro1406y009n43awa0e5n6t2t06a8tty9azpu9at25"})) + + }) + + It("should parse Msg commands when there is MsgExec (inner message MsgWithdrawDelegatorReward) in the transaction", func() { + expected := ` + { + "name": "MsgExecCreated", + "version": 1, + "height": 313, + "uuid": "{UUID}", + "msgName": "MsgExec", + "txHash": "711F6ED876F2EDDF927E8330621D734B1661D2A26132CFF141C9399266564176", + "msgIndex": 0, + "params": { + "@type": "/cosmos.authz.v1beta1.MsgExec", + "grantee": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "msgs": [ + { + "@type": "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward" + }, + { + "@type": "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward" + } + ] + } + } + ` + + expectedInnerMsg := []string{` + { + "name": "MsgWithdrawDelegatorRewardCreated", + "version": 1, + "height": 313, + "uuid": "{UUID}", + "msgName": "MsgWithdrawDelegatorReward", + "txHash": "711F6ED876F2EDDF927E8330621D734B1661D2A26132CFF141C9399266564176", + "msgIndex": 0, + "delegatorAddress": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "validatorAddress": "crocncl1htqsxfj4k9hhagtvlmqx6l4j593pzdk7wq0ad0", + "recipientAddress": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "amount": [ + { + "denom": "basecro", + "amount": "362332" + } + ] + }`, + `{ + "name": "MsgWithdrawDelegatorRewardCreated", + "version": 1, + "height": 313, + "uuid": "{UUID}", + "msgName": "MsgWithdrawDelegatorReward", + "txHash": "711F6ED876F2EDDF927E8330621D734B1661D2A26132CFF141C9399266564176", + "msgIndex": 1, + "delegatorAddress": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "validatorAddress": "crocncl17cye5gmealmpgz3tclfjga7urdjxj6nah3u8w2", + "recipientAddress": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "amount": [] + }`} + + txDecoder := utils.NewTxDecoder() + block, _, _ := tendermint.ParseBlockResp(strings.NewReader( + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_WITHDRAW_DELEGATOR_REWARD_BLOCK_RESP, + )) + blockResults, _ := tendermint.ParseBlockResultsResp(strings.NewReader( + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_WITHDRAW_DELEGATOR_REWARD_BLOCK_RESULTS_RESP, + )) + + accountAddressPrefix := "cro" + stakingDenom := "basecro" + + pm := usecase_parser_test.InitParserManager() + + cmds, possibleSignerAddresses, err := parser.ParseBlockTxsMsgToCommands( + pm, + txDecoder, + block, + blockResults, + accountAddressPrefix, + stakingDenom, + ) + Expect(err).To(BeNil()) + Expect(cmds).To(HaveLen(3)) + + cmd := cmds[0] + Expect(cmd.Name()).To(Equal("CreateMsgExec")) + + untypedEvent, _ := cmd.Exec() + createMsgExecEvent := untypedEvent.(*event.MsgExec) + regex, _ := regexp.Compile("\n?\r?\\s?") + + Expect(json.MustMarshalToString(createMsgExecEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expected, ""), + "{UUID}", + createMsgExecEvent.UUID(), + -1, + ), + )) + + innerCmd := cmds[1] + Expect(innerCmd.Name()).To(Equal("CreateMsgWithdrawDelegatorReward")) + + untypedInnerEvent, _ := innerCmd.Exec() + createMsgWithdrawDelegatorRewardEvent := untypedInnerEvent.(*event.MsgWithdrawDelegatorReward) + Expect(json.MustMarshalToString(createMsgWithdrawDelegatorRewardEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expectedInnerMsg[0], ""), + "{UUID}", + createMsgWithdrawDelegatorRewardEvent.UUID(), + -1, + ), + )) + + innerCmd = cmds[2] + Expect(innerCmd.Name()).To(Equal("CreateMsgWithdrawDelegatorReward")) + + untypedInnerEvent, _ = innerCmd.Exec() + createMsgWithdrawDelegatorRewardEvent = untypedInnerEvent.(*event.MsgWithdrawDelegatorReward) + + Expect(json.MustMarshalToString(createMsgWithdrawDelegatorRewardEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expectedInnerMsg[1], ""), + "{UUID}", + createMsgWithdrawDelegatorRewardEvent.UUID(), + -1, + ), + )) + Expect(possibleSignerAddresses).To(Equal([]string{"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n"})) + + }) + + It("should parse Msg commands when there is MsgExec (inner message MsgWithdrawValidatorCommission) in the transaction", func() { + expected := ` + { + "name": "MsgExecCreated", + "version": 1, + "height": 5991, + "uuid": "{UUID}", + "msgName": "MsgExec", + "txHash": "575DE51BFF24CEE75654C1BE8EFE30B01E9269E58267A27B53F5338457B9B870", + "msgIndex": 0, + "params": { + "@type": "/cosmos.authz.v1beta1.MsgExec", + "grantee": "cro1406y009n43awa0e5n6t2t06a8tty9azpu9at25", + "msgs": [ + { + "@type": "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward" + }, + { + "@type": "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission" + } + ] + } + } + ` + + expectedInnerMsg := []string{` + { + "name": "MsgWithdrawDelegatorRewardCreated", + "version": 1, + "height": 5991, + "uuid": "{UUID}", + "msgName": "MsgWithdrawDelegatorReward", + "txHash": "575DE51BFF24CEE75654C1BE8EFE30B01E9269E58267A27B53F5338457B9B870", + "msgIndex": 0, + "delegatorAddress": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "validatorAddress": "crocncl1htqsxfj4k9hhagtvlmqx6l4j593pzdk7wq0ad0", + "recipientAddress": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "amount": [ + { + "denom": "basecro", + "amount": "1285329" + } + ] + }`, + `{ + "name": "MsgWithdrawValidatorCommissionCreated", + "version": 1, + "height": 5991, + "uuid": "{UUID}", + "msgName": "MsgWithdrawValidatorCommission", + "txHash": "575DE51BFF24CEE75654C1BE8EFE30B01E9269E58267A27B53F5338457B9B870", + "msgIndex": 1, + "validatorAddress": "crocncl1htqsxfj4k9hhagtvlmqx6l4j593pzdk7wq0ad0", + "recipientAddress": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "amount": [ + { + "denom": "basecro", + "amount": "142814" + } + ] + }`} + + txDecoder := utils.NewTxDecoder() + block, _, _ := tendermint.ParseBlockResp(strings.NewReader( + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_WITHDRAW_VALIDATOR_COMMISSION_BLOCK_RESP, + )) + blockResults, _ := tendermint.ParseBlockResultsResp(strings.NewReader( + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_WITHDRAW_VALIDATOR_COMMISSION_BLOCK_RESULTS_RESP, + )) + + accountAddressPrefix := "cro" + stakingDenom := "basecro" + + pm := usecase_parser_test.InitParserManager() + + cmds, possibleSignerAddresses, err := parser.ParseBlockTxsMsgToCommands( + pm, + txDecoder, + block, + blockResults, + accountAddressPrefix, + stakingDenom, + ) + Expect(err).To(BeNil()) + Expect(cmds).To(HaveLen(3)) + + cmd := cmds[0] + Expect(cmd.Name()).To(Equal("CreateMsgExec")) + + untypedEvent, _ := cmd.Exec() + createMsgExecEvent := untypedEvent.(*event.MsgExec) + regex, _ := regexp.Compile("\n?\r?\\s?") + + Expect(json.MustMarshalToString(createMsgExecEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expected, ""), + "{UUID}", + createMsgExecEvent.UUID(), + -1, + ), + )) + + innerCmd := cmds[1] + Expect(innerCmd.Name()).To(Equal("CreateMsgWithdrawDelegatorReward")) + + untypedInnerEvent, _ := innerCmd.Exec() + createMsgWithdrawDelegatorRewardEvent := untypedInnerEvent.(*event.MsgWithdrawDelegatorReward) + Expect(json.MustMarshalToString(createMsgWithdrawDelegatorRewardEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expectedInnerMsg[0], ""), + "{UUID}", + createMsgWithdrawDelegatorRewardEvent.UUID(), + -1, + ), + )) + + innerCmd = cmds[2] + Expect(innerCmd.Name()).To(Equal("CreateMsgWithdrawValidatorCommission")) + + untypedInnerEvent, _ = innerCmd.Exec() + createMsgWithdrawValidatorCommissionEvent := untypedInnerEvent.(*event.MsgWithdrawValidatorCommission) + + Expect(json.MustMarshalToString(createMsgWithdrawValidatorCommissionEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expectedInnerMsg[1], ""), + "{UUID}", + createMsgWithdrawValidatorCommissionEvent.UUID(), + -1, + ), + )) + Expect(possibleSignerAddresses).To(Equal([]string{"cro1406y009n43awa0e5n6t2t06a8tty9azpu9at25"})) + + }) + + It("should parse Msg commands when there is MsgExec (inner message MsgFundCommunityPool) in the transaction", func() { + expected := ` + { + "name": "MsgExecCreated", + "version": 1, + "height": 2569, + "uuid": "{UUID}", + "msgName": "MsgExec", + "txHash": "6628CBD728424C24B58E1598800DFFB7FCD8CBECD212925171E933980B8E7143", + "msgIndex": 0, + "params": { + "@type": "/cosmos.authz.v1beta1.MsgExec", + "grantee": "cro1406y009n43awa0e5n6t2t06a8tty9azpu9at25", + "msgs": [ + { + "@type": "/cosmos.distribution.v1beta1.MsgFundCommunityPool" + }, + { + "@type": "/cosmos.distribution.v1beta1.MsgFundCommunityPool" + } + ] + } + } + ` + + expectedInnerMsg := []string{` + { + "name": "MsgFundCommunityPoolCreated", + "version": 1, + "height": 2569, + "uuid": "{UUID}", + "msgName": "MsgFundCommunityPool", + "txHash": "6628CBD728424C24B58E1598800DFFB7FCD8CBECD212925171E933980B8E7143", + "msgIndex": 0, + "depositor": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "amount": [ + { + "denom": "basecro", + "amount": "10" + } + ] + }`, + `{ + "name": "MsgFundCommunityPoolCreated", + "version": 1, + "height": 2569, + "uuid": "{UUID}", + "msgName": "MsgFundCommunityPool", + "txHash": "6628CBD728424C24B58E1598800DFFB7FCD8CBECD212925171E933980B8E7143", + "msgIndex": 1, + "depositor": "cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n", + "amount": [ + { + "denom": "basecro", + "amount": "11" + } + ] + }`} + + txDecoder := utils.NewTxDecoder() + block, _, _ := tendermint.ParseBlockResp(strings.NewReader( + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_FUND_COMMUNITY_POOL_BLOCK_RESP, + )) + blockResults, _ := tendermint.ParseBlockResultsResp(strings.NewReader( + usecase_parser_test_msg_exec.TX_MSG_EXEC_MSG_FUND_COMMUNITY_POOL_BLOCK_RESULTS_RESP, + )) + + accountAddressPrefix := "cro" + stakingDenom := "basecro" + + pm := usecase_parser_test.InitParserManager() + + cmds, possibleSignerAddresses, err := parser.ParseBlockTxsMsgToCommands( + pm, + txDecoder, + block, + blockResults, + accountAddressPrefix, + stakingDenom, + ) + Expect(err).To(BeNil()) + Expect(cmds).To(HaveLen(3)) + + cmd := cmds[0] + Expect(cmd.Name()).To(Equal("CreateMsgExec")) + + untypedEvent, _ := cmd.Exec() + createMsgExecEvent := untypedEvent.(*event.MsgExec) + regex, _ := regexp.Compile("\n?\r?\\s?") + + Expect(json.MustMarshalToString(createMsgExecEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expected, ""), + "{UUID}", + createMsgExecEvent.UUID(), + -1, + ), + )) + + innerCmd := cmds[1] + Expect(innerCmd.Name()).To(Equal("CreateMsgFundCommunityPool")) + + untypedInnerEvent, _ := innerCmd.Exec() + createMsgFundCommunityPoolEvent := untypedInnerEvent.(*event.MsgFundCommunityPool) + + Expect(json.MustMarshalToString(createMsgFundCommunityPoolEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expectedInnerMsg[0], ""), + "{UUID}", + createMsgFundCommunityPoolEvent.UUID(), + -1, + ), + )) + + innerCmd = cmds[2] + Expect(innerCmd.Name()).To(Equal("CreateMsgFundCommunityPool")) + + untypedInnerEvent, _ = innerCmd.Exec() + createMsgFundCommunityPoolEvent = untypedInnerEvent.(*event.MsgFundCommunityPool) + + Expect(json.MustMarshalToString(createMsgFundCommunityPoolEvent)).To(Equal( + strings.Replace( + regex.ReplaceAllString(expectedInnerMsg[1], ""), + "{UUID}", + createMsgFundCommunityPoolEvent.UUID(), + -1, + ), + )) + Expect(possibleSignerAddresses).To(Equal([]string{"cro1406y009n43awa0e5n6t2t06a8tty9azpu9at25"})) + + }) }) }) diff --git a/usecase/parser/register.go b/usecase/parser/register.go index cd00e135..08035f6b 100644 --- a/usecase/parser/register.go +++ b/usecase/parser/register.go @@ -69,8 +69,7 @@ func InitParsers(manager *utils.CosmosParserManager) { // cosmos authz manager.RegisterParser("/cosmos.authz.v1beta1.MsgGrant", BEGIN_BLOCK_HEIGHT, ParseMsgGrant) manager.RegisterParser("/cosmos.authz.v1beta1.MsgRevoke", BEGIN_BLOCK_HEIGHT, ParseMsgRevoke) - // FIXME: https://github.com/crypto-com/chain-indexing/issues/673 - //manager.RegisterParser("/cosmos.authz.v1beta1.MsgExec", BEGIN_BLOCK_HEIGHT, ParseMsgExec) + manager.RegisterParser("/cosmos.authz.v1beta1.MsgExec", BEGIN_BLOCK_HEIGHT, ParseMsgExec) // cosmos feegrant manager.RegisterParser("/cosmos.feegrant.v1beta1.MsgGrantAllowance", BEGIN_BLOCK_HEIGHT, ParseMsgGrantAllowance) diff --git a/usecase/parser/test/tx_msg_exec_msg_delegate.go b/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_delegate.go similarity index 100% rename from usecase/parser/test/tx_msg_exec_msg_delegate.go rename to usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_delegate.go diff --git a/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_fund_community_pool.go b/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_fund_community_pool.go new file mode 100644 index 00000000..7a95a2c5 --- /dev/null +++ b/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_fund_community_pool.go @@ -0,0 +1,589 @@ +package usecase_parser_test + +const TX_MSG_EXEC_MSG_FUND_COMMUNITY_POOL_BLOCK_RESP = ` +{ + "jsonrpc": "2.0", + "id": -1, + "result": { + "block_id": { + "hash": "2D88B3626C86523D66F996D65B0A3D359FD76D92FE8B195CDB23C475C0A24545", + "parts": { + "total": 1, + "hash": "8EEB7C542644BFF56D4D0AE467263CD1F8B2F4525447E6C99171D858189C10BF" + } + }, + "block": { + "header": { + "version": { + "block": "11" + }, + "chain_id": "chaintest", + "height": "2569", + "time": "2022-08-11T03:19:16.711807Z", + "last_block_id": { + "hash": "CD94C4AFCEC7AEBF541C4FBDD1E1284EDAE48BD0EB5FD20A56C59BE7AF3D0E54", + "parts": { + "total": 1, + "hash": "5AB048BA65819A9975D88D84F748C676558081BF779866A78FE420E429E94156" + } + }, + "last_commit_hash": "D231D335C0503C3BE39205E4B57FE215B5599A44AC4CDC58F3923AE8A7BB650E", + "data_hash": "F6B6983E098BDA5F2496CD189B6C87388D6036EBD0C99657870F88F8A24C0250", + "validators_hash": "5EBA69EC505C58FDBA6E1C1FD3201B7A7C2822BA9403BAEBA9754D105027ECEB", + "next_validators_hash": "5EBA69EC505C58FDBA6E1C1FD3201B7A7C2822BA9403BAEBA9754D105027ECEB", + "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", + "app_hash": "4C1C45A75B81B5456974E1193D891F5B8982C86E11F0FB7D859E05BD4C2B58D6", + "last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "proposer_address": "687E731503E488DFC9B1961EC6513CF4DEFCE59D" + }, + "data": { + "txs": [ + "CrUCCrICCh0vY29zbW9zLmF1dGh6LnYxYmV0YTEuTXNnRXhlYxKQAgoqY3JvMTQwNnkwMDluNDNhd2EwZTVuNnQydDA2YTh0dHk5YXpwdTlhdDI1EnAKMS9jb3Ntb3MuZGlzdHJpYnV0aW9uLnYxYmV0YTEuTXNnRnVuZENvbW11bml0eVBvb2wSOwoNCgdiYXNlY3JvEgIxMBIqY3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBuEnAKMS9jb3Ntb3MuZGlzdHJpYnV0aW9uLnYxYmV0YTEuTXNnRnVuZENvbW11bml0eVBvb2wSOwoNCgdiYXNlY3JvEgIxMRIqY3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBuElgKUApGCh8vY29zbW9zLmNyeXB0by5zZWNwMjU2azEuUHViS2V5EiMKIQNrfGTd70aQIuyCXaBOVHUNvHddYe0krKAWqPLnwNefrhIECgIIARgGEgQQwJoMGkBbD+Ja40o6nNEy5v+3cixYPWIJRbILlhmY7gRKKIb7OCtZQj+xUciNUvhqz884gVhPu2E8fKdh9y4uA71aHsSo" + ] + }, + "evidence": { + "evidence": [] + }, + "last_commit": { + "height": "2568", + "round": 0, + "block_id": { + "hash": "CD94C4AFCEC7AEBF541C4FBDD1E1284EDAE48BD0EB5FD20A56C59BE7AF3D0E54", + "parts": { + "total": 1, + "hash": "5AB048BA65819A9975D88D84F748C676558081BF779866A78FE420E429E94156" + } + }, + "signatures": [ + { + "block_id_flag": 2, + "validator_address": "687E731503E488DFC9B1961EC6513CF4DEFCE59D", + "timestamp": "2022-08-11T03:19:16.747971Z", + "signature": "a5JoLOv8/dx9SW4FmUA2SyQv5S1pBtlehaeLiXyBnr4Z80tBLNcO1J2HXX1slLS9j3jqpq3IfpaJ4CBK43xkAQ==" + }, + { + "block_id_flag": 2, + "validator_address": "E37CFA47E8186366465AFD992B916502781D0919", + "timestamp": "2022-08-11T03:19:16.711807Z", + "signature": "ZvkJ8em2Ytu2SWvS+W3IHX7jzrtKL/hEI/72OSxPOsAiSd/77oejamJKG8Bgv0uzBAuU+dt/tB1HrzyOnK9cDA==" + } + ] + } + } + } +} +` + +const TX_MSG_EXEC_MSG_FUND_COMMUNITY_POOL_BLOCK_RESULTS_RESP = ` +{ + "jsonrpc": "2.0", + "id": -1, + "result": { + "height": "2569", + "txs_results": [ + { + "code": 0, + "data": "CiUKHS9jb3Ntb3MuYXV0aHoudjFiZXRhMS5Nc2dFeGVjEgQKAAoA", + "log": "[{\"events\":[{\"type\":\"coin_received\",\"attributes\":[{\"key\":\"receiver\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"amount\",\"value\":\"10basecro\"},{\"key\":\"receiver\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"amount\",\"value\":\"11basecro\"}]},{\"type\":\"coin_spent\",\"attributes\":[{\"key\":\"spender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"amount\",\"value\":\"10basecro\"},{\"key\":\"spender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"amount\",\"value\":\"11basecro\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/cosmos.authz.v1beta1.MsgExec\"},{\"key\":\"sender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"module\",\"value\":\"distribution\"},{\"key\":\"sender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"sender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"module\",\"value\":\"distribution\"},{\"key\":\"sender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"sender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"amount\",\"value\":\"10basecro\"},{\"key\":\"recipient\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"sender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"amount\",\"value\":\"11basecro\"}]}]}]", + "info": "", + "gas_wanted": "200000", + "gas_used": "79803", + "events": [ + { + "type": "tx", + "attributes": [ + { + "key": "ZmVl", + "value": null, + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "YWNjX3NlcQ==", + "value": "Y3JvMTQwNnkwMDluNDNhd2EwZTVuNnQydDA2YTh0dHk5YXpwdTlhdDI1LzY=", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "c2lnbmF0dXJl", + "value": "V3cvaVd1TktPcHpSTXViL3QzSXNXRDFpQ1VXeUM1WVptTzRFU2lpRyt6Z3JXVUkvc1ZISWpWTDRhcy9QT0lGWVQ3dGhQSHluWWZjdUxnTzlXaDdFcUE9PQ==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "YWN0aW9u", + "value": "L2Nvc21vcy5hdXRoei52MWJldGExLk1zZ0V4ZWM=", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTBiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTBiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTBiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "ZGlzdHJpYnV0aW9u", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTFiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTFiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTFiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "ZGlzdHJpYnV0aW9u", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + } + ] + } + ], + "codespace": "" + } + ], + "begin_block_events": [ + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNDhiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coinbase", + "attributes": [ + { + "key": "bWludGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNDhiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNDhiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNDhiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNDhiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + } + ] + }, + { + "type": "mint", + "attributes": [ + { + "key": "Ym9uZGVkX3JhdGlv", + "value": "MC4wMDEyMDMzMDU3NzM5NzE4NjQ=", + "index": true + }, + { + "key": "aW5mbGF0aW9u", + "value": "MC4xMzAwNTI4MTkzMTc4NjY5OTE=", + "index": true + }, + { + "key": "YW5udWFsX3Byb3Zpc2lvbnM=", + "value": "MjE2MTU5MjIxMDMyLjU5ODk4MTA5MDQ1NTY4NjA5Mw==", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNDg=", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNDhiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNDhiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNDhiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + } + ] + }, + { + "type": "proposer_reward", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxMi40MDAwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxLjI0MDAwMDAwMDAwMDAwMDAwMGJhc2Vjcm8=", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxMi40MDAwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5Mi41MzIwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MjUuMzIwMDAwMDAwMDAwMDAwMDAwYmFzZWNybw==", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5Mi41MzIwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MjUuMzIwMDAwMDAwMDAwMDAwMDAwYmFzZWNybw==", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + } + ], + "end_block_events": null, + "validator_updates": null, + "consensus_param_updates": { + "block": { + "max_bytes": "22020096", + "max_gas": "-1" + }, + "evidence": { + "max_age_num_blocks": "100000", + "max_age_duration": "172800000000000", + "max_bytes": "1048576" + }, + "validator": { + "pub_key_types": [ + "ed25519" + ] + } + } + } +} +` diff --git a/usecase/parser/test/tx_msg_exec_msg_send.go b/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_send.go similarity index 100% rename from usecase/parser/test/tx_msg_exec_msg_send.go rename to usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_send.go diff --git a/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_set_withdraw_address.go b/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_set_withdraw_address.go new file mode 100644 index 00000000..3b2a51e9 --- /dev/null +++ b/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_set_withdraw_address.go @@ -0,0 +1,464 @@ +package usecase_parser_test + +const TX_MSG_EXEC_MSG_SET_WITHDRAW_ADDRESS_BLOCK_RESP = ` +{ + "jsonrpc": "2.0", + "id": -1, + "result": { + "block_id": { + "hash": "03263B69D5AAF9BC9952477DF72BAAF2B578E0CCC5E184103148B13B69B3389D", + "parts": { + "total": 1, + "hash": "6501FF7A2E2B1270188B6100914734A10FAC6475FFB98562BE2D37F74D29D5A7" + } + }, + "block": { + "header": { + "version": { + "block": "11" + }, + "chain_id": "chaintest", + "height": "292", + "time": "2022-08-11T08:26:54.360681Z", + "last_block_id": { + "hash": "84BB867F07C7A6EC81B20599F2F20E9A795257335B120CEBECB0BB5FDF5E3CF2", + "parts": { + "total": 1, + "hash": "007061C1BC5B26B8D6A99D7C3E4133F6B5D1DBA637FEB95CEFEDDA37180BD4E1" + } + }, + "last_commit_hash": "66BFF84634FEAD8DB8AB76CEEDC65919513B935DC2E1D3BA1F57DFC8ABE54302", + "data_hash": "677F2B86E71F84545D73EBF8449794CB04895411B2EFF78EB31F4EAE2AFADE55", + "validators_hash": "D179F82943E9BA4C392F1A3A75F75670098576F035DC973B1FBC21F816A84CC5", + "next_validators_hash": "D179F82943E9BA4C392F1A3A75F75670098576F035DC973B1FBC21F816A84CC5", + "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", + "app_hash": "29B03993F27E581FC1C0650B2E3E264342574C44612F5FB9458F117B1797EF34", + "last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "proposer_address": "F288243EE77CDC90BF8BBDA4F3D75163A8C8E589" + }, + "data": { + "txs": [ + "CuIBCt8BCh0vY29zbW9zLmF1dGh6LnYxYmV0YTEuTXNnRXhlYxK9AQoqY3JvMTQwNnkwMDluNDNhd2EwZTVuNnQydDA2YTh0dHk5YXpwdTlhdDI1Eo4BCjIvY29zbW9zLmRpc3RyaWJ1dGlvbi52MWJldGExLk1zZ1NldFdpdGhkcmF3QWRkcmVzcxJYCipjcm8xaHRxc3hmajRrOWhoYWd0dmxtcXg2bDRqNTkzcHpkazdkZHY1MG4SKmNybzE0MDZ5MDA5bjQzYXdhMGU1bjZ0MnQwNmE4dHR5OWF6cHU5YXQyNRJYClAKRgofL2Nvc21vcy5jcnlwdG8uc2VjcDI1NmsxLlB1YktleRIjCiEDa3xk3e9GkCLsgl2gTlR1Dbx3XWHtJKygFqjy58DXn64SBAoCCAEYAxIEEMCaDBpALNJps5yQJ8AJXnf53XJcrN2DbXSbWMxE/e82rhm0as8S/vTIWZUCVIaDxSCDKt09mlYRwwDSAZOfW6XGh/6p5Q==" + ] + }, + "evidence": { + "evidence": [] + }, + "last_commit": { + "height": "291", + "round": 0, + "block_id": { + "hash": "84BB867F07C7A6EC81B20599F2F20E9A795257335B120CEBECB0BB5FDF5E3CF2", + "parts": { + "total": 1, + "hash": "007061C1BC5B26B8D6A99D7C3E4133F6B5D1DBA637FEB95CEFEDDA37180BD4E1" + } + }, + "signatures": [ + { + "block_id_flag": 2, + "validator_address": "0737362FA0CB60BBEC339BBA31F25FE6BD363ED0", + "timestamp": "2022-08-11T08:26:54.360681Z", + "signature": "xDkTXjfirZahCf0c5a4ls3qhgVheQKsAQdKMwlT7HoaLSCcgctFaeI+Z3zcqGKXAn0yTIbVSmjIJ4xRFDa1GBQ==" + }, + { + "block_id_flag": 2, + "validator_address": "F288243EE77CDC90BF8BBDA4F3D75163A8C8E589", + "timestamp": "2022-08-11T08:26:54.3967Z", + "signature": "r2AgkWmmMr4X0FT1f0/7k2aqX9Sp5dGN4zBO5LTYeAQ9ca0G2HNO7PNdSISU0we7WMi1XxHSiWdvV/G51U88Bw==" + } + ] + } + } + } +} +` + +const TX_MSG_EXEC_MSG_SET_WITHDRAW_ADDRESS_BLOCK_RESULTS_RESP = ` +{ + "jsonrpc": "2.0", + "id": -1, + "result": { + "height": "292", + "txs_results": [ + { + "code": 0, + "data": "CiMKHS9jb3Ntb3MuYXV0aHoudjFiZXRhMS5Nc2dFeGVjEgIKAA==", + "log": "[{\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/cosmos.authz.v1beta1.MsgExec\"},{\"key\":\"module\",\"value\":\"distribution\"},{\"key\":\"sender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"}]},{\"type\":\"set_withdraw_address\",\"attributes\":[{\"key\":\"withdraw_address\",\"value\":\"cro1406y009n43awa0e5n6t2t06a8tty9azpu9at25\"}]}]}]", + "info": "", + "gas_wanted": "200000", + "gas_used": "47394", + "events": [ + { + "type": "tx", + "attributes": [ + { + "key": "ZmVl", + "value": null, + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "YWNjX3NlcQ==", + "value": "Y3JvMTQwNnkwMDluNDNhd2EwZTVuNnQydDA2YTh0dHk5YXpwdTlhdDI1LzM=", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "c2lnbmF0dXJl", + "value": "TE5KcHM1eVFKOEFKWG5mNTNYSmNyTjJEYlhTYldNeEUvZTgycmhtMGFzOFMvdlRJV1pVQ1ZJYUR4U0NES3QwOW1sWVJ3d0RTQVpPZlc2WEdoLzZwNVE9PQ==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "YWN0aW9u", + "value": "L2Nvc21vcy5hdXRoei52MWJldGExLk1zZ0V4ZWM=", + "index": true + } + ] + }, + { + "type": "set_withdraw_address", + "attributes": [ + { + "key": "d2l0aGRyYXdfYWRkcmVzcw==", + "value": "Y3JvMTQwNnkwMDluNDNhd2EwZTVuNnQydDA2YTh0dHk5YXpwdTlhdDI1", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "ZGlzdHJpYnV0aW9u", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + } + ] + } + ], + "codespace": "" + } + ], + "begin_block_events": [ + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coinbase", + "attributes": [ + { + "key": "bWludGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + } + ] + }, + { + "type": "mint", + "attributes": [ + { + "key": "Ym9uZGVkX3JhdGlv", + "value": "MC4wMDEyMDMzNjIyMjE2MTgxNTU=", + "index": true + }, + { + "key": "aW5mbGF0aW9u", + "value": "MC4xMzAwMDYwMDM1OTY3OTQ5OTQ=", + "index": true + }, + { + "key": "YW5udWFsX3Byb3Zpc2lvbnM=", + "value": "MjE2MDcxMjczMDczLjQ5OTk5NDYzMDcyNjM1OTExNg==", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzQ=", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + } + ] + }, + { + "type": "proposer_reward", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxMS43MDAwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxLjE3MDAwMDAwMDAwMDAwMDAwMGJhc2Vjcm8=", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxMS43MDAwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MS44ODEwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MTguODEwMDAwMDAwMDAwMDAwMDAwYmFzZWNybw==", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MS44ODEwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MTguODEwMDAwMDAwMDAwMDAwMDAwYmFzZWNybw==", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + } + ], + "end_block_events": null, + "validator_updates": null, + "consensus_param_updates": { + "block": { + "max_bytes": "22020096", + "max_gas": "-1" + }, + "evidence": { + "max_age_num_blocks": "100000", + "max_age_duration": "172800000000000", + "max_bytes": "1048576" + }, + "validator": { + "pub_key_types": [ + "ed25519" + ] + } + } + } +} +` diff --git a/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_withdraw_delegator_reward.go b/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_withdraw_delegator_reward.go new file mode 100644 index 00000000..3d53f69a --- /dev/null +++ b/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_withdraw_delegator_reward.go @@ -0,0 +1,559 @@ +package usecase_parser_test + +const TX_MSG_EXEC_MSG_WITHDRAW_DELEGATOR_REWARD_BLOCK_RESP = ` +{ + "jsonrpc": "2.0", + "id": -1, + "result": { + "block_id": { + "hash": "ABADA3C9E4E43B019EEE4CD2A7FD9EFEA0F8968C9D62915615E0C20F3D8CBEFC", + "parts": { + "total": 1, + "hash": "FEB80A021E4361105437B636AC163F2F3D6E2312E194F06C90F44384B6D80610" + } + }, + "block": { + "header": { + "version": { + "block": "11" + }, + "chain_id": "chaintest", + "height": "313", + "time": "2022-08-11T09:10:07.111359Z", + "last_block_id": { + "hash": "7D37C7B0D7951DF33C9FB8325FBD3195273283844F58DD635EE6670CCEF07699", + "parts": { + "total": 1, + "hash": "E7B1758C470956AB30ADD1EEF6D05628FF53F9CC2A609F69B620634FCDA2F31B" + } + }, + "last_commit_hash": "978B717F13BF769FB299BE09244B5E954627E41F6E0BF57CADD57C1728BA5285", + "data_hash": "6EDB8920F3922910E0351E4B4CBA40DFBA493584608BF6B06F5C7DF9C34C3701", + "validators_hash": "3CC6A79299D004B413B5701492B3CC3BCB0A44DC245AB40E92E4D3A7F38D44C9", + "next_validators_hash": "3CC6A79299D004B413B5701492B3CC3BCB0A44DC245AB40E92E4D3A7F38D44C9", + "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", + "app_hash": "56F6964C4476F01DEC0E546A701302896469017E1BF46E60AD39D96ADD63C0DB", + "last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "proposer_address": "1BA1E260F60A3A76B51CD36CB92026402D49A031" + }, + "data": { + "txs": [ + "CoUDCoIDCh0vY29zbW9zLmF1dGh6LnYxYmV0YTEuTXNnRXhlYxLgAgoqY3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBuEpcBCjcvY29zbW9zLmRpc3RyaWJ1dGlvbi52MWJldGExLk1zZ1dpdGhkcmF3RGVsZWdhdG9yUmV3YXJkElwKKmNybzFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN2RkdjUwbhIuY3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMBKXAQo3L2Nvc21vcy5kaXN0cmlidXRpb24udjFiZXRhMS5Nc2dXaXRoZHJhd0RlbGVnYXRvclJld2FyZBJcCipjcm8xaHRxc3hmajRrOWhoYWd0dmxtcXg2bDRqNTkzcHpkazdkZHY1MG4SLmNyb2NuY2wxN2N5ZTVnbWVhbG1wZ3ozdGNsZmpnYTd1cmRqeGo2bmFoM3U4dzISWApQCkYKHy9jb3Ntb3MuY3J5cHRvLnNlY3AyNTZrMS5QdWJLZXkSIwohAzwKY/mjHju6d7GSvY/oTu62ILJwQ+ZdCiAOadX5F366EgQKAggBGAMSBBDAmgwaQCKdcfyXIPQOrVuiaZZXswnVj5NvAQLYTU33iIH3kAVoMQ7QC03X0FjeMvVLhwzt5cVzjaSdGXERFRXZ8N4sc2Y=" + ] + }, + "evidence": { + "evidence": [] + }, + "last_commit": { + "height": "312", + "round": 0, + "block_id": { + "hash": "7D37C7B0D7951DF33C9FB8325FBD3195273283844F58DD635EE6670CCEF07699", + "parts": { + "total": 1, + "hash": "E7B1758C470956AB30ADD1EEF6D05628FF53F9CC2A609F69B620634FCDA2F31B" + } + }, + "signatures": [ + { + "block_id_flag": 2, + "validator_address": "1BA1E260F60A3A76B51CD36CB92026402D49A031", + "timestamp": "2022-08-11T09:10:07.111359Z", + "signature": "PQCoHaYCXLYgLoYYLAy49SL6BvGLvYV5wwdvvfUqNzCAY85fPvQoTOnTrg31Bo6QvXpv5P8aIXuzzFWZAJJHBw==" + }, + { + "block_id_flag": 2, + "validator_address": "D1483ACF4613CF4450BC0FCEB07F84FE2634A5B1", + "timestamp": "2022-08-11T09:10:07.129718Z", + "signature": "SrzBacorSQbUnovRRcI1R3rbYyRgvh2lUks3FCX5McyDZvRvzLXgd14fNDUAdAMK0mrGGN96M8eOAG9QZXQMBQ==" + } + ] + } + } + } +} +` + +const TX_MSG_EXEC_MSG_WITHDRAW_DELEGATOR_REWARD_BLOCK_RESULTS_RESP = ` +{ + "jsonrpc": "2.0", + "id": -1, + "result": { + "height": "313", + "txs_results": [ + { + "code": 0, + "data": "CiUKHS9jb3Ntb3MuYXV0aHoudjFiZXRhMS5Nc2dFeGVjEgQKAAoA", + "log": "[{\"events\":[{\"type\":\"coin_received\",\"attributes\":[{\"key\":\"receiver\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"amount\",\"value\":\"362332basecro\"}]},{\"type\":\"coin_spent\",\"attributes\":[{\"key\":\"spender\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"amount\",\"value\":\"362332basecro\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/cosmos.authz.v1beta1.MsgExec\"},{\"key\":\"sender\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"module\",\"value\":\"distribution\"},{\"key\":\"sender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"module\",\"value\":\"distribution\"},{\"key\":\"sender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"sender\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"amount\",\"value\":\"362332basecro\"}]},{\"type\":\"withdraw_rewards\",\"attributes\":[{\"key\":\"amount\",\"value\":\"362332basecro\"},{\"key\":\"validator\",\"value\":\"crocncl1htqsxfj4k9hhagtvlmqx6l4j593pzdk7wq0ad0\"},{\"key\":\"amount\"},{\"key\":\"validator\",\"value\":\"crocncl17cye5gmealmpgz3tclfjga7urdjxj6nah3u8w2\"}]}]}]", + "info": "", + "gas_wanted": "200000", + "gas_used": "153624", + "events": [ + { + "type": "tx", + "attributes": [ + { + "key": "ZmVl", + "value": null, + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "YWNjX3NlcQ==", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBuLzM=", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "c2lnbmF0dXJl", + "value": "SXAxeC9KY2c5QTZ0VzZKcGxsZXpDZFdQazI4QkF0aE5UZmVJZ2ZlUUJXZ3hEdEFMVGRmUVdONHk5VXVIRE8zbHhYT05wSjBaY1JFVkZkbnczaXh6Wmc9PQ==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "YWN0aW9u", + "value": "L2Nvc21vcy5hdXRoei52MWJldGExLk1zZ0V4ZWM=", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzYyMzMyYmFzZWNybw==", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzYyMzMyYmFzZWNybw==", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzYyMzMyYmFzZWNybw==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + } + ] + }, + { + "type": "withdraw_rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MzYyMzMyYmFzZWNybw==", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "ZGlzdHJpYnV0aW9u", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + } + ] + }, + { + "type": "withdraw_rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": null, + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "ZGlzdHJpYnV0aW9u", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + } + ] + } + ], + "codespace": "" + } + ], + "begin_block_events": [ + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coinbase", + "attributes": [ + { + "key": "bWludGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + } + ] + }, + { + "type": "mint", + "attributes": [ + { + "key": "Ym9uZGVkX3JhdGlv", + "value": "MC4wMDEyMDMzNjE3MDE2OTczMzk=", + "index": true + }, + { + "key": "aW5mbGF0aW9u", + "value": "MC4xMzAwMDY0MzUzNjIzMjA0MjM=", + "index": true + }, + { + "key": "YW5udWFsX3Byb3Zpc2lvbnM=", + "value": "MjE2MDcyMDg0MTM1LjU1MDg5NzU1MTg4NjkwNzk0NA==", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzQ=", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyMzRiYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + } + ] + }, + { + "type": "proposer_reward", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxMS43MDAwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxLjE3MDAwMDAwMDAwMDAwMDAwMGJhc2Vjcm8=", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxMS43MDAwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MS44ODEwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MTguODEwMDAwMDAwMDAwMDAwMDAwYmFzZWNybw==", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MS44ODEwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MTguODEwMDAwMDAwMDAwMDAwMDAwYmFzZWNybw==", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + } + ], + "end_block_events": null, + "validator_updates": null, + "consensus_param_updates": { + "block": { + "max_bytes": "22020096", + "max_gas": "-1" + }, + "evidence": { + "max_age_num_blocks": "100000", + "max_age_duration": "172800000000000", + "max_bytes": "1048576" + }, + "validator": { + "pub_key_types": [ + "ed25519" + ] + } + } + } +} +` diff --git a/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_withdraw_validator_commission.go b/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_withdraw_validator_commission.go new file mode 100644 index 00000000..a66b3086 --- /dev/null +++ b/usecase/parser/test/tx_msg_exec/tx_msg_exec_msg_withdraw_validator_commission.go @@ -0,0 +1,614 @@ +package usecase_parser_test + +const TX_MSG_EXEC_MSG_WITHDRAW_VALIDATOR_COMMISSION_BLOCK_RESP = ` +{ + "jsonrpc": "2.0", + "id": -1, + "result": { + "block_id": { + "hash": "94727699F5F489DEE28C94D6B0E3C8B503EA742B5307B187C30DF233FD6E334B", + "parts": { + "total": 1, + "hash": "D22B5D67F5F71D8996DAD52D74F1064314A02F44F64C9CD1950FE05F089AB92F" + } + }, + "block": { + "header": { + "version": { + "block": "11" + }, + "chain_id": "chaintest", + "height": "5991", + "time": "2022-08-12T02:59:57.09639Z", + "last_block_id": { + "hash": "632C790AB185E8D5C6D3129579D49D56BCED17E1D47C9CFA88A4BE295D231148", + "parts": { + "total": 1, + "hash": "18D6C5A6872B6C62D504C5FBCCE53812EA911AC56CDDAC12DFCD05E165611CC6" + } + }, + "last_commit_hash": "D4570C1D0AFFE51426301B0B4CB6907B03074827CCB1BA5B24ED4B868DC746FC", + "data_hash": "43B7683878C0235CEE8F88DE67660ECE8B940FCDEA4F3AA3ED88DF6BC2E762E9", + "validators_hash": "9797875DD992FE368DA8CB7A1A6C04F8F09B5F667332108571700DBDE676B8D8", + "next_validators_hash": "9797875DD992FE368DA8CB7A1A6C04F8F09B5F667332108571700DBDE676B8D8", + "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", + "app_hash": "A69E1D8D43AF188CD99FC9E6031D85BEDF30F26A66EB9CFFCB6616150DDA67CB", + "last_results_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855", + "proposer_address": "42404550EC84BDC92FE4A309740FE93DA1E98A1B" + }, + "data": { + "txs": [ + "CtwCCtkCCh0vY29zbW9zLmF1dGh6LnYxYmV0YTEuTXNnRXhlYxK3AgoqY3JvMTQwNnkwMDluNDNhd2EwZTVuNnQydDA2YTh0dHk5YXpwdTlhdDI1EpcBCjcvY29zbW9zLmRpc3RyaWJ1dGlvbi52MWJldGExLk1zZ1dpdGhkcmF3RGVsZWdhdG9yUmV3YXJkElwKKmNybzFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN2RkdjUwbhIuY3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMBJvCjsvY29zbW9zLmRpc3RyaWJ1dGlvbi52MWJldGExLk1zZ1dpdGhkcmF3VmFsaWRhdG9yQ29tbWlzc2lvbhIwCi5jcm9jbmNsMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3d3EwYWQwElgKUApGCh8vY29zbW9zLmNyeXB0by5zZWNwMjU2azEuUHViS2V5EiMKIQNrfGTd70aQIuyCXaBOVHUNvHddYe0krKAWqPLnwNefrhIECgIIARgQEgQQwJoMGkDMONvP4mTQflkVF6GtC7TvzPHDSBwt9OoYzYgd78EAPzvsQb0HTzf7JNTcFltR/900Mo1c5k3FDWkIFxK9ztBY" + ] + }, + "evidence": { + "evidence": [] + }, + "last_commit": { + "height": "5990", + "round": 0, + "block_id": { + "hash": "632C790AB185E8D5C6D3129579D49D56BCED17E1D47C9CFA88A4BE295D231148", + "parts": { + "total": 1, + "hash": "18D6C5A6872B6C62D504C5FBCCE53812EA911AC56CDDAC12DFCD05E165611CC6" + } + }, + "signatures": [ + { + "block_id_flag": 2, + "validator_address": "42404550EC84BDC92FE4A309740FE93DA1E98A1B", + "timestamp": "2022-08-12T02:59:57.09639Z", + "signature": "yNz6LZdB/uvsn6JmMWl3dvI5Lz+OeiOc7Vu98pL6vnbMCIIFpjmKh/NGIAyDf4bFdPNGi4i8us7s39XO2LfUBg==" + }, + { + "block_id_flag": 2, + "validator_address": "FB8249644B36E76759F42EAE764F5842E779D1EE", + "timestamp": "2022-08-12T02:59:57.180172Z", + "signature": "cnpZUOaMD92bFykK0ISQriFiAK6iMVCeK1YFpM7B1NR0X6oxlXeGtleDyxQHkBi1Kk0KqomxliTteEsArYW5Bg==" + } + ] + } + } + } +} +` + +const TX_MSG_EXEC_MSG_WITHDRAW_VALIDATOR_COMMISSION_BLOCK_RESULTS_RESP = ` +{ + "jsonrpc": "2.0", + "id": -1, + "result": { + "height": "5991", + "txs_results": [ + { + "code": 0, + "data": "CiUKHS9jb3Ntb3MuYXV0aHoudjFiZXRhMS5Nc2dFeGVjEgQKAAoA", + "log": "[{\"events\":[{\"type\":\"coin_received\",\"attributes\":[{\"key\":\"receiver\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"amount\",\"value\":\"1285329basecro\"},{\"key\":\"receiver\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"amount\",\"value\":\"142814basecro\"}]},{\"type\":\"coin_spent\",\"attributes\":[{\"key\":\"spender\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"amount\",\"value\":\"1285329basecro\"},{\"key\":\"spender\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"amount\",\"value\":\"142814basecro\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/cosmos.authz.v1beta1.MsgExec\"},{\"key\":\"sender\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"module\",\"value\":\"distribution\"},{\"key\":\"sender\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"sender\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"module\",\"value\":\"distribution\"},{\"key\":\"sender\",\"value\":\"crocncl1htqsxfj4k9hhagtvlmqx6l4j593pzdk7wq0ad0\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"sender\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"amount\",\"value\":\"1285329basecro\"},{\"key\":\"recipient\",\"value\":\"cro1htqsxfj4k9hhagtvlmqx6l4j593pzdk7ddv50n\"},{\"key\":\"sender\",\"value\":\"cro1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8lyv94w\"},{\"key\":\"amount\",\"value\":\"142814basecro\"}]},{\"type\":\"withdraw_commission\",\"attributes\":[{\"key\":\"amount\",\"value\":\"142814basecro\"}]},{\"type\":\"withdraw_rewards\",\"attributes\":[{\"key\":\"amount\",\"value\":\"1285329basecro\"},{\"key\":\"validator\",\"value\":\"crocncl1htqsxfj4k9hhagtvlmqx6l4j593pzdk7wq0ad0\"}]}]}]", + "info": "", + "gas_wanted": "200000", + "gas_used": "130101", + "events": [ + { + "type": "tx", + "attributes": [ + { + "key": "ZmVl", + "value": null, + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "YWNjX3NlcQ==", + "value": "Y3JvMTQwNnkwMDluNDNhd2EwZTVuNnQydDA2YTh0dHk5YXpwdTlhdDI1LzE2", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "c2lnbmF0dXJl", + "value": "ekRqYnorSmswSDVaRlJlaHJRdTA3OHp4dzBnY0xmVHFHTTJJSGUvQkFEODc3RUc5QjA4Myt5VFUzQlpiVWYvZE5ES05YT1pOeFExcENCY1N2YzdRV0E9PQ==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "YWN0aW9u", + "value": "L2Nvc21vcy5hdXRoei52MWJldGExLk1zZ0V4ZWM=", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTI4NTMyOWJhc2Vjcm8=", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTI4NTMyOWJhc2Vjcm8=", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTI4NTMyOWJhc2Vjcm8=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + } + ] + }, + { + "type": "withdraw_rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTI4NTMyOWJhc2Vjcm8=", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "ZGlzdHJpYnV0aW9u", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTQyODE0YmFzZWNybw==", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTQyODE0YmFzZWNybw==", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMWh0cXN4Zmo0azloaGFndHZsbXF4Nmw0ajU5M3B6ZGs3ZGR2NTBu", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTQyODE0YmFzZWNybw==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + } + ] + }, + { + "type": "withdraw_commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTQyODE0YmFzZWNybw==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "ZGlzdHJpYnV0aW9u", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + } + ], + "codespace": "" + } + ], + "begin_block_events": [ + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNjliYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coinbase", + "attributes": [ + { + "key": "bWludGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNjliYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNjliYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNjliYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNjliYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMW0zaDMwd2x2c2Y4bGxydXh0cHVrZHZzeTBrbTJrdW04czIwcG0z", + "index": true + } + ] + }, + { + "type": "mint", + "attributes": [ + { + "key": "Ym9uZGVkX3JhdGlv", + "value": "MC4wMDEyMDMyMjA5MDY2MTk1NzU=", + "index": true + }, + { + "key": "aW5mbGF0aW9u", + "value": "MC4xMzAxMjMxNzY1NDg2MjM5MDU=", + "index": true + }, + { + "key": "YW5udWFsX3Byb3Zpc2lvbnM=", + "value": "MjE2MjkxNDE1NTM3LjY1NDI5NDA1MTM5NTY4ODY1MA==", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNjk=", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNjliYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNjliYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "Y3JvMWp2NjVzM2dycWY2djZqbDNkcDR0NmM5dDlyazk5Y2Q4bHl2OTR3", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MzQyNjliYXNlY3Jv", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "Y3JvMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsZ3p0ZWh2", + "index": true + } + ] + }, + { + "type": "proposer_reward", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxMy40NTAwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxLjM0NTAwMDAwMDAwMDAwMDAwMGJhc2Vjcm8=", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTcxMy40NTAwMDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5My41MDg1MDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MzUuMDg1MDAwMDAwMDAwMDAwMDAwYmFzZWNybw==", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDE3Y3llNWdtZWFsbXBnejN0Y2xmamdhN3VyZGp4ajZuYWgzdTh3Mg==", + "index": true + } + ] + }, + { + "type": "commission", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5My41MDg1MDAwMDAwMDAwMDAwMDBiYXNlY3Jv", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + }, + { + "type": "rewards", + "attributes": [ + { + "key": "YW1vdW50", + "value": "MTU5MzUuMDg1MDAwMDAwMDAwMDAwMDAwYmFzZWNybw==", + "index": true + }, + { + "key": "dmFsaWRhdG9y", + "value": "Y3JvY25jbDFodHFzeGZqNGs5aGhhZ3R2bG1xeDZsNGo1OTNwemRrN3dxMGFkMA==", + "index": true + } + ] + } + ], + "end_block_events": null, + "validator_updates": null, + "consensus_param_updates": { + "block": { + "max_bytes": "22020096", + "max_gas": "-1" + }, + "evidence": { + "max_age_num_blocks": "100000", + "max_age_duration": "172800000000000", + "max_bytes": "1048576" + }, + "validator": { + "pub_key_types": [ + "ed25519" + ] + } + } + } +} +` diff --git a/usecase/parser/utils/txs_results_event.go b/usecase/parser/utils/txs_results_event.go index 5788114e..fe5e4885 100644 --- a/usecase/parser/utils/txs_results_event.go +++ b/usecase/parser/utils/txs_results_event.go @@ -61,3 +61,14 @@ func (log *ParsedTxsResultsEvents) GetEventsByType(t string) []*ParsedTxsResultL return logEvents } + +func (log *ParsedTxsResultsEvents) GetRawEvents() []model.BlockResultsEvent { + return log.rawEvents +} + +func (log *ParsedTxsResultsEvents) GetTypeIndex(key string) []int { + return log.typeIndex[key] +} +func (log *ParsedTxsResultsEvents) RemoveIndexType(key string, index int) { + log.typeIndex[key] = append(log.typeIndex[key][:index], log.typeIndex[key][index+1:]...) +} diff --git a/usecase/parser/utils/txs_results_log_event.go b/usecase/parser/utils/txs_results_log_event.go index 0f26188a..8c6baf0c 100644 --- a/usecase/parser/utils/txs_results_log_event.go +++ b/usecase/parser/utils/txs_results_log_event.go @@ -80,3 +80,10 @@ func (log *ParsedTxsResultLogEvent) GetAttributeByKey(key string) *string { } return &log.rawEvent.Attributes[log.keyIndex[key]].Value } + +func (log *ParsedTxsResultLogEvent) GetRawEvents() model.BlockResultsEvent { + return log.rawEvent +} +func (log *ParsedTxsResultLogEvent) GetKeyIndex() map[string]int { + return log.keyIndex +}