From 64d40d6c1a095761a03d1ba55eb45877596e8e7b Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Fri, 26 Mar 2021 13:17:00 +0100 Subject: [PATCH] simplify imports (#98) remove broken uint64 converter - upstream std/json also includes a broken uint64 converter --- json_rpc.nimble | 2 +- json_rpc/client.nim | 4 ++-- json_rpc/clients/httpclient.nim | 6 ++++-- json_rpc/clients/socketclient.nim | 7 +++++-- json_rpc/clients/websocketclient.nim | 7 +++++-- json_rpc/jsonmarshal.nim | 19 ++++--------------- json_rpc/router.nim | 4 ++-- json_rpc/server.nim | 5 ++--- json_rpc/servers/httpserver.nim | 6 ++++-- json_rpc/servers/socketserver.nim | 5 ++--- 10 files changed, 31 insertions(+), 34 deletions(-) diff --git a/json_rpc.nimble b/json_rpc.nimble index 2b405509..e12fb4bd 100644 --- a/json_rpc.nimble +++ b/json_rpc.nimble @@ -6,7 +6,7 @@ license = "Apache License 2.0" skipDirs = @["tests"] ### Dependencies -requires "nim >= 0.17.3", +requires "nim >= 1.2.0", "nimcrypto", "stint", "chronos", diff --git a/json_rpc/client.nim b/json_rpc/client.nim index f7294618..5673fee8 100644 --- a/json_rpc/client.nim +++ b/json_rpc/client.nim @@ -1,12 +1,12 @@ import - std/[tables, json, macros], + std/[tables, macros], chronos, ./jsonmarshal from strutils import toLowerAscii, replace export - chronos, json, tables + chronos, jsonmarshal, tables type ClientId* = int64 diff --git a/json_rpc/clients/httpclient.nim b/json_rpc/clients/httpclient.nim index 9a63bcc7..6419c681 100644 --- a/json_rpc/clients/httpclient.nim +++ b/json_rpc/clients/httpclient.nim @@ -1,9 +1,11 @@ import - std/[json, strutils, tables, uri], + std/[strutils, tables, uri], stew/byteutils, - chronicles, httputils, chronos, json_serialization/std/net, + chronicles, httputils, json_serialization/std/net, ../client +export client + logScope: topics = "JSONRPC-HTTP-CLIENT" diff --git a/json_rpc/clients/socketclient.nim b/json_rpc/clients/socketclient.nim index c4468d90..727cc1ba 100644 --- a/json_rpc/clients/socketclient.nim +++ b/json_rpc/clients/socketclient.nim @@ -1,6 +1,9 @@ import - std/[json, tables], - ../client, chronos + std/tables, + chronos, + ../client + +export client type RpcSocketClient* = ref object of RpcClient diff --git a/json_rpc/clients/websocketclient.nim b/json_rpc/clients/websocketclient.nim index 067242ef..48fcc185 100644 --- a/json_rpc/clients/websocketclient.nim +++ b/json_rpc/clients/websocketclient.nim @@ -1,6 +1,9 @@ import - std/[json, strtabs, tables], - ../client, chronos + std/[strtabs, tables], + chronos, + ../client + +export client const newsUseChronos = true include news diff --git a/json_rpc/jsonmarshal.nim b/json_rpc/jsonmarshal.nim index 411ab9bf..ba509c74 100644 --- a/json_rpc/jsonmarshal.nim +++ b/json_rpc/jsonmarshal.nim @@ -2,16 +2,12 @@ import std/[macros, json, options, typetraits], stew/byteutils -export json +export json, options proc expect*(actual, expected: JsonNodeKind, argName: string) = - if actual != expected: raise newException(ValueError, "Parameter [" & argName & "] expected " & $expected & " but got " & $actual) - -proc `%`*(n: byte{not lit}): JsonNode = - newJInt(int(n)) - -proc `%`*(n: uint64{not lit}): JsonNode = - newJInt(int(n)) + if actual != expected: + raise newException( + ValueError, "Parameter [" & argName & "] expected " & $expected & " but got " & $actual) proc `%`*(n: ref SomeInteger): JsonNode = if n.isNil: @@ -19,13 +15,6 @@ proc `%`*(n: ref SomeInteger): JsonNode = else: newJInt(n[]) -when (NimMajor, NimMinor, NimPatch) < (0, 19, 9): - proc `%`*[T](option: Option[T]): JsonNode = - if option.isSome: - `%`(option.get) - else: - newJNull() - # Compiler requires forward decl when processing out of module proc fromJson*(n: JsonNode, argName: string, result: var bool) proc fromJson*(n: JsonNode, argName: string, result: var int) diff --git a/json_rpc/router.nim b/json_rpc/router.nim index e6282921..03ae5de0 100644 --- a/json_rpc/router.nim +++ b/json_rpc/router.nim @@ -1,10 +1,10 @@ import - std/[json, macros, options, strutils, tables], + std/[macros, options, strutils, tables], chronicles, chronos, json_serialization/writer, ./jsonmarshal export - chronos, json, jsonmarshal + chronos, jsonmarshal type StringOfJson* = JsonString diff --git a/json_rpc/server.nim b/json_rpc/server.nim index 27914ac2..cd05bceb 100644 --- a/json_rpc/server.nim +++ b/json_rpc/server.nim @@ -1,10 +1,9 @@ import - std/[json, macros], - chronos, chronicles, + chronos, ./router, ./jsonmarshal -export chronos, json, jsonmarshal, router, chronicles +export chronos, jsonmarshal, router type RpcServer* = ref object of RootRef diff --git a/json_rpc/servers/httpserver.nim b/json_rpc/servers/httpserver.nim index 39b1b14c..a2777f91 100644 --- a/json_rpc/servers/httpserver.nim +++ b/json_rpc/servers/httpserver.nim @@ -1,7 +1,9 @@ import - std/[json, strutils], + std/[strutils], chronicles, httputils, chronos, - ../server, ../errors + ".."/[errors, server] + +export server logScope: topics = "JSONRPC-HTTP-SERVER" diff --git a/json_rpc/servers/socketserver.nim b/json_rpc/servers/socketserver.nim index 4ce77c86..63b6d4a1 100644 --- a/json_rpc/servers/socketserver.nim +++ b/json_rpc/servers/socketserver.nim @@ -1,10 +1,9 @@ import - std/json, chronicles, json_serialization/std/net, - ../server, ../errors + ".."/[errors, server] -export server +export errors, server type RpcSocketServer* = ref object of RpcServer