{"action":"created","comment":{"url":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/comments/186974315","pull_request_review_id":118657451,"id":186974315,"diff_hunk":"@@ -13,15 +14,152 @@ type\n     code*: int\n     data*: JsonNode\n \n-proc newRpcServer*(address: string, port: Port = Port(8545)): RpcServer =\n-  RpcServer(\n+proc register*(server: RpcServer, name: string, rpc: RpcProc) =\n+  server.procs[name] = rpc\n+\n+proc unRegisterAll*(server: RpcServer) = server.procs.clear\n+\n+proc newRpcServer*(address = \"localhost\", port: Port = Port(8545)): RpcServer =\n+  result = RpcServer(\n     socket: newAsyncSocket(),\n     port: port,\n     address: address,\n     procs: newTable[string, RpcProc]()\n   )\n \n-proc register*(server: RpcServer, name: string, rpc: RpcProc) =\n-  server.procs[name] = rpc\n+var sharedServer: RpcServer\n \n-proc unRegisterAll*(server: RpcServer) = server.procs.clear\n+proc sharedRpcServer*(): RpcServer =\n+  if sharedServer.isNil: sharedServer = newRpcServer(\"\")\n+  result = sharedServer\n+  \n+proc fromJson(n: JsonNode, argName: string, result: var bool) =\n+  if n.kind != JBool: raise newException(ValueError, \"Parameter \\\"\" & argName & \"\\\" expected JBool but got \" & $n.kind)\n+  result = n.getBool()\n+\n+proc fromJson(n: JsonNode, argName: string, result: var int) =\n+  if n.kind != JInt: raise newException(ValueError, \"Parameter \\\"\" & argName & \"\\\" expected JInt but got \" & $n.kind)\n+  result = n.getInt()\n+\n+proc fromJson(n: JsonNode, argName: string, result: var byte) =\n+  if n.kind != JInt: raise newException(ValueError, \"Parameter \\\"\" & argName & \"\\\" expected JInt but got \" & $n.kind)\n+  let v = n.getInt()\n+  if v > 255 or v < 0: raise newException(ValueError, \"Parameter \\\"\" & argName & \"\\\" value out of range for byte: \" & $v)\n+  result = byte(v)\n+\n+proc fromJson(n: JsonNode, argName: string, result: var float) =\n+  if n.kind != JFloat: raise newException(ValueError, \"Parameter \\\"\" & argName & \"\\\" expected JFloat but got \" & $n.kind)\n+  result = n.getFloat()\n+\n+proc fromJson(n: JsonNode, argName: string, result: var string) =\n+  if n.kind != JString: raise newException(ValueError, \"Parameter \\\"\" & argName & \"\\\" expected JString but got \" & $n.kind)\n+  result = n.getStr()\n+\n+proc fromJson[T](n: JsonNode, argName: string, result: var seq[T]) =\n+  result = newSeq[T](n.len)\n+  for i in 0 ..< n.len:\n+    fromJson(n[i], argName, result[i])\n+\n+proc fromJson[N, T](n: JsonNode, argName: string, result: var array[N, T]) =\n+  for i in 0 ..< n.len:\n+    fromJson(n[i], argName, result[i])\n+\n+proc fromJson[T: object](n: JsonNode, argName: string, result: var T) =\n+  for k, v in fieldpairs(result):\n+    fromJson(n[k], k, v)\n+\n+proc unpackArg[T](argIdx: int, argName: string, argtype: typedesc[T], args: JsonNode): T =\n+  when argType is array or argType is seq:\n+    if args[argIdx].kind != JArray: raise newException(ValueError, \"Parameter \\\"\" & argName & \"\\\" expected JArray but got \" & $args[argIdx].kind)\n+  when argType is array:\n+    if args[argIdx].len > result.len: raise newException(ValueError, \"Parameter \\\"\" & argName & \"\\\" item count is too big for array\")\n+  when argType is object:\n+    if args[argIdx].kind != JObject: raise newException(ValueError, \"Parameter \\\"\" & argName & \"\\\" expected JObject but got \" & $args[argIdx].kind)\n+  fromJson(args[argIdx], argName, result)\n+\n+proc expectArrayLen(node: NimNode, paramsIdent: untyped, length: int) =","path":"eth-rpc/server/servertypes.nim","position":83,"original_position":83,"commit_id":"e74dfdce62359aadc2f0334db519dd7d4bae42fa","original_commit_id":"1ac58430f08e5e82fad9ca32045e4ad8e556a803","user":{"login":"coffeepots","id":12612616,"avatar_url":"https://avatars0.githubusercontent.com/u/12612616?v=4","gravatar_id":"","url":"https://api.github.com/users/coffeepots","html_url":"https://github.com/coffeepots","followers_url":"https://api.github.com/users/coffeepots/followers","following_url":"https://api.github.com/users/coffeepots/following{/other_user}","gists_url":"https://api.github.com/users/coffeepots/gists{/gist_id}","starred_url":"https://api.github.com/users/coffeepots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coffeepots/subscriptions","organizations_url":"https://api.github.com/users/coffeepots/orgs","repos_url":"https://api.github.com/users/coffeepots/repos","events_url":"https://api.github.com/users/coffeepots/events{/privacy}","received_events_url":"https://api.github.com/users/coffeepots/received_events","type":"User","site_admin":false},"body":"@yglukhov I've replaced the macro now :)","created_at":"2018-05-09T08:52:42Z","updated_at":"2018-05-09T08:52:42Z","html_url":"https://github.com/status-im/nim-eth-rpc/pull/7#discussion_r186974315","pull_request_url":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/7","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/comments/186974315"},"html":{"href":"https://github.com/status-im/nim-eth-rpc/pull/7#discussion_r186974315"},"pull_request":{"href":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/7"}},"in_reply_to_id":186881844},"pull_request":{"url":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/7","id":186737912,"html_url":"https://github.com/status-im/nim-eth-rpc/pull/7","diff_url":"https://github.com/status-im/nim-eth-rpc/pull/7.diff","patch_url":"https://github.com/status-im/nim-eth-rpc/pull/7.patch","issue_url":"https://api.github.com/repos/status-im/nim-eth-rpc/issues/7","number":7,"state":"open","locked":false,"title":"PR #5 (Remove includes and expand macros) change requests","user":{"login":"coffeepots","id":12612616,"avatar_url":"https://avatars0.githubusercontent.com/u/12612616?v=4","gravatar_id":"","url":"https://api.github.com/users/coffeepots","html_url":"https://github.com/coffeepots","followers_url":"https://api.github.com/users/coffeepots/followers","following_url":"https://api.github.com/users/coffeepots/following{/other_user}","gists_url":"https://api.github.com/users/coffeepots/gists{/gist_id}","starred_url":"https://api.github.com/users/coffeepots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coffeepots/subscriptions","organizations_url":"https://api.github.com/users/coffeepots/orgs","repos_url":"https://api.github.com/users/coffeepots/repos","events_url":"https://api.github.com/users/coffeepots/events{/privacy}","received_events_url":"https://api.github.com/users/coffeepots/received_events","type":"User","site_admin":false},"body":"* Moved raises out of generics (need to replace these with proper async returns)\r\n* Refactored check code for expected parameter length\r\n* Moved `multiRemove` macro into proc\r\n* Used accessors to ensure checking when fetch required message fields from json","created_at":"2018-05-08T19:51:40Z","updated_at":"2018-05-09T08:52:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"61d7aaf54d830f10f186a4fbab395e2719b81656","assignee":null,"assignees":[],"requested_reviewers":[{"login":"zah","id":175462,"avatar_url":"https://avatars2.githubusercontent.com/u/175462?v=4","gravatar_id":"","url":"https://api.github.com/users/zah","html_url":"https://github.com/zah","followers_url":"https://api.github.com/users/zah/followers","following_url":"https://api.github.com/users/zah/following{/other_user}","gists_url":"https://api.github.com/users/zah/gists{/gist_id}","starred_url":"https://api.github.com/users/zah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zah/subscriptions","organizations_url":"https://api.github.com/users/zah/orgs","repos_url":"https://api.github.com/users/zah/repos","events_url":"https://api.github.com/users/zah/events{/privacy}","received_events_url":"https://api.github.com/users/zah/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/7/commits","review_comments_url":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/7/comments","review_comment_url":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/status-im/nim-eth-rpc/issues/7/comments","statuses_url":"https://api.github.com/repos/status-im/nim-eth-rpc/statuses/e74dfdce62359aadc2f0334db519dd7d4bae42fa","head":{"label":"status-im:YuriyRequests","ref":"YuriyRequests","sha":"e74dfdce62359aadc2f0334db519dd7d4bae42fa","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":123437311,"name":"nim-eth-rpc","full_name":"status-im/nim-eth-rpc","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/nim-eth-rpc","description":"Remote procedure calls for the Nimbus Ethereum project","fork":false,"url":"https://api.github.com/repos/status-im/nim-eth-rpc","forks_url":"https://api.github.com/repos/status-im/nim-eth-rpc/forks","keys_url":"https://api.github.com/repos/status-im/nim-eth-rpc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/nim-eth-rpc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/nim-eth-rpc/teams","hooks_url":"https://api.github.com/repos/status-im/nim-eth-rpc/hooks","issue_events_url":"https://api.github.com/repos/status-im/nim-eth-rpc/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/nim-eth-rpc/events","assignees_url":"https://api.github.com/repos/status-im/nim-eth-rpc/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/nim-eth-rpc/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/nim-eth-rpc/tags","blobs_url":"https://api.github.com/repos/status-im/nim-eth-rpc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/nim-eth-rpc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/nim-eth-rpc/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/nim-eth-rpc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/nim-eth-rpc/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/nim-eth-rpc/languages","stargazers_url":"https://api.github.com/repos/status-im/nim-eth-rpc/stargazers","contributors_url":"https://api.github.com/repos/status-im/nim-eth-rpc/contributors","subscribers_url":"https://api.github.com/repos/status-im/nim-eth-rpc/subscribers","subscription_url":"https://api.github.com/repos/status-im/nim-eth-rpc/subscription","commits_url":"https://api.github.com/repos/status-im/nim-eth-rpc/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/nim-eth-rpc/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/nim-eth-rpc/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/nim-eth-rpc/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/nim-eth-rpc/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/nim-eth-rpc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/nim-eth-rpc/merges","archive_url":"https://api.github.com/repos/status-im/nim-eth-rpc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/nim-eth-rpc/downloads","issues_url":"https://api.github.com/repos/status-im/nim-eth-rpc/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/nim-eth-rpc/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/nim-eth-rpc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/nim-eth-rpc/labels{/name}","releases_url":"https://api.github.com/repos/status-im/nim-eth-rpc/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/nim-eth-rpc/deployments","created_at":"2018-03-01T13:17:26Z","updated_at":"2018-04-26T18:53:07Z","pushed_at":"2018-05-09T08:52:09Z","git_url":"git://github.com/status-im/nim-eth-rpc.git","ssh_url":"git@github.com:status-im/nim-eth-rpc.git","clone_url":"https://github.com/status-im/nim-eth-rpc.git","svn_url":"https://github.com/status-im/nim-eth-rpc","homepage":null,"size":85,"stargazers_count":1,"watchers_count":1,"language":"Nim","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":6,"watchers":1,"default_branch":"master"}},"base":{"label":"status-im:master","ref":"master","sha":"93296d40c1b22ec74f5a994bf47604c41595700a","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":123437311,"name":"nim-eth-rpc","full_name":"status-im/nim-eth-rpc","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/nim-eth-rpc","description":"Remote procedure calls for the Nimbus Ethereum project","fork":false,"url":"https://api.github.com/repos/status-im/nim-eth-rpc","forks_url":"https://api.github.com/repos/status-im/nim-eth-rpc/forks","keys_url":"https://api.github.com/repos/status-im/nim-eth-rpc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/nim-eth-rpc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/nim-eth-rpc/teams","hooks_url":"https://api.github.com/repos/status-im/nim-eth-rpc/hooks","issue_events_url":"https://api.github.com/repos/status-im/nim-eth-rpc/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/nim-eth-rpc/events","assignees_url":"https://api.github.com/repos/status-im/nim-eth-rpc/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/nim-eth-rpc/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/nim-eth-rpc/tags","blobs_url":"https://api.github.com/repos/status-im/nim-eth-rpc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/nim-eth-rpc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/nim-eth-rpc/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/nim-eth-rpc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/nim-eth-rpc/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/nim-eth-rpc/languages","stargazers_url":"https://api.github.com/repos/status-im/nim-eth-rpc/stargazers","contributors_url":"https://api.github.com/repos/status-im/nim-eth-rpc/contributors","subscribers_url":"https://api.github.com/repos/status-im/nim-eth-rpc/subscribers","subscription_url":"https://api.github.com/repos/status-im/nim-eth-rpc/subscription","commits_url":"https://api.github.com/repos/status-im/nim-eth-rpc/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/nim-eth-rpc/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/nim-eth-rpc/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/nim-eth-rpc/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/nim-eth-rpc/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/nim-eth-rpc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/nim-eth-rpc/merges","archive_url":"https://api.github.com/repos/status-im/nim-eth-rpc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/nim-eth-rpc/downloads","issues_url":"https://api.github.com/repos/status-im/nim-eth-rpc/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/nim-eth-rpc/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/nim-eth-rpc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/nim-eth-rpc/labels{/name}","releases_url":"https://api.github.com/repos/status-im/nim-eth-rpc/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/nim-eth-rpc/deployments","created_at":"2018-03-01T13:17:26Z","updated_at":"2018-04-26T18:53:07Z","pushed_at":"2018-05-09T08:52:09Z","git_url":"git://github.com/status-im/nim-eth-rpc.git","ssh_url":"git@github.com:status-im/nim-eth-rpc.git","clone_url":"https://github.com/status-im/nim-eth-rpc.git","svn_url":"https://github.com/status-im/nim-eth-rpc","homepage":null,"size":85,"stargazers_count":1,"watchers_count":1,"language":"Nim","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/7"},"html":{"href":"https://github.com/status-im/nim-eth-rpc/pull/7"},"issue":{"href":"https://api.github.com/repos/status-im/nim-eth-rpc/issues/7"},"comments":{"href":"https://api.github.com/repos/status-im/nim-eth-rpc/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/status-im/nim-eth-rpc/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/status-im/nim-eth-rpc/statuses/e74dfdce62359aadc2f0334db519dd7d4bae42fa"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"coffeepots"}}