Skip to content

Commit

Permalink
simplify imports (#98)
Browse files Browse the repository at this point in the history
remove broken uint64 converter - upstream std/json also includes a
broken uint64 converter
  • Loading branch information
arnetheduck committed Mar 26, 2021
1 parent ac52886 commit 64d40d6
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 34 deletions.
2 changes: 1 addition & 1 deletion json_rpc.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions json_rpc/client.nim
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions json_rpc/clients/httpclient.nim
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
7 changes: 5 additions & 2 deletions json_rpc/clients/socketclient.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import
std/[json, tables],
../client, chronos
std/tables,
chronos,
../client

export client

type
RpcSocketClient* = ref object of RpcClient
Expand Down
7 changes: 5 additions & 2 deletions json_rpc/clients/websocketclient.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import
std/[json, strtabs, tables],
../client, chronos
std/[strtabs, tables],
chronos,
../client

export client

const newsUseChronos = true
include news
Expand Down
19 changes: 4 additions & 15 deletions json_rpc/jsonmarshal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,19 @@ 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:
newJNull()
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)
Expand Down
4 changes: 2 additions & 2 deletions json_rpc/router.nim
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions json_rpc/server.nim
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions json_rpc/servers/httpserver.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import
std/[json, strutils],
std/[strutils],
chronicles, httputils, chronos,
../server, ../errors
".."/[errors, server]

export server

logScope:
topics = "JSONRPC-HTTP-SERVER"
Expand Down
5 changes: 2 additions & 3 deletions json_rpc/servers/socketserver.nim
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 64d40d6

Please sign in to comment.