diff --git a/helper/call.go b/helper/call.go index 90447416..fa739908 100644 --- a/helper/call.go +++ b/helper/call.go @@ -11,10 +11,7 @@ import ( "strings" "time" - "github.com/ethereum/go-ethereum" - - "github.com/maticnetwork/heimdall/tron" - + eth "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" ethTypes "github.com/ethereum/go-ethereum/core/types" @@ -29,6 +26,7 @@ import ( "github.com/maticnetwork/heimdall/contracts/statereceiver" "github.com/maticnetwork/heimdall/contracts/statesender" "github.com/maticnetwork/heimdall/contracts/validatorset" + "github.com/maticnetwork/heimdall/tron" "github.com/maticnetwork/heimdall/types" hmTypes "github.com/maticnetwork/heimdall/types" @@ -299,13 +297,13 @@ func (c *ContractCaller) GetRootTokenType(rootChainType string, rootChainManager switch rootChainType { case hmTypes.RootChainTypeEth: contractAddress := common.HexToAddress(rootChainManagerProxy) - result, err = c.MainChainClient.CallContract(context.Background(), ethereum.CallMsg{ + result, err = c.MainChainClient.CallContract(context.Background(), eth.CallMsg{ To: &contractAddress, Data: data, }, nil) case hmTypes.RootChainTypeBsc: contractAddress := common.HexToAddress(rootChainManagerProxy) - result, err = c.BscChainClient.CallContract(context.Background(), ethereum.CallMsg{ + result, err = c.BscChainClient.CallContract(context.Background(), eth.CallMsg{ To: &contractAddress, Data: data, }, nil) @@ -516,7 +514,7 @@ func (c *ContractCaller) GetLogs(fromBlock *big.Int, toBlock *big.Int, addrs []c ctx, cancel := context.WithTimeout(context.Background(), c.MaticChainTimeout) defer cancel() - logs, err := c.MaticChainClient.FilterLogs(ctx, ethereum.FilterQuery{ //nolint:typecheck + logs, err := c.MaticChainClient.FilterLogs(ctx, eth.FilterQuery{ FromBlock: fromBlock, ToBlock: toBlock, Addresses: addrs, diff --git a/helper/state_sync.go b/helper/state_sync.go index a2dfb8f1..1d46ae42 100644 --- a/helper/state_sync.go +++ b/helper/state_sync.go @@ -42,11 +42,7 @@ type StateSyncData struct { // ParseStateSyncData decodes StateSender data encoded as abi.encode(eventType, syncData). func ParseStateSyncData(data []byte) (*StateSyncData, error) { stateData, err := parseStateSyncPayload(data) - if err == nil && stateData.EventType != StateSyncEventUnknown { - return stateData, nil - } else if stateData.EventType == StateSyncEventUnknown { - return nil, errors.New("invalid EventType") - } else { + if err != nil { return nil, err } @@ -84,7 +80,7 @@ func parseStateSyncPayload(data []byte) (*StateSyncData, error) { case StateSyncMapTokenTypeHash: return parseMapTokenStateSyncData(syncData) default: - return &StateSyncData{EventType: StateSyncEventUnknown}, nil + return &StateSyncData{EventType: StateSyncEventUnknown}, errors.New("invalid state sync type") } }