From 20df578e6e0cfd80e618c04b1d54c2b71b42af06 Mon Sep 17 00:00:00 2001 From: vincentysc Date: Wed, 4 Dec 2024 10:31:12 +0800 Subject: [PATCH 1/3] move raw data field parsing to existing MsgEthereumTx parser --- usecase/parser/msg.go | 57 ++++- usecase/parser/register.go | 3 +- usecase/parser/v1_4_0_cronos/msg/msg.go | 293 ------------------------ 3 files changed, 50 insertions(+), 303 deletions(-) diff --git a/usecase/parser/msg.go b/usecase/parser/msg.go index 3dcdc518..579ff19b 100644 --- a/usecase/parser/msg.go +++ b/usecase/parser/msg.go @@ -1,6 +1,7 @@ package parser import ( + "bytes" "encoding/base64" "encoding/hex" "fmt" @@ -9,9 +10,7 @@ import ( "time" "github.com/crypto-com/chain-indexing/entity/command" - jsoniter "github.com/json-iterator/go" - "github.com/mitchellh/mapstructure" - + "github.com/crypto-com/chain-indexing/external/json" "github.com/crypto-com/chain-indexing/external/primptr" "github.com/crypto-com/chain-indexing/external/tmcosmosutils" "github.com/crypto-com/chain-indexing/external/utctime" @@ -25,6 +24,10 @@ import ( "github.com/crypto-com/chain-indexing/usecase/parser/icaauth" "github.com/crypto-com/chain-indexing/usecase/parser/utils" mapstructure_utils "github.com/crypto-com/chain-indexing/usecase/parser/utils/mapstructure" + eth_types "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rlp" + jsoniter "github.com/json-iterator/go" + "github.com/mitchellh/mapstructure" ) const ( @@ -2359,14 +2362,52 @@ func ParseMsgEthereumTx( var commands []command.Command var possibleSignerAddresses []string - log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) + var input []byte + if rawMsg.Raw != "" { + events := utils.NewParsedTxsResultsEvents(parserParams.TxsResult.Events) + log := events.ParsedEventToTxsResultLog() + parserParams.TxsResult.Log = log - if rawMsg.Data.Data != "" { - inputData, err := base64.StdEncoding.DecodeString(rawMsg.Data.Data) + rawTxData, err := hex.DecodeString(rawMsg.Raw[2:]) // Remove hex prefix "0x..." + if err != nil { + panic("error decoding raw tx data") + } + + // decode the raw tx data + var tx eth_types.Transaction + reader := bytes.NewReader(rawTxData) + err = tx.DecodeRLP(rlp.NewStream(reader, 0)) + if err != nil { + err = tx.UnmarshalBinary(rawTxData) + if err != nil { + panic(fmt.Errorf("error unmarshalling tx: %v", err)) + } + } + + // unmarshal the raw tx data into `decodeRaw` field + var txBytes []byte + txBytes, err = tx.MarshalJSON() + if err != nil { + panic(fmt.Errorf("error marshalling tx: %v", err)) + } + + var decodedRaw model.DecodedRaw + err = json.Unmarshal(txBytes, &decodedRaw) + if err != nil { + panic(fmt.Errorf("error unmarshalling tx: %v", err)) + } + msgEthereumTxParams.DecodedRaw = &decodedRaw + input = tx.Data() + } else if rawMsg.Data.Data != "" { + input, err = base64.StdEncoding.DecodeString(rawMsg.Data.Data) if err != nil { panic(fmt.Errorf("error decoding RawMsgEthereumTx.Data.Data: %v", err)) } + } + + log := utils.NewParsedTxsResultLog(&parserParams.TxsResult.Log[parserParams.MsgIndex]) + if string(input) != "" { // parse IBC msgChannelOpenInit if log.HasEvent("channel_open_init") { events := log.GetEventsByType("channel_open_init") @@ -2511,7 +2552,7 @@ func ParseMsgEthereumTx( // parse msgCreateClient sendEvents := log.GetEventsByType("create_client") if len(sendEvents) > 0 { - msg, err := parserParams.EthereumTxInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, MSG_CREATE_CLIENT_TYPE_URL) + msg, err := parserParams.EthereumTxInnerMsgDecoder.DecodeCosmosMsgFromTxInput(input, MSG_CREATE_CLIENT_TYPE_URL) if err != nil { panic(fmt.Errorf("error deserializing MsgCreateClient: %v", err)) } @@ -2526,7 +2567,7 @@ func ParseMsgEthereumTx( // parse MsgUpdateClient sendEvents := log.GetEventsByType("update_client") if len(sendEvents) > 0 { - msg, err := parserParams.EthereumTxInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, MSG_UPDATE_CLIENT_TYPE_URL) + msg, err := parserParams.EthereumTxInnerMsgDecoder.DecodeCosmosMsgFromTxInput(input, MSG_UPDATE_CLIENT_TYPE_URL) if err != nil { panic(fmt.Errorf("error deserializing MsgUpdateClient: %v", err)) } diff --git a/usecase/parser/register.go b/usecase/parser/register.go index f6270688..71c0c741 100644 --- a/usecase/parser/register.go +++ b/usecase/parser/register.go @@ -108,9 +108,8 @@ func RegisterBreakingVersionParsers(manager *utils.CosmosParserManager) { /* Cronos v1.4.0 */ - if manager.GetCronosV1_4_0BlockHeight() > 0 { - manager.RegisterParser("/ethermint.evm.v1.MsgEthereumTx", manager.GetCronosV1_4_0BlockHeight(), V1_4_0_cronos_msg.ParseMsgEthereumTx) + manager.RegisterParser("/ethermint.evm.v1.MsgEthereumTx", manager.GetCronosV1_4_0BlockHeight(), V1_4_0_cronos_msg.ParseMsgEventsToLog(ParseMsgEthereumTx)) // cosmos bank manager.RegisterParser("/cosmos.bank.v1beta1.MsgSend", manager.GetCronosV1_4_0BlockHeight(), V1_4_0_cronos_msg.ParseMsgEventsToLog(ParseMsgSend)) diff --git a/usecase/parser/v1_4_0_cronos/msg/msg.go b/usecase/parser/v1_4_0_cronos/msg/msg.go index 87f1aa3c..0fd450f2 100644 --- a/usecase/parser/v1_4_0_cronos/msg/msg.go +++ b/usecase/parser/v1_4_0_cronos/msg/msg.go @@ -1,303 +1,10 @@ package msg import ( - "bytes" - "encoding/base64" - "encoding/hex" - "encoding/json" - "fmt" - "time" - - "github.com/mitchellh/mapstructure" - - eth_types "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/rlp" - "github.com/crypto-com/chain-indexing/entity/command" - command_usecase "github.com/crypto-com/chain-indexing/usecase/command" - "github.com/crypto-com/chain-indexing/usecase/model" - "github.com/crypto-com/chain-indexing/usecase/parser/ibc" - "github.com/crypto-com/chain-indexing/usecase/parser/icaauth" "github.com/crypto-com/chain-indexing/usecase/parser/utils" - mapstructure_utils "github.com/crypto-com/chain-indexing/usecase/parser/utils/mapstructure" ) -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)) - } - - fromBytes, err := base64.StdEncoding.DecodeString(rawMsg.From) - if err != nil { - panic(fmt.Errorf("error decoding from address: %v", err)) - } - fromAddress := hex.EncodeToString(fromBytes) - rawMsg.From = fmt.Sprintf("0x%s", utils.AddressParse(fromAddress)) - - 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, - } - - var commands []command.Command - var possibleSignerAddresses []string - - events := utils.NewParsedTxsResultsEvents(parserParams.TxsResult.Events) - log := events.ParsedEventToTxsResultLog() - parserParams.TxsResult.Log = log - - rawTxData, err := hex.DecodeString(rawMsg.Raw[2:]) // Remove hex prefix "0x..." - if err != nil { - panic("error decoding raw tx data") - } - - // decode the raw tx data - var tx eth_types.Transaction - reader := bytes.NewReader(rawTxData) - err = tx.DecodeRLP(rlp.NewStream(reader, 0)) - if err != nil { - err = tx.UnmarshalBinary(rawTxData) - if err != nil { - panic(fmt.Errorf("error unmarshalling tx: %v", err)) - } - } - - // unmarshal the raw tx data into `decodeRaw` field - var txBytes []byte - txBytes, err = tx.MarshalJSON() - if err != nil { - panic(fmt.Errorf("error marshalling tx: %v", err)) - } - - var decodedRaw model.DecodedRaw - err = json.Unmarshal(txBytes, &decodedRaw) - if err != nil { - panic(fmt.Errorf("error unmarshalling tx: %v", err)) - } - msgEthereumTxParams.DecodedRaw = &decodedRaw - - if len(tx.Data()) > 0 { - inputData := tx.Data() - - // parse IBC msgChannelOpenInit - if events.HasEvent("channel_open_init") { - channelOpenInitEvents := events.GetEventsByType("channel_open_init") - if len(channelOpenInitEvents) > 0 { - for _, event := range channelOpenInitEvents { - counterpartyPortId := event.GetAttributeByKey("counterparty_port_id") - if counterpartyPortId != nil { - if *counterpartyPortId == "icahost" { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := icaauth.ParseMsgRegisterAccount(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - break - } - } else { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgChannelOpenInit(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - break - } - } - } - } else if events.HasEvent("channel_open_try") { - // parse IBC msgChannelOpenTry - if events.GetEventByType("channel_open_try") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgChannelOpenTry(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("channel_open_ack") { - // parse IBC msgChannelOpenAck - - if events.GetEventByType("channel_open_ack") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgChannelOpenAck(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("channel_open_confirm") { - // parse IBC msgChannelOpenConfirm - - if events.GetEventByType("channel_open_confirm") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgChannelOpenConfirm(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("submit_msgs_result") { - // parse ICA msgSendTx - if events.GetEventByType("submit_msgs_result") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := icaauth.ParseMsgSubmitTx(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("acknowledge_packet") { - // parse MsgAcknowledgement - if events.GetEventByType("acknowledge_packet") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgAcknowledgement(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("timeout_packet") { - // parse MsgTimeout - - if events.GetEventByType("timeout_packet") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgTimeout(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("recv_packet") { - // parse MsgRecvPacket - recvPacketEvents := events.GetEventsByType("recv_packet") - if len(recvPacketEvents) > 0 { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgRecvPacket(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("channel_close_init") { - // parse msgChannelCloseInit - if events.GetEventByType("channel_close_init") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgChannelCloseInit(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("channel_close_confirm") { - // parse msgChannelCloseConfirm - if events.GetEventByType("channel_close_confirm") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgChannelCloseConfirm(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("connection_open_init") { - // parse msgConnectionOpenInit - if events.GetEventByType("connection_open_init") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgConnectionOpenInit(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("connection_open_try") { - // parse msgConnectionOpenTry - if events.GetEventByType("connection_open_try") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgConnectionOpenTry(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("connection_open_ack") { - // parse msgConnectionOpenAck - if events.GetEventByType("connection_open_ack") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgConnectionOpenAck(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("connection_open_confirm") { - // parse msgConnectionOpenConfirm - if events.GetEventByType("connection_open_confirm") != nil { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgConnectionOpenConfirm(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("send_packet") { - // parse msgTransfer - sendEvents := events.GetEventsByType("send_packet") - if len(sendEvents) > 0 { - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgTransfer(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("create_client") { - // parse msgCreateClient - sendEvents := events.GetEventsByType("create_client") - if len(sendEvents) > 0 { - msg, err := parserParams.EthereumTxInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, "MsgCreateClient") - if err != nil { - panic(fmt.Errorf("error deserializing MsgCreateClient: %v", err)) - } - - parserParams.Msg = msg - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgCreateClient(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } else if events.HasEvent("update_client") { - // parse MsgUpdateClient - sendEvents := events.GetEventsByType("update_client") - if len(sendEvents) > 0 { - msg, err := parserParams.EthereumTxInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, "MsgUpdateClient") - if err != nil { - panic(fmt.Errorf("error deserializing MsgUpdateClient: %v", err)) - } - - parserParams.Msg = msg - parserParams.IsEthereumTxInnerMsg = true - cmds, signers := ibc.ParseMsgUpdateClient(parserParams) - commands = append(commands, cmds...) - possibleSignerAddresses = append(possibleSignerAddresses, signers...) - } - } - } - - // Getting possible signer address from Msg - // FIXME: https://github.com/crypto-com/chain-indexing/issues/729 - // possibleSignerAddresses = append(possibleSignerAddresses, msgEthereumTxParams.From) - - return append(commands, command_usecase.NewCreateMsgEthereumTx( - parserParams.MsgCommonParams, - - msgEthereumTxParams, - )), possibleSignerAddresses -} - func ParseMsgEventsToLog( parser utils.CosmosParser, ) utils.CosmosParser { From 57beff23c663d9d64aab3fe50e16e0f2a3cc1d3c Mon Sep 17 00:00:00 2001 From: vincentysc Date: Wed, 4 Dec 2024 10:45:45 +0800 Subject: [PATCH 2/3] update test case --- .../v1_4_0_cronos/msg_ethereum_tx_test.go | 108 ------------------ 1 file changed, 108 deletions(-) delete mode 100644 usecase/parser/v1_4_0_cronos/msg_ethereum_tx_test.go diff --git a/usecase/parser/v1_4_0_cronos/msg_ethereum_tx_test.go b/usecase/parser/v1_4_0_cronos/msg_ethereum_tx_test.go deleted file mode 100644 index b2623c4f..00000000 --- a/usecase/parser/v1_4_0_cronos/msg_ethereum_tx_test.go +++ /dev/null @@ -1,108 +0,0 @@ -package parser_test - -import ( - "fmt" - "strings" - - "github.com/crypto-com/chain-indexing/usecase/model" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/crypto-com/chain-indexing/infrastructure/cosmosapp" - "github.com/crypto-com/chain-indexing/infrastructure/tendermint" - command_usecase "github.com/crypto-com/chain-indexing/usecase/command" - "github.com/crypto-com/chain-indexing/usecase/event" - "github.com/crypto-com/chain-indexing/usecase/parser" - V1_4_0_msg "github.com/crypto-com/chain-indexing/usecase/parser/v1_4_0_cronos/msg" - - usecase_parser_test "github.com/crypto-com/chain-indexing/usecase/parser/test" - usecase_parser_V1_4_0_test "github.com/crypto-com/chain-indexing/usecase/parser/v1_4_0_cronos/test" -) - -var _ = Describe("ParseMsgCommands", func() { - Describe("MsgEthereumTx", func() { - It("should parse Msg commands when there is MsgEthereumTx in the transaction", func() { - block, _, _ := tendermint.ParseBlockResp(strings.NewReader( - usecase_parser_V1_4_0_test.TX_MSG_ETHEREUM_TX_BLOCK_RESP, - )) - blockResults, _ := tendermint.ParseBlockResultsResp(strings.NewReader( - usecase_parser_V1_4_0_test.TX_MSG_ETHEREUM_TX_BLOCK_RESULTS_RESP, - ), &tendermint.RawBlockResultEventAttributeDecoder{}) - - tx := MustParseTxsResp(usecase_parser_V1_4_0_test.TX_MSG_ETHEREUM_TX_TXS_RESP) - txs := []model.CosmosTxWithHash{*tx} - - accountAddressPrefix := "tcro" - stakingDenom := "basecro" - - pm := usecase_parser_test.InitParserManager() - pm.RegisterParser("/ethermint.evm.v1.MsgEthereumTx", 27101800, V1_4_0_msg.ParseMsgEthereumTx) - - cmds, possibleSignerAddresses, err := parser.ParseBlockTxsMsgToCommands( - pm, - block.Height, - blockResults, - txs, - accountAddressPrefix, - stakingDenom, - ) - Expect(err).To(BeNil()) - Expect(cmds).To(HaveLen(1)) - cmd := cmds[0] - Expect(cmd.Name()).To(Equal("/ethermint.evm.v1.MsgEthereumTx.Create")) - - Expect(cmd).To(Equal(command_usecase.NewCreateMsgEthereumTx( - event.MsgCommonParams{ - BlockHeight: int64(27101811), - TxHash: "C25934D736EFAD9CF2978EEAAB166AE12534351EF4AF9ABC28CBA78B3296D451", - TxSuccess: true, - MsgIndex: 0, - }, - model.MsgEthereumTxParams{ - RawMsgEthereumTx: model.RawMsgEthereumTx{ - - Type: "/ethermint.evm.v1.MsgEthereumTx", - Size: 0, - Data: nil, - From: "0xc4468854fe73744d7d9805eb52fde77c5169ed6b", - Hash: "", - Raw: "0xf90430824f0e8606d23ad5f80083010df594b6256dcb23cee06eda2408e73945963606fdddd780b903c43798c7f2000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000006732fc2200000000000000000000000000000000000000000000000000000000017302d6000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000343524f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034441490000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000345544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004555344430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045553445400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000457425443000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000c4c7000000000000000000000000000000000000000000000000000000000003baa0c3f00000000000000000000000000000000000000000000000000000313a9eacf80000000000000000000000000000000000000000000000000000000003b97bcc0000000000000000000000000000000000000000000000000000000003bab44c00000000000000000000000000000000000000000000000000000519c73d3ac008202c7a056a66c6115dcbf7824e07203fab30da6b4bbf6126fe4ad4be71784525c0693a9a0428593e87eedc78f7ad7670ceb0d10c1a3ecd145571dc46a4af7f82b1a46ff55", - DecodedRaw: &model.DecodedRaw{ - Type: "0x0", - Hash: "0x3094941c989efc91ad9f8fec4d24a565b7f4423fb15738875eaf9fac633eb741", - Nonce: "0x4f0e", - GasLimit: "", - GasPrice: "0x6d23ad5f800", - MaxFeePerGas: "", - MaxPriorityFeePerGas: "", - From: "", - To: "0xb6256dcb23cee06eda2408e73945963606fdddd7", - PublicKey: "", - V: "0x2c7", - R: "0x56a66c6115dcbf7824e07203fab30da6b4bbf6126fe4ad4be71784525c0693a9", - S: "0x428593e87eedc78f7ad7670ceb0d10c1a3ecd145571dc46a4af7f82b1a46ff55", - Value: "0x0", - Input: "0x3798c7f2000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000006732fc2200000000000000000000000000000000000000000000000000000000017302d6000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000343524f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034441490000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000345544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004555344430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045553445400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000457425443000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000c4c7000000000000000000000000000000000000000000000000000000000003baa0c3f00000000000000000000000000000000000000000000000000000313a9eacf80000000000000000000000000000000000000000000000000000000003b97bcc0000000000000000000000000000000000000000000000000000000003bab44c00000000000000000000000000000000000000000000000000000519c73d3ac00", - }, - }, - }, - ))) - var emptyAddress []string - Expect(possibleSignerAddresses).To(Equal(emptyAddress)) - }) - }) -}) - -func MustParseTxsResp(rawResp string) *model.CosmosTxWithHash { - tx, err := cosmosapp.ParseTxsResp(strings.NewReader(rawResp)) - - if err != nil { - panic(fmt.Sprintf("error parsing block results response: %v", err)) - } - - return &model.CosmosTxWithHash{ - Tx: tx.Tx, - Hash: tx.TxResponse.TxHash, - } -} From 01ec2f09538dd90e8c1981a4d786bf27de4f966e Mon Sep 17 00:00:00 2001 From: vincentysc Date: Wed, 4 Dec 2024 10:48:05 +0800 Subject: [PATCH 3/3] fix lint --- usecase/parser/msg.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usecase/parser/msg.go b/usecase/parser/msg.go index 579ff19b..30425ef7 100644 --- a/usecase/parser/msg.go +++ b/usecase/parser/msg.go @@ -2368,7 +2368,8 @@ func ParseMsgEthereumTx( log := events.ParsedEventToTxsResultLog() parserParams.TxsResult.Log = log - rawTxData, err := hex.DecodeString(rawMsg.Raw[2:]) // Remove hex prefix "0x..." + var rawTxData []byte + rawTxData, err = hex.DecodeString(rawMsg.Raw[2:]) // Remove hex prefix "0x..." if err != nil { panic("error decoding raw tx data") }