@@ -1472,10 +1472,11 @@ struct RPCCallImp
1472
1472
// ------------------------------------------------------------------------------
1473
1473
1474
1474
// Used internally by rpcClient.
1475
- static Json::Value
1476
- rpcCmdLineToJson (
1475
+ Json::Value
1476
+ rpcCmdToJson (
1477
1477
std::vector<std::string> const & args,
1478
1478
Json::Value& retParams,
1479
+ unsigned int apiVersion,
1479
1480
beast::Journal j)
1480
1481
{
1481
1482
Json::Value jvRequest (Json::objectValue);
@@ -1493,11 +1494,11 @@ rpcCmdLineToJson(
1493
1494
1494
1495
jvRequest = rpParser.parseCommand (args[0 ], jvRpcParams, true );
1495
1496
1496
- auto insert_api_version = [](Json::Value& jr) {
1497
+ auto insert_api_version = [apiVersion ](Json::Value& jr) {
1497
1498
if (jr.isObject () && !jr.isMember (jss::error) &&
1498
1499
!jr.isMember (jss::api_version))
1499
1500
{
1500
- jr[jss::api_version] = RPC::apiMaximumSupportedVersion ;
1501
+ jr[jss::api_version] = apiVersion ;
1501
1502
}
1502
1503
};
1503
1504
@@ -1510,42 +1511,14 @@ rpcCmdLineToJson(
1510
1511
return jvRequest;
1511
1512
}
1512
1513
1513
- Json::Value
1514
- cmdLineToJSONRPC (std::vector<std::string> const & args, beast::Journal j)
1515
- {
1516
- Json::Value jv = Json::Value (Json::objectValue);
1517
- auto const paramsObj = rpcCmdLineToJson (args, jv, j);
1518
-
1519
- // Re-use jv to return our formatted result.
1520
- jv.clear ();
1521
-
1522
- // Allow parser to rewrite method.
1523
- jv[jss::method] = paramsObj.isMember (jss::method)
1524
- ? paramsObj[jss::method].asString ()
1525
- : args[0 ];
1526
-
1527
- // If paramsObj is not empty, put it in a [params] array.
1528
- if (paramsObj.begin () != paramsObj.end ())
1529
- {
1530
- auto & paramsArray = Json::setArray (jv, jss::params);
1531
- paramsArray.append (paramsObj);
1532
- }
1533
- if (paramsObj.isMember (jss::jsonrpc))
1534
- jv[jss::jsonrpc] = paramsObj[jss::jsonrpc];
1535
- if (paramsObj.isMember (jss::ripplerpc))
1536
- jv[jss::ripplerpc] = paramsObj[jss::ripplerpc];
1537
- if (paramsObj.isMember (jss::id))
1538
- jv[jss::id] = paramsObj[jss::id];
1539
- return jv;
1540
- }
1541
-
1542
1514
// ------------------------------------------------------------------------------
1543
1515
1544
1516
std::pair<int , Json::Value>
1545
1517
rpcClient (
1546
1518
std::vector<std::string> const & args,
1547
1519
Config const & config,
1548
1520
Logs& logs,
1521
+ unsigned int apiVersion,
1549
1522
std::unordered_map<std::string, std::string> const & headers)
1550
1523
{
1551
1524
static_assert (
@@ -1561,7 +1534,8 @@ rpcClient(
1561
1534
try
1562
1535
{
1563
1536
Json::Value jvRpc = Json::Value (Json::objectValue);
1564
- jvRequest = rpcCmdLineToJson (args, jvRpc, logs.journal (" RPCParser" ));
1537
+ jvRequest =
1538
+ rpcCmdToJson (args, jvRpc, apiVersion, logs.journal (" RPCParser" ));
1565
1539
1566
1540
if (jvRequest.isMember (jss::error))
1567
1541
{
@@ -1698,7 +1672,8 @@ fromCommandLine(
1698
1672
const std::vector<std::string>& vCmd,
1699
1673
Logs& logs)
1700
1674
{
1701
- auto const result = rpcClient (vCmd, config, logs);
1675
+ auto const result =
1676
+ rpcClient (vCmd, config, logs, RPC::apiMaximumSupportedVersion);
1702
1677
1703
1678
std::cout << result.second .toStyledString ();
1704
1679
0 commit comments