From 0c704bb145a9a35a808e2b737149ba41d93b9b8f Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 29 Apr 2021 10:56:29 +0200 Subject: [PATCH] json-rpc: add response-to-json --- pkg/arvo/app/azimuth-rpc.hoon | 27 ++------------------------- pkg/arvo/lib/json/rpc.hoon | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index 4911ae362c..5c26790f23 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -1,7 +1,7 @@ :: Azimuth RPC API :: /- rpc=json-rpc -/+ naive, *server, default-agent, verb, dbug, version +/+ naive, json-rpc, *server, default-agent, verb, dbug, version |% +$ card card:agent:gall :: @@ -141,7 +141,7 @@ ++ get-point |= [id=@t params=request-params:rpc] %- json-response:gen - %- rpc-response-to-json + %- response-to-json:json-rpc ?. ?=([%object *] params) [%error id 'X' 'RPC params must be an object'] ?> ?=(^ +.params) @@ -204,29 +204,6 @@ ['nonce' (numb:enjs:format nonce)] == -- - :: TODO: move to rpc library - :: - ++ rpc-response-to-json - |= =response:rpc - ^- json - :: TODO: consider all cases - :: - ?+ -.response ~|([%unsupported-rpc-response response] !!) - %result - :- %o - %- molt - ^- (list [@t json]) - ~[['id' s+id.response] ['res' res.response]] - :: - %error - :- %o - %- molt - ^- (list [@t json]) - :~ ['id' s+id.response] - ['code' s+code.response] - ['message' s+message.response] - == - == -- :: ++ scry-point diff --git a/pkg/arvo/lib/json/rpc.hoon b/pkg/arvo/lib/json/rpc.hoon index e44ad1d686..c5ead16c7e 100644 --- a/pkg/arvo/lib/json/rpc.hoon +++ b/pkg/arvo/lib/json/rpc.hoon @@ -28,4 +28,26 @@ %object [%o (~(gas by *(map @t json)) +.params)] == == +:: +++ response-to-json + |= =response + ^- json + :: TODO: consider all cases + :: + ?+ -.response ~|([%unsupported-rpc-response response] !!) + %result + :- %o + %- molt + ^- (list [@t json]) + ~[['id' s+id.response] ['res' res.response]] + :: + %error + :- %o + %- molt + ^- (list [@t json]) + :~ ['id' s+id.response] + ['code' s+code.response] + ['message' s+message.response] + == + == --