Remove old types (#1630)

* Remove transaction/types

* Delete common/types/commands

* Delete common/types
This commit is contained in:
Jackson Mills
2021-09-21 09:08:56 -07:00
committed by Mayukha Vadari
parent 6fac420d9f
commit 94a8c65200
28 changed files with 2 additions and 849 deletions

View File

@@ -1,23 +0,0 @@
import {
AccountRootLedgerEntry,
SignerListLedgerEntry,
QueueData,
} 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: AccountRootLedgerEntry
signer_lists?: SignerListLedgerEntry[]
ledger_current_index?: number
ledger_index?: number
queue_data?: QueueData
validated?: boolean
}

View File

@@ -1,19 +0,0 @@
import { Trustline } from '../objects'
export interface AccountLinesRequest {
account: string
ledger_hash?: string
ledger_index?: number | ('validated' | 'closed' | 'current')
peer?: string
limit?: number
marker?: unknown
}
export interface AccountLinesResponse {
account: string
lines: Trustline[]
ledger_current_index?: number
ledger_index?: number
ledger_hash?: string
marker?: unknown
}

View File

@@ -1,85 +0,0 @@
import { AccountObjectType } from '../../../models/common'
import {
CheckLedgerEntry,
RippleStateLedgerEntry,
OfferLedgerEntry,
SignerListLedgerEntry,
EscrowLedgerEntry,
PayChannelLedgerEntry,
DepositPreauthLedgerEntry,
} from '../objects'
export interface GetAccountObjectsOptions {
type?: AccountObjectType
ledgerHash?: string
ledgerIndex?: number | ('validated' | 'closed' | 'current')
limit?: number
marker?: string
}
export interface AccountObjectsRequest {
account: string
// (Optional) Filter results to include only this type of ledger object.
type?:
| string
| (
| 'check'
| 'escrow'
| 'offer'
| 'payment_channel'
| 'signer_list'
| 'state'
)
// (Optional) A 20-byte hex string for the ledger version to use.
ledger_hash?: string
// (Optional) The sequence number of the ledger to use,
// or a shortcut string to choose a ledger automatically.
ledger_index?: number | ('validated' | 'closed' | 'current')
limit?: number
marker?: string
}
export interface AccountObjectsResponse {
account: string
// Array of objects owned by this account.
// from the getAccountObjects section of the dev center
account_objects: Array<
| CheckLedgerEntry
| RippleStateLedgerEntry
| OfferLedgerEntry
| SignerListLedgerEntry
| EscrowLedgerEntry
| PayChannelLedgerEntry
| DepositPreauthLedgerEntry
>
// (May be omitted) The identifying hash of the ledger
// that was used to generate this response.
ledger_hash?: string
// (May be omitted) The sequence number of the ledger version
// that was used to generate this response.
ledger_index?: number
// (May be omitted) The sequence number of the current in-progress ledger
// version that was used to generate this response.
ledger_current_index?: number
// The limit that was used in this request, if any.
limit?: number
// Server-defined value indicating the response is paginated. Pass this
// to the next call to resume where this call left off. Omitted when there
// are no additional pages after this one.
marker?: string
// If true, this information comes from a ledger version
// that has been validated by consensus.
validated?: boolean
}

View File

@@ -1,27 +0,0 @@
import { RippledAmount } from '../objects'
export interface AccountOffersRequest {
account: string
ledger_hash?: string
ledger_index?: number | ('validated' | 'closed' | 'current')
limit?: number
marker?: unknown
}
export interface AccountOffersResponse {
account: string
ledger_hash?: string
ledger_current_index?: number
ledger_index?: number
marker?: unknown
offers?: AccountOffer[]
}
export interface AccountOffer {
seq: number
flags: number
taker_gets: RippledAmount
taker_pays: RippledAmount
quality: string
expiration?: number
}

View File

@@ -1,26 +0,0 @@
import { TakerRequestAmount, RippledAmount, OfferLedgerEntry } 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?: unknown
}
export interface BookOffersResponse {
offers: BookOffer[]
ledger_hash?: string
ledger_current_index?: number
ledger_index?: number
marker?: unknown
}
export interface BookOffer extends OfferLedgerEntry {
quality?: string
owner_funds?: string
taker_gets_funded?: RippledAmount
taker_pays_funded?: RippledAmount
}

View File

@@ -1,19 +0,0 @@
import { Amount } from '../objects'
export interface GatewayBalancesRequest {
account: string
strict?: boolean
hotwallet: string | 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
}

View File

@@ -1,10 +0,0 @@
export * from './account_info'
export * from './account_lines'
export * from './account_objects'
export * from './account_offers'
export * from './book_offers'
export * from './gateway_balances'
export * from './ledger'
export * from './ledger_data'
export * from './ledger_entry'
export * from './server_info'

View File

@@ -1,20 +0,0 @@
import { Ledger, QueueData } from '../objects'
export interface LedgerRequest {
ledger_hash?: string
ledger_index?: number | ('validated' | 'closed' | 'current')
full?: boolean
accounts?: boolean
transactions?: boolean
expand?: boolean
owner_funds?: boolean
binary?: boolean
queue?: boolean
}
export interface LedgerResponse {
ledger_index: number
ledger_hash: string
ledger: Ledger
queue_data?: QueueData
}

View File

@@ -1,12 +0,0 @@
import { LedgerData } from '../objects'
export interface LedgerDataRequest {
id?: any
ledger_hash?: string
ledger_index?: string
binary?: boolean
limit?: number
marker?: string
}
export type LedgerDataResponse = LedgerData

View File

@@ -1,36 +0,0 @@
import { LedgerEntry } from '../objects'
export interface LedgerEntryRequest {
ledger_hash?: string
ledger_index?: number | ('validated' | 'closed' | 'current')
index?: string
account_root?: string
directory?:
| string
| {
sub_index?: number
dir_root: string
}
| {
sub_index?: number
owner: string
}
offer?:
| string
| {
account: string
seq: number
}
ripple_state?: {
accounts: [string, string]
currency: string
}
binary?: boolean
}
export interface LedgerEntryResponse {
index: string
ledger_index: number
node_binary?: string
node?: LedgerEntry
}

View File

@@ -1,51 +0,0 @@
export interface ServerInfoRequest {
id?: number
}
export interface ServerInfoResponse {
info: {
amendment_blocked?: boolean
build_version: string
closed_ledger?: LedgerInfo
complete_ledgers: string
hostid: string
io_latency_ms: number
last_close: {
converge_time_s: number
proposers: number
}
load?: {
job_types: Array<{
job_type: string
per_second: number
in_progress: number
}>
threads: number
}
load_factor: number
load_factor_local?: number
load_factor_net?: number
load_factor_cluster?: number
load_factor_fee_escalation?: number
load_factor_fee_queue?: number
load_factor_server?: number
peers: number
pubkey_node: string
pubkey_validator: string
server_state: string
state_accounting: any
uptime: number
validated_ledger?: LedgerInfo
validation_quorum: number
validator_list_expires: string
}
}
export interface LedgerInfo {
age: number
base_fee_xrp: number
hash: string
reserve_base_xrp: number
reserve_inc_xrp: number
seq: number
}

View File

@@ -1,19 +0,0 @@
import { Amount } from './amounts'
export interface Adjustment {
address: string
amount: Amount
tag?: number
}
export interface MaxAdjustment {
address: string
maxAmount: Amount
tag?: number
}
export interface MinAdjustment {
address: string
minAmount: Amount
tag?: number
}

View File

@@ -1,24 +0,0 @@
export interface Amount extends Issue {
value: 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 interface Issue {
currency: string
issuer?: string
counterparty?: string
}

View File

@@ -1,12 +0,0 @@
export * from './adjustments'
export * from './amounts'
export * from './ledger'
export * from './ledger_data'
export * from './ledger_entries'
export * from './memos'
export * from './orders'
export * from './queue_data'
export * from './settings'
export * from './signers'
export * from './transactions'
export * from './trustlines'

View File

@@ -1,31 +0,0 @@
export interface Ledger {
account_hash: string
close_time: number
close_time_human: string
close_time_resolution: number
closed: boolean
ledger_hash: string
ledger_index: string
parent_hash: string
total_coins: string
transaction_hash: string
transactions: string[] | object[]
close_flags?: number
parent_close_time?: number
accountState?: any[]
validated?: boolean
}
// https://xrpl.org/subscribe.html#ledger-stream
export interface LedgerClosedEvent {
type: 'ledgerClosed'
fee_base: number
fee_ref: number
ledger_hash: string
ledger_index: number
ledger_time: number
reserve_base: number
reserve_inc: number
txn_count: number
validated_ledgers: string
}

View File

@@ -1,6 +0,0 @@
export interface LedgerData {
ledger_index: string
ledger_hash: string
marker: string
state: Array<{ data?: string; LedgerEntryType?: string; index: string } & any>
}

View File

@@ -1,191 +0,0 @@
import { Amount, RippledAmount } from './amounts'
import { SignerEntry } from './index'
export interface AccountRootLedgerEntry {
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
TickSize?: number
TransferRate?: number
WalletLocator?: string
WalletSize?: number // DEPRECATED
}
export interface AmendmentsLedgerEntry {
LedgerEntryType: 'Amendments'
Amendments?: string[]
Majorities?: any[]
Flags: 0
}
export interface CheckLedgerEntry {
LedgerEntryType: 'Check'
Account: string
Destination
string
Flags: 0
OwnerNode: string
PreviousTxnID: string
PreviousTxnLgrSeq: number
SendMax: string | object
Sequence: number
DestinationNode: string
DestinationTag: number
Expiration: number
InvoiceID: string
SourceTag: number
}
export interface DepositPreauthLedgerEntry {
LedgerEntryType: 'DepositPreauth'
Account: string
Authorize: string
OwnerNode: string
PreviousTxnID: string
PreviousTxnLgrSeq: number
}
export interface DirectoryNodeLedgerEntry {
LedgerEntryType: 'DirectoryNode'
Flags: number
RootIndex: string
Indexes: string[]
IndexNext?: number
IndexPrevious?: number
}
export interface OfferDirectoryNodeLedgerEntry
extends DirectoryNodeLedgerEntry {
TakerPaysCurrency: string
TakerPaysIssuer: string
TakerGetsCurrency: string
TakerGetsIssuer: string
ExchangeRate?: number // DEPRECATED
}
export interface OwnerDirectoryNodeLedgerEntry
extends DirectoryNodeLedgerEntry {
Owner: string
}
export interface EscrowLedgerEntry {
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
}
export interface FeeSettingsLedgerEntry {
LedgerEntryType: 'FeeSettings'
BaseFee: string
ReferenceFeeUnits: number
ReserveBase: number
ReserveIncrement: number
Flags: number
}
export interface LedgerHashesLedgerEntry {
LedgerEntryType: 'LedgerHashes'
Hashes: string[]
Flags: number
FirstLedgerSequence?: number // DEPRECATED
LastLedgerSequence?: number
}
export interface OfferLedgerEntry {
LedgerEntryType: 'Offer'
Flags: number
Account: string
Sequence: number
TakerPays: RippledAmount
TakerGets: RippledAmount
BookDirectory: string
BookNode: string
OwnerNode: string
PreviousTxnID: string
PreviousTxnLgrSeq: number
Expiration?: number
}
export interface PayChannelLedgerEntry {
LedgerEntryType: 'PayChannel'
Sequence: number
Account: string
Amount: string
Balance: string
PublicKey: string
Destination: string
SettleDelay: number
Expiration?: number
CancelAfter?: number
SourceTag?: number
DestinationTag?: number
OwnerNode: string
PreviousTxnID: string
PreviousTxnLgrSeq: number
index: string
}
export interface RippleStateLedgerEntry {
LedgerEntryType: 'RippleState'
Flags: number
Balance: Amount
LowLimit: Amount
HighLimit: Amount
PreviousTxnID: string
PreviousTxnLgrSeq: number
LowNode?: string
HighNode?: string
LowQualityIn?: number
LowQualityOut?: number
HighQualityIn?: number
HighQualityOut?: number
}
export interface SignerListLedgerEntry {
LedgerEntryType: 'SignerList'
OwnerNode: string
SignerQuorum: number
SignerEntries: SignerEntry[]
SignerListID: number
PreviousTxnID: string
PreviousTxnLgrSeq: number
}
// see https://ripple.com/build/ledger-format/#ledger-object-types
export type LedgerEntry =
| AccountRootLedgerEntry
| AmendmentsLedgerEntry
| CheckLedgerEntry
| DepositPreauthLedgerEntry
| DirectoryNodeLedgerEntry
| OfferDirectoryNodeLedgerEntry
| OwnerDirectoryNodeLedgerEntry
| EscrowLedgerEntry
| FeeSettingsLedgerEntry
| LedgerHashesLedgerEntry
| OfferLedgerEntry
| PayChannelLedgerEntry
| RippleStateLedgerEntry
| SignerListLedgerEntry

View File

@@ -1,5 +0,0 @@
export interface Memo {
type?: string
format?: string
data?: string
}

View File

@@ -1,17 +0,0 @@
import { Amount } from './amounts'
import { Memo } from './memos'
export interface FormattedOrderSpecification {
direction: string
quantity: Amount
totalPrice: Amount
immediateOrCancel?: boolean
fillOrKill?: boolean
expirationTime?: string
orderToReplace?: number
memos?: Memo[]
// If enabled, the offer will not consume offers that exactly match it, and
// instead becomes an Offer node in the ledger. It will still consume offers
// that cross it.
passive?: boolean
}

View File

@@ -1,16 +0,0 @@
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[]
}

View File

@@ -1,33 +0,0 @@
import { Memo } from './memos'
export interface WeightedSigner {
address: string
weight: number
}
export interface Signers {
threshold?: number
weights: WeightedSigner[]
}
export interface FormattedSettings {
defaultRipple?: boolean
depositAuth?: boolean
disableMasterKey?: boolean
disallowIncomingXRP?: boolean
domain?: string
emailHash?: string | null
walletLocator?: string | null
enableTransactionIDTracking?: boolean
globalFreeze?: boolean
memos?: Memo[]
messageKey?: string
noFreeze?: boolean
passwordSpent?: boolean
regularKey?: string
requireAuthorization?: boolean
requireDestinationTag?: boolean
signers?: Signers
transferRate?: number | null
tickSize?: number
}

View File

@@ -1,6 +0,0 @@
export interface SignerEntry {
SignerEntry: {
Account: string
SignerWeight: number
}
}

View File

@@ -1,29 +0,0 @@
import { Signer } from '../../../models/common'
import { RippledAmount } from './amounts'
import { Memo } from './memos'
export interface OfferCreateTransaction {
TransactionType: 'OfferCreate'
Account: string
AccountTxnID?: string
Fee: string
Field: any
Flags: number
LastLedgerSequence?: number
Sequence: number
Signers: Signer[]
SigningPubKey: string
SourceTag?: number
TakerGets: RippledAmount
TakerPays: RippledAmount
TxnSignature: string
Expiration?: number
Memos?: Memo[]
OfferSequence?: number
}
export interface SignedTransaction {
signedTransaction: string
id: string
}

View File

@@ -1,42 +0,0 @@
import { Memo } from './memos'
export 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
freeze?: boolean
freeze_peer?: boolean
authorized?: boolean
peer_authorized?: boolean
}
export interface FormattedTrustlineSpecification {
currency: string
counterparty: string
limit: string
qualityIn?: number
qualityOut?: number
ripplingDisabled?: boolean
authorized?: boolean
frozen?: boolean
memos?: Memo[]
}
export interface FormattedTrustline {
specification: FormattedTrustlineSpecification
counterparty: {
limit: string
ripplingDisabled?: boolean
frozen?: boolean
authorized?: boolean
}
state: {
balance: string
}
}

View File

@@ -3,10 +3,6 @@ export { default as BroadcastClient } from './client/broadcastClient'
export { Client } from './client'
export * from './transaction/types'
export * from './common/types/objects/ledger'
export * from './models/methods'
export * from './models/transactions'

View File

@@ -1,6 +1,5 @@
import { OfferCreateTransaction } from '../../common/types/objects'
import type { Amount, Currency, Path, StreamType } from '../common'
import { Transaction } from '../transactions'
import { OfferCreate, Transaction } from '../transactions'
import TransactionMetadata from '../transactions/metadata'
import type { BaseRequest, BaseResponse } from './baseMethod'
@@ -88,7 +87,7 @@ export interface PeerStatusStream extends BaseStream {
ledger_index_min?: number
}
interface ModifiedOfferCreateTransaction extends OfferCreateTransaction {
interface ModifiedOfferCreateTransaction extends OfferCreate {
owner_funds: string
}

View File

@@ -1,38 +0,0 @@
export interface Submit {
success: boolean
engineResult: string
engineResultCode: number
engineResultMessage?: string
txBlob?: string
txJson?: object
}
export interface KeyPair {
publicKey: string
privateKey: string
}
export interface SignOptions {
signAs: string
}
export interface Outcome {
result: string
ledgerVersion: number
indexInLedger: number
fee: string
balanceChanges: {
[key: string]: Array<{
currency: string
counterparty?: string
value: string
}>
}
orderbookChanges: object
deliveredAmount?: {
currency: string
counterparty?: string
value: string
}
timestamp?: string
}

View File

@@ -15,9 +15,6 @@ import {
xAddressToClassicAddress,
} from 'ripple-address-codec'
import { ValidationError } from '../common/errors'
import { RippledAmount } from '../common/types/objects'
import { deriveKeypair, deriveXAddress } from './derive'
import { generateXAddress } from './generateAddress'
import {
@@ -54,47 +51,6 @@ function isValidSecret(secret: string): boolean {
}
}
/**
* TODO: Remove/rename this function.
*
* @param amount - Convert an Amount in.
* @returns Amount without X-Address issuer.
* @throws When issuer X-Address includes a tag.
*/
function toRippledAmount(amount: RippledAmount): RippledAmount {
if (typeof amount === 'string') {
return amount
}
if (amount.currency === 'XRP') {
return xrpToDrops(amount.value)
}
if (amount.currency === 'drops') {
return amount.value
}
let issuer = amount.counterparty ?? amount.issuer
let tag: number | false = false
try {
if (issuer) {
;({ classicAddress: issuer, tag } = xAddressToClassicAddress(issuer))
}
} catch (_e) {
/* not an X-address */
}
if (tag !== false) {
throw new ValidationError('Issuer X-address includes a tag')
}
return {
currency: amount.currency,
issuer,
value: amount.value,
}
}
/**
* Removes undefined values from an object.
*
@@ -121,7 +77,6 @@ function convertStringToHex(string: string): string {
export {
dropsToXrp,
xrpToDrops,
toRippledAmount,
removeUndefined,
rippleTimeToISOTime,
ISOTimeToRippleTime,