20e9b2ede3
* rpc: event websocket subscription * rpc: use tendermint event subscriptions * new log events * filter evm transactions * filter logs * wip: refactor filters * remove custom BlockNumber * wip: refactor rpc * HeaderByNumber and HeaderByHash * update Tendermint event system * update Filter * update EventSystem * fix lint issues * update rpc filters * upgrade to tendermint v0.33.4 * update filters * fix unsubscription * updates wip * initialize channels * cleanup go routines * pass ResultEvent channel on subscription * error channel * add block filter changes test * add eventCh loop * pass funcs in select go func, block filter working * cleanup * lint * NewFilter and GetFilterChanges working * eth_getLogs working * lint * lint * cleanup * remove logs and minor fixes * changelog * address @noot comments * revert BlockNumber removal Co-authored-by: noot <elizabethjbinks@gmail.com>
36 lines
866 B
Go
36 lines
866 B
Go
package rpc
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
)
|
|
|
|
// PublicNetAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.
|
|
type PublicNetAPI struct {
|
|
networkVersion uint64
|
|
}
|
|
|
|
// NewPublicNetAPI creates an instance of the public Net Web3 API.
|
|
func NewPublicNetAPI(_ context.CLIContext) *PublicNetAPI {
|
|
chainID := viper.GetString(flags.FlagChainID)
|
|
// parse the chainID from a integer string
|
|
intChainID, err := strconv.ParseUint(chainID, 0, 64)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("invalid chainID: %s, must be integer format", chainID))
|
|
}
|
|
|
|
return &PublicNetAPI{
|
|
networkVersion: intChainID,
|
|
}
|
|
}
|
|
|
|
// Version returns the current ethereum protocol version.
|
|
func (s *PublicNetAPI) Version() string {
|
|
return fmt.Sprintf("%d", s.networkVersion)
|
|
}
|