-
Notifications
You must be signed in to change notification settings - Fork 524
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
Changes from 4 commits
b444052
02ea8e8
1fc389e
315b11d
e6c9260
0f0edbf
6969ce5
487de54
68b334f
a41e90a
a7c4ebe
5f2e36b
920f574
6b84955
7af3bbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
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 { | ||
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. It sounds like all of these are optional
|
||
auth_change: boolean, | ||
fee: string, | ||
fee_level: string, | ||
max_spend_drops: string, | ||
seq: number | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {RippledAmount} 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; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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 { | ||
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. Should also include |
||
account: string; | ||
ledger_current_index?: number; | ||
ledger_index?: number; | ||
marker?: any; | ||
offers?: AccountOffer[]; | ||
} | ||
|
||
export interface AccountOffer { | ||
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. Should also include |
||
flags: number, | ||
taker_gets: RippledAmount, | ||
taker_pays: RippledAmount, | ||
quality: string, | ||
expiration?: number | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {TakerRequestAmount} from '../objects/amounts' | ||
import {OfferCreateTransaction} from '../objects/transactions' | ||
|
||
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: OfferCreateTransaction[]; | ||
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. https://ripple.com/build/rippled-apis/#book-offers
Should this instead be a different interface ( 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. Good catch! Yea I think that's the right way to handle this |
||
ledger_hash?: string; | ||
ledger_current_index?: number; | ||
ledger_index?: number; | ||
marker?: any; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
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; | ||
} |
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' |
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 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
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 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
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. | ||
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. nit: this comment is long for one line (could benefit from being hard wrapped) |
||
*/ | ||
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 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from './accounts' | ||
export * from './adjustments' | ||
export * from './amounts' | ||
export * from './memo' | ||
export * from './signers' | ||
export * from './transactions' | ||
export * from './trustlines' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
export type Memo = { | ||
type?: string, | ||
format?: string, | ||
data?: string | ||
} |
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.