XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.2k stars 511 forks source link

getOrderbook doesn't return all the book's info #799

Closed tuloski closed 6 years ago

tuloski commented 6 years ago

Some fields returned by rippled are not returned by api.getOrderbook(). For example the "owner_funds" field which is fundamental to build autobridged books and the "flags" field.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/49634790-getorderbook-doesn-t-return-all-the-book-s-info?utm_campaign=plugin&utm_content=tracker%2F323756&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F323756&utm_medium=issues&utm_source=github).
FredKSchott commented 6 years ago

Happy to take a stab at this with some direction. Mainly, where should this info live? Right now the object has format {specification, properties, state}, state feels like the best place to add.

Bigger picture, its a lot of extra work to create a separate data format for ripple-lib that's entirely different from the Ripple API, and the fact that its a smaller subset introduces bugs like this. Would you consider a format like this?

{
    "direction": "buy",
    "passive": true,
    "expirationTime": "1234567890",
    "makerExchangeRate": "365.9629780181032",
    "data": { /* Raw API Response Object */ }
}

Useful helper properties are still added but all API data is returned to the consumer (/w maybe some light formatting directly to taker_gets_funded/taker_pays_funded so that they expand strings to full objects). That way consumers don't need to learn a second less-documented API.

intelliot commented 6 years ago

@FredKSchott I'm in favor of returning all API data to the consumer, as you said. Historically, RippleAPI was designed independent of rippled. However, moving forward, we'd like to unify their APIs and make them as similar as possible. Please feel free to take a stab at this!

FredKSchott commented 6 years ago

Sounds good, I'll take a stab.

tuloski commented 6 years ago

Yeah, I don't get why RippleAPI returns different structures from rippled. But if you change again you are gonna be hated by all developers (me included) :) .

FredKSchott commented 6 years ago

See #812, current proposal is additive, does not modify or break current interface.