From 642fdd591f47908b1a64a2c828e7aa657b7f17d6 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 20 Jul 2018 19:34:10 +0300 Subject: [PATCH] fix the package structure to make Nimble happy --- README.md | 8 ++++---- json_rpc/router.nim | 2 +- json_rpc/rpcclient.nim | 3 +++ json_rpc/rpcserver.nim | 3 +++ rpcclient.nim | 3 --- rpcserver.nim | 3 --- tests/ethhexstrings.nim | 4 ++-- tests/ethprocs.nim | 5 ++++- tests/stintjson.nim | 2 +- tests/testerrors.nim | 2 +- tests/testethcalls.nim | 2 +- tests/testhttp.nim | 2 +- tests/testrpcmacro.nim | 2 +- tests/testserverclient.nim | 2 +- 14 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 json_rpc/rpcclient.nim create mode 100644 json_rpc/rpcserver.nim delete mode 100644 rpcclient.nim delete mode 100644 rpcserver.nim diff --git a/README.md b/README.md index 3fc1da6..e373c9f 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ When an error occurs, the `error` is populated, otherwise `result` will be popul Here's a simple example: ```nim -import rpcserver +import json_rpc/rpcserver var router = newRpcRouter() @@ -272,7 +272,7 @@ This example uses the socket transport defined in `socket.nim`. Once executed, the "hello" RPC will be available to a socket based client. ```nim -import rpcserver +import json_rpc/rpcserver # Create a socket server for transport var srv = newRpcSocketServer("localhost", Port(8585)) @@ -298,7 +298,7 @@ The `call` procedure takes care of the basic format of the JSON to send to the s However you still need to provide `params` as a `JsonNode`, which must exactly match the parameters defined in the equivalent `rpc` definition. ```nim -import rpcclient, rpcserver, asyncdispatch, json +import json_rpc/[rpcclient, rpcserver], asyncdispatch, json var server = newRpcSocketServer("localhost", Port(8545)) @@ -404,4 +404,4 @@ Please make sure to update tests as appropriate. # License [MIT](https://choosealicense.com/licenses/mit/) or -Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) \ No newline at end of file +Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) diff --git a/json_rpc/router.nim b/json_rpc/router.nim index e5a0b6a..92f04be 100644 --- a/json_rpc/router.nim +++ b/json_rpc/router.nim @@ -1,5 +1,5 @@ import - json, tables, asyncdispatch2, jsonmarshal, strutils, macros, + json, tables, asyncdispatch2, jsonmarshal, strutils, macros, chronicles, options export asyncdispatch2, json, jsonmarshal diff --git a/json_rpc/rpcclient.nim b/json_rpc/rpcclient.nim new file mode 100644 index 0000000..03224d5 --- /dev/null +++ b/json_rpc/rpcclient.nim @@ -0,0 +1,3 @@ +import client +import clients/[socketclient, httpclient] +export client, socketclient, httpclient diff --git a/json_rpc/rpcserver.nim b/json_rpc/rpcserver.nim new file mode 100644 index 0000000..81c3c7e --- /dev/null +++ b/json_rpc/rpcserver.nim @@ -0,0 +1,3 @@ +import server +import servers/[socketserver, httpserver] +export server, socketserver, httpserver diff --git a/rpcclient.nim b/rpcclient.nim deleted file mode 100644 index 7b03554..0000000 --- a/rpcclient.nim +++ /dev/null @@ -1,3 +0,0 @@ -import json_rpc/client -import json_rpc/clients/[socketclient, httpclient] -export client, socketclient, httpclient diff --git a/rpcserver.nim b/rpcserver.nim deleted file mode 100644 index 534f3c2..0000000 --- a/rpcserver.nim +++ /dev/null @@ -1,3 +0,0 @@ -import json_rpc/server -import json_rpc/servers/[socketserver, httpserver] -export server, socketserver, httpserver diff --git a/tests/ethhexstrings.nim b/tests/ethhexstrings.nim index f711689..e97adf1 100644 --- a/tests/ethhexstrings.nim +++ b/tests/ethhexstrings.nim @@ -58,8 +58,8 @@ template hexQuantityStr*(value: string): HexQuantityStr = value.HexQuantityStr # Converters -import json -from ../rpcserver import expect +import json +from ../json_rpc/rpcserver import expect proc `%`*(value: HexDataStr): JsonNode = if not value.validate: diff --git a/tests/ethprocs.nim b/tests/ethprocs.nim index 02ec761..f34b3b3 100644 --- a/tests/ethprocs.nim +++ b/tests/ethprocs.nim @@ -1,4 +1,7 @@ -import ../rpcserver, nimcrypto, json, stint, strutils, ethtypes, stintjson, ethhexstrings +import + strutils, json, + nimcrypto, stint, + ethtypes, ethhexstrings, stintjson, ../json_rpc/rpcserver #[ For details on available RPC calls, see: https://github.com/ethereum/wiki/wiki/JSON-RPC diff --git a/tests/stintjson.nim b/tests/stintjson.nim index ac9af61..5edad06 100644 --- a/tests/stintjson.nim +++ b/tests/stintjson.nim @@ -1,5 +1,5 @@ import json, stint -from ../rpcserver import expect +from ../json_rpc/rpcserver import expect template stintStr(n: UInt256|Int256): JsonNode = var s = n.toHex diff --git a/tests/testerrors.nim b/tests/testerrors.nim index 2ab2b9e..7fe4d46 100644 --- a/tests/testerrors.nim +++ b/tests/testerrors.nim @@ -3,7 +3,7 @@ allow unchecked and unformatted calls. ]# -import unittest, debugclient, ../rpcserver +import unittest, debugclient, ../json_rpc/rpcserver import strformat, chronicles var server = newRpcSocketServer("localhost", 8547.Port) diff --git a/tests/testethcalls.nim b/tests/testethcalls.nim index 4b67e8f..fc112ff 100644 --- a/tests/testethcalls.nim +++ b/tests/testethcalls.nim @@ -1,5 +1,5 @@ import unittest, json, tables -import ../rpcclient, ../rpcserver +import ../json_rpc/[rpcclient, rpcserver] import stint, ethtypes, ethprocs, stintjson, nimcrypto, ethhexstrings, chronicles from os import getCurrentDir, DirSep diff --git a/tests/testhttp.nim b/tests/testhttp.nim index 9339501..3ea9dd8 100644 --- a/tests/testhttp.nim +++ b/tests/testhttp.nim @@ -1,6 +1,6 @@ import unittest, json, strutils import httputils, chronicles -import ../rpcserver, ../rpcclient +import ../json_rpc/[rpcserver, rpcclient] const TestsCount = 100 diff --git a/tests/testrpcmacro.nim b/tests/testrpcmacro.nim index 9138c98..e3db6d8 100644 --- a/tests/testrpcmacro.nim +++ b/tests/testrpcmacro.nim @@ -1,5 +1,5 @@ import unittest, json, tables, chronicles -import ../rpcserver +import ../json_rpc/rpcserver type # some nested types to check object parsing diff --git a/tests/testserverclient.nim b/tests/testserverclient.nim index 6e4b008..d8f8e58 100644 --- a/tests/testserverclient.nim +++ b/tests/testserverclient.nim @@ -1,5 +1,5 @@ import unittest, json, chronicles -import ../rpcclient, ../rpcserver +import ../json_rpc/[rpcclient, rpcserver] var srv = newRpcSocketServer(["localhost:8545"]) var client = newRpcSocketClient()