-
Notifications
You must be signed in to change notification settings - Fork 523
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
Defines TypeScript types for rippled account method requests & responses #1498
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
912bb97
offer
mvadari da51f26
accountroot
mvadari 2c2339d
amendments
mvadari df0bc93
check
mvadari f18038f
deposit preauth
mvadari b1b9851
directory node
mvadari 5071cbe
escrow
mvadari 0af06f4
fee settings
mvadari 06aecbf
ledger hashes
mvadari 3bf2bec
negative unl
mvadari bfa9fe2
pay channel
mvadari c25bbf9
ripple state
mvadari bb8b283
signer list
mvadari 0389ff6
ticket
mvadari 72c13a2
export
mvadari 8373430
respond to comments
mvadari 4e2ff67
rename files to camelCase
mvadari 0e7e267
account_channels
mvadari 804898f
account_currencies
mvadari 9ba5ea1
account_info
mvadari d1e29a8
account_lines
mvadari 66b72f7
account_objects
mvadari 636ec0d
account_offers
mvadari 945bfe4
account_tx
mvadari ab0643f
gateway_balances
mvadari 0100700
no ripple check
mvadari 8549ae0
respond to comments
mvadari 31c3066
export methods
mvadari 540068f
fix typos
mvadari c7261dc
respond to comments
mvadari 1b9ab29
Merge branch '2.0' into mv/account-methods
mvadari 053339f
edit BaseResponse to be more specific
mvadari 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 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,38 @@ | ||
import { Amount } from "."; | ||
|
||
interface CreatedNode { | ||
CreatedNode: { | ||
LedgerEntryType: string | ||
LedgerIndex: string | ||
NewFields: {[field: string]: any} | ||
} | ||
} | ||
|
||
interface ModifiedNode { | ||
ModifiedNode: { | ||
LedgerEntryType: string | ||
LedgerIndex: string | ||
FinalFields: {[field: string]: any} | ||
PreviousFields: {[field: string]: any} | ||
PreviousTxnID?: string | ||
PreviouTxnLgrSeq?: number | ||
} | ||
} | ||
|
||
interface DeletedNode { | ||
DeletedNode: { | ||
LedgerEntryType: string | ||
LedgerIndex: string | ||
FinalFields: {[field: string]: any} | ||
} | ||
} | ||
|
||
type Node = CreatedNode | ModifiedNode | DeletedNode | ||
|
||
export interface TransactionMetadata { | ||
AffectedNodes: Node[] | ||
DeliveredAmount?: Amount | ||
delivered_amount?: Amount | ||
TransactionIndex: number | ||
TransactionResult: 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 |
---|---|---|
|
@@ -43,4 +43,4 @@ export { | |
RippleState, | ||
SignerList, | ||
Ticket | ||
} | ||
} |
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,39 @@ | ||
import { BaseRequest, BaseResponse } from './baseMethod' | ||
import { LedgerIndex } from "../common" | ||
|
||
interface Channel { | ||
account: string | ||
amount: string | ||
balance: string | ||
channel_id: string | ||
destination_account: string | ||
settle_delay: number | ||
public_key?: string | ||
public_key_hex?: string | ||
expiration?: number | ||
cancel_after?: number | ||
source_tab?: number | ||
destination_tag?: number | ||
} | ||
|
||
export interface AccountChannelsRequest extends BaseRequest { | ||
command: "account_channels" | ||
account: string | ||
destination_account?: string | ||
ledger_hash?: string | ||
ledger_index?: LedgerIndex | ||
limit: number | ||
marker: any | ||
} | ||
|
||
export interface AccountChannelsResponse extends BaseResponse { | ||
result: { | ||
account: string | ||
channels: Channel[] | ||
ledger_hash: string | ||
ledger_index: number | ||
validated?: boolean | ||
limit?: number | ||
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,21 @@ | ||
import { BaseRequest, BaseResponse } from './baseMethod' | ||
import { LedgerIndex } from "../common" | ||
|
||
export interface AccountCurrenciesRequest extends BaseRequest { | ||
command: "account_currencies" | ||
account: string | ||
destination_account?: string | ||
ledger_hash?: string | ||
ledger_index?: LedgerIndex | ||
strict?: boolean | ||
} | ||
|
||
export interface AccountCurrenciesResponse extends BaseResponse { | ||
result: { | ||
ledger_hash?: string | ||
ledger_index: number | ||
receive_currencies: string[] | ||
send_currencies: string[] | ||
validated: boolean | ||
} | ||
} |
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,41 @@ | ||
import { BaseRequest, BaseResponse } from './baseMethod' | ||
import { LedgerIndex } from "../common" | ||
import { AccountRoot, SignerList } from "../ledger" | ||
|
||
export interface AccountInfoRequest extends BaseRequest { | ||
command: "account_info" | ||
account: string | ||
ledger_hash?: string | ||
ledger_index?: LedgerIndex | ||
queue?: boolean | ||
signer_lists?: boolean | ||
strict?: boolean | ||
} | ||
|
||
export interface QueueTransaction { | ||
auth_change: boolean | ||
fee: string | ||
fee_level: string | ||
max_spend_drops: string | ||
seq: number | ||
} | ||
|
||
export interface QueueData { | ||
txn_count: number | ||
auth_change_queued?: boolean | ||
lowest_sequence?: number | ||
highest_sequence?: number | ||
max_spend_drops_total?: string | ||
transactions?: QueueTransaction[] | ||
} | ||
|
||
export interface AccountInfoResponse extends BaseResponse { | ||
result: { | ||
account_data: AccountRoot | ||
signer_lists?: SignerList[] | ||
ledger_current_index?: number | ||
ledger_index?: number | ||
queue_data?: QueueData | ||
validated?: boolean | ||
} | ||
} |
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,39 @@ | ||
import { BaseRequest, BaseResponse } from './baseMethod' | ||
import { LedgerIndex } from "../common" | ||
|
||
interface Trustline { | ||
account: string | ||
balance: string | ||
currency: string | ||
limit: string | ||
limit_peer: string | ||
quality_in: number | ||
quality_out: number | ||
no_ripple?: boolean | ||
no_ripple_peer?: boolean | ||
authorized?: boolean | ||
peer_authorized?: boolean | ||
freeze?: boolean | ||
freeze_peer?: boolean | ||
} | ||
|
||
export interface AccountLinesRequest extends BaseRequest { | ||
command: "account_lines" | ||
account: string | ||
ledger_hash?: string | ||
ledger_index?: LedgerIndex | ||
peer?: string | ||
limit?: number | ||
marker?: any | ||
} | ||
|
||
export interface AccountLinesResponse extends BaseResponse { | ||
result: { | ||
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,29 @@ | ||
import { BaseRequest, BaseResponse } from './baseMethod' | ||
import { AccountObjectType, LedgerIndex } from "../common" | ||
import { Check, DepositPreauth, Escrow, Offer, PayChannel, RippleState, SignerList, Ticket } from "../ledger" | ||
|
||
export interface AccountObjectsRequest extends BaseRequest { | ||
command: "account_objects" | ||
account: string | ||
type?: AccountObjectType | ||
deletion_blockers_only?: boolean | ||
ledger_hash?: string | ||
ledger_index?: LedgerIndex | ||
limit?: number | ||
marker?: any | ||
} | ||
|
||
type AccountObject = Check | DepositPreauth | Escrow | Offer | PayChannel | SignerList | Ticket | RippleState | ||
|
||
export interface AccountObjectsResponse extends BaseResponse { | ||
result: { | ||
account: string | ||
account_objects: AccountObject[] | ||
ledger_hash?: string | ||
ledger_index?: number | ||
ledger_current_index?: number | ||
limit?: number | ||
marker?: string | ||
validated?: boolean | ||
} | ||
} |
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,32 @@ | ||
import { Amount, LedgerIndex } from "../common"; | ||
import { BaseRequest, BaseResponse } from "./baseMethod"; | ||
|
||
export interface AccountOffersRequest extends BaseRequest { | ||
command: "account_offers" | ||
account: string | ||
ledger_hash?: string | ||
ledger_index?: LedgerIndex | ||
limit?: number | ||
marker?: any | ||
strict?: boolean | ||
} | ||
|
||
interface AccountOffer { | ||
flags: number | ||
seq: number | ||
taker_gets: Amount | ||
taker_pays: Amount | ||
quality: string | ||
expiration?: number | ||
} | ||
|
||
export interface AccountOffersResponse extends BaseResponse { | ||
result: { | ||
account: string | ||
offers?: AccountOffer[] | ||
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,36 @@ | ||
import { LedgerIndex } from "../common"; | ||
import { TransactionMetadata } from "../common/transaction"; | ||
import { BaseRequest, BaseResponse } from "./baseMethod"; | ||
|
||
export interface AccountTxRequest extends BaseRequest { | ||
command: "account_tx" | ||
account: string | ||
ledger_index_min?: number | ||
ledger_index_max?: number | ||
ledger_hash?: string | ||
ledger_index?: LedgerIndex | ||
binary?: boolean | ||
forward?: boolean | ||
limit?: number | ||
marker?: any | ||
} | ||
|
||
interface AccountTransaction { | ||
ledger_index: number | ||
meta: string | TransactionMetadata | ||
tx?: any // TODO: replace when transaction objects are done | ||
tx_blob?: string | ||
validated: boolean | ||
} | ||
|
||
export interface AccountTxResponse extends BaseResponse { | ||
result: { | ||
account: string | ||
ledger_index_min: number | ||
ledger_index_max: number | ||
limit: number | ||
marker?: any | ||
transactions: AccountTransaction[] | ||
validated?: boolean | ||
} | ||
} |
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,26 @@ | ||
import { Response } from "."; | ||
|
||
export interface BaseRequest { | ||
id: number | string | ||
command: string | ||
api_version?: number | ||
} | ||
|
||
interface Warning { | ||
id: number | ||
message: string | ||
details?: {[key: string]: string} | ||
} | ||
|
||
export interface BaseResponse { | ||
id: number | string | ||
status: "success" | "error" | string | ||
type: "response" | string | ||
result: any | ||
warning?: "load" | ||
warnings?: Warning[] | ||
forwarded?: boolean | ||
error?: string | ||
request?: Response | ||
api_version?: 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 @@ | ||
import { LedgerIndex } from '../common' | ||
import { BaseRequest, BaseResponse } from './baseMethod'; | ||
|
||
export interface GatewayBalancesRequest extends BaseRequest { | ||
command: "gateway_balances" | ||
account: string | ||
strict?: boolean | ||
hotwallet: string | string[] | ||
ledger_hash?: string | ||
ledger_index?: LedgerIndex | ||
} | ||
|
||
interface Balance { | ||
currency: string | ||
value: string | ||
} | ||
|
||
export interface GatewayBalancesResponse extends BaseResponse { | ||
result: { | ||
account: string | ||
obligations?: {[currency: string]: string} | ||
balances?: {[address: string]: Balance[]} | ||
assets?: {[address: string]: Balance[]} | ||
ledger_hash?: string | ||
ledger_current_index?: number | ||
ledger_index?: number | ||
} | ||
} |
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.
Is there any way we can narrow this from
{[field: string]: any
? Does this come in the form of aLedgerEntry
that we can use to replaceany
here?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.
You could in theory narrow it, but as far as I understand, it's a subset of
LedgerEntry
fields, and isn't necessarily a fullLedgerEntry
object. I suppose this is another question for @intelliotThere 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.
This is probably any (modifiable) fields in any ledger object, so I believe there are a lot of possibilities, and it'll expand in the future as more kinds of ledger objects are added in the future. I would fine with leaving this as-is, but of course, if we want to make this more specific in the future, that would be fine as well.