aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api
diff options
context:
space:
mode:
authorBas van Kervel <basvankervel@ziggo.nl>2015-06-08 16:23:54 +0800
committerBas van Kervel <basvankervel@gmail.com>2015-06-11 20:13:57 +0800
commit348f1562e29c80cac3c1d13ff255a25ed4ec81c7 (patch)
tree65889e985dc5c12c6c3a92847920b8f25997d81d /rpc/api
parent7e41d7ac51fdaba1c03ec3f9cb8cc7a7bc3830f4 (diff)
downloaddexon-348f1562e29c80cac3c1d13ff255a25ed4ec81c7.tar
dexon-348f1562e29c80cac3c1d13ff255a25ed4ec81c7.tar.gz
dexon-348f1562e29c80cac3c1d13ff255a25ed4ec81c7.tar.bz2
dexon-348f1562e29c80cac3c1d13ff255a25ed4ec81c7.tar.lz
dexon-348f1562e29c80cac3c1d13ff255a25ed4ec81c7.tar.xz
dexon-348f1562e29c80cac3c1d13ff255a25ed4ec81c7.tar.zst
dexon-348f1562e29c80cac3c1d13ff255a25ed4ec81c7.zip
restructured eth rpc API
Diffstat (limited to 'rpc/api')
-rw-r--r--rpc/api/api.go3
-rw-r--r--rpc/api/eth.go8
-rw-r--r--rpc/api/utils.go111
3 files changed, 122 insertions, 0 deletions
diff --git a/rpc/api/api.go b/rpc/api/api.go
index 206647946..e431e5c1e 100644
--- a/rpc/api/api.go
+++ b/rpc/api/api.go
@@ -32,6 +32,9 @@ type EthereumApi interface {
// API identifier
Name() string
+ // API version
+ ApiVersion() string
+
// Execute the given request and returns the response or an error
Execute(*shared.Request) (interface{}, error)
diff --git a/rpc/api/eth.go b/rpc/api/eth.go
index f27f17f39..a0b9dad86 100644
--- a/rpc/api/eth.go
+++ b/rpc/api/eth.go
@@ -11,6 +11,10 @@ import (
"github.com/ethereum/go-ethereum/xeth"
)
+const (
+ EthApiVersion = "1.0"
+)
+
// eth api provider
// See https://github.com/ethereum/wiki/wiki/JSON-RPC
type ethApi struct {
@@ -97,6 +101,10 @@ func (self *ethApi) Name() string {
return EthApiName
}
+func (self *ethApi) ApiVersion() string {
+ return EthApiVersion
+}
+
func (self *ethApi) Accounts(req *shared.Request) (interface{}, error) {
return self.xeth.Accounts(), nil
}
diff --git a/rpc/api/utils.go b/rpc/api/utils.go
index ad8a97e92..318d7c39b 100644
--- a/rpc/api/utils.go
+++ b/rpc/api/utils.go
@@ -10,6 +10,117 @@ import (
"github.com/ethereum/go-ethereum/xeth"
)
+var (
+ // Mapping between the different methods each api supports
+ AutoCompletion = map[string][]string{
+ "admin": []string{
+ "addPeer",
+ "peers",
+ "nodeInfo",
+ "exportChain",
+ "importChain",
+ "verbosity",
+ "chainSyncStatus",
+ "setSolc",
+ "datadir",
+ },
+ "debug": []string{
+ "dumpBlock",
+ "getBlockRlp",
+ "printBlock",
+ "processBlock",
+ "seedHash",
+ "setHead",
+ },
+ "eth": []string{
+ "accounts",
+ "blockNumber",
+ "getBalance",
+ "protocolVersion",
+ "coinbase",
+ "mining",
+ "gasPrice",
+ "getStorage",
+ "storageAt",
+ "getStorageAt",
+ "getTransactionCount",
+ "getBlockTransactionCountByHash",
+ "getBlockTransactionCountByNumber",
+ "getUncleCountByBlockHash",
+ "getUncleCountByBlockNumber",
+ "getData",
+ "getCode",
+ "sign",
+ "sendTransaction",
+ "transact",
+ "estimateGas",
+ "call",
+ "flush",
+ "getBlockByHash",
+ "getBlockByNumber",
+ "getTransactionByHash",
+ "getTransactionByBlockHashAndIndex",
+ "getUncleByBlockHashAndIndex",
+ "getUncleByBlockNumberAndIndex",
+ "getCompilers",
+ "compileSolidity",
+ "newFilter",
+ "newBlockFilter",
+ "newPendingTransactionFilter",
+ "uninstallFilter",
+ "getFilterChanges",
+ "getFilterLogs",
+ "getLogs",
+ "hashrate",
+ "getWork",
+ "submitWork",
+ },
+ "miner": []string{
+ "hashrate",
+ "makeDAG",
+ "setExtra",
+ "setGasPrice",
+ "startAutoDAG",
+ "start",
+ "stopAutoDAG",
+ "stop",
+ },
+ "net": []string{
+ "peerCount",
+ "listening",
+ },
+ "personal": []string{
+ "listAccounts",
+ "newAccount",
+ "deleteAccount",
+ "unlockAccount",
+ },
+ "shh": []string{
+ "version",
+ "post",
+ "hasIdentity",
+ "newIdentity",
+ "newFilter",
+ "uninstallFilter",
+ "getFilterChanges",
+ },
+ "txpool": []string{
+ "status",
+ },
+ "web3": []string{
+ "sha3",
+ "version",
+ "fromWei",
+ "toWei",
+ "toHex",
+ "toAscii",
+ "fromAscii",
+ "toBigNumber",
+ "isAddress",
+ },
+ }
+)
+
// Parse a comma separated API string to individual api's
func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.Ethereum) ([]EthereumApi, error) {
if len(strings.TrimSpace(apistr)) == 0 {