Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
rpc, evm: refactor (#588)
Browse files Browse the repository at this point in the history
* stargate: refactor

* remove evm CLI

* rpc: refactor

* more fixes

* fixes fixes fixes

* changelog

* refactor according to namespaces

* fix

* lint

* remove export logic

* fix rpc test

* godoc
  • Loading branch information
fedekunze committed Oct 22, 2020
1 parent be09a6e commit 4501bbc
Show file tree
Hide file tree
Showing 36 changed files with 2,395 additions and 2,586 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (crypto) [\#559](https://github.com/cosmos/ethermint/pull/559) Refactored crypto package in preparation for the SDK's Stargate release:
* `crypto.PubKeySecp256k1` and `crypto.PrivKeySecp256k1` are now `ethsecp256k1.PubKey` and `ethsecp256k1.PrivKey`, respectively
* Moved SDK `SigningAlgo` implementation for Ethermint's Secp256k1 key to `crypto/hd` package.
* (rpc) [\#588](https://github.com/cosmos/ethermint/pull/588) The `rpc` package has been refactored to account for the separation of each
corresponding Ethereum API namespace:
* `rpc/namespaces/eth`: `eth` namespace. Exposes the `PublicEthereumAPI` and the `PublicFilterAPI`.
* `rpc/namespaces/personal`: `personal` namespace. Exposes the `PrivateAccountAPI`.
* `rpc/namespaces/net`: `net` namespace. Exposes the `PublicNetAPI`.
* `rpc/namespaces/web3`: `web3` namespace. Exposes the `PublicWeb3API`.

* (evm) [\#588](https://github.com/cosmos/ethermint/pull/588) The EVM transaction CLI has been removed in favor of the JSON-RPC.

### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion cmd/ethermintcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func main() {
queryCmd(cdc),
txCmd(cdc),
client.ValidateChainID(
rpc.EmintServeCmd(cdc),
rpc.ServeCmd(cdc),
),
flags.LineBreak,
client.KeyCommands(),
Expand Down
35 changes: 20 additions & 15 deletions rpc/apis.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Package rpc contains RPC handler methods and utilities to start
// Ethermint's Web3-compatibly JSON-RPC server.
package rpc

import (
Expand All @@ -8,6 +6,13 @@ import (
"github.com/cosmos/cosmos-sdk/client/context"

"github.com/cosmos/ethermint/crypto/ethsecp256k1"
"github.com/cosmos/ethermint/rpc/backend"
"github.com/cosmos/ethermint/rpc/namespaces/eth"
"github.com/cosmos/ethermint/rpc/namespaces/eth/filters"
"github.com/cosmos/ethermint/rpc/namespaces/net"
"github.com/cosmos/ethermint/rpc/namespaces/personal"
"github.com/cosmos/ethermint/rpc/namespaces/web3"
rpctypes "github.com/cosmos/ethermint/rpc/types"
)

// RPC namespaces and API version
Expand All @@ -20,17 +25,17 @@ const (
apiVersion = "1.0"
)

// GetRPCAPIs returns the list of all APIs
func GetRPCAPIs(cliCtx context.CLIContext, keys []ethsecp256k1.PrivKey) []rpc.API {
nonceLock := new(AddrLocker)
backend := NewEthermintBackend(cliCtx)
ethAPI := NewPublicEthAPI(cliCtx, backend, nonceLock, keys)
// GetAPIs returns the list of all APIs from the Ethereum namespaces
func GetAPIs(clientCtx context.CLIContext, keys ...ethsecp256k1.PrivKey) []rpc.API {
nonceLock := new(rpctypes.AddrLocker)
backend := backend.New(clientCtx)
ethAPI := eth.NewAPI(clientCtx, backend, nonceLock, keys...)

return []rpc.API{
{
Namespace: Web3Namespace,
Version: apiVersion,
Service: NewPublicWeb3API(),
Service: web3.NewAPI(),
Public: true,
},
{
Expand All @@ -40,21 +45,21 @@ func GetRPCAPIs(cliCtx context.CLIContext, keys []ethsecp256k1.PrivKey) []rpc.AP
Public: true,
},
{
Namespace: PersonalNamespace,
Namespace: EthNamespace,
Version: apiVersion,
Service: NewPersonalEthAPI(ethAPI),
Public: false,
Service: filters.NewAPI(clientCtx, backend),
Public: true,
},
{
Namespace: EthNamespace,
Namespace: PersonalNamespace,
Version: apiVersion,
Service: NewPublicFilterAPI(cliCtx, backend),
Public: true,
Service: personal.NewAPI(ethAPI),
Public: false,
},
{
Namespace: NetNamespace,
Version: apiVersion,
Service: NewPublicNetAPI(cliCtx),
Service: net.NewAPI(clientCtx),
Public: true,
},
}
Expand Down
22 changes: 0 additions & 22 deletions rpc/args/send_tx.go

This file was deleted.

0 comments on commit 4501bbc

Please sign in to comment.