laconicd-deprecated/ethereum/rpc/net_api.go

33 lines
738 B
Go
Raw Normal View History

2021-04-18 16:39:15 +00:00
package rpc
import (
"fmt"
ethermint "github.com/tharsis/ethermint/types"
2021-04-18 16:39:15 +00:00
"github.com/cosmos/cosmos-sdk/client"
)
// PublicNetAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.
type PublicNetAPI struct {
networkVersion uint64
}
2021-04-18 16:39:15 +00:00
// NewPublicNetAPI creates an instance of the public Net Web3 API.
2021-04-19 07:30:55 +00:00
func NewPublicNetAPI(clientCtx client.Context) *PublicNetAPI {
// parse the chainID from a integer string
2021-04-19 07:30:55 +00:00
chainIDEpoch, err := ethermint.ParseChainID(clientCtx.ChainID)
if err != nil {
panic(err)
}
return &PublicNetAPI{
networkVersion: chainIDEpoch.Uint64(),
}
}
// Version returns the current ethereum protocol version.
2021-04-18 16:39:15 +00:00
func (s *PublicNetAPI) Version() string {
return fmt.Sprintf("%d", s.networkVersion)
}