diff --git a/bootstrap/app.go b/bootstrap/app.go index 53ff5420..35d06d06 100644 --- a/bootstrap/app.go +++ b/bootstrap/app.go @@ -7,7 +7,7 @@ import ( "github.com/crypto-com/chain-indexing/appinterface/rdb" config "github.com/crypto-com/chain-indexing/bootstrap/config" projection_entity "github.com/crypto-com/chain-indexing/entity/projection" - "github.com/crypto-com/chain-indexing/external/evminnermsgdecoder" + "github.com/crypto-com/chain-indexing/external/ethereumtxinnermsgdecoder" applogger "github.com/crypto-com/chain-indexing/external/logger" "github.com/crypto-com/chain-indexing/external/txdecoder" "github.com/crypto-com/chain-indexing/infrastructure/metric/prometheus" @@ -81,9 +81,9 @@ func (a *app) InitHTTPAPIServer(registry RouteRegistry) { } } -func (a *app) InitIndexService(projections []projection_entity.Projection, cronJobs []projection_entity.CronJob, txDecoder txdecoder.TxDecoder, evmInnerMsgDecoder evminnermsgdecoder.EvmInnerMsgDecoder) { +func (a *app) InitIndexService(projections []projection_entity.Projection, cronJobs []projection_entity.CronJob, txDecoder txdecoder.TxDecoder, ethereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder) { if a.config.IndexService.Enable { - a.indexService = NewIndexService(a.logger, a.rdbConn, a.config, projections, cronJobs, txDecoder, evmInnerMsgDecoder) + a.indexService = NewIndexService(a.logger, a.rdbConn, a.config, projections, cronJobs, txDecoder, ethereumTxInnerMsgDecoder) } } diff --git a/bootstrap/indexservice.go b/bootstrap/indexservice.go index 224ffc12..25b2a971 100644 --- a/bootstrap/indexservice.go +++ b/bootstrap/indexservice.go @@ -10,7 +10,7 @@ import ( "github.com/crypto-com/chain-indexing/bootstrap/config" "github.com/crypto-com/chain-indexing/entity/event" projection_entity "github.com/crypto-com/chain-indexing/entity/projection" - "github.com/crypto-com/chain-indexing/external/evminnermsgdecoder" + "github.com/crypto-com/chain-indexing/external/ethereumtxinnermsgdecoder" applogger "github.com/crypto-com/chain-indexing/external/logger" "github.com/crypto-com/chain-indexing/external/txdecoder" event_usecase "github.com/crypto-com/chain-indexing/usecase/event" @@ -42,8 +42,8 @@ type IndexService struct { GithubAPIUser string GithubAPIToken string - txDecoder txdecoder.TxDecoder - evmInnerMsgDecoder evminnermsgdecoder.EvmInnerMsgDecoder + txDecoder txdecoder.TxDecoder + ethereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder } // NewIndexService creates a new server instance for polling and indexing @@ -54,7 +54,7 @@ func NewIndexService( projections []projection_entity.Projection, cronJobs []projection_entity.CronJob, txDecoder txdecoder.TxDecoder, - evmInnerMsgDecoder evminnermsgdecoder.EvmInnerMsgDecoder, + ethereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder, ) *IndexService { return &IndexService{ logger: logger, @@ -83,8 +83,8 @@ func NewIndexService( GithubAPIUser: config.IndexService.GithubAPI.Username, GithubAPIToken: config.IndexService.GithubAPI.Token, - txDecoder: txDecoder, - evmInnerMsgDecoder: evmInnerMsgDecoder, + txDecoder: txDecoder, + ethereumTxInnerMsgDecoder: ethereumTxInnerMsgDecoder, } } @@ -165,8 +165,8 @@ func (service *IndexService) RunEventStoreMode() error { StartingBlockHeight: service.startingBlockHeight, BlockResultEventAttributeDecodeMethod: service.BlockResultEventAttributeDecodeMethod, }, - TxDecoder: service.txDecoder, - EvmInnerMsgDecoder: service.evmInnerMsgDecoder, + TxDecoder: service.txDecoder, + EthereumTxInnerMsgDecoder: service.ethereumTxInnerMsgDecoder, }, utils.NewCosmosParserManager( utils.CosmosParserManagerParams{ @@ -207,8 +207,8 @@ func (service *IndexService) RunTendermintDirectMode() error { StartingBlockHeight: service.startingBlockHeight, BlockResultEventAttributeDecodeMethod: service.BlockResultEventAttributeDecodeMethod, }, - TxDecoder: service.txDecoder, - EvmInnerMsgDecoder: service.evmInnerMsgDecoder, + TxDecoder: service.txDecoder, + EthereumTxInnerMsgDecoder: service.ethereumTxInnerMsgDecoder, }, utils.NewCosmosParserManager( utils.CosmosParserManagerParams{ diff --git a/bootstrap/syncmanager.go b/bootstrap/syncmanager.go index 366e3294..e14dae2c 100644 --- a/bootstrap/syncmanager.go +++ b/bootstrap/syncmanager.go @@ -8,7 +8,7 @@ import ( cosmosapp_interface "github.com/crypto-com/chain-indexing/appinterface/cosmosapp" eventhandler_interface "github.com/crypto-com/chain-indexing/appinterface/eventhandler" tendermint_interface "github.com/crypto-com/chain-indexing/appinterface/tendermint" - "github.com/crypto-com/chain-indexing/external/evminnermsgdecoder" + "github.com/crypto-com/chain-indexing/external/ethereumtxinnermsgdecoder" "github.com/crypto-com/chain-indexing/external/txdecoder" cosmosapp_infrastructure "github.com/crypto-com/chain-indexing/infrastructure/cosmosapp" "github.com/crypto-com/chain-indexing/usecase/model" @@ -55,17 +55,17 @@ type SyncManager struct { startingBlockHeight int64 - txDecoder txdecoder.TxDecoder - evmInnerMsgDecoder evminnermsgdecoder.EvmInnerMsgDecoder + txDecoder txdecoder.TxDecoder + ethereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder eventAttributeDecoder tendermint_interface.BlockResultEventAttributeDecoder } type SyncManagerParams struct { - Logger applogger.Logger - RDbConn rdb.Conn - TxDecoder txdecoder.TxDecoder - EvmInnerMsgDecoder evminnermsgdecoder.EvmInnerMsgDecoder + Logger applogger.Logger + RDbConn rdb.Conn + TxDecoder txdecoder.TxDecoder + EthereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder Config SyncManagerConfig } @@ -147,8 +147,8 @@ func NewSyncManager( startingBlockHeight: params.Config.StartingBlockHeight, - txDecoder: params.TxDecoder, - evmInnerMsgDecoder: params.EvmInnerMsgDecoder, + txDecoder: params.TxDecoder, + ethereumTxInnerMsgDecoder: params.EthereumTxInnerMsgDecoder, eventAttributeDecoder: eventAttributeDecoder, } @@ -298,7 +298,7 @@ func (manager *SyncManager) syncBlockWorker(blockHeight int64) ([]command_entity }) manager.parserManager.TxDecoder = manager.txDecoder - manager.parserManager.EvmInnerMsgDecoder = manager.evmInnerMsgDecoder + manager.parserManager.EthereumTxInnerMsgDecoder = manager.ethereumTxInnerMsgDecoder commands, err := parser.ParseBlockToCommands( parseBlockToCommandsLogger, manager.parserManager, diff --git a/external/evminnermsgdecoder/evminnermsgdecoder.go b/external/ethereumtxinnermsgdecoder/ethereumtxinnermsgdecoder.go similarity index 50% rename from external/evminnermsgdecoder/evminnermsgdecoder.go rename to external/ethereumtxinnermsgdecoder/ethereumtxinnermsgdecoder.go index 9d859db6..9e43cc58 100644 --- a/external/evminnermsgdecoder/evminnermsgdecoder.go +++ b/external/ethereumtxinnermsgdecoder/ethereumtxinnermsgdecoder.go @@ -1,5 +1,5 @@ -package evminnermsgdecoder +package ethereumtxinnermsgdecoder -type EvmInnerMsgDecoder interface { +type EthereumTxInnerMsgDecoder interface { DecodeCosmosMsgFromTxInput([]byte, string) (map[string]interface{}, error) } diff --git a/usecase/parser/msg.go b/usecase/parser/msg.go index dddaac4c..adf290b6 100644 --- a/usecase/parser/msg.go +++ b/usecase/parser/msg.go @@ -155,18 +155,18 @@ func ParseBlockTxsMsgToCommands( parser := parserManager.GetParser(utils.CosmosParserKey(msgType.(string)), utils.ParserBlockHeight(blockHeight)) msgCommands, possibleSignerAddresses = parser(utils.CosmosParserParams{ - AddressPrefix: accountAddressPrefix, - StakingDenom: stakingDenom, - TxsResult: txsResult, - MsgCommonParams: msgCommonParams, - Msg: msg, - MsgIndex: msgIndex, - ParserManager: parserManager, - Logger: parserManager.GetLogger(), - TxDecoder: parserManager.TxDecoder, - EvmInnerMsgDecoder: parserManager.EvmInnerMsgDecoder, - IsProposalInnerMsg: false, - IsEthereumTxInnerMsg: false, + AddressPrefix: accountAddressPrefix, + StakingDenom: stakingDenom, + TxsResult: txsResult, + MsgCommonParams: msgCommonParams, + Msg: msg, + MsgIndex: msgIndex, + ParserManager: parserManager, + Logger: parserManager.GetLogger(), + TxDecoder: parserManager.TxDecoder, + EthereumTxInnerMsgDecoder: parserManager.EthereumTxInnerMsgDecoder, + IsProposalInnerMsg: false, + IsEthereumTxInnerMsg: false, }) } addresses = append(addresses, possibleSignerAddresses...) @@ -2509,7 +2509,7 @@ func ParseMsgEthereumTx( // parse msgCreateClient sendEvents := log.GetEventsByType("create_client") if len(sendEvents) > 0 { - msg, err := parserParams.EvmInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, MSG_CREATE_CLIENT_TYPE_URL) + msg, err := parserParams.EthereumTxInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, MSG_CREATE_CLIENT_TYPE_URL) if err != nil { panic(fmt.Errorf("error deserializing MsgCreateClient: %v", err)) } @@ -2524,7 +2524,7 @@ func ParseMsgEthereumTx( // parse MsgUpdateClient sendEvents := log.GetEventsByType("update_client") if len(sendEvents) > 0 { - msg, err := parserParams.EvmInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, MSG_UPDATE_CLIENT_TYPE_URL) + msg, err := parserParams.EthereumTxInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, MSG_UPDATE_CLIENT_TYPE_URL) if err != nil { panic(fmt.Errorf("error deserializing MsgUpdateClient: %v", err)) } diff --git a/usecase/parser/utils/parsermanager.go b/usecase/parser/utils/parsermanager.go index fadec8ba..7f4767af 100644 --- a/usecase/parser/utils/parsermanager.go +++ b/usecase/parser/utils/parsermanager.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/crypto-com/chain-indexing/entity/command" - "github.com/crypto-com/chain-indexing/external/evminnermsgdecoder" + "github.com/crypto-com/chain-indexing/external/ethereumtxinnermsgdecoder" applogger "github.com/crypto-com/chain-indexing/external/logger" "github.com/crypto-com/chain-indexing/external/txdecoder" "github.com/crypto-com/chain-indexing/usecase/event" @@ -12,11 +12,11 @@ import ( ) type CosmosParserManager struct { - store map[CosmosParserKey]BlockHeightToCosmosParserMap - logger applogger.Logger - config CosmosParserManagerConfig - TxDecoder txdecoder.TxDecoder - EvmInnerMsgDecoder evminnermsgdecoder.EvmInnerMsgDecoder + store map[CosmosParserKey]BlockHeightToCosmosParserMap + logger applogger.Logger + config CosmosParserManagerConfig + TxDecoder txdecoder.TxDecoder + EthereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder } type CosmosParserKey string @@ -48,18 +48,18 @@ type CosmosParser func( ) ([]command.Command, []string) type CosmosParserParams struct { - AddressPrefix string - StakingDenom string - TxsResult model.BlockResultsTxsResult - MsgCommonParams event.MsgCommonParams - MsgIndex int - Msg map[string]interface{} - ParserManager *CosmosParserManager - Logger applogger.Logger - TxDecoder txdecoder.TxDecoder - EvmInnerMsgDecoder evminnermsgdecoder.EvmInnerMsgDecoder - IsProposalInnerMsg bool - IsEthereumTxInnerMsg bool + AddressPrefix string + StakingDenom string + TxsResult model.BlockResultsTxsResult + MsgCommonParams event.MsgCommonParams + MsgIndex int + Msg map[string]interface{} + ParserManager *CosmosParserManager + Logger applogger.Logger + TxDecoder txdecoder.TxDecoder + EthereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder + IsProposalInnerMsg bool + IsEthereumTxInnerMsg bool } func NewCosmosParserManager(params CosmosParserManagerParams) *CosmosParserManager { diff --git a/usecase/parser/v1_4_0_cronos/msg/msg.go b/usecase/parser/v1_4_0_cronos/msg/msg.go index e41983cb..d9e40139 100644 --- a/usecase/parser/v1_4_0_cronos/msg/msg.go +++ b/usecase/parser/v1_4_0_cronos/msg/msg.go @@ -253,7 +253,7 @@ func ParseMsgEthereumTx( // parse msgCreateClient sendEvents := events.GetEventsByType("create_client") if len(sendEvents) > 0 { - msg, err := parserParams.EvmInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, "MsgCreateClient") + msg, err := parserParams.EthereumTxInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, "MsgCreateClient") if err != nil { panic(fmt.Errorf("error deserializing MsgCreateClient: %v", err)) } @@ -268,7 +268,7 @@ func ParseMsgEthereumTx( // parse MsgUpdateClient sendEvents := events.GetEventsByType("update_client") if len(sendEvents) > 0 { - msg, err := parserParams.EvmInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, "MsgUpdateClient") + msg, err := parserParams.EthereumTxInnerMsgDecoder.DecodeCosmosMsgFromTxInput(inputData, "MsgUpdateClient") if err != nil { panic(fmt.Errorf("error deserializing MsgUpdateClient: %v", err)) }