steemit / steem-js

Steem.js the official JavaScript library for Steem blockchain
https://www.npmjs.com/package/steem
MIT License
472 stars 225 forks source link

Changes to steemd jsonrpc format #385

Open youkaicountry opened 6 years ago

youkaicountry commented 6 years ago

From issue 2486 in steem by @j4ys0n:

The call:

  steem.api.getAccounts(['dlive'], (err, result) => {
      if (err) {
        res.send(err);
      } else {
        res.send(result);
      }
    });

returns:

{
    "name": "RPCError",
    "code": -32002,
    "data": {
        "code": 10,
        "name": "assert_exception",
        "message": "Assert Exception",
        "stack": [
            {
                "context": {
                    "level": "error",
                    "file": "json_rpc_plugin.cpp",
                    "line": 206,
                    "method": "find_api_method",
                    "hostname": "",
                    "timestamp": "2018-05-22T16:10:03"
                },
                "format": "method_itr != api_itr->second.end(): Could not find method ${method}",
                "data": {
                    "method": "get_accounts"
                }
            }
        ]
    }
}

Console output: 2618763ms json_rpc_plugin.cpp:331 rpc ] message: {"id":0,"jsonrpc":"2.0","method":"call","params":["database_api","get_accounts",[["dlive"]]]}

The reason is that steemd master has changes to the jsonrpc format.

The correct jsonrpc calls are either:

{"id":0,"jsonrpc":"2.0","method":"call","params":["condenser_api","get_accounts",[["dlive"]]]}

or

{"id":0,"jsonrpc":"2.0","method":"database_api.find_accounts", "params":{"accounts":["dlive"]}}

The first is a compatibility layer with our old format. The second is the newer format.

j4ys0n commented 6 years ago

Will this be fixed soon?