Skip to content
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

feat: codegen types for account_info and payment #2816

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/xrpl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@scure/bip32": "^1.3.1",
"@scure/bip39": "^1.2.1",
"@xrpl/openapi": "^1.0.1",
justinr1234 marked this conversation as resolved.
Show resolved Hide resolved
"@xrplf/isomorphic": "^1.0.1",
"@xrplf/secret-numbers": "^1.0.0",
"bignumber.js": "^9.0.0",
Expand Down
235 changes: 7 additions & 228 deletions packages/xrpl/src/models/methods/accountInfo.ts
Original file line number Diff line number Diff line change
@@ -1,228 +1,7 @@
import { APIVersion, DEFAULT_API_VERSION, RIPPLED_API_V1 } from '../common'
import { AccountRoot, SignerList } from '../ledger'

import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'

/**
* The `account_info` command retrieves information about an account, its
* activity, and its XRP balance. All information retrieved is relative to a
* particular version of the ledger. Returns an {@link AccountInfoResponse}.
*
* @category Requests
*/
export interface AccountInfoRequest extends BaseRequest, LookupByLedgerRequest {
command: 'account_info'
/** A unique identifier for the account, most commonly the account's address. */
account: string
/**
* Whether to get info about this account's queued transactions. Can only be
* used when querying for the data from the current open ledger. Not available
* from servers in Reporting Mode.
*/
queue?: boolean
/**
* Request SignerList objects associated with this account.
*/
signer_lists?: boolean
/**
* If true, then the account field only accepts a public key or XRP Ledger
* address. Otherwise, account can be a secret or passphrase (not
* recommended). The default is false.
*/
strict?: boolean
}

export interface AccountQueueTransaction {
/**
* Whether this transaction changes this address's ways of authorizing
* transactions.
*/
auth_change: boolean
/** The Transaction Cost of this transaction, in drops of XRP. */
fee: string
/**
* The transaction cost of this transaction, relative to the minimum cost for
* this type of transaction, in fee levels.
*/
fee_level: string
/** The maximum amount of XRP, in drops, this transaction could send or destroy. */
max_spend_drops: string
/** The Sequence Number of this transaction. */
seq: number
}

export interface AccountQueueData {
/** Number of queued transactions from this address. */
txn_count: number
/**
* Whether a transaction in the queue changes this address's ways of
* authorizing transactions. If true, this address can queue no further
* transactions until that transaction has been executed or dropped from the
* queue.
*/
auth_change_queued?: boolean
/** The lowest Sequence Number among transactions queued by this address. */
lowest_sequence?: number
/** The highest Sequence Number among transactions queued by this address. */
highest_sequence?: number
/**
* Integer amount of drops of XRP that could be debited from this address if
* every transaction in the queue consumes the maximum amount of XRP possible.
*/
max_spend_drops_total?: string
/** Information about each queued transaction from this address. */
transactions?: AccountQueueTransaction[]
}

export interface AccountInfoAccountFlags {
/**
* Enable rippling on this address's trust lines by default. Required for issuing addresses; discouraged for others.
*/
defaultRipple: boolean
/**
* This account can only receive funds from transactions it sends, and from preauthorized accounts.
* (It has DepositAuth enabled.)
*/
depositAuth: boolean
/**
* Disallows use of the master key to sign transactions for this account.
*/
disableMasterKey: boolean
/**
* Disallow incoming Checks from other accounts.
*/
disallowIncomingCheck?: boolean
/**
* Disallow incoming NFTOffers from other accounts. Part of the DisallowIncoming amendment.
*/
disallowIncomingNFTokenOffer?: boolean
/**
* Disallow incoming PayChannels from other accounts. Part of the DisallowIncoming amendment.
*/
disallowIncomingPayChan?: boolean
/**
* Disallow incoming Trustlines from other accounts. Part of the DisallowIncoming amendment.
*/
disallowIncomingTrustline?: boolean
/**
* Client applications should not send XRP to this account. Not enforced by rippled.
*/
disallowIncomingXRP: boolean
/**
* All assets issued by this address are frozen.
*/
globalFreeze: boolean
/**
* This address cannot freeze trust lines connected to it. Once enabled, cannot be disabled.
*/
noFreeze: boolean
/**
* The account has used its free SetRegularKey transaction.
*/
passwordSpent: boolean
/**
* This account must individually approve other users for those users to hold this account's issued currencies.
*/
requireAuthorization: boolean
/**
* Requires incoming payments to specify a Destination Tag.
*/
requireDestinationTag: boolean
/**
* This address can claw back issued IOUs. Once enabled, cannot be disabled.
*/
allowTrustLineClawback: boolean
}

interface BaseAccountInfoResponse extends BaseResponse {
result: {
/**
* The AccountRoot ledger object with this account's information, as stored
* in the ledger.
*/
account_data: AccountRoot
/**
* A map of account flags parsed out. This will only be available for rippled nodes 1.11.0 and higher.
*/
account_flags?: AccountInfoAccountFlags
/**
* The ledger index of the current in-progress ledger, which was used when
* retrieving this information.
*/
ledger_current_index?: number
/**
* The ledger index of the ledger version used when retrieving this
* information. The information does not contain any changes from ledger
* versions newer than this one.
*/
ledger_index?: number
/**
* Information about queued transactions sent by this account. This
* information describes the state of the local rippled server, which may be
* different from other servers in the peer-to-peer XRP Ledger network. Some
* fields may be omitted because the values are calculated "lazily" by the
* queuing mechanism.
*/
queue_data?: AccountQueueData
/**
* True if this data is from a validated ledger version; if omitted or set
* to false, this data is not final.
*/
validated?: boolean
}
}

/**
* Response expected from a {@link AccountInfoRequest}.
*
* @category Responses
*/
export interface AccountInfoResponse extends BaseAccountInfoResponse {
result: BaseAccountInfoResponse['result'] & {
/**
* If requested, array of SignerList ledger objects associated with this account for Multi-Signing.
* Since an account can own at most one SignerList, this array must have exactly one
* member if it is present.
*/
signer_lists?: SignerList[]
}
}

/**
* Response expected from a {@link AccountInfoRequest} using API version 1.
*
* @category ResponsesV1
*/
export interface AccountInfoV1Response extends BaseAccountInfoResponse {
result: BaseAccountInfoResponse['result'] & {
/**
* The AccountRoot ledger object with this account's information, as stored
* in the ledger.
* If requested, also includes Array of SignerList ledger objects
* associated with this account for Multi-Signing. Since an account can own
* at most one SignerList, this array must have exactly one member if it is
* present.
*/
account_data: BaseAccountInfoResponse['result']['account_data'] & {
/**
* Array of SignerList ledger objects associated with this account for Multi-Signing.
* Since an account can own at most one SignerList, this array must have exactly one
* member if it is present.
* Quirk: In API version 1, this field is nested under account_data. For this method,
* Clio implements the API version 2 behavior where is field is not nested under account_data.
*/
signer_lists?: SignerList[]
}
}
}

/**
* Type to map between the API version and the response type.
*
* @category Responses
*/
export type AccountInfoVersionResponseMap<
Version extends APIVersion = typeof DEFAULT_API_VERSION,
> = Version extends typeof RIPPLED_API_V1
? AccountInfoV1Response
: AccountInfoResponse
export {
type AccountInfoRequest,
type AccountInfoResponseV1 as AccountInfoResponse,
type AccountFlags as AccountInfoAccountFlags,
type QueueData as AccountQueueData,
type Transactions as AccountQueueTransaction,
} from '@xrpl/openapi'
98 changes: 4 additions & 94 deletions packages/xrpl/src/models/methods/submit.ts
Original file line number Diff line number Diff line change
@@ -1,94 +1,4 @@
import { SubmittableTransaction } from '../transactions'

import { BaseRequest, BaseResponse } from './baseMethod'

/**
* The submit method applies a transaction and sends it to the network to be
* confirmed and included in future ledgers. Expects a response in the form of a
* {@link SubmitResponse}.
*
* @category Requests
*/
export interface SubmitRequest extends BaseRequest {
command: 'submit'
/** The complete transaction in hex string format. */
tx_blob: string
/**
* If true, and the transaction fails locally, do not retry or relay the
* transaction to other servers. The default is false.
*/
fail_hard?: boolean
}

/**
* Response expected from a {@link SubmitRequest}.
*
* @category Responses
*/
export interface SubmitResponse extends BaseResponse {
result: {
/**
* Text result code indicating the preliminary result of the transaction,
* for example `tesSUCCESS`.
*/
engine_result: string
/** Numeric version of the result code. */
engine_result_code: number
/** Human-readable explanation of the transaction's preliminary result. */
engine_result_message: string
/** The complete transaction in hex string format. */
tx_blob: string
/** The complete transaction in JSON format. */
tx_json: SubmittableTransaction & { hash?: string }
/**
* The value true indicates that the transaction was applied, queued,
* broadcast, or kept for later. The value `false` indicates that none of
* those happened, so the transaction cannot possibly succeed as long as you
* do not submit it again and have not already submitted it another time.
*/
accepted: boolean
/**
* The next Sequence Number available for the sending account after all
* pending and queued transactions.
*/
account_sequence_available: number
/**
* The next Sequence number for the sending account after all transactions
* that have been provisionally applied, but not transactions in the queue.
*/
account_sequence_next: number
/**
* The value true indicates that this transaction was applied to the open
* ledger. In this case, the transaction is likely, but not guaranteed, to
* be validated in the next ledger version.
*/
applied: boolean
/**
* The value true indicates this transaction was broadcast to peer servers
* in the peer-to-peer XRP Ledger network.
*/
broadcast: boolean
/**
* The value true indicates that the transaction was kept to be retried
* later.
*/
kept: boolean
/**
* The value true indicates the transaction was put in the Transaction
* Queue, which means it is likely to be included in a future ledger
* version.
*/
queued: boolean
/**
* The current open ledger cost before processing this transaction
* transactions with a lower cost are likely to be queued.
*/
open_ledger_cost: string
/**
* The ledger index of the newest validated ledger at the time of
* submission. This provides a lower bound on the ledger versions that the
* transaction can appear in as a result of this request.
*/
validated_ledger_index: number
}
}
export {
type SubmitRequestV1 as SubmitRequest,
type SubmitResponseV1 as SubmitResponse,
} from '@xrpl/openapi'
Loading