Defines TypeScript types for all ledger objects (#1499)

* offer

* accountroot

* amendments

* check

* deposit preauth

* directory node

* escrow

* fee settings

* ledger hashes

* negative unl

* pay channel

* ripple state

* signer list

* ticket

* export

* respond to comments

* rename files to camelCase
This commit is contained in:
Mayukha Vadari
2021-08-09 09:54:56 -07:00
parent 6e4868e6c7
commit 0886af33fd
17 changed files with 283 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
export type LedgerIndex = number | ('validated' | 'closed' | 'current')
export type AccountObjectType = 'check' | 'escrow' | 'offer' | 'payment_channel' | 'signer_list' | 'state'
export interface XRP {
currency: "XRP"
}
export interface IssuedCurrency {
currency: string
issuer: string
}
export type Currency = IssuedCurrency | XRP
export interface IssuedCurrencyAmount extends IssuedCurrency {
value: string
}
export type Amount = IssuedCurrencyAmount | string

View File

@@ -0,0 +1,20 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
export interface AccountRoot extends BaseLedgerEntry{
LedgerEntryType: 'AccountRoot'
Account: string
Balance: string
Flags: number
OwnerCount: number
PreviousTxnID: string
PreviousTxnLgrSeq: number
Sequence: number
AccountTxnID?: string
Domain?: string
EmailHash?: string
MessageKey?: string
RegularKey?: string
TicketCount?: number
TickSize?: number
TransferRate?: number
}

View File

@@ -0,0 +1,15 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
interface Majority {
Majority: {
Amendment: string
CloseTime: number
}
}
export interface Amendments extends BaseLedgerEntry {
LedgerEntryType: 'Amendments'
Amendments?: string[]
Majorities?: Majority[]
Flags: 0
}

View File

@@ -0,0 +1,3 @@
export interface BaseLedgerEntry {
index: string
}

View File

@@ -0,0 +1,19 @@
import { Amount } from "../common";
import { BaseLedgerEntry } from "./baseLedgerEntry";
export interface Check extends BaseLedgerEntry {
LedgerEntryType: 'Check'
Account: string
Destination: string
Flags: 0
OwnerNode: string
PreviousTxnID: string
PreviousTxnLgrSeq: number
SendMax: Amount
Sequence: number
DestinationNode?: string
DestinationTag?: number
Expiration?: number
InvoiceID?: string
SourceTag?: number
}

View File

@@ -0,0 +1,11 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
export interface DepositPreauth extends BaseLedgerEntry {
LedgerEntryType: 'DepositPreauth'
Account: string
Authorize: string
Flags: 0
OwnerNode: string
PreviousTxnID: string
PreviousTxnLgrSeq: number
}

View File

@@ -0,0 +1,15 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
export interface DirectoryNode extends BaseLedgerEntry {
LedgerEntryType: 'DirectoryNode'
Flags: number
RootIndex: string
Indexes: string[]
IndexNext?: number
IndexPrevious?: number
Owner?: string
TakerPaysCurrency?: string
TakerPaysIssuer?: string
TakerGetsCurrency?: string
TakerGetsIssuer?: string
}

View File

@@ -0,0 +1,18 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
export interface Escrow extends BaseLedgerEntry {
LedgerEntryType: 'Escrow'
Account: string
Destination: string
Amount: string
Condition?: string
CancelAfter?: number
FinishAfter?: number
Flags: number
SourceTag?: number
DestinationTag?: number
OwnerNode: string
DestinationNode?: string
PreviousTxnID: string
PreviousTxnLgrSeq: number
}

View File

@@ -0,0 +1,10 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
export interface FeeSettings extends BaseLedgerEntry {
LedgerEntryType: 'FeeSettings'
BaseFee: string
ReferenceFeeUnits: number
ReserveBase: number
ReserveIncrement: number
Flags: number
}

View File

@@ -0,0 +1,46 @@
import { AccountRoot } from "./accountRoot";
import { Amendments } from "./amendments";
import { Check } from "./check";
import { DepositPreauth } from "./depositPreauth";
import { DirectoryNode } from "./directoryNode";
import { Escrow } from "./escrow";
import { FeeSettings } from "./feeSettings";
import { LedgerHashes } from "./ledgerHashes";
import { NegativeUNL } from "./negativeUNL";
import { Offer } from "./offer";
import { PayChannel } from "./payChannel";
import { RippleState } from "./rippleState";
import { SignerList } from "./signerList";
import { Ticket } from "./ticket";
export type LedgerEntry = AccountRoot
| Amendments
| Check
| DepositPreauth
| DirectoryNode
| Escrow
| FeeSettings
| LedgerHashes
| NegativeUNL
| Offer
| PayChannel
| RippleState
| SignerList
| Ticket
export {
AccountRoot,
Amendments,
Check,
DepositPreauth,
DirectoryNode,
Escrow,
FeeSettings,
LedgerHashes,
NegativeUNL,
Offer,
PayChannel,
RippleState,
SignerList,
Ticket
}

View File

@@ -0,0 +1,8 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
export interface LedgerHashes extends BaseLedgerEntry {
LedgerEntryType: 'LedgerHashes'
LastLedgerSequence?: number
Hashes: string[]
Flags: number
}

View File

@@ -0,0 +1,13 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
interface DisabledValidator {
FirstLedgerSequence: number
PublicKey: string
}
export interface NegativeUNL extends BaseLedgerEntry {
LedgerEntryType: "NegativeUNL"
DisabledValidators?: DisabledValidator[]
ValidatorToDisable?: string
ValidatorToReEnable?: string
}

View File

@@ -0,0 +1,17 @@
import { Amount } from "../common";
import { BaseLedgerEntry } from "./baseLedgerEntry";
export interface Offer extends BaseLedgerEntry {
LedgerEntryType: 'Offer'
Flags: number
Account: string
Sequence: number
TakerPays: Amount
TakerGets: Amount
BookDirectory: string
BookNode: string
OwnerNode: string
PreviousTxnID: string
PreviousTxnLgrSeq: number
Expiration?: number
}

View File

@@ -0,0 +1,20 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
export interface PayChannel extends BaseLedgerEntry {
LedgerEntryType: 'PayChannel'
Account: string
Destination: string
Amount: string
Balance: string
PublicKey: string
SettleDelay: number
OwnerNode: string
PreviousTxnID: string
PreviousTxnLgrSeq: number
Flags: number
Expiration?: number
CancelAfter?: number
SourceTag?: number
DestinationTag?: number
DestinationNode?: string
}

View File

@@ -0,0 +1,18 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
import { IssuedCurrencyAmount } from "../common";
export interface RippleState extends BaseLedgerEntry {
LedgerEntryType: 'RippleState'
Flags: number
Balance: IssuedCurrencyAmount
LowLimit: IssuedCurrencyAmount
HighLimit: IssuedCurrencyAmount
PreviousTxnID: string
PreviousTxnLgrSeq: number
LowNode?: string
HighNode?: string
LowQualityIn?: number
LowQualityOut?: number
HighQualityIn?: number
HighQualityOut?: number
}

View File

@@ -0,0 +1,19 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
interface SignerEntry {
SignerEntry: {
Account: string
SignerWeight: number
}
}
export interface SignerList extends BaseLedgerEntry {
LedgerEntryType: 'SignerList'
Flags: number
PreviousTxnID: string
PreviousTxnLgrSeq: number
OwnerNode: string
SignerEntries: SignerEntry[]
SignerListID: number
SignerQuorum: number
}

View File

@@ -0,0 +1,11 @@
import { BaseLedgerEntry } from "./baseLedgerEntry";
export interface Ticket extends BaseLedgerEntry {
LedgerEntryType: "Ticket"
Account: string
Flags: number
OwnerNode: string
PreviousTxnID: string
PreviousTxnLgrSeq: number
TicketSequence: number
}