-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose new request interface, implement first few request typings #843
Merged
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b444052
Flesh out that request interface & typings
02ea8e8
add back undocumented authorized properties
1fc389e
standardize on Formatted prefix
315b11d
match existing request default limit of infinity
e6c9260
fix lint errors
0f0edbf
update types, code review
6969ce5
Add test of getTrustlines with multiple pages of results
intelliot 487de54
[fold] Address review comments
intelliot 68b334f
[fold] Return realistic number of items in test
intelliot a41e90a
Merge branch 'add-trustlines-test' into FredKSchott-request-interface
intelliot a7c4ebe
Merge branch 'request-interface' of github.com:FredKSchott/ripple-lib…
intelliot 5f2e36b
clamp properly inside requestAll()
920f574
slice return array to limit
6b84955
Merge branch 'develop' into request-interface
intelliot 7af3bbb
cleanup, handle bad response
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {AccountRoot, SignerList} from '../objects' | ||
|
||
export interface AccountInfoRequest { | ||
account: string, | ||
strict?: boolean, | ||
queue?: boolean, | ||
ledger_hash?: string, | ||
ledger_index?: number | ('validated' | 'closed' | 'current'), | ||
signer_lists?: boolean | ||
} | ||
|
||
export interface AccountInfoResponse { | ||
account_data: AccountRoot, | ||
signer_lists?: SignerList[], | ||
ledger_current_index?: number, | ||
ledger_index?: number, | ||
queue_data?: QueueData, | ||
validated?: boolean | ||
} | ||
|
||
interface QueueData { | ||
txn_count: number, | ||
auth_change_queued?: boolean, | ||
lowest_sequence?: number, | ||
highest_sequence?: number, | ||
max_spend_drops_total?: string, | ||
transactions?: TransactionData[] | ||
} | ||
|
||
interface TransactionData { | ||
auth_change?: boolean, | ||
fee?: string, | ||
fee_level?: string, | ||
max_spend_drops?: string, | ||
seq?: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Trustline} from '../objects' | ||
|
||
export interface AccountLinesRequest { | ||
account: string, | ||
ledger_hash?: string, | ||
ledger_index?: number | ('validated' | 'closed' | 'current'), | ||
peer?: string, | ||
limit?: number, | ||
marker?: any, | ||
} | ||
|
||
export interface AccountLinesResponse { | ||
account: string, | ||
lines: Trustline[], | ||
ledger_current_index?: number, | ||
ledger_index?: number, | ||
ledger_hash?: string, | ||
marker?: any, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {RippledAmount} from '../objects' | ||
|
||
export interface AccountOffersRequest { | ||
account: string, | ||
ledger_hash?: string, | ||
ledger_index?: number | ('validated' | 'closed' | 'current'), | ||
limit?: number, | ||
marker?: any, | ||
} | ||
|
||
export interface AccountOffersResponse { | ||
account: string, | ||
ledger_hash?: string, | ||
ledger_current_index?: number, | ||
ledger_index?: number, | ||
marker?: any, | ||
offers?: AccountOffer[], | ||
} | ||
|
||
export interface AccountOffer { | ||
seq: number, | ||
flags: number, | ||
taker_gets: RippledAmount, | ||
taker_pays: RippledAmount, | ||
quality: string, | ||
expiration?: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
TakerRequestAmount, | ||
OfferCreateTransaction, | ||
RippledAmount | ||
} from '../objects' | ||
|
||
export interface BookOffersRequest { | ||
taker?: string, | ||
taker_gets: TakerRequestAmount, | ||
taker_pays: TakerRequestAmount, | ||
ledger_hash?: string, | ||
ledger_index?: number | ('validated' | 'closed' | 'current'), | ||
limit?: number, | ||
marker?: any | ||
} | ||
|
||
export interface BookOffersResponse { | ||
account: string, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
offers: OrderBookOffer[], | ||
ledger_hash?: string, | ||
ledger_current_index?: number, | ||
ledger_index?: number, | ||
marker?: any | ||
} | ||
|
||
interface OrderBookOffer extends OfferCreateTransaction { | ||
quality?: number | ||
owner_funds?: string, | ||
taker_gets_funded?: RippledAmount, | ||
taker_pays_funded?: RippledAmount | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {Amount} from '../objects' | ||
|
||
|
||
export interface GatewayBalancesRequest { | ||
account: string, | ||
strict?: boolean, | ||
hotwallet: string|Array<string>, | ||
ledger_hash?: string, | ||
ledger_index?: number | ('validated' | 'closed' | 'current') | ||
} | ||
|
||
export interface GatewayBalancesResponse { | ||
account: string, | ||
obligations?: {[currency: string]: string}, | ||
balances?: {[address: string]: Amount[]}, | ||
assets?: {[address: string]: Amount[]}, | ||
ledger_hash?: string, | ||
ledger_current_index?: number, | ||
ledger_index?: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './account_info' | ||
export * from './account_lines' | ||
export * from './account_offers' | ||
export * from './book_offers' | ||
export * from './gateway_balances' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export interface AccountRoot { | ||
LedgerEntryType: string, | ||
Account: string, | ||
Flags: number, | ||
Sequence: number, | ||
Balance: string, | ||
OwnerCount: number, | ||
PreviousTxnID: string, | ||
PreviousTxnLgrSeq: number, | ||
AccountTxnID?: string, | ||
RegularKey?: string, | ||
EmailHash?: string, | ||
MessageKey?: string | ||
TickSize?: number, | ||
TransferRate?: number, | ||
Domain?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Amount} from './amounts' | ||
|
||
export type Adjustment = { | ||
address: string, | ||
amount: Amount, | ||
tag?: number | ||
} | ||
|
||
export type MaxAdjustment = { | ||
address: string, | ||
maxAmount: Amount, | ||
tag?: number | ||
} | ||
|
||
export type MinAdjustment = { | ||
address: string, | ||
minAmount: Amount, | ||
tag?: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export type Amount = { | ||
value: string, | ||
currency: string, | ||
issuer?: string, | ||
counterparty?: string | ||
} | ||
|
||
|
||
export type RippledAmount = string | Amount | ||
|
||
/** | ||
* Specification of which currency the account taking the offer would pay/ | ||
* receive, as an object with currency and issuer fields (omit issuer for XRP). | ||
* Similar to currency amounts. | ||
*/ | ||
export interface TakerRequestAmount { | ||
currency: string | ||
issuer?: string | ||
} | ||
|
||
/** | ||
* A currency-counterparty pair, or just currency if it's XRP. | ||
*/ | ||
export type Issue = { | ||
currency: string, | ||
issuer?: string, | ||
counterparty?: string | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this first check that
singleResult[collectKey]
exists in case the wrong collect key was provided?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, do we have a precedence for rejecting if the response object is malformed?
As long as the API will always return this property for a response I think it's safe to reject if
singleResult[collectKey]
===undefined
. But if that's not a safe assumption maybe we just stop collecting and return the responses collected so far. What do you guys think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure - I think either way should be fine, since this shouldn't actually happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at some of the existing parse functions in
src/ledger/parse/
, we seem to be in the habit of not rejecting if the response object is malformed.https://github.com/ripple/ripple-lib/blob/e311b74dac0a90e7a83b9126f0d64840a395e789/src/ledger/parse/payment-channel.ts#L46-L61
So I'd vote for returning the collected responses.