aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm/service.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/evm/service.go')
-rw-r--r--plugin/evm/service.go29
1 files changed, 17 insertions, 12 deletions
diff --git a/plugin/evm/service.go b/plugin/evm/service.go
index 128b98e..a934941 100644
--- a/plugin/evm/service.go
+++ b/plugin/evm/service.go
@@ -19,7 +19,6 @@ import (
"github.com/ava-labs/avalanchego/utils/json"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
- ethcrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
)
@@ -39,14 +38,17 @@ type SnowmanAPI struct{ vm *VM }
// AvaxAPI offers Avalanche network related API methods
type AvaxAPI struct{ vm *VM }
-// Web3API offers helper API methods
-type Web3API struct{}
+// NetAPI offers network related API methods
+type NetAPI struct{ vm *VM }
-// ClientVersion returns the version of the vm running
-func (s *Web3API) ClientVersion() string { return version }
+// Listening returns an indication if the node is listening for network connections.
+func (s *NetAPI) Listening() bool { return true } // always listening
+
+// PeerCount returns the number of connected peers
+func (s *NetAPI) PeerCount() hexutil.Uint { return hexutil.Uint(0) } // TODO: report number of connected peers
-// Sha3 returns the bytes returned by hashing [input] with Keccak256
-func (s *Web3API) Sha3(input hexutil.Bytes) hexutil.Bytes { return ethcrypto.Keccak256(input) }
+// Version returns the current ethereum protocol version.
+func (s *NetAPI) Version() string { return fmt.Sprintf("%d", s.vm.networkID) }
// GetAcceptedFrontReply defines the reply that will be sent from the
// GetAcceptedFront API call
@@ -71,6 +73,9 @@ func (api *SnowmanAPI) IssueBlock(ctx context.Context) error {
return api.vm.tryBlockGen()
}
+// ClientVersion returns the version of the vm running
+func (service *AvaxAPI) ClientVersion() string { return version }
+
// ExportKeyArgs are arguments for ExportKey
type ExportKeyArgs struct {
api.UserPass
@@ -116,7 +121,7 @@ type ImportKeyArgs struct {
}
// ImportKey adds a private key to the provided user
-func (service *AvaxAPI) ImportKey(r *http.Request, args *ImportKeyArgs, reply *api.JsonAddress) error {
+func (service *AvaxAPI) ImportKey(r *http.Request, args *ImportKeyArgs, reply *api.JSONAddress) error {
log.Info(fmt.Sprintf("EVM: ImportKey called for user '%s'", args.Username))
if !strings.HasPrefix(args.PrivateKey, constants.SecretKeyPrefix) {
@@ -164,13 +169,13 @@ type ImportArgs struct {
}
// ImportAVAX is a deprecated name for Import.
-func (service *AvaxAPI) ImportAVAX(_ *http.Request, args *ImportArgs, response *api.JsonTxID) error {
+func (service *AvaxAPI) ImportAVAX(_ *http.Request, args *ImportArgs, response *api.JSONTxID) error {
return service.Import(nil, args, response)
}
// Import issues a transaction to import AVAX from the X-chain. The AVAX
// must have already been exported from the X-Chain.
-func (service *AvaxAPI) Import(_ *http.Request, args *ImportArgs, response *api.JsonTxID) error {
+func (service *AvaxAPI) Import(_ *http.Request, args *ImportArgs, response *api.JSONTxID) error {
log.Info("EVM: ImportAVAX called")
chainID, err := service.vm.ctx.BCLookup.Lookup(args.SourceChain)
@@ -221,7 +226,7 @@ type ExportAVAXArgs struct {
// ExportAVAX exports AVAX from the C-Chain to the X-Chain
// It must be imported on the X-Chain to complete the transfer
-func (service *AvaxAPI) ExportAVAX(_ *http.Request, args *ExportAVAXArgs, response *api.JsonTxID) error {
+func (service *AvaxAPI) ExportAVAX(_ *http.Request, args *ExportAVAXArgs, response *api.JSONTxID) error {
return service.Export(nil, &ExportArgs{
ExportAVAXArgs: *args,
AssetID: service.vm.ctx.AVAXAssetID,
@@ -237,7 +242,7 @@ type ExportArgs struct {
// Export exports an asset from the C-Chain to the X-Chain
// It must be imported on the X-Chain to complete the transfer
-func (service *AvaxAPI) Export(_ *http.Request, args *ExportArgs, response *api.JsonTxID) error {
+func (service *AvaxAPI) Export(_ *http.Request, args *ExportArgs, response *api.JSONTxID) error {
log.Info("EVM: Export called")
if args.AssetID.IsZero() {
return fmt.Errorf("assetID is required")